@openmrs/esm-appointments-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/2048.js CHANGED
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(tU).join(", ")}.
9
9
  If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(i)}`),s&&l&&![tU.Array,tU.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${r}'. ${o}.
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 og(e,n){return oy(n.map(({[e]:n})=>n).filter(e=>!!e))}function oy(e){return e.reduce((e,n)=>on(e,n),{})}function ob(e,n,t=""){for(let o of Object.keys(n)){let a=n[o],r=t+"."+o,i=e[o];if(!e.hasOwnProperty(o)){("extensionSlots"!==o||""===t)&&oC(r,`Unknown config key '${r}' provided. Ignoring.`);continue}(function e(n,t,o){ov(o,n._type,t),ok(t)?n._type===tU.Object?function(n,t,o){if(n._elements)for(let a of Object.keys(t)){let r=t[a];e(n._elements,r,`${o}.${a}`)}}(n,t,o):n.hasOwnProperty("_default")||n.hasOwnProperty("_type")||ob(n,t,o):n._type===tU.Array&&function(n,t,o){if(ov(o,tU.Array,t)){if(ow(n._elements))for(let a=0;a<t.length;a++)e(n._elements,t[a],`${o}[${a}]`);for(let e=0;e<t.length;e++)ov(`${o}[${e}]`,n._elements?._type,t[e])}}(n,t,o)})(i,a,r)}}oa();function o_(e,n,t=""){if(e){if(n!==e._default&&o$(t,e._validators,n),ok(n))for(let o of Object.keys(n)){let a=n[o],r=t+"."+o,i=e[o];e._type===tU.Object&&e._elements?o_(e._elements,a,r):o_(i,a,r)}else if(Array.isArray(n)&&e._elements)for(let o=0;o<n.length;o++)o_(e._elements,n[o],`${t}[${o}]`)}}function ov(e,n,t){return!n||o$(e,[{Array:tq,Boolean:tK,ConceptUuid:tX,Number:tY,Object:tJ,String:tZ,UUID:tX,PersonAttributeTypeUuid:tX,PatientIdentifierTypeUuid:tX}[n]],t)}function o$(e,n,t){let o=!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}`;oC(e,a),o=!1}}}catch(n){console.error(`Skipping invalid validator at "${e}". Encountered error
12
- ${n}`)}return o}let oA=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let o=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(o&&ow(e)){if(a._type===tU.Array&&Array.isArray(o)){let a=o.map(n=>oA(e,n));t[n]=a}else if(a._type===tU.Object)for(let n of Object.keys(o))o[n]=oA(e,o[n])}}else if(ok(a)){let e=o??{};ok(e)&&(t[n]=oA(a,e))}}return t};function ow(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ok(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let ox=new Set;function oC(e,n){let t=`${e}:::${n}`;ox||(ox=new Set),ox.has(t)||(console.error(n),ox.add(t))}function oE(e){e?ox.forEach(n=>{n.startsWith(e)&&ox.delete(n)}):ox.clear()}function oS(){ot.forEach(e=>e()),ot.length=0,oa()}let oD={"Translation overrides":{_description:"Per-language overrides for frontend translations should be keyed by language code and each language dictionary contains the translation key and the display value",_type:tU.Object,_default:{},_validators:[tH(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(", ")}.`})]}},oz={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:tU.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:tU.String,_default:void 0}},...oD},oM=(e,n)=>tH(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),oP=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return tH(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,o=t.exec(e);for(;o;){if(!n.includes(o[1]))return!1;o=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},oO=oP([]),oT=e=>tH(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),oN={inRange:oM,isUrl:oO,isUrlWithTemplateParameters:oP,oneOf:oT};var oI=t(2034);let oB=U("breadcrumbs",[]);function oj(e){return oR([e])}function oR(e){let n=[...oF(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,oI.pathToRegexp)(e.matcher).regexp:(0,oI.pathToRegexp)(e.path).regexp,settings:e}))];oB.setState(n,!0)}function oF(){return oB.getState()}function oL(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=oL(e,t.join("/"));if(n)return n}}(e,n)}function oW(e,n){if(e.length>0){let t=oL(e,n);if(t){let n=[t],o=oL(e,t.settings.parent);for(;void 0!==o;)n.push(o),o=oL(e,o.settings.parent);return n.reverse()}}return[]}function oV(e){return oW(oF(),e)}var oG=Object.freeze({__proto__:null,get start(){return ra},get ensureJQuerySupport(){return aV},get setBootstrapMaxTime(){return ak},get setMountMaxTime(){return ax},get setUnmountMaxTime(){return aC},get setUnloadMaxTime(){return aE},get registerApplication(){return a0},get unregisterApplication(){return a2},get getMountedApps(){return aZ},get getAppStatus(){return aX},get unloadApplication(){return a3},get checkActivityFunctions(){return a1},get getAppNames(){return aJ},get pathToActiveWhen(){return a6},get navigateToUrl(){return aT},get patchHistoryApi(){return aF},get triggerAppChange(){return re},get addErrorHandler(){return oY},get removeErrorHandler(){return oZ},get mountRootParcel(){return a_},get NOT_LOADED(){return oQ},get LOADING_SOURCE_CODE(){return o0},get NOT_BOOTSTRAPPED(){return o1},get BOOTSTRAPPING(){return o2},get NOT_MOUNTED(){return o3},get MOUNTING(){return o5},get UPDATING(){return o6},get LOAD_ERROR(){return o9},get MOUNTED(){return o4},get UNLOADING(){return o7},get UNMOUNTING(){return o8},get SKIP_BECAUSE_BROKEN(){return ae}}),oU=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,oH=!function(){try{var e=new oU("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}:oU;let oq=[];function oK(e,n,t){let o=oX(e,n,t);oq.length?oq.forEach(e=>e(o)):setTimeout(()=>{throw o})}function oY(e){if("function"!=typeof e)throw Error(oJ(28,!1));oq.push(e)}function oZ(e){if("function"!=typeof e)throw Error(oJ(29,!1));let n=!1;return oq=oq.filter(t=>{let o=t===e;return n=n||o,!o}),n}function oJ(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 oX(e,n,t){let o,a=`${ar(n)} '${ao(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}o=e}else{console.warn(oJ(30,!1,n.status,ao(n)));try{o=Error(a+JSON.stringify(e))}catch(n){o=e}}return o.appOrParcelName=ao(n),n.status=t,o}let oQ="NOT_LOADED",o0="LOADING_SOURCE_CODE",o1="NOT_BOOTSTRAPPED",o2="BOOTSTRAPPING",o3="NOT_MOUNTED",o5="MOUNTING",o4="MOUNTED",o6="UPDATING",o8="UNMOUNTING",o7="UNLOADING",o9="LOAD_ERROR",ae="SKIP_BECAUSE_BROKEN";function an(e){return e.status===o4}function at(e){try{return e.activeWhen(window.location)}catch(n){return oK(n,e,ae),!1}}function ao(e){return e.name}function aa(e){return!!e.unmountThisParcel}function ar(e){return aa(e)?"parcel":"application"}function ai(){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 as(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function al(e){return e&&("function"==typeof e||Array.isArray(e)&&!as(e,e=>"function"!=typeof e))}function ac(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let o=ar(e),a=ao(e);return function(e){return t.reduce((t,r,i)=>t.then(()=>{let t=r(e);return ap(t)?t:Promise.reject(oJ(15,!1,o,a,n,i))}),Promise.resolve())}}function ap(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let au=[];function ad(e,n){return Promise.resolve().then(()=>e.status!==o1?e:(e.status=o2,e.bootstrap?aS(e,"bootstrap").then(t).catch(t=>{if(n)throw oX(t,e,ae);return oK(t,e,ae),e}):Promise.resolve().then(t)));function t(){return e.status=o3,e}}function af(e,n){return Promise.resolve().then(()=>{if(e.status!==o4)return e;return e.status=o8,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,o=>t().then(()=>{let t=Error(o.message);if(n)throw oX(t,e,ae);oK(t,e,ae)})).then(()=>e);function t(){return aS(e,"unmount").then(()=>{e.status=o3},t=>{if(n)throw oX(t,e,ae);oK(t,e,ae)})}})}let ah=!1,am=!1;function ag(e,n){return Promise.resolve().then(()=>e.status!==o3?e:(ah||(window.dispatchEvent(new oH("single-spa:before-first-mount")),ah=!0),e.status=o5,aS(e,"mount").then(()=>(e.status=o4,am||(window.dispatchEvent(new oH("single-spa:first-mount")),am=!0),e)).catch(t=>{return e.status=o4,af(e,!0).then(o,o);function o(){if(n)throw oX(t,e,ae);return oK(t,e,ae),e}})))}let ay=0,ab={parcels:{}};function a_(){return av.apply(ab,arguments)}function av(e,n){let t,o,a,r=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(oJ(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(oJ(3,!1,typeof e.name));let i=ay++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(oJ(4,!1,s,typeof n));if(!n.domElement)throw Error(oJ(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?o0:o1,customProps:n,parentName:ao(r),unmountThisParcel:()=>f.then(()=>{if(p.status!==o4)throw Error(oJ(6,!1,s,p.status));return af(p,!0)}).then(e=>(p.parentName&&delete r.parcels[p.id],e)).then(e=>(o(e),e)).catch(e=>{throw p.status=ae,a(e),e})};r.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(oJ(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(oJ(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!al(e.bootstrap))throw Error(oJ(9,!1,s));if(!al(e.mount))throw Error(oJ(10,!1,s));if(!al(e.unmount))throw Error(oJ(11,!1,s));if(e.update&&!al(e.update))throw Error(oJ(12,!1,s));let n=ac(e,"bootstrap"),o=ac(e,"mount"),a=ac(e,"unmount");p.status=o1,p.name=s,p.bootstrap=n,p.mount=o,p.unmount=a,p.timeouts=aD(e.timeouts),e.update&&(p.update=ac(e,"update"),t.update=function(e){return p.customProps=e,a$(Promise.resolve().then(()=>{if(p.status!==o4)throw Error(oJ(32,!1,ao(p)));return p.status=o6,aS(p,"update").then(()=>(p.status=o4,p)).catch(e=>{throw oX(e,p,ae)})}))})})).then(()=>ad(p,!0)),f=d.then(()=>ag(p,!0)),h=new Promise((e,n)=>{o=e,a=n});return t={mount:()=>a$(Promise.resolve().then(()=>{if(p.status!==o3)throw Error(oJ(13,!1,s,p.status));return r.parcels[i]=p,ag(p)})),unmount:()=>a$(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:a$(u),bootstrapPromise:a$(d),mountPromise:a$(f),unmountPromise:a$(h)}}function a$(e){return e.then(()=>null)}function aA(e){let n=ao(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(oJ(40,!1),n,t));let o=ai({},t,{name:n,mountParcel:av.bind(e),singleSpa:oG});return aa(e)&&(o.unmountSelf=e.unmountThisParcel),o}let aw={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 ak(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(16,!1));aw.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ax(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(17,!1));aw.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aC(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(18,!1));aw.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aE(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(19,!1));aw.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aS(e,n){let t=e.timeouts[n],o=t.warningMillis,a=ar(e);return new Promise((r,i)=>{let s=!1,l=!1;e[n](aA(e)).then(e=>{s=!0,r(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),o),setTimeout(()=>p(!0),t.millis);let c=oJ(31,!1,n,a,ao(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*o+o<t.millis&&setTimeout(()=>p(e+1),o)))}})}function aD(e){let n={};for(let t in aw)n[t]=ai({},aw[t],e&&e[t]||{});return n}function az(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==oQ&&e.status!==o9?e:(e.status=o0,e.loadPromise=Promise.resolve().then(()=>{let o=e.loadApp(aA(e));if(!ap(o))throw t=!0,Error(oJ(33,!1,ao(e)));return o.then(t=>{let o;e.loadErrorTime=null,"object"!=typeof(n=t)&&(o=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!al(n.bootstrap)&&(o=35),al(n.mount)||(o=36),al(n.unmount)||(o=37);let a=ar(n);if(o){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(oJ(o,!1,a,ao(e),t),n),oK(void 0,e,ae),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=ai({},e.devtools.overlays,n.devtools.overlays)),e.status=o1,e.bootstrap=ac(n,"bootstrap"),e.mount=ac(n,"mount"),e.unmount=ac(n,"unmount"),e.unload=ac(n,"unload"),e.timeouts=aD(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let o;return delete e.loadPromise,t?o=ae:(o=o9,e.loadErrorTime=(new Date).getTime()),oK(n,e,o),e}))})}let aM="u">typeof window,aP={hashchange:[],popstate:[]},aO=["hashchange","popstate"];function aT(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(oJ(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=aL(window.location.href),o=aL(n);0===n.indexOf("#")?window.location.hash=o.hash:t.host!==o.host&&o.host?window.location.href=n:o.pathname===t.pathname&&o.search===t.search?window.location.hash=o.hash:window.history.pushState(null,null,n)}function aN(e){if(e){let n=e[0].type;aO.indexOf(n)>=0&&aP[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function aI(){rn([],arguments)}function aB(e,n){return function(){let t=window.location.href,a=e.apply(this,arguments),r=window.location.href;return o&&t===r||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 aj=null,aR=!1;function aF(e){if(aR)throw Error(oJ(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,aR=!0,aj=window.history.replaceState,window.addEventListener("hashchange",aI),window.addEventListener("popstate",aI);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&aO.indexOf(e)>=0)||as(aP[e],e=>e===t))return n.apply(this,arguments);aP[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&aO.indexOf(e)>=0&&(aP[e]=aP[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=aB(window.history.pushState,"pushState"),window.history.replaceState=aB(aj,"replaceState")}function aL(e){let n=document.createElement("a");return n.href=e,n}aM&&(window.singleSpaNavigate?console.warn(oJ(41,!1)):window.singleSpaNavigate=aT);let aW=!1;function aV(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!aW){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return aG.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return aG.call(this,t,window.removeEventListener,e,n,arguments)},aW=!0}}function aG(e,n,t,o,a){return"string"!=typeof t?e.apply(this,a):(t.split(/\s+/).forEach(e=>{aO.indexOf(e)>=0&&(n(e,o),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,a))}let aU={};function aH(e){return Promise.resolve().then(()=>{let n=aU[ao(e)];if(!n)return e;if(e.status===oQ)return aq(e,n),e;if(e.status===o7)return n.promise.then(()=>e);if(e.status!==o3&&e.status!==o9)return e;let t=e.status===o9?Promise.resolve():aS(e,"unload");return e.status=o7,t.then(()=>(aq(e,n),e)).catch(t=>(delete aU[ao(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,oK(t,e,ae),n.reject(t),e))})}function aq(e,n){delete aU[ao(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oQ,n.resolve()}function aK(e,n,t,o){aU[ao(e)]={app:e,resolve:t,reject:o},Object.defineProperty(aU[ao(e)],"promise",{get:n})}let aY=[];function aZ(){return aY.filter(an).map(ao)}function aJ(){return aY.map(ao)}function aX(e){let n=as(aY,n=>ao(n)===e);return n?n.status:null}let aQ=!1;function a0(e,n,t,o){var a,r;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(oJ(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(oJ(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(oJ(20,!1));let o=e=>"string"==typeof e||"function"==typeof e;if(!(o(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(o)))throw Error(oJ(24,!1));if(!a4(e.customProps))throw Error(oJ(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,o){if("string"!=typeof e||0===e.length)throw Error(oJ(20,!1));if(!n)throw Error(oJ(23,!1));if("function"!=typeof t)throw Error(oJ(24,!1));if(!a4(o))throw Error(oJ(22,!1))}(e,n,t,o),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=o),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(r=i.activeWhen)?r:[r]).map(e=>"function"==typeof e?e:a6(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(ro||aQ||(aQ=!0,setTimeout(()=>{ro||console.warn(oJ(1,!1))},5e3)),-1!==aJ().indexOf(l.name))throw Error(oJ(21,!1,l.name));aY.push(ai({loadErrorTime:null,status:oQ,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),aM&&(aV(),rn())}function a1(e=window.location){return aY.filter(n=>n.activeWhen(e)).map(ao)}function a2(e){if(0===aY.filter(n=>ao(n)===e).length)throw Error(oJ(25,!1,e));return(aM?a3(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=aY.map(ao).indexOf(e);aY.splice(n,1)})}function a3(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(oJ(26,!1));let t=as(aY,n=>ao(n)===e);if(!t)throw Error(oJ(27,!1,e));let o=aU[ao(t)];if(n&&n.waitForUnmount){if(o)return o.promise;{let e=new Promise((n,o)=>{aK(t,()=>e,n,o)});return e}}{let e;return o?(e=o.promise,a5(t,o.resolve,o.reject)):e=new Promise((n,o)=>{aK(t,()=>e,n,o),a5(t,n,o)}),e}}function a5(e,n,t){Promise.resolve().then(()=>{if(as(a1(),n=>n===ao(e)))return re()}).then(()=>af(e).then(aH).then(()=>{n(),setTimeout(()=>{rn()})})).catch(t)}function a4(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function a6(e,n){let t=function(e,n){let t=0,o=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],a=o&&"/"===t;(!o&&":"===t||a)&&r(n)}return r(e.length),RegExp(a,"i");function r(r){let i=e.slice(t,r).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=o?"[^/]+/?":i,r===e.length)if(o)n&&(a+="$");else{let e=n?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}o=!o,t=r}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let o=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(o)}}let a8=!1,a7=[],a9=aM&&window.location.href;function re(){return rn()}function rn(e=[],n,t=!1){let o,a,r,i,s;if(a8)return new Promise((e,t)=>{a7.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(o=[],a=[],r=[],i=[],s=(new Date).getTime(),aY.forEach(e=>{let n=e.status!==ae&&at(e);switch(e.status){case o9:n&&s-e.loadErrorTime>=200&&r.push(e);break;case oQ:case o0:n&&r.push(e);break;case o1:case o3:!n&&aU[ao(e)]?o.push(e):n&&i.push(e);break;case o4:n||a.push(e)}}),{appsToUnload:o,appsToUnmount:a,appsToLoad:r,appsToMount:i}),d,f=[],h=a9,m=a9=window.location.href;return ro?(a8=!0,d=l.concat(p,c,u),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 aj.call(window.history,history.state,"",h.substring(location.origin.length)),a9=location.href,a8=!1,rn(e,n,!0);let o=l.map(aH),a=Promise.all(c.map(af).map(e=>e.then(aH)).concat(o));a.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let r=p.map(e=>az(e).then(e=>rt(e,a))),i=u.filter(e=>0>p.indexOf(e)).map(e=>rt(e,a));return a.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(r.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(az)).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(oJ(42,!1))),console.warn(e),!1)))}function y(){let n=aZ();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(a8=!1,a7.length>0){let e=a7;a7=[],rn(e)}return n}function b(){t||(e.forEach(e=>{aN(e.eventArguments)}),aN(n))}function v(e=!1,t){let o={},a={[o4]:[],[o3]:[],[oQ]:[],[ae]:[]};e?(p.concat(u).forEach((e,n)=>{i(e,o4)}),l.forEach(e=>{i(e,oQ)}),c.forEach(e=>{i(e,o3)})):d.forEach(e=>{i(e)});let r={detail:{newAppStatuses:o,appsByNewStatus:a,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&ai(r.detail,t),r;function i(e,n){let t=ao(e);n=n||aX(t),o[t]=n,(a[n]=a[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new oH(`single-spa:${e}`,n))}}function rt(e,n){return at(e)?ad(e).then(e=>n.then(()=>at(e)?ag(e):e)):n.then(()=>e)}let ro=!1;function ra(e){ro=!0,aM&&(aF(e),rn())}function rr(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return ri(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function ri(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function rs({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),o=rr(e,n).replace(window.location.origin,"");o.startsWith(t)?aT(o):window.location.assign(o)}aM&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aY]},reroute:rn,NOT_LOADED:oQ,toLoadPromise:az,toBootstrapPromise:ad,unregisterApplication:a2,getProfilerData:function(){return au}});let rl="openmrs:history";function rc(e){let n=JSON.parse(sessionStorage.getItem(rl)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(rl,JSON.stringify(n))}function rp(){0===JSON.parse(sessionStorage.getItem(rl)??"[]").length&&document.referrer&&rc(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=ru();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(rl,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?rd({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&rc(window.location.href)})}function ru(){return JSON.parse(sessionStorage.getItem(rl)??"[]")}function rd({toUrl:e}){let n=ru(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);rs({to:n[t]}),sessionStorage.setItem(rl,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rf(){sessionStorage.removeItem(rl)}let rh="${openmrsSpaBase}/login",rm={redirectAuthFailure:{enabled:{_type:tU.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:tU.String,_default:rh,_validators:[oN.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:tU.Array,_default:[401],_elements:{_type:tU.Number,_validators:[oN.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:tU.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}},followRedirects:{_type:tU.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function rg(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let ry="/ws/rest/v1",rb="/ws/fhir2/R4",r_=`${ry}/session`;function rv(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function r$(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=rv(e);if(n.headers||(n.headers={}),eO(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(ry)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rb)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let o=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:a}=await ou("@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&&rs({to:n})}return e.data=null,e}return t===rv(r_)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(rf(),rs({to:n.url||e.headers.get("location")||rh}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let a=n;try{a=JSON.parse(n)}catch(e){}throw new rw(t,e,a,o)},n=>{throw new rw(t,e,null,o)})})}function rA(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 ek(o=>{let a=!1;return r$(e,n).then(e=>{a=!0,o.next(e),o.complete()},e=>{a=!0,o.error(e)}),()=>{a||t.abort()}})}class rw extends Error{constructor(e,n,t,o){super(),rg(this,"response",void 0),rg(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`,o.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
12
+ ${n}`)}return o}let oA=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let o=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(o&&ow(e)){if(a._type===tU.Array&&Array.isArray(o)){let a=o.map(n=>oA(e,n));t[n]=a}else if(a._type===tU.Object)for(let n of Object.keys(o))o[n]=oA(e,o[n])}}else if(ok(a)){let e=o??{};ok(e)&&(t[n]=oA(a,e))}}return t};function ow(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ok(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let ox=new Set;function oC(e,n){let t=`${e}:::${n}`;ox||(ox=new Set),ox.has(t)||(console.error(n),ox.add(t))}function oE(e){e?ox.forEach(n=>{n.startsWith(e)&&ox.delete(n)}):ox.clear()}function oS(){ot.forEach(e=>e()),ot.length=0,oa()}let oD={"Translation overrides":{_description:"Per-language overrides for frontend translations should be keyed by language code and each language dictionary contains the translation key and the display value",_type:tU.Object,_default:{},_validators:[tH(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(", ")}.`})]}},oz={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:tU.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:tU.String,_default:void 0}},...oD},oM=(e,n)=>tH(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),oP=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return tH(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,o=t.exec(e);for(;o;){if(!n.includes(o[1]))return!1;o=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},oO=oP([]),oT=e=>tH(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),oN={inRange:oM,isUrl:oO,isUrlWithTemplateParameters:oP,oneOf:oT};var oI=t(2034);let oB=U("breadcrumbs",[]);function oj(e){return oR([e])}function oR(e){let n=[...oF(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,oI.pathToRegexp)(e.matcher).regexp:(0,oI.pathToRegexp)(e.path).regexp,settings:e}))];oB.setState(n,!0)}function oF(){return oB.getState()}function oL(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=oL(e,t.join("/"));if(n)return n}}(e,n)}function oW(e,n){if(e.length>0){let t=oL(e,n);if(t){let n=[t],o=oL(e,t.settings.parent);for(;void 0!==o;)n.push(o),o=oL(e,o.settings.parent);return n.reverse()}}return[]}function oV(e){return oW(oF(),e)}var oG=Object.freeze({__proto__:null,get start(){return ra},get ensureJQuerySupport(){return aV},get setBootstrapMaxTime(){return ak},get setMountMaxTime(){return ax},get setUnmountMaxTime(){return aC},get setUnloadMaxTime(){return aE},get registerApplication(){return a0},get unregisterApplication(){return a2},get getMountedApps(){return aZ},get getAppStatus(){return aX},get unloadApplication(){return a3},get checkActivityFunctions(){return a1},get getAppNames(){return aJ},get pathToActiveWhen(){return a6},get navigateToUrl(){return aT},get patchHistoryApi(){return aF},get triggerAppChange(){return re},get addErrorHandler(){return oY},get removeErrorHandler(){return oZ},get mountRootParcel(){return a_},get NOT_LOADED(){return oQ},get LOADING_SOURCE_CODE(){return o0},get NOT_BOOTSTRAPPED(){return o1},get BOOTSTRAPPING(){return o2},get NOT_MOUNTED(){return o3},get MOUNTING(){return o5},get UPDATING(){return o6},get LOAD_ERROR(){return o9},get MOUNTED(){return o4},get UNLOADING(){return o7},get UNMOUNTING(){return o8},get SKIP_BECAUSE_BROKEN(){return ae}}),oU=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,oH=!function(){try{var e=new oU("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}:oU;let oq=[];function oK(e,n,t){let o=oX(e,n,t);oq.length?oq.forEach(e=>e(o)):setTimeout(()=>{throw o})}function oY(e){if("function"!=typeof e)throw Error(oJ(28,!1));oq.push(e)}function oZ(e){if("function"!=typeof e)throw Error(oJ(29,!1));let n=!1;return oq=oq.filter(t=>{let o=t===e;return n=n||o,!o}),n}function oJ(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 oX(e,n,t){let o,a=`${ar(n)} '${ao(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}o=e}else{console.warn(oJ(30,!1,n.status,ao(n)));try{o=Error(a+JSON.stringify(e))}catch(n){o=e}}return o.appOrParcelName=ao(n),n.status=t,o}let oQ="NOT_LOADED",o0="LOADING_SOURCE_CODE",o1="NOT_BOOTSTRAPPED",o2="BOOTSTRAPPING",o3="NOT_MOUNTED",o5="MOUNTING",o4="MOUNTED",o6="UPDATING",o8="UNMOUNTING",o7="UNLOADING",o9="LOAD_ERROR",ae="SKIP_BECAUSE_BROKEN";function an(e){return e.status===o4}function at(e){try{return e.activeWhen(window.location)}catch(n){return oK(n,e,ae),!1}}function ao(e){return e.name}function aa(e){return!!e.unmountThisParcel}function ar(e){return aa(e)?"parcel":"application"}function ai(){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 as(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function al(e){return e&&("function"==typeof e||Array.isArray(e)&&!as(e,e=>"function"!=typeof e))}function ac(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let o=ar(e),a=ao(e);return function(e){return t.reduce((t,r,i)=>t.then(()=>{let t=r(e);return ap(t)?t:Promise.reject(oJ(15,!1,o,a,n,i))}),Promise.resolve())}}function ap(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let au=[];function ad(e,n){return Promise.resolve().then(()=>e.status!==o1?e:(e.status=o2,e.bootstrap?aS(e,"bootstrap").then(t).catch(t=>{if(n)throw oX(t,e,ae);return oK(t,e,ae),e}):Promise.resolve().then(t)));function t(){return e.status=o3,e}}function af(e,n){return Promise.resolve().then(()=>{if(e.status!==o4)return e;return e.status=o8,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,o=>t().then(()=>{let t=Error(o.message);if(n)throw oX(t,e,ae);oK(t,e,ae)})).then(()=>e);function t(){return aS(e,"unmount").then(()=>{e.status=o3},t=>{if(n)throw oX(t,e,ae);oK(t,e,ae)})}})}let ah=!1,am=!1;function ag(e,n){return Promise.resolve().then(()=>e.status!==o3?e:(ah||(window.dispatchEvent(new oH("single-spa:before-first-mount")),ah=!0),e.status=o5,aS(e,"mount").then(()=>(e.status=o4,am||(window.dispatchEvent(new oH("single-spa:first-mount")),am=!0),e)).catch(t=>{return e.status=o4,af(e,!0).then(o,o);function o(){if(n)throw oX(t,e,ae);return oK(t,e,ae),e}})))}let ay=0,ab={parcels:{}};function a_(){return av.apply(ab,arguments)}function av(e,n){let t,o,a,r=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(oJ(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(oJ(3,!1,typeof e.name));let i=ay++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(oJ(4,!1,s,typeof n));if(!n.domElement)throw Error(oJ(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?o0:o1,customProps:n,parentName:ao(r),unmountThisParcel:()=>f.then(()=>{if(p.status!==o4)throw Error(oJ(6,!1,s,p.status));return af(p,!0)}).then(e=>(p.parentName&&delete r.parcels[p.id],e)).then(e=>(o(e),e)).catch(e=>{throw p.status=ae,a(e),e})};r.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(oJ(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(oJ(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!al(e.bootstrap))throw Error(oJ(9,!1,s));if(!al(e.mount))throw Error(oJ(10,!1,s));if(!al(e.unmount))throw Error(oJ(11,!1,s));if(e.update&&!al(e.update))throw Error(oJ(12,!1,s));let n=ac(e,"bootstrap"),o=ac(e,"mount"),a=ac(e,"unmount");p.status=o1,p.name=s,p.bootstrap=n,p.mount=o,p.unmount=a,p.timeouts=aD(e.timeouts),e.update&&(p.update=ac(e,"update"),t.update=function(e){return p.customProps=e,a$(Promise.resolve().then(()=>{if(p.status!==o4)throw Error(oJ(32,!1,ao(p)));return p.status=o6,aS(p,"update").then(()=>(p.status=o4,p)).catch(e=>{throw oX(e,p,ae)})}))})})).then(()=>ad(p,!0)),f=d.then(()=>ag(p,!0)),h=new Promise((e,n)=>{o=e,a=n});return t={mount:()=>a$(Promise.resolve().then(()=>{if(p.status!==o3)throw Error(oJ(13,!1,s,p.status));return r.parcels[i]=p,ag(p)})),unmount:()=>a$(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:a$(u),bootstrapPromise:a$(d),mountPromise:a$(f),unmountPromise:a$(h)}}function a$(e){return e.then(()=>null)}function aA(e){let n=ao(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(oJ(40,!1),n,t));let o=ai({},t,{name:n,mountParcel:av.bind(e),singleSpa:oG});return aa(e)&&(o.unmountSelf=e.unmountThisParcel),o}let aw={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 ak(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(16,!1));aw.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ax(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(17,!1));aw.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aC(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(18,!1));aw.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aE(e,n,t){if("number"!=typeof e||e<=0)throw Error(oJ(19,!1));aw.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aS(e,n){let t=e.timeouts[n],o=t.warningMillis,a=ar(e);return new Promise((r,i)=>{let s=!1,l=!1;e[n](aA(e)).then(e=>{s=!0,r(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),o),setTimeout(()=>p(!0),t.millis);let c=oJ(31,!1,n,a,ao(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*o+o<t.millis&&setTimeout(()=>p(e+1),o)))}})}function aD(e){let n={};for(let t in aw)n[t]=ai({},aw[t],e&&e[t]||{});return n}function az(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==oQ&&e.status!==o9?e:(e.status=o0,e.loadPromise=Promise.resolve().then(()=>{let o=e.loadApp(aA(e));if(!ap(o))throw t=!0,Error(oJ(33,!1,ao(e)));return o.then(t=>{let o;e.loadErrorTime=null,"object"!=typeof(n=t)&&(o=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!al(n.bootstrap)&&(o=35),al(n.mount)||(o=36),al(n.unmount)||(o=37);let a=ar(n);if(o){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(oJ(o,!1,a,ao(e),t),n),oK(void 0,e,ae),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=ai({},e.devtools.overlays,n.devtools.overlays)),e.status=o1,e.bootstrap=ac(n,"bootstrap"),e.mount=ac(n,"mount"),e.unmount=ac(n,"unmount"),e.unload=ac(n,"unload"),e.timeouts=aD(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let o;return delete e.loadPromise,t?o=ae:(o=o9,e.loadErrorTime=(new Date).getTime()),oK(n,e,o),e}))})}let aM="u">typeof window,aP={hashchange:[],popstate:[]},aO=["hashchange","popstate"];function aT(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(oJ(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=aL(window.location.href),o=aL(n);0===n.indexOf("#")?window.location.hash=o.hash:t.host!==o.host&&o.host?window.location.href=n:o.pathname===t.pathname&&o.search===t.search?window.location.hash=o.hash:window.history.pushState(null,null,n)}function aN(e){if(e){let n=e[0].type;aO.indexOf(n)>=0&&aP[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function aI(){rn([],arguments)}function aB(e,n){return function(){let t=window.location.href,a=e.apply(this,arguments),r=window.location.href;return o&&t===r||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 aj=null,aR=!1;function aF(e){if(aR)throw Error(oJ(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,aR=!0,aj=window.history.replaceState,window.addEventListener("hashchange",aI),window.addEventListener("popstate",aI);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&aO.indexOf(e)>=0)||as(aP[e],e=>e===t))return n.apply(this,arguments);aP[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&aO.indexOf(e)>=0&&(aP[e]=aP[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=aB(window.history.pushState,"pushState"),window.history.replaceState=aB(aj,"replaceState")}function aL(e){let n=document.createElement("a");return n.href=e,n}aM&&(window.singleSpaNavigate?console.warn(oJ(41,!1)):window.singleSpaNavigate=aT);let aW=!1;function aV(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!aW){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return aG.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return aG.call(this,t,window.removeEventListener,e,n,arguments)},aW=!0}}function aG(e,n,t,o,a){return"string"!=typeof t?e.apply(this,a):(t.split(/\s+/).forEach(e=>{aO.indexOf(e)>=0&&(n(e,o),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,a))}let aU={};function aH(e){return Promise.resolve().then(()=>{let n=aU[ao(e)];if(!n)return e;if(e.status===oQ)return aq(e,n),e;if(e.status===o7)return n.promise.then(()=>e);if(e.status!==o3&&e.status!==o9)return e;let t=e.status===o9?Promise.resolve():aS(e,"unload");return e.status=o7,t.then(()=>(aq(e,n),e)).catch(t=>(delete aU[ao(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,oK(t,e,ae),n.reject(t),e))})}function aq(e,n){delete aU[ao(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oQ,n.resolve()}function aK(e,n,t,o){aU[ao(e)]={app:e,resolve:t,reject:o},Object.defineProperty(aU[ao(e)],"promise",{get:n})}let aY=[];function aZ(){return aY.filter(an).map(ao)}function aJ(){return aY.map(ao)}function aX(e){let n=as(aY,n=>ao(n)===e);return n?n.status:null}let aQ=!1;function a0(e,n,t,o){var a,r;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(oJ(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(oJ(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(oJ(20,!1));let o=e=>"string"==typeof e||"function"==typeof e;if(!(o(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(o)))throw Error(oJ(24,!1));if(!a4(e.customProps))throw Error(oJ(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,o){if("string"!=typeof e||0===e.length)throw Error(oJ(20,!1));if(!n)throw Error(oJ(23,!1));if("function"!=typeof t)throw Error(oJ(24,!1));if(!a4(o))throw Error(oJ(22,!1))}(e,n,t,o),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=o),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(r=i.activeWhen)?r:[r]).map(e=>"function"==typeof e?e:a6(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(ro||aQ||(aQ=!0,setTimeout(()=>{ro||console.warn(oJ(1,!1))},5e3)),-1!==aJ().indexOf(l.name))throw Error(oJ(21,!1,l.name));aY.push(ai({loadErrorTime:null,status:oQ,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),aM&&(aV(),rn())}function a1(e=window.location){return aY.filter(n=>n.activeWhen(e)).map(ao)}function a2(e){if(0===aY.filter(n=>ao(n)===e).length)throw Error(oJ(25,!1,e));return(aM?a3(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=aY.map(ao).indexOf(e);aY.splice(n,1)})}function a3(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(oJ(26,!1));let t=as(aY,n=>ao(n)===e);if(!t)throw Error(oJ(27,!1,e));let o=aU[ao(t)];if(n&&n.waitForUnmount){if(o)return o.promise;{let e=new Promise((n,o)=>{aK(t,()=>e,n,o)});return e}}{let e;return o?(e=o.promise,a5(t,o.resolve,o.reject)):e=new Promise((n,o)=>{aK(t,()=>e,n,o),a5(t,n,o)}),e}}function a5(e,n,t){Promise.resolve().then(()=>{if(as(a1(),n=>n===ao(e)))return re()}).then(()=>af(e).then(aH).then(()=>{n(),setTimeout(()=>{rn()})})).catch(t)}function a4(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function a6(e,n){let t=function(e,n){let t=0,o=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],a=o&&"/"===t;(!o&&":"===t||a)&&r(n)}return r(e.length),RegExp(a,"i");function r(r){let i=e.slice(t,r).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=o?"[^/]+/?":i,r===e.length)if(o)n&&(a+="$");else{let e=n?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}o=!o,t=r}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let o=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(o)}}let a8=!1,a7=[],a9=aM&&window.location.href;function re(){return rn()}function rn(e=[],n,t=!1){let o,a,r,i,s;if(a8)return new Promise((e,t)=>{a7.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(o=[],a=[],r=[],i=[],s=(new Date).getTime(),aY.forEach(e=>{let n=e.status!==ae&&at(e);switch(e.status){case o9:n&&s-e.loadErrorTime>=200&&r.push(e);break;case oQ:case o0:n&&r.push(e);break;case o1:case o3:!n&&aU[ao(e)]?o.push(e):n&&i.push(e);break;case o4:n||a.push(e)}}),{appsToUnload:o,appsToUnmount:a,appsToLoad:r,appsToMount:i}),d,f=[],h=a9,m=a9=window.location.href;return ro?(a8=!0,d=l.concat(p,c,u),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 aj.call(window.history,history.state,"",h.substring(location.origin.length)),a9=location.href,a8=!1,rn(e,n,!0);let o=l.map(aH),a=Promise.all(c.map(af).map(e=>e.then(aH)).concat(o));a.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let r=p.map(e=>az(e).then(e=>rt(e,a))),i=u.filter(e=>0>p.indexOf(e)).map(e=>rt(e,a));return a.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(r.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(az)).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(oJ(42,!1))),console.warn(e),!1)))}function y(){let n=aZ();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(a8=!1,a7.length>0){let e=a7;a7=[],rn(e)}return n}function b(){t||(e.forEach(e=>{aN(e.eventArguments)}),aN(n))}function v(e=!1,t){let o={},a={[o4]:[],[o3]:[],[oQ]:[],[ae]:[]};e?(p.concat(u).forEach((e,n)=>{i(e,o4)}),l.forEach(e=>{i(e,oQ)}),c.forEach(e=>{i(e,o3)})):d.forEach(e=>{i(e)});let r={detail:{newAppStatuses:o,appsByNewStatus:a,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&ai(r.detail,t),r;function i(e,n){let t=ao(e);n=n||aX(t),o[t]=n,(a[n]=a[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new oH(`single-spa:${e}`,n))}}function rt(e,n){return at(e)?ad(e).then(e=>n.then(()=>at(e)?ag(e):e)):n.then(()=>e)}let ro=!1;function ra(e){ro=!0,aM&&(aF(e),rn())}function rr(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return ri(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function ri(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function rs({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),o=rr(e,n).replace(window.location.origin,"");o.startsWith(t)?aT(o):window.location.assign(o)}aM&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aY]},reroute:rn,NOT_LOADED:oQ,toLoadPromise:az,toBootstrapPromise:ad,unregisterApplication:a2,getProfilerData:function(){return au}});let rl="openmrs:history";function rc(e){let n=JSON.parse(sessionStorage.getItem(rl)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(rl,JSON.stringify(n))}function rp(){0===JSON.parse(sessionStorage.getItem(rl)??"[]").length&&document.referrer&&rc(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=ru();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(rl,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?rd({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&rc(window.location.href)})}function ru(){return JSON.parse(sessionStorage.getItem(rl)??"[]")}function rd({toUrl:e}){let n=ru(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);rs({to:n[t]}),sessionStorage.setItem(rl,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rf(){sessionStorage.removeItem(rl)}let rh="${openmrsSpaBase}/login",rm={redirectAuthFailure:{enabled:{_type:tU.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:tU.String,_default:rh,_validators:[oN.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:tU.Array,_default:[401],_elements:{_type:tU.Number,_validators:[oN.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:tU.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}},followRedirects:{_type:tU.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function rg(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let ry="/ws/rest/v1",rb="/ws/fhir2/R4",r_=`${ry}/session`;function rv(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function r$(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=rv(e);if(n.headers||(n.headers={}),eO(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(ry)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rb)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let o=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:a}=await ou("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(a&&n&&(t===rv(r_)||204===e.status)&&rs({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===rv(r_)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(rf(),rs({to:n.url||e.headers.get("location")||rh}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let a=n;try{a=JSON.parse(n)}catch(e){}throw new rw(t,e,a,o)},n=>{throw new rw(t,e,null,o)})})}function rA(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 ek(o=>{let a=!1;return r$(e,n).then(e=>{a=!0,o.next(e),o.complete()},e=>{a=!0,o.error(e)}),()=>{a||t.abort()}})}class rw extends Error{constructor(e,n,t,o){super(),rg(this,"response",void 0),rg(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`,o.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
13
13
  ${o.stack}
14
14
  Stacktrace for incoming response:
15
15
  ${this.stack}`}}let rk=U("session",{loaded:!1,session:null}),rx=0;function rC(e={includeAuthStatus:!0}){return(rx<Date.now()-6e4||!rk.getState().loaded)&&rD(),new ek(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(rk.getState()),rk.subscribe(t)})}function rE(){return(rx<Date.now()-6e4||!rk.getState().loaded)&&rD(),rk}function rS(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 rD(e,n){rx=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),rI(r$(r_,{headers:t}))}function rz(){rk.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function rM(e,n){var t,o;if(void 0===n)return!e;if(!e)return!0;return t=e,o=n,("string"==typeof t?!Z(o.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Z(o.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 rP(){let e,n;return new Promise(t=>{let o=o=>{o.loaded&&o.session.user&&(e=o.session.user,t(o.session.user),n&&n())};o(rk.getState()),e||(n=rk.subscribe(o))})}function rO(){return new Promise((e,n)=>{rC().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function rT(e,n){return rI(r$(r_,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function rN(e,n,t){return t||(t=new AbortController),await r$(`${ry}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),rD()}function rI(e){return new Promise((n,t)=>{e.then(e=>{let o;"object"==typeof e?.data?(o={loaded:!0,session:e.data},rk.setState(o),n(o)):(o={loaded:!1,session:null},rk.setState(o),t(o))}).catch(e=>{N(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};rk.setState(n),t(n)})})}function rB(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}rk.subscribe(e=>{e.loaded&&e.session&&rS(e.session)});let rj={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function rR(){or("@openmrs/esm-api",rm),rD()}let rF={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"},rL=e=>"string"==typeof e,rW=()=>{let e,n,t=new Promise((t,o)=>{e=t,n=o});return t.resolve=e,t.reject=n,t},rV=e=>null==e?"":""+e,rG=/###/g,rU=e=>e&&e.indexOf("###")>-1?e.replace(rG,"."):e,rH=e=>!e||rL(e),rq=(e,n,t)=>{let o=rL(n)?n.split("."):n,a=0;for(;a<o.length-1;){if(rH(e))return{};let n=rU(o[a]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++a}return rH(e)?{}:{obj:e,k:rU(o[a])}},rK=(e,n,t)=>{let{obj:o,k:a}=rq(e,n,Object);if(void 0!==o||1===n.length){o[a]=t;return}let r=n[n.length-1],i=n.slice(0,n.length-1),s=rq(e,i,Object);for(;void 0===s.obj&&i.length;)r=`${i[i.length-1]}.${r}`,s=rq(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${r}`]&&(s.obj=void 0);s.obj[`${s.k}.${r}`]=t},rY=(e,n)=>{let{obj:t,k:o}=rq(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,o))return t[o]},rZ=(e,n,t)=>{for(let o in n)"__proto__"!==o&&"constructor"!==o&&(o in e?rL(e[o])||e[o]instanceof String||rL(n[o])||n[o]instanceof String?t&&(e[o]=n[o]):rZ(e[o],n[o],t):e[o]=n[o]);return e};var rJ={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let rX=e=>rL(e)?e.replace(/[&<>"'\/]/g,e=>rJ[e]):e,rQ=[" ",",","?","!",";"],r0=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),r1=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let o=n.split(t),a=e;for(let e=0;e<o.length;){let n;if(!a||"object"!=typeof a)return;let r="";for(let i=e;i<o.length;++i)if(i!==e&&(r+=t),r+=o[i],void 0!==(n=a[r])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<o.length-1)continue;e+=i-e+1;break}a=n}return a},r2=e=>e?.replace("_","-"),r3={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 r5{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||r3,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,o){return o&&!this.debug?null:(rL(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new r5(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new r5(this.logger,e)}}var r4=new r5;class r6{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 o=0;o<t;o++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,o])=>{for(let a=0;a<o;a++)t.apply(t,[e,...n])})}}class r8 extends r6{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,o={}){let a,r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,i=void 0!==o.ignoreJSONStructure?o.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,n],t&&(Array.isArray(t)?a.push(...t):rL(t)&&r?a.push(...t.split(r)):a.push(t)));let s=rY(this.data,a);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=a[0],n=a[1],t=a.slice(2).join(".")),!s&&i&&rL(t))?r1(this.data?.[e]?.[n],t,r):s}addResource(e,n,t,o,a={silent:!1}){let r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(r?t.split(r):t)),e.indexOf(".")>-1&&(i=e.split("."),o=n,n=i[1]),this.addNamespaces(n),rK(this.data,i,o),a.silent||this.emit("added",e,n,t,o)}addResources(e,n,t,o={silent:!1}){for(let o in t)(rL(t[o])||Array.isArray(t[o]))&&this.addResource(e,n,o,t[o],{silent:!0});o.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,o,a,r={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),o=t,t=n,n=i[1]),this.addNamespaces(n);let s=rY(this.data,i)||{};r.skipCopy||(t=JSON.parse(JSON.stringify(t))),o?rZ(s,t,a):s={...s,...t},rK(this.data,i,s),r.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 r7={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,o,a){return e.forEach(e=>{n=this.processors[e]?.process(n,t,o,a)??n}),n}};let r9=Symbol("i18next/PATH_KEY");function ie(e,n){let t,o,a,{[r9]:r}=e((o=[],(a=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===r9)?o:(o.push(n),(t=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return r.join(n?.keySeparator??".")}let it={},io=e=>!rL(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ia extends r6{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=r4.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let o=this.resolve(e,t);if(o?.res===void 0)return!1;let a=io(o.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 o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=n.ns||this.options.defaultNS||[],r=t&&e.indexOf(t)>-1,i=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let o=rQ.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===o.length)return!0;let a=r0.getRegExp(`(${o.map(e=>"?"===e?"\\?":e).join("|")})`),r=!a.test(e);if(!r){let n=e.indexOf(t);n>0&&!a.test(e.substring(0,n))&&(r=!0)}return r})(e,t,o);if(r&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:rL(a)?[a]:a};let r=e.split(t);(t!==o||t===o&&this.options.ns.indexOf(r[0])>-1)&&(a=r.shift()),e=r.join(o)}return{key:e,namespaces:rL(a)?[a]:a}}translate(e,n,t){let o="object"==typeof n?{...n}:n;if("object"!=typeof o&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof o&&(o={...o}),o||(o={}),null==e)return"";"function"==typeof e&&(e=ie(e,{...this.options,...o})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==o.returnDetails?o.returnDetails:this.options.returnDetails,r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],o),l=s[s.length-1],c=void 0!==o.nsSeparator?o.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let p=o.lng||this.language,u=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return u?a?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:`${l}${c}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(o)}:i;let d=this.resolve(e,o),f=d?.res,h=d?.usedKey||i,m=d?.exactUsedKey||i,g=void 0!==o.joinArrays?o.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==o.count&&!rL(o.count),v=ia.hasDefaultValue(o),$=b?this.pluralResolver.getSuffix(p,o.count,o):"",A=o.ordinal&&b?this.pluralResolver.getSuffix(p,o.count,{ordinal:!1}):"",w=b&&!o.ordinal&&0===o.count,k=w&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${$}`]||o[`defaultValue${A}`]||o.defaultValue,x=f;y&&!f&&v&&(x=k);let C=io(x),E=Object.prototype.toString.apply(x);if(y&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(rL(g)&&Array.isArray(x))){if(!o.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,{...o,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(d.res=e,d.usedParams=this.getUsedParamsDetails(o),d):e}if(r){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}${r}${e}`;v&&!f?n[e]=this.translate(a,{...o,defaultValue:io(k)?k[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(a,{...o,joinArrays:!1,ns:s}),n[e]===a&&(n[e]=x[e])}f=n}}else if(y&&rL(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,o,t));else{let n=!1,a=!1;!this.isValidLookup(f)&&v&&(n=!0,f=k),this.isValidLookup(f)||(a=!0,f=i);let s=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:f,u=v&&k!==f&&this.options.updateMissing;if(a||n||u){if(this.logger.log(u?"updateKey":"missingKey",p,l,i,u?k:f),r){let e=this.resolve(i,{...o,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,o.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(o.lng||this.language):e.push(o.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,u,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,a,u,o),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,o);w&&o[`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,o[`defaultValue${n}`]||k)})}):t(e,i,k))}f=this.extendTranslation(f,e,o,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,o))}return a?(d.res=f,d.usedParams=this.getUsedParamsDetails(o),d):f}extendTranslation(e,n,t,o,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!t.skipInterpolation){let r;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=rL(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let n=e.match(this.interpolator.nestingRegexp);r=n&&n.length}let s=t.replace&&!rL(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||o.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);r<(n&&n.length)&&(t.nest=!1)}!t.lng&&o&&o.res&&(t.lng=this.language||o.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 r=t.postProcess||this.options.postProcess,i=rL(r)?[r]:r;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=r7.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,o,a,r,i;return rL(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;o=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let p=void 0!==n.count&&!rL(n.count),u=p&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(rL(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,!it[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(it[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${o}" 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(o=>{let i;if(this.isValidLookup(t))return;r=o;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,o,e,n);else{let e;p&&(e=this.pluralResolver.getSuffix(o,n.count,n));let t=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),u&&s.push(l+t)),d){let o=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(o),p&&(n.ordinal&&0===e.indexOf(a)&&s.push(o+e.replace(a,this.options.pluralSeparator)),s.push(o+e),u&&s.push(o+t))}}for(;i=s.pop();)this.isValidLookup(t)||(a=i,t=this.getResource(o,e,i,n))}))})}),{res:t,usedKey:o,exactUsedKey:a,usedLng:r,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,o={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,o):this.resourceStore.getResource(e,n,t,o)}getUsedParamsDetails(e={}){let n=e.replace&&!rL(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 ir{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=r4.create("languageUtils")}getScriptPartFromCode(e){if(!(e=r2(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=r2(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(rL(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 o=this.getLanguagePartFromCode(e);if(this.isSupportedCode(o))return n=o;n=this.options.supportedLngs.find(e=>{if(e===o||!(0>e.indexOf("-")&&0>o.indexOf("-"))&&(e.indexOf("-")>0&&0>o.indexOf("-")&&e.substring(0,e.indexOf("-"))===o||0===e.indexOf(o)&&o.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)),rL(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),o=[],a=e=>{e&&(this.isSupportedCode(e)?o.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return rL(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))):rL(e)&&a(this.formatLanguageCode(e)),t.forEach(e=>{0>o.indexOf(e)&&a(this.formatLanguageCode(e))}),o}}let ii={zero:0,one:1,two:2,few:3,many:4,other:5},is={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class il{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=r4.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,o=r2("dev"===e?"en":e),a=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:o,type:a});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];try{t=new Intl.PluralRules(o,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),is;if(!e.match(/-|_/))return is;let o=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(o,n)}return this.pluralRulesCache[r]=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)=>ii[e]-ii[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let o=this.getRule(e,t);return o?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${o.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let ic=(e,n,t,o=".",a=!0)=>{let r,i=void 0!==(r=rY(e,t))?r:rY(n,t);return!i&&a&&rL(t)&&void 0===(i=r1(e,t,o))&&(i=r1(n,t,o)),i};class ip{constructor(e={}){this.logger=r4.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:o,prefix:a,prefixEscaped:r,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:p,nestingPrefix:u,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==n?n:rX,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==o&&o,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):r||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=u?u.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,o){let a,r,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=ic(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,t,{...o,...n,interpolationkey:e}):a}let a=e.split(this.formatSeparator),r=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(ic(n,s,r,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...o,...n,interpolationkey:r})};this.resetRegExp();let c=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=o?.interpolation?.skipOnVariables!==void 0?o.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===(r=l(t)))if("function"==typeof c){let n=c(e,a,o);r=rL(n)?n:""}else if(o&&Object.prototype.hasOwnProperty.call(o,t))r="";else if(p){r=a[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),r="";else rL(r)||this.useRawValueToEscape||(r=rV(r));let s=n.safeValue(r);if(e=e.replace(a[0],s),p?(n.regex.lastIndex+=r.length,n.regex.lastIndex-=a[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let o,a,r,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let o=e.split(RegExp(`${t}[ ]*{`)),a=`{${o[1]}`;e=o[0];let i=(a=this.interpolate(a,r)).match(/'/g),s=a.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(a=a.replace(/'/g,'"'));try{r=JSON.parse(a),n&&(r={...n,...r})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${a}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,e};for(;o=this.nestingRegexp.exec(e);){let s=[];(r=(r={...t}).replace&&!rL(r.replace)?r.replace:r).applyPostProcessor=!1,delete r.defaultValue;let l=/{.*}/.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(-1!==l&&(s=o[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),o[1]=o[1].slice(0,l)),(a=n(i.call(this,o[1].trim(),r),r))&&o[0]===e&&!rL(a))return a;rL(a)||(a=rV(a)),a||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:o[1].trim()}),a.trim())),e=e.replace(o[0],a),this.regexp.lastIndex=0}return e}}let iu=e=>{let n={};return(t,o,a)=>{let r=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(r={...r,[a.interpolationkey]:void 0});let i=o+JSON.stringify(r),s=n[i];return s||(s=e(r2(o),a),n[i]=s),s(t)}},id=e=>(n,t,o)=>e(r2(t),o)(n);class ih{constructor(e={}){this.logger=r4.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?iu:id;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()]=iu(n)}format(e,n,t,o={}){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:r}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let o=e.split("(");n=o[0].toLowerCase().trim();let a=o[1].substring(0,o[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,...o]=e.split(":"),a=o.join(":").trim().replace(/^'+|'+$/g,""),r=n.trim();t[r]||(t[r]=a),"false"===a&&(t[r]=!1),"true"===a&&(t[r]=!0),isNaN(a)||(t[r]=parseInt(a,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[a]){let n=e;try{let i=o?.formatParams?.[o.interpolationkey]||{},s=i.locale||i.lng||o.locale||o.lng||t;n=this.formats[a](e,s,{...r,...o,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class im extends r6{constructor(e,n,t,o={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=o,this.logger=r4.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,o.backend,o)}queueLoad(e,n,t,o){let a={},r={},i={},s={};return e.forEach(e=>{let o=!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===r[i]&&(r[i]=!0):(this.state[i]=1,o=!1,void 0===r[i]&&(r[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[n]&&(s[n]=!0)))}),o||(i[e]=!0)}),(Object.keys(a).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(a),pending:Object.keys(r),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let o=e.split("|"),a=o[0],r=o[1];n&&this.emit("failedLoading",a,r,n),!n&&t&&this.store.addResourceBundle(a,r,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,o)=>{let{obj:a,k:r}=rq(e,n,Object);a[r]=a[r]||[],a[r].push(t)})(t.loaded,[a],r),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,o=0,a=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:o,wait:a,callback:r});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&&o<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,o+1,2*a,r)},a):r(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={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();rL(e)&&(e=this.languageUtils.toResolveHierarchy(e)),rL(n)&&(n=[n]);let a=this.queueLoad(e,n,t,o);if(!a.toLoad.length)return a.pending.length||o(),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("|"),o=t[0],a=t[1];this.read(o,a,"read",void 0,void 0,(t,r)=>{t&&this.logger.warn(`${n}loading namespace ${a} for language ${o} failed`,t),!t&&r&&this.logger.log(`${n}loaded namespace ${a} for language ${o}`,r),this.loaded(e,t,r)})}saveMissing(e,n,t,o,a,r={},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={...r,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;(a=5===l.length?l(e,n,t,o,s):l(e,n,t,o))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,n,t,o,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,o)}}}let ig=()=>({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]),rL(e[1])&&(n.defaultValue=e[1]),rL(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}),iy=e=>(rL(e.ns)&&(e.ns=[e.ns]),rL(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),rL(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),ib=()=>{};class i_ extends r6{constructor(e={},n){if(super(),this.options=iy(e),this.services={},this.logger=r4,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&&(rL(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=ig();this.options={...t,...this.options,...iy(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 o=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?r4.init(o(this.modules.logger),this.options):r4.init(null,this.options),e=this.modules.formatter?this.modules.formatter:ih;let n=new ir(this.options);this.store=new r8(this.options.resources,this.options);let a=this.services;a.logger=r4,a.resourceStore=this.store,a.languageUtils=n,a.pluralResolver=new il(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=o(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new ip(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new im(o(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(a.languageDetector=o(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=o(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new ia(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=ib),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=rW(),r=()=>{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?r():setTimeout(r,0),a}loadResources(e,n=ib){let t=n,o=rL(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(o?.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)})};o?n(o):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 o=rW();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=ib),this.services.backendConnector.reload(e,n,e=>{o.resolve(),t(e)}),o}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&&r7.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=rW();this.emit("languageChanging",e);let o=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(a,r)=>{r?this.isLanguageChangingTo===e&&(o(r),this.translator.changeLanguage(r),this.isLanguageChangingTo=void 0,this.emit("languageChanged",r),this.logger.log("languageChanged",r)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(a,(...e)=>this.t(...e))},r=n=>{e||n||!this.services.languageDetector||(n=[]);let t=rL(n)?n:n&&n[0],r=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(rL(n)?[n]:n);r&&(this.language||o(r),this.translator.language||this.translator.changeLanguage(r),this.services.languageDetector?.cacheUserLanguage?.(r)),this.loadResources(r,e=>{a(e,r)})};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(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let o=(e,n,...a)=>{let r,i;(r="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(a)):{...n}).lng=r.lng||o.lng,r.lngs=r.lngs||o.lngs,r.ns=r.ns||o.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||t||o.keyPrefix);let s=this.options.keySeparator||".";return r.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=ie(e,{...this.options,...n})),`${r.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=ie(e,{...this.options,...n})),i=r.keyPrefix?`${r.keyPrefix}${s}${e}`:e),this.t(i,r)};return rL(e)?o.lng=e:o.lngs=e,o.ns=n,o.keyPrefix=t,o}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],o=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let r=(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,r);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(t,e)&&(!o||r(a,e)))}loadNamespaces(e,n){let t=rW();return this.options.ns?(rL(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=rW();rL(e)&&(e=[e]);let o=this.options.preload||[],a=e.filter(e=>0>o.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=o.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 ir(ig());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 i_(e,n)}cloneInstance(e={},n=ib){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let o={...this.options,...e,isClone:!0},a=new i_(o);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 r8(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,o)=>(t[o]={...e[n][o]},t),e[n]),e),{}),o),a.services.resourceStore=a.store),a.translator=new ia(a.services,o),a.translator.on("*",(e,...n)=>{a.emit(e,...n)}),a.init(o,n),a.translator.options=o,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 iv=i_.createInstance();iv.createInstance=i_.createInstance,iv.createInstance,iv.dir,iv.init,iv.loadResources,iv.reloadResources,iv.use,iv.changeLanguage,iv.getFixedT,iv.t,iv.exists,iv.setDefaultNamespace,iv.hasLoadedNamespace,iv.loadNamespaces,iv.loadLanguages;let i$=iv.default||iv;function iA(e,n,t,o){return i$.t(n,{ns:e,defaultValue:t,...o})}function iw(e,n,t){return rF[e]?iA("core",e,n??rF[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}i$.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let ik="import-map-override:",ix="import-map-overrides-disabled",iC="import-map-overrides:change",iE=!1,iS=null;async function iD(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{if(o.src){let e=await fetch(o.src);n.push(await e.json())}else o.textContent&&n.push(JSON.parse(o.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return iz(n)}function iz(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function iM(){let e={};try{let n=iI();for(let t=0;t<localStorage.length;t++){let o=localStorage.key(t);if(o?.startsWith(ik)){let t=o.slice(ik.length);if(!n.includes(t)){let n=localStorage.getItem(o);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function iP(){let e=await iD();return iE?iz([e,iS??iM()]):e}async function iO(){return iD()}async function iT(){return iE?iz([await iD(),iM()]):iD()}function iN(e){if(!iE)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(ik)){let n=localStorage.getItem(t);n&&(e[t.slice(ik.length)]=n)}}return{imports:e}}return iM()}function iI(){if(!iE)return[];try{let e=localStorage.getItem(ix);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function iB(e){return!!iE&&iI().includes(e)}function ij(e,n){if(!iE)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(ik+e,n),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function iR(e){if(!iE)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(ik+e);let n=iI().filter(n=>n!==e);n.length>0?localStorage.setItem(ix,JSON.stringify(n)):localStorage.removeItem(ix),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function iF(){if(!iE)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(ik)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ix),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function iL(e){if(!iE)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=iI().filter(n=>n!==e);n.length>0?localStorage.setItem(ix,JSON.stringify(n)):localStorage.removeItem(ix),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let iW=!1;function iV(){!iW&&(iW=!0,(iE="development"===window.spaEnv)&&(iS=iM()))}function iG(e){return e.replace(/[\/\-@]/g,"_")}async function iU(e,n="./start",o){var a;let r,i=!o?.maxLoadingTime||o.maxLoadingTime<=0?6e5:o.maxLoadingTime;await Promise.race([iH(e,o?.importMap),new Promise((n,t)=>{r=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)})]),r&&clearTimeout(r);let s=iG(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 iH(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=iG(e);if(!window[t]){let t=n??await iq();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 o=t.imports[e];o.startsWith("./")&&(o=window.spaBase+o.substring(1));let a=e in iN().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let o=document.head.querySelector(`script[src="${e}"]`),a=window[iK];if(a||(a=window[iK]=new Set([])),o)if(a.has(e)){let e,a,r;r=()=>{e&&o.removeEventListener("load",e),a&&o.removeEventListener("error",a)},e=()=>{r(),n(null)},a=e=>{r(),t(e.message)},o.addEventListener("load",e),o.addEventListener("error",a)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let o,r,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),o&&s.removeEventListener("load",o),r&&s.removeEventListener("error",r)},o=()=>{i(),n(null)},r=n=>{i();let o=`Failed to load script from ${e}`;console.error(o,n),t(n.message??o)},s.addEventListener("load",o),s.addEventListener("error",r),document.head.appendChild(s)}}(o,e,n)})}catch(e){return a&&z({kind:"error",title:iw("scriptLoadingFailed","Error: Script failed to load"),description:iw("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:o}),actionButtonLabel:iw("resetOverrides","Reset overrides"),onActionButtonClick(){iF(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function iq(){return iP()}let iK=Symbol("__openmrs_script_loading");function iY(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 iZ(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,n])=>"string"==typeof e&&iY(n))}let iJ="openmrs-routes:",iX="openmrs-routes:change",iQ=!1,i0=null;async function i1(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let o=e[t];try{let e;if(o.src){let n=await fetch(o.src);e=await n.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&iZ(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return i2(n)}function i2(e){let n={};for(let t of e)t&&"object"==typeof t&&Object.assign(n,t);return n}async function i3(){let e={};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(iJ)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(iJ.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(iY(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),o=await n.json();if(iY(o))return{moduleName:e,routes:o};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 i5(){let e=await i1();return iQ?i2([e,i0??await i3()]):e}async function i4(){return i1()}async function i6(){return iQ?i2([await i1(),await i3()]):i1()}function i8(){if(!iQ)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(iJ)){let n=localStorage.getItem(t);n&&(e[t.slice(iJ.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function i7(e,n){if(!iQ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(iJ+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!iY(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(iJ+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(iJ+e,JSON.stringify(n.toString()));else{if(!iY(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(iJ+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(iX))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function i9(e){if(!iQ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(iJ+e),window.dispatchEvent(new CustomEvent(iX))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function se(){if(!iQ)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(iJ)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(iX))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sn=null;function st(){return sn||(sn=(iQ="development"===window.spaEnv)?i3().then(e=>{i0=e}):Promise.resolve())}let so=`${ry}/attachment`;function sa(e,n){return r$(`${so}/${e}`,{signal:n.signal})}function sr(e,n,t){return r$(`${so}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function si(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)),r$(`${so}`,{method:"POST",body:t})}function ss(e,n){return r$(`${so}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function sl(e,n){return new Promise(function(t){var o=new MessageChannel;o.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[o.port2])})}function sc(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function sp(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,o=Array(n);t<n;t++)o[t]=e[t];return o}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var su=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function sd(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var sf=function(e,n){this.type=e,Object.assign(this,n)};function sh(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function sm(){}var sg={type:"SKIP_WAITING"};function sy(e,n){if(!n)return e&&e.then?e.then(sm):Promise.resolve()}var sb=function(e){function n(n,t){var o,a;return void 0===t&&(t={}),(o=e.call(this)||this).nn={},o.tn=0,o.rn=new su,o.en=new su,o.on=new su,o.un=0,o.an=new Set,o.cn=function(){var e=o.fn,n=e.installing;o.tn>0||!sd(n.scriptURL,o.sn.toString())||performance.now()>o.un+6e4?(o.vn=n,e.removeEventListener("updatefound",o.cn)):(o.hn=n,o.an.add(n),o.rn.resolve(n)),++o.tn,n.addEventListener("statechange",o.ln)},o.ln=function(e){var n=o.fn,t=e.target,a=t.state,r=t===o.vn,i={sw:t,isExternal:r,originalEvent:e};!r&&o.mn&&(i.isUpdate=!0),o.dispatchEvent(new sf(a,i)),"installed"===a?o.wn=self.setTimeout(function(){"installed"===a&&n.waiting===t&&o.dispatchEvent(new sf("waiting",i))},200):"activating"===a&&(clearTimeout(o.wn),r||o.en.resolve(t))},o.dn=function(e){var n=o.hn,t=n!==navigator.serviceWorker.controller;o.dispatchEvent(new sf("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:o.mn})),t||o.on.resolve(n)},a=function(e){var n=e.data,t=e.ports,a=e.source;return sh(o.getSW(),function(){o.an.has(a)&&o.dispatchEvent(new sf("message",{data:n,originalEvent:e,ports:t,sw:a}))})},o.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)}},o.sn=n,o.nn=t,navigator.serviceWorker.addEventListener("message",o.gn),o}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,o,a=n.prototype;return a.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var o,a,r,i=this;return o=function(){if(!t&&"complete"!==document.readyState)return sy(new Promise(function(e){return window.addEventListener("load",e)}))},a=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),sh(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&&sd(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new sf("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})},(r=o())&&r.then?r.then(a):a(r)}catch(e){return Promise.reject(e)}},a.update=function(){try{return this.fn?sy(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 sh(this.getSW(),function(n){return sl(n,e)})}catch(e){return Promise.reject(e)}},a.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&sl(this.fn.waiting,sg)},a.pn=function(){var e=navigator.serviceWorker.controller;return e&&sd(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 sh(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}}],sc(n.prototype,t),o&&sc(n,o),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 sp(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)?sp(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 s_(e,n){if(void 0!==u)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),u;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new sb(e,n);return u=t.register().then(()=>t.controlling.then(()=>t))}function sv(){return u??Promise.resolve(void 0)}let s$="x-omrs-offline-response-body",sA="x-omrs-offline-response-status",sw="x-omrs-offline-caching-strategy";async function sk(e){let n=await sv();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 sx(){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 sC(){return!window.indexedDB}async function sE(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function sS(){return await sE()||await sC()||await sx()}let sD="openmrs3:offline-mode",sz="unavailable";function sM(){return{current:sz,notAvailable:"unavailable"===sz,active:"on"===sz}}function sP(e){"unavailable"!==sz&&"unavailable"!==e&&(localStorage.setItem(sD,"on"===e?"active":"disabled"),sz=e)}async function sO(){await sS()||(sz="active"===localStorage.getItem(sD)?"on":"off"),navigator.onLine}let sT="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,sN=Object.keys,sI=Array.isArray;function sB(e,n){return"object"!=typeof n||sN(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||sT.Promise||(sT.Promise=Promise);let sj=Object.getPrototypeOf,sR={}.hasOwnProperty;function sF(e,n){return sR.call(e,n)}function sL(e,n){"function"==typeof n&&(n=n(sj(e))),("u"<typeof Reflect?sN:Reflect.ownKeys)(n).forEach(t=>{sV(e,t,n[t])})}let sW=Object.defineProperty;function sV(e,n,t,o){sW(e,n,sB(t&&sF(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},o))}function sG(e){return{from:function(n){return e.prototype=Object.create(n.prototype),sV(e.prototype,"constructor",e),{extend:sL.bind(null,e.prototype)}}}}let sU=Object.getOwnPropertyDescriptor;function sH(e,n){let t;return sU(e,n)||(t=sj(e))&&sH(t,n)}let sq=[].slice;function sK(e,n,t){return sq.call(e,n,t)}function sY(e,n){return n(e)}function sZ(e){if(!e)throw Error("Assertion Failed")}function sJ(e){sT.setImmediate?setImmediate(e):setTimeout(e,0)}function sX(e,n){return e.reduce((e,t,o)=>{var a=n(t,o);return a&&(e[a[0]]=a[1]),e},{})}function sQ(e,n){if("string"==typeof n&&sF(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],o=0,a=n.length;o<a;++o){var r=sQ(e,n[o]);t.push(r)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return null==s?void 0:sQ(s,n.substr(i+1))}}function s0(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){sZ("string"!=typeof t&&"length"in t);for(var o=0,a=n.length;o<a;++o)s0(e,n[o],t[o])}else{var r=n.indexOf(".");if(-1!==r){var i=n.substr(0,r),s=n.substr(r+1);if(""===s)void 0===t?sI(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&sF(e,i)||(l=e[i]={}),s0(l,s,t)}}else void 0===t?sI(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function s1(e){var n={};for(var t in e)sF(e,t)&&(n[t]=e[t]);return n}let s2=[].concat;function s3(e){return s2.apply([],e)}let s5="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(s3([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>sT[e]),s4=s5.map(e=>sT[e]);sX(s5,e=>[e,!0]);let s6=null;function s8(e){s6="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=s6&&s6.get(n);if(t)return t;if(sI(n)){t=[],s6&&s6.set(n,t);for(var o=0,a=n.length;o<a;++o)t.push(e(n[o]))}else if(s4.indexOf(n.constructor)>=0)t=n;else{let o=sj(n);for(var r in t=o===Object.prototype?{}:Object.create(o),s6&&s6.set(n,t),n)sF(n,r)&&(t[r]=e(n[r]))}return t}(e);return s6=null,n}let{toString:s7}={};function s9(e){return s7.call(e).slice(8,-1)}let le="u">typeof Symbol?Symbol.iterator:"@@iterator",ln="symbol"==typeof le?function(e){var n;return null!=e&&(n=e[le])&&n.apply(e)}:function(){return null},lt={};function lo(e){var n,t,o,a;if(1==arguments.length){if(sI(e))return e.slice();if(this===lt&&"string"==typeof e)return[e];if(a=ln(e)){for(t=[];!(o=a.next()).done;)t.push(o.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 la="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var lr="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),li=()=>!0;let ls=!Error("").stack;function ll(){if(ls)try{throw ll.arguments,Error()}catch(e){return e}return Error()}function lc(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(li).map(e=>"\n"+e).join("")):""}var lp=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],lu=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(lp),ld={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 lf(e,n){this._e=ll(),this.name=e,this.message=n}function lh(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function lm(e,n,t,o){this._e=ll(),this.failures=n,this.failedKeys=o,this.successCount=t,this.message=lh(e,n)}function lg(e,n){this._e=ll(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=lh(e,n)}sG(lf).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+lc(this._e,2))}},toString:function(){return this.name+": "+this.message}}),sG(lm).from(lf),sG(lg).from(lf);var ly=lu.reduce((e,n)=>(e[n]=n+"Error",e),{}),lb=lu.reduce((e,n)=>{var t=n+"Error";function o(e,o){this._e=ll(),this.name=t,e?"string"==typeof e?(this.message=`${e}${o?"\n "+o:""}`,this.inner=o||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=ld[n]||t,this.inner=null)}return sG(o).from(lf),e[n]=o,e},{});lb.Syntax=SyntaxError,lb.Type=TypeError,lb.Range=RangeError;var l_=lp.reduce((e,n)=>(e[n+"Error"]=lb[n],e),{}),lv=lu.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=lb[n]),e),{});function l$(){}function lA(e){return e}function lw(e,n){return null==e||e===lA?n:function(t){return n(e(t))}}function lk(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function lx(e,n){return e===l$?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var r=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?lk(o,this.onsuccess):o),a&&(this.onerror=this.onerror?lk(a,this.onerror):a),void 0!==r?r:t}}function lC(e,n){return e===l$?n:function(){e.apply(this,arguments);var t=this.onsuccess,o=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?lk(t,this.onsuccess):t),o&&(this.onerror=this.onerror?lk(o,this.onerror):o)}}function lE(e,n){return e===l$?n:function(t){var o=e.apply(this,arguments);sB(t,o);var a=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?lk(a,this.onsuccess):a),r&&(this.onerror=this.onerror?lk(r,this.onerror):r),void 0===o?void 0===i?void 0:i:sB(o,i)}}function lS(e,n){return e===l$?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function lD(e,n){return e===l$?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var o=this,a=arguments.length,r=Array(a);a--;)r[a]=arguments[a];return t.then(function(){return n.apply(o,r)})}return n.apply(this,arguments)}}lv.ModifyError=lm,lv.DexieError=lf,lv.BulkError=lg;var lz={};let[lM,lP,lO]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,sj(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,sj(n),e]})(),lT=lP&&lP.then,lN=lM&&lM.constructor,lI=!!lO;var lB=!1,lj=lO?()=>{lO.then(l4)}:sT.setImmediate?setImmediate.bind(null,l4):sT.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{l4(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(l4,0)},lR=function(e,n){lK.push([e,n]),lL&&(lj(),lL=!1)},lF=!0,lL=!0,lW=[],lV=[],lG=null,lU=lA,lH={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:c_,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{c_(e[0],e[1])}catch(e){}})}},lq=lH,lK=[],lY=0,lZ=[];function lJ(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=l$,this._lib=!1;var n=this._PSD=lq;if(lr&&(this._stackHolder=ll(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==lz)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&l0(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 o=n._lib&&l6();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof lJ?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,l1(n)),o&&l8()}},l0.bind(null,n))}catch(e){l0(n,e)}}(this,e)}let lX={get:function(){var e=lq,n=cr;function t(t,o){var a=!e.global&&(e!==lq||n!==cr);let r=a&&!cc();var i=new lJ((n,i)=>{l2(this,new lQ(cg(t,e,a,r),cg(o,e,a,r),n,i,e))});return lr&&l5(i,this),i}return t.prototype=lz,t},set:function(e){sV(this,"then",e&&e.prototype===lz?lX:{get:function(){return e},set:lX.set})}};function lQ(e,n,t,o,a){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=o,this.psd=a}function l0(e,n){if(lV.push(n),null===e._state){var t=e._lib&&l6();n=lU(n),e._state=!1,e._value=n,lr&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=sH(n,"stack");n._promise=e,sV(n,"stack",{get:()=>lB?t&&(t.get?t.get.apply(n):t.value):e.stack})}),lW.some(n=>n._value===e._value)||lW.push(e),l1(e),t&&l8()}}function l1(e){var n=e._listeners;e._listeners=[];for(var t=0,o=n.length;t<o;++t)l2(e,n[t]);var a=e._PSD;--a.ref||a.finalize(),0===lY&&(++lY,lR(()=>{0==--lY&&l7()},[]))}function l2(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,++lY,lR(l3,[t,e,n])}else e._listeners.push(n)}function l3(e,n,t){try{lG=n;var o,a=n._value;n._state?o=e(a):(lV.length&&(lV=[]),o=e(a),-1===lV.indexOf(a)&&function(e){for(var n=lW.length;n;)if(lW[--n]._value===e._value)return void lW.splice(n,1)}(n)),t.resolve(o)}catch(e){t.reject(e)}finally{lG=null,0==--lY&&l7(),--t.psd.ref||t.psd.finalize()}}function l5(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function l4(){l6()&&l8()}function l6(){var e=lF;return lF=!1,lL=!1,e}function l8(){var e,n,t;do for(;lK.length>0;)for(e=lK,lK=[],t=e.length,n=0;n<t;++n){var o=e[n];o[0].apply(null,o[1])}while(lK.length>0);lF=!0,lL=!0}function l7(){var e=lW;lW=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=lZ.slice(0),t=n.length;t;)n[--t]()}function l9(e){return new lJ(lz,!1,e)}function ce(e,n){var t=lq;return function(){var o=l6(),a=lq;try{return cf(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{cf(a,!1),o&&l8()}}}sL(lJ.prototype,{then:lX,_then:function(e,n){l2(this,new lQ(null,null,e,n,lq))},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):l9(e)):this.then(null,e=>e&&e.name===n?t(e):l9(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),l9(n)))},stack:{get:function(){if(this._stack)return this._stack;try{lB=!0;var e=(function e(n,t,o){if(t.length===o)return t;var a="";if(!1===n._state){var r,i,s=n._value;null!=s?(r=s.name||"Error",i=s.message||s,a=lc(s,0)):(r=s,i=""),t.push(r+(i?": "+i:"")+a)}return lr&&((a=lc(n._stackHolder,2))&&-1===t.indexOf(a)&&t.push(a),n._prev&&e(n._prev,t,o)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{lB=!1}}},timeout:function(e,n){return e<1/0?new lJ((t,o)=>{var a=setTimeout(()=>o(new lb.Timeout(n)),e);this.then(t,o).finally(clearTimeout.bind(null,a))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&sV(lJ.prototype,Symbol.toStringTag,"Dexie.Promise"),lH.env=ch(),sL(lJ,{all:function(){var e=lo.apply(null,arguments).map(cp);return new lJ(function(n,t){0===e.length&&n([]);var o=e.length;e.forEach((a,r)=>lJ.resolve(a).then(t=>{e[r]=t,--o||n(e)},t))})},resolve:e=>{if(e instanceof lJ)return e;if(e&&"function"==typeof e.then)return new lJ((n,t)=>{e.then(n,t)});var n=new lJ(lz,!0,e);return l5(n,lG),n},reject:l9,race:function(){var e=lo.apply(null,arguments).map(cp);return new lJ((n,t)=>{e.map(e=>lJ.resolve(e).then(n,t))})},PSD:{get:()=>lq,set:e=>lq=e},totalEchoes:{get:()=>cr},newPSD:cs,usePSD:cm,scheduler:{get:()=>lR,set:e=>{lR=e}},rejectionMapper:{get:()=>lU,set:e=>{lU=e}},follow:(e,n)=>new lJ((t,o)=>cs((n,t)=>{var o=lq;o.unhandleds=[],o.onunhandled=t,o.finalize=lk(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},lZ.push(function n(){e(),lZ.splice(lZ.indexOf(n),1)}),++lY,lR(()=>{0==--lY&&l7()},[])},o.finalize),e()},n,t,o))}),lN&&(lN.allSettled&&sV(lJ,"allSettled",function(){let e=lo.apply(null,arguments).map(cp);return new lJ(n=>{0===e.length&&n([]);let t=e.length,o=Array(t);e.forEach((e,a)=>lJ.resolve(e).then(e=>o[a]={status:"fulfilled",value:e},e=>o[a]={status:"rejected",reason:e}).then(()=>--t||n(o)))})}),lN.any&&"u">typeof AggregateError&&sV(lJ,"any",function(){let e=lo.apply(null,arguments).map(cp);return new lJ((n,t)=>{0===e.length&&t(AggregateError([]));let o=e.length,a=Array(o);e.forEach((e,r)=>lJ.resolve(e).then(e=>n(e),e=>{a[r]=e,--o||t(AggregateError(a))}))})}));let cn={awaits:0,echoes:0,id:0};var ct=0,co=[],ca=0,cr=0,ci=0;function cs(e,n,t,o){var a=lq,r=Object.create(a);r.parent=a,r.ref=0,r.global=!1,r.id=++ci;var i=lH.env;r.env=lI?{Promise:lJ,PromiseProp:{value:lJ,configurable:!0,writable:!0},all:lJ.all,race:lJ.race,allSettled:lJ.allSettled,any:lJ.any,resolve:lJ.resolve,reject:lJ.reject,nthen:cy(i.nthen,r),gthen:cy(i.gthen,r)}:{},n&&sB(r,n),++a.ref,r.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cm(r,e,t,o);return 0===r.ref&&r.finalize(),s}function cl(){return cn.id||(cn.id=++ct),++cn.awaits,cn.echoes+=100,cn.id}function cc(){return!!cn.awaits&&(0==--cn.awaits&&(cn.id=0),cn.echoes=100*cn.awaits,!0)}function cp(e){return cn.echoes&&e&&e.constructor===lN?(cl(),e.then(e=>(cc(),e),e=>(cc(),cv(e)))):e}function cu(e){++cr,cn.echoes&&0!=--cn.echoes||(cn.echoes=cn.id=0),co.push(lq),cf(e,!0)}function cd(){var e=co[co.length-1];co.pop(),cf(e,!1)}function cf(e,n){var t,o=lq;if((n?!cn.echoes||ca++&&e===lq:!ca||--ca&&e===lq)||(t=n?cu.bind(null,e):cd,lT.call(lM,t)),e!==lq&&(lq=e,o===lH&&(lH.env=ch()),lI)){var a=lH.env.Promise,r=e.env;lP.then=r.nthen,a.prototype.then=r.gthen,(o.global||e.global)&&(Object.defineProperty(sT,"Promise",r.PromiseProp),a.all=r.all,a.race=r.race,a.resolve=r.resolve,a.reject=r.reject,r.allSettled&&(a.allSettled=r.allSettled),r.any&&(a.any=r.any))}}function ch(){var e=sT.Promise;return lI?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(sT,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:lP.then,gthen:e.prototype.then}:{}}function cm(e,n,t,o,a){var r=lq;try{return cf(e,!0),n(t,o,a)}finally{cf(r,!1)}}function cg(e,n,t,o){return"function"!=typeof e?e:function(){var a,r=lq;t&&cl(),cf(n,!0);try{return e.apply(this,arguments)}finally{cf(r,!1),o&&(a=cc,lT.call(lM,a))}}}function cy(e,n){return function(t,o){return e.call(this,cg(t,n),cg(o,n))}}-1===(""+lT).indexOf("[native code]")&&(cl=cc=l$);let cb="unhandledrejection";function c_(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var o,a={promise:n,reason:e};if(sT.document&&document.createEvent?((o=document.createEvent("Event")).initEvent(cb,!0,!0),sB(o,a)):sT.CustomEvent&&sB(o=new CustomEvent(cb,{detail:a}),a),o&&sT.dispatchEvent&&(dispatchEvent(o),!sT.PromiseRejectionEvent&&sT.onunhandledrejection))try{sT.onunhandledrejection(o)}catch(e){}lr&&o&&!o.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var cv=lJ.reject;let c$="3.2.7",cA=String.fromCharCode(65535),cw=-1/0,ck="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",cx="String expected.",cC=[],cE="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),cS=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),cD="__dbnames",cz="readonly",cM="readwrite";function cP(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let cO={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function cT(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=s8(n))[e],n)}class cN{_trans(e,n,t){let o=this._tx||lq.trans,a=this.name;function r(e,t,o){if(!o.schema[a])throw new lb.NotFound("Table "+a+" not part of transaction");return n(o.idbtrans,o)}let i=l6();try{return o&&o.db===this.db?o===lq.trans?o._promise(e,r,t):cs(()=>o._promise(e,r,t),{trans:o,transless:lq.transless||lq}):function e(n,t,o,a){if(n.idbdb&&(n._state.openComplete||lq.letThrough||n._vip)){var r=n._createTransaction(t,o,n._dbSchema);try{r.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===ly.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,a))):cv(r)}return r._promise(t,(e,n)=>cs(()=>(lq.trans=r,a(e,n,r)))).then(e=>r._completion.then(()=>e))}if(n._state.openComplete)return cv(new lb.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return cv(new lb.DatabaseClosed);n.open().catch(l$)}return n._state.dbReadyPromise.then(()=>e(n,t,o,a))}(this.db,e,[this.name],r)}finally{i&&l8()}}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(sI(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=sN(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!==cA){let o=t.keyPath.slice(0,n.length);return this.where(o).equals(o.map(n=>e[n]))}!t&&lr&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:o}=this.schema,a=this.db._deps.indexedDB;function r(e,n){try{return 0===a.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],a)=>{let i=o[a],s=e[a];return[n||i,n||!i?cP(t,i&&i.multi?e=>{let n=sQ(e,a);return sI(n)&&n.some(e=>r(s,e))}:e=>r(s,sQ(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,sI(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 o in n)if(sF(n,o))try{t[o]=n[o]}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){sB(this,e)})}add(e,n){let{auto:t,keyPath:o}=this.schema.primKey,a=e;return o&&t&&(a=cT(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})).then(e=>e.numFailures?lJ.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{s0(e,o,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||sI(e))return this.where(":id").equals(e).modify(n);{let t=sQ(e,this.schema.primKey.keyPath);if(void 0===t)return cv(new lb.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?sN(n).forEach(t=>{s0(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:o}=this.schema.primKey,a=e;return o&&t&&(a=cT(o)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})).then(e=>e.numFailures?lJ.reject(e.failures[0]):e.lastResult).then(n=>{if(o)try{s0(e,o,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?lJ.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:cO})).then(e=>e.numFailures?lJ.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 o=Array.isArray(n)?n:void 0,a=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&o)throw new lb.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new lb.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(cT(r)):e;return this.core.mutate({trans:n,type:"add",keys:o,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return a?n:t;throw new lg(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,o)})})}bulkPut(e,n,t){let o=Array.isArray(n)?n:void 0,a=(t=t||(o?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&o)throw new lb.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new lb.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(cT(r)):e;return this.core.mutate({trans:n,type:"put",keys:o,values:s,wantResults:a}).then(({numFailures:e,results:n,lastResult:t,failures:o})=>{if(0===e)return a?n:t;throw new lg(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,o)})})}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:o})=>{if(0===e)return t;throw new lg(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,o)})}}function cI(e){var n={},t=function(t,o){if(o){for(var a=arguments.length,r=Array(a-1);--a;)r[a-1]=arguments[a];return n[t].subscribe.apply(null,r),e}if("string"==typeof t)return n[t]};t.addEventType=r;for(var o=1,a=arguments.length;o<a;++o)r(arguments[o]);return t;function r(e,o,a){if("object"!=typeof e){o||(o=lS),a||(a=l$);var i={subscribers:[],fire:a,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=o(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(o,a)}};return n[e]=t[e]=i,i}sN(e).forEach(function(n){var t=e[n];if(sI(t))r(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new lb.InvalidArgument("Invalid event config");var o=r(n,lA,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];o.subscribers.forEach(function(e){sJ(function(){e.apply(null,n)})})})}})}}function cB(e,n){return sG(n).from({prototype:e}),n}function cj(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function cR(e,n){e.filter=cP(e.filter,n)}function cF(e,n,t){var o=e.replayFilter;e.replayFilter=o?()=>cP(o(),n()):n,e.justLimit=t&&!o}function cL(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new lb.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function cW(e,n,t){let o=cL(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:o,range:e.range}})}function cV(e,n,t,o){let a=e.replayFilter?cP(e.filter,e.replayFilter()):e.filter;if(e.or){let r={},i=(e,t,o)=>{if(!a||a(t,o,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),sF(r,s)||(r[s]=!0,n(e,t,o))}};return Promise.all([e.or._iterate(i,t),cG(cW(e,o,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return cG(cW(e,o,t),cP(e.algorithm,a),n,!e.keysOnly&&e.valueMapper)}function cG(e,n,t,o){var a=ce(o?(e,n,a)=>t(o(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=l$},n=>{e.fail(n),t=l$})||a(e.value,e,e=>t=e),t()})})}function cU(e,n){try{let t=cH(e),o=cH(n);if(t!==o)return"Array"===t?1:"Array"===o?-1:"binary"===t?1:"binary"===o?-1:"string"===t?1:"string"===o?-1:"Date"===t?1:"Date"!==o?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,o=n.length,a=t<o?t:o;for(let t=0;t<a;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===o?0:t<o?-1:1}(cq(e),cq(n));case"Array":return function(e,n){let t=e.length,o=n.length,a=t<o?t:o;for(let t=0;t<a;++t){let o=cU(e[t],n[t]);if(0!==o)return o}return t===o?0:t<o?-1:1}(e,n)}}catch(e){}return NaN}function cH(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=s9(e);return"ArrayBuffer"===t?"binary":t}function cq(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class cK{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,cv.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,cv.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=cP(n.algorithm,e)}_iterate(e,n){return cV(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&sB(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>cV(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(cj(n,!0))return t.count({trans:e,query:{index:cL(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var o=0;return cV(n,()=>(++o,!1),e,t).then(()=>o)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),o=t[0],a=t.length-1;function r(e,n){return n?r(e[t[n]],n-1):e[o]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=r(e,a),o=r(n,a);return t<o?-i:t>o?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&&cj(n,!0)&&n.limit>0){let{valueMapper:t}=n,o=cL(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:o,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return cV(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,cj(n)?cF(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):cF(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),cF(this._ctx,()=>{var n=e;return function(e,t,o){return--n<=0&&t(o),n>=0}},!0),this}until(e,n){return cR(this._ctx,function(t,o,a){return!e(t.value)||(o(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 cR(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=cP(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&&cj(n,!0)&&n.limit>0)return this._read(e=>{var t=cL(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 cR(this._ctx,function(e){var n=e.primaryKey.toString(),o=sF(t,n);return t[n]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(t=>{var o;if("function"==typeof e)o=e;else{var a=sN(e),r=a.length;o=function(n){for(var t=!1,o=0;o<r;++o){var i=a[o],s=e[i];sQ(n,i)!==s&&(s0(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,p=[],u=0,d=[],f=(e,n)=>{let{failures:t,numFailures:o}=n;for(let n of(u+=e-o,sN(t)))p.push(t[n])};return this.clone().primaryKeys().then(a=>{let r=p=>{let u=Math.min(c,a.length-p);return i.getMany({trans:t,keys:a.slice(p,p+u),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<u;++e){let n=d[e],t={value:s8(n),primKey:a[p+e]};!1!==o.call(t,t.value,t)&&(null==t.value?y.push(a[p+e]):s||0===cU(l(n),l(t.value))?(m.push(t.value),s&&g.push(a[p+e])):(y.push(a[p+e]),h.push(t.value)))}let b=cj(n)&&n.limit===1/0&&("function"!=typeof e||e===cY)&&{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===cY)&&i.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>a.length>p+u&&r(p+c))})};return r(0).then(()=>{if(p.length>0)throw new lm("Error modifying one or more objects",p,u,d);return a.length})})})}delete(){var e=this._ctx,n=e.range;return cj(e)&&(e.isPrimKey&&!cE||3===n.type)?this._write(t=>{let{primaryKey:o}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:o,range:n}}).then(o=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:a})=>{if(a)throw new lm("Could not delete some values",Object.keys(e).map(n=>e[n]),o-a);return o-a}))}):this.modify(cY)}}let cY=(e,n)=>n.value=null;function cZ(e,n){return e<n?-1:+(e!==n)}function cJ(e,n){return e>n?-1:+(e!==n)}function cX(e,n,t){var o=e instanceof c3?new e.Collection(e):e;return o._ctx.error=t?new t(n):TypeError(n),o}function cQ(e){return new e.Collection(e,()=>c2("")).limit(0)}function c0(e,n,t,o){var a,r,i,s,l,c,p,u=t.length;if(!t.every(e=>"string"==typeof e))return cX(e,cx);function d(e){a="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),r="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?cZ:cJ;var n=t.map(function(e){return{lower:r(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,p="next"===e?"":o}d("next");var f=new e.Collection(e,()=>c1(s[0],l[u-1]+o));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,o){var a=e.key;if("string"!=typeof a)return!1;var d=r(a);if(n(d,l,h))return!0;for(var f=null,m=h;m<u;++m){var g=function(e,n,t,o,a,r){for(var i=Math.min(e.length,o.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==o[l])return 0>a(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>a(e[l],o[l])?e.substr(0,l)+o[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<o.length&&"next"===r?e+t.substr(e.length):i<e.length&&"prev"===r?e.substr(0,t.length):s<0?null:e.substr(0,s)+o[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+p)}:o),!1}),f}function c1(e,n,t,o){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:o}}function c2(e){return{type:1,lower:e,upper:e}}class c3{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,o){t=!1!==t,o=!0===o;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||o)&&(!t||!o)?cQ(this):new this.Collection(this,()=>c1(e,n,!t,!o))}catch(e){return cX(this,ck)}}equals(e){return null==e?cX(this,ck):new this.Collection(this,()=>c2(e))}above(e){return null==e?cX(this,ck):new this.Collection(this,()=>c1(e,void 0,!0))}aboveOrEqual(e){return null==e?cX(this,ck):new this.Collection(this,()=>c1(e,void 0,!1))}below(e){return null==e?cX(this,ck):new this.Collection(this,()=>c1(void 0,e,!1,!0))}belowOrEqual(e){return null==e?cX(this,ck):new this.Collection(this,()=>c1(void 0,e))}startsWith(e){return"string"!=typeof e?cX(this,cx):this.between(e,e+cA,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):c0(this,(e,n)=>0===e.indexOf(n[0]),[e],cA)}equalsIgnoreCase(e){return c0(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=lo.apply(lt,arguments);return 0===e.length?cQ(this):c0(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=lo.apply(lt,arguments);return 0===e.length?cQ(this):c0(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,cA)}anyOf(){let e=lo.apply(lt,arguments),n=this._cmp;try{e.sort(n)}catch(e){return cX(this,ck)}if(0===e.length)return cQ(this);let t=new this.Collection(this,()=>c1(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let o=0;return t._addAlgorithm((t,a,r)=>{let i=t.key;for(;n(i,e[o])>0;)if(++o===e.length)return a(r),!1;return 0===n(i,e[o])||(a(()=>{t.continue(e[o])}),!1)}),t}notEqual(e){return this.inAnyRange([[cw,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=lo.apply(lt,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return cX(this,ck)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[cw,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,o=this._ascending,a=this._descending,r=this._min,i=this._max;if(0===e.length)return cQ(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=o(e[0],e[1])))return cX(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",lb.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,p=o;function u(e,n){return p(e[0],n[0])}try{(c=e.reduce(function(e,n){let o=0,a=e.length;for(;o<a;++o){let a=e[o];if(0>t(n[0],a[1])&&t(n[1],a[0])>0){a[0]=r(a[0],n[0]),a[1]=i(a[1],n[1]);break}}return o===a&&e.push(n),e},[])).sort(u)}catch(e){return cX(this,ck)}let d=0,f=l?e=>o(e,c[d][1])>0:e=>o(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,()=>c1(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,p=o):(m=h,p=a),c.sort(u)},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(()=>{p===o?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=lo.apply(lt,arguments);return e.every(e=>"string"==typeof e)?0===e.length?cQ(this):this.inAnyRange(e.map(e=>[e,e+cA])):cX(this,"startsWithAnyOf() only works with strings")}}function c5(e){return ce(function(n){return c4(n),e(n.target.error),!1})}function c4(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let c6="storagemutated",c8="x-storagemutated-1",c7=cI(null,c6);class c9{_lock(){return sZ(!lq.global),++this._reculock,1!==this._reculock||lq.global||(lq.lockOwnerFor=this),this}_unlock(){if(sZ(!lq.global),0==--this._reculock)for(lq.global||(lq.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cm(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&lq.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(sZ(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new lb.DatabaseClosed(t);case"MissingAPIError":throw new lb.MissingAPI(t.message,t);default:throw new lb.OpenFailed(t)}if(!this.active)throw new lb.TransactionInactive;return sZ(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=ce(n=>{c4(n),this._reject(e.error)}),e.onabort=ce(n=>{c4(n),this.active&&this._reject(new lb.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=ce(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&c7.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return cv(new lb.ReadOnly("Transaction is readonly"));if(!this.active)return cv(new lb.TransactionInactive);if(this._locked())return new lJ((o,a)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(o,a)},lq])});if(t)return cs(()=>{var e=new lJ((e,t)=>{this._lock();let o=n(e,t,this);o&&o.then&&o.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var o=new lJ((e,t)=>{var o=n(e,t,this);o&&o.then&&o.then(e,t)});return o._lib=!0,o}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=lJ.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var o=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(o.get(-1/0).onsuccess=e)}()}var a=n._waitingFor;return new lJ((e,o)=>{t.then(t=>n._waitingQueue.push(ce(e.bind(null,t))),e=>n._waitingQueue.push(ce(o.bind(null,e)))).finally(()=>{n._waitingFor===a&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new lb.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(sF(n,e))return n[e];let t=this.schema[e];if(!t)throw new lb.NotFound("Table "+e+" not part of transaction");let o=new this.db.Table(e,t,this);return o.core=this.db.core.table(e),n[e]=o,o}}function pe(e,n,t,o,a,r,i){return{name:e,keyPath:n,unique:t,multi:o,auto:a,compound:r,src:(t&&!i?"&":"")+(o?"*":"")+(a?"++":"")+pn(n)}}function pn(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function pt(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:sX(t,e=>[e.name,e])}}let po=e=>{try{return e.only([[]]),po=()=>[[]],[[]]}catch(e){return po=()=>cA,cA}};function pa(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>sQ(n,e):n=>sQ(n,e)}function pr(e){return[].slice.call(e)}let pi=0;function ps(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function pl({_novip:e},n){let t=n.db,o=function(e,n,{IDBKeyRange:t,indexedDB:o},a){var r;return{dbcore:(r=function(e,n,t){let o;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:o,lowerOpen:a,upperOpen:r}=e;return void 0===t?void 0===o?null:n.upperBound(o,!!r):void 0===o?n.lowerBound(t,!!a):n.bound(t,o,!!a,!!r)}let{schema:r,hasGetAll:i}=(o=pr(e.objectStoreNames),{schema:{name:e.name,tables:o.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,o=sI(n),a=null==n,r={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:a,compound:o,keyPath:n,autoIncrement:t,unique:!0,extractKey:pa(n)},indexes:pr(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:o,keyPath:a}=e,i={name:n,compound:sI(a),keyPath:a,unique:t,multiEntry:o,extractKey:pa(a)};return r[ps(a)]=i,i}),getIndexByKeyPath:e=>r[ps(e)]};return r[":id"]=i.primaryKey,null!=n&&(r[ps(n)]=i.primaryKey),i})},hasGetAll:o.length>0&&"getAll"in t.objectStore(o[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=r.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:o,values:r,range:i}){return new Promise((s,l)=>{let c;s=ce(s);let p=e.objectStore(n),u=null==p.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=o||r||{length:1};if(o&&r&&o.length!==r.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,c4(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=p.clear()):h.push(c=p.delete(a(i)))}else{let[e,n]=d?u?[r,o]:[r,null]:[o,null];if(d)for(let o=0;o<f;++o)h.push(c=n&&void 0!==n[o]?p[t](e[o],n[o]):p[t](e[o])),c.onerror=y;else for(let n=0;n<f;++n)h.push(c=p[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?o:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((o,a)=>{o=ce(o);let r=e.objectStore(n),i=t.length,s=Array(i),l,c=0,p=0,u=e=>{let n=e.target;s[n._pos]=n.result,++p===c&&o(s)},d=c5(a);for(let e=0;e<i;++e)null!=t[e]&&((l=r.get(t[e]))._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&o(s)}),get:({trans:e,key:t})=>new Promise((o,a)=>{o=ce(o);let r=e.objectStore(n).get(t);r.onsuccess=e=>o(e.target.result),r.onerror=c5(a)}),query:e=>new Promise((t,o)=>{t=ce(t);let{trans:r,values:s,limit:l,query:c}=e,p=l===1/0?void 0:l,{index:u,range:d}=c,f=r.objectStore(n),h=u.isPrimaryKey?f:f.index(u.name),m=a(d);if(0===l)return t({result:[]});if(i){let e=s?h.getAll(m,p):h.getAllKeys(m,p);e.onsuccess=e=>t({result:e.target.result}),e.onerror=c5(o)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),a=[];n.onsuccess=o=>{let r=n.result;return r?(a.push(s?r.value:r.primaryKey),++e===l?t({result:a}):void r.continue()):t({result:a})},n.onerror=c5(o)}}),openCursor:function({trans:e,values:t,query:o,reverse:r,unique:i}){return new Promise((s,l)=>{s=ce(s);let{index:c,range:p}=o,u=e.objectStore(n),d=c.isPrimaryKey?u:u.index(c.name),f=r?i?"prevunique":"prev":i?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(a(p),f):d.openCursor(a(p),f);h.onerror=c5(l),h.onsuccess=ce(n=>{let t=h.result;if(!t)return void s(null);t.___id=++pi,t.done=!1;let o=t.continue.bind(t),a=t.continuePrimaryKey;a&&(a=a.bind(t));let r=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=ce(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=ce(e),h.onerror=c5(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=ce(e=>{h.onsuccess=s,s()}),t.continue=o,t.continuePrimaryKey=a,t.advance=r,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:o,range:r}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=o.isPrimaryKey?s:s.index(o.name),c=a(r),p=c?l.count(c):l.count();p.onsuccess=ce(n=>e(n.target.result)),p.onerror=c5(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:po(n),schema:r}}(n,t,a),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),r))}}(e._middlewares,t,e._deps,n);e.core=o.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 pc({_novip:e},n,t,o){t.forEach(t=>{let a=o[t];n.forEach(n=>{let o=sH(n,t);(!o||"value"in o&&void 0===o.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?sV(n,t,{get(){return this.table(t)},set(e){sW(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,a))})})}function pp({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function pu(e,n){return e._cfg.version-n._cfg.version}function pd(e,n){let t,o={del:[],add:[],change:[]};for(t in e)n[t]||o.del.push(t);for(t in n){let a=e[t],r=n[t];if(a){let e={name:t,def:r,recreate:!1,del:[],add:[],change:[]};if(""+(a.primKey.keyPath||"")==""+(r.primKey.keyPath||"")&&(a.primKey.auto===r.primKey.auto||cE)){let n,t=a.idxByName,i=r.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let o=t[n],a=i[n];o?o.src!==a.src&&e.change.push(a):e.add.push(a)}(e.del.length>0||e.add.length>0||e.change.length>0)&&o.change.push(e)}else e.recreate=!0,o.change.push(e)}else o.add.push([t,r])}return o}function pf(e,n,t,o){let a=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return o.forEach(e=>ph(a,e)),a}function ph(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function pm(e,n,t){let o={};return sK(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),a=n.keyPath,r=pe(pn(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=pe(t.name,a,!!t.unique,!!t.multiEntry,!1,a&&"string"!=typeof a,!1);i.push(s)}o[e]=pt(e,r,i)}),o}function pg({_novip:e},n,t){let o=t.db.objectStoreNames;for(let a=0;a<o.length;++a){let r=o[a],i=t.objectStore(r);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],o=i.index(t).keyPath,a="string"==typeof o?o:"["+sK(o).join("+")+"]";if(n[r]){let e=n[r].idxByName[a];e&&(e.name=t,delete n[r].idxByName[a],n[r].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&sT.WorkerGlobalScope&&sT instanceof sT.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class py{_parseStoresSpec(e,n){sN(e).forEach(t=>{if(null!==e[t]){var o=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),o=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return pe(t,o||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),sI(o),0===n)}),a=o.shift();if(a.multi)throw new lb.Schema("Primary key cannot be multi-valued");o.forEach(e=>{if(e.auto)throw new lb.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new lb.Schema("Index must have a name and cannot be an empty string")}),n[t]=pt(t,a,o)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?sB(this._cfg.storesSource,e):e;let t=n._versions,o={},a={};return t.forEach(e=>{sB(o,e._cfg.storesSource),a=e._cfg.dbschema={},e._parseStoresSpec(o,a)}),n._dbSchema=a,pp(n,[n._allTables,n,n.Transaction.prototype]),pc(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],sN(a),a),n._storeNames=sN(a),this}upgrade(e){return this._cfg.contentUpgrade=lD(this._cfg.contentUpgrade||l$,e),this}}function pb(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new pB(cD,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function p_(e){return e&&"function"==typeof e.databases}function pv(e){return cs(function(){return lq.letThrough=!0,e()})}function p$(e){var n=n=>e.next(n),t=a(n),o=a(n=>e.throw(n));function a(e){return n=>{var a=e(n),r=a.value;return a.done?r:r&&"function"==typeof r.then?r.then(t,o):sI(r)?Promise.all(r).then(t,o):t(r)}}return a(n)()}function pA(e,n,t){var o=arguments.length;if(o<2)throw new lb.InvalidArgument("Too few arguments");for(var a=Array(o-1);--o;)a[o-1]=arguments[o];return t=a.pop(),[e,s3(a),t]}function pw(e,n,t){let o=sI(e)?e.slice():[e];for(let e=0;e<t;++e)o.push(n);return o}let pk={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:o}=t,a={},r=[];function i(e,n,t){let o=ps(e),s=a[o]=a[o]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,p={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:pa(e),unique:!c&&t.unique};return s.push(p),p.isPrimaryKey||r.push(p),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),p}let s=i(o.primaryKey.keyPath,0,o.primaryKey);for(let e of(a[":id"]=[s],o.indexes))i(e.keyPath,0,e);function l(n){var t,o;let a=n.query.index;return a.isVirtual?{...n,query:{index:a,range:(t=n.query.range,o=a.keyTail,{type:1===t.type?2:t.type,lower:pw(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,o),lowerOpen:!0,upper:pw(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,o),upperOpen:!0})}}:n}return{...t,schema:{...o,primaryKey:s,indexes:r,getIndexByKeyPath:function(e){let n=a[ps(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:o,isVirtual:a,keyLength:r}=n.query.index;return a?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(a){null!=a?t.continue(pw(a,n.reverse?e.MAX_KEY:e.MIN_KEY,o)):n.unique?t.continue(t.key.slice(0,r).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,o)):t.continue()}},continuePrimaryKey:{value(n,a){t.continuePrimaryKey(pw(n,e.MAX_KEY,o),a)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===r?e[0]:e.slice(0,r)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function px(e,n,t,o){return t=t||{},o=o||"",sN(e).forEach(a=>{if(sF(n,a)){var r=e[a],i=n[a];if("object"==typeof r&&"object"==typeof i&&r&&i){let e=s9(r);e!==s9(i)?t[o+a]=n[a]:"Object"===e?px(r,i,t,o+a+"."):r!==i&&(t[o+a]=n[a])}else r!==i&&(t[o+a]=n[a])}else t[o+a]=void 0}),sN(n).forEach(a=>{sF(e,a)||(t[o+a]=n[a])}),t}let pC={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:o}=t.schema;return{...t,mutate(e){let a=lq.trans,{deleting:r,creating:i,updating:s}=a.table(n).hook;switch(e.type){case"add":if(i.fire===l$)break;return a._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===l$&&s.fire===l$)break;return a._promise("readwrite",()=>l(e),!0);case"delete":if(r.fire===l$)break;return a._promise("readwrite",()=>l(e),!0);case"deleteRange":if(r.fire===l$)break;return a._promise("readwrite",()=>(function e(n,a,r){return t.query({trans:n,values:!1,query:{index:o,range:a},limit:r}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(o=>o.numFailures>0?Promise.reject(o.failures[0]):t.length<r?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...a,lower:t[t.length-1],lowerOpen:!0},r)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,a;let l=lq.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(o.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],p={onerror:null,onsuccess:null};if("delete"===e.type)r.fire.call(p,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(p,t,e.values[a],l);null==t&&null!=n&&(t=n,e.keys[a]=t,o.outbound||s0(e.values[a],o.keyPath,t))}else{let n=px(c,e.values[a]),o=s.fire.call(p,n,t,c,l);if(o){let n=e.values[a];Object.keys(o).forEach(e=>{sF(n,e)?n[e]=o[e]:s0(n,e,o[e])})}}return p});return t.mutate(e).then(({failures:t,results:o,numFailures:r,lastResult:i})=>{for(let r=0;r<c.length;++r){let i=o?o[r]:c[r],s=a[r];null==i?s.onerror&&s.onerror(t[r]):s.onsuccess&&s.onsuccess("put"===e.type&&n[r]?e.values[r]:i)}return{failures:t,results:o,numFailures:r,lastResult:i}}).catch(e=>(a.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function pE(e,n,t){try{if(!n||n.keys.length<e.length)return null;let o=[];for(let a=0,r=0;a<n.keys.length&&r<e.length;++a)0===cU(n.keys[a],e[r])&&(o.push(t?s8(n.values[a]):n.values[a]),++r);return o.length===e.length?o:null}catch(e){return null}}let pS={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=pE(e.keys,e.trans._cache,"clone"===e.cache);return n?lJ.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?s8(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function pD(e){return!("from"in e)}let pz=function(e,n){if(!this){let n=new pz;return e&&"d"in e&&sB(n,e),n}sB(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function pM(e,n,t){let o=cU(n,t);if(isNaN(o))return;if(o>0)throw RangeError();if(pD(e))return sB(e,{from:n,to:t,d:1});let a=e.l,r=e.r;if(0>cU(t,e.from))return a?pM(a,n,t):e.l={from:n,to:t,d:1,l:null,r:null},pT(e);if(cU(n,e.to)>0)return r?pM(r,n,t):e.r={from:n,to:t,d:1,l:null,r:null},pT(e);0>cU(n,e.from)&&(e.from=n,e.l=null,e.d=r?r.d+1:1),cU(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&&pP(e,a),r&&i&&pP(e,r)}function pP(e,n){pD(n)||function e(n,{from:t,to:o,l:a,r:r}){pM(n,t,o),a&&e(n,a),r&&e(n,r)}(e,n)}function pO(e){let n=pD(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>cU(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>=cU(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 pT(e){var n,t;let o=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),a=o>1?"r":o<-1?"l":"";if(a){let n="r"===a?"l":"r",t={...e},o=e[a];e.from=o.from,e.to=o.to,e[a]=o[a],t[a]=o[n],e[n]=t,t.d=pN(t)}e.d=pN(e)}function pN({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}sL(pz.prototype,{add(e){return pP(this,e),this},addKey(e){return pM(this,e,e),this},addKeys(e){return e.forEach(e=>pM(this,e,e)),this},[le](){return pO(this)}});let pI={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new pz(e.MIN_KEY,e.MAX_KEY);return{...e,table:o=>{let a=e.table(o),{schema:r}=a,{primaryKey:i}=r,{extractKey:s,outbound:l}=i,c={...a,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${o}/${e}`;return s[t]||(s[t]=new pz)},c=l(""),p=l(":dels"),{type:u}=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(sI(d)){"delete"!==u&&(d=e.results),c.addKeys(d);let n=pE(d,h);n||"add"===u||p.addKeys(d),(n||f)&&r.indexes.forEach(function(e){let t=l(e.name||"");function o(n){return null!=n?e.extractKey(n):null}let a=n=>e.multiEntry&&sI(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let r=n&&o(n[t]),i=f&&o(f[t]);0!==cU(r,i)&&(null!=r&&a(r),null!=i&&a(i))})})}else if(d){let e={from:d.lower,to:d.upper};p.add(e),c.add(e)}else c.add(t),p.add(t),r.indexes.forEach(e=>l(e.name).add(t));return e})}},p=({query:{index:n,range:t}})=>{var o,a;return[n,new pz(null!=(o=t.lower)?o:e.MIN_KEY,null!=(a=t.upper)?a:e.MAX_KEY)]},u={get:e=>[i,new pz(e.key)],getMany:e=>[i,(new pz).addKeys(e.keys)],count:p,query:p,openCursor:p};return sN(u).forEach(e=>{c[e]=function(r){let{subscr:i}=lq;if(i){let c=e=>{let t=`idb://${n}/${o}/${e}`;return i[t]||(i[t]=new pz)},p=c(""),d=c(":dels"),[f,h]=u[e](r);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&r.values&&a.query({...r,values:!1});return a[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&r.values)return n.then(({result:e})=>(p.addKeys(e),t));let e=r.values?t.result.map(s):t.result;r.values?p.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=r.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&&p.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return a[e].apply(this,arguments)}}),c}}}};class pB{constructor(e,n){var t;this._middlewares={},this.verno=0;const o=pB.dependencies;this._options=n={addons:pB.addons,autoOpen:!0,indexedDB:o.indexedDB,IDBKeyRange:o.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 r={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:l$,dbReadyPromise:null,cancelOpen:l$,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};r.dbReadyPromise=new lJ(e=>{r.dbReadyResolve=e}),r.openCanceller=new lJ((e,n)=>{r.cancelOpen=n}),this._state=r,this.name=e,this.on=cI(this,"populate","blocked","versionchange","close",{ready:[lD,l$]}),this.on.ready.subscribe=sY(this.on.ready.subscribe,e=>(n,t)=>{pB.vip(()=>{let o=this._state;if(o.openComplete)o.dbOpenError||lJ.resolve().then(n),t&&e(n);else if(o.onReadyBeingFired)o.onReadyBeingFired.push(n),t&&e(n);else{e(n);let o=this;t||e(function e(){o.on.ready.unsubscribe(n),o.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,cB(cK.prototype,function(e,n){this.db=t;let o=cO,a=null;if(n)try{o=n()}catch(e){a=e}let r=e._ctx,i=r.table,s=i.hook.reading.fire;this._ctx={table:i,index:r.index,isPrimKey:!r.index||i.schema.primKey.keyPath&&r.index===i.schema.primKey.name,range:o,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:a,or:r.or,valueMapper:s!==lA?s:null}})),this.Table=function(e){return cB(cN.prototype,function(n,t,o){this.db=e,this._tx=o,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:cI(null,{creating:[lx,l$],reading:[lw,lA],updating:[lE,l$],deleting:[lC,l$]})})}(this),this.Transaction=function(e){return cB(c9.prototype,function(n,t,o,a,r){this.db=e,this.mode=n,this.storeNames=t,this.schema=o,this.chromeTransactionDurability=a,this.idbtrans=null,this.on=cI(this,"complete","error","abort"),this.parent=r||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 lJ((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(),cv(e)})})}(this),this.Version=function(e){return cB(py.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return cB(c3.prototype,function(n,t,o){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:o};let a=e._deps.indexedDB;if(!a)throw new lb.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=po(n.IDBKeyRange),this._createTransaction=(e,n,t,o)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,o),this._fireOnBlocked=e=>{this.on("blocked").fire(e),cC.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(pk),this.use(pC),this.use(pI),this.use(pS),this.vip=Object.create(this,{_vip:{value:!0}}),a.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new lb.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new lb.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(pu),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||lq.letThrough||this._vip)?e():new lJ((e,n)=>{if(this._state.openComplete)return n(new lb.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new lb.DatabaseClosed);this.open().catch(l$)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:o}){o&&this.unuse({stack:e,name:o});let a=this._middlewares[e]||(this._middlewares[e]=[]);return a.push({stack:e,create:n,level:null==t?10:t,name:o}),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:o}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?cv(t.dbOpenError):e);lr&&(t.openCanceller._stackHolder=ll()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let a=t.openCanceller;function r(){if(t.openCanceller!==a)throw new lb.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1,c=()=>new lJ((n,a)=>{if(r(),!o)throw new lb.MissingAPI;let i=e.name,c=t.autoSchema?o.open(i):o.open(i,Math.round(10*e.verno));if(!c)throw new lb.MissingAPI;c.onerror=c5(a),c.onblocked=ce(e._fireOnBlocked),c.onupgradeneeded=ce(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=c4,s.abort(),c.result.close();let e=o.deleteDatabase(i);e.onsuccess=e.onerror=ce(()=>{a(new lb.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,o,i,d;s.onerror=c5(a);var r,p,u=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=u<1,e._novip.idbdb=c.result,r=u/10,p=s,t=e._dbSchema,(o=e._createTransaction("readwrite",e._storeNames,t)).create(p),o._completion.catch(a),i=o._reject.bind(o),d=lq.transless||lq,cs(()=>{lq.trans=o,lq.transless=d,0===r?(sN(t).forEach(e=>{pf(p,e,t[e].primKey,t[e].indexes)}),pl(e,p),lJ.follow(()=>e.on.populate.fire(o)).catch(i)):(function({_novip:e},n,t,o){let a=[],r=e._versions,i=e._dbSchema=pm(e,e.idbdb,o),s=!1;return r.filter(e=>e._cfg.version>=n).forEach(r=>{a.push(()=>{let a=i,l=r._cfg.dbschema;pg(e,a,o),pg(e,l,o),i=e._dbSchema=l;let c=pd(a,l);c.add.forEach(e=>{pf(o,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new lb.Upgrade("Not yet support for changing primary key");{let n=o.objectStore(e.name);e.add.forEach(e=>ph(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),ph(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let p=r._cfg.contentUpgrade;if(p&&r._cfg.version>n){let n;pl(e,o),t._memoizedTables={},s=!0;let r=s1(l);c.del.forEach(e=>{r[e]=a[e]}),pp(e,[e.Transaction.prototype]),pc(e,[e.Transaction.prototype],sN(r),r),t.schema=r;let i=la(p);i&&cl();let u=lJ.follow(()=>{if((n=p(t))&&i){var e=cc.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?lJ.resolve(n):u.then(()=>n)}}),a.push(n=>{var o;s&&cE||(o=r._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==o[e]&&n.db.deleteObjectStore(e))),pp(e,[e.Transaction.prototype]),pc(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return a.length?lJ.resolve(a.shift()(t.idbtrans)).then(e):lJ.resolve()})().then(()=>{var e;sN(e=i).forEach(n=>{o.db.objectStoreNames.contains(n)||pf(o,n,e[n].primKey,e[n].indexes)})})})(e,r,o,p).catch(i)})}},a),c.onsuccess=ce(()=>{s=null;let o=e._novip.idbdb=c.result,a=sK(o.objectStoreNames);if(a.length>0)try{let n,r=o.transaction(1===a.length?a[0]:a,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let o=e._dbSchema=pm(0,n,t);e._storeNames=sK(n.objectStoreNames,0),pc(e,[e._allTables],sN(o),o)}(e,o,r):(pg(e,e._dbSchema,r),((n=pd(pm(0,e.idbdb,r),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.")),pl(e,r)}catch(e){}cC.push(e),o.onversionchange=ce(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),o.onclose=ce(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){p_(e)||t===cD||pb(e,n).put({name:t}).catch(l$)}(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()):lJ.reject(e));return lJ.race([a,("u"<typeof navigator?lJ.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(()=>(r(),t.onReadyBeingFired=[],lJ.resolve(pv(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let o=t.onReadyBeingFired.reduce(lD,l$);return t.onReadyBeingFired=[],lJ.resolve(pv(()=>o(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(),cv(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=cC.indexOf(this);if(n>=0&&cC.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new lJ(n=>{e.dbReadyResolve=n}),e.openCanceller=new lJ((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new lb.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new lJ((t,o)=>{let a=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=ce(()=>{!function({indexedDB:e,IDBKeyRange:n},t){p_(e)||t===cD||pb(e,n).delete(t).catch(l$)}(this._deps,this.name),t()}),e.onerror=c5(o),e.onblocked=this._fireOnBlocked};if(e)throw new lb.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 sN(this._allTables).map(e=>this._allTables[e])}transaction(){let e=pA.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let o,a,r=lq.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=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===cz)o=cz;else{if("rw"!=e&&e!=cM)throw new lb.InvalidArgument("Invalid transaction mode: "+e);o=cM}if(r){if(r.mode===cz&&o===cM){if(!i)throw new lb.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&a.forEach(e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!i)throw new lb.SubTransaction("Table "+e+" not included in parent transaction.");r=null}}),i&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,(n,t)=>{t(e)}):cv(e)}let s=(function e(n,t,o,a,r){return lJ.resolve().then(()=>{let i,s=lq.transless||lq,l=n._createTransaction(t,o,n._dbSchema,a);if(a)l.idbtrans=a.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(a){return a.name===ly.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,o,null,r))):cv(a)}let c=la(r);c&&cl();let p=lJ.follow(()=>{if(i=r.call(l,l))if(c){var e=cc.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=p$(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?lJ.resolve(i).then(e=>l.active?e:cv(new lb.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):p.then(()=>i)).then(e=>(a&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),cv(e)))})}).bind(null,this,o,a,r,t);return r?r._promise(o,s,"lock"):lq.trans?cm(lq.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!sF(this._allTables,e))throw new lb.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let pj="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class pR{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[pj](){return this}}function pF(e,n){return sN(n).forEach(t=>{pP(e[t]||(e[t]=new pz),n[t])}),e}try{a={indexedDB:sT.indexedDB||sT.mozIndexedDB||sT.webkitIndexedDB||sT.msIndexedDB,IDBKeyRange:sT.IDBKeyRange||sT.webkitIDBKeyRange}}catch(e){a={indexedDB:null,IDBKeyRange:null}}function pL(e){let n=pW;try{pW=!0,c7.storagemutated.fire(e)}finally{pW=n}}sL(pB,{...lv,delete:e=>new pB(e,{addons:[]}).delete(),exists:e=>new pB(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return p_(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==cD)):pb(e,n).toCollection().primaryKeys()})(pB.dependencies).then(e)}catch(e){return cv(new lb.MissingAPI)}},defineClass:()=>function(e){sB(this,e)},ignoreTransaction:e=>lq.trans?cm(lq.transless,e):e(),vip:pv,async:function(e){return function(){try{var n=p$(e.apply(this,arguments));return n&&"function"==typeof n.then?n:lJ.resolve(n)}catch(e){return cv(e)}}},spawn:function(e,n,t){try{var o=p$(e.apply(t,n||[]));return o&&"function"==typeof o.then?o:lJ.resolve(o)}catch(e){return cv(e)}},currentTransaction:{get:()=>lq.trans||null},waitFor:function(e,n){let t=lJ.resolve("function"==typeof e?pB.ignoreTransaction(e):e).timeout(n||6e4);return lq.trans?lq.trans.waitFor(t):t},Promise:lJ,debug:{get:()=>lr,set:e=>{lr=e,li="dexie"===e?()=>!0:cS}},derive:sG,extend:sB,props:sL,override:sY,Events:cI,on:c7,liveQuery:function(e){let n,t=!1,o=new pR(o=>{let a=la(e),r=!1,i={},s={},l={get closed(){return r},unsubscribe:()=>{r=!0,c7.storagemutated.unsubscribe(d)}};o.start&&o.start(l);let c=!1,p=!1;function u(){return sN(s).some(e=>i[e]&&function(e,n){let t=pO(n),o=t.next();if(o.done)return!1;let a=o.value,r=pO(e),i=r.next(a.from),s=i.value;for(;!o.done&&!i.done;){if(0>=cU(s.from,a.to)&&cU(s.to,a.from)>=0)return!0;0>cU(a.from,s.from)?a=(o=t.next(s.from)).value:s=(i=r.next(a.from)).value}return!1}(i[e],s[e]))}let d=e=>{pF(i,e),u()&&f()},f=()=>{let h,m;if(c||r)return;i={};let g={},y=(a&&cl(),h=()=>cs(e,{subscr:g,trans:null}),m=lq.trans?cm(lq.transless,h):h(),a&&m.then(cc,cc),m);p||(c7(c6,d),p=!0),c=!0,Promise.resolve(y).then(e=>{t=!0,n=e,c=!1,r||(u()?f():(i={},s=g,o.next&&o.next(e)))},e=>{c=!1,t=!1,o.error&&o.error(e),l.unsubscribe()})};return f(),l});return o.hasValue=()=>t,o.getValue=()=>n,o},extendObservabilitySet:pF,getByKeyPath:sQ,setByKeyPath:s0,delByKeyPath:function(e,n){"string"==typeof n?s0(e,n,void 0):"length"in n&&[].map.call(n,function(n){s0(e,n,void 0)})},shallowClone:s1,deepClone:s8,getObjectDiff:px,cmp:cU,asap:sJ,minKey:cw,addons:[],connections:cC,errnames:ly,dependencies:a,semVer:c$,version:c$.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),pB.maxKey=po(pB.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(c7(c6,e=>{if(!pW){let n;cE?(n=document.createEvent("CustomEvent")).initCustomEvent(c8,!0,!0,e):n=new CustomEvent(c8,{detail:e}),pW=!0,dispatchEvent(n),pW=!1}}),addEventListener(c8,({detail:e})=>{pW||pL(e)}));let pW=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(c8);"function"==typeof e.unref&&e.unref(),c7(c6,n=>{pW||e.postMessage(n)}),e.onmessage=e=>{e.data&&pL(e.data)}}else if("u">typeof self&&"u">typeof navigator){c7(c6,e=>{try{pW||("u">typeof localStorage&&localStorage.setItem(c8,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:c8,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===c8){let n=JSON.parse(e.newValue);n&&pL(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===c8&&pL(e.changedParts)})}function pV(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}lJ.rejectionMapper=function(e,n){if(!e||e instanceof lf||e instanceof TypeError||e instanceof SyntaxError||!e.name||!l_[e.name])return e;var t=new l_[e.name](n||e.message,e);return"stack"in e&&sV(t,"stack",{get:function(){return this.inner.stack}}),t},li=cS;class pG extends pB{constructor(){super("EsmOffline"),pV(this,"syncQueue",void 0),pV(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 pU(){return new pG}let pH=new pG,pq={},pK=U("offline-synchronization",{});function pY(){return pK}async function pZ(){if(pK.getState().synchronization)return;let e=await pH.syncQueue.count(),n={},t=Object.entries(pq),o=t.length,a={},r=new AbortController,i=()=>{let e=pK.getState().synchronization;pK.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{pK.setState({synchronization:{totalCount:e,pendingCount:e,abortController:r}});for(let e=0;e<o&&t.length>0;e++)for(let e=t.length;e--;){let[o,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(a[o]={},await Promise.all(l),n[o]=pJ(s,a,r,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{pK.setState({synchronization:void 0})}}async function pJ({type:e,dependsOn:n,process:t},o,a,r){let i=[],s=[],l=await pX();await pH.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[p,u,{id:d,dependencies:f=[]}]=i[c];try{let r=await t(u,{abort:a,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?o[t][e]:void 0)});void 0!==d&&(o[e][d]=r),await pH.syncQueue.delete(p)}catch(e){await pH.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{r()}}}async function pX(){let e=await rP();return e?.uuid||"*"}async function pQ(e,n,t,o){let a=o&&o.id;return void 0!==a&&await pH.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===a).delete().catch(pB.errnames.DatabaseClosed),await pH.syncQueue.add({type:n,content:t,userId:e,descriptor:o||{},createdOn:new Date}).catch(pB.errnames.DatabaseClosed,()=>-1)}async function p0(e,n,t){let o=await pX();return await pQ(o,e,n,t)}async function p1(e,n){return(await p2(e,n)).map(e=>e.content)}async function p2(e,n){return await pH.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(pB.errnames.DatabaseClosed,()=>[])}async function p3(e){let n=await pX();return await p1(n,e)}async function p5(e){let n=await pX();return await p2(n,e)}async function p4(e){return await pH.syncQueue.get(e).catch(pB.errnames.DatabaseClosed,()=>void 0)}function p6(e){return!!pq[e]?.options.onBeginEditSyncItem}async function p8(e){let n=await p4(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=pq[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 p7(e){await pH.syncQueue.delete(e).catch(pB.errnames.DatabaseClosed)}function p9(e,n,t,o={}){pq[e]={type:e,dependsOn:n,process:t,options:o}}let ue="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),un=new Uint8Array(16),ut=[];for(let e=0;e<256;++e)ut.push((e+256).toString(16).slice(1));let uo=function(e,n,t){if(ue&&!n&&!e)return ue();let o=(e=e||{}).random||(e.rng||function(){if(!r&&!(r="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 r(un)})();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=o[e];return n}return function(e,n=0){return ut[e[n+0]]+ut[e[n+1]]+ut[e[n+2]]+ut[e[n+3]]+"-"+ut[e[n+4]]+ut[e[n+5]]+"-"+ut[e[n+6]]+ut[e[n+7]]+"-"+ut[e[n+8]]+ut[e[n+9]]+"-"+ut[e[n+10]]+ut[e[n+11]]+ut[e[n+12]]+ut[e[n+13]]+ut[e[n+14]]+ut[e[n+15]]}(o)},ua="OFFLINE+";function ur(){return ua+uo()}function ui(e){return e.startsWith(ua)}let us={};function ul(){return Object.values(us)}function uc(e){us[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.`),us[e.id]=e}async function up(e){let n=await ub();return await uu(n,e)}async function uu(e,n){let t=new pG;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(pB.errnames.DatabaseClosed,()=>[])}async function ud(e,n){let t=await ub();return await uf(t,e,n)}async function uf(e,n,t){let o=new pG,a=await o.dynamicOfflineData.get({type:n,identifier:t}).catch(pB.errnames.DatabaseClosed,()=>void 0);a?a.users.includes(e)||await o.dynamicOfflineData.update(a.id,{users:[...a.users,e]}).catch(pB.errnames.DatabaseClosed):await o.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(pB.errnames.DatabaseClosed)}async function uh(e,n){let t=await ub();return await um(t,e,n)}async function um(e,n,t){let o=new pG,a=await o.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(pB.errnames.DatabaseClosed,()=>void 0);a&&(a.users.length>1?await o.dynamicOfflineData.update(a.id,{users:a.users.filter(n=>n!==e)}).catch(pB.errnames.DatabaseClosed):await o.dynamicOfflineData.delete(a.id).catch(pB.errnames.DatabaseClosed))}async function ug(e,n){let t=await up(e);await Promise.all(t.map(async e=>uy(e.type,e.identifier,n)))}async function uy(e,n,t){await ud(e,n);let o=new pG,a=await ub(),r=await o.dynamicOfflineData.get({type:e,identifier:n}).catch(pB.errnames.DatabaseClosed,()=>void 0),i=ul().filter(n=>n.type===e);if(!r)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),p=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),u={syncedOn:new Date,syncedBy:a,succeededHandlers:l,erroredHandlers:c,errors:p};r.id&&await o.dynamicOfflineData.update(r.id,{syncState:u}).catch(pB.errnames.DatabaseClosed)}async function ub(){let e=(await rP()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let u_=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function uv(){return uw(),u_}function u$(e,n){uw(),uc({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 uA(e){uw(),await uy("patient",e)}function uw(){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 uk(e,n,t=!0){if(e){let o=null,[a,r]=await Promise.all([r$(`${rb}/Patient/${e}`,n).catch(e=>o=e),t?ux(e):Promise.resolve(null)]);if(a.ok)return a.data;if(r)return r;if(o)throw o}return null}async function ux(e){let n=(await p3("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function uC(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function uE(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 uS=t(9549);function uD(e){return{uuid:e.uuid,display:e.display}}function uz(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let o=t.toString();return rA(`${ry}/location${o?"?"+o:""}`).pipe((0,uS.map)(e=>e.data.results.map(uD))).pipe((0,uS.take)(1))}function uM(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uP(){return rA(`${ry}/visittype`).pipe((0,uS.map)(e=>e.data.results.map(uM))).pipe((0,uS.take)(1))}var uO=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),uT=function(e){function n(n,t){var o=e.call(this)||this;return o.subject=n,o.subscriber=t,o.closed=!1,o}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}(eb),uN=function(e){function n(n){var t=e.call(this,n)||this;return t.destination=n,t}return ep(n,e),n}(e$),uI=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[ev]=function(){return new uN(this)},n.prototype.lift=function(e){var n=new uB(this,this);return n.operator=e,n},n.prototype.next=function(e){if(this.closed)throw new uO;if(!this.isStopped)for(var n=this.observers,t=n.length,o=n.slice(),a=0;a<t;a++)o[a].next(e)},n.prototype.error=function(e){if(this.closed)throw new uO;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var n=this.observers,t=n.length,o=n.slice(),a=0;a<t;a++)o[a].error(e);this.observers.length=0},n.prototype.complete=function(){if(this.closed)throw new uO;this.isStopped=!0;for(var e=this.observers,n=e.length,t=e.slice(),o=0;o<n;o++)t[o].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 uO},n.prototype._subscribe=function(e){if(this.closed)throw new uO;return this.hasError?(e.error(this.thrownError),eb.EMPTY):this.isStopped?(e.complete(),eb.EMPTY):(this.observers.push(e),new uT(this,e))},n.prototype.asObservable=function(){var e=new ek;return e.source=this,e},n.create=function(e,n){return new uB(e,n)},n}(ek),uB=function(e){function n(n,t){var o=e.call(this)||this;return o.destination=n,o.source=t,o}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):eb.EMPTY},n}(uI),uj=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 uO},n.prototype.next=function(n){e.prototype.next.call(this,this._value=n)},n}(uI),uR=((ea={}).NEWVISIT="startVisit",ea.EDITVISIT="editVisit",ea.LOADING="loadingVisit",ea),uF=((er={}).NOTSTARTED="notStarted",er.ONGOING="ongoing",er);let uL="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))",uW=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function uV(){return q("visit",uW)}function uG(e,n){uV().setState({patientUuid:e,manuallySetVisitUuid:n})}function uU(e,n){return r$(`${ry}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function uH(e,n,t){return r$(`${ry}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function uq(e,n,t){return r$(`${ry}/visit?patient=${e}&v=${t??uL}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}uV().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let uK=new uj(null);class uY{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+uY.version}static addUnaryOp(e){return uY.max_unop_len=Math.max(e.length,uY.max_unop_len),uY.unary_ops[e]=1,uY}static addBinaryOp(e,n,t){return uY.max_binop_len=Math.max(e.length,uY.max_binop_len),uY.binary_ops[e]=n,t?uY.right_associative.add(e):uY.right_associative.delete(e),uY}static addIdentifierChar(e){return uY.additional_identifier_chars.add(e),uY}static addLiteral(e,n){return uY.literals[e]=n,uY}static removeUnaryOp(e){return delete uY.unary_ops[e],e.length===uY.max_unop_len&&(uY.max_unop_len=uY.getMaxKeyLen(uY.unary_ops)),uY}static removeAllUnaryOps(){return uY.unary_ops={},uY.max_unop_len=0,uY}static removeIdentifierChar(e){return uY.additional_identifier_chars.delete(e),uY}static removeBinaryOp(e){return delete uY.binary_ops[e],e.length===uY.max_binop_len&&(uY.max_binop_len=uY.getMaxKeyLen(uY.binary_ops)),uY.right_associative.delete(e),uY}static removeAllBinaryOps(){return uY.binary_ops={},uY.max_binop_len=0,uY}static removeLiteral(e){return delete uY.literals[e],uY}static removeAllLiterals(){return uY.literals={},uY}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 uY(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 uY.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!uY.binary_ops[String.fromCharCode(e)]||uY.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return uY.isIdentifierStart(e)||uY.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(uY.hooks[e]){let t={context:this,node:n};return uY.hooks.run(e,t),t.node}return n}searchHook(e){if(uY.hooks[e]){let n={context:this};return uY.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===uY.SPACE_CODE||e===uY.TAB_CODE||e===uY.LF_CODE||e===uY.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:uY.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,o;for(;this.index<this.expr.length;)if((t=this.code)===uY.SEMCOL_CODE||t===uY.COMMA_CODE)this.index++;else if(o=this.gobbleExpression())n.push(o);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,uY.max_binop_len),n=e.length;for(;n>0;){if(uY.binary_ops.hasOwnProperty(e)&&(!uY.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!uY.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,o,a,r,i,s,l;if(!(r=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return r;for(a={value:n,prec:uY.binaryPrecedence(n),right_a:uY.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),o=[r,a,i];n=this.gobbleBinaryOp();){if(0===(t=uY.binaryPrecedence(n))){this.index-=n.length;break}a={value:n,prec:t,right_a:uY.right_associative.has(n)},l=n;let s=e=>a.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;o.length>2&&s(o[o.length-2]);)i=o.pop(),n=o.pop().value,r=o.pop(),e={type:uY.BINARY_EXP,operator:n,left:r,right:i},o.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),o.push(a,e)}for(s=o.length-1,e=o[s];s>1;)e={type:uY.BINARY_EXP,operator:o[s-1].value,left:o[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,o;if(this.gobbleSpaces(),o=this.searchHook("gobble-token"))return this.runHook("after-token",o);if(e=this.code,uY.isDecimalDigit(e)||e===uY.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===uY.SQUOTE_CODE||e===uY.DQUOTE_CODE)o=this.gobbleStringLiteral();else if(e===uY.OBRACK_CODE)o=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,uY.max_unop_len)).length;t>0;){if(uY.unary_ops.hasOwnProperty(n)&&(!uY.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!uY.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:uY.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}uY.isIdentifierStart(e)?(o=this.gobbleIdentifier(),uY.literals.hasOwnProperty(o.name)?o={type:uY.LITERAL,value:uY.literals[o.name],raw:o.name}:o.name===uY.this_str&&(o={type:uY.THIS_EXP})):e===uY.OPAREN_CODE&&(o=this.gobbleGroup())}return o?(o=this.gobbleTokenProperty(o),this.runHook("after-token",o)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===uY.PERIOD_CODE||n===uY.OBRACK_CODE||n===uY.OPAREN_CODE||n===uY.QUMARK_CODE;){let t;if(n===uY.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==uY.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===uY.OBRACK_CODE?((e={type:uY.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==uY.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===uY.OPAREN_CODE?e={type:uY.CALL_EXP,arguments:this.gobbleArguments(uY.CPAREN_CODE),callee:e}:(n===uY.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:uY.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(;uY.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===uY.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);uY.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++));uY.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);uY.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,uY.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===uY.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===uY.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:uY.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),o=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){o=!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 o||this.throwError('Unclosed quote after "'+e+'"'),{type:uY.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(uY.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,uY.isIdentifierPart(e))this.index++;else break;return{type:uY.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){t=!0,this.index++,e===uY.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===uY.COMMA_CODE){if(this.index++,++o!==n.length){if(e===uY.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===uY.CBRACK_CODE)for(let e=n.length;e<o;e++)n.push(null)}}else if(n.length!==o&&0!==o)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==uY.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(uY.CPAREN_CODE);if(this.code===uY.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:uY.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:uY.ARRAY_EXP,elements:this.gobbleArguments(uY.CBRACK_CODE)}}}Object.assign(uY,{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)})}}(uY),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"}),uY.max_unop_len=uY.getMaxKeyLen(uY.unary_ops),uY.max_binop_len=uY.getMaxKeyLen(uY.binary_ops);let uZ=e=>new uY(e).parse(),uJ=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(uY).filter(e=>!uJ.includes(e)&&void 0===uZ[e]).forEach(e=>{uZ[e]=uY[e]}),uZ.Jsep=uY,uZ.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,o=this.gobbleExpression();if(o||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:o,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let uX="ArrowFunctionExpression",uQ={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)}},u0={...uQ,Promise};function u1(e,n={}){return u8(e,n,de)}async function u2(e,n={}){return u7(e,n,de)}function u3(e,n={}){return u8(e,n,dn)}function u5(e,n={}){return u7(e,n,dn)}function u4(e,n={}){return u8(e,n,dt)}function u6(e,n={}){return u7(e,n,dt)}function u8(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 o=di(n,uQ),a=da("string"==typeof e?uZ(e):e,o);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 u7(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 o=di(n,u0);return Promise.resolve(da("string"==typeof e?uZ(e):e,o)).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 u9(e){return uZ(e)}function de(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dn(e){return"boolean"==typeof e}function dt(e){return"number"==typeof e}function da(e,n){switch(e.type){case"UnaryExpression":var t,o,a,r,i,s,l,c,p,u,d,f,h=e,m=n;let g=da(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=da(y.left,b),$=da(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,o=n,da(t.test,o)?da(t.consequent,o):da(t.alternate,o);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(ds(w)),x=da(A.callee,w);if(x){if("function"!=typeof x)throw`${dc(A.callee)} is not a function`}else throw`No function named ${dc(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return a=e,r=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,o)=>{let a=e[o];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 da(a.body,r.addVariables(n))}).bind(r.thisObj??null);case"MemberExpression":return function(e,n){let t,o=da(e.object,n);if(void 0===o)switch(e.object.type){case"Identifier":{let t=dr(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=dr(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=o;if("string"==typeof o)a=String.prototype;else if("number"==typeof o)a=Number.prototype;else if("function"==typeof o);else if("object"!=typeof o)throw`VisitMemberExpression does not support member access on type ${typeof o}`;switch(n.thisObj=a,e.property.type){case"Identifier":case"MemberExpression":t=da(e.property,n);break;default:{let a=da(e.property,n);if(void 0===a)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dl(a),t=o[a]}}return"function"==typeof t?t.bind(o):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(ds(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(ds(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(ds(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 dl((p=e).value),p.value;case"Identifier":var z=e,M=n;dl(z.name);let P=M.thisObj;if(P&&("object"==typeof P||"function"==typeof P)&&z.name in P){let e=P[z.name];return dl(e),e}if(M.variables&&z.name in M.variables){let e=M.variables[z.name];return dl(e),e}return z.name in M.globals?M.globals[z.name]:void 0;case"TemplateLiteral":let O,T;return u=e,d=n,O=u.expressions?.map(ds(d))??[],(T=u.quasis?.map(ds(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 dr(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return dr(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function di(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 ds(e){return function(n){return null===n?null:da(n,e)}}function dl(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dc(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function dp(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:{...u0},isLocalExpression:!1,variables:new Set};return du("string"==typeof e?uZ(e):e,n),[...n.variables]}function du(e,n){switch(e.type){case"UnaryExpression":return o=e,a=n,du(o.argument,a);case"BinaryExpression":return r=e,i=n,[du(r.left,i),du(r.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[du(s.consequent,l),du(s.test,l),du(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,p=n,t=du(c.callee,p),c.arguments?.map(dd(p)),t;case"ArrowFunctionExpression":var o,a,r,i,s,l,c,p,u,d,f,h,m,g,y,b,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(dd(k))??[],C=du(A.body,k)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||w.variables.add(e);return;case"MemberExpression":let E;return u=e,d=n,du(u.object,d),void((E={...d}).isLocalExpression=!0,du(u.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(dd(h));case"SequenceExpression":return m=e,g=n,void m.expressions?.map(dd(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(dd(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(dd($)),v.quasis?.map(dd($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dd(e){return function(n){return null===n?null:du(n,e)}}uZ.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:uX,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=uX,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)})}}),uZ.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 o=n.node;for(;o.type===e.MEMBER_EXP||o.type===e.CALL_EXP&&o.callee.type===e.MEMBER_EXP;)o=o.type===e.MEMBER_EXP?o.object:o.callee.object;o.type="NewExpression"}})}}),uZ.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,o="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:o+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(o+=this.expr.charAt(this.index++),a());let r=this.char;("e"===r||"E"===r)&&(o+=this.expr.charAt(this.index++),("+"===(r=this.char)||"-"===r)&&(o+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+o+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+o+this.char+")");else if(i===e.PERIOD_CODE){o.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:o},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(o),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(o){if(48===this.code){var a,r,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let p="";for(;a=this.code,r=c,95===a||r.some(([e,n])=>a>=e&&a<=n);)95===this.code?this.index++:p+=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,o);return}this.throwError("unexpected char within number")}o.node={type:e.LITERAL,value:parseInt(p,"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,o)})}}),uZ.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,o=!1;for(;this.index<this.expr.length;){if(47===this.code&&!o){let o,a=this.expr.slice(t,this.index),r="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)r+=this.char;else break}try{o=new RegExp(a,r)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:o,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?o=!0:o&&this.code===e.CBRACK_CODE&&(o=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),uZ.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,o=this.gobbleExpression();if(o||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:o,alternate:a},t.operator&&e.binary_ops[t.operator]<=.9){let o=t;for(;o.right.operator&&e.binary_ops[o.right.operator]<=.9;)o=o.right;n.node.test=o.right,o.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),uZ.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},o="",a="",r=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:a,cooked:o},tail:r});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,r=!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="",o="",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":o+="\n";break;case"r":o+="\r";break;case"t":o+=" ";break;case"b":o+="\b";break;case"f":o+="\f";break;case"v":o+="\v";break;default:o+=i}else o+=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})}}),uZ.addBinaryOp("in",7),uZ.addBinaryOp("??",1);let df=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:",""),o=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...o}}return e}()});function dh(e,n,t){df.setState(o=>({flags:{...o.flags,[e]:{enabled:o.flags[e]?.enabled??!1,label:n,description:t}}}))}function dm(){let e=df.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 dg(e){return df.getState().flags[e].enabled}function dy(e,n){df.subscribe(t=>{n(t.flags[e].enabled)})}function db(e,n){df.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function d_(e){return!window.offlineEnabled||(e??navigator.onLine)}df.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 dv=nM(function(e,n,t){nw(e,n,t)});function d$(e=!0,n=!1){return dA(d_(),e,n)}function dA(e,n=!0,t=!1){return!!(e?n:t)}let dw=U("extensionsInternal",{slots:{},extensions:{}}),dk=()=>q("extensionsInternal",{slots:{},extensions:{}});function dx(e){let n=dw.getState(),t=e(n);t!==n&&dw.setState(t)}let dC=()=>q("extensions",{slots:{}});function dE(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});n6(t1.getState().mountedExtensions,n)||t1.setState({mountedExtensions:n})}dE(dw.getState()),dw.subscribe(dE);let dS=dk(),dD=dC(),dz=t3(),dM=t6();function dP(e,n,t,o,a){let r={},i=d_(),s=Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[o,l]of Object.entries(e.slots)){let{config:c}=t4(n,l.name),p=dV(o,e,c,t,s,i,a.session);r[o]={moduleName:l.moduleName,assignedExtensions:p}}n6(dD.getState().slots,r)||dD.setState({slots:r})}function dO(){dP(dS.getState(),dz.getState(),dM.getState(),df.getState(),rk.getState())}function dT(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function dN(e){let[n]=e.split("#");return n}function dI(e,n){let t=dN(n);return e.extensions[t]}function dB(e){return dI(dS.getState(),e)}dS.subscribe(e=>{dP(e,dz.getState(),dM.getState(),df.getState(),rk.getState())}),dz.subscribe(e=>{dP(dS.getState(),e,dM.getState(),df.getState(),rk.getState())}),dM.subscribe(e=>{dP(dS.getState(),dz.getState(),e,df.getState(),rk.getState())}),df.subscribe(e=>{dP(dS.getState(),dz.getState(),dM.getState(),e,rk.getState())}),rk.subscribe(e=>{dP(dS.getState(),dz.getState(),dM.getState(),df.getState(),e)}),dO(),y(dO);let dj=e=>dS.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function dR(e,n){dx(t=>{let o=t.slots[e];return o?{...t,slots:{...t.slots,[e]:{...o,attachedIds:[...o.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...dT(e),attachedIds:[n]}}}})}function dF(e,n){dx(t=>{let o=t.slots[e];return o&&o.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...o,attachedIds:o.attachedIds.filter(e=>e!==n)}}}:t})}function dL(e){dx(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function dW(e,n,t,o){let a=n.indexOf(e);if(-1!==a)return a;{if(void 0!==t)return 1e3+t;let n=o.indexOf(e);return -1!==n?2e3+n:-1}}function dV(e,n,t,o,a,r,i){let s=function(e,n){let t=e.add||[],o=e.remove||[],a=e.order||[],{extensions:r}=dS.getState();return[...n,...t].filter(e=>!o.includes(e)).sort((e,t)=>{let o=dW(e,a,r[dN(e)]?.order,n),i=dW(t,a,r[dN(t)]?.order,n);return -1===i?-1:-1===o?1:o-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,p=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=t7(o,e,c),u=dv(s,t9(t,e,c)),d=dN(c),f=n.extensions[d];if(f){let n=u?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!rM(n,i.user)))continue;let t=u?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!u3(t,p))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&&!dA(r,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:u,featureFlag:f.featureFlag,meta:f.meta,online:u?.["Display conditions"]?.online??f.online??!0,offline:u?.["Display conditions"]?.offline??f.offline??!1})}}return l}function dG(e){let n=dS.getState(),{config:t}=t5(e),o=dM.getState(),a=df.getState(),r=rk.getState(),i=d_();return dV(e,n,t,o,Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,r.session)}let dU=(e,n,t)=>dS.setState(o=>{let a=o.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}.`),o;if(a&&a==e)return o;if(o.slots[n])return{...o,slots:{...o.slots,[n]:{...o.slots[n],moduleName:e,state:t}}};let r=dT(n,e,t);return{...o,slots:{...o.slots,[n]:{...r}}}});function dH(e,n,t=!1){dS.setState(o=>{let a=t?dv(o.slots[e].state,n):n;return{...o,slots:{...o.slots,[e]:{...o.slots[e],state:a}}}})}let dq=()=>dD.setState(()=>({slots:{},extensions:{}})),dK=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function dY({name:e,basePath:n,mode:t,componentContext:o,state:a}){dK.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:o,state:a})}function dZ(e){dK.getState().slotName===e&&dK.setState(dK.getInitialState(),!0)}let dJ=U("modalRegistry",{modals:{}});function dX(e){dJ.setState(n=>(n.modals[e.name]=e,n))}function dQ(e){let n=dJ.getState().modals[e];if(!n){let t=dB(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.`),dX(n))}return n}let d0=U("workspaceRegistrations",{workspaces:{}}),d1=U("workspaceGroups",{workspaceGroups:{}});function d2(e){d0.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 d3(e){d1.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 d5=new Set;function d4(e){let n=d0.getState().workspaces;if(n[e])return n[e];{let n=dB(e);if(n){var t;let o;return d5.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.`),d5.add(e)),{name:n.name,title:(t=n,"string"==typeof(o=t?.meta?.title)?o:o&&"object"==typeof o?iA(t.moduleName,o.key,o.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 d6(e){let n=d1.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let d8=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function d7(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=d8.getState(),o=n[e];if(o){let n=t[o.window];if(n)return n;throw Error(`No workspace window found with name: ${o.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function d9(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=d8.getState(),o=t[e];if(o){let t=n[o.group];if(t)return t;throw Error(`No workspace group found with name: ${o.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fe(e){let{openedWindows:n}=d8.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function fn(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=d8.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);o[t.name]={...t,moduleName:e}}d8.setState({registeredGroupsByName:o})}function ft(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=d8.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}d8.setState({registeredWindowsByName:o})}function fo(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=d8.getState(),o={...t};for(let t of n){if(o[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};o[t.name]=n}d8.setState({registeredWorkspacesByName:o})}let fa=0;async function fr(e,n,t,o,a=e=>e,r={}){let i=dN(o),s=dB(o),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:p,online:u,offline:d,load:f}=s;if(d$(u,d)){dx(a=>({...a,extensions:{...a.extensions,[i]:{...a.extensions[i],instances:[...a.extensions[i].instances,{domElement:e,id:o,slotName:n,slotModuleName:t}]}}}));let s=await f(),u=fa++;l=a_(a({...s,name:`${n}/${i}-${u}`}),{...r,_meta:c,_extensionContext:{extensionId:o,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${o} into ${n} but no DOM element was available.`);return l}var fi=t(7125),fs=t.n(fi);let fl=(0,fi.createContext)({moduleName:"",featureName:""});function fc({to:e,templateParams:n,onBeforeNavigate:t,children:o,...a}){return(0,fi.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}`)},[]),fs().createElement("a",{onClick:o=>{0===o.button&&!o.ctrlKey&&!o.shiftKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),t?.(o),rs({to:e,templateParams:n})),0===o.button&&(o.ctrlKey||o.metaKey)&&t?.(o),0===o.button&&o.shiftKey&&t?.(o),1===o.button&&t?.(o)},href:rr(e,n),...a},o)}let fp=({state:e,children:n,...t})=>{let{extension:o}=(0,fi.useContext)(fl),a=(0,fi.useRef)(null),r=(0,fi.useRef)(Promise.resolve()),i=(0,fi.useCallback)(n=>{o?.extensionSlotName&&o.extensionSlotModuleName&&o.extensionSlotModuleName&&!a.current&&fr(n,o.extensionSlotName,o.extensionSlotModuleName,o.extensionId,void 0,e).then(e=>{a.current=e})},[]);return(0,fi.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":r.current&&r.current.then(()=>{a.current?.getStatus()==="MOUNTED"&&a.current.unmount()})}},[]),(0,fi.useEffect)(()=>{a.current&&a.current.update&&"UNMOUNTING"!==a.current.getStatus()&&Promise.all([a.current.mountPromise,r.current]).then(()=>{a?.current?.getStatus()==="MOUNTED"&&a.current.update&&(r.current=a.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||a.current?.getStatus()==="MOUNTED")throw e}))})},[e]),o?fs().createElement("div",{ref:i,"data-extension-id":o?.extensionId,style:{position:"relative"},...t}):null};function fu(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[o,a]of Object.entries(n)){let n=function(...n){e.setState(e=>a(e,...n))};t[o]=n}return t}let fd=()=>e=>e;function ff(e,n=fd(),t){let o=(0,fi.useCallback)(n=>e.subscribe(n),[e]),a=(0,fi.useCallback)(()=>n(e.getState()),[e,n]),r=(0,fi.useSyncExternalStore)(o,a,a),i=(0,fi.useMemo)(()=>t?fu(e,t):{},[e,t]);return{...r,...i}}function fh(e,n){return ff(e,fd(),n)}function fm(e){return function(n){let t=(0,fi.useCallback)(n=>e.subscribe(n),[]),o=(0,fi.useCallback)(()=>e.getState(),[]),a=(0,fi.useSyncExternalStore)(t,o,o),r=(0,fi.useMemo)(()=>n?fu(e,n):{},[n]);return{...a,...r}}}let fg=e=>ff(dC(),n=>n.slots?.[e]);function fy(e){let n=fg(e);return n?.assignedExtensions??[]}function fb(e,n){let{moduleName:t}=(0,fi.useContext)(fl),o=(0,fi.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,fi.useEffect)(()=>{dU(t,e,n),o.current=!1},[]),(0,fi.useEffect)(()=>{o.current||dH(e,n)},[e,n]),{extensions:fy(e),extensionSlotName:e,extensionSlotModuleName:t}}function f_(e){return e}function fv({name:e,extensionSlotName:n,select:t=f_,children:o,state:a,style:r,...i}){if(o&&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,fi.useRef)(null),{extensions:c,extensionSlotModuleName:p}=fb(s,a),u=(0,fi.useMemo)(()=>t(c),[t,c]),d=(0,fi.useMemo)(()=>{if("function"==typeof o&&!fs().isValidElement(o))return u.map(e=>o(e,a))},[o,u]);return fs().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...r,position:"relative"},...i},s&&u?.map((e,n)=>fs().createElement(fl.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},d?.[n]??("function"!=typeof o?o:null)??fs().createElement(fp,{state:a}))))}var f$=t(5873);function fA(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,o)}return t}function fw(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?fA(Object(t),!0).forEach(function(n){var o,a,r;o=e,a=n,r=t[n],a in o?Object.defineProperty(o,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[a]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):fA(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function fk(e){return(fk="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 fx(e){return(fx="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 fC(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(fx(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(fx(e)));return e}}var fE=null;try{fE=require("react").createContext()}catch(e){}var fS={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 fD(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function fz(e,n){return new Promise(function(t,o){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,r=fT(e,n,function(){t(this)}),i=fC(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,o=e.elementToRender,a=e.domElement,r=n[t];if("function"!=typeof r)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=r(a);return i.render(o),i;case"hydrateRoot":return r(a,o);default:return r(o,a),null}}({elementToRender:r,domElement:i,reactDom:fO(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function fM(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var o=e.renderResults[n.name];o&&o.unmount?o.unmount():fO(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function fP(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var o=fT(e,n,null),a=e.renderResults[n.name];if(a&&a.render)a.render(o);else{var r=fC(e,n)();fO(e).render(o,r)}})}function fO(e){return e.ReactDOMClient||e.ReactDOM}function fT(e,n,t){var o=e.React.createElement(e.rootComponent,n),a=fE?e.React.createElement(fE.Provider,{value:n},o):o;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,fw(fw({},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 fN=t(5921),fI=t(1123),fB=t(9106);let fj={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fR=new Map;(0,fB.initCache)(fR);let fF={errorRetryCount:3,fetcher:r$,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof rw){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>fR};function fL(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},fj,e),t={...fF,...n.swrConfig};return function(e){var o,a,r,i,s;return r=a=class extends(o=fs().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 fs().createElement("div",null,"An error has occurred. Please try reloading the page.");{let o=fs().createElement(fi.Suspense,{fallback:null},fs().createElement(fI.BE,{value:t},fs().createElement(fl.Provider,{value:this.state.config},n.disableTranslations?fs().createElement(e,this.props):fs().createElement(fN.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},fs().createElement(e,this.props)))));return n.strictMode&&fs().StrictMode?fs().createElement(fs().StrictMode,null,o):o}}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 r?Object.defineProperty(r,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[i]=s,a}}function fW(e,n){return function(e){if("object"!==fk(e))throw Error("single-spa-react requires a configuration object");var n,t=fw(fw({},fS),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");!fE&&t.React.createContext&&(fE=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 o={bootstrap:fD.bind(null,t),mount:fz.bind(null,t),unmount:fM.bind(null,t)};return t.parcelCanUpdate&&(o.update=fP.bind(null,t)),o}({React:fs(),ReactDOMClient:f$,rootComponent:fL(n)(e)})}function fV(e,n){return()=>e().then(({default:e})=>fW(e,n))}function fG(e,n){return()=>Promise.resolve(fW(e,n))}let fU=fV,fH=W()(()=>({}));H("openmrs-app-context",fH);let fq={};function fK(e,n=e=>e){let t=fH.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function fY(e,n){fH.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function fZ(e){return null===e?null:Object.freeze(Object.assign({},e))}let fJ=new Map;function fX(e,n){let t=(0,fi.useRef)(n??{}),o=(0,fi.useRef)(n=>fY(e,n)),a=(0,fi.useRef)(Symbol());return(0,fi.useEffect)(()=>{let t=n??{},o=a.current;return null===fK(e)?!function(e,n=fq){fH.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===fq?{}: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.`),fY(e,()=>t)),fJ.set(e,o),()=>{fJ.get(e)===o&&(fH.setState(n=>(e in n&&delete n[e],n)),fJ.delete(e))}},[e]),(0,fi.useEffect)(()=>{let o=n??{};j(t.current,o)||(fY(e,()=>o),t.current=o)},[n]),o.current}function fQ({namespace:e,value:n}){return fX(e,n),null}let f0=({children:e,value:n,fallback:t})=>n?fs().createElement(fs().Fragment,null,e):t?fs().createElement(fs().Fragment,null,t):null;function f1(){let e=(0,fi.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,fi.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function f2(e,n=e=>e??{}){let[t,o]=(0,fi.useState)(()=>{if(f3(e))return;let t=fK(e);if(null!==t)return n?n(t):t});return(0,fi.useEffect)(()=>{if(f3(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,fi.useEffect)(()=>{var t;let a;return(t=e=>{if(null==e)return void o(void 0);let t=n?n(e):e;o(e=>j(e,t)?e:t)})(fZ(a=fK(e))),fH.subscribe(n=>{let o=e in n?n[e]:null;o!==a&&(a=o,t(fZ(o)))})},[e,n]),t}function f3(e){return"string"!=typeof e||0===e.trim().length}function f5(e){let[n,t]=(0,fi.useState)([]);return(0,fi.useEffect)(()=>dC().subscribe(o=>{let a=o.slots[e]?.assignedExtensions.map(e=>e.id)??[];n6(a,n)||t(a)}),[]),n}function f4(e,n){let{data:t,error:o,mutate:a,isLoading:r,isValidating:i}=(0,fI.Ay)(`${so}?patient=${e}&includeEncounterless=${n}`,r$);return(0,fi.useMemo)(()=>({isLoading:r,data:t?.data.results??[],error:o,mutate:a,isValidating:i}),[t,o,r,i,a])}function f6(e){(0,fi.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let f8={},f7=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".