@openmrs/esm-ward-app 11.1.0 → 11.1.1-pre.8929
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/4064.js
CHANGED
|
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(rO).join(", ")}.
|
|
|
9
9
|
If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(i)}`),s&&l&&![rO.Array,rO.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${o}'. ${r}.
|
|
10
10
|
|
|
11
11
|
If you're the maintainer: the 'elements' key only works with '_type' equal to 'Array' or 'Object'. Received ${JSON.stringify(l)}`)}}function aa(e,n){return ao(n.map(({[e]:n})=>n).filter(e=>!!e))}function ao(e){return e.reduce((e,n)=>rQ(e,n),{})}function ai(e,n,t=""){for(let r of Object.keys(n)){let a=n[r],o=t+"."+r,i=e[r];if(!e.hasOwnProperty(r)){("extensionSlots"!==r||""===t)&&ah(o,`Unknown config key '${o}' provided. Ignoring.`);continue}(function e(n,t,r){al(r,n._type,t),ad(t)?n._type===rO.Object?function(n,t,r){if(n._elements)for(let a of Object.keys(t)){let o=t[a];e(n._elements,o,`${r}.${a}`)}}(n,t,r):n.hasOwnProperty("_default")||n.hasOwnProperty("_type")||ai(n,t,r):n._type===rO.Array&&function(n,t,r){if(al(r,rO.Array,t)){if(ap(n._elements))for(let a=0;a<t.length;a++)e(n._elements,t[a],`${r}[${a}]`);for(let e=0;e<t.length;e++)al(`${r}[${e}]`,n._elements?._type,t[e])}}(n,t,r)})(i,a,o)}}r2();function as(e,n,t=""){if(e){if(n!==e._default&&ac(t,e._validators,n),ad(n))for(let r of Object.keys(n)){let a=n[r],o=t+"."+r,i=e[r];e._type===rO.Object&&e._elements?as(e._elements,a,o):as(i,a,o)}else if(Array.isArray(n)&&e._elements)for(let r=0;r<n.length;r++)as(e._elements,n[r],`${t}[${r}]`)}}function al(e,n,t){return!n||ac(e,[{Array:rN,Boolean:rI,ConceptUuid:rF,Number:rB,Object:rR,String:rj,UUID:rF,PersonAttributeTypeUuid:rF,PatientIdentifierTypeUuid:rF}[n]],t)}function ac(e,n,t){let r=!0;if(n)try{for(let a of n){let n=a(t);if("string"==typeof n){let a="object"==typeof t?`Invalid configuration for ${e}: ${n}`:`Invalid configuration value ${t} for ${e}: ${n}`;ah(e,a),r=!1}}}catch(n){console.error(`Skipping invalid validator at "${e}". Encountered error
|
|
12
|
-
${n}`)}return r}let au=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let r=t[n],a=e[n];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=a._default);let e=a._elements;if(r&&ap(e)){if(a._type===rO.Array&&Array.isArray(r)){let a=r.map(n=>au(e,n));t[n]=a}else if(a._type===rO.Object)for(let n of Object.keys(r))r[n]=au(e,r[n])}}else if(ad(a)){let e=r??{};ad(e)&&(t[n]=au(a,e))}}return t};function ap(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ad(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let af=new Set;function ah(e,n){let t=`${e}:::${n}`;af||(af=new Set),af.has(t)||(console.error(n),af.add(t))}function am(e){e?af.forEach(n=>{n.startsWith(e)&&af.delete(n)}):af.clear()}function ag(){r0.forEach(e=>e()),r0.length=0,r2()}let ay={"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:rO.Object,_default:{},_validators:[rT(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=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: ${n.join(", ")}.`})]}},ab={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:rO.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:rO.String,_default:void 0}},...ay},a_=(e,n)=>rT(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),av=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return rT(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,r=t.exec(e);for(;r;){if(!n.includes(r[1]))return!1;r=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},a$=av([]),aw=e=>rT(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),aA={inRange:a_,isUrl:a$,isUrlWithTemplateParameters:av,oneOf:aw};var ak=t(2034);let ax=U("breadcrumbs",[]);function aC(e){return aE([e])}function aE(e){let n=[...aS(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ak.pathToRegexp)(e.matcher).regexp:(0,ak.pathToRegexp)(e.path).regexp,settings:e}))];ax.setState(n,!0)}function aS(){return ax.getState()}function aD(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=aD(e,t.join("/"));if(n)return n}}(e,n)}function az(e,n){if(e.length>0){let t=aD(e,n);if(t){let n=[t],r=aD(e,t.settings.parent);for(;void 0!==r;)n.push(r),r=aD(e,r.settings.parent);return n.reverse()}}return[]}function aM(e){return az(aS(),e)}var aP=Object.freeze({__proto__:null,get start(){return o2},get ensureJQuerySupport(){return oM},get setBootstrapMaxTime(){return od},get setMountMaxTime(){return of},get setUnmountMaxTime(){return oh},get setUnloadMaxTime(){return om},get registerApplication(){return oW},get unregisterApplication(){return oG},get getMountedApps(){return oj},get getAppStatus(){return oF},get unloadApplication(){return oU},get checkActivityFunctions(){return oV},get getAppNames(){return oR},get pathToActiveWhen(){return oK},get navigateToUrl(){return ow},get patchHistoryApi(){return oS},get triggerAppChange(){return oX},get addErrorHandler(){return aB},get removeErrorHandler(){return aj},get mountRootParcel(){return os},get NOT_LOADED(){return aL},get LOADING_SOURCE_CODE(){return aW},get NOT_BOOTSTRAPPED(){return aV},get BOOTSTRAPPING(){return aG},get NOT_MOUNTED(){return aU},get MOUNTING(){return aH},get UPDATING(){return aK},get LOAD_ERROR(){return aJ},get MOUNTED(){return aq},get UNLOADING(){return aZ},get UNMOUNTING(){return aY},get SKIP_BECAUSE_BROKEN(){return aX}}),aO=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,aT=!function(){try{var e=new aO("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:aO;let aN=[];function aI(e,n,t){let r=aF(e,n,t);aN.length?aN.forEach(e=>e(r)):setTimeout(()=>{throw r})}function aB(e){if("function"!=typeof e)throw Error(aR(28,!1));aN.push(e)}function aj(e){if("function"!=typeof e)throw Error(aR(29,!1));let n=!1;return aN=aN.filter(t=>{let r=t===e;return n=n||r,!r}),n}function aR(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function aF(e,n,t){let r,a=`${a3(n)} '${a1(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}r=e}else{console.warn(aR(30,!1,n.status,a1(n)));try{r=Error(a+JSON.stringify(e))}catch(n){r=e}}return r.appOrParcelName=a1(n),n.status=t,r}let aL="NOT_LOADED",aW="LOADING_SOURCE_CODE",aV="NOT_BOOTSTRAPPED",aG="BOOTSTRAPPING",aU="NOT_MOUNTED",aH="MOUNTING",aq="MOUNTED",aK="UPDATING",aY="UNMOUNTING",aZ="UNLOADING",aJ="LOAD_ERROR",aX="SKIP_BECAUSE_BROKEN";function aQ(e){return e.status===aq}function a0(e){try{return e.activeWhen(window.location)}catch(n){return aI(n,e,aX),!1}}function a1(e){return e.name}function a2(e){return!!e.unmountThisParcel}function a3(e){return a2(e)?"parcel":"application"}function a5(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function a4(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function a6(e){return e&&("function"==typeof e||Array.isArray(e)&&!a4(e,e=>"function"!=typeof e))}function a8(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let r=a3(e),a=a1(e);return function(e){return t.reduce((t,o,i)=>t.then(()=>{let t=o(e);return a7(t)?t:Promise.reject(aR(15,!1,r,a,n,i))}),Promise.resolve())}}function a7(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let a9=[];function oe(e,n){return Promise.resolve().then(()=>e.status!==aV?e:(e.status=aG,e.bootstrap?og(e,"bootstrap").then(t).catch(t=>{if(n)throw aF(t,e,aX);return aI(t,e,aX),e}):Promise.resolve().then(t)));function t(){return e.status=aU,e}}function on(e,n){return Promise.resolve().then(()=>{if(e.status!==aq)return e;return e.status=aY,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,r=>t().then(()=>{let t=Error(r.message);if(n)throw aF(t,e,aX);aI(t,e,aX)})).then(()=>e);function t(){return og(e,"unmount").then(()=>{e.status=aU},t=>{if(n)throw aF(t,e,aX);aI(t,e,aX)})}})}let ot=!1,or=!1;function oa(e,n){return Promise.resolve().then(()=>e.status!==aU?e:(ot||(window.dispatchEvent(new aT("single-spa:before-first-mount")),ot=!0),e.status=aH,og(e,"mount").then(()=>(e.status=aq,or||(window.dispatchEvent(new aT("single-spa:first-mount")),or=!0),e)).catch(t=>{return e.status=aq,on(e,!0).then(r,r);function r(){if(n)throw aF(t,e,aX);return aI(t,e,aX),e}})))}let oo=0,oi={parcels:{}};function os(){return ol.apply(oi,arguments)}function ol(e,n){let t,r,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(aR(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(aR(3,!1,typeof e.name));let i=oo++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(aR(4,!1,s,typeof n));if(!n.domElement)throw Error(aR(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:i,parcels:{},status:l?aW:aV,customProps:n,parentName:a1(o),unmountThisParcel:()=>f.then(()=>{if(u.status!==aq)throw Error(aR(6,!1,s,u.status));return on(u,!0)}).then(e=>(u.parentName&&delete o.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=aX,a(e),e})};o.parcels[i]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(aR(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(aR(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!a6(e.bootstrap))throw Error(aR(9,!1,s));if(!a6(e.mount))throw Error(aR(10,!1,s));if(!a6(e.unmount))throw Error(aR(11,!1,s));if(e.update&&!a6(e.update))throw Error(aR(12,!1,s));let n=a8(e,"bootstrap"),r=a8(e,"mount"),a=a8(e,"unmount");u.status=aV,u.name=s,u.bootstrap=n,u.mount=r,u.unmount=a,u.timeouts=oy(e.timeouts),e.update&&(u.update=a8(e,"update"),t.update=function(e){return u.customProps=e,oc(Promise.resolve().then(()=>{if(u.status!==aq)throw Error(aR(32,!1,a1(u)));return u.status=aK,og(u,"update").then(()=>(u.status=aq,u)).catch(e=>{throw aF(e,u,aX)})}))})})).then(()=>oe(u,!0)),f=d.then(()=>oa(u,!0)),h=new Promise((e,n)=>{r=e,a=n});return t={mount:()=>oc(Promise.resolve().then(()=>{if(u.status!==aU)throw Error(aR(13,!1,s,u.status));return o.parcels[i]=u,oa(u)})),unmount:()=>oc(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:oc(p),bootstrapPromise:oc(d),mountPromise:oc(f),unmountPromise:oc(h)}}function oc(e){return e.then(()=>null)}function ou(e){let n=a1(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(aR(40,!1),n,t));let r=a5({},t,{name:n,mountParcel:ol.bind(e),singleSpa:aP});return a2(e)&&(r.unmountSelf=e.unmountThisParcel),r}let op={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function od(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(16,!1));op.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function of(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(17,!1));op.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function oh(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(18,!1));op.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function om(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(19,!1));op.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function og(e,n){let t=e.timeouts[n],r=t.warningMillis,a=a3(e);return new Promise((o,i)=>{let s=!1,l=!1;e[n](ou(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),t.millis);let c=aR(31,!1,n,a,a1(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<t.millis&&setTimeout(()=>u(e+1),r)))}})}function oy(e){let n={};for(let t in op)n[t]=a5({},op[t],e&&e[t]||{});return n}function ob(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==aL&&e.status!==aJ?e:(e.status=aW,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(ou(e));if(!a7(r))throw t=!0,Error(aR(33,!1,a1(e)));return r.then(t=>{let r;e.loadErrorTime=null,"object"!=typeof(n=t)&&(r=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!a6(n.bootstrap)&&(r=35),a6(n.mount)||(r=36),a6(n.unmount)||(r=37);let a=a3(n);if(r){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(aR(r,!1,a,a1(e),t),n),aI(void 0,e,aX),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=a5({},e.devtools.overlays,n.devtools.overlays)),e.status=aV,e.bootstrap=a8(n,"bootstrap"),e.mount=a8(n,"mount"),e.unmount=a8(n,"unmount"),e.unload=a8(n,"unload"),e.timeouts=oy(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let r;return delete e.loadPromise,t?r=aX:(r=aJ,e.loadErrorTime=(new Date).getTime()),aI(n,e,r),e}))})}let o_="u">typeof window,ov={hashchange:[],popstate:[]},o$=["hashchange","popstate"];function ow(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(aR(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=oD(window.location.href),r=oD(n);0===n.indexOf("#")?window.location.hash=r.hash:t.host!==r.host&&r.host?window.location.href=n:r.pathname===t.pathname&&r.search===t.search?window.location.hash=r.hash:window.history.pushState(null,null,n)}function oA(e){if(e){let n=e[0].type;o$.indexOf(n)>=0&&ov[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ok(){oQ([],arguments)}function ox(e,n){return function(){let t=window.location.href,a=e.apply(this,arguments),o=window.location.href;return r&&t===o||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),a}}let oC=null,oE=!1;function oS(e){if(oE)throw Error(aR(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,oE=!0,oC=window.history.replaceState,window.addEventListener("hashchange",ok),window.addEventListener("popstate",ok);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&o$.indexOf(e)>=0)||a4(ov[e],e=>e===t))return n.apply(this,arguments);ov[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&o$.indexOf(e)>=0&&(ov[e]=ov[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=ox(window.history.pushState,"pushState"),window.history.replaceState=ox(oC,"replaceState")}function oD(e){let n=document.createElement("a");return n.href=e,n}o_&&(window.singleSpaNavigate?console.warn(aR(41,!1)):window.singleSpaNavigate=ow);let oz=!1;function oM(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!oz){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return oP.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return oP.call(this,t,window.removeEventListener,e,n,arguments)},oz=!0}}function oP(e,n,t,r,a){return"string"!=typeof t?e.apply(this,a):(t.split(/\s+/).forEach(e=>{o$.indexOf(e)>=0&&(n(e,r),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,a))}let oO={};function oT(e){return Promise.resolve().then(()=>{let n=oO[a1(e)];if(!n)return e;if(e.status===aL)return oN(e,n),e;if(e.status===aZ)return n.promise.then(()=>e);if(e.status!==aU&&e.status!==aJ)return e;let t=e.status===aJ?Promise.resolve():og(e,"unload");return e.status=aZ,t.then(()=>(oN(e,n),e)).catch(t=>(delete oO[a1(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,aI(t,e,aX),n.reject(t),e))})}function oN(e,n){delete oO[a1(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aL,n.resolve()}function oI(e,n,t,r){oO[a1(e)]={app:e,resolve:t,reject:r},Object.defineProperty(oO[a1(e)],"promise",{get:n})}let oB=[];function oj(){return oB.filter(aQ).map(a1)}function oR(){return oB.map(a1)}function oF(e){let n=a4(oB,n=>a1(n)===e);return n?n.status:null}let oL=!1;function oW(e,n,t,r){var a,o;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(aR(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(aR(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(aR(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(aR(24,!1));if(!oq(e.customProps))throw Error(aR(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,r){if("string"!=typeof e||0===e.length)throw Error(aR(20,!1));if(!n)throw Error(aR(23,!1));if("function"!=typeof t)throw Error(aR(24,!1));if(!oq(r))throw Error(aR(22,!1))}(e,n,t,r),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=r),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(o=i.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:oK(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(o1||oL||(oL=!0,setTimeout(()=>{o1||console.warn(aR(1,!1))},5e3)),-1!==oR().indexOf(l.name))throw Error(aR(21,!1,l.name));oB.push(a5({loadErrorTime:null,status:aL,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),o_&&(oM(),oQ())}function oV(e=window.location){return oB.filter(n=>n.activeWhen(e)).map(a1)}function oG(e){if(0===oB.filter(n=>a1(n)===e).length)throw Error(aR(25,!1,e));return(o_?oU(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=oB.map(a1).indexOf(e);oB.splice(n,1)})}function oU(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(aR(26,!1));let t=a4(oB,n=>a1(n)===e);if(!t)throw Error(aR(27,!1,e));let r=oO[a1(t)];if(n&&n.waitForUnmount){if(r)return r.promise;{let e=new Promise((n,r)=>{oI(t,()=>e,n,r)});return e}}{let e;return r?(e=r.promise,oH(t,r.resolve,r.reject)):e=new Promise((n,r)=>{oI(t,()=>e,n,r),oH(t,n,r)}),e}}function oH(e,n,t){Promise.resolve().then(()=>{if(a4(oV(),n=>n===a1(e)))return oX()}).then(()=>on(e).then(oT).then(()=>{n(),setTimeout(()=>{oQ()})})).catch(t)}function oq(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function oK(e,n){let t=function(e,n){let t=0,r=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],a=r&&"/"===t;(!r&&":"===t||a)&&o(n)}return o(e.length),RegExp(a,"i");function o(o){let i=e.slice(t,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=r?"[^/]+/?":i,o===e.length)if(r)n&&(a+="$");else{let e=n?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}r=!r,t=o}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let r=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(r)}}let oY=!1,oZ=[],oJ=o_&&window.location.href;function oX(){return oQ()}function oQ(e=[],n,t=!1){let r,a,o,i,s;if(oY)return new Promise((e,t)=>{oZ.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],a=[],o=[],i=[],s=(new Date).getTime(),oB.forEach(e=>{let n=e.status!==aX&&a0(e);switch(e.status){case aJ:n&&s-e.loadErrorTime>=200&&o.push(e);break;case aL:case aW:n&&o.push(e);break;case aV:case aU:!n&&oO[a1(e)]?r.push(e):n&&i.push(e);break;case aq:n||a.push(e)}}),{appsToUnload:r,appsToUnmount:a,appsToLoad:o,appsToMount:i}),d,f=[],h=oJ,m=oJ=window.location.href;return o1?(oY=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return oC.call(window.history,history.state,"",h.substring(location.origin.length)),oJ=location.href,oY=!1,oQ(e,n,!0);let r=l.map(oT),a=Promise.all(c.map(on).map(e=>e.then(oT)).concat(r));a.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let o=u.map(e=>ob(e).then(e=>o0(e,a))),i=p.filter(e=>0>u.indexOf(e)).map(e=>o0(e,a));return a.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(o.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(ob)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(aR(42,!1))),console.warn(e),!1)))}function y(){let n=oj();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(oY=!1,oZ.length>0){let e=oZ;oZ=[],oQ(e)}return n}function b(){t||(e.forEach(e=>{oA(e.eventArguments)}),oA(n))}function v(e=!1,t){let r={},a={[aq]:[],[aU]:[],[aL]:[],[aX]:[]};e?(u.concat(p).forEach((e,n)=>{i(e,aq)}),l.forEach(e=>{i(e,aL)}),c.forEach(e=>{i(e,aU)})):d.forEach(e=>{i(e)});let o={detail:{newAppStatuses:r,appsByNewStatus:a,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&a5(o.detail,t),o;function i(e,n){let t=a1(e);n=n||oF(t),r[t]=n,(a[n]=a[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new aT(`single-spa:${e}`,n))}}function o0(e,n){return a0(e)?oe(e).then(e=>n.then(()=>a0(e)?oa(e):e)):n.then(()=>e)}let o1=!1;function o2(e){o1=!0,o_&&(oS(e),oQ())}function o3(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return o5(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function o5(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function o4({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),r=o3(e,n).replace(window.location.origin,"");r.startsWith(t)?ow(r):window.location.assign(r)}o_&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...oB]},reroute:oQ,NOT_LOADED:aL,toLoadPromise:ob,toBootstrapPromise:oe,unregisterApplication:oG,getProfilerData:function(){return a9}});let o6="openmrs:history";function o8(e){let n=JSON.parse(sessionStorage.getItem(o6)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(o6,JSON.stringify(n))}function o7(){0===JSON.parse(sessionStorage.getItem(o6)??"[]").length&&document.referrer&&o8(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=o9();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(o6,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?ie({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&o8(window.location.href)})}function o9(){return JSON.parse(sessionStorage.getItem(o6)??"[]")}function ie({toUrl:e}){let n=o9(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);o4({to:n[t]}),sessionStorage.setItem(o6,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function it(){sessionStorage.removeItem(o6)}let ir="${openmrsSpaBase}/login",ia={redirectAuthFailure:{enabled:{_type:rO.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:rO.String,_default:ir,_validators:[aA.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:rO.Array,_default:[401],_elements:{_type:rO.Number,_validators:[aA.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:rO.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:rO.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function io(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let ii="/ws/rest/v1",is="/ws/fhir2/R4",il=`${ii}/session`;function ic(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function iu(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)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 t=ic(e);if(n.headers||(n.headers={}),eH(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(ii)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(is)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let r=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:a}=await r9("@openmrs/esm-api");if(e.ok)if(204!==e.status)return e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e});else{if(a&&e.headers.has("location")){let n=e.headers.get("location");n&&o4({to:n})}return e.data=null,e}return t===ic(il)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(it(),o4({to:n.url||e.headers.get("location")||ir}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let a=n;try{a=JSON.parse(n)}catch(e){}throw new id(t,e,a,r)},n=>{throw new id(t,e,null,r)})})}function ip(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new ex(r=>{let a=!1;return iu(e,n).then(e=>{a=!0,r.next(e),r.complete()},e=>{a=!0,r.error(e)}),()=>{a||t.abort()}})}class id extends Error{constructor(e,n,t,r){super(),io(this,"response",void 0),io(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
12
|
+
${n}`)}return r}let au=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let r=t[n],a=e[n];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=a._default);let e=a._elements;if(r&&ap(e)){if(a._type===rO.Array&&Array.isArray(r)){let a=r.map(n=>au(e,n));t[n]=a}else if(a._type===rO.Object)for(let n of Object.keys(r))r[n]=au(e,r[n])}}else if(ad(a)){let e=r??{};ad(e)&&(t[n]=au(a,e))}}return t};function ap(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ad(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let af=new Set;function ah(e,n){let t=`${e}:::${n}`;af||(af=new Set),af.has(t)||(console.error(n),af.add(t))}function am(e){e?af.forEach(n=>{n.startsWith(e)&&af.delete(n)}):af.clear()}function ag(){r0.forEach(e=>e()),r0.length=0,r2()}let ay={"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:rO.Object,_default:{},_validators:[rT(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=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: ${n.join(", ")}.`})]}},ab={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:rO.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:rO.String,_default:void 0}},...ay},a_=(e,n)=>rT(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),av=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return rT(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,r=t.exec(e);for(;r;){if(!n.includes(r[1]))return!1;r=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},a$=av([]),aw=e=>rT(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),aA={inRange:a_,isUrl:a$,isUrlWithTemplateParameters:av,oneOf:aw};var ak=t(2034);let ax=U("breadcrumbs",[]);function aC(e){return aE([e])}function aE(e){let n=[...aS(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ak.pathToRegexp)(e.matcher).regexp:(0,ak.pathToRegexp)(e.path).regexp,settings:e}))];ax.setState(n,!0)}function aS(){return ax.getState()}function aD(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=aD(e,t.join("/"));if(n)return n}}(e,n)}function az(e,n){if(e.length>0){let t=aD(e,n);if(t){let n=[t],r=aD(e,t.settings.parent);for(;void 0!==r;)n.push(r),r=aD(e,r.settings.parent);return n.reverse()}}return[]}function aM(e){return az(aS(),e)}var aP=Object.freeze({__proto__:null,get start(){return o2},get ensureJQuerySupport(){return oM},get setBootstrapMaxTime(){return od},get setMountMaxTime(){return of},get setUnmountMaxTime(){return oh},get setUnloadMaxTime(){return om},get registerApplication(){return oW},get unregisterApplication(){return oG},get getMountedApps(){return oj},get getAppStatus(){return oF},get unloadApplication(){return oU},get checkActivityFunctions(){return oV},get getAppNames(){return oR},get pathToActiveWhen(){return oK},get navigateToUrl(){return ow},get patchHistoryApi(){return oS},get triggerAppChange(){return oX},get addErrorHandler(){return aB},get removeErrorHandler(){return aj},get mountRootParcel(){return os},get NOT_LOADED(){return aL},get LOADING_SOURCE_CODE(){return aW},get NOT_BOOTSTRAPPED(){return aV},get BOOTSTRAPPING(){return aG},get NOT_MOUNTED(){return aU},get MOUNTING(){return aH},get UPDATING(){return aK},get LOAD_ERROR(){return aJ},get MOUNTED(){return aq},get UNLOADING(){return aZ},get UNMOUNTING(){return aY},get SKIP_BECAUSE_BROKEN(){return aX}}),aO=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,aT=!function(){try{var e=new aO("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:aO;let aN=[];function aI(e,n,t){let r=aF(e,n,t);aN.length?aN.forEach(e=>e(r)):setTimeout(()=>{throw r})}function aB(e){if("function"!=typeof e)throw Error(aR(28,!1));aN.push(e)}function aj(e){if("function"!=typeof e)throw Error(aR(29,!1));let n=!1;return aN=aN.filter(t=>{let r=t===e;return n=n||r,!r}),n}function aR(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function aF(e,n,t){let r,a=`${a3(n)} '${a1(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}r=e}else{console.warn(aR(30,!1,n.status,a1(n)));try{r=Error(a+JSON.stringify(e))}catch(n){r=e}}return r.appOrParcelName=a1(n),n.status=t,r}let aL="NOT_LOADED",aW="LOADING_SOURCE_CODE",aV="NOT_BOOTSTRAPPED",aG="BOOTSTRAPPING",aU="NOT_MOUNTED",aH="MOUNTING",aq="MOUNTED",aK="UPDATING",aY="UNMOUNTING",aZ="UNLOADING",aJ="LOAD_ERROR",aX="SKIP_BECAUSE_BROKEN";function aQ(e){return e.status===aq}function a0(e){try{return e.activeWhen(window.location)}catch(n){return aI(n,e,aX),!1}}function a1(e){return e.name}function a2(e){return!!e.unmountThisParcel}function a3(e){return a2(e)?"parcel":"application"}function a5(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function a4(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function a6(e){return e&&("function"==typeof e||Array.isArray(e)&&!a4(e,e=>"function"!=typeof e))}function a8(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let r=a3(e),a=a1(e);return function(e){return t.reduce((t,o,i)=>t.then(()=>{let t=o(e);return a7(t)?t:Promise.reject(aR(15,!1,r,a,n,i))}),Promise.resolve())}}function a7(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let a9=[];function oe(e,n){return Promise.resolve().then(()=>e.status!==aV?e:(e.status=aG,e.bootstrap?og(e,"bootstrap").then(t).catch(t=>{if(n)throw aF(t,e,aX);return aI(t,e,aX),e}):Promise.resolve().then(t)));function t(){return e.status=aU,e}}function on(e,n){return Promise.resolve().then(()=>{if(e.status!==aq)return e;return e.status=aY,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,r=>t().then(()=>{let t=Error(r.message);if(n)throw aF(t,e,aX);aI(t,e,aX)})).then(()=>e);function t(){return og(e,"unmount").then(()=>{e.status=aU},t=>{if(n)throw aF(t,e,aX);aI(t,e,aX)})}})}let ot=!1,or=!1;function oa(e,n){return Promise.resolve().then(()=>e.status!==aU?e:(ot||(window.dispatchEvent(new aT("single-spa:before-first-mount")),ot=!0),e.status=aH,og(e,"mount").then(()=>(e.status=aq,or||(window.dispatchEvent(new aT("single-spa:first-mount")),or=!0),e)).catch(t=>{return e.status=aq,on(e,!0).then(r,r);function r(){if(n)throw aF(t,e,aX);return aI(t,e,aX),e}})))}let oo=0,oi={parcels:{}};function os(){return ol.apply(oi,arguments)}function ol(e,n){let t,r,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(aR(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(aR(3,!1,typeof e.name));let i=oo++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(aR(4,!1,s,typeof n));if(!n.domElement)throw Error(aR(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:i,parcels:{},status:l?aW:aV,customProps:n,parentName:a1(o),unmountThisParcel:()=>f.then(()=>{if(u.status!==aq)throw Error(aR(6,!1,s,u.status));return on(u,!0)}).then(e=>(u.parentName&&delete o.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=aX,a(e),e})};o.parcels[i]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(aR(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(aR(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!a6(e.bootstrap))throw Error(aR(9,!1,s));if(!a6(e.mount))throw Error(aR(10,!1,s));if(!a6(e.unmount))throw Error(aR(11,!1,s));if(e.update&&!a6(e.update))throw Error(aR(12,!1,s));let n=a8(e,"bootstrap"),r=a8(e,"mount"),a=a8(e,"unmount");u.status=aV,u.name=s,u.bootstrap=n,u.mount=r,u.unmount=a,u.timeouts=oy(e.timeouts),e.update&&(u.update=a8(e,"update"),t.update=function(e){return u.customProps=e,oc(Promise.resolve().then(()=>{if(u.status!==aq)throw Error(aR(32,!1,a1(u)));return u.status=aK,og(u,"update").then(()=>(u.status=aq,u)).catch(e=>{throw aF(e,u,aX)})}))})})).then(()=>oe(u,!0)),f=d.then(()=>oa(u,!0)),h=new Promise((e,n)=>{r=e,a=n});return t={mount:()=>oc(Promise.resolve().then(()=>{if(u.status!==aU)throw Error(aR(13,!1,s,u.status));return o.parcels[i]=u,oa(u)})),unmount:()=>oc(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:oc(p),bootstrapPromise:oc(d),mountPromise:oc(f),unmountPromise:oc(h)}}function oc(e){return e.then(()=>null)}function ou(e){let n=a1(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(aR(40,!1),n,t));let r=a5({},t,{name:n,mountParcel:ol.bind(e),singleSpa:aP});return a2(e)&&(r.unmountSelf=e.unmountThisParcel),r}let op={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function od(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(16,!1));op.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function of(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(17,!1));op.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function oh(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(18,!1));op.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function om(e,n,t){if("number"!=typeof e||e<=0)throw Error(aR(19,!1));op.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function og(e,n){let t=e.timeouts[n],r=t.warningMillis,a=a3(e);return new Promise((o,i)=>{let s=!1,l=!1;e[n](ou(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),t.millis);let c=aR(31,!1,n,a,a1(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<t.millis&&setTimeout(()=>u(e+1),r)))}})}function oy(e){let n={};for(let t in op)n[t]=a5({},op[t],e&&e[t]||{});return n}function ob(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==aL&&e.status!==aJ?e:(e.status=aW,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(ou(e));if(!a7(r))throw t=!0,Error(aR(33,!1,a1(e)));return r.then(t=>{let r;e.loadErrorTime=null,"object"!=typeof(n=t)&&(r=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!a6(n.bootstrap)&&(r=35),a6(n.mount)||(r=36),a6(n.unmount)||(r=37);let a=a3(n);if(r){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(aR(r,!1,a,a1(e),t),n),aI(void 0,e,aX),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=a5({},e.devtools.overlays,n.devtools.overlays)),e.status=aV,e.bootstrap=a8(n,"bootstrap"),e.mount=a8(n,"mount"),e.unmount=a8(n,"unmount"),e.unload=a8(n,"unload"),e.timeouts=oy(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let r;return delete e.loadPromise,t?r=aX:(r=aJ,e.loadErrorTime=(new Date).getTime()),aI(n,e,r),e}))})}let o_="u">typeof window,ov={hashchange:[],popstate:[]},o$=["hashchange","popstate"];function ow(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(aR(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=oD(window.location.href),r=oD(n);0===n.indexOf("#")?window.location.hash=r.hash:t.host!==r.host&&r.host?window.location.href=n:r.pathname===t.pathname&&r.search===t.search?window.location.hash=r.hash:window.history.pushState(null,null,n)}function oA(e){if(e){let n=e[0].type;o$.indexOf(n)>=0&&ov[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ok(){oQ([],arguments)}function ox(e,n){return function(){let t=window.location.href,a=e.apply(this,arguments),o=window.location.href;return r&&t===o||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),a}}let oC=null,oE=!1;function oS(e){if(oE)throw Error(aR(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,oE=!0,oC=window.history.replaceState,window.addEventListener("hashchange",ok),window.addEventListener("popstate",ok);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&o$.indexOf(e)>=0)||a4(ov[e],e=>e===t))return n.apply(this,arguments);ov[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&o$.indexOf(e)>=0&&(ov[e]=ov[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=ox(window.history.pushState,"pushState"),window.history.replaceState=ox(oC,"replaceState")}function oD(e){let n=document.createElement("a");return n.href=e,n}o_&&(window.singleSpaNavigate?console.warn(aR(41,!1)):window.singleSpaNavigate=ow);let oz=!1;function oM(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!oz){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return oP.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return oP.call(this,t,window.removeEventListener,e,n,arguments)},oz=!0}}function oP(e,n,t,r,a){return"string"!=typeof t?e.apply(this,a):(t.split(/\s+/).forEach(e=>{o$.indexOf(e)>=0&&(n(e,r),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,a))}let oO={};function oT(e){return Promise.resolve().then(()=>{let n=oO[a1(e)];if(!n)return e;if(e.status===aL)return oN(e,n),e;if(e.status===aZ)return n.promise.then(()=>e);if(e.status!==aU&&e.status!==aJ)return e;let t=e.status===aJ?Promise.resolve():og(e,"unload");return e.status=aZ,t.then(()=>(oN(e,n),e)).catch(t=>(delete oO[a1(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,aI(t,e,aX),n.reject(t),e))})}function oN(e,n){delete oO[a1(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aL,n.resolve()}function oI(e,n,t,r){oO[a1(e)]={app:e,resolve:t,reject:r},Object.defineProperty(oO[a1(e)],"promise",{get:n})}let oB=[];function oj(){return oB.filter(aQ).map(a1)}function oR(){return oB.map(a1)}function oF(e){let n=a4(oB,n=>a1(n)===e);return n?n.status:null}let oL=!1;function oW(e,n,t,r){var a,o;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(aR(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(aR(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(aR(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(aR(24,!1));if(!oq(e.customProps))throw Error(aR(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,r){if("string"!=typeof e||0===e.length)throw Error(aR(20,!1));if(!n)throw Error(aR(23,!1));if("function"!=typeof t)throw Error(aR(24,!1));if(!oq(r))throw Error(aR(22,!1))}(e,n,t,r),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=r),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(o=i.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:oK(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(o1||oL||(oL=!0,setTimeout(()=>{o1||console.warn(aR(1,!1))},5e3)),-1!==oR().indexOf(l.name))throw Error(aR(21,!1,l.name));oB.push(a5({loadErrorTime:null,status:aL,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),o_&&(oM(),oQ())}function oV(e=window.location){return oB.filter(n=>n.activeWhen(e)).map(a1)}function oG(e){if(0===oB.filter(n=>a1(n)===e).length)throw Error(aR(25,!1,e));return(o_?oU(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=oB.map(a1).indexOf(e);oB.splice(n,1)})}function oU(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(aR(26,!1));let t=a4(oB,n=>a1(n)===e);if(!t)throw Error(aR(27,!1,e));let r=oO[a1(t)];if(n&&n.waitForUnmount){if(r)return r.promise;{let e=new Promise((n,r)=>{oI(t,()=>e,n,r)});return e}}{let e;return r?(e=r.promise,oH(t,r.resolve,r.reject)):e=new Promise((n,r)=>{oI(t,()=>e,n,r),oH(t,n,r)}),e}}function oH(e,n,t){Promise.resolve().then(()=>{if(a4(oV(),n=>n===a1(e)))return oX()}).then(()=>on(e).then(oT).then(()=>{n(),setTimeout(()=>{oQ()})})).catch(t)}function oq(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function oK(e,n){let t=function(e,n){let t=0,r=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],a=r&&"/"===t;(!r&&":"===t||a)&&o(n)}return o(e.length),RegExp(a,"i");function o(o){let i=e.slice(t,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=r?"[^/]+/?":i,o===e.length)if(r)n&&(a+="$");else{let e=n?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}r=!r,t=o}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let r=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(r)}}let oY=!1,oZ=[],oJ=o_&&window.location.href;function oX(){return oQ()}function oQ(e=[],n,t=!1){let r,a,o,i,s;if(oY)return new Promise((e,t)=>{oZ.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],a=[],o=[],i=[],s=(new Date).getTime(),oB.forEach(e=>{let n=e.status!==aX&&a0(e);switch(e.status){case aJ:n&&s-e.loadErrorTime>=200&&o.push(e);break;case aL:case aW:n&&o.push(e);break;case aV:case aU:!n&&oO[a1(e)]?r.push(e):n&&i.push(e);break;case aq:n||a.push(e)}}),{appsToUnload:r,appsToUnmount:a,appsToLoad:o,appsToMount:i}),d,f=[],h=oJ,m=oJ=window.location.href;return o1?(oY=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return oC.call(window.history,history.state,"",h.substring(location.origin.length)),oJ=location.href,oY=!1,oQ(e,n,!0);let r=l.map(oT),a=Promise.all(c.map(on).map(e=>e.then(oT)).concat(r));a.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let o=u.map(e=>ob(e).then(e=>o0(e,a))),i=p.filter(e=>0>u.indexOf(e)).map(e=>o0(e,a));return a.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(o.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(ob)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(aR(42,!1))),console.warn(e),!1)))}function y(){let n=oj();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(oY=!1,oZ.length>0){let e=oZ;oZ=[],oQ(e)}return n}function b(){t||(e.forEach(e=>{oA(e.eventArguments)}),oA(n))}function v(e=!1,t){let r={},a={[aq]:[],[aU]:[],[aL]:[],[aX]:[]};e?(u.concat(p).forEach((e,n)=>{i(e,aq)}),l.forEach(e=>{i(e,aL)}),c.forEach(e=>{i(e,aU)})):d.forEach(e=>{i(e)});let o={detail:{newAppStatuses:r,appsByNewStatus:a,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&a5(o.detail,t),o;function i(e,n){let t=a1(e);n=n||oF(t),r[t]=n,(a[n]=a[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new aT(`single-spa:${e}`,n))}}function o0(e,n){return a0(e)?oe(e).then(e=>n.then(()=>a0(e)?oa(e):e)):n.then(()=>e)}let o1=!1;function o2(e){o1=!0,o_&&(oS(e),oQ())}function o3(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return o5(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function o5(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function o4({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),r=o3(e,n).replace(window.location.origin,"");r.startsWith(t)?ow(r):window.location.assign(r)}o_&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...oB]},reroute:oQ,NOT_LOADED:aL,toLoadPromise:ob,toBootstrapPromise:oe,unregisterApplication:oG,getProfilerData:function(){return a9}});let o6="openmrs:history";function o8(e){let n=JSON.parse(sessionStorage.getItem(o6)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(o6,JSON.stringify(n))}function o7(){0===JSON.parse(sessionStorage.getItem(o6)??"[]").length&&document.referrer&&o8(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=o9();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(o6,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?ie({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&o8(window.location.href)})}function o9(){return JSON.parse(sessionStorage.getItem(o6)??"[]")}function ie({toUrl:e}){let n=o9(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);o4({to:n[t]}),sessionStorage.setItem(o6,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function it(){sessionStorage.removeItem(o6)}let ir="${openmrsSpaBase}/login",ia={redirectAuthFailure:{enabled:{_type:rO.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:rO.String,_default:ir,_validators:[aA.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:rO.Array,_default:[401],_elements:{_type:rO.Number,_validators:[aA.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:rO.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:rO.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function io(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let ii="/ws/rest/v1",is="/ws/fhir2/R4",il=`${ii}/session`;function ic(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function iu(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)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 t=ic(e);if(n.headers||(n.headers={}),eH(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(ii)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(is)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let r=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:a}=await r9("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(a&&n&&(t===ic(il)||204===e.status)&&o4({to:n}),204===e.status)?(e.data=null,e):e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e})}return t===ic(il)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(it(),o4({to:n.url||e.headers.get("location")||ir}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let a=n;try{a=JSON.parse(n)}catch(e){}throw new id(t,e,a,r)},n=>{throw new id(t,e,null,r)})})}function ip(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new ex(r=>{let a=!1;return iu(e,n).then(e=>{a=!0,r.next(e),r.complete()},e=>{a=!0,r.error(e)}),()=>{a||t.abort()}})}class id extends Error{constructor(e,n,t,r){super(),io(this,"response",void 0),io(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${r.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
15
|
${this.stack}`}}let ih=U("session",{loaded:!1,session:null}),im=0;function ig(e={includeAuthStatus:!0}){return(im<Date.now()-6e4||!ih.getState().loaded)&&i_(),new ex(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(ih.getState()),ih.subscribe(t)})}function iy(){return(im<Date.now()-6e4||!ih.getState().loaded)&&i_(),ih}function ib(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function i_(e,n){im=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),iC(iu(il,{headers:t}))}function iv(){ih.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function i$(e,n){var t,r;if(void 0===n)return!e;if(!e)return!0;return t=e,r=n,("string"==typeof t?!Z(r.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Z(r.privileges.find(n=>e===n.display))):(Z(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Z(n.roles.find(e=>"System Developer"===e.display))}function iw(){let e,n;return new Promise(t=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,t(r.session.user),n&&n())};r(ih.getState()),e||(n=ih.subscribe(r))})}function iA(){return new Promise((e,n)=>{ig().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function ik(e,n){return iC(iu(il,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function ix(e,n,t){return t||(t=new AbortController),await iu(`${ii}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),i_()}function iC(e){return new Promise((n,t)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},ih.setState(r),n(r)):(r={loaded:!1,session:null},ih.setState(r),t(r))}).catch(e=>{N(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};ih.setState(n),t(n)})})}function iE(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}ih.subscribe(e=>{e.loaded&&e.session&&ib(e.session)});let iS={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function iD(){r3("@openmrs/esm-api",ia),i_()}let iz={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",closeWorkspaces2PromptTitle:"Close workspace(s)",closeWorkspaces2PromptBody:"You are about to close the following workspace(s), which might have unsaved changes:",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"},iM=e=>"string"==typeof e,iP=()=>{let e,n,t=new Promise((t,r)=>{e=t,n=r});return t.resolve=e,t.reject=n,t},iO=e=>null==e?"":""+e,iT=/###/g,iN=e=>e&&e.indexOf("###")>-1?e.replace(iT,"."):e,iI=e=>!e||iM(e),iB=(e,n,t)=>{let r=iM(n)?n.split("."):n,a=0;for(;a<r.length-1;){if(iI(e))return{};let n=iN(r[a]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++a}return iI(e)?{}:{obj:e,k:iN(r[a])}},ij=(e,n,t)=>{let{obj:r,k:a}=iB(e,n,Object);if(void 0!==r||1===n.length){r[a]=t;return}let o=n[n.length-1],i=n.slice(0,n.length-1),s=iB(e,i,Object);for(;void 0===s.obj&&i.length;)o=`${i[i.length-1]}.${o}`,s=iB(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}`]=t},iR=(e,n)=>{let{obj:t,k:r}=iB(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,r))return t[r]},iF=(e,n,t)=>{for(let r in n)"__proto__"!==r&&"constructor"!==r&&(r in e?iM(e[r])||e[r]instanceof String||iM(n[r])||n[r]instanceof String?t&&(e[r]=n[r]):iF(e[r],n[r],t):e[r]=n[r]);return e};var iL={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let iW=e=>iM(e)?e.replace(/[&<>"'\/]/g,e=>iL[e]):e,iV=[" ",",","?","!",";"],iG=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),iU=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let r=n.split(t),a=e;for(let e=0;e<r.length;){let n;if(!a||"object"!=typeof a)return;let o="";for(let i=e;i<r.length;++i)if(i!==e&&(o+=t),o+=r[i],void 0!==(n=a[o])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<r.length-1)continue;e+=i-e+1;break}a=n}return a},iH=e=>e?.replace("_","-"),iq={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class iK{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||iq,this.options=n,this.debug=n.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,n,t,r){return r&&!this.debug?null:(iM(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new iK(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new iK(this.logger,e)}}var iY=new iK;class iZ{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let r=0;r<t;r++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,r])=>{for(let a=0;a<r;a++)t.apply(t,[e,...n])})}}class iJ extends iZ{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,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 n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,r={}){let a,o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,n],t&&(Array.isArray(t)?a.push(...t):iM(t)&&o?a.push(...t.split(o)):a.push(t)));let s=iR(this.data,a);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=a[0],n=a[1],t=a.slice(2).join(".")),!s&&i&&iM(t))?iU(this.data?.[e]?.[n],t,o):s}addResource(e,n,t,r,a={silent:!1}){let o=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(o?t.split(o):t)),e.indexOf(".")>-1&&(i=e.split("."),r=n,n=i[1]),this.addNamespaces(n),ij(this.data,i,r),a.silent||this.emit("added",e,n,t,r)}addResources(e,n,t,r={silent:!1}){for(let r in t)(iM(t[r])||Array.isArray(t[r]))&&this.addResource(e,n,r,t[r],{silent:!0});r.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,r,a,o={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),r=t,t=n,n=i[1]),this.addNamespaces(n);let s=iR(this.data,i)||{};o.skipCopy||(t=JSON.parse(JSON.stringify(t))),r?iF(s,t,a):s={...s,...t},ij(this.data,i,s),o.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var iX={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,r,a){return e.forEach(e=>{n=this.processors[e]?.process(n,t,r,a)??n}),n}};let iQ=Symbol("i18next/PATH_KEY");function i0(e,n){let t,r,a,{[iQ]:o}=e((r=[],(a=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===iQ)?r:(r.push(n),(t=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return o.join(n?.keySeparator??".")}let i1={},i2=e=>!iM(e)&&"boolean"!=typeof e&&"number"!=typeof e;class i3 extends iZ{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=iY.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let r=this.resolve(e,t);if(r?.res===void 0)return!1;let a=i2(r.res);return!1!==t.returnObjects||!a}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=n.ns||this.options.defaultNS||[],o=t&&e.indexOf(t)>-1,i=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let r=iV.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===r.length)return!0;let a=iG.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`),o=!a.test(e);if(!o){let n=e.indexOf(t);n>0&&!a.test(e.substring(0,n))&&(o=!0)}return o})(e,t,r);if(o&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:iM(a)?[a]:a};let o=e.split(t);(t!==r||t===r&&this.options.ns.indexOf(o[0])>-1)&&(a=o.shift()),e=o.join(r)}return{key:e,namespaces:iM(a)?[a]:a}}translate(e,n,t){let r="object"==typeof n?{...n}:n;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=i0(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],r),l=s[s.length-1],c=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let u=r.lng||this.language,p=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?a?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${c}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:i;let d=this.resolve(e,r),f=d?.res,h=d?.usedKey||i,m=d?.exactUsedKey||i,g=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==r.count&&!iM(r.count),v=i3.hasDefaultValue(r),$=b?this.pluralResolver.getSuffix(u,r.count,r):"",w=r.ordinal&&b?this.pluralResolver.getSuffix(u,r.count,{ordinal:!1}):"",A=b&&!r.ordinal&&0===r.count,k=A&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${$}`]||r[`defaultValue${w}`]||r.defaultValue,x=f;y&&!f&&v&&(x=k);let C=i2(x),E=Object.prototype.toString.apply(x);if(y&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(iM(g)&&Array.isArray(x))){if(!r.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(h,x,{...r,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(d.res=e,d.usedParams=this.getUsedParamsDetails(r),d):e}if(o){let e=Array.isArray(x),n=e?[]:{},t=e?m:h;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let a=`${t}${o}${e}`;v&&!f?n[e]=this.translate(a,{...r,defaultValue:i2(k)?k[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(a,{...r,joinArrays:!1,ns:s}),n[e]===a&&(n[e]=x[e])}f=n}}else if(y&&iM(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,r,t));else{let n=!1,a=!1;!this.isValidLookup(f)&&v&&(n=!0,f=k),this.isValidLookup(f)||(a=!0,f=i);let s=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:f,p=v&&k!==f&&this.options.updateMissing;if(a||n||p){if(this.logger.log(p?"updateKey":"missingKey",u,l,i,p?k:f),o){let e=this.resolve(i,{...r,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=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(r.lng||this.language):e.push(r.lng||this.language);let t=(e,n,t)=>{let a=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,a,p,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,a,p,r),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,r);A&&r[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],i+n,r[`defaultValue${n}`]||k)})}):t(e,i,k))}f=this.extendTranslation(f,e,r,d,t),a&&f===i&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${i}`),(a||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${i}`:i,n?f:void 0,r))}return a?(d.res=f,d.usedParams=this.getUsedParamsDetails(r),d):f}extendTranslation(e,n,t,r,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!t.skipInterpolation){let o;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=iM(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let n=e.match(this.interpolator.nestingRegexp);o=n&&n.length}let s=t.replace&&!iM(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||r.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);o<(n&&n.length)&&(t.nest=!1)}!t.lng&&r&&r.res&&(t.lng=this.language||r.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>a?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let o=t.postProcess||this.options.postProcess,i=iM(o)?[o]:o;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=iX.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,r,a,o,i;return iM(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;r=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let u=void 0!==n.count&&!iM(n.count),p=u&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(iM(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(i=e,!i1[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(i1[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${f.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!!!")),f.forEach(r=>{let i;if(this.isValidLookup(t))return;o=r;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,r,e,n);else{let e;u&&(e=this.pluralResolver.getSuffix(r,n.count,n));let t=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),p&&s.push(l+t)),d){let r=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(r),u&&(n.ordinal&&0===e.indexOf(a)&&s.push(r+e.replace(a,this.options.pluralSeparator)),s.push(r+e),p&&s.push(r+t))}}for(;i=s.pop();)this.isValidLookup(t)||(a=i,t=this.getResource(r,e,i,n))}))})}),{res:t,usedKey:r,exactUsedKey:a,usedLng:o,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,r):this.resourceStore.getResource(e,n,t,r)}getUsedParamsDetails(e={}){let n=e.replace&&!iM(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class i5{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=iY.create("languageUtils")}getScriptPartFromCode(e){if(!(e=iH(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=iH(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(iM(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n: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 n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return n=r;n=this.options.supportedLngs.find(e=>{if(e===r||!(0>e.indexOf("-")&&0>r.indexOf("-"))&&(e.indexOf("-")>0&&0>r.indexOf("-")&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),iM(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),r=[],a=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return iM(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))):iM(e)&&a(this.formatLanguageCode(e)),t.forEach(e=>{0>r.indexOf(e)&&a(this.formatLanguageCode(e))}),r}}let i4={zero:0,one:1,two:2,few:3,many:4,other:5},i6={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class i8{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=iY.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,r=iH("dev"===e?"en":e),a=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:a});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{t=new Intl.PluralRules(r,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),i6;if(!e.match(/-|_/))return i6;let r=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(r,n)}return this.pluralRulesCache[o]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>i4[e]-i4[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let r=this.getRule(e,t);return r?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${r.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let i7=(e,n,t,r=".",a=!0)=>{let o,i=void 0!==(o=iR(e,t))?o:iR(n,t);return!i&&a&&iM(t)&&void 0===(i=iU(e,t,r))&&(i=iU(n,t,r)),i};class i9{constructor(e={}){this.logger=iY.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:n,escapeValue:t,useRawValueToEscape:r,prefix:a,prefixEscaped:o,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==n?n:iW,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==r&&r,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"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,n,t,r){let a,o,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=i7(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,t,{...r,...n,interpolationkey:e}):a}let a=e.split(this.formatSeparator),o=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(i7(n,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...r,...n,interpolationkey:o})};this.resetRegExp();let c=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables!==void 0?r.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(n=>{for(i=0;a=n.regex.exec(e);){let t=a[1].trim();if(void 0===(o=l(t)))if("function"==typeof c){let n=c(e,a,r);o=iM(n)?n:""}else if(r&&Object.prototype.hasOwnProperty.call(r,t))o="";else if(u){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),o="";else iM(o)||this.useRawValueToEscape||(o=iO(o));let s=n.safeValue(o);if(e=e.replace(a[0],s),u?(n.regex.lastIndex+=o.length,n.regex.lastIndex-=a[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let r,a,o,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let r=e.split(RegExp(`${t}[ ]*{`)),a=`{${r[1]}`;e=r[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),n&&(o={...n,...o})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${a}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];(o=(o={...t}).replace&&!iM(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(s=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),(a=n(i.call(this,r[1].trim(),o),o))&&r[0]===e&&!iM(a))return a;iM(a)||(a=iO(a)),a||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:r[1].trim()}),a.trim())),e=e.replace(r[0],a),this.regexp.lastIndex=0}return e}}let se=e=>{let n={};return(t,r,a)=>{let o=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(o={...o,[a.interpolationkey]:void 0});let i=r+JSON.stringify(o),s=n[i];return s||(s=e(iH(r),a),n[i]=s),s(t)}},sn=e=>(n,t,r)=>e(iH(t),r)(n);class st{constructor(e={}){this.logger=iY.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?se:sn;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=se(n)}format(e,n,t,r={}){let a=n.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,n)=>{let{formatName:a,formatOptions:o}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let r=e.split("(");n=r[0].toLowerCase().trim();let a=r[1].substring(0,r[1].length-1);"currency"===n&&0>a.indexOf(":")?t.currency||(t.currency=a.trim()):"relativetime"===n&&0>a.indexOf(":")?t.range||(t.range=a.trim()):a.split(";").forEach(e=>{if(e){let[n,...r]=e.split(":"),a=r.join(":").trim().replace(/^'+|'+$/g,""),o=n.trim();t[o]||(t[o]=a),"false"===a&&(t[o]=!1),"true"===a&&(t[o]=!0),isNaN(a)||(t[o]=parseInt(a,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[a]){let n=e;try{let i=r?.formatParams?.[r.interpolationkey]||{},s=i.locale||i.lng||r.locale||r.lng||t;n=this.formats[a](e,s,{...o,...r,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class sr extends iZ{constructor(e,n,t,r={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=r,this.logger=iY.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,r.backend,r)}queueLoad(e,n,t,r){let a={},o={},i={},s={};return e.forEach(e=>{let r=!0;n.forEach(n=>{let i=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===o[i]&&(o[i]=!0):(this.state[i]=1,r=!1,void 0===o[i]&&(o[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[n]&&(s[n]=!0)))}),r||(i[e]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let r=e.split("|"),a=r[0],o=r[1];n&&this.emit("failedLoading",a,o,n),!n&&t&&this.store.addResourceBundle(a,o,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let i={};this.queue.forEach(t=>{((e,n,t,r)=>{let{obj:a,k:o}=iB(e,n,Object);a[o]=a[o]||[],a[o].push(t)})(t.loaded,[a],o),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{i[e]||(i[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===i[e][n]&&(i[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,r=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:r,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&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,r+1,2*a,o)},a):o(i,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>i(null,e)).catch(i):i(null,t)}catch(e){i(e)}return}return s(e,n,i)}prepareLoading(e,n,t={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();iM(e)&&(e=this.languageUtils.toResolveHierarchy(e)),iM(n)&&(n=[n]);let a=this.queueLoad(e,n,t,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),r=t[0],a=t[1];this.read(r,a,"read",void 0,void 0,(t,o)=>{t&&this.logger.warn(`${n}loading namespace ${a} for language ${r} failed`,t),!t&&o&&this.logger.log(`${n}loaded namespace ${a} for language ${r}`,o),this.loaded(e,t,o)})}saveMissing(e,n,t,r,a,o={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" 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!=t&&""!==t){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,n,t,r,s):l(e,n,t,r))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,n,t,r,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,r)}}}let sa=()=>({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 n={};if("object"==typeof e[1]&&(n=e[1]),iM(e[1])&&(n.defaultValue=e[1]),iM(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),so=e=>(iM(e.ns)&&(e.ns=[e.ns]),iM(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),iM(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),si=()=>{};class ss extends iZ{constructor(e={},n){if(super(),this.options=so(e),this.services={},this.logger=iY,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(iM(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=sa();this.options={...t,...this.options,...so(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?iY.init(r(this.modules.logger),this.options):iY.init(null,this.options),e=this.modules.formatter?this.modules.formatter:st;let n=new i5(this.options);this.store=new iJ(this.options.resources,this.options);let a=this.services;a.logger=iY,a.resourceStore=this.store,a.languageUtils=n,a.pluralResolver=new i8(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.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===t.interpolation.format)&&(a.formatter=r(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new i9(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new sr(r(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(a.languageDetector=r(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=r(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new i3(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=si),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]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let a=iP(),o=()=>{let e=(e,t)=>{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(t),n(e,t)};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,n=si){let t=n,r=iM(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};r?n(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let r=iP();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=si),this.services.backendConnector.reload(e,n,e=>{r.resolve(),t(e)}),r}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&&iX.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 n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=iP();this.emit("languageChanging",e);let r=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&&(r(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(a,(...e)=>this.t(...e))},o=n=>{e||n||!this.services.languageDetector||(n=[]);let t=iM(n)?n:n&&n[0],o=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(iM(n)?[n]:n);o&&(this.language||r(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()),t}getFixedT(e,n,t){let r=(e,n,...a)=>{let o,i;(o="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(a)):{...n}).lng=o.lng||r.lng,o.lngs=o.lngs||r.lngs,o.ns=o.ns||r.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||t||r.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=i0(e,{...this.options,...n})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=i0(e,{...this.options,...n})),i=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(i,o)};return iM(e)?r.lng=e:r.lngs=e,r.ns=n,r.keyPrefix=t,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){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 t=n.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let o=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(t,e)&&(!r||o(a,e)))}loadNamespaces(e,n){let t=iP();return this.options.ns?(iM(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=iP();iM(e)&&(e=[e]);let r=this.options.preload||[],a=e.filter(e=>0>r.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=r.concat(a),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new i5(sa());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(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new ss(e,n)}cloneInstance(e={},n=si){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let r={...this.options,...e,isClone:!0},a=new ss(r);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)},t&&(a.store=new iJ(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,r)=>(t[r]={...e[n][r]},t),e[n]),e),{}),r),a.services.resourceStore=a.store),a.translator=new i3(a.services,r),a.translator.on("*",(e,...n)=>{a.emit(e,...n)}),a.init(r,n),a.translator.options=r,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 sl=ss.createInstance();sl.createInstance=ss.createInstance,sl.createInstance,sl.dir,sl.init,sl.loadResources,sl.reloadResources,sl.use,sl.changeLanguage,sl.getFixedT,sl.t,sl.exists,sl.setDefaultNamespace,sl.hasLoadedNamespace,sl.loadNamespaces,sl.loadLanguages;let sc=sl.default||sl;function su(e,n,t,r){return sc.t(n,{ns:e,defaultValue:t,...r})}function sp(e,n,t){return iz[e]?su("core",e,n??iz[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}sc.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let sd="import-map-override:",sf="import-map-overrides-disabled",sh="import-map-overrides:change",sm=!1,sg=null;async function sy(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{if(r.src){let e=await fetch(r.src);n.push(await e.json())}else r.textContent&&n.push(JSON.parse(r.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return sb(n)}function sb(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function s_(){let e={};try{let n=sk();for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(sd)){let t=r.slice(sd.length);if(!n.includes(t)){let n=localStorage.getItem(r);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sv(){let e=await sy();return sm?sb([e,sg??s_()]):e}async function s$(){return sy()}async function sw(){return sm?sb([await sy(),s_()]):sy()}function sA(e){if(!sm)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(sd)){let n=localStorage.getItem(t);n&&(e[t.slice(sd.length)]=n)}}return{imports:e}}return s_()}function sk(){if(!sm)return[];try{let e=localStorage.getItem(sf);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function sx(e){return!!sm&&sk().includes(e)}function sC(e,n){if(!sm)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sd+e,n),window.dispatchEvent(new CustomEvent(sh))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sE(e){if(!sm)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sd+e);let n=sk().filter(n=>n!==e);n.length>0?localStorage.setItem(sf,JSON.stringify(n)):localStorage.removeItem(sf),window.dispatchEvent(new CustomEvent(sh))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sS(){if(!sm)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(sd)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sf),window.dispatchEvent(new CustomEvent(sh))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sD(e){if(!sm)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=sk().filter(n=>n!==e);n.length>0?localStorage.setItem(sf,JSON.stringify(n)):localStorage.removeItem(sf),window.dispatchEvent(new CustomEvent(sh))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sz=!1;function sM(){!sz&&(sz=!0,(sm="development"===window.spaEnv)&&(sg=s_()))}function sP(e){return e.replace(/[\/\-@]/g,"_")}async function sO(e,n="./start",r){var a;let o,i=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([sT(e,r?.importMap),new Promise((n,t)=>{o=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=i)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=sP(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(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function sT(e,n){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 t=sP(e);if(!window[t]){let t=n??await sN();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let r=t.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let a=e in sA().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let r=document.head.querySelector(`script[src="${e}"]`),a=window[sI];if(a||(a=window[sI]=new Set([])),r)if(a.has(e)){let e,a,o;o=()=>{e&&r.removeEventListener("load",e),a&&r.removeEventListener("error",a)},e=()=>{o(),n(null)},a=e=>{o(),t(e.message)},r.addEventListener("load",e),r.addEventListener("error",a)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let r,o,i;a.add(e);let s=document.createElement("script");s.src=e,s.type="text/javascript",s.async=!0;let l=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);i=()=>{clearTimeout(l),a.delete(e),r&&s.removeEventListener("load",r),o&&s.removeEventListener("error",o)},r=()=>{i(),n(null)},o=n=>{i();let r=`Failed to load script from ${e}`;console.error(r,n),t(n.message??r)},s.addEventListener("load",r),s.addEventListener("error",o),document.head.appendChild(s)}}(r,e,n)})}catch(e){return a&&z({kind:"error",title:sp("scriptLoadingFailed","Error: Script failed to load"),description:sp("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:r}),actionButtonLabel:sp("resetOverrides","Reset overrides"),onActionButtonClick(){sS(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sN(){return sv()}let sI=Symbol("__openmrs_script_loading");function sB(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function sj(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,n])=>"string"==typeof e&&sB(n))}let sR="openmrs-routes:",sF="openmrs-routes:change",sL=!1,sW=null;async function sV(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{let e;if(r.src){let n=await fetch(r.src);e=await n.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&sj(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return sG(n)}function sG(e){let n={};for(let t of e)t&&"object"==typeof t&&Object.assign(n,t);return n}async function sU(){let e={};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(sR)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(sR.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(sB(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),r=await n.json();if(sB(r))return{moduleName:e,routes:r};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function sH(){let e=await sV();return sL?sG([e,sW??await sU()]):e}async function sq(){return sV()}async function sK(){return sL?sG([await sV(),await sU()]):sV()}function sY(){if(!sL)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(sR)){let n=localStorage.getItem(t);n&&(e[t.slice(sR.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function sZ(e,n){if(!sL)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(sR+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!sB(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(sR+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(sR+e,JSON.stringify(n.toString()));else{if(!sB(n))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`,n);localStorage.setItem(sR+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(sF))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function sJ(e){if(!sL)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sR+e),window.dispatchEvent(new CustomEvent(sF))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function sX(){if(!sL)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(sR)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sF))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sQ=null;function s0(){return sQ||(sQ=(sL="development"===window.spaEnv)?sU().then(e=>{sW=e}):Promise.resolve())}let s1=`${ii}/attachment`;function s2(e,n){return iu(`${s1}/${e}`,{signal:n.signal})}function s3(e,n,t){return iu(`${s1}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function s5(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),iu(`${s1}`,{method:"POST",body:t})}function s4(e,n){return iu(`${s1}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function s6(e,n){return new Promise(function(t){var r=new MessageChannel;r.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[r.port2])})}function s8(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s7(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var s9=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function le(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var ln=function(e,n){this.type=e,Object.assign(this,n)};function lt(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function lr(){}var la={type:"SKIP_WAITING"};function lo(e,n){if(!n)return e&&e.then?e.then(lr):Promise.resolve()}var li=function(e){function n(n,t){var r,a;return void 0===t&&(t={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new s9,r.en=new s9,r.on=new s9,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,n=e.installing;r.tn>0||!le(n.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=n,e.removeEventListener("updatefound",r.cn)):(r.hn=n,r.an.add(n),r.rn.resolve(n)),++r.tn,n.addEventListener("statechange",r.ln)},r.ln=function(e){var n=r.fn,t=e.target,a=t.state,o=t===r.vn,i={sw:t,isExternal:o,originalEvent:e};!o&&r.mn&&(i.isUpdate=!0),r.dispatchEvent(new ln(a,i)),"installed"===a?r.wn=self.setTimeout(function(){"installed"===a&&n.waiting===t&&r.dispatchEvent(new ln("waiting",i))},200):"activating"===a&&(clearTimeout(r.wn),o||r.en.resolve(t))},r.dn=function(e){var n=r.hn,t=n!==navigator.serviceWorker.controller;r.dispatchEvent(new ln("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:r.mn})),t||r.on.resolve(n)},a=function(e){var n=e.data,t=e.ports,a=e.source;return lt(r.getSW(),function(){r.an.has(a)&&r.dispatchEvent(new ln("message",{data:n,originalEvent:e,ports:t,sw:a}))})},r.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(a.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=n,r.nn=t,navigator.serviceWorker.addEventListener("message",r.gn),r}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,r,a=n.prototype;return a.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var r,a,o,i=this;return r=function(){if(!t&&"complete"!==document.readyState)return lo(new Promise(function(e){return window.addEventListener("load",e)}))},a=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),lt(i.bn(),function(e){i.fn=e,i.yn&&(i.hn=i.yn,i.en.resolve(i.yn),i.on.resolve(i.yn),i.yn.addEventListener("statechange",i.ln,{once:!0}));var n=i.fn.waiting;return n&&le(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new ln("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),i.hn&&(i.rn.resolve(i.hn),i.an.add(i.hn)),i.fn.addEventListener("updatefound",i.cn),navigator.serviceWorker.addEventListener("controllerchange",i.dn),i.fn})},(o=r())&&o.then?o.then(a):a(o)}catch(e){return Promise.reject(e)}},a.update=function(){try{return this.fn?lo(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},a.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},a.messageSW=function(e){try{return lt(this.getSW(),function(n){return s6(n,e)})}catch(e){return Promise.reject(e)}},a.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&s6(this.fn.waiting,la)},a.pn=function(){var e=navigator.serviceWorker.controller;return e&&le(e.scriptURL,this.sn.toString())?e:void 0},a.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return lt(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},t=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],s8(n.prototype,t),r&&s8(n,r),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return s7(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s7(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function ls(e,n){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new li(e,n);return p=t.register().then(()=>t.controlling.then(()=>t))}function ll(){return p??Promise.resolve(void 0)}let lc="x-omrs-offline-response-body",lu="x-omrs-offline-response-status",lp="x-omrs-offline-caching-strategy";async function ld(e){let n=await ll();return n?await n.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function lf(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(n){if(n.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function lh(){return!window.indexedDB}async function lm(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function lg(){return await lm()||await lh()||await lf()}let ly="openmrs3:offline-mode",lb="unavailable";function l_(){return{current:lb,notAvailable:"unavailable"===lb,active:"on"===lb}}function lv(e){"unavailable"!==lb&&"unavailable"!==e&&(localStorage.setItem(ly,"on"===e?"active":"disabled"),lb=e)}async function l$(){await lg()||(lb="active"===localStorage.getItem(ly)?"on":"off"),navigator.onLine}let lw="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,lA=Object.keys,lk=Array.isArray;function lx(e,n){return"object"!=typeof n||lA(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||lw.Promise||(lw.Promise=Promise);let lC=Object.getPrototypeOf,lE={}.hasOwnProperty;function lS(e,n){return lE.call(e,n)}function lD(e,n){"function"==typeof n&&(n=n(lC(e))),("u"<typeof Reflect?lA:Reflect.ownKeys)(n).forEach(t=>{lM(e,t,n[t])})}let lz=Object.defineProperty;function lM(e,n,t,r){lz(e,n,lx(t&&lS(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},r))}function lP(e){return{from:function(n){return e.prototype=Object.create(n.prototype),lM(e.prototype,"constructor",e),{extend:lD.bind(null,e.prototype)}}}}let lO=Object.getOwnPropertyDescriptor;function lT(e,n){let t;return lO(e,n)||(t=lC(e))&&lT(t,n)}let lN=[].slice;function lI(e,n,t){return lN.call(e,n,t)}function lB(e,n){return n(e)}function lj(e){if(!e)throw Error("Assertion Failed")}function lR(e){lw.setImmediate?setImmediate(e):setTimeout(e,0)}function lF(e,n){return e.reduce((e,t,r)=>{var a=n(t,r);return a&&(e[a[0]]=a[1]),e},{})}function lL(e,n){if("string"==typeof n&&lS(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],r=0,a=n.length;r<a;++r){var o=lL(e,n[r]);t.push(o)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return null==s?void 0:lL(s,n.substr(i+1))}}function lW(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){lj("string"!=typeof t&&"length"in t);for(var r=0,a=n.length;r<a;++r)lW(e,n[r],t[r])}else{var o=n.indexOf(".");if(-1!==o){var i=n.substr(0,o),s=n.substr(o+1);if(""===s)void 0===t?lk(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&lS(e,i)||(l=e[i]={}),lW(l,s,t)}}else void 0===t?lk(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function lV(e){var n={};for(var t in e)lS(e,t)&&(n[t]=e[t]);return n}let lG=[].concat;function lU(e){return lG.apply([],e)}let lH="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(lU([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>lw[e]),lq=lH.map(e=>lw[e]);lF(lH,e=>[e,!0]);let lK=null;function lY(e){lK="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=lK&&lK.get(n);if(t)return t;if(lk(n)){t=[],lK&&lK.set(n,t);for(var r=0,a=n.length;r<a;++r)t.push(e(n[r]))}else if(lq.indexOf(n.constructor)>=0)t=n;else{let r=lC(n);for(var o in t=r===Object.prototype?{}:Object.create(r),lK&&lK.set(n,t),n)lS(n,o)&&(t[o]=e(n[o]))}return t}(e);return lK=null,n}let{toString:lZ}={};function lJ(e){return lZ.call(e).slice(8,-1)}let lX="u">typeof Symbol?Symbol.iterator:"@@iterator",lQ="symbol"==typeof lX?function(e){var n;return null!=e&&(n=e[lX])&&n.apply(e)}:function(){return null},l0={};function l1(e){var n,t,r,a;if(1==arguments.length){if(lk(e))return e.slice();if(this===l0&&"string"==typeof e)return[e];if(a=lQ(e)){for(t=[];!(r=a.next()).done;)t.push(r.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let l2="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var l3="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),l5=()=>!0;let l4=!Error("").stack;function l6(){if(l4)try{throw l6.arguments,Error()}catch(e){return e}return Error()}function l8(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(l5).map(e=>"\n"+e).join("")):""}var l7=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],l9=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(l7),ce={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function cn(e,n){this._e=l6(),this.name=e,this.message=n}function ct(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function cr(e,n,t,r){this._e=l6(),this.failures=n,this.failedKeys=r,this.successCount=t,this.message=ct(e,n)}function ca(e,n){this._e=l6(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=ct(e,n)}lP(cn).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+l8(this._e,2))}},toString:function(){return this.name+": "+this.message}}),lP(cr).from(cn),lP(ca).from(cn);var co=l9.reduce((e,n)=>(e[n]=n+"Error",e),{}),ci=l9.reduce((e,n)=>{var t=n+"Error";function r(e,r){this._e=l6(),this.name=t,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=ce[n]||t,this.inner=null)}return lP(r).from(cn),e[n]=r,e},{});ci.Syntax=SyntaxError,ci.Type=TypeError,ci.Range=RangeError;var cs=l7.reduce((e,n)=>(e[n+"Error"]=ci[n],e),{}),cl=l9.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=ci[n]),e),{});function cc(){}function cu(e){return e}function cp(e,n){return null==e||e===cu?n:function(t){return n(e(t))}}function cd(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function cf(e,n){return e===cc?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var r=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var o=n.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?cd(r,this.onsuccess):r),a&&(this.onerror=this.onerror?cd(a,this.onerror):a),void 0!==o?o:t}}function ch(e,n){return e===cc?n:function(){e.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?cd(t,this.onsuccess):t),r&&(this.onerror=this.onerror?cd(r,this.onerror):r)}}function cm(e,n){return e===cc?n:function(t){var r=e.apply(this,arguments);lx(t,r);var a=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?cd(a,this.onsuccess):a),o&&(this.onerror=this.onerror?cd(o,this.onerror):o),void 0===r?void 0===i?void 0:i:lx(r,i)}}function cg(e,n){return e===cc?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function cy(e,n){return e===cc?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var r=this,a=arguments.length,o=Array(a);a--;)o[a]=arguments[a];return t.then(function(){return n.apply(r,o)})}return n.apply(this,arguments)}}cl.ModifyError=cr,cl.DexieError=cn,cl.BulkError=ca;var cb={};let[c_,cv,c$]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,lC(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,lC(n),e]})(),cw=cv&&cv.then,cA=c_&&c_.constructor,ck=!!c$;var cx=!1,cC=c$?()=>{c$.then(cq)}:lw.setImmediate?setImmediate.bind(null,cq):lw.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{cq(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(cq,0)},cE=function(e,n){cI.push([e,n]),cD&&(cC(),cD=!1)},cS=!0,cD=!0,cz=[],cM=[],cP=null,cO=cu,cT={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:us,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{us(e[0],e[1])}catch(e){}})}},cN=cT,cI=[],cB=0,cj=[];function cR(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=cc,this._lib=!1;var n=this._PSD=cN;if(l3&&(this._stackHolder=l6(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==cb)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&cW(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var r=n._lib&&cK();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof cR?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,cV(n)),r&&cY()}},cW.bind(null,n))}catch(e){cW(n,e)}}(this,e)}let cF={get:function(){var e=cN,n=c3;function t(t,r){var a=!e.global&&(e!==cN||n!==c3);let o=a&&!c8();var i=new cR((n,i)=>{cG(this,new cL(ua(t,e,a,o),ua(r,e,a,o),n,i,e))});return l3&&cH(i,this),i}return t.prototype=cb,t},set:function(e){lM(this,"then",e&&e.prototype===cb?cF:{get:function(){return e},set:cF.set})}};function cL(e,n,t,r,a){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=r,this.psd=a}function cW(e,n){if(cM.push(n),null===e._state){var t=e._lib&&cK();n=cO(n),e._state=!1,e._value=n,l3&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=lT(n,"stack");n._promise=e,lM(n,"stack",{get:()=>cx?t&&(t.get?t.get.apply(n):t.value):e.stack})}),cz.some(n=>n._value===e._value)||cz.push(e),cV(e),t&&cY()}}function cV(e){var n=e._listeners;e._listeners=[];for(var t=0,r=n.length;t<r;++t)cG(e,n[t]);var a=e._PSD;--a.ref||a.finalize(),0===cB&&(++cB,cE(()=>{0==--cB&&cZ()},[]))}function cG(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++cB,cE(cU,[t,e,n])}else e._listeners.push(n)}function cU(e,n,t){try{cP=n;var r,a=n._value;n._state?r=e(a):(cM.length&&(cM=[]),r=e(a),-1===cM.indexOf(a)&&function(e){for(var n=cz.length;n;)if(cz[--n]._value===e._value)return void cz.splice(n,1)}(n)),t.resolve(r)}catch(e){t.reject(e)}finally{cP=null,0==--cB&&cZ(),--t.psd.ref||t.psd.finalize()}}function cH(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function cq(){cK()&&cY()}function cK(){var e=cS;return cS=!1,cD=!1,e}function cY(){var e,n,t;do for(;cI.length>0;)for(e=cI,cI=[],t=e.length,n=0;n<t;++n){var r=e[n];r[0].apply(null,r[1])}while(cI.length>0);cS=!0,cD=!0}function cZ(){var e=cz;cz=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=cj.slice(0),t=n.length;t;)n[--t]()}function cJ(e){return new cR(cb,!1,e)}function cX(e,n){var t=cN;return function(){var r=cK(),a=cN;try{return un(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{un(a,!1),r&&cY()}}}lD(cR.prototype,{then:cF,_then:function(e,n){cG(this,new cL(null,null,e,n,cN))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):cJ(e)):this.then(null,e=>e&&e.name===n?t(e):cJ(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),cJ(n)))},stack:{get:function(){if(this._stack)return this._stack;try{cx=!0;var e=(function e(n,t,r){if(t.length===r)return t;var a="";if(!1===n._state){var o,i,s=n._value;null!=s?(o=s.name||"Error",i=s.message||s,a=l8(s,0)):(o=s,i=""),t.push(o+(i?": "+i:"")+a)}return l3&&((a=l8(n._stackHolder,2))&&-1===t.indexOf(a)&&t.push(a),n._prev&&e(n._prev,t,r)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{cx=!1}}},timeout:function(e,n){return e<1/0?new cR((t,r)=>{var a=setTimeout(()=>r(new ci.Timeout(n)),e);this.then(t,r).finally(clearTimeout.bind(null,a))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&lM(cR.prototype,Symbol.toStringTag,"Dexie.Promise"),cT.env=ut(),lD(cR,{all:function(){var e=l1.apply(null,arguments).map(c7);return new cR(function(n,t){0===e.length&&n([]);var r=e.length;e.forEach((a,o)=>cR.resolve(a).then(t=>{e[o]=t,--r||n(e)},t))})},resolve:e=>{if(e instanceof cR)return e;if(e&&"function"==typeof e.then)return new cR((n,t)=>{e.then(n,t)});var n=new cR(cb,!0,e);return cH(n,cP),n},reject:cJ,race:function(){var e=l1.apply(null,arguments).map(c7);return new cR((n,t)=>{e.map(e=>cR.resolve(e).then(n,t))})},PSD:{get:()=>cN,set:e=>cN=e},totalEchoes:{get:()=>c3},newPSD:c4,usePSD:ur,scheduler:{get:()=>cE,set:e=>{cE=e}},rejectionMapper:{get:()=>cO,set:e=>{cO=e}},follow:(e,n)=>new cR((t,r)=>c4((n,t)=>{var r=cN;r.unhandleds=[],r.onunhandled=t,r.finalize=cd(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},cj.push(function n(){e(),cj.splice(cj.indexOf(n),1)}),++cB,cE(()=>{0==--cB&&cZ()},[])},r.finalize),e()},n,t,r))}),cA&&(cA.allSettled&&lM(cR,"allSettled",function(){let e=l1.apply(null,arguments).map(c7);return new cR(n=>{0===e.length&&n([]);let t=e.length,r=Array(t);e.forEach((e,a)=>cR.resolve(e).then(e=>r[a]={status:"fulfilled",value:e},e=>r[a]={status:"rejected",reason:e}).then(()=>--t||n(r)))})}),cA.any&&"u">typeof AggregateError&&lM(cR,"any",function(){let e=l1.apply(null,arguments).map(c7);return new cR((n,t)=>{0===e.length&&t(AggregateError([]));let r=e.length,a=Array(r);e.forEach((e,o)=>cR.resolve(e).then(e=>n(e),e=>{a[o]=e,--r||t(AggregateError(a))}))})}));let cQ={awaits:0,echoes:0,id:0};var c0=0,c1=[],c2=0,c3=0,c5=0;function c4(e,n,t,r){var a=cN,o=Object.create(a);o.parent=a,o.ref=0,o.global=!1,o.id=++c5;var i=cT.env;o.env=ck?{Promise:cR,PromiseProp:{value:cR,configurable:!0,writable:!0},all:cR.all,race:cR.race,allSettled:cR.allSettled,any:cR.any,resolve:cR.resolve,reject:cR.reject,nthen:uo(i.nthen,o),gthen:uo(i.gthen,o)}:{},n&&lx(o,n),++a.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=ur(o,e,t,r);return 0===o.ref&&o.finalize(),s}function c6(){return cQ.id||(cQ.id=++c0),++cQ.awaits,cQ.echoes+=100,cQ.id}function c8(){return!!cQ.awaits&&(0==--cQ.awaits&&(cQ.id=0),cQ.echoes=100*cQ.awaits,!0)}function c7(e){return cQ.echoes&&e&&e.constructor===cA?(c6(),e.then(e=>(c8(),e),e=>(c8(),ul(e)))):e}function c9(e){++c3,cQ.echoes&&0!=--cQ.echoes||(cQ.echoes=cQ.id=0),c1.push(cN),un(e,!0)}function ue(){var e=c1[c1.length-1];c1.pop(),un(e,!1)}function un(e,n){var t,r=cN;if((n?!cQ.echoes||c2++&&e===cN:!c2||--c2&&e===cN)||(t=n?c9.bind(null,e):ue,cw.call(c_,t)),e!==cN&&(cN=e,r===cT&&(cT.env=ut()),ck)){var a=cT.env.Promise,o=e.env;cv.then=o.nthen,a.prototype.then=o.gthen,(r.global||e.global)&&(Object.defineProperty(lw,"Promise",o.PromiseProp),a.all=o.all,a.race=o.race,a.resolve=o.resolve,a.reject=o.reject,o.allSettled&&(a.allSettled=o.allSettled),o.any&&(a.any=o.any))}}function ut(){var e=lw.Promise;return ck?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(lw,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:cv.then,gthen:e.prototype.then}:{}}function ur(e,n,t,r,a){var o=cN;try{return un(e,!0),n(t,r,a)}finally{un(o,!1)}}function ua(e,n,t,r){return"function"!=typeof e?e:function(){var a,o=cN;t&&c6(),un(n,!0);try{return e.apply(this,arguments)}finally{un(o,!1),r&&(a=c8,cw.call(c_,a))}}}function uo(e,n){return function(t,r){return e.call(this,ua(t,n),ua(r,n))}}-1===(""+cw).indexOf("[native code]")&&(c6=c8=cc);let ui="unhandledrejection";function us(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var r,a={promise:n,reason:e};if(lw.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ui,!0,!0),lx(r,a)):lw.CustomEvent&&lx(r=new CustomEvent(ui,{detail:a}),a),r&&lw.dispatchEvent&&(dispatchEvent(r),!lw.PromiseRejectionEvent&&lw.onunhandledrejection))try{lw.onunhandledrejection(r)}catch(e){}l3&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var ul=cR.reject;let uc="3.2.7",uu=String.fromCharCode(65535),up=-1/0,ud="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",uf="String expected.",uh=[],um="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),ug=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),uy="__dbnames",ub="readonly",u_="readwrite";function uv(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let u$={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function uw(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=lY(n))[e],n)}class uA{_trans(e,n,t){let r=this._tx||cN.trans,a=this.name;function o(e,t,r){if(!r.schema[a])throw new ci.NotFound("Table "+a+" not part of transaction");return n(r.idbtrans,r)}let i=cK();try{return r&&r.db===this.db?r===cN.trans?r._promise(e,o,t):c4(()=>r._promise(e,o,t),{trans:r,transless:cN.transless||cN}):function e(n,t,r,a){if(n.idbdb&&(n._state.openComplete||cN.letThrough||n._vip)){var o=n._createTransaction(t,r,n._dbSchema);try{o.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===co.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,a))):ul(o)}return o._promise(t,(e,n)=>c4(()=>(cN.trans=o,a(e,n,o)))).then(e=>o._completion.then(()=>e))}if(n._state.openComplete)return ul(new ci.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return ul(new ci.DatabaseClosed);n.open().catch(cc)}return n._state.dbReadyPromise.then(()=>e(n,t,r,a))}(this.db,e,[this.name],o)}finally{i&&cY()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(lk(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=lA(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>{if(e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)){for(let t=0;t<n.length;++t)if(-1===n.indexOf(e.keyPath[t]))return!1;return!0}return!1}).sort((e,n)=>e.keyPath.length-n.keyPath.length)[0];if(t&&this.db._maxKey!==uu){let r=t.keyPath.slice(0,n.length);return this.where(r).equals(r.map(n=>e[n]))}!t&&l3&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:r}=this.schema,a=this.db._deps.indexedDB;function o(e,n){try{return 0===a.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],a)=>{let i=r[a],s=e[a];return[n||i,n||!i?uv(t,i&&i.multi?e=>{let n=lL(e,a);return lk(n)&&n.some(e=>o(s,e))}:e=>o(s,lL(e,a))):t]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):t?this.filter(s):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,lk(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var r in n)if(lS(n,r))try{t[r]=n[r]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){lx(this,e)})}add(e,n){let{auto:t,keyPath:r}=this.schema.primKey,a=e;return r&&t&&(a=uw(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})).then(e=>e.numFailures?cR.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{lW(e,r,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||lk(e))return this.where(":id").equals(e).modify(n);{let t=lL(e,this.schema.primKey.keyPath);if(void 0===t)return ul(new ci.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?lA(n).forEach(t=>{lW(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:r}=this.schema.primKey,a=e;return r&&t&&(a=uw(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})).then(e=>e.numFailures?cR.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{lW(e,r,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?cR.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:u$})).then(e=>e.numFailures?cR.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let r=Array.isArray(n)?n:void 0,a=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:o}=this.schema.primKey;if(o&&r)throw new ci.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new ci.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=o&&t?e.map(uw(o)):e;return this.core.mutate({trans:n,type:"add",keys:r,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return a?n:t;throw new ca(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,r)})})}bulkPut(e,n,t){let r=Array.isArray(n)?n:void 0,a=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:o}=this.schema.primKey;if(o&&r)throw new ci.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new ci.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=o&&t?e.map(uw(o)):e;return this.core.mutate({trans:n,type:"put",keys:r,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return a?n:t;throw new ca(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,r)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:r})=>{if(0===e)return t;throw new ca(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,r)})}}function uk(e){var n={},t=function(t,r){if(r){for(var a=arguments.length,o=Array(a-1);--a;)o[a-1]=arguments[a];return n[t].subscribe.apply(null,o),e}if("string"==typeof t)return n[t]};t.addEventType=o;for(var r=1,a=arguments.length;r<a;++r)o(arguments[r]);return t;function o(e,r,a){if("object"!=typeof e){r||(r=cg),a||(a=cc);var i={subscribers:[],fire:a,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=r(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(r,a)}};return n[e]=t[e]=i,i}lA(e).forEach(function(n){var t=e[n];if(lk(t))o(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new ci.InvalidArgument("Invalid event config");var r=o(n,cu,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];r.subscribers.forEach(function(e){lR(function(){e.apply(null,n)})})})}})}}function ux(e,n){return lP(n).from({prototype:e}),n}function uC(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function uE(e,n){e.filter=uv(e.filter,n)}function uS(e,n,t){var r=e.replayFilter;e.replayFilter=r?()=>uv(r(),n()):n,e.justLimit=t&&!r}function uD(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new ci.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function uz(e,n,t){let r=uD(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function uM(e,n,t,r){let a=e.replayFilter?uv(e.filter,e.replayFilter()):e.filter;if(e.or){let o={},i=(e,t,r)=>{if(!a||a(t,r,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),lS(o,s)||(o[s]=!0,n(e,t,r))}};return Promise.all([e.or._iterate(i,t),uP(uz(e,r,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return uP(uz(e,r,t),uv(e.algorithm,a),n,!e.keysOnly&&e.valueMapper)}function uP(e,n,t,r){var a=cX(r?(e,n,a)=>t(r(e),n,a):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=cc},n=>{e.fail(n),t=cc})||a(e.value,e,e=>t=e),t()})})}function uO(e,n){try{let t=uT(e),r=uT(n);if(t!==r)return"Array"===t?1:"Array"===r?-1:"binary"===t?1:"binary"===r?-1:"string"===t?1:"string"===r?-1:"Date"===t?1:"Date"!==r?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,r=n.length,a=t<r?t:r;for(let t=0;t<a;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===r?0:t<r?-1:1}(uN(e),uN(n));case"Array":return function(e,n){let t=e.length,r=n.length,a=t<r?t:r;for(let t=0;t<a;++t){let r=uO(e[t],n[t]);if(0!==r)return r}return t===r?0:t<r?-1:1}(e,n)}}catch(e){}return NaN}function uT(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=lJ(e);return"ArrayBuffer"===t?"binary":t}function uN(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class uI{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,ul.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,ul.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=uv(n.algorithm,e)}_iterate(e,n){return uM(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&lx(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>uM(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(uC(n,!0))return t.count({trans:e,query:{index:uD(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var r=0;return uM(n,()=>(++r,!1),e,t).then(()=>r)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),r=t[0],a=t.length-1;function o(e,n){return n?o(e[t[n]],n-1):e[r]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=o(e,a),r=o(n,a);return t<r?-i:t>r?i:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&uC(n,!0)&&n.limit>0){let{valueMapper:t}=n,r=uD(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:r,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return uM(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,uC(n)?uS(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):uS(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),uS(this._ctx,()=>{var n=e;return function(e,t,r){return--n<=0&&t(r),n>=0}},!0),this}until(e,n){return uE(this._ctx,function(t,r,a){return!e(t.value)||(r(a),n)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n;return uE(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=uv(n.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&uC(n,!0)&&n.limit>0)return this._read(e=>{var t=uD(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return uE(this._ctx,function(e){var n=e.primaryKey.toString(),r=lS(t,n);return t[n]=!0,!r}),this}modify(e){var n=this._ctx;return this._write(t=>{var r;if("function"==typeof e)r=e;else{var a=lA(e),o=a.length;r=function(n){for(var t=!1,r=0;r<o;++r){var i=a[r],s=e[i];lL(n,i)!==s&&(lW(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,n)=>{let{failures:t,numFailures:r}=n;for(let n of(p+=e-r,lA(t)))u.push(t[n])};return this.clone().primaryKeys().then(a=>{let o=u=>{let p=Math.min(c,a.length-u);return i.getMany({trans:t,keys:a.slice(u,u+p),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<p;++e){let n=d[e],t={value:lY(n),primKey:a[u+e]};!1!==r.call(t,t.value,t)&&(null==t.value?y.push(a[u+e]):s||0===uO(l(n),l(t.value))?(m.push(t.value),s&&g.push(a[u+e])):(y.push(a[u+e]),h.push(t.value)))}let b=uC(n)&&n.limit===1/0&&("function"!=typeof e||e===uB)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&i.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)y.splice(parseInt(n),1);f(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(y.length>0||b&&e===uB)&&i.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>a.length>u+p&&o(u+c))})};return o(0).then(()=>{if(u.length>0)throw new cr("Error modifying one or more objects",u,p,d);return a.length})})})}delete(){var e=this._ctx,n=e.range;return uC(e)&&(e.isPrimKey&&!um||3===n.type)?this._write(t=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:r,range:n}}).then(r=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:a})=>{if(a)throw new cr("Could not delete some values",Object.keys(e).map(n=>e[n]),r-a);return r-a}))}):this.modify(uB)}}let uB=(e,n)=>n.value=null;function uj(e,n){return e<n?-1:+(e!==n)}function uR(e,n){return e>n?-1:+(e!==n)}function uF(e,n,t){var r=e instanceof uU?new e.Collection(e):e;return r._ctx.error=t?new t(n):TypeError(n),r}function uL(e){return new e.Collection(e,()=>uG("")).limit(0)}function uW(e,n,t,r){var a,o,i,s,l,c,u,p=t.length;if(!t.every(e=>"string"==typeof e))return uF(e,uf);function d(e){a="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?uj:uR;var n=t.map(function(e){return{lower:o(e),upper:a(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,u="next"===e?"":r}d("next");var f=new e.Collection(e,()=>uV(s[0],l[p-1]+r));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,r){var a=e.key;if("string"!=typeof a)return!1;var d=o(a);if(n(d,l,h))return!0;for(var f=null,m=h;m<p;++m){var g=function(e,n,t,r,a,o){for(var i=Math.min(e.length,r.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==r[l])return 0>a(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>a(e[l],r[l])?e.substr(0,l)+r[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>a(e[l],c)&&(s=l)}return i<r.length&&"next"===o?e+t.substr(e.length):i<e.length&&"prev"===o?e.substr(0,t.length):s<0?null:e.substr(0,s)+r[s]+t.substr(s+1)}(a,d,s[m],l[m],i,c);null===g&&null===f?h=m+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+u)}:r),!1}),f}function uV(e,n,t,r){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:r}}function uG(e){return{type:1,lower:e,upper:e}}class uU{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,r){t=!1!==t,r=!0===r;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||r)&&(!t||!r)?uL(this):new this.Collection(this,()=>uV(e,n,!t,!r))}catch(e){return uF(this,ud)}}equals(e){return null==e?uF(this,ud):new this.Collection(this,()=>uG(e))}above(e){return null==e?uF(this,ud):new this.Collection(this,()=>uV(e,void 0,!0))}aboveOrEqual(e){return null==e?uF(this,ud):new this.Collection(this,()=>uV(e,void 0,!1))}below(e){return null==e?uF(this,ud):new this.Collection(this,()=>uV(void 0,e,!1,!0))}belowOrEqual(e){return null==e?uF(this,ud):new this.Collection(this,()=>uV(void 0,e))}startsWith(e){return"string"!=typeof e?uF(this,uf):this.between(e,e+uu,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):uW(this,(e,n)=>0===e.indexOf(n[0]),[e],uu)}equalsIgnoreCase(e){return uW(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=l1.apply(l0,arguments);return 0===e.length?uL(this):uW(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=l1.apply(l0,arguments);return 0===e.length?uL(this):uW(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,uu)}anyOf(){let e=l1.apply(l0,arguments),n=this._cmp;try{e.sort(n)}catch(e){return uF(this,ud)}if(0===e.length)return uL(this);let t=new this.Collection(this,()=>uV(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let r=0;return t._addAlgorithm((t,a,o)=>{let i=t.key;for(;n(i,e[r])>0;)if(++r===e.length)return a(o),!1;return 0===n(i,e[r])||(a(()=>{t.continue(e[r])}),!1)}),t}notEqual(e){return this.inAnyRange([[up,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=l1.apply(l0,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return uF(this,ud)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[up,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,r=this._ascending,a=this._descending,o=this._min,i=this._max;if(0===e.length)return uL(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return uF(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",ci.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,u=r;function p(e,n){return u(e[0],n[0])}try{(c=e.reduce(function(e,n){let r=0,a=e.length;for(;r<a;++r){let a=e[r];if(0>t(n[0],a[1])&&t(n[1],a[0])>0){a[0]=o(a[0],n[0]),a[1]=i(a[1],n[1]);break}}return r===a&&e.push(n),e},[])).sort(p)}catch(e){return uF(this,ud)}let d=0,f=l?e=>r(e,c[d][1])>0:e=>r(e,c[d][1])>=0,h=s?e=>a(e,c[d][0])>0:e=>a(e,c[d][0])>=0,m=f,g=new this.Collection(this,()=>uV(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,u=r):(m=h,u=a),c.sort(p)},g._addAlgorithm((e,n,t)=>{for(var a=e.key;m(a);)if(++d===c.length)return n(t),!1;return!!(!f(a)&&!h(a))||(0===this._cmp(a,c[d][1])||0===this._cmp(a,c[d][0])||n(()=>{u===r?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=l1.apply(l0,arguments);return e.every(e=>"string"==typeof e)?0===e.length?uL(this):this.inAnyRange(e.map(e=>[e,e+uu])):uF(this,"startsWithAnyOf() only works with strings")}}function uH(e){return cX(function(n){return uq(n),e(n.target.error),!1})}function uq(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let uK="storagemutated",uY="x-storagemutated-1",uZ=uk(null,uK);class uJ{_lock(){return lj(!cN.global),++this._reculock,1!==this._reculock||cN.global||(cN.lockOwnerFor=this),this}_unlock(){if(lj(!cN.global),0==--this._reculock)for(cN.global||(cN.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{ur(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&cN.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(lj(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new ci.DatabaseClosed(t);case"MissingAPIError":throw new ci.MissingAPI(t.message,t);default:throw new ci.OpenFailed(t)}if(!this.active)throw new ci.TransactionInactive;return lj(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=cX(n=>{uq(n),this._reject(e.error)}),e.onabort=cX(n=>{uq(n),this.active&&this._reject(new ci.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=cX(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&uZ.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return ul(new ci.ReadOnly("Transaction is readonly"));if(!this.active)return ul(new ci.TransactionInactive);if(this._locked())return new cR((r,a)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(r,a)},cN])});if(t)return c4(()=>{var e=new cR((e,t)=>{this._lock();let r=n(e,t,this);r&&r.then&&r.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new cR((e,t)=>{var r=n(e,t,this);r&&r.then&&r.then(e,t)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=cR.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var r=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var a=n._waitingFor;return new cR((e,r)=>{t.then(t=>n._waitingQueue.push(cX(e.bind(null,t))),e=>n._waitingQueue.push(cX(r.bind(null,e)))).finally(()=>{n._waitingFor===a&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new ci.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(lS(n,e))return n[e];let t=this.schema[e];if(!t)throw new ci.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,t,this);return r.core=this.db.core.table(e),n[e]=r,r}}function uX(e,n,t,r,a,o,i){return{name:e,keyPath:n,unique:t,multi:r,auto:a,compound:o,src:(t&&!i?"&":"")+(r?"*":"")+(a?"++":"")+uQ(n)}}function uQ(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function u0(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:lF(t,e=>[e.name,e])}}let u1=e=>{try{return e.only([[]]),u1=()=>[[]],[[]]}catch(e){return u1=()=>uu,uu}};function u2(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>lL(n,e):n=>lL(n,e)}function u3(e){return[].slice.call(e)}let u5=0;function u4(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function u6({_novip:e},n){let t=n.db,r=function(e,n,{IDBKeyRange:t,indexedDB:r},a){var o;return{dbcore:(o=function(e,n,t){let r;function a(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:r,lowerOpen:a,upperOpen:o}=e;return void 0===t?void 0===r?null:n.upperBound(r,!!o):void 0===r?n.lowerBound(t,!!a):n.bound(t,r,!!a,!!o)}let{schema:o,hasGetAll:i}=(r=u3(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,r=lk(n),a=null==n,o={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:a,compound:r,keyPath:n,autoIncrement:t,unique:!0,extractKey:u2(n)},indexes:u3(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:r,keyPath:a}=e,i={name:n,compound:lk(a),keyPath:a,unique:t,multiEntry:r,extractKey:u2(a)};return o[u4(a)]=i,i}),getIndexByKeyPath:e=>o[u4(e)]};return o[":id"]=i.primaryKey,null!=n&&(o[u4(n)]=i.primaryKey),i})},hasGetAll:r.length>0&&"getAll"in t.objectStore(r[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=o.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:r,values:o,range:i}){return new Promise((s,l)=>{let c;s=cX(s);let u=e.objectStore(n),p=null==u.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=r||o||{length:1};if(r&&o&&r.length!==o.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],g=0,y=e=>{++g,uq(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=u.clear()):h.push(c=u.delete(a(i)))}else{let[e,n]=d?p?[o,r]:[o,null]:[r,null];if(d)for(let r=0;r<f;++r)h.push(c=n&&void 0!==n[r]?u[t](e[r],n[r]):u[t](e[r])),c.onerror=y;else for(let n=0;n<f;++n)h.push(c=u[t](e[n])),c.onerror=y}let b=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(m[n]=e.error)),s({numFailures:g,failures:m,results:"delete"===t?r:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((r,a)=>{r=cX(r);let o=e.objectStore(n),i=t.length,s=Array(i),l,c=0,u=0,p=e=>{let n=e.target;s[n._pos]=n.result,++u===c&&r(s)},d=uH(a);for(let e=0;e<i;++e)null!=t[e]&&((l=o.get(t[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&r(s)}),get:({trans:e,key:t})=>new Promise((r,a)=>{r=cX(r);let o=e.objectStore(n).get(t);o.onsuccess=e=>r(e.target.result),o.onerror=uH(a)}),query:e=>new Promise((t,r)=>{t=cX(t);let{trans:o,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=o.objectStore(n),h=p.isPrimaryKey?f:f.index(p.name),m=a(d);if(0===l)return t({result:[]});if(i){let e=s?h.getAll(m,u):h.getAllKeys(m,u);e.onsuccess=e=>t({result:e.target.result}),e.onerror=uH(r)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),a=[];n.onsuccess=r=>{let o=n.result;return o?(a.push(s?o.value:o.primaryKey),++e===l?t({result:a}):void o.continue()):t({result:a})},n.onerror=uH(r)}}),openCursor:function({trans:e,values:t,query:r,reverse:o,unique:i}){return new Promise((s,l)=>{s=cX(s);let{index:c,range:u}=r,p=e.objectStore(n),d=c.isPrimaryKey?p:p.index(c.name),f=o?i?"prevunique":"prev":i?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(a(u),f):d.openCursor(a(u),f);h.onerror=uH(l),h.onsuccess=cX(n=>{let t=h.result;if(!t)return void s(null);t.___id=++u5,t.done=!1;let r=t.continue.bind(t),a=t.continuePrimaryKey;a&&(a=a.bind(t));let o=t.advance.bind(t),i=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=cX(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=cX(e),h.onerror=uH(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(h.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return h.onsuccess=cX(e=>{h.onsuccess=s,s()}),t.continue=r,t.continuePrimaryKey=a,t.advance=o,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:r,range:o}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=r.isPrimaryKey?s:s.index(r.name),c=a(o),u=c?l.count(c):l.count();u.onsuccess=cX(n=>e(n.target.result)),u.onerror=uH(i)})}}}),l={};return s.forEach(e=>l[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:u1(n),schema:o}}(n,t,a),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),o))}}(e._middlewares,t,e._deps,n);e.core=r.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function u8({_novip:e},n,t,r){t.forEach(t=>{let a=r[t];n.forEach(n=>{let r=lT(n,t);(!r||"value"in r&&void 0===r.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?lM(n,t,{get(){return this.table(t)},set(e){lz(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,a))})})}function u7({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function u9(e,n){return e._cfg.version-n._cfg.version}function pe(e,n){let t,r={del:[],add:[],change:[]};for(t in e)n[t]||r.del.push(t);for(t in n){let a=e[t],o=n[t];if(a){let e={name:t,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(a.primKey.keyPath||"")==""+(o.primKey.keyPath||"")&&(a.primKey.auto===o.primKey.auto||um)){let n,t=a.idxByName,i=o.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let r=t[n],a=i[n];r?r.src!==a.src&&e.change.push(a):e.add.push(a)}(e.del.length>0||e.add.length>0||e.change.length>0)&&r.change.push(e)}else e.recreate=!0,r.change.push(e)}else r.add.push([t,o])}return r}function pn(e,n,t,r){let a=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return r.forEach(e=>pt(a,e)),a}function pt(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function pr(e,n,t){let r={};return lI(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),a=n.keyPath,o=uX(uQ(a),a||"",!1,!1,!!n.autoIncrement,a&&"string"!=typeof a,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);a=t.keyPath;var s=uX(t.name,a,!!t.unique,!!t.multiEntry,!1,a&&"string"!=typeof a,!1);i.push(s)}r[e]=u0(e,o,i)}),r}function pa({_novip:e},n,t){let r=t.db.objectStoreNames;for(let a=0;a<r.length;++a){let o=r[a],i=t.objectStore(o);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],r=i.index(t).keyPath,a="string"==typeof r?r:"["+lI(r).join("+")+"]";if(n[o]){let e=n[o].idxByName[a];e&&(e.name=t,delete n[o].idxByName[a],n[o].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&lw.WorkerGlobalScope&&lw instanceof lw.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class po{_parseStoresSpec(e,n){lA(e).forEach(t=>{if(null!==e[t]){var r=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return uX(t,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),lk(r),0===n)}),a=r.shift();if(a.multi)throw new ci.Schema("Primary key cannot be multi-valued");r.forEach(e=>{if(e.auto)throw new ci.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new ci.Schema("Index must have a name and cannot be an empty string")}),n[t]=u0(t,a,r)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?lx(this._cfg.storesSource,e):e;let t=n._versions,r={},a={};return t.forEach(e=>{lx(r,e._cfg.storesSource),a=e._cfg.dbschema={},e._parseStoresSpec(r,a)}),n._dbSchema=a,u7(n,[n._allTables,n,n.Transaction.prototype]),u8(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],lA(a),a),n._storeNames=lA(a),this}upgrade(e){return this._cfg.contentUpgrade=cy(this._cfg.contentUpgrade||cc,e),this}}function pi(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new px(uy,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function ps(e){return e&&"function"==typeof e.databases}function pl(e){return c4(function(){return cN.letThrough=!0,e()})}function pc(e){var n=n=>e.next(n),t=a(n),r=a(n=>e.throw(n));function a(e){return n=>{var a=e(n),o=a.value;return a.done?o:o&&"function"==typeof o.then?o.then(t,r):lk(o)?Promise.all(o).then(t,r):t(o)}}return a(n)()}function pu(e,n,t){var r=arguments.length;if(r<2)throw new ci.InvalidArgument("Too few arguments");for(var a=Array(r-1);--r;)a[r-1]=arguments[r];return t=a.pop(),[e,lU(a),t]}function pp(e,n,t){let r=lk(e)?e.slice():[e];for(let e=0;e<t;++e)r.push(n);return r}let pd={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:r}=t,a={},o=[];function i(e,n,t){let r=u4(e),s=a[r]=a[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,u={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:u2(e),unique:!c&&t.unique};return s.push(u),u.isPrimaryKey||o.push(u),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),u}let s=i(r.primaryKey.keyPath,0,r.primaryKey);for(let e of(a[":id"]=[s],r.indexes))i(e.keyPath,0,e);function l(n){var t,r;let a=n.query.index;return a.isVirtual?{...n,query:{index:a,range:(t=n.query.range,r=a.keyTail,{type:1===t.type?2:t.type,lower:pp(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:pp(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:n}return{...t,schema:{...r,primaryKey:s,indexes:o,getIndexByKeyPath:function(e){let n=a[u4(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:r,isVirtual:a,keyLength:o}=n.query.index;return a?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(a){null!=a?t.continue(pp(a,n.reverse?e.MAX_KEY:e.MIN_KEY,r)):n.unique?t.continue(t.key.slice(0,o).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,r)):t.continue()}},continuePrimaryKey:{value(n,a){t.continuePrimaryKey(pp(n,e.MAX_KEY,r),a)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function pf(e,n,t,r){return t=t||{},r=r||"",lA(e).forEach(a=>{if(lS(n,a)){var o=e[a],i=n[a];if("object"==typeof o&&"object"==typeof i&&o&&i){let e=lJ(o);e!==lJ(i)?t[r+a]=n[a]:"Object"===e?pf(o,i,t,r+a+"."):o!==i&&(t[r+a]=n[a])}else o!==i&&(t[r+a]=n[a])}else t[r+a]=void 0}),lA(n).forEach(a=>{lS(e,a)||(t[r+a]=n[a])}),t}let ph={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:r}=t.schema;return{...t,mutate(e){let a=cN.trans,{deleting:o,creating:i,updating:s}=a.table(n).hook;switch(e.type){case"add":if(i.fire===cc)break;return a._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===cc&&s.fire===cc)break;return a._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===cc)break;return a._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===cc)break;return a._promise("readwrite",()=>(function e(n,a,o){return t.query({trans:n,values:!1,query:{index:r,range:a},limit:o}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):t.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...a,lower:t[t.length-1],lowerOpen:!0},o)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,a;let l=cN.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(r.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(a=e).type?Promise.resolve([]):t.getMany({trans:a.trans,keys:c,cache:"immutable"})).then(n=>{let a=c.map((t,a)=>{let c=n[a],u={onerror:null,onsuccess:null};if("delete"===e.type)o.fire.call(u,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(u,t,e.values[a],l);null==t&&null!=n&&(t=n,e.keys[a]=t,r.outbound||lW(e.values[a],r.keyPath,t))}else{let n=pf(c,e.values[a]),r=s.fire.call(u,n,t,c,l);if(r){let n=e.values[a];Object.keys(r).forEach(e=>{lS(n,e)?n[e]=r[e]:lW(n,e,r[e])})}}return u});return t.mutate(e).then(({failures:t,results:r,numFailures:o,lastResult:i})=>{for(let o=0;o<c.length;++o){let i=r?r[o]:c[o],s=a[o];null==i?s.onerror&&s.onerror(t[o]):s.onsuccess&&s.onsuccess("put"===e.type&&n[o]?e.values[o]:i)}return{failures:t,results:r,numFailures:o,lastResult:i}}).catch(e=>(a.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function pm(e,n,t){try{if(!n||n.keys.length<e.length)return null;let r=[];for(let a=0,o=0;a<n.keys.length&&o<e.length;++a)0===uO(n.keys[a],e[o])&&(r.push(t?lY(n.values[a]):n.values[a]),++o);return r.length===e.length?r:null}catch(e){return null}}let pg={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=pm(e.keys,e.trans._cache,"clone"===e.cache);return n?cR.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?lY(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function py(e){return!("from"in e)}let pb=function(e,n){if(!this){let n=new pb;return e&&"d"in e&&lx(n,e),n}lx(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function p_(e,n,t){let r=uO(n,t);if(isNaN(r))return;if(r>0)throw RangeError();if(py(e))return lx(e,{from:n,to:t,d:1});let a=e.l,o=e.r;if(0>uO(t,e.from))return a?p_(a,n,t):e.l={from:n,to:t,d:1,l:null,r:null},pw(e);if(uO(n,e.to)>0)return o?p_(o,n,t):e.r={from:n,to:t,d:1,l:null,r:null},pw(e);0>uO(n,e.from)&&(e.from=n,e.l=null,e.d=o?o.d+1:1),uO(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;a&&!e.l&&pv(e,a),o&&i&&pv(e,o)}function pv(e,n){py(n)||function e(n,{from:t,to:r,l:a,r:o}){p_(n,t,r),a&&e(n,a),o&&e(n,o)}(e,n)}function p$(e){let n=py(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>uO(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=uO(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function pw(e){var n,t;let r=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),a=r>1?"r":r<-1?"l":"";if(a){let n="r"===a?"l":"r",t={...e},r=e[a];e.from=r.from,e.to=r.to,e[a]=r[a],t[a]=r[n],e[n]=t,t.d=pA(t)}e.d=pA(e)}function pA({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}lD(pb.prototype,{add(e){return pv(this,e),this},addKey(e){return p_(this,e,e),this},addKeys(e){return e.forEach(e=>p_(this,e,e)),this},[lX](){return p$(this)}});let pk={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new pb(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{let a=e.table(r),{schema:o}=a,{primaryKey:i}=o,{extractKey:s,outbound:l}=i,c={...a,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${r}/${e}`;return s[t]||(s[t]=new pb)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return a.mutate(e).then(e=>{if(lk(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let n=pm(d,h);n||"add"===p||u.addKeys(d),(n||f)&&o.indexes.forEach(function(e){let t=l(e.name||"");function r(n){return null!=n?e.extractKey(n):null}let a=n=>e.multiEntry&&lk(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let o=n&&r(n[t]),i=f&&r(f[t]);0!==uO(o,i)&&(null!=o&&a(o),null!=i&&a(i))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(t),u.add(t),o.indexes.forEach(e=>l(e.name).add(t));return e})}},u=({query:{index:n,range:t}})=>{var r,a;return[n,new pb(null!=(r=t.lower)?r:e.MIN_KEY,null!=(a=t.upper)?a:e.MAX_KEY)]},p={get:e=>[i,new pb(e.key)],getMany:e=>[i,(new pb).addKeys(e.keys)],count:u,query:u,openCursor:u};return lA(p).forEach(e=>{c[e]=function(o){let{subscr:i}=cN;if(i){let c=e=>{let t=`idb://${n}/${r}/${e}`;return i[t]||(i[t]=new pb)},u=c(""),d=c(":dels"),[f,h]=p[e](o);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&o.values&&a.query({...o,values:!1});return a[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&o.values)return n.then(({result:e})=>(u.addKeys(e),t));let e=o.values?t.result.map(s):t.result;o.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=o.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&u.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return a[e].apply(this,arguments)}}),c}}}};class px{constructor(e,n){var t;this._middlewares={},this.verno=0;const r=px.dependencies;this._options=n={addons:px.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:a}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:cc,dbReadyPromise:null,cancelOpen:cc,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new cR(e=>{o.dbReadyResolve=e}),o.openCanceller=new cR((e,n)=>{o.cancelOpen=n}),this._state=o,this.name=e,this.on=uk(this,"populate","blocked","versionchange","close",{ready:[cy,cc]}),this.on.ready.subscribe=lB(this.on.ready.subscribe,e=>(n,t)=>{px.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||cR.resolve().then(n),t&&e(n);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(n),t&&e(n);else{e(n);let r=this;t||e(function e(){r.on.ready.unsubscribe(n),r.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,ux(uI.prototype,function(e,n){this.db=t;let r=u$,a=null;if(n)try{r=n()}catch(e){a=e}let o=e._ctx,i=o.table,s=i.hook.reading.fire;this._ctx={table:i,index:o.index,isPrimKey:!o.index||i.schema.primKey.keyPath&&o.index===i.schema.primKey.name,range:r,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:a,or:o.or,valueMapper:s!==cu?s:null}})),this.Table=function(e){return ux(uA.prototype,function(n,t,r){this.db=e,this._tx=r,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:uk(null,{creating:[cf,cc],reading:[cp,cu],updating:[cm,cc],deleting:[ch,cc]})})}(this),this.Transaction=function(e){return ux(uJ.prototype,function(n,t,r,a,o){this.db=e,this.mode=n,this.storeNames=t,this.schema=r,this.chromeTransactionDurability=a,this.idbtrans=null,this.on=uk(this,"complete","error","abort"),this.parent=o||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new cR((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),ul(e)})})}(this),this.Version=function(e){return ux(po.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return ux(uU.prototype,function(n,t,r){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:r};let a=e._deps.indexedDB;if(!a)throw new ci.MissingAPI;this._cmp=this._ascending=a.cmp.bind(a),this._descending=(e,n)=>a.cmp(n,e),this._max=(e,n)=>a.cmp(e,n)>0?e:n,this._min=(e,n)=>0>a.cmp(e,n)?e:n,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=u1(n.IDBKeyRange),this._createTransaction=(e,n,t,r)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),uh.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(pd),this.use(ph),this.use(pk),this.use(pg),this.vip=Object.create(this,{_vip:{value:!0}}),a.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new ci.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new ci.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(u9),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||cN.letThrough||this._vip)?e():new cR((e,n)=>{if(this._state.openComplete)return n(new ci.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new ci.DatabaseClosed);this.open().catch(cc)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:r}){r&&this.unuse({stack:e,name:r});let a=this._middlewares[e]||(this._middlewares[e]=[]);return a.push({stack:e,create:n,level:null==t?10:t,name:r}),a.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?ul(t.dbOpenError):e);l3&&(t.openCanceller._stackHolder=l6()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let a=t.openCanceller;function o(){if(t.openCanceller!==a)throw new ci.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1,c=()=>new cR((n,a)=>{if(o(),!r)throw new ci.MissingAPI;let i=e.name,c=t.autoSchema?r.open(i):r.open(i,Math.round(10*e.verno));if(!c)throw new ci.MissingAPI;c.onerror=uH(a),c.onblocked=cX(e._fireOnBlocked),c.onupgradeneeded=cX(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=uq,s.abort(),c.result.close();let e=r.deleteDatabase(i);e.onsuccess=e.onerror=cX(()=>{a(new ci.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,r,i,d;s.onerror=uH(a);var o,u,p=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=p<1,e._novip.idbdb=c.result,o=p/10,u=s,t=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,t)).create(u),r._completion.catch(a),i=r._reject.bind(r),d=cN.transless||cN,c4(()=>{cN.trans=r,cN.transless=d,0===o?(lA(t).forEach(e=>{pn(u,e,t[e].primKey,t[e].indexes)}),u6(e,u),cR.follow(()=>e.on.populate.fire(r)).catch(i)):(function({_novip:e},n,t,r){let a=[],o=e._versions,i=e._dbSchema=pr(e,e.idbdb,r),s=!1;return o.filter(e=>e._cfg.version>=n).forEach(o=>{a.push(()=>{let a=i,l=o._cfg.dbschema;pa(e,a,r),pa(e,l,r),i=e._dbSchema=l;let c=pe(a,l);c.add.forEach(e=>{pn(r,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new ci.Upgrade("Not yet support for changing primary key");{let n=r.objectStore(e.name);e.add.forEach(e=>pt(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),pt(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let u=o._cfg.contentUpgrade;if(u&&o._cfg.version>n){let n;u6(e,r),t._memoizedTables={},s=!0;let o=lV(l);c.del.forEach(e=>{o[e]=a[e]}),u7(e,[e.Transaction.prototype]),u8(e,[e.Transaction.prototype],lA(o),o),t.schema=o;let i=l2(u);i&&c6();let p=cR.follow(()=>{if((n=u(t))&&i){var e=c8.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?cR.resolve(n):p.then(()=>n)}}),a.push(n=>{var r;s&&um||(r=o._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==r[e]&&n.db.deleteObjectStore(e))),u7(e,[e.Transaction.prototype]),u8(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return a.length?cR.resolve(a.shift()(t.idbtrans)).then(e):cR.resolve()})().then(()=>{var e;lA(e=i).forEach(n=>{r.db.objectStoreNames.contains(n)||pn(r,n,e[n].primKey,e[n].indexes)})})})(e,o,r,u).catch(i)})}},a),c.onsuccess=cX(()=>{s=null;let r=e._novip.idbdb=c.result,a=lI(r.objectStoreNames);if(a.length>0)try{let n,o=r.transaction(1===a.length?a[0]:a,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let r=e._dbSchema=pr(0,n,t);e._storeNames=lI(n.objectStoreNames,0),u8(e,[e._allTables],lA(r),r)}(e,r,o):(pa(e,e._dbSchema,o),((n=pe(pr(0,e.idbdb,o),e._dbSchema)).add.length||n.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),u6(e,o)}catch(e){}uh.push(e),r.onversionchange=cX(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),r.onclose=cX(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){ps(e)||t===uy||pi(e,n).put({name:t}).catch(cc)}(e._deps,i),n()},a)}).catch(e=>e&&"UnknownError"===e.name&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),c()):cR.reject(e));return cR.race([a,("u"<typeof navigator?cR.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(c)]).then(()=>(o(),t.onReadyBeingFired=[],cR.resolve(pl(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(cy,cc);return t.onReadyBeingFired=[],cR.resolve(pl(()=>r(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return a===t.openCanceller&&e._close(),ul(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=uh.indexOf(this);if(n>=0&&uh.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new cR(n=>{e.dbReadyResolve=n}),e.openCanceller=new cR((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new ci.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new cR((t,r)=>{let a=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cX(()=>{!function({indexedDB:e,IDBKeyRange:n},t){ps(e)||t===uy||pi(e,n).delete(t).catch(cc)}(this._deps,this.name),t()}),e.onerror=uH(r),e.onblocked=this._fireOnBlocked};if(e)throw new ci.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(a):a()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return lA(this._allTables).map(e=>this._allTables[e])}transaction(){let e=pu.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let r,a,o=cN.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===ub)r=ub;else{if("rw"!=e&&e!=u_)throw new ci.InvalidArgument("Invalid transaction mode: "+e);r=u_}if(o){if(o.mode===ub&&r===u_){if(!i)throw new ci.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(e=>{if(o&&-1===o.storeNames.indexOf(e)){if(!i)throw new ci.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),i&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,(n,t)=>{t(e)}):ul(e)}let s=(function e(n,t,r,a,o){return cR.resolve().then(()=>{let i,s=cN.transless||cN,l=n._createTransaction(t,r,n._dbSchema,a);if(a)l.idbtrans=a.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(a){return a.name===co.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,null,o))):ul(a)}let c=l2(o);c&&c6();let u=cR.follow(()=>{if(i=o.call(l,l))if(c){var e=c8.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=pc(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?cR.resolve(i).then(e=>l.active?e:ul(new ci.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>i)).then(e=>(a&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),ul(e)))})}).bind(null,this,r,a,o,t);return o?o._promise(r,s,"lock"):cN.trans?ur(cN.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!lS(this._allTables,e))throw new ci.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let pC="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class pE{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[pC](){return this}}function pS(e,n){return lA(n).forEach(t=>{pv(e[t]||(e[t]=new pb),n[t])}),e}try{a={indexedDB:lw.indexedDB||lw.mozIndexedDB||lw.webkitIndexedDB||lw.msIndexedDB,IDBKeyRange:lw.IDBKeyRange||lw.webkitIDBKeyRange}}catch(e){a={indexedDB:null,IDBKeyRange:null}}function pD(e){let n=pz;try{pz=!0,uZ.storagemutated.fire(e)}finally{pz=n}}lD(px,{...cl,delete:e=>new px(e,{addons:[]}).delete(),exists:e=>new px(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return ps(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==uy)):pi(e,n).toCollection().primaryKeys()})(px.dependencies).then(e)}catch(e){return ul(new ci.MissingAPI)}},defineClass:()=>function(e){lx(this,e)},ignoreTransaction:e=>cN.trans?ur(cN.transless,e):e(),vip:pl,async:function(e){return function(){try{var n=pc(e.apply(this,arguments));return n&&"function"==typeof n.then?n:cR.resolve(n)}catch(e){return ul(e)}}},spawn:function(e,n,t){try{var r=pc(e.apply(t,n||[]));return r&&"function"==typeof r.then?r:cR.resolve(r)}catch(e){return ul(e)}},currentTransaction:{get:()=>cN.trans||null},waitFor:function(e,n){let t=cR.resolve("function"==typeof e?px.ignoreTransaction(e):e).timeout(n||6e4);return cN.trans?cN.trans.waitFor(t):t},Promise:cR,debug:{get:()=>l3,set:e=>{l3=e,l5="dexie"===e?()=>!0:ug}},derive:lP,extend:lx,props:lD,override:lB,Events:uk,on:uZ,liveQuery:function(e){let n,t=!1,r=new pE(r=>{let a=l2(e),o=!1,i={},s={},l={get closed(){return o},unsubscribe:()=>{o=!0,uZ.storagemutated.unsubscribe(d)}};r.start&&r.start(l);let c=!1,u=!1;function p(){return lA(s).some(e=>i[e]&&function(e,n){let t=p$(n),r=t.next();if(r.done)return!1;let a=r.value,o=p$(e),i=o.next(a.from),s=i.value;for(;!r.done&&!i.done;){if(0>=uO(s.from,a.to)&&uO(s.to,a.from)>=0)return!0;0>uO(a.from,s.from)?a=(r=t.next(s.from)).value:s=(i=o.next(a.from)).value}return!1}(i[e],s[e]))}let d=e=>{pS(i,e),p()&&f()},f=()=>{let h,m;if(c||o)return;i={};let g={},y=(a&&c6(),h=()=>c4(e,{subscr:g,trans:null}),m=cN.trans?ur(cN.transless,h):h(),a&&m.then(c8,c8),m);u||(uZ(uK,d),u=!0),c=!0,Promise.resolve(y).then(e=>{t=!0,n=e,c=!1,o||(p()?f():(i={},s=g,r.next&&r.next(e)))},e=>{c=!1,t=!1,r.error&&r.error(e),l.unsubscribe()})};return f(),l});return r.hasValue=()=>t,r.getValue=()=>n,r},extendObservabilitySet:pS,getByKeyPath:lL,setByKeyPath:lW,delByKeyPath:function(e,n){"string"==typeof n?lW(e,n,void 0):"length"in n&&[].map.call(n,function(n){lW(e,n,void 0)})},shallowClone:lV,deepClone:lY,getObjectDiff:pf,cmp:uO,asap:lR,minKey:up,addons:[],connections:uh,errnames:co,dependencies:a,semVer:uc,version:uc.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),px.maxKey=u1(px.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(uZ(uK,e=>{if(!pz){let n;um?(n=document.createEvent("CustomEvent")).initCustomEvent(uY,!0,!0,e):n=new CustomEvent(uY,{detail:e}),pz=!0,dispatchEvent(n),pz=!1}}),addEventListener(uY,({detail:e})=>{pz||pD(e)}));let pz=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(uY);"function"==typeof e.unref&&e.unref(),uZ(uK,n=>{pz||e.postMessage(n)}),e.onmessage=e=>{e.data&&pD(e.data)}}else if("u">typeof self&&"u">typeof navigator){uZ(uK,e=>{try{pz||("u">typeof localStorage&&localStorage.setItem(uY,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:uY,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===uY){let n=JSON.parse(e.newValue);n&&pD(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===uY&&pD(e.changedParts)})}function pM(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}cR.rejectionMapper=function(e,n){if(!e||e instanceof cn||e instanceof TypeError||e instanceof SyntaxError||!e.name||!cs[e.name])return e;var t=new cs[e.name](n||e.message,e);return"stack"in e&&lM(t,"stack",{get:function(){return this.inner.stack}}),t},l5=ug;class pP extends px{constructor(){super("EsmOffline"),pM(this,"syncQueue",void 0),pM(this,"dynamicOfflineData",void 0),this.version(4).stores({syncQueue:"++id,userId,type,[userId+type]",dynamicOfflineData:"++id,type,identifier,*users,&[type+identifier]"}),this.syncQueue=this.table("syncQueue"),this.dynamicOfflineData=this.table("dynamicOfflineData")}}function pO(){return new pP}let pT=new pP,pN={},pI=U("offline-synchronization",{});function pB(){return pI}async function pj(){if(pI.getState().synchronization)return;let e=await pT.syncQueue.count(),n={},t=Object.entries(pN),r=t.length,a={},o=new AbortController,i=()=>{let e=pI.getState().synchronization;pI.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{pI.setState({synchronization:{totalCount:e,pendingCount:e,abortController:o}});for(let e=0;e<r&&t.length>0;e++)for(let e=t.length;e--;){let[r,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(a[r]={},await Promise.all(l),n[r]=pR(s,a,o,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{pI.setState({synchronization:void 0})}}async function pR({type:e,dependsOn:n,process:t},r,a,o){let i=[],s=[],l=await pF();await pT.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[u,p,{id:d,dependencies:f=[]}]=i[c];try{let o=await t(p,{abort:a,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?r[t][e]:void 0)});void 0!==d&&(r[e][d]=o),await pT.syncQueue.delete(u)}catch(e){await pT.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{o()}}}async function pF(){let e=await iw();return e?.uuid||"*"}async function pL(e,n,t,r){let a=r&&r.id;return void 0!==a&&await pT.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===a).delete().catch(px.errnames.DatabaseClosed),await pT.syncQueue.add({type:n,content:t,userId:e,descriptor:r||{},createdOn:new Date}).catch(px.errnames.DatabaseClosed,()=>-1)}async function pW(e,n,t){let r=await pF();return await pL(r,e,n,t)}async function pV(e,n){return(await pG(e,n)).map(e=>e.content)}async function pG(e,n){return await pT.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(px.errnames.DatabaseClosed,()=>[])}async function pU(e){let n=await pF();return await pV(n,e)}async function pH(e){let n=await pF();return await pG(n,e)}async function pq(e){return await pT.syncQueue.get(e).catch(px.errnames.DatabaseClosed,()=>void 0)}function pK(e){return!!pN[e]?.options.onBeginEditSyncItem}async function pY(e){let n=await pq(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=pN[n.type]?.options.onBeginEditSyncItem;if(!t)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${n.type}" supports editing items.`);t(n)}async function pZ(e){await pT.syncQueue.delete(e).catch(px.errnames.DatabaseClosed)}function pJ(e,n,t,r={}){pN[e]={type:e,dependsOn:n,process:t,options:r}}let pX="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pQ=new Uint8Array(16),p0=[];for(let e=0;e<256;++e)p0.push((e+256).toString(16).slice(1));let p1=function(e,n,t){if(pX&&!n&&!e)return pX();let r=(e=e||{}).random||(e.rng||function(){if(!o&&!(o="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return o(pQ)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=r[e];return n}return function(e,n=0){return p0[e[n+0]]+p0[e[n+1]]+p0[e[n+2]]+p0[e[n+3]]+"-"+p0[e[n+4]]+p0[e[n+5]]+"-"+p0[e[n+6]]+p0[e[n+7]]+"-"+p0[e[n+8]]+p0[e[n+9]]+"-"+p0[e[n+10]]+p0[e[n+11]]+p0[e[n+12]]+p0[e[n+13]]+p0[e[n+14]]+p0[e[n+15]]}(r)},p2="OFFLINE+";function p3(){return p2+p1()}function p5(e){return e.startsWith(p2)}let p4={};function p6(){return Object.values(p4)}function p8(e){p4[e.id]&&console.warn(`[setupDynamicOfflineDataHandler] Another second handler with the ID "${e.id}" was registered. This handler will override the previous one. This could be unintended as the previous handler might run different flows than the newly registered one. If this is the case, ensure that you are setting up the handlers with different IDs.`),p4[e.id]=e}async function p7(e){let n=await ds();return await p9(n,e)}async function p9(e,n){let t=new pP;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(px.errnames.DatabaseClosed,()=>[])}async function de(e,n){let t=await ds();return await dn(t,e,n)}async function dn(e,n,t){let r=new pP,a=await r.dynamicOfflineData.get({type:n,identifier:t}).catch(px.errnames.DatabaseClosed,()=>void 0);a?a.users.includes(e)||await r.dynamicOfflineData.update(a.id,{users:[...a.users,e]}).catch(px.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(px.errnames.DatabaseClosed)}async function dt(e,n){let t=await ds();return await dr(t,e,n)}async function dr(e,n,t){let r=new pP,a=await r.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(px.errnames.DatabaseClosed,()=>void 0);a&&(a.users.length>1?await r.dynamicOfflineData.update(a.id,{users:a.users.filter(n=>n!==e)}).catch(px.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(a.id).catch(px.errnames.DatabaseClosed))}async function da(e,n){let t=await p7(e);await Promise.all(t.map(async e=>di(e.type,e.identifier,n)))}async function di(e,n,t){await de(e,n);let r=new pP,a=await ds(),o=await r.dynamicOfflineData.get({type:e,identifier:n}).catch(px.errnames.DatabaseClosed,()=>void 0),i=p6().filter(n=>n.type===e);if(!o)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:a,succeededHandlers:l,erroredHandlers:c,errors:u};o.id&&await r.dynamicOfflineData.update(o.id,{syncState:p}).catch(px.errnames.DatabaseClosed)}async function ds(){let e=(await iw()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let dl=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function dc(){return dd(),dl}function du(e,n){dd(),p8({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function dp(e){dd(),await di("patient",e)}function dd(){console.warn("The offline patient API has been deprecated and will be removed in a future release. To prevent future crashes, the functions remain available for the moment, but any invocations should be migrated ASAP.")}async function df(e,n,t=!0){if(e){let r=null,[a,o]=await Promise.all([iu(`${is}/Patient/${e}`,n).catch(e=>r=e),t?dh(e):Promise.resolve(null)]);if(a.ok)return a.data;if(o)return o;if(r)throw r}return null}async function dh(e){let n=(await pU("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function dm(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function dg(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var dy=t(9549);function db(e){return{uuid:e.uuid,display:e.display}}function d_(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let r=t.toString();return ip(`${ii}/location${r?"?"+r:""}`).pipe((0,dy.map)(e=>e.data.results.map(db))).pipe((0,dy.take)(1))}function dv(e){return{uuid:e.uuid,display:e.display,name:e.name}}function d$(){return ip(`${ii}/visittype`).pipe((0,dy.map)(e=>e.data.results.map(dv))).pipe((0,dy.take)(1))}var dw=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),dA=function(e){function n(n,t){var r=e.call(this)||this;return r.subject=n,r.subscriber=t,r.closed=!1,r}return ep(n,e),n.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,n=e.observers;if(this.subject=null,n&&0!==n.length&&!e.isStopped&&!e.closed){var t=n.indexOf(this.subscriber);-1!==t&&n.splice(t,1)}}},n}(e_),dk=function(e){function n(n){var t=e.call(this,n)||this;return t.destination=n,t}return ep(n,e),n}(ew),dx=function(e){function n(){var n=e.call(this)||this;return n.observers=[],n.closed=!1,n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return ep(n,e),n.prototype[e$]=function(){return new dk(this)},n.prototype.lift=function(e){var n=new dC(this,this);return n.operator=e,n},n.prototype.next=function(e){if(this.closed)throw new dw;if(!this.isStopped)for(var n=this.observers,t=n.length,r=n.slice(),a=0;a<t;a++)r[a].next(e)},n.prototype.error=function(e){if(this.closed)throw new dw;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var n=this.observers,t=n.length,r=n.slice(),a=0;a<t;a++)r[a].error(e);this.observers.length=0},n.prototype.complete=function(){if(this.closed)throw new dw;this.isStopped=!0;for(var e=this.observers,n=e.length,t=e.slice(),r=0;r<n;r++)t[r].complete();this.observers.length=0},n.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},n.prototype._trySubscribe=function(n){if(!this.closed)return e.prototype._trySubscribe.call(this,n);throw new dw},n.prototype._subscribe=function(e){if(this.closed)throw new dw;return this.hasError?(e.error(this.thrownError),e_.EMPTY):this.isStopped?(e.complete(),e_.EMPTY):(this.observers.push(e),new dA(this,e))},n.prototype.asObservable=function(){var e=new ex;return e.source=this,e},n.create=function(e,n){return new dC(e,n)},n}(ex),dC=function(e){function n(n,t){var r=e.call(this)||this;return r.destination=n,r.source=t,r}return ep(n,e),n.prototype.next=function(e){var n=this.destination;n&&n.next&&n.next(e)},n.prototype.error=function(e){var n=this.destination;n&&n.error&&this.destination.error(e)},n.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},n.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):e_.EMPTY},n}(dx),dE=function(e){function n(n){var t=e.call(this)||this;return t._value=n,t}return ep(n,e),Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),n.prototype._subscribe=function(n){var t=e.prototype._subscribe.call(this,n);return t&&!t.closed&&n.next(this._value),t},n.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new dw},n.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},n}(dx),dS=((eo={}).NEWVISIT="startVisit",eo.EDITVISIT="editVisit",eo.LOADING="loadingVisit",eo),dD=((ei={}).NOTSTARTED="notStarted",ei.ONGOING="ongoing",ei);let dz="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))",dM=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function dP(){return q("visit",dM)}function dO(e,n){dP().setState({patientUuid:e,manuallySetVisitUuid:n})}function dT(e,n){return iu(`${ii}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function dN(e,n,t){return iu(`${ii}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function dI(e,n,t){return iu(`${ii}/visit?patient=${e}&v=${t??dz}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}dP().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let dB=new dE(null);class dj{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+dj.version}static addUnaryOp(e){return dj.max_unop_len=Math.max(e.length,dj.max_unop_len),dj.unary_ops[e]=1,dj}static addBinaryOp(e,n,t){return dj.max_binop_len=Math.max(e.length,dj.max_binop_len),dj.binary_ops[e]=n,t?dj.right_associative.add(e):dj.right_associative.delete(e),dj}static addIdentifierChar(e){return dj.additional_identifier_chars.add(e),dj}static addLiteral(e,n){return dj.literals[e]=n,dj}static removeUnaryOp(e){return delete dj.unary_ops[e],e.length===dj.max_unop_len&&(dj.max_unop_len=dj.getMaxKeyLen(dj.unary_ops)),dj}static removeAllUnaryOps(){return dj.unary_ops={},dj.max_unop_len=0,dj}static removeIdentifierChar(e){return dj.additional_identifier_chars.delete(e),dj}static removeBinaryOp(e){return delete dj.binary_ops[e],e.length===dj.max_binop_len&&(dj.max_binop_len=dj.getMaxKeyLen(dj.binary_ops)),dj.right_associative.delete(e),dj}static removeAllBinaryOps(){return dj.binary_ops={},dj.max_binop_len=0,dj}static removeLiteral(e){return delete dj.literals[e],dj}static removeAllLiterals(){return dj.literals={},dj}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 dj(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 dj.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!dj.binary_ops[String.fromCharCode(e)]||dj.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return dj.isIdentifierStart(e)||dj.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(dj.hooks[e]){let t={context:this,node:n};return dj.hooks.run(e,t),t.node}return n}searchHook(e){if(dj.hooks[e]){let n={context:this};return dj.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===dj.SPACE_CODE||e===dj.TAB_CODE||e===dj.LF_CODE||e===dj.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:dj.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,r;for(;this.index<this.expr.length;)if((t=this.code)===dj.SEMCOL_CODE||t===dj.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())n.push(r);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}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,dj.max_binop_len),n=e.length;for(;n>0;){if(dj.binary_ops.hasOwnProperty(e)&&(!dj.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!dj.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,r,a,o,i,s,l;if(!(o=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return o;for(a={value:n,prec:dj.binaryPrecedence(n),right_a:dj.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),r=[o,a,i];n=this.gobbleBinaryOp();){if(0===(t=dj.binaryPrecedence(n))){this.index-=n.length;break}a={value:n,prec:t,right_a:dj.right_associative.has(n)},l=n;let s=e=>a.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;r.length>2&&s(r[r.length-2]);)i=r.pop(),n=r.pop().value,o=r.pop(),e={type:dj.BINARY_EXP,operator:n,left:o,right:i},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(a,e)}for(s=r.length-1,e=r[s];s>1;)e={type:dj.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,dj.isDecimalDigit(e)||e===dj.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===dj.SQUOTE_CODE||e===dj.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===dj.OBRACK_CODE)r=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,dj.max_unop_len)).length;t>0;){if(dj.unary_ops.hasOwnProperty(n)&&(!dj.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!dj.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:dj.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}dj.isIdentifierStart(e)?(r=this.gobbleIdentifier(),dj.literals.hasOwnProperty(r.name)?r={type:dj.LITERAL,value:dj.literals[r.name],raw:r.name}:r.name===dj.this_str&&(r={type:dj.THIS_EXP})):e===dj.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===dj.PERIOD_CODE||n===dj.OBRACK_CODE||n===dj.OPAREN_CODE||n===dj.QUMARK_CODE;){let t;if(n===dj.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==dj.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===dj.OBRACK_CODE?((e={type:dj.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==dj.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===dj.OPAREN_CODE?e={type:dj.CALL_EXP,arguments:this.gobbleArguments(dj.CPAREN_CODE),callee:e}:(n===dj.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:dj.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;dj.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===dj.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);dj.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));dj.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);dj.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,dj.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===dj.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===dj.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:dj.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){r=!0;break}if("\\"===n)switch(n=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+=n}else e+=n}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:dj.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(dj.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,dj.isIdentifierPart(e))this.index++;else break;return{type:dj.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){t=!0,this.index++,e===dj.CPAREN_CODE&&r&&r>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===dj.COMMA_CODE){if(this.index++,++r!==n.length){if(e===dj.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===dj.CBRACK_CODE)for(let e=n.length;e<r;e++)n.push(null)}}else if(n.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==dj.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(dj.CPAREN_CODE);if(this.code===dj.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:dj.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:dj.ARRAY_EXP,elements:this.gobbleArguments(dj.CBRACK_CODE)}}}Object.assign(dj,{hooks:new class{add(e,n,t){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]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},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)})}}(dj),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"}),dj.max_unop_len=dj.getMaxKeyLen(dj.unary_ops),dj.max_binop_len=dj.getMaxKeyLen(dj.binary_ops);let dR=e=>new dj(e).parse(),dF=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(dj).filter(e=>!dF.includes(e)&&void 0===dR[e]).forEach(e=>{dR[e]=dj[e]}),dR.Jsep=dj,dR.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let dL="ArrowFunctionExpression",dW={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)}},dV={...dW,Promise};function dG(e,n={}){return dZ(e,n,dQ)}async function dU(e,n={}){return dJ(e,n,dQ)}function dH(e,n={}){return dZ(e,n,d0)}function dq(e,n={}){return dJ(e,n,d0)}function dK(e,n={}){return dZ(e,n,d1)}function dY(e,n={}){return dJ(e,n,d1)}function dZ(e,n={},t){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==n&&(n={});let r=d5(n,dW),a=d2("string"==typeof e?dR(e):e,r);if(t(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 dJ(e,n={},t){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==n&&(n={});let r=d5(n,dV);return Promise.resolve(d2("string"==typeof e?dR(e):e,r)).then(n=>{if(t(n))return n;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 dX(e){return dR(e)}function dQ(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function d0(e){return"boolean"==typeof e}function d1(e){return"number"==typeof e}function d2(e,n){switch(e.type){case"UnaryExpression":var t,r,a,o,i,s,l,c,u,p,d,f,h=e,m=n;let g=d2(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var y=e,b=n;let v=d2(y.left,b),$=d2(y.right,b);switch(y.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${y.operator}' operator`}case"ConditionalExpression":return t=e,r=n,d2(t.test,r)?d2(t.consequent,r):d2(t.alternate,r);case"CallExpression":var w=e,A=n;let k=w.arguments?.map(d4(A)),x=d2(w.callee,A);if(x){if("function"!=typeof x)throw`${d8(w.callee)} is not a function`}else throw`No function named ${d8(w.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return a=e,o=n,C=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<C.length)throw`Required argument(s) ${C.slice(e.length,-1).join(", ")} were not provided`;let n=Object.fromEntries(C.reduce((n,t,r)=>{let a=e[r];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(a)&&n.push([t,a]),n},[]));return d2(a.body,o.addVariables(n))}).bind(o.thisObj??null);case"MemberExpression":return function(e,n){let t,r=d2(e.object,n);if(void 0===r)switch(e.object.type){case"Identifier":{let t=d3(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=d3(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let a=r;if("string"==typeof r)a=String.prototype;else if("number"==typeof r)a=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(n.thisObj=a,e.property.type){case"Identifier":case"MemberExpression":t=d2(e.property,n);break;default:{let a=d2(e.property,n);if(void 0===a)throw{type:"Illegal property access",message:"No property was supplied to the property access"};d6(a),t=r[a]}}return"function"==typeof t?t.bind(r):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(d4(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(d4(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(d4(D));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 d6((u=e).value),u.value;case"Identifier":var z=e,M=n;d6(z.name);let P=M.thisObj;if(P&&("object"==typeof P||"function"==typeof P)&&z.name in P){let e=P[z.name];return d6(e),e}if(M.variables&&z.name in M.variables){let e=M.variables[z.name];return d6(e),e}return z.name in M.globals?M.globals[z.name]:void 0;case"TemplateLiteral":let O,T;return p=e,d=n,O=p.expressions?.map(d4(d))??[],(T=p.quasis?.map(d4(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+O.join("")+T.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 d3(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return d3(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function d5(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function d4(e){return function(n){return null===n?null:d2(n,e)}}function d6(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function d8(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function d7(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 n={globals:{...dV},isLocalExpression:!1,variables:new Set};return d9("string"==typeof e?dR(e):e,n),[...n.variables]}function d9(e,n){switch(e.type){case"UnaryExpression":return r=e,a=n,d9(r.argument,a);case"BinaryExpression":return o=e,i=n,[d9(o.left,i),d9(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[d9(s.consequent,l),d9(s.test,l),d9(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,u=n,t=d9(c.callee,u),c.arguments?.map(fe(u)),t;case"ArrowFunctionExpression":var r,a,o,i,s,l,c,u,p,d,f,h,m,g,y,b,v,$,w=e,A=n;let k={...A};k.isLocalExpression=!0;let x=w.params?.map(fe(k))??[],C=d9(w.body,k)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||A.variables.add(e);return;case"MemberExpression":let E;return p=e,d=n,d9(p.object,d),void((E={...d}).isLocalExpression=!0,d9(p.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(fe(h));case"SequenceExpression":return m=e,g=n,void m.expressions?.map(fe(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(fe(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=n;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(fe($)),v.quasis?.map(fe($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function fe(e){return function(n){return null===n?null:d9(n,e)}}dR.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:dL,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=dL,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),dR.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let r=n.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),dR.plugins.register({name:"numbers",init(e){function n(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 t(n){let t=this.index,r="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(r+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(r+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(i===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:r},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let u="";for(;a=this.code,o=c,95===a||o.some(([e,n])=>a>=e&&a<=n);)95===this.code?this.index++:u+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,r);return}this.throwError("unexpected char within number")}r.node={type:e.LITERAL,value:parseInt(u,"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)&&t.call(this,r)})}}),dR.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,a=this.expr.slice(t,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{r=new RegExp(a,o)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:r,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),dR.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),dR.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},r="",a="",o=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:a,cooked:r},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",r="",n.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":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=i}else r+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),dR.addBinaryOp("in",7),dR.addBinaryOp("??",1);let fn=q("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...r}}return e}()});function ft(e,n,t){fn.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:n,description:t}}}))}function fr(){let e=fn.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(n=>{let t=n.replace("openmrs:feature-flag:","");e[t]||(localStorage.removeItem(n),localStorage.removeItem(`openmrs:feature-flag-meta:${t}`))})}function fa(e){return fn.getState().flags[e].enabled}function fo(e,n){fn.subscribe(t=>{n(t.flags[e].enabled)})}function fi(e,n){fn.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function fs(e){return!window.offlineEnabled||(e??navigator.onLine)}fn.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var fl=to(function(e,n,t){n8(e,n,t)});function fc(e=!0,n=!1){return fu(fs(),e,n)}function fu(e,n=!0,t=!1){return!!(e?n:t)}let fp=U("extensionsInternal",{slots:{},extensions:{}}),fd=()=>q("extensionsInternal",{slots:{},extensions:{}});function ff(e){let n=fp.getState(),t=e(n);t!==n&&fp.setState(t)}let fh=()=>q("extensions",{slots:{}});function fm(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});tZ(rV.getState().mountedExtensions,n)||rV.setState({mountedExtensions:n})}fm(fp.getState()),fp.subscribe(fm);let fg=fd(),fy=fh(),fb=rU(),f_=rK();function fv(e,n,t,r,a){let o={},i=fs(),s=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,l]of Object.entries(e.slots)){let{config:c}=rq(n,l.name),u=fM(r,e,c,t,s,i,a.session);o[r]={moduleName:l.moduleName,assignedExtensions:u}}tZ(fy.getState().slots,o)||fy.setState({slots:o})}function f$(){fv(fg.getState(),fb.getState(),f_.getState(),fn.getState(),ih.getState())}function fw(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function fA(e){let[n]=e.split("#");return n}function fk(e,n){let t=fA(n);return e.extensions[t]}function fx(e){return fk(fg.getState(),e)}fg.subscribe(e=>{fv(e,fb.getState(),f_.getState(),fn.getState(),ih.getState())}),fb.subscribe(e=>{fv(fg.getState(),e,f_.getState(),fn.getState(),ih.getState())}),f_.subscribe(e=>{fv(fg.getState(),fb.getState(),e,fn.getState(),ih.getState())}),fn.subscribe(e=>{fv(fg.getState(),fb.getState(),f_.getState(),e,ih.getState())}),ih.subscribe(e=>{fv(fg.getState(),fb.getState(),f_.getState(),fn.getState(),e)}),f$(),y(f$);let fC=e=>fg.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function fE(e,n){ff(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[...r.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...fw(e),attachedIds:[n]}}}})}function fS(e,n){ff(t=>{let r=t.slots[e];return r&&r.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==n)}}}:t})}function fD(e){ff(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function fz(e,n,t,r){let a=n.indexOf(e);if(-1!==a)return a;{if(void 0!==t)return 1e3+t;let n=r.indexOf(e);return -1!==n?2e3+n:-1}}function fM(e,n,t,r,a,o,i){let s=function(e,n){let t=e.add||[],r=e.remove||[],a=e.order||[],{extensions:o}=fg.getState();return[...n,...t].filter(e=>!r.includes(e)).sort((e,t)=>{let r=fz(e,a,o[fA(e)]?.order,n),i=fz(t,a,o[fA(t)]?.order,n);return -1===i?-1:-1===r?1:r-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,u=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=rZ(r,e,c),p=fl(s,rJ(t,e,c)),d=fA(c),f=n.extensions[d];if(f){let n=p?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!i$(n,i.user)))continue;let t=p?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!dH(t,u))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${d} in slot ${e}`,n);continue}if(f.featureFlag&&!a.includes(f.featureFlag)||window.offlineEnabled&&!fu(o,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1})}}return l}function fP(e){let n=fg.getState(),{config:t}=rH(e),r=f_.getState(),a=fn.getState(),o=ih.getState(),i=fs();return fM(e,n,t,r,Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,o.session)}let fO=(e,n,t)=>fg.setState(r=>{let a=r.slots[n]?.moduleName;if(a&&a!=e)return console.warn(`An extension slot with the name '${n}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${a}.`),r;if(a&&a==e)return r;if(r.slots[n])return{...r,slots:{...r.slots,[n]:{...r.slots[n],moduleName:e,state:t}}};let o=fw(n,e,t);return{...r,slots:{...r.slots,[n]:{...o}}}});function fT(e,n,t=!1){fg.setState(r=>{let a=t?fl(r.slots[e].state,n):n;return{...r,slots:{...r.slots,[e]:{...r.slots[e],state:a}}}})}let fN=()=>fy.setState(()=>({slots:{},extensions:{}})),fI=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function fB({name:e,basePath:n,mode:t,componentContext:r,state:a}){fI.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:r,state:a})}function fj(e){fI.getState().slotName===e&&fI.setState(fI.getInitialState(),!0)}let fR=U("modalRegistry",{modals:{}});function fF(e){fR.setState(n=>(n.modals[e.name]=e,n))}function fL(e){let n=fR.getState().modals[e];if(!n){let t=fx(e);t&&(n={name:e,load:t.load,moduleName:t.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.`),fF(n))}return n}let fW=U("workspaceRegistrations",{workspaces:{}}),fV=U("workspaceGroups",{workspaceGroups:{}});function fG(e){fW.setState(n=>({workspaces:{...n.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function fU(e){fV.setState(n=>{let t=n.workspaceGroups[e.name];return t?{workspaceGroups:{...n.workspaceGroups,[e.name]:{...t,members:Array.from(new Set([...t.members,...e.members]))}}}:{workspaceGroups:{...n.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let fH=new Set;function fq(e){let n=fW.getState().workspaces;if(n[e])return n[e];{let n=fx(e);if(n){var t;let r;return fH.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),fH.add(e)),{name:n.name,title:(t=n,"string"==typeof(r=t?.meta?.title)?r:r&&"object"==typeof r?su(t.moduleName,r.key,r.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function fK(e){let n=fV.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let fY=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function fZ(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=fY.getState(),r=n[e];if(r){let n=t[r.window];if(n)return n;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function fJ(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=fY.getState(),r=t[e];if(r){let t=n[r.group];if(t)return t;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fX(e){let{openedWindows:n}=fY.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function fQ(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=fY.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);r[t.name]={...t,moduleName:e}}fY.setState({registeredGroupsByName:r})}function f0(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=fY.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}fY.setState({registeredWindowsByName:r})}function f1(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=fY.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}fY.setState({registeredWorkspacesByName:r})}let f2=0;async function f3(e,n,t,r,a=e=>e,o={}){let i=fA(r),s=fx(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(fc(p,d)){ff(a=>({...a,extensions:{...a.extensions,[i]:{...a.extensions[i],instances:[...a.extensions[i].instances,{domElement:e,id:r,slotName:n,slotModuleName:t}]}}}));let s=await f(),p=f2++;l=os(a({...s,name:`${n}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:u},domElement:e})}}else console.warn(`Tried to render ${r} into ${n} but no DOM element was available.`);return l}var f5=t(7125),f4=t.n(f5);let f6=(0,f5.createContext)({moduleName:"",featureName:""});function f8({to:e,templateParams:n,onBeforeNavigate:t,children:r,...a}){return(0,f5.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}`)},[]),f4().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),t?.(r),o4({to:e,templateParams:n})),0===r.button&&(r.ctrlKey||r.metaKey)&&t?.(r),0===r.button&&r.shiftKey&&t?.(r),1===r.button&&t?.(r)},href:o3(e,n),...a},r)}let f7=({state:e,children:n,...t})=>{let{extension:r}=(0,f5.useContext)(f6),a=(0,f5.useRef)(null),o=(0,f5.useRef)(Promise.resolve()),i=(0,f5.useCallback)(n=>{r?.extensionSlotName&&r.extensionSlotModuleName&&r.extensionSlotModuleName&&!a.current&&f3(n,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(e=>{a.current=e})},[]);return(0,f5.useEffect)(()=>()=>{if(a&&a.current)switch(a.current.getStatus()){case"MOUNTING":a.current.mountPromise.then(()=>{a.current?.getStatus()==="MOUNTED"&&a.current.unmount()});break;case"MOUNTED":a.current.unmount();break;case"UPDATING":o.current&&o.current.then(()=>{a.current?.getStatus()==="MOUNTED"&&a.current.unmount()})}},[]),(0,f5.useEffect)(()=>{a.current&&a.current.update&&"UNMOUNTING"!==a.current.getStatus()&&Promise.all([a.current.mountPromise,o.current]).then(()=>{a?.current?.getStatus()==="MOUNTED"&&a.current.update&&(o.current=a.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||a.current?.getStatus()==="MOUNTED")throw e}))})},[e]),r?f4().createElement("div",{ref:i,"data-extension-id":r?.extensionId,style:{position:"relative"},...t}):null};function f9(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[r,a]of Object.entries(n)){let n=function(...n){e.setState(e=>a(e,...n))};t[r]=n}return t}let he=()=>e=>e;function hn(e,n=he(),t){let r=(0,f5.useCallback)(n=>e.subscribe(n),[e]),a=(0,f5.useCallback)(()=>n(e.getState()),[e,n]),o=(0,f5.useSyncExternalStore)(r,a,a),i=(0,f5.useMemo)(()=>t?f9(e,t):{},[e,t]);return{...o,...i}}function ht(e,n){return hn(e,he(),n)}function hr(e){return function(n){let t=(0,f5.useCallback)(n=>e.subscribe(n),[]),r=(0,f5.useCallback)(()=>e.getState(),[]),a=(0,f5.useSyncExternalStore)(t,r,r),o=(0,f5.useMemo)(()=>n?f9(e,n):{},[n]);return{...a,...o}}}let ha=e=>hn(fh(),n=>n.slots?.[e]);function ho(e){let n=ha(e);return n?.assignedExtensions??[]}function hi(e,n){let{moduleName:t}=(0,f5.useContext)(f6),r=(0,f5.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,f5.useEffect)(()=>{fO(t,e,n),r.current=!1},[]),(0,f5.useEffect)(()=>{r.current||fT(e,n)},[e,n]),{extensions:ho(e),extensionSlotName:e,extensionSlotModuleName:t}}function hs(e){return e}function hl({name:e,extensionSlotName:n,select:t=hs,children:r,state:a,style:o,...i}){if(r&&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??n,l=(0,f5.useRef)(null),{extensions:c,extensionSlotModuleName:u}=hi(s,a),p=(0,f5.useMemo)(()=>t(c),[t,c]),d=(0,f5.useMemo)(()=>{if("function"==typeof r&&!f4().isValidElement(r))return p.map(e=>r(e,a))},[r,p]);return f4().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...o,position:"relative"},...i},s&&p?.map((e,n)=>f4().createElement(f6.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[n]??("function"!=typeof r?r:null)??f4().createElement(f7,{state:a}))))}var hc=t(5873);function hu(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function hp(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?hu(Object(t),!0).forEach(function(n){var r,a,o;r=e,a=n,o=t[n],a in r?Object.defineProperty(r,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):hu(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function hd(e){return(hd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function hf(e){return(hf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function hh(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(hf(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(hf(e)));return e}}var hm=null;try{hm=require("react").createContext()}catch(e){}var hg={React:null,ReactDOM:null,ReactDOMClient:null,rootComponent:null,loadRootComponent:null,errorBoundary:null,errorBoundaryClass:null,domElementGetter:null,parcelCanUpdate:!0,suppressComponentDidCatchWarning:!1,domElements:{},renderResults:{},updateResolves:{},unmountResolves:{}};function hy(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function hb(e,n){return new Promise(function(t,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=hw(e,n,function(){t(this)}),i=hh(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,r=e.elementToRender,a=e.domElement,o=n[t];if("function"!=typeof o)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(r),i;case"hydrateRoot":return o(a,r);default:return o(r,a),null}}({elementToRender:o,domElement:i,reactDom:h$(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function h_(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var r=e.renderResults[n.name];r&&r.unmount?r.unmount():h$(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function hv(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var r=hw(e,n,null),a=e.renderResults[n.name];if(a&&a.render)a.render(r);else{var o=hh(e,n)();h$(e).render(r,o)}})}function h$(e){return e.ReactDOMClient||e.ReactDOM}function hw(e,n,t){var r=e.React.createElement(e.rootComponent,n),a=hm?e.React.createElement(hm.Provider,{value:n},r):r;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),a=e.React.createElement(e.errorBoundaryClass,n,a)),a=e.React.createElement(e.SingleSpaRoot,hp(hp({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),a)}var hA=t(5921),hk=t(1123),hx=t(9106);let hC={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},hE=new Map;(0,hx.initCache)(hE);let hS={errorRetryCount:3,fetcher:iu,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof id){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>hE};function hD(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},hC,e),t={...hS,...n.swrConfig};return function(e){var r,a,o,i,s;return o=a=class extends(r=f4().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return f4().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=f4().createElement(f5.Suspense,{fallback:null},f4().createElement(hk.BE,{value:t},f4().createElement(f6.Provider,{value:this.state.config},n.disableTranslations?f4().createElement(e,this.props):f4().createElement(hA.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},f4().createElement(e,this.props)))));return n.strictMode&&f4().StrictMode?f4().createElement(f4().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${n.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function hz(e,n){return function(e){if("object"!==hd(e))throw Error("single-spa-react requires a configuration object");var n,t=hp(hp({},hg),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!hm&&t.React.createContext&&(hm=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var r={bootstrap:hy.bind(null,t),mount:hb.bind(null,t),unmount:h_.bind(null,t)};return t.parcelCanUpdate&&(r.update=hv.bind(null,t)),r}({React:f4(),ReactDOMClient:hc,rootComponent:hD(n)(e)})}function hM(e,n){return()=>e().then(({default:e})=>hz(e,n))}function hP(e,n){return()=>Promise.resolve(hz(e,n))}let hO=hM,hT=W()(()=>({}));H("openmrs-app-context",hT);let hN={};function hI(e,n=e=>e){let t=hT.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function hB(e,n){hT.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function hj(e){return null===e?null:Object.freeze(Object.assign({},e))}let hR=new Map;function hF(e,n){let t=(0,f5.useRef)(n??{}),r=(0,f5.useRef)(n=>hB(e,n)),a=(0,f5.useRef)(Symbol());return(0,f5.useEffect)(()=>{let t=n??{},r=a.current;return null===hI(e)?!function(e,n=hN){hT.setState(t=>{if(e in t)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({},t,{[e]:n===hN?{}:n})})}(e,t):(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.`),hB(e,()=>t)),hR.set(e,r),()=>{hR.get(e)===r&&(hT.setState(n=>(e in n&&delete n[e],n)),hR.delete(e))}},[e]),(0,f5.useEffect)(()=>{let r=n??{};j(t.current,r)||(hB(e,()=>r),t.current=r)},[n]),r.current}function hL({namespace:e,value:n}){return hF(e,n),null}let hW=({children:e,value:n,fallback:t})=>n?f4().createElement(f4().Fragment,null,e):t?f4().createElement(f4().Fragment,null,t):null;function hV(){let e=(0,f5.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,f5.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function hG(e,n=e=>e??{}){let[t,r]=(0,f5.useState)(()=>{if(hU(e))return;let t=hI(e);if(null!==t)return n?n(t):t});return(0,f5.useEffect)(()=>{if(hU(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,f5.useEffect)(()=>{var t;let a;return(t=e=>{if(null==e)return void r(void 0);let t=n?n(e):e;r(e=>j(e,t)?e:t)})(hj(a=hI(e))),hT.subscribe(n=>{let r=e in n?n[e]:null;r!==a&&(a=r,t(hj(r)))})},[e,n]),t}function hU(e){return"string"!=typeof e||0===e.trim().length}function hH(e){let[n,t]=(0,f5.useState)([]);return(0,f5.useEffect)(()=>fh().subscribe(r=>{let a=r.slots[e]?.assignedExtensions.map(e=>e.id)??[];tZ(a,n)||t(a)}),[]),n}function hq(e,n){let{data:t,error:r,mutate:a,isLoading:o,isValidating:i}=(0,hk.Ay)(`${s1}?patient=${e}&includeEncounterless=${n}`,iu);return(0,f5.useMemo)(()=>({isLoading:o,data:t?.data.results??[],error:r,mutate:a,isValidating:i}),[t,r,o,i,a])}function hK(e){(0,f5.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let hY={},hZ=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|