@openmrs/esm-stock-management-app 3.2.2-pre.1680 → 3.2.2-pre.1683
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/4716.js
CHANGED
|
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
|
|
|
12
12
|
${n}`)}return a}let tI=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let a=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(a&&tN(e)){if(o._type===nV.Array&&Array.isArray(a)){let o=a.map(n=>tI(e,n));t[n]=o}else if(o._type===nV.Object)for(let n of Object.keys(a))a[n]=tI(e,a[n])}}else if(tj(o)){let e=a??{};tj(e)&&(t[n]=tI(o,e))}}return t};function tN(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tj(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let tR=new Set;function tF(e,n){let t=`${e}:::${n}`;tR||(tR=new Set),tR.has(t)||(console.error(n),tR.add(t))}function tL(e){e?tR.forEach(n=>{n.startsWith(e)&&tR.delete(n)}):tR.clear()}function tW(){tu.forEach(e=>e()),tu.length=0,tm.clear(),tx.clear(),tE.clear(),tC.clear(),td()}let tG={"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:nV.Object,_default:{},_validators:[nU(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(", ")}.`})]}},tV={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nV.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nV.String,_default:void 0}},...tG},tU=(e,n)=>nU(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tq=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nU(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,a=t.exec(e);for(;a;){if(!n.includes(a[1]))return!1;a=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tH=tq([]),tK=e=>nU(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),tY={inRange:tU,isUrl:tH,isUrlWithTemplateParameters:tq,oneOf:tK};var tJ=t(48067);let tZ=U("breadcrumbs",[]);function tX(e){return tQ([e])}function tQ(e){let n=[...t0(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tJ.pathToRegexp)(e.matcher).regexp:(0,tJ.pathToRegexp)(e.path).regexp,settings:e}))];tZ.setState(n,!0)}function t0(){return tZ.getState()}function t1(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=t1(e,t.join("/"));if(n)return n}}(e,n)}function t2(e,n){if(e.length>0){let t=t1(e,n);if(t){let n=[t],a=t1(e,t.settings.parent);for(;void 0!==a;)n.push(a),a=t1(e,a.settings.parent);return n.reverse()}}return[]}function t3(e){return t2(t0(),e)}var t5=Object.freeze({__proto__:null,get start(){return ob},get ensureJQuerySupport(){return a3},get setBootstrapMaxTime(){return aj},get setMountMaxTime(){return aR},get setUnmountMaxTime(){return aF},get setUnloadMaxTime(){return aL},get registerApplication(){return oo},get unregisterApplication(){return oi},get getMountedApps(){return oe},get getAppStatus(){return ot},get unloadApplication(){return os},get checkActivityFunctions(){return or},get getAppNames(){return on},get pathToActiveWhen(){return ou},get navigateToUrl(){return aK},get patchHistoryApi(){return a0},get triggerAppChange(){return om},get addErrorHandler(){return t9},get removeErrorHandler(){return ae},get mountRootParcel(){return aP},get NOT_LOADED(){return aa},get LOADING_SOURCE_CODE(){return ao},get NOT_BOOTSTRAPPED(){return ar},get BOOTSTRAPPING(){return ai},get NOT_MOUNTED(){return as},get MOUNTING(){return al},get UPDATING(){return au},get LOAD_ERROR(){return af},get MOUNTED(){return ac},get UNLOADING(){return ad},get UNMOUNTING(){return ap},get SKIP_BECAUSE_BROKEN(){return am}}),t4=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,t6=!function(){try{var e=new t4("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}:t4;let t8=[];function t7(e,n,t){let a=at(e,n,t);t8.length?t8.forEach(e=>e(a)):setTimeout(()=>{throw a})}function t9(e){if("function"!=typeof e)throw Error(an(28,!1));t8.push(e)}function ae(e){if("function"!=typeof e)throw Error(an(29,!1));let n=!1;return t8=t8.filter(t=>{let a=t===e;return n=n||a,!a}),n}function an(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 at(e,n,t){let a,o=`${a_(n)} '${ay(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}a=e}else{console.warn(an(30,!1,n.status,ay(n)));try{a=Error(o+JSON.stringify(e))}catch(n){a=e}}return a.appOrParcelName=ay(n),n.status=t,a}let aa="NOT_LOADED",ao="LOADING_SOURCE_CODE",ar="NOT_BOOTSTRAPPED",ai="BOOTSTRAPPING",as="NOT_MOUNTED",al="MOUNTING",ac="MOUNTED",au="UPDATING",ap="UNMOUNTING",ad="UNLOADING",af="LOAD_ERROR",am="SKIP_BECAUSE_BROKEN";function ah(e){return e.status===ac}function ag(e){try{return e.activeWhen(window.location)}catch(n){return t7(n,e,am),!1}}function ay(e){return e.name}function ab(e){return!!e.unmountThisParcel}function a_(e){return ab(e)?"parcel":"application"}function av(){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 a$(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function aA(e){return e&&("function"==typeof e||Array.isArray(e)&&!a$(e,e=>"function"!=typeof e))}function ak(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let a=a_(e),o=ay(e);return function(e){return t.reduce((t,r,i)=>t.then(()=>{let t=r(e);return aw(t)?t:Promise.reject(an(15,!1,a,o,n,i))}),Promise.resolve())}}function aw(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let ax=[];function aC(e,n){return Promise.resolve().then(()=>e.status!==ar?e:(e.status=ai,e.bootstrap?aW(e,"bootstrap").then(t).catch(t=>{if(n)throw at(t,e,am);return t7(t,e,am),e}):Promise.resolve().then(t)));function t(){return e.status=as,e}}function aE(e,n){return Promise.resolve().then(()=>{if(e.status!==ac)return e;return e.status=ap,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,a=>t().then(()=>{let t=Error(a.message);if(n)throw at(t,e,am);t7(t,e,am)})).then(()=>e);function t(){return aW(e,"unmount").then(()=>{e.status=as},t=>{if(n)throw at(t,e,am);t7(t,e,am)})}})}let aS=!1,aD=!1;function aM(e,n){return Promise.resolve().then(()=>e.status!==as?e:(aS||(window.dispatchEvent(new t6("single-spa:before-first-mount")),aS=!0),e.status=al,aW(e,"mount").then(()=>(e.status=ac,aD||(window.dispatchEvent(new t6("single-spa:first-mount")),aD=!0),e)).catch(t=>{return e.status=ac,aE(e,!0).then(a,a);function a(){if(n)throw at(t,e,am);return t7(t,e,am),e}})))}let az=0,aO={parcels:{}};function aP(){return aT.apply(aO,arguments)}function aT(e,n){let t,a,o,r=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(an(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(an(3,!1,typeof e.name));let i=az++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(an(4,!1,s,typeof n));if(!n.domElement)throw Error(an(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:i,parcels:{},status:l?ao:ar,customProps:n,parentName:ay(r),unmountThisParcel:()=>f.then(()=>{if(u.status!==ac)throw Error(an(6,!1,s,u.status));return aE(u,!0)}).then(e=>(u.parentName&&delete r.parcels[u.id],e)).then(e=>(a(e),e)).catch(e=>{throw u.status=am,o(e),e})};r.parcels[i]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(an(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(an(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!aA(e.bootstrap))throw Error(an(9,!1,s));if(!aA(e.mount))throw Error(an(10,!1,s));if(!aA(e.unmount))throw Error(an(11,!1,s));if(e.update&&!aA(e.update))throw Error(an(12,!1,s));let n=ak(e,"bootstrap"),a=ak(e,"mount"),o=ak(e,"unmount");u.status=ar,u.name=s,u.bootstrap=n,u.mount=a,u.unmount=o,u.timeouts=aG(e.timeouts),e.update&&(u.update=ak(e,"update"),t.update=function(e){return u.customProps=e,aB(Promise.resolve().then(()=>{if(u.status!==ac)throw Error(an(32,!1,ay(u)));return u.status=au,aW(u,"update").then(()=>(u.status=ac,u)).catch(e=>{throw at(e,u,am)})}))})})).then(()=>aC(u,!0)),f=d.then(()=>aM(u,!0)),m=new Promise((e,n)=>{a=e,o=n});return t={mount:()=>aB(Promise.resolve().then(()=>{if(u.status!==as)throw Error(an(13,!1,s,u.status));return r.parcels[i]=u,aM(u)})),unmount:()=>aB(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:aB(p),bootstrapPromise:aB(d),mountPromise:aB(f),unmountPromise:aB(m)}}function aB(e){return e.then(()=>null)}function aI(e){let n=ay(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(an(40,!1),n,t));let a=av({},t,{name:n,mountParcel:aT.bind(e),singleSpa:t5});return ab(e)&&(a.unmountSelf=e.unmountThisParcel),a}let aN={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 aj(e,n,t){if("number"!=typeof e||e<=0)throw Error(an(16,!1));aN.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aR(e,n,t){if("number"!=typeof e||e<=0)throw Error(an(17,!1));aN.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aF(e,n,t){if("number"!=typeof e||e<=0)throw Error(an(18,!1));aN.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aL(e,n,t){if("number"!=typeof e||e<=0)throw Error(an(19,!1));aN.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aW(e,n){let t=e.timeouts[n],a=t.warningMillis,o=a_(e);return new Promise((r,i)=>{let s=!1,l=!1;e[n](aI(e)).then(e=>{s=!0,r(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>u(1),a),setTimeout(()=>u(!0),t.millis);let c=an(31,!1,n,o,ay(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*a+a<t.millis&&setTimeout(()=>u(e+1),a)))}})}function aG(e){let n={};for(let t in aN)n[t]=av({},aN[t],e&&e[t]||{});return n}function aV(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==aa&&e.status!==af?e:(e.status=ao,e.loadPromise=Promise.resolve().then(()=>{let a=e.loadApp(aI(e));if(!aw(a))throw t=!0,Error(an(33,!1,ay(e)));return a.then(t=>{let a;e.loadErrorTime=null,"object"!=typeof(n=t)&&(a=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!aA(n.bootstrap)&&(a=35),aA(n.mount)||(a=36),aA(n.unmount)||(a=37);let o=a_(n);if(a){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(an(a,!1,o,ay(e),t),n),t7(void 0,e,am),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=av({},e.devtools.overlays,n.devtools.overlays)),e.status=ar,e.bootstrap=ak(n,"bootstrap"),e.mount=ak(n,"mount"),e.unmount=ak(n,"unmount"),e.unload=ak(n,"unload"),e.timeouts=aG(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let a;return delete e.loadPromise,t?a=am:(a=af,e.loadErrorTime=(new Date).getTime()),t7(n,e,a),e}))})}let aU="u">typeof window,aq={hashchange:[],popstate:[]},aH=["hashchange","popstate"];function aK(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(an(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=a1(window.location.href),a=a1(n);0===n.indexOf("#")?window.location.hash=a.hash:t.host!==a.host&&a.host?window.location.href=n:a.pathname===t.pathname&&a.search===t.search?window.location.hash=a.hash:window.history.pushState(null,null,n)}function aY(e){if(e){let n=e[0].type;aH.indexOf(n)>=0&&aq[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function aJ(){oh([],arguments)}function aZ(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 aX=null,aQ=!1;function a0(e){if(aQ)throw Error(an(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,aQ=!0,aX=window.history.replaceState,window.addEventListener("hashchange",aJ),window.addEventListener("popstate",aJ);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&aH.indexOf(e)>=0)||a$(aq[e],e=>e===t))return n.apply(this,arguments);aq[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&aH.indexOf(e)>=0&&(aq[e]=aq[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=aZ(window.history.pushState,"pushState"),window.history.replaceState=aZ(aX,"replaceState")}function a1(e){let n=document.createElement("a");return n.href=e,n}aU&&(window.singleSpaNavigate?console.warn(an(41,!1)):window.singleSpaNavigate=aK);let a2=!1;function a3(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!a2){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return a5.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return a5.call(this,t,window.removeEventListener,e,n,arguments)},a2=!0}}function a5(e,n,t,a,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{aH.indexOf(e)>=0&&(n(e,a),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let a4={};function a6(e){return Promise.resolve().then(()=>{let n=a4[ay(e)];if(!n)return e;if(e.status===aa)return a8(e,n),e;if(e.status===ad)return n.promise.then(()=>e);if(e.status!==as&&e.status!==af)return e;let t=e.status===af?Promise.resolve():aW(e,"unload");return e.status=ad,t.then(()=>(a8(e,n),e)).catch(t=>(delete a4[ay(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,t7(t,e,am),n.reject(t),e))})}function a8(e,n){delete a4[ay(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aa,n.resolve()}function a7(e,n,t,a){a4[ay(e)]={app:e,resolve:t,reject:a},Object.defineProperty(a4[ay(e)],"promise",{get:n})}let a9=[];function oe(){return a9.filter(ah).map(ay)}function on(){return a9.map(ay)}function ot(e){let n=a$(a9,n=>ay(n)===e);return n?n.status:null}let oa=!1;function oo(e,n,t,a){var o,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(an(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(an(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(an(20,!1));let a=e=>"string"==typeof e||"function"==typeof e;if(!(a(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(a)))throw Error(an(24,!1));if(!oc(e.customProps))throw Error(an(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,a){if("string"!=typeof e||0===e.length)throw Error(an(20,!1));if(!n)throw Error(an(23,!1));if("function"!=typeof t)throw Error(an(24,!1));if(!oc(a))throw Error(an(22,!1))}(e,n,t,a),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=a),i.loadApp="function"!=typeof(o=i.loadApp)?()=>Promise.resolve(o):o,i.customProps=i.customProps||{},s=(s=Array.isArray(r=i.activeWhen)?r:[r]).map(e=>"function"==typeof e?e:ou(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(oy||oa||(oa=!0,setTimeout(()=>{oy||console.warn(an(1,!1))},5e3)),-1!==on().indexOf(l.name))throw Error(an(21,!1,l.name));a9.push(av({loadErrorTime:null,status:aa,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),aU&&(a3(),oh())}function or(e=window.location){return a9.filter(n=>n.activeWhen(e)).map(ay)}function oi(e){if(0===a9.filter(n=>ay(n)===e).length)throw Error(an(25,!1,e));return(aU?os(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=a9.map(ay).indexOf(e);a9.splice(n,1)})}function os(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(an(26,!1));let t=a$(a9,n=>ay(n)===e);if(!t)throw Error(an(27,!1,e));let a=a4[ay(t)];if(n&&n.waitForUnmount){if(a)return a.promise;{let e=new Promise((n,a)=>{a7(t,()=>e,n,a)});return e}}{let e;return a?(e=a.promise,ol(t,a.resolve,a.reject)):e=new Promise((n,a)=>{a7(t,()=>e,n,a),ol(t,n,a)}),e}}function ol(e,n,t){Promise.resolve().then(()=>{if(a$(or(),n=>n===ay(e)))return om()}).then(()=>aE(e).then(a6).then(()=>{n(),setTimeout(()=>{oh()})})).catch(t)}function oc(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function ou(e,n){let t=function(e,n){let t=0,a=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=a&&"/"===t;(!a&&":"===t||o)&&r(n)}return r(e.length),RegExp(o,"i");function r(r){let i=e.slice(t,r).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=a?"[^/]+/?":i,r===e.length)if(a)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}a=!a,t=r}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let a=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(a)}}let op=!1,od=[],of=aU&&window.location.href;function om(){return oh()}function oh(e=[],n,t=!1){let a,o,r,i,s;if(op)return new Promise((e,t)=>{od.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(a=[],o=[],r=[],i=[],s=(new Date).getTime(),a9.forEach(e=>{let n=e.status!==am&&ag(e);switch(e.status){case af:n&&s-e.loadErrorTime>=200&&r.push(e);break;case aa:case ao:n&&r.push(e);break;case ar:case as:!n&&a4[ay(e)]?a.push(e):n&&i.push(e);break;case ac:n||o.push(e)}}),{appsToUnload:a,appsToUnmount:o,appsToLoad:r,appsToMount:i}),d,f=[],m=of,h=of=window.location.href;return oy?(op=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return aX.call(window.history,history.state,"",m.substring(location.origin.length)),of=location.href,op=!1,oh(e,n,!0);let a=l.map(a6),o=Promise.all(c.map(aE).map(e=>e.then(a6)).concat(a));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let r=u.map(e=>aV(e).then(e=>og(e,o))),i=p.filter(e=>0>u.indexOf(e)).map(e=>og(e,o));return o.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=u,Promise.resolve().then(()=>Promise.all(u.map(aV)).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(an(42,!1))),console.warn(e),!1)))}function y(){let n=oe();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(op=!1,od.length>0){let e=od;od=[],oh(e)}return n}function b(){t||(e.forEach(e=>{aY(e.eventArguments)}),aY(n))}function v(e=!1,t){let a={},o={[ac]:[],[as]:[],[aa]:[],[am]:[]};e?(u.concat(p).forEach((e,n)=>{i(e,ac)}),l.forEach(e=>{i(e,aa)}),c.forEach(e=>{i(e,as)})):d.forEach(e=>{i(e)});let r={detail:{newAppStatuses:a,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:m,newUrl:h}};return t&&av(r.detail,t),r;function i(e,n){let t=ay(e);n=n||ot(t),a[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new t6(`single-spa:${e}`,n))}}function og(e,n){return ag(e)?aC(e).then(e=>n.then(()=>ag(e)?aM(e):e)):n.then(()=>e)}let oy=!1;function ob(e){oy=!0,aU&&(a0(e),oh())}function o_(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return ov(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function ov(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function o$({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),a=o_(e,n).replace(window.location.origin,"");a.startsWith(t)?aK(a):window.location.assign(a)}aU&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...a9]},reroute:oh,NOT_LOADED:aa,toLoadPromise:aV,toBootstrapPromise:aC,unregisterApplication:oi,getProfilerData:function(){return ax}});let oA="openmrs:history";function ok(e){let n=JSON.parse(sessionStorage.getItem(oA)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(oA,JSON.stringify(n))}function ow(){0===JSON.parse(sessionStorage.getItem(oA)??"[]").length&&document.referrer&&ok(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=ox();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(oA,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?oC({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&ok(window.location.href)})}function ox(){return JSON.parse(sessionStorage.getItem(oA)??"[]")}function oC({toUrl:e}){let n=ox(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);o$({to:n[t]}),sessionStorage.setItem(oA,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function oE(){sessionStorage.removeItem(oA)}let oS="${openmrsSpaBase}/login",oD={redirectAuthFailure:{enabled:{_type:nV.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nV.String,_default:oS,_validators:[tY.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:nV.Array,_default:[401],_elements:{_type:nV.Number,_validators:[tY.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nV.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:nV.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function oM(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let oz="/ws/rest/v1",oO="/ws/fhir2/R4",oP=`${oz}/session`;function oT(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function oB(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=oT(e);if(n.headers||(n.headers={}),ef(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(oz)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(oO)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let a=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await tA("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(o&&n&&(t===oT(oP)||204===e.status)&&o$({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===oT(oP)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(oE(),o$({to:n.url||e.headers.get("location")||oS}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new oN(t,e,o,a)},n=>{throw new oN(t,e,null,a)})})}function oI(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 er.Observable(a=>{let o=!1;return oB(e,n).then(e=>{o=!0,a.next(e),a.complete()},e=>{o=!0,a.error(e)}),()=>{o||t.abort()}})}class oN extends Error{constructor(e,n,t,a){super(),oM(this,"response",void 0),oM(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`,a.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${a.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let oj=U("session",{loaded:!1,session:null}),oR=0;function oF(e={includeAuthStatus:!0}){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oG(),new er.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(oj.getState()),oj.subscribe(t)})}function oL(){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oG(),oj}function oW(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 oG(e,n){oR=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),oJ(oB(oP,{headers:t}))}function oV(){oj.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oU(e,n){var t,a;if(void 0===n)return!e;if(!e)return!0;return t=e,a=n,("string"==typeof t?!J(a.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!J(a.privileges.find(n=>e===n.display))):(J(t)||console.error(`Could not understand privileges "${t}"`),!0))||!J(n.roles.find(e=>"System Developer"===e.display))}function oq(){let e,n;return new Promise(t=>{let a=a=>{a.loaded&&a.session.user&&(e=a.session.user,t(a.session.user),n&&n())};a(oj.getState()),e||(n=oj.subscribe(a))})}function oH(){return new Promise((e,n)=>{oF().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function oK(e,n){return oJ(oB(oP,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function oY(e,n,t){return t||(t=new AbortController),await oB(`${oz}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),oG()}function oJ(e){return new Promise((n,t)=>{e.then(e=>{let a;"object"==typeof e?.data?(a={loaded:!0,session:e.data},oj.setState(a),n(a)):(a={loaded:!1,session:null},oj.setState(a),t(a))}).catch(e=>{B(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};oj.setState(n),t(n)})})}function oZ(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oj.subscribe(e=>{e.loaded&&e.session&&oW(e.session)});let oX={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function oQ(){th("@openmrs/esm-api",oD),oG()}let o0={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"},o1=e=>"string"==typeof e,o2=()=>{let e,n,t=new Promise((t,a)=>{e=t,n=a});return t.resolve=e,t.reject=n,t},o3=e=>null==e?"":""+e,o5=/###/g,o4=e=>e&&e.indexOf("###")>-1?e.replace(o5,"."):e,o6=e=>!e||o1(e),o8=(e,n,t)=>{let a=o1(n)?n.split("."):n,o=0;for(;o<a.length-1;){if(o6(e))return{};let n=o4(a[o]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++o}return o6(e)?{}:{obj:e,k:o4(a[o])}},o7=(e,n,t)=>{let{obj:a,k:o}=o8(e,n,Object);if(void 0!==a||1===n.length){a[o]=t;return}let r=n[n.length-1],i=n.slice(0,n.length-1),s=o8(e,i,Object);for(;void 0===s.obj&&i.length;)r=`${i[i.length-1]}.${r}`,s=o8(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},o9=(e,n)=>{let{obj:t,k:a}=o8(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,a))return t[a]},re=(e,n,t)=>{for(let a in n)"__proto__"!==a&&"constructor"!==a&&(a in e?o1(e[a])||e[a]instanceof String||o1(n[a])||n[a]instanceof String?t&&(e[a]=n[a]):re(e[a],n[a],t):e[a]=n[a]);return e};var rn={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let rt=e=>o1(e)?e.replace(/[&<>"'\/]/g,e=>rn[e]):e,ra=[" ",",","?","!",";"],ro=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),rr=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let a=n.split(t),o=e;for(let e=0;e<a.length;){let n;if(!o||"object"!=typeof o)return;let r="";for(let i=e;i<a.length;++i)if(i!==e&&(r+=t),r+=a[i],void 0!==(n=o[r])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<a.length-1)continue;e+=i-e+1;break}o=n}return o},ri=e=>e?.replace("_","-"),rs={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 rl{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||rs,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,a){return a&&!this.debug?null:(o1(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new rl(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new rl(this.logger,e)}}var rc=new rl;class ru{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 a=0;a<t;a++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,a])=>{for(let o=0;o<a;o++)t.apply(t,[e,...n])})}}class rp extends ru{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,a={}){let o,r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=void 0!==a.ignoreJSONStructure?a.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],t&&(Array.isArray(t)?o.push(...t):o1(t)&&r?o.push(...t.split(r)):o.push(t)));let s=o9(this.data,o);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=o[0],n=o[1],t=o.slice(2).join(".")),!s&&i&&o1(t))?rr(this.data?.[e]?.[n],t,r):s}addResource(e,n,t,a,o={silent:!1}){let r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(r?t.split(r):t)),e.indexOf(".")>-1&&(i=e.split("."),a=n,n=i[1]),this.addNamespaces(n),o7(this.data,i,a),o.silent||this.emit("added",e,n,t,a)}addResources(e,n,t,a={silent:!1}){for(let a in t)(o1(t[a])||Array.isArray(t[a]))&&this.addResource(e,n,a,t[a],{silent:!0});a.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,a,o,r={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),a=t,t=n,n=i[1]),this.addNamespaces(n);let s=o9(this.data,i)||{};r.skipCopy||(t=JSON.parse(JSON.stringify(t))),a?re(s,t,o):s={...s,...t},o7(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 rd={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,a,o){return e.forEach(e=>{n=this.processors[e]?.process(n,t,a,o)??n}),n}};let rf=Symbol("i18next/PATH_KEY");function rm(e,n){let t,a,o,{[rf]:r}=e((a=[],(o=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===rf)?a:(a.push(n),(t=Proxy.revocable(e,o)).proxy),Proxy.revocable(Object.create(null),o).proxy));return r.join(n?.keySeparator??".")}let rh={},rg=e=>!o1(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ry extends ru{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=rc.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let a=this.resolve(e,t);if(a?.res===void 0)return!1;let o=rg(a.res);return!1!==t.returnObjects||!o}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let a=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=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 a=ra.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===a.length)return!0;let o=ro.getRegExp(`(${a.map(e=>"?"===e?"\\?":e).join("|")})`),r=!o.test(e);if(!r){let n=e.indexOf(t);n>0&&!o.test(e.substring(0,n))&&(r=!0)}return r})(e,t,a);if(r&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:o1(o)?[o]:o};let r=e.split(t);(t!==a||t===a&&this.options.ns.indexOf(r[0])>-1)&&(o=r.shift()),e=r.join(a)}return{key:e,namespaces:o1(o)?[o]:o}}translate(e,n,t){let a="object"==typeof n?{...n}:n;if("object"!=typeof a&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof a&&(a={...a}),a||(a={}),null==e)return"";"function"==typeof e&&(e=rm(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==a.returnDetails?a.returnDetails:this.options.returnDetails,r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],a),l=s[s.length-1],c=void 0!==a.nsSeparator?a.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let u=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?o?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:`${l}${c}${i}`:o?{res:i,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:i;let d=this.resolve(e,a),f=d?.res,m=d?.usedKey||i,h=d?.exactUsedKey||i,g=void 0!==a.joinArrays?a.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==a.count&&!o1(a.count),v=ry.hasDefaultValue(a),$=b?this.pluralResolver.getSuffix(u,a.count,a):"",A=a.ordinal&&b?this.pluralResolver.getSuffix(u,a.count,{ordinal:!1}):"",k=b&&!a.ordinal&&0===a.count,w=k&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${$}`]||a[`defaultValue${A}`]||a.defaultValue,x=f;y&&!f&&v&&(x=w);let C=rg(x),E=Object.prototype.toString.apply(x);if(y&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(o1(g)&&Array.isArray(x))){if(!a.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(m,x,{...a,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return o?(d.res=e,d.usedParams=this.getUsedParamsDetails(a),d):e}if(r){let e=Array.isArray(x),n=e?[]:{},t=e?h:m;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let o=`${t}${r}${e}`;v&&!f?n[e]=this.translate(o,{...a,defaultValue:rg(w)?w[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(o,{...a,joinArrays:!1,ns:s}),n[e]===o&&(n[e]=x[e])}f=n}}else if(y&&o1(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,a,t));else{let n=!1,o=!1;!this.isValidLookup(f)&&v&&(n=!0,f=w),this.isValidLookup(f)||(o=!0,f=i);let s=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:f,p=v&&w!==f&&this.options.updateMissing;if(o||n||p){if(this.logger.log(p?"updateKey":"missingKey",u,l,i,p?w:f),r){let e=this.resolve(i,{...a,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,a.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(a.lng||this.language):e.push(a.lng||this.language);let t=(e,n,t)=>{let o=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,o,p,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,o,p,a),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,a);k&&a[`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,a[`defaultValue${n}`]||w)})}):t(e,i,w))}f=this.extendTranslation(f,e,a,d,t),o&&f===i&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${i}`),(o||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${i}`:i,n?f:void 0,a))}return o?(d.res=f,d.usedParams=this.getUsedParamsDetails(a),d):f}extendTranslation(e,n,t,a,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!t.skipInterpolation){let r;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=o1(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&&!o1(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||a.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);r<(n&&n.length)&&(t.nest=!1)}!t.lng&&a&&a.res&&(t.lng=this.language||a.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[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=o1(r)?[r]:r;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=rd.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,a,o,r,i;return o1(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;a=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let u=void 0!==n.count&&!o1(n.count),p=u&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(o1(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,!rh[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(rh[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${a}" 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(a=>{let i;if(this.isValidLookup(t))return;r=a;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,a,e,n);else{let e;u&&(e=this.pluralResolver.getSuffix(a,n.count,n));let t=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&0===e.indexOf(o)&&s.push(l+e.replace(o,this.options.pluralSeparator)),s.push(l+e),p&&s.push(l+t)),d){let a=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(a),u&&(n.ordinal&&0===e.indexOf(o)&&s.push(a+e.replace(o,this.options.pluralSeparator)),s.push(a+e),p&&s.push(a+t))}}for(;i=s.pop();)this.isValidLookup(t)||(o=i,t=this.getResource(a,e,i,n))}))})}),{res:t,usedKey:a,exactUsedKey:o,usedLng:r,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,a):this.resourceStore.getResource(e,n,t,a)}getUsedParamsDetails(e={}){let n=e.replace&&!o1(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 rb{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=rc.create("languageUtils")}getScriptPartFromCode(e){if(!(e=ri(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=ri(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(o1(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 a=this.getLanguagePartFromCode(e);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(e=>{if(e===a||!(0>e.indexOf("-")&&0>a.indexOf("-"))&&(e.indexOf("-")>0&&0>a.indexOf("-")&&e.substring(0,e.indexOf("-"))===a||0===e.indexOf(a)&&a.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)),o1(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),a=[],o=e=>{e&&(this.isSupportedCode(e)?a.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return o1(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):o1(e)&&o(this.formatLanguageCode(e)),t.forEach(e=>{0>a.indexOf(e)&&o(this.formatLanguageCode(e))}),a}}let r_={zero:0,one:1,two:2,few:3,many:4,other:5},rv={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class r${constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=rc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,a=ri("dev"===e?"en":e),o=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:a,type:o});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];try{t=new Intl.PluralRules(a,{type:o})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),rv;if(!e.match(/-|_/))return rv;let a=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(a,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)=>r_[e]-r_[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let a=this.getRule(e,t);return a?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let rA=(e,n,t,a=".",o=!0)=>{let r,i=void 0!==(r=o9(e,t))?r:o9(n,t);return!i&&o&&o1(t)&&void 0===(i=rr(e,t,a))&&(i=rr(n,t,a)),i};class rk{constructor(e={}){this.logger=rc.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:a,prefix:o,prefixEscaped:r,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==n?n:rt,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==a&&a,this.prefix=o?o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):r||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):m||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,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,a){let o,r,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let o=rA(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,t,{...a,...n,interpolationkey:e}):o}let o=e.split(this.formatSeparator),r=o.shift().trim(),i=o.join(this.formatSeparator).trim();return this.format(rA(n,s,r,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...a,...n,interpolationkey:r})};this.resetRegExp();let c=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=a?.interpolation?.skipOnVariables!==void 0?a.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;o=n.regex.exec(e);){let t=o[1].trim();if(void 0===(r=l(t)))if("function"==typeof c){let n=c(e,o,a);r=o1(n)?n:""}else if(a&&Object.prototype.hasOwnProperty.call(a,t))r="";else if(u){r=o[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),r="";else o1(r)||this.useRawValueToEscape||(r=o3(r));let s=n.safeValue(r);if(e=e.replace(o[0],s),u?(n.regex.lastIndex+=r.length,n.regex.lastIndex-=o[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let a,o,r,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let a=e.split(RegExp(`${t}[ ]*{`)),o=`{${a[1]}`;e=a[0];let i=(o=this.interpolate(o,r)).match(/'/g),s=o.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(o=o.replace(/'/g,'"'));try{r=JSON.parse(o),n&&(r={...n,...r})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${o}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,e};for(;a=this.nestingRegexp.exec(e);){let s=[];(r=(r={...t}).replace&&!o1(r.replace)?r.replace:r).applyPostProcessor=!1,delete r.defaultValue;let l=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(-1!==l&&(s=a[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),a[1]=a[1].slice(0,l)),(o=n(i.call(this,a[1].trim(),r),r))&&a[0]===e&&!o1(o))return o;o1(o)||(o=o3(o)),o||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:a[1].trim()}),o.trim())),e=e.replace(a[0],o),this.regexp.lastIndex=0}return e}}let rw=e=>{let n={};return(t,a,o)=>{let r=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(r={...r,[o.interpolationkey]:void 0});let i=a+JSON.stringify(r),s=n[i];return s||(s=e(ri(a),o),n[i]=s),s(t)}},rx=e=>(n,t,a)=>e(ri(t),a)(n);class rC{constructor(e={}){this.logger=rc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?rw:rx;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()]=rw(n)}format(e,n,t,a={}){let o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&0>o[0].indexOf(")")&&o.find(e=>e.indexOf(")")>-1)){let e=o.findIndex(e=>e.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,e)].join(this.formatSeparator)}return o.reduce((e,n)=>{let{formatName:o,formatOptions:r}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let a=e.split("(");n=a[0].toLowerCase().trim();let o=a[1].substring(0,a[1].length-1);"currency"===n&&0>o.indexOf(":")?t.currency||(t.currency=o.trim()):"relativetime"===n&&0>o.indexOf(":")?t.range||(t.range=o.trim()):o.split(";").forEach(e=>{if(e){let[n,...a]=e.split(":"),o=a.join(":").trim().replace(/^'+|'+$/g,""),r=n.trim();t[r]||(t[r]=o),"false"===o&&(t[r]=!1),"true"===o&&(t[r]=!0),isNaN(o)||(t[r]=parseInt(o,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[o]){let n=e;try{let i=a?.formatParams?.[a.interpolationkey]||{},s=i.locale||i.lng||a.locale||a.lng||t;n=this.formats[o](e,s,{...r,...a,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class rE extends ru{constructor(e,n,t,a={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=a,this.logger=rc.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,a.backend,a)}queueLoad(e,n,t,a){let o={},r={},i={},s={};return e.forEach(e=>{let a=!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,a=!1,void 0===r[i]&&(r[i]=!0),void 0===o[i]&&(o[i]=!0),void 0===s[n]&&(s[n]=!0)))}),a||(i[e]=!0)}),(Object.keys(o).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(o),pending:Object.keys(r),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let a=e.split("|"),o=a[0],r=a[1];n&&this.emit("failedLoading",o,r,n),!n&&t&&this.store.addResourceBundle(o,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,a)=>{let{obj:o,k:r}=o8(e,n,Object);o[r]=o[r]||[],o[r].push(t)})(t.loaded,[o],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,a=0,o=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:a,wait:o,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&&a<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,a+1,2*o,r)},o):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={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();o1(e)&&(e=this.languageUtils.toResolveHierarchy(e)),o1(n)&&(n=[n]);let o=this.queueLoad(e,n,t,a);if(!o.toLoad.length)return o.pending.length||a(),null;o.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("|"),a=t[0],o=t[1];this.read(a,o,"read",void 0,void 0,(t,r)=>{t&&this.logger.warn(`${n}loading namespace ${o} for language ${a} failed`,t),!t&&r&&this.logger.log(`${n}loaded namespace ${o} for language ${a}`,r),this.loaded(e,t,r)})}saveMissing(e,n,t,a,o,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:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;(o=5===l.length?l(e,n,t,a,s):l(e,n,t,a))&&"function"==typeof o.then?o.then(e=>i(null,e)).catch(i):i(null,o)}catch(e){i(e)}else l(e,n,t,a,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,a)}}}let rS=()=>({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]),o1(e[1])&&(n.defaultValue=e[1]),o1(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}),rD=e=>(o1(e.ns)&&(e.ns=[e.ns]),o1(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),o1(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),rM=()=>{};class rz extends ru{constructor(e={},n){if(super(),this.options=rD(e),this.services={},this.logger=rc,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&&(o1(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=rS();this.options={...t,...this.options,...rD(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 a=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?rc.init(a(this.modules.logger),this.options):rc.init(null,this.options),e=this.modules.formatter?this.modules.formatter:rC;let n=new rb(this.options);this.store=new rp(this.options.resources,this.options);let o=this.services;o.logger=rc,o.resourceStore=this.store,o.languageUtils=n,o.pluralResolver=new r$(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)&&(o.formatter=a(e),o.formatter.init&&o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new rk(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new rE(a(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(o.languageDetector=a(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=a(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new ry(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=rM),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 o=o2(),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),o.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),o}loadResources(e,n=rM){let t=n,a=o1(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(a?.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)})};a?n(a):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 a=o2();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=rM),this.services.backendConnector.reload(e,n,e=>{a.resolve(),t(e)}),a}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&&rd.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=o2();this.emit("languageChanging",e);let a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(o,r)=>{r?this.isLanguageChangingTo===e&&(a(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(o,(...e)=>this.t(...e))},r=n=>{e||n||!this.services.languageDetector||(n=[]);let t=o1(n)?n:n&&n[0],r=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(o1(n)?[n]:n);r&&(this.language||a(r),this.translator.language||this.translator.changeLanguage(r),this.services.languageDetector?.cacheUserLanguage?.(r)),this.loadResources(r,e=>{o(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 a=(e,n,...o)=>{let r,i;(r="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(o)):{...n}).lng=r.lng||a.lng,r.lngs=r.lngs||a.lngs,r.ns=r.ns||a.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||t||a.keyPrefix);let s=this.options.keySeparator||".";return r.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=rm(e,{...this.options,...n})),`${r.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=rm(e,{...this.options,...n})),i=r.keyPrefix?`${r.keyPrefix}${s}${e}`:e),this.t(i,r)};return o1(e)?a.lng=e:a.lngs=e,a.ns=n,a.keyPrefix=t,a}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],a=!!this.options&&this.options.fallbackLng,o=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)&&(!a||r(o,e)))}loadNamespaces(e,n){let t=o2();return this.options.ns?(o1(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=o2();o1(e)&&(e=[e]);let a=this.options.preload||[],o=e.filter(e=>0>a.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=a.concat(o),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 rb(rS());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 rz(e,n)}cloneInstance(e={},n=rM){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let a={...this.options,...e,isClone:!0},o=new rz(a);return(void 0!==e.debug||void 0!==e.prefix)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},t&&(o.store=new rp(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,a)=>(t[a]={...e[n][a]},t),e[n]),e),{}),a),o.services.resourceStore=o.store),o.translator=new ry(o.services,a),o.translator.on("*",(e,...n)=>{o.emit(e,...n)}),o.init(a,n),o.translator.options=a,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let rO=rz.createInstance();rO.createInstance=rz.createInstance,rO.createInstance,rO.dir,rO.init,rO.loadResources,rO.reloadResources,rO.use,rO.changeLanguage,rO.getFixedT,rO.t,rO.exists,rO.setDefaultNamespace,rO.hasLoadedNamespace,rO.loadNamespaces,rO.loadLanguages;let rP=rO.default||rO;function rT(e,n,t,a){return rP.t(n,{ns:e,defaultValue:t,...a})}function rB(e,n,t){return o0[e]?rT("core",e,n??o0[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}rP.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let rI="import-map-override:",rN="import-map-overrides-disabled",rj="import-map-overrides:change",rR=!1,rF=null,rL=null;async function rW(){return rL??(rL=rG().then(({map:e,complete:n})=>(n||(rL=null),e))),rL}async function rG(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[],t=!0;for(let a=0;a<e.length;a++){let o=e[a];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);n.push(await e.json())}else o.textContent&&n.push(JSON.parse(o.textContent))}catch(e){t=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${a}`,e)}}return{map:rV(n),complete:t}}function rV(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function rU(){let e={};try{let n=rJ();for(let t=0;t<localStorage.length;t++){let a=localStorage.key(t);if(a?.startsWith(rI)){let t=a.slice(rI.length);if(!n.includes(t)){let n=localStorage.getItem(a);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function rq(){let e=await rW();return rR?rV([e,rF??rU()]):e}async function rH(){return rW()}async function rK(){return rR?rV([await rW(),rU()]):rW()}function rY(e){if(!rR)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(rI)){let n=localStorage.getItem(t);n&&(e[t.slice(rI.length)]=n)}}return{imports:e}}return rU()}function rJ(){if(!rR)return[];try{let e=localStorage.getItem(rN);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function rZ(e){return!!rR&&rJ().includes(e)}function rX(e,n){if(!rR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(rI+e,n),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function rQ(e){if(!rR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(rI+e);let n=rJ().filter(n=>n!==e);n.length>0?localStorage.setItem(rN,JSON.stringify(n)):localStorage.removeItem(rN),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function r0(){if(!rR)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(rI)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(rN),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function r1(e){if(!rR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=rJ().filter(n=>n!==e);n.length>0?localStorage.setItem(rN,JSON.stringify(n)):localStorage.removeItem(rN),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let r2=!1;function r3(){!r2&&(r2=!0,(rR="development"===window.spaEnv)&&(rF=rU()))}function r5(e){return e.replace(/[\/\-@]/g,"_")}async function r4(e,n="./start",a){var o;let r,i=!a?.maxLoadingTime||a.maxLoadingTime<=0?6e5:a.maxLoadingTime;await Promise.race([r6(e,a?.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=r5(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(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 r6(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=r5(e);if(!window[t]){let t=n??await r8();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 a=t.imports[e];a.startsWith("./")&&(a=window.spaBase+a.substring(1));let o=e in rY().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let a=document.head.querySelector(`script[src="${e}"]`),o=window[r7];if(o||(o=window[r7]=new Set([])),a)if(o.has(e)){let e,o,r;r=()=>{e&&a.removeEventListener("load",e),o&&a.removeEventListener("error",o)},e=()=>{r(),n(null)},o=e=>{r(),t(e.message)},a.addEventListener("load",e),a.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let a,r,i;o.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),o.delete(e),a&&s.removeEventListener("load",a),r&&s.removeEventListener("error",r)},a=()=>{i(),n(null)},r=n=>{i();let a=`Failed to load script from ${e}`;console.error(a,n),t(n.message??a)},s.addEventListener("load",a),s.addEventListener("error",r),document.head.appendChild(s)}}(a,e,n)})}catch(e){return o&&M({kind:"error",title:rB("scriptLoadingFailed","Error: Script failed to load"),description:rB("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:a}),actionButtonLabel:rB("resetOverrides","Reset overrides"),onActionButtonClick(){r0(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function r8(){return rq()}let r7=Symbol("__openmrs_script_loading");function r9(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 ie(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,n])=>"string"==typeof e&&r9(n))}let it="openmrs-routes:",ia="openmrs-routes:change",io=!1,ir=null,ii=null;async function is(){return ii??(ii=il().then(({map:e,complete:n})=>(n||(ii=null),e))),ii}async function il(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[],t=!0;for(let a=0;a<e.length;a++){let o=e[a];try{let e;if(o.src){let n=await fetch(o.src);if(!n.ok)throw Error(`Request for ${o.src} returned ${n.status} ${n.statusText}`);e=await n.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&ie(e)&&n.push(e)}catch(e){t=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${a}`,e)}}return{map:ic(n),complete:t}}function ic(e){let n={routes:{}};for(let t of e)t&&"object"==typeof t&&!Array.isArray(t)&&(Object.assign(n.routes,t.routes),void 0===n.version&&void 0!==t.version&&(n.version=t.version));return n}async function iu(){let e={version:void 0,routes:{}};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(it)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(it.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(r9(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),a=await n.json();if(r9(a))return{moduleName:e,routes:a};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.routes[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 ip(){let e=await is();return io?ic([e,ir??await iu()]):e}async function id(){return is()}async function im(){return io?ic([await is(),await iu()]):is()}function ih(){if(!io)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(it)){let n=localStorage.getItem(t);n&&(e[t.slice(it.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function ig(e,n){if(!io)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(it+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!r9(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(it+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(it+e,JSON.stringify(n.toString()));else{if(!r9(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(it+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(ia))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function iy(e){if(!io)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(it+e),window.dispatchEvent(new CustomEvent(ia))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ib(){if(!io)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(it)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(ia))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let i_=null;function iv(){return i_||(i_=(io="development"===window.spaEnv)?iu().then(e=>{ir=e}):Promise.resolve())}let i$=`${oz}/attachment`;function iA(e,n){return oB(`${i$}/${e}`,{signal:n.signal})}function ik(e,n,t){return oB(`${i$}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function iw(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)),oB(`${i$}`,{method:"POST",body:t})}function ix(e,n){return oB(`${i$}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function iC(e,n){return new Promise(function(t){var a=new MessageChannel;a.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[a.port2])})}function iE(e,n){for(var t=0;t<n.length;t++){var a=n[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function iS(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var iD=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function iM(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var iz=function(e,n){this.type=e,Object.assign(this,n)};function iO(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function iP(){}var iT={type:"SKIP_WAITING"};function iB(e,n){if(!n)return e&&e.then?e.then(iP):Promise.resolve()}var iI=function(e){function n(n,t){var a,o;return void 0===t&&(t={}),(a=e.call(this)||this).nn={},a.tn=0,a.rn=new iD,a.en=new iD,a.on=new iD,a.un=0,a.an=new Set,a.cn=function(){var e=a.fn,n=e.installing;a.tn>0||!iM(n.scriptURL,a.sn.toString())||performance.now()>a.un+6e4?(a.vn=n,e.removeEventListener("updatefound",a.cn)):(a.hn=n,a.an.add(n),a.rn.resolve(n)),++a.tn,n.addEventListener("statechange",a.ln)},a.ln=function(e){var n=a.fn,t=e.target,o=t.state,r=t===a.vn,i={sw:t,isExternal:r,originalEvent:e};!r&&a.mn&&(i.isUpdate=!0),a.dispatchEvent(new iz(o,i)),"installed"===o?a.wn=self.setTimeout(function(){"installed"===o&&n.waiting===t&&a.dispatchEvent(new iz("waiting",i))},200):"activating"===o&&(clearTimeout(a.wn),r||a.en.resolve(t))},a.dn=function(e){var n=a.hn,t=n!==navigator.serviceWorker.controller;a.dispatchEvent(new iz("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:a.mn})),t||a.on.resolve(n)},o=function(e){var n=e.data,t=e.ports,o=e.source;return iO(a.getSW(),function(){a.an.has(o)&&a.dispatchEvent(new iz("message",{data:n,originalEvent:e,ports:t,sw:o}))})},a.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},a.sn=n,a.nn=t,navigator.serviceWorker.addEventListener("message",a.gn),a}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,a,o=n.prototype;return o.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var a,o,r,i=this;return a=function(){if(!t&&"complete"!==document.readyState)return iB(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),iO(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&&iM(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new iz("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=a())&&r.then?r.then(o):o(r)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?iB(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return iO(this.getSW(),function(n){return iC(n,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&iC(this.fn.waiting,iT)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&iM(e.scriptURL,this.sn.toString())?e:void 0},o.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 iO(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}}],iE(n.prototype,t),a&&iE(n,a),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 iS(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)?iS(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 iN(e,n){if(void 0!==d)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),d;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new iI(e,n);return d=t.register().then(()=>t.controlling.then(()=>t))}function ij(){return d??Promise.resolve(void 0)}let iR="x-omrs-offline-response-body",iF="x-omrs-offline-response-status",iL="x-omrs-offline-caching-strategy";async function iW(e){let n=await ij();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 iG(){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 iV(){return!window.indexedDB}async function iU(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function iq(){return await iU()||await iV()||await iG()}let iH="openmrs3:offline-mode",iK="unavailable";function iY(){return{current:iK,notAvailable:"unavailable"===iK,active:"on"===iK}}function iJ(e){"unavailable"!==iK&&"unavailable"!==e&&(localStorage.setItem(iH,"on"===e?"active":"disabled"),iK=e)}async function iZ(){await iq()||(iK="active"===localStorage.getItem(iH)?"on":"off"),navigator.onLine}let iX="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,iQ=Object.keys,i0=Array.isArray;function i1(e,n){return"object"!=typeof n||iQ(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||iX.Promise||(iX.Promise=Promise);let i2=Object.getPrototypeOf,i3={}.hasOwnProperty;function i5(e,n){return i3.call(e,n)}function i4(e,n){"function"==typeof n&&(n=n(i2(e))),("u"<typeof Reflect?iQ:Reflect.ownKeys)(n).forEach(t=>{i8(e,t,n[t])})}let i6=Object.defineProperty;function i8(e,n,t,a){i6(e,n,i1(t&&i5(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},a))}function i7(e){return{from:function(n){return e.prototype=Object.create(n.prototype),i8(e.prototype,"constructor",e),{extend:i4.bind(null,e.prototype)}}}}let i9=Object.getOwnPropertyDescriptor;function se(e,n){let t;return i9(e,n)||(t=i2(e))&&se(t,n)}let sn=[].slice;function st(e,n,t){return sn.call(e,n,t)}function sa(e,n){return n(e)}function so(e){if(!e)throw Error("Assertion Failed")}function sr(e){iX.setImmediate?setImmediate(e):setTimeout(e,0)}function si(e,n){return e.reduce((e,t,a)=>{var o=n(t,a);return o&&(e[o[0]]=o[1]),e},{})}function ss(e,n){if(i5(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],a=0,o=n.length;a<o;++a){var r=ss(e,n[a]);t.push(r)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return void 0===s?void 0:ss(s,n.substr(i+1))}}function sl(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){so("string"!=typeof t&&"length"in t);for(var a=0,o=n.length;a<o;++a)sl(e,n[a],t[a])}else{var r=n.indexOf(".");if(-1!==r){var i=n.substr(0,r),s=n.substr(r+1);if(""===s)void 0===t?i0(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&i5(e,i)||(l=e[i]={}),sl(l,s,t)}}else void 0===t?i0(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function sc(e){var n={};for(var t in e)i5(e,t)&&(n[t]=e[t]);return n}let su=[].concat;function sp(e){return su.apply([],e)}let sd="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(sp([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>iX[e]),sf=sd.map(e=>iX[e]);si(sd,e=>[e,!0]);let sm=null;function sh(e){sm="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=sm&&sm.get(n);if(t)return t;if(i0(n)){t=[],sm&&sm.set(n,t);for(var a=0,o=n.length;a<o;++a)t.push(e(n[a]))}else if(sf.indexOf(n.constructor)>=0)t=n;else{let a=i2(n);for(var r in t=a===Object.prototype?{}:Object.create(a),sm&&sm.set(n,t),n)i5(n,r)&&(t[r]=e(n[r]))}return t}(e);return sm=null,n}let{toString:sg}={};function sy(e){return sg.call(e).slice(8,-1)}let sb="u">typeof Symbol?Symbol.iterator:"@@iterator",s_="symbol"==typeof sb?function(e){var n;return null!=e&&(n=e[sb])&&n.apply(e)}:function(){return null},sv={};function s$(e){var n,t,a,o;if(1==arguments.length){if(i0(e))return e.slice();if(this===sv&&"string"==typeof e)return[e];if(o=s_(e)){for(t=[];!(a=o.next()).done;)t.push(a.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 sA="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var sk="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),sw=()=>!0;let sx=!Error("").stack;function sC(){if(sx)try{throw sC.arguments,Error()}catch(e){return e}return Error()}function sE(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(sw).map(e=>"\n"+e).join("")):""}var sS=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sD=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(sS),sM={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 sz(e,n){this._e=sC(),this.name=e,this.message=n}function sO(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function sP(e,n,t,a){this._e=sC(),this.failures=n,this.failedKeys=a,this.successCount=t,this.message=sO(e,n)}function sT(e,n){this._e=sC(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=sO(e,n)}i7(sz).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+sE(this._e,2))}},toString:function(){return this.name+": "+this.message}}),i7(sP).from(sz),i7(sT).from(sz);var sB=sD.reduce((e,n)=>(e[n]=n+"Error",e),{}),sI=sD.reduce((e,n)=>{var t=n+"Error";function a(e,a){this._e=sC(),this.name=t,e?"string"==typeof e?(this.message=`${e}${a?"\n "+a:""}`,this.inner=a||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sM[n]||t,this.inner=null)}return i7(a).from(sz),e[n]=a,e},{});sI.Syntax=SyntaxError,sI.Type=TypeError,sI.Range=RangeError;var sN=sS.reduce((e,n)=>(e[n+"Error"]=sI[n],e),{}),sj=sD.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=sI[n]),e),{});function sR(){}function sF(e){return e}function sL(e,n){return null==e||e===sF?n:function(t){return n(e(t))}}function sW(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function sG(e,n){return e===sR?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var a=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var r=n.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?sW(a,this.onsuccess):a),o&&(this.onerror=this.onerror?sW(o,this.onerror):o),void 0!==r?r:t}}function sV(e,n){return e===sR?n:function(){e.apply(this,arguments);var t=this.onsuccess,a=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?sW(t,this.onsuccess):t),a&&(this.onerror=this.onerror?sW(a,this.onerror):a)}}function sU(e,n){return e===sR?n:function(t){var a=e.apply(this,arguments);i1(t,a);var o=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?sW(o,this.onsuccess):o),r&&(this.onerror=this.onerror?sW(r,this.onerror):r),void 0===a?void 0===i?void 0:i:i1(a,i)}}function sq(e,n){return e===sR?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sH(e,n){return e===sR?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var a=this,o=arguments.length,r=Array(o);o--;)r[o]=arguments[o];return t.then(function(){return n.apply(a,r)})}return n.apply(this,arguments)}}sj.ModifyError=sP,sj.DexieError=sz,sj.BulkError=sT;var sK={};let[sY,sJ,sZ]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,i2(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,i2(n),e]})(),sX=sJ&&sJ.then,sQ=sY&&sY.constructor,s0=!!sZ;var s1=!1,s2=sZ?()=>{sZ.then(lf)}:iX.setImmediate?setImmediate.bind(null,lf):iX.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{lf(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(lf,0)},s3=function(e,n){lt.push([e,n]),s4&&(s2(),s4=!1)},s5=!0,s4=!0,s6=[],s8=[],s7=null,s9=sF,le={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lN,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lN(e[0],e[1])}catch(e){}})}},ln=le,lt=[],la=0,lo=[];function lr(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=sR,this._lib=!1;var n=this._PSD=ln;if(sk&&(this._stackHolder=sC(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sK)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&ll(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 a=n._lib&&lm();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof lr?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,lc(n)),a&&lh()}},ll.bind(null,n))}catch(e){ll(n,e)}}(this,e)}let li={get:function(){var e=ln,n=lk;function t(t,a){var o=!e.global&&(e!==ln||n!==lk);let r=o&&!lE();var i=new lr((n,i)=>{lu(this,new ls(lT(t,e,o,r),lT(a,e,o,r),n,i,e))});return sk&&ld(i,this),i}return t.prototype=sK,t},set:function(e){i8(this,"then",e&&e.prototype===sK?li:{get:function(){return e},set:li.set})}};function ls(e,n,t,a,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=a,this.psd=o}function ll(e,n){if(s8.push(n),null===e._state){var t=e._lib&&lm();n=s9(n),e._state=!1,e._value=n,sk&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=se(n,"stack");n._promise=e,i8(n,"stack",{get:()=>s1?t&&(t.get?t.get.apply(n):t.value):e.stack})}),s6.some(n=>n._value===e._value)||s6.push(e),lc(e),t&&lh()}}function lc(e){var n=e._listeners;e._listeners=[];for(var t=0,a=n.length;t<a;++t)lu(e,n[t]);var o=e._PSD;--o.ref||o.finalize(),0===la&&(++la,s3(()=>{0==--la&&lg()},[]))}function lu(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,++la,s3(lp,[t,e,n])}else e._listeners.push(n)}function lp(e,n,t){try{s7=n;var a,o=n._value;n._state?a=e(o):(s8.length&&(s8=[]),a=e(o),-1===s8.indexOf(o)&&function(e){for(var n=s6.length;n;)if(s6[--n]._value===e._value)return void s6.splice(n,1)}(n)),t.resolve(a)}catch(e){t.reject(e)}finally{s7=null,0==--la&&lg(),--t.psd.ref||t.psd.finalize()}}function ld(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function lf(){lm()&&lh()}function lm(){var e=s5;return s5=!1,s4=!1,e}function lh(){var e,n,t;do for(;lt.length>0;)for(e=lt,lt=[],t=e.length,n=0;n<t;++n){var a=e[n];a[0].apply(null,a[1])}while(lt.length>0);s5=!0,s4=!0}function lg(){var e=s6;s6=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=lo.slice(0),t=n.length;t;)n[--t]()}function ly(e){return new lr(sK,!1,e)}function lb(e,n){var t=ln;return function(){var a=lm(),o=ln;try{return lz(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{lz(o,!1),a&&lh()}}}i4(lr.prototype,{then:li,_then:function(e,n){lu(this,new ls(null,null,e,n,ln))},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):ly(e)):this.then(null,e=>e&&e.name===n?t(e):ly(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),ly(n)))},stack:{get:function(){if(this._stack)return this._stack;try{s1=!0;var e=(function e(n,t,a){if(t.length===a)return t;var o="";if(!1===n._state){var r,i,s=n._value;null!=s?(r=s.name||"Error",i=s.message||s,o=sE(s,0)):(r=s,i=""),t.push(r+(i?": "+i:"")+o)}return sk&&((o=sE(n._stackHolder,2))&&-1===t.indexOf(o)&&t.push(o),n._prev&&e(n._prev,t,a)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{s1=!1}}},timeout:function(e,n){return e<1/0?new lr((t,a)=>{var o=setTimeout(()=>a(new sI.Timeout(n)),e);this.then(t,a).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&i8(lr.prototype,Symbol.toStringTag,"Dexie.Promise"),le.env=lO(),i4(lr,{all:function(){var e=s$.apply(null,arguments).map(lS);return new lr(function(n,t){0===e.length&&n([]);var a=e.length;e.forEach((o,r)=>lr.resolve(o).then(t=>{e[r]=t,--a||n(e)},t))})},resolve:e=>{if(e instanceof lr)return e;if(e&&"function"==typeof e.then)return new lr((n,t)=>{e.then(n,t)});var n=new lr(sK,!0,e);return ld(n,s7),n},reject:ly,race:function(){var e=s$.apply(null,arguments).map(lS);return new lr((n,t)=>{e.map(e=>lr.resolve(e).then(n,t))})},PSD:{get:()=>ln,set:e=>ln=e},totalEchoes:{get:()=>lk},newPSD:lx,usePSD:lP,scheduler:{get:()=>s3,set:e=>{s3=e}},rejectionMapper:{get:()=>s9,set:e=>{s9=e}},follow:(e,n)=>new lr((t,a)=>lx((n,t)=>{var a=ln;a.unhandleds=[],a.onunhandled=t,a.finalize=sW(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},lo.push(function n(){e(),lo.splice(lo.indexOf(n),1)}),++la,s3(()=>{0==--la&&lg()},[])},a.finalize),e()},n,t,a))}),sQ&&(sQ.allSettled&&i8(lr,"allSettled",function(){let e=s$.apply(null,arguments).map(lS);return new lr(n=>{0===e.length&&n([]);let t=e.length,a=Array(t);e.forEach((e,o)=>lr.resolve(e).then(e=>a[o]={status:"fulfilled",value:e},e=>a[o]={status:"rejected",reason:e}).then(()=>--t||n(a)))})}),sQ.any&&"u">typeof AggregateError&&i8(lr,"any",function(){let e=s$.apply(null,arguments).map(lS);return new lr((n,t)=>{0===e.length&&t(AggregateError([]));let a=e.length,o=Array(a);e.forEach((e,r)=>lr.resolve(e).then(e=>n(e),e=>{o[r]=e,--a||t(AggregateError(o))}))})}));let l_={awaits:0,echoes:0,id:0};var lv=0,l$=[],lA=0,lk=0,lw=0;function lx(e,n,t,a){var o=ln,r=Object.create(o);r.parent=o,r.ref=0,r.global=!1,r.id=++lw;var i=le.env;r.env=s0?{Promise:lr,PromiseProp:{value:lr,configurable:!0,writable:!0},all:lr.all,race:lr.race,allSettled:lr.allSettled,any:lr.any,resolve:lr.resolve,reject:lr.reject,nthen:lB(i.nthen,r),gthen:lB(i.gthen,r)}:{},n&&i1(r,n),++o.ref,r.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lP(r,e,t,a);return 0===r.ref&&r.finalize(),s}function lC(){return l_.id||(l_.id=++lv),++l_.awaits,l_.echoes+=100,l_.id}function lE(){return!!l_.awaits&&(0==--l_.awaits&&(l_.id=0),l_.echoes=100*l_.awaits,!0)}function lS(e){return l_.echoes&&e&&e.constructor===sQ?(lC(),e.then(e=>(lE(),e),e=>(lE(),lj(e)))):e}function lD(e){++lk,l_.echoes&&0!=--l_.echoes||(l_.echoes=l_.id=0),l$.push(ln),lz(e,!0)}function lM(){var e=l$[l$.length-1];l$.pop(),lz(e,!1)}function lz(e,n){var t,a=ln;if((n?!l_.echoes||lA++&&e===ln:!lA||--lA&&e===ln)||(t=n?lD.bind(null,e):lM,sX.call(sY,t)),e!==ln&&(ln=e,a===le&&(le.env=lO()),s0)){var o=le.env.Promise,r=e.env;sJ.then=r.nthen,o.prototype.then=r.gthen,(a.global||e.global)&&(Object.defineProperty(iX,"Promise",r.PromiseProp),o.all=r.all,o.race=r.race,o.resolve=r.resolve,o.reject=r.reject,r.allSettled&&(o.allSettled=r.allSettled),r.any&&(o.any=r.any))}}function lO(){var e=iX.Promise;return s0?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(iX,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:sJ.then,gthen:e.prototype.then}:{}}function lP(e,n,t,a,o){var r=ln;try{return lz(e,!0),n(t,a,o)}finally{lz(r,!1)}}function lT(e,n,t,a){return"function"!=typeof e?e:function(){var o,r=ln;t&&lC(),lz(n,!0);try{return e.apply(this,arguments)}finally{lz(r,!1),a&&(o=lE,sX.call(sY,o))}}}function lB(e,n){return function(t,a){return e.call(this,lT(t,n),lT(a,n))}}-1===(""+sX).indexOf("[native code]")&&(lC=lE=sR);let lI="unhandledrejection";function lN(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var a,o={promise:n,reason:e};if(iX.document&&document.createEvent?((a=document.createEvent("Event")).initEvent(lI,!0,!0),i1(a,o)):iX.CustomEvent&&i1(a=new CustomEvent(lI,{detail:o}),o),a&&iX.dispatchEvent&&(dispatchEvent(a),!iX.PromiseRejectionEvent&&iX.onunhandledrejection))try{iX.onunhandledrejection(a)}catch(e){}sk&&a&&!a.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var lj=lr.reject;let lR="3.2.4",lF=String.fromCharCode(65535),lL=-1/0,lW="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lG="String expected.",lV=[],lU="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lq=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lH="__dbnames",lK="readonly",lY="readwrite";function lJ(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let lZ={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lX(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=sh(n))[e],n)}class lQ{_trans(e,n,t){let a=this._tx||ln.trans,o=this.name;function r(e,t,a){if(!a.schema[o])throw new sI.NotFound("Table "+o+" not part of transaction");return n(a.idbtrans,a)}let i=lm();try{return a&&a.db===this.db?a===ln.trans?a._promise(e,r,t):lx(()=>a._promise(e,r,t),{trans:a,transless:ln.transless||ln}):function e(n,t,a,o){if(n.idbdb&&(n._state.openComplete||ln.letThrough||n._vip)){var r=n._createTransaction(t,a,n._dbSchema);try{r.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===sB.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,a,o))):lj(r)}return r._promise(t,(e,n)=>lx(()=>(ln.trans=r,o(e,n,r)))).then(e=>r._completion.then(()=>e))}if(n._state.openComplete)return lj(new sI.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return lj(new sI.DatabaseClosed);n.open().catch(sR)}return n._state.dbReadyPromise.then(()=>e(n,t,a,o))}(this.db,e,[this.name],r)}finally{i&&lh()}}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(i0(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=iQ(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=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==lF)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&sk&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:a}=this.schema,o=this.db._deps.indexedDB;function r(e,n){try{return 0===o.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],o)=>{let i=a[o],s=e[o];return[n||i,n||!i?lJ(t,i&&i.multi?e=>{let n=ss(e,o);return i0(n)&&n.some(e=>r(s,e))}:e=>r(s,ss(e,o))):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,i0(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 a in n)if(i5(n,a))try{t[a]=n[a]}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){i1(this,e)})}add(e,n){let{auto:t,keyPath:a}=this.schema.primKey,o=e;return a&&t&&(o=lX(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[o]})).then(e=>e.numFailures?lr.reject(e.failures[0]):e.lastResult).then(n=>{if(a)try{sl(e,a,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||i0(e))return this.where(":id").equals(e).modify(n);{let t=ss(e,this.schema.primKey.keyPath);if(void 0===t)return lj(new sI.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?iQ(n).forEach(t=>{sl(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:a}=this.schema.primKey,o=e;return a&&t&&(o=lX(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=n?[n]:null})).then(e=>e.numFailures?lr.reject(e.failures[0]):e.lastResult).then(n=>{if(a)try{sl(e,a,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?lr.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lZ})).then(e=>e.numFailures?lr.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 a=Array.isArray(n)?n:void 0,o=(t=t||(a?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&a)throw new sI.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new sI.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(lX(r)):e;return this.core.mutate({trans:n,type:"add",keys:a,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:a})=>{if(0===e)return o?n:t;throw new sT(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,a)})})}bulkPut(e,n,t){let a=Array.isArray(n)?n:void 0,o=(t=t||(a?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&a)throw new sI.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new sI.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(lX(r)):e;return this.core.mutate({trans:n,type:"put",keys:a,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:a})=>{if(0===e)return o?n:t;throw new sT(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,a)})})}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:a})=>{if(0===e)return t;throw new sT(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,a)})}}function l0(e){var n={},t=function(t,a){if(a){for(var o=arguments.length,r=Array(o-1);--o;)r[o-1]=arguments[o];return n[t].subscribe.apply(null,r),e}if("string"==typeof t)return n[t]};t.addEventType=r;for(var a=1,o=arguments.length;a<o;++a)r(arguments[a]);return t;function r(e,a,o){if("object"!=typeof e){a||(a=sq),o||(o=sR);var i={subscribers:[],fire:o,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=a(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(a,o)}};return n[e]=t[e]=i,i}iQ(e).forEach(function(n){var t=e[n];if(i0(t))r(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new sI.InvalidArgument("Invalid event config");var a=r(n,sF,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];a.subscribers.forEach(function(e){sr(function(){e.apply(null,n)})})})}})}}function l1(e,n){return i7(n).from({prototype:e}),n}function l2(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function l3(e,n){e.filter=lJ(e.filter,n)}function l5(e,n,t){var a=e.replayFilter;e.replayFilter=a?()=>lJ(a(),n()):n,e.justLimit=t&&!a}function l4(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new sI.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function l6(e,n,t){let a=l4(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:a,range:e.range}})}function l8(e,n,t,a){let o=e.replayFilter?lJ(e.filter,e.replayFilter()):e.filter;if(e.or){let r={},i=(e,t,a)=>{if(!o||o(t,a,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),i5(r,s)||(r[s]=!0,n(e,t,a))}};return Promise.all([e.or._iterate(i,t),l7(l6(e,a,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return l7(l6(e,a,t),lJ(e.algorithm,o),n,!e.keysOnly&&e.valueMapper)}function l7(e,n,t,a){var o=lb(a?(e,n,o)=>t(a(e),n,o):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=sR},n=>{e.fail(n),t=sR})||o(e.value,e,e=>t=e),t()})})}function l9(e,n){try{let t=ce(e),a=ce(n);if(t!==a)return"Array"===t?1:"Array"===a?-1:"binary"===t?1:"binary"===a?-1:"string"===t?1:"string"===a?-1:"Date"===t?1:"Date"!==a?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,a=n.length,o=t<a?t:a;for(let t=0;t<o;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===a?0:t<a?-1:1}(cn(e),cn(n));case"Array":return function(e,n){let t=e.length,a=n.length,o=t<a?t:a;for(let t=0;t<o;++t){let a=l9(e[t],n[t]);if(0!==a)return a}return t===a?0:t<a?-1:1}(e,n)}}catch(e){}return NaN}function ce(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=sy(e);return"ArrayBuffer"===t?"binary":t}function cn(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class ct{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,lj.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,lj.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=lJ(n.algorithm,e)}_iterate(e,n){return l8(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&i1(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>l8(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(l2(n,!0))return t.count({trans:e,query:{index:l4(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var a=0;return l8(n,()=>(++a,!1),e,t).then(()=>a)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),a=t[0],o=t.length-1;function r(e,n){return n?r(e[t[n]],n-1):e[a]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=r(e,o),a=r(n,o);return t<a?-i:t>a?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&&l2(n,!0)&&n.limit>0){let{valueMapper:t}=n,a=l4(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:a,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return l8(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,l2(n)?l5(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):l5(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),l5(this._ctx,()=>{var n=e;return function(e,t,a){return--n<=0&&t(a),n>=0}},!0),this}until(e,n){return l3(this._ctx,function(t,a,o){return!e(t.value)||(a(o),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 l3(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=lJ(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&&l2(n,!0)&&n.limit>0)return this._read(e=>{var t=l4(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 l3(this._ctx,function(e){var n=e.primaryKey.toString(),a=i5(t,n);return t[n]=!0,!a}),this}modify(e){var n=this._ctx;return this._write(t=>{var a;if("function"==typeof e)a=e;else{var o=iQ(e),r=o.length;a=function(n){for(var t=!1,a=0;a<r;++a){var i=o[a],s=e[i];ss(n,i)!==s&&(sl(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,n)=>{let{failures:t,numFailures:a}=n;for(let n of(p+=e-a,iQ(t)))u.push(t[n])};return this.clone().primaryKeys().then(o=>{let r=u=>{let p=Math.min(c,o.length-u);return i.getMany({trans:t,keys:o.slice(u,u+p),cache:"immutable"}).then(d=>{let m=[],h=[],g=s?[]:null,y=[];for(let e=0;e<p;++e){let n=d[e],t={value:sh(n),primKey:o[u+e]};!1!==a.call(t,t.value,t)&&(null==t.value?y.push(o[u+e]):s||0===l9(l(n),l(t.value))?(h.push(t.value),s&&g.push(o[u+e])):(y.push(o[u+e]),m.push(t.value)))}let b=l2(n)&&n.limit===1/0&&("function"!=typeof e||e===ca)&&{index:n.index,range:n.range};return Promise.resolve(m.length>0&&i.mutate({trans:t,type:"add",values:m}).then(e=>{for(let n in e.failures)y.splice(parseInt(n),1);f(m.length,e)})).then(()=>(h.length>0||b&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:h,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(h.length,e))).then(()=>(y.length>0||b&&e===ca)&&i.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>o.length>u+p&&r(u+c))})};return r(0).then(()=>{if(u.length>0)throw new sP("Error modifying one or more objects",u,p,d);return o.length})})})}delete(){var e=this._ctx,n=e.range;return l2(e)&&(e.isPrimKey&&!lU||3===n.type)?this._write(t=>{let{primaryKey:a}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:a,range:n}}).then(a=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:o})=>{if(o)throw new sP("Could not delete some values",Object.keys(e).map(n=>e[n]),a-o);return a-o}))}):this.modify(ca)}}let ca=(e,n)=>n.value=null;function co(e,n){return e<n?-1:+(e!==n)}function cr(e,n){return e>n?-1:+(e!==n)}function ci(e,n,t){var a=e instanceof cp?new e.Collection(e):e;return a._ctx.error=t?new t(n):TypeError(n),a}function cs(e){return new e.Collection(e,()=>cu("")).limit(0)}function cl(e,n,t,a){var o,r,i,s,l,c,u,p=t.length;if(!t.every(e=>"string"==typeof e))return ci(e,lG);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),r="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?co:cr;var n=t.map(function(e){return{lower:r(e),upper:o(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,u="next"===e?"":a}d("next");var f=new e.Collection(e,()=>cc(s[0],l[p-1]+a));f._ondirectionchange=function(e){d(e)};var m=0;return f._addAlgorithm(function(e,t,a){var o=e.key;if("string"!=typeof o)return!1;var d=r(o);if(n(d,l,m))return!0;for(var f=null,h=m;h<p;++h){var g=function(e,n,t,a,o,r){for(var i=Math.min(e.length,a.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==a[l])return 0>o(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>o(e[l],a[l])?e.substr(0,l)+a[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>o(e[l],c)&&(s=l)}return i<a.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)+a[s]+t.substr(s+1)}(o,d,s[h],l[h],i,c);null===g&&null===f?m=h+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+u)}:a),!1}),f}function cc(e,n,t,a){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:a}}function cu(e){return{type:1,lower:e,upper:e}}class cp{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,a){t=!1!==t,a=!0===a;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||a)&&(!t||!a)?cs(this):new this.Collection(this,()=>cc(e,n,!t,!a))}catch(e){return ci(this,lW)}}equals(e){return null==e?ci(this,lW):new this.Collection(this,()=>cu(e))}above(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(e,void 0,!0))}aboveOrEqual(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(e,void 0,!1))}below(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(void 0,e,!1,!0))}belowOrEqual(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(void 0,e))}startsWith(e){return"string"!=typeof e?ci(this,lG):this.between(e,e+lF,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):cl(this,(e,n)=>0===e.indexOf(n[0]),[e],lF)}equalsIgnoreCase(e){return cl(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=s$.apply(sv,arguments);return 0===e.length?cs(this):cl(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=s$.apply(sv,arguments);return 0===e.length?cs(this):cl(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,lF)}anyOf(){let e=s$.apply(sv,arguments),n=this._cmp;try{e.sort(n)}catch(e){return ci(this,lW)}if(0===e.length)return cs(this);let t=new this.Collection(this,()=>cc(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let a=0;return t._addAlgorithm((t,o,r)=>{let i=t.key;for(;n(i,e[a])>0;)if(++a===e.length)return o(r),!1;return 0===n(i,e[a])||(o(()=>{t.continue(e[a])}),!1)}),t}notEqual(e){return this.inAnyRange([[lL,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=s$.apply(sv,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return ci(this,lW)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[lL,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,a=this._ascending,o=this._descending,r=this._min,i=this._max;if(0===e.length)return cs(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=a(e[0],e[1])))return ci(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sI.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,u=a;function p(e,n){return u(e[0],n[0])}try{(c=e.reduce(function(e,n){let a=0,o=e.length;for(;a<o;++a){let o=e[a];if(0>t(n[0],o[1])&&t(n[1],o[0])>0){o[0]=r(o[0],n[0]),o[1]=i(o[1],n[1]);break}}return a===o&&e.push(n),e},[])).sort(p)}catch(e){return ci(this,lW)}let d=0,f=l?e=>a(e,c[d][1])>0:e=>a(e,c[d][1])>=0,m=s?e=>o(e,c[d][0])>0:e=>o(e,c[d][0])>=0,h=f,g=new this.Collection(this,()=>cc(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(h=f,u=a):(h=m,u=o),c.sort(p)},g._addAlgorithm((e,n,t)=>{for(var o=e.key;h(o);)if(++d===c.length)return n(t),!1;return!!(!f(o)&&!m(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||n(()=>{u===a?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=s$.apply(sv,arguments);return e.every(e=>"string"==typeof e)?0===e.length?cs(this):this.inAnyRange(e.map(e=>[e,e+lF])):ci(this,"startsWithAnyOf() only works with strings")}}function cd(e){return lb(function(n){return cf(n),e(n.target.error),!1})}function cf(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let cm="storagemutated",ch="x-storagemutated-1",cg=l0(null,cm);class cy{_lock(){return so(!ln.global),++this._reculock,1!==this._reculock||ln.global||(ln.lockOwnerFor=this),this}_unlock(){if(so(!ln.global),0==--this._reculock)for(ln.global||(ln.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lP(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&ln.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(so(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new sI.DatabaseClosed(t);case"MissingAPIError":throw new sI.MissingAPI(t.message,t);default:throw new sI.OpenFailed(t)}if(!this.active)throw new sI.TransactionInactive;return so(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=lb(n=>{cf(n),this._reject(e.error)}),e.onabort=lb(n=>{cf(n),this.active&&this._reject(new sI.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=lb(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&cg.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return lj(new sI.ReadOnly("Transaction is readonly"));if(!this.active)return lj(new sI.TransactionInactive);if(this._locked())return new lr((a,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(a,o)},ln])});if(t)return lx(()=>{var e=new lr((e,t)=>{this._lock();let a=n(e,t,this);a&&a.then&&a.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var a=new lr((e,t)=>{var a=n(e,t,this);a&&a.then&&a.then(e,t)});return a._lib=!0,a}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=lr.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var a=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(a.get(-1/0).onsuccess=e)}()}var o=n._waitingFor;return new lr((e,a)=>{t.then(t=>n._waitingQueue.push(lb(e.bind(null,t))),e=>n._waitingQueue.push(lb(a.bind(null,e)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sI.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(i5(n,e))return n[e];let t=this.schema[e];if(!t)throw new sI.NotFound("Table "+e+" not part of transaction");let a=new this.db.Table(e,t,this);return a.core=this.db.core.table(e),n[e]=a,a}}function cb(e,n,t,a,o,r,i){return{name:e,keyPath:n,unique:t,multi:a,auto:o,compound:r,src:(t&&!i?"&":"")+(a?"*":"")+(o?"++":"")+c_(n)}}function c_(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function cv(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:si(t,e=>[e.name,e])}}let c$=e=>{try{return e.only([[]]),c$=()=>[[]],[[]]}catch(e){return c$=()=>lF,lF}};function cA(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>ss(n,e):n=>ss(n,e)}function ck(e){return[].slice.call(e)}let cw=0;function cx(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function cC({_novip:e},n){let t=n.db,a=function(e,n,{IDBKeyRange:t,indexedDB:a},o){var r;return{dbcore:(r=function(e,n,t){let a;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:a,lowerOpen:o,upperOpen:r}=e;return void 0===t?void 0===a?null:n.upperBound(a,!!r):void 0===a?n.lowerBound(t,!!o):n.bound(t,a,!!o,!!r)}let{schema:r,hasGetAll:i}=(a=ck(e.objectStoreNames),{schema:{name:e.name,tables:a.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,a=i0(n),o=null==n,r={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:a,keyPath:n,autoIncrement:t,unique:!0,extractKey:cA(n)},indexes:ck(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:a,keyPath:o}=e,i={name:n,compound:i0(o),keyPath:o,unique:t,multiEntry:a,extractKey:cA(o)};return r[cx(o)]=i,i}),getIndexByKeyPath:e=>r[cx(e)]};return r[":id"]=i.primaryKey,null!=n&&(r[cx(n)]=i.primaryKey),i})},hasGetAll:a.length>0&&"getAll"in t.objectStore(a[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:a,values:r,range:i}){return new Promise((s,l)=>{let c;s=lb(s);let u=e.objectStore(n),p=null==u.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=a||r||{length:1};if(a&&r&&a.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 m=[],h=[],g=0,y=e=>{++g,cf(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:h,results:[],lastResult:void 0});3===i.type?m.push(c=u.clear()):m.push(c=u.delete(o(i)))}else{let[e,n]=d?p?[r,a]:[r,null]:[a,null];if(d)for(let a=0;a<f;++a)m.push(c=n&&void 0!==n[a]?u[t](e[a],n[a]):u[t](e[a])),c.onerror=y;else for(let n=0;n<f;++n)m.push(c=u[t](e[n])),c.onerror=y}let b=e=>{let n=e.target.result;m.forEach((e,n)=>null!=e.error&&(h[n]=e.error)),s({numFailures:g,failures:h,results:"delete"===t?a:m.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((a,o)=>{a=lb(a);let r=e.objectStore(n),i=t.length,s=Array(i),l,c=0,u=0,p=e=>{let n=e.target;s[n._pos]=n.result,++u===c&&a(s)},d=cd(o);for(let e=0;e<i;++e)null!=t[e]&&((l=r.get(t[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&a(s)}),get:({trans:e,key:t})=>new Promise((a,o)=>{a=lb(a);let r=e.objectStore(n).get(t);r.onsuccess=e=>a(e.target.result),r.onerror=cd(o)}),query:e=>new Promise((t,a)=>{t=lb(t);let{trans:r,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=r.objectStore(n),m=p.isPrimaryKey?f:f.index(p.name),h=o(d);if(0===l)return t({result:[]});if(i){let e=s?m.getAll(h,u):m.getAllKeys(h,u);e.onsuccess=e=>t({result:e.target.result}),e.onerror=cd(a)}else{let e=0,n=!s&&"openKeyCursor"in m?m.openKeyCursor(h):m.openCursor(h),o=[];n.onsuccess=a=>{let r=n.result;return r?(o.push(s?r.value:r.primaryKey),++e===l?t({result:o}):void r.continue()):t({result:o})},n.onerror=cd(a)}}),openCursor:function({trans:e,values:t,query:a,reverse:r,unique:i}){return new Promise((s,l)=>{s=lb(s);let{index:c,range:u}=a,p=e.objectStore(n),d=c.isPrimaryKey?p:p.index(c.name),f=r?i?"prevunique":"prev":i?"nextunique":"next",m=!t&&"openKeyCursor"in d?d.openKeyCursor(o(u),f):d.openCursor(o(u),f);m.onerror=cd(l),m.onsuccess=lb(n=>{let t=m.result;if(!t)return void s(null);t.___id=++cw,t.done=!1;let a=t.continue.bind(t),o=t.continuePrimaryKey;o&&(o=o.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=lb(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=lb(e),m.onerror=cd(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(m.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return m.onsuccess=lb(e=>{m.onsuccess=s,s()}),t.continue=a,t.continuePrimaryKey=o,t.advance=r,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:a,range:r}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=a.isPrimaryKey?s:s.index(a.name),c=o(r),u=c?l.count(c):l.count();u.onsuccess=lb(n=>e(n.target.result)),u.onerror=cd(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:c$(n),schema:r}}(n,t,o),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),r))}}(e._middlewares,t,e._deps,n);e.core=a.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 cE({_novip:e},n,t,a){t.forEach(t=>{let o=a[t];n.forEach(n=>{let a=se(n,t);(!a||"value"in a&&void 0===a.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?i8(n,t,{get(){return this.table(t)},set(e){i6(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,o))})})}function cS({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function cD(e,n){return e._cfg.version-n._cfg.version}function cM(e,n){let t,a={del:[],add:[],change:[]};for(t in e)n[t]||a.del.push(t);for(t in n){let o=e[t],r=n[t];if(o){let e={name:t,def:r,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(r.primKey.keyPath||"")&&(o.primKey.auto===r.primKey.auto||lU)){let n,t=o.idxByName,i=r.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let a=t[n],o=i[n];a?a.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&a.change.push(e)}else e.recreate=!0,a.change.push(e)}else a.add.push([t,r])}return a}function cz(e,n,t,a){let o=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return a.forEach(e=>cO(o,e)),o}function cO(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function cP(e,n,t){let a={};return st(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),o=n.keyPath,r=cb(c_(o),o||"",!1,!1,!!n.autoIncrement,o&&"string"!=typeof o,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);o=t.keyPath;var s=cb(t.name,o,!!t.unique,!!t.multiEntry,!1,o&&"string"!=typeof o,!1);i.push(s)}a[e]=cv(e,r,i)}),a}function cT({_novip:e},n,t){let a=t.db.objectStoreNames;for(let o=0;o<a.length;++o){let r=a[o],i=t.objectStore(r);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],a=i.index(t).keyPath,o="string"==typeof a?a:"["+st(a).join("+")+"]";if(n[r]){let e=n[r].idxByName[o];e&&(e.name=t,delete n[r].idxByName[o],n[r].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&iX.WorkerGlobalScope&&iX instanceof iX.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class cB{_parseStoresSpec(e,n){iQ(e).forEach(t=>{if(null!==e[t]){var a=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),a=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return cb(t,a||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),i0(a),0===n)}),o=a.shift();if(o.multi)throw new sI.Schema("Primary key cannot be multi-valued");a.forEach(e=>{if(e.auto)throw new sI.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sI.Schema("Index must have a name and cannot be an empty string")}),n[t]=cv(t,o,a)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?i1(this._cfg.storesSource,e):e;let t=n._versions,a={},o={};return t.forEach(e=>{i1(a,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(a,o)}),n._dbSchema=o,cS(n,[n._allTables,n,n.Transaction.prototype]),cE(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],iQ(o),o),n._storeNames=iQ(o),this}upgrade(e){return this._cfg.contentUpgrade=sH(this._cfg.contentUpgrade||sR,e),this}}function cI(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new c1(lH,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function cN(e){return e&&"function"==typeof e.databases}function cj(e){return lx(function(){return ln.letThrough=!0,e()})}function cR(e){var n=n=>e.next(n),t=o(n),a=o(n=>e.throw(n));function o(e){return n=>{var o=e(n),r=o.value;return o.done?r:r&&"function"==typeof r.then?r.then(t,a):i0(r)?Promise.all(r).then(t,a):t(r)}}return o(n)()}function cF(e,n,t){var a=arguments.length;if(a<2)throw new sI.InvalidArgument("Too few arguments");for(var o=Array(a-1);--a;)o[a-1]=arguments[a];return t=o.pop(),[e,sp(o),t]}function cL(e,n,t){let a=i0(e)?e.slice():[e];for(let e=0;e<t;++e)a.push(n);return a}let cW={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:a}=t,o={},r=[];function i(e,n,t){let a=cx(e),s=o[a]=o[a]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,u={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:cA(e),unique:!c&&t.unique};return s.push(u),u.isPrimaryKey||r.push(u),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),u}let s=i(a.primaryKey.keyPath,0,a.primaryKey);for(let e of(o[":id"]=[s],a.indexes))i(e.keyPath,0,e);function l(n){var t,a;let o=n.query.index;return o.isVirtual?{...n,query:{index:o,range:(t=n.query.range,a=o.keyTail,{type:1===t.type?2:t.type,lower:cL(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,a),lowerOpen:!0,upper:cL(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,a),upperOpen:!0})}}:n}return{...t,schema:{...a,primaryKey:s,indexes:r,getIndexByKeyPath:function(e){let n=o[cx(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:a,isVirtual:o,keyLength:r}=n.query.index;return o?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(o){null!=o?t.continue(cL(o,n.reverse?e.MAX_KEY:e.MIN_KEY,a)):n.unique?t.continue(t.key.slice(0,r).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,a)):t.continue()}},continuePrimaryKey:{value(n,o){t.continuePrimaryKey(cL(n,e.MAX_KEY,a),o)}},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 cG(e,n,t,a){return t=t||{},a=a||"",iQ(e).forEach(o=>{if(i5(n,o)){var r=e[o],i=n[o];if("object"==typeof r&&"object"==typeof i&&r&&i){let e=sy(r);e!==sy(i)?t[a+o]=n[o]:"Object"===e?cG(r,i,t,a+o+"."):r!==i&&(t[a+o]=n[o])}else r!==i&&(t[a+o]=n[o])}else t[a+o]=void 0}),iQ(n).forEach(o=>{i5(e,o)||(t[a+o]=n[o])}),t}let cV={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:a}=t.schema;return{...t,mutate(e){let o=ln.trans,{deleting:r,creating:i,updating:s}=o.table(n).hook;switch(e.type){case"add":if(i.fire===sR)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===sR&&s.fire===sR)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(r.fire===sR)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(r.fire===sR)break;return o._promise("readwrite",()=>(function e(n,o,r){return t.query({trans:n,values:!1,query:{index:a,range:o},limit:r}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(a=>a.numFailures>0?Promise.reject(a.failures[0]):t.length<r?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...o,lower:t[t.length-1],lowerOpen:!0},r)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,o;let l=ln.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(a.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"===(o=e).type?Promise.resolve([]):t.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(n=>{let o=c.map((t,o)=>{let c=n[o],u={onerror:null,onsuccess:null};if("delete"===e.type)r.fire.call(u,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(u,t,e.values[o],l);null==t&&null!=n&&(t=n,e.keys[o]=t,a.outbound||sl(e.values[o],a.keyPath,t))}else{let n=cG(c,e.values[o]),a=s.fire.call(u,n,t,c,l);if(a){let n=e.values[o];Object.keys(a).forEach(e=>{i5(n,e)?n[e]=a[e]:sl(n,e,a[e])})}}return u});return t.mutate(e).then(({failures:t,results:a,numFailures:r,lastResult:i})=>{for(let r=0;r<c.length;++r){let i=a?a[r]:c[r],s=o[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:a,numFailures:r,lastResult:i}}).catch(e=>(o.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cU(e,n,t){try{if(!n||n.keys.length<e.length)return null;let a=[];for(let o=0,r=0;o<n.keys.length&&r<e.length;++o)0===l9(n.keys[o],e[r])&&(a.push(t?sh(n.values[o]):n.values[o]),++r);return a.length===e.length?a:null}catch(e){return null}}let cq={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=cU(e.keys,e.trans._cache,"clone"===e.cache);return n?lr.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sh(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cH(e){return!("from"in e)}let cK=function(e,n){if(!this){let n=new cK;return e&&"d"in e&&i1(n,e),n}i1(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function cY(e,n,t){let a=l9(n,t);if(isNaN(a))return;if(a>0)throw RangeError();if(cH(e))return i1(e,{from:n,to:t,d:1});let o=e.l,r=e.r;if(0>l9(t,e.from))return o?cY(o,n,t):e.l={from:n,to:t,d:1,l:null,r:null},cX(e);if(l9(n,e.to)>0)return r?cY(r,n,t):e.r={from:n,to:t,d:1,l:null,r:null},cX(e);0>l9(n,e.from)&&(e.from=n,e.l=null,e.d=r?r.d+1:1),l9(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;o&&!e.l&&cJ(e,o),r&&i&&cJ(e,r)}function cJ(e,n){cH(n)||function e(n,{from:t,to:a,l:o,r:r}){cY(n,t,a),o&&e(n,o),r&&e(n,r)}(e,n)}function cZ(e){let n=cH(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>l9(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>=l9(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 cX(e){var n,t;let a=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),o=a>1?"r":a<-1?"l":"";if(o){let n="r"===o?"l":"r",t={...e},a=e[o];e.from=a.from,e.to=a.to,e[o]=a[o],t[o]=a[n],e[n]=t,t.d=cQ(t)}e.d=cQ(e)}function cQ({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}i4(cK.prototype,{add(e){return cJ(this,e),this},addKey(e){return cY(this,e,e),this},addKeys(e){return e.forEach(e=>cY(this,e,e)),this},[sb](){return cZ(this)}});let c0={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new cK(e.MIN_KEY,e.MAX_KEY);return{...e,table:a=>{let o=e.table(a),{schema:r}=o,{primaryKey:i}=r,{extractKey:s,outbound:l}=i,c={...o,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${a}/${e}`;return s[t]||(s[t]=new cK)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],m=e.trans._cache;return o.mutate(e).then(e=>{if(i0(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let n=cU(d,m);n||"add"===p||u.addKeys(d),(n||f)&&r.indexes.forEach(function(e){let t=l(e.name||"");function a(n){return null!=n?e.extractKey(n):null}let o=n=>e.multiEntry&&i0(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let r=n&&a(n[t]),i=f&&a(f[t]);0!==l9(r,i)&&(null!=r&&o(r),null!=i&&o(i))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(t),u.add(t),r.indexes.forEach(e=>l(e.name).add(t));return e})}},u=({query:{index:n,range:t}})=>{var a,o;return[n,new cK(null!=(a=t.lower)?a:e.MIN_KEY,null!=(o=t.upper)?o:e.MAX_KEY)]},p={get:e=>[i,new cK(e.key)],getMany:e=>[i,(new cK).addKeys(e.keys)],count:u,query:u,openCursor:u};return iQ(p).forEach(e=>{c[e]=function(r){let{subscr:i}=ln;if(i){let c=e=>{let t=`idb://${n}/${a}/${e}`;return i[t]||(i[t]=new cK)},u=c(""),d=c(":dels"),[f,m]=p[e](r);if(c(f.name||"").add(m),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&r.values&&o.query({...r,values:!1});return o[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&r.values)return n.then(({result:e})=>(u.addKeys(e),t));let e=r.values?t.result.map(s):t.result;r.values?u.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&&u.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return o[e].apply(this,arguments)}}),c}}}};class c1{constructor(e,n){var t;this._middlewares={},this.verno=0;const a=c1.dependencies;this._options=n={addons:c1.addons,autoOpen:!0,indexedDB:a.indexedDB,IDBKeyRange:a.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=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:sR,dbReadyPromise:null,cancelOpen:sR,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};r.dbReadyPromise=new lr(e=>{r.dbReadyResolve=e}),r.openCanceller=new lr((e,n)=>{r.cancelOpen=n}),this._state=r,this.name=e,this.on=l0(this,"populate","blocked","versionchange","close",{ready:[sH,sR]}),this.on.ready.subscribe=sa(this.on.ready.subscribe,e=>(n,t)=>{c1.vip(()=>{let a=this._state;if(a.openComplete)a.dbOpenError||lr.resolve().then(n),t&&e(n);else if(a.onReadyBeingFired)a.onReadyBeingFired.push(n),t&&e(n);else{e(n);let a=this;t||e(function e(){a.on.ready.unsubscribe(n),a.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,l1(ct.prototype,function(e,n){this.db=t;let a=lZ,o=null;if(n)try{a=n()}catch(e){o=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:a,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:r.or,valueMapper:s!==sF?s:null}})),this.Table=function(e){return l1(lQ.prototype,function(n,t,a){this.db=e,this._tx=a,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:l0(null,{creating:[sG,sR],reading:[sL,sF],updating:[sU,sR],deleting:[sV,sR]})})}(this),this.Transaction=function(e){return l1(cy.prototype,function(n,t,a,o,r){this.db=e,this.mode=n,this.storeNames=t,this.schema=a,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=l0(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 lr((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(),lj(e)})})}(this),this.Version=function(e){return l1(cB.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return l1(cp.prototype,function(n,t,a){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:a};let o=e._deps.indexedDB;if(!o)throw new sI.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,n)=>o.cmp(n,e),this._max=(e,n)=>o.cmp(e,n)>0?e:n,this._min=(e,n)=>0>o.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=c$(n.IDBKeyRange),this._createTransaction=(e,n,t,a)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,a),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lV.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(cW),this.use(cV),this.use(c0),this.use(cq),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sI.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sI.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(cD),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ln.letThrough||this._vip)?e():new lr((e,n)=>{if(this._state.openComplete)return n(new sI.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new sI.DatabaseClosed);this.open().catch(sR)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:a}){a&&this.unuse({stack:e,name:a});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:n,level:null==t?10:t,name:a}),o.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:a}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?lj(t.dbOpenError):e);sk&&(t.openCanceller._stackHolder=sC()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let o=t.openCanceller;function r(){if(t.openCanceller!==o)throw new sI.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1;return lr.race([o,("u"<typeof navigator?lr.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(()=>new lr((n,o)=>{if(r(),!a)throw new sI.MissingAPI;let i=e.name,c=t.autoSchema?a.open(i):a.open(i,Math.round(10*e.verno));if(!c)throw new sI.MissingAPI;c.onerror=cd(o),c.onblocked=lb(e._fireOnBlocked),c.onupgradeneeded=lb(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=cf,s.abort(),c.result.close();let e=a.deleteDatabase(i);e.onsuccess=e.onerror=lb(()=>{o(new sI.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,a,i,d;s.onerror=cd(o);var r,u,p=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=p<1,e._novip.idbdb=c.result,r=p/10,u=s,t=e._dbSchema,(a=e._createTransaction("readwrite",e._storeNames,t)).create(u),a._completion.catch(o),i=a._reject.bind(a),d=ln.transless||ln,lx(()=>{ln.trans=a,ln.transless=d,0===r?(iQ(t).forEach(e=>{cz(u,e,t[e].primKey,t[e].indexes)}),cC(e,u),lr.follow(()=>e.on.populate.fire(a)).catch(i)):(function({_novip:e},n,t,a){let o=[],r=e._versions,i=e._dbSchema=cP(e,e.idbdb,a),s=!1;return r.filter(e=>e._cfg.version>=n).forEach(r=>{o.push(()=>{let o=i,l=r._cfg.dbschema;cT(e,o,a),cT(e,l,a),i=e._dbSchema=l;let c=cM(o,l);c.add.forEach(e=>{cz(a,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new sI.Upgrade("Not yet support for changing primary key");{let n=a.objectStore(e.name);e.add.forEach(e=>cO(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),cO(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let u=r._cfg.contentUpgrade;if(u&&r._cfg.version>n){let n;cC(e,a),t._memoizedTables={},s=!0;let r=sc(l);c.del.forEach(e=>{r[e]=o[e]}),cS(e,[e.Transaction.prototype]),cE(e,[e.Transaction.prototype],iQ(r),r),t.schema=r;let i=sA(u);i&&lC();let p=lr.follow(()=>{if((n=u(t))&&i){var e=lE.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?lr.resolve(n):p.then(()=>n)}}),o.push(n=>{var a;s&&lU||(a=r._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==a[e]&&n.db.deleteObjectStore(e))),cS(e,[e.Transaction.prototype]),cE(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return o.length?lr.resolve(o.shift()(t.idbtrans)).then(e):lr.resolve()})().then(()=>{var e;iQ(e=i).forEach(n=>{a.db.objectStoreNames.contains(n)||cz(a,n,e[n].primKey,e[n].indexes)})})})(e,r,a,u).catch(i)})}},o),c.onsuccess=lb(()=>{s=null;let a=e._novip.idbdb=c.result,o=st(a.objectStoreNames);if(o.length>0)try{let n,r=a.transaction(1===o.length?o[0]:o,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let a=e._dbSchema=cP(0,n,t);e._storeNames=st(n.objectStoreNames,0),cE(e,[e._allTables],iQ(a),a)}(e,a,r):(cT(e,e._dbSchema,r),((n=cM(cP(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.")),cC(e,r)}catch(e){}lV.push(e),a.onversionchange=lb(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),a.onclose=lb(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){cN(e)||t===lH||cI(e,n).put({name:t}).catch(sR)}(e._deps,i),n()},o)}))]).then(()=>(r(),t.onReadyBeingFired=[],lr.resolve(cj(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let a=t.onReadyBeingFired.reduce(sH,sR);return t.onReadyBeingFired=[],lr.resolve(cj(()=>a(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 o===t.openCanceller&&e._close(),lj(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=lV.indexOf(this);if(n>=0&&lV.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new lr(n=>{e.dbReadyResolve=n}),e.openCanceller=new lr((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sI.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new lr((t,a)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lb(()=>{!function({indexedDB:e,IDBKeyRange:n},t){cN(e)||t===lH||cI(e,n).delete(t).catch(sR)}(this._deps,this.name),t()}),e.onerror=cd(a),e.onblocked=this._fireOnBlocked};if(e)throw new sI.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(o):o()})}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 iQ(this._allTables).map(e=>this._allTables[e])}transaction(){let e=cF.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let a,o,r=ln.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=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===lK)a=lK;else{if("rw"!=e&&e!=lY)throw new sI.InvalidArgument("Invalid transaction mode: "+e);a=lY}if(r){if(r.mode===lK&&a===lY){if(!i)throw new sI.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&o.forEach(e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!i)throw new sI.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)}):lj(e)}let s=(function e(n,t,a,o,r){return lr.resolve().then(()=>{let i,s=ln.transless||ln,l=n._createTransaction(t,a,n._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===sB.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,a,null,r))):lj(o)}let c=sA(r);c&&lC();let u=lr.follow(()=>{if(i=r.call(l,l))if(c){var e=lE.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=cR(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?lr.resolve(i).then(e=>l.active?e:lj(new sI.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>i)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),lj(e)))})}).bind(null,this,a,o,r,t);return r?r._promise(a,s,"lock"):ln.trans?lP(ln.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!i5(this._allTables,e))throw new sI.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let c2="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class c3{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[c2](){return this}}function c5(e,n){return iQ(n).forEach(t=>{cJ(e[t]||(e[t]=new cK),n[t])}),e}try{r={indexedDB:iX.indexedDB||iX.mozIndexedDB||iX.webkitIndexedDB||iX.msIndexedDB,IDBKeyRange:iX.IDBKeyRange||iX.webkitIDBKeyRange}}catch(e){r={indexedDB:null,IDBKeyRange:null}}function c4(e){let n=c6;try{c6=!0,cg.storagemutated.fire(e)}finally{c6=n}}i4(c1,{...sj,delete:e=>new c1(e,{addons:[]}).delete(),exists:e=>new c1(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return cN(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lH)):cI(e,n).toCollection().primaryKeys()})(c1.dependencies).then(e)}catch(e){return lj(new sI.MissingAPI)}},defineClass:()=>function(e){i1(this,e)},ignoreTransaction:e=>ln.trans?lP(ln.transless,e):e(),vip:cj,async:function(e){return function(){try{var n=cR(e.apply(this,arguments));return n&&"function"==typeof n.then?n:lr.resolve(n)}catch(e){return lj(e)}}},spawn:function(e,n,t){try{var a=cR(e.apply(t,n||[]));return a&&"function"==typeof a.then?a:lr.resolve(a)}catch(e){return lj(e)}},currentTransaction:{get:()=>ln.trans||null},waitFor:function(e,n){let t=lr.resolve("function"==typeof e?c1.ignoreTransaction(e):e).timeout(n||6e4);return ln.trans?ln.trans.waitFor(t):t},Promise:lr,debug:{get:()=>sk,set:e=>{sk=e,sw="dexie"===e?()=>!0:lq}},derive:i7,extend:i1,props:i4,override:sa,Events:l0,on:cg,liveQuery:function(e){let n,t=!1,a=new c3(a=>{let o=sA(e),r=!1,i={},s={},l={get closed(){return r},unsubscribe:()=>{r=!0,cg.storagemutated.unsubscribe(d)}};a.start&&a.start(l);let c=!1,u=!1;function p(){return iQ(s).some(e=>i[e]&&function(e,n){let t=cZ(n),a=t.next();if(a.done)return!1;let o=a.value,r=cZ(e),i=r.next(o.from),s=i.value;for(;!a.done&&!i.done;){if(0>=l9(s.from,o.to)&&l9(s.to,o.from)>=0)return!0;0>l9(o.from,s.from)?o=(a=t.next(s.from)).value:s=(i=r.next(o.from)).value}return!1}(i[e],s[e]))}let d=e=>{c5(i,e),p()&&f()},f=()=>{let m,h;if(c||r)return;i={};let g={},y=(o&&lC(),m=()=>lx(e,{subscr:g,trans:null}),h=ln.trans?lP(ln.transless,m):m(),o&&h.then(lE,lE),h);u||(cg(cm,d),u=!0),c=!0,Promise.resolve(y).then(e=>{t=!0,n=e,c=!1,r||(p()?f():(i={},s=g,a.next&&a.next(e)))},e=>{c=!1,t=!1,a.error&&a.error(e),l.unsubscribe()})};return f(),l});return a.hasValue=()=>t,a.getValue=()=>n,a},extendObservabilitySet:c5,getByKeyPath:ss,setByKeyPath:sl,delByKeyPath:function(e,n){"string"==typeof n?sl(e,n,void 0):"length"in n&&[].map.call(n,function(n){sl(e,n,void 0)})},shallowClone:sc,deepClone:sh,getObjectDiff:cG,cmp:l9,asap:sr,minKey:lL,addons:[],connections:lV,errnames:sB,dependencies:r,semVer:lR,version:lR.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),c1.maxKey=c$(c1.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(cg(cm,e=>{if(!c6){let n;lU?(n=document.createEvent("CustomEvent")).initCustomEvent(ch,!0,!0,e):n=new CustomEvent(ch,{detail:e}),c6=!0,dispatchEvent(n),c6=!1}}),addEventListener(ch,({detail:e})=>{c6||c4(e)}));let c6=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(ch);"function"==typeof e.unref&&e.unref(),cg(cm,n=>{c6||e.postMessage(n)}),e.onmessage=e=>{e.data&&c4(e.data)}}else if("u">typeof self&&"u">typeof navigator){cg(cm,e=>{try{c6||("u">typeof localStorage&&localStorage.setItem(ch,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:ch,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===ch){let n=JSON.parse(e.newValue);n&&c4(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===ch&&c4(e.changedParts)})}function c8(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}lr.rejectionMapper=function(e,n){if(!e||e instanceof sz||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sN[e.name])return e;var t=new sN[e.name](n||e.message,e);return"stack"in e&&i8(t,"stack",{get:function(){return this.inner.stack}}),t},sw=lq;class c7 extends c1{constructor(){super("EsmOffline"),c8(this,"syncQueue",void 0),c8(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 c9(){return new c7}let ue=new c7,un={},ut=U("offline-synchronization",{});function ua(){return ut}async function uo(){if(ut.getState().synchronization)return;let e=await ue.syncQueue.count(),n={},t=Object.entries(un),a=t.length,o={},r=new AbortController,i=()=>{let e=ut.getState().synchronization;ut.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{ut.setState({synchronization:{totalCount:e,pendingCount:e,abortController:r}});for(let e=0;e<a&&t.length>0;e++)for(let e=t.length;e--;){let[a,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(o[a]={},await Promise.all(l),n[a]=ur(s,o,r,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{ut.setState({synchronization:void 0})}}async function ur({type:e,dependsOn:n,process:t},a,o,r){let i=[],s=[],l=await ui();await ue.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[u,p,{id:d,dependencies:f=[]}]=i[c];try{let r=await t(p,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?a[t][e]:void 0)});void 0!==d&&(a[e][d]=r),await ue.syncQueue.delete(u)}catch(e){await ue.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{r()}}}async function ui(){let e=await oq();return e?.uuid||"*"}async function us(e,n,t,a){let o=a&&a.id;return void 0!==o&&await ue.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(c1.errnames.DatabaseClosed),await ue.syncQueue.add({type:n,content:t,userId:e,descriptor:a||{},createdOn:new Date}).catch(c1.errnames.DatabaseClosed,()=>-1)}async function ul(e,n,t){let a=await ui();return await us(a,e,n,t)}async function uc(e,n){return(await uu(e,n)).map(e=>e.content)}async function uu(e,n){return await ue.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(c1.errnames.DatabaseClosed,()=>[])}async function up(e){let n=await ui();return await uc(n,e)}async function ud(e){let n=await ui();return await uu(n,e)}async function uf(e){return await ue.syncQueue.get(e).catch(c1.errnames.DatabaseClosed,()=>void 0)}function um(e){return!!un[e]?.options.onBeginEditSyncItem}async function uh(e){let n=await uf(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=un[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 ug(e){await ue.syncQueue.delete(e).catch(c1.errnames.DatabaseClosed)}function uy(e,n,t,a={}){un[e]={type:e,dependsOn:n,process:t,options:a}}let ub="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),u_=new Uint8Array(16),uv=[];for(let e=0;e<256;++e)uv.push((e+256).toString(16).slice(1));let u$=function(e,n,t){if(ub&&!n&&!e)return ub();let a=(e=e||{}).random||(e.rng||function(){if(!i&&!(i="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 i(u_)})();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=a[e];return n}return function(e,n=0){return uv[e[n+0]]+uv[e[n+1]]+uv[e[n+2]]+uv[e[n+3]]+"-"+uv[e[n+4]]+uv[e[n+5]]+"-"+uv[e[n+6]]+uv[e[n+7]]+"-"+uv[e[n+8]]+uv[e[n+9]]+"-"+uv[e[n+10]]+uv[e[n+11]]+uv[e[n+12]]+uv[e[n+13]]+uv[e[n+14]]+uv[e[n+15]]}(a)},uA="OFFLINE+";function uk(){return uA+u$()}function uw(e){return e.startsWith(uA)}let ux={};function uC(){return Object.values(ux)}function uE(e){ux[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.`),ux[e.id]=e}async function uS(e){let n=await uI();return await uD(n,e)}async function uD(e,n){let t=new c7;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(c1.errnames.DatabaseClosed,()=>[])}async function uM(e,n){let t=await uI();return await uz(t,e,n)}async function uz(e,n,t){let a=new c7,o=await a.dynamicOfflineData.get({type:n,identifier:t}).catch(c1.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await a.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(c1.errnames.DatabaseClosed):await a.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(c1.errnames.DatabaseClosed)}async function uO(e,n){let t=await uI();return await uP(t,e,n)}async function uP(e,n,t){let a=new c7,o=await a.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(c1.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await a.dynamicOfflineData.update(o.id,{users:o.users.filter(n=>n!==e)}).catch(c1.errnames.DatabaseClosed):await a.dynamicOfflineData.delete(o.id).catch(c1.errnames.DatabaseClosed))}async function uT(e,n){let t=await uS(e);await Promise.all(t.map(async e=>uB(e.type,e.identifier,n)))}async function uB(e,n,t){await uM(e,n);let a=new c7,o=await uI(),r=await a.dynamicOfflineData.get({type:e,identifier:n}).catch(c1.errnames.DatabaseClosed,()=>void 0),i=uC().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),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:u};r.id&&await a.dynamicOfflineData.update(r.id,{syncState:p}).catch(c1.errnames.DatabaseClosed)}async function uI(){let e=(await oq()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let uN=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function uj(){return uL(),uN}function uR(e,n){uL(),uE({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 uF(e){uL(),await uB("patient",e)}function uL(){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 uW(e,n,t=!0){if(e){let a=null,[o,r]=await Promise.all([oB(`${oO}/Patient/${e}`,n).catch(e=>a=e),t?uG(e):Promise.resolve(null)]);if(o.ok)return o.data;if(r)return r;if(a)throw a}return null}async function uG(e){let n=(await up("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function uV(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function uU(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 uq=t(56170);function uH(e){return{uuid:e.uuid,display:e.display}}function uK(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let a=t.toString();return oI(`${oz}/location${a?"?"+a:""}`).pipe((0,uq.map)(e=>e.data.results.map(uH))).pipe((0,uq.take)(1))}function uY(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uJ(){return oI(`${oz}/visittype`).pipe((0,uq.map)(e=>e.data.results.map(uY))).pipe((0,uq.take)(1))}var uZ=((en={}).NEWVISIT="startVisit",en.EDITVISIT="editVisit",en.LOADING="loadingVisit",en),uX=((et={}).NOTSTARTED="notStarted",et.ONGOING="ongoing",et);let uQ="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))",u0=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function u1(){return H("visit",u0)}function u2(e,n){u1().setState({patientUuid:e,manuallySetVisitUuid:n})}function u3(e,n){return oB(`${oz}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function u5(e,n,t){return oB(`${oz}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function u4(e,n,t){return oB(`${oz}/visit?patient=${e}&v=${t??uQ}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}u1().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let u6=new er.BehaviorSubject(null);class u8{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+u8.version}static addUnaryOp(e){return u8.max_unop_len=Math.max(e.length,u8.max_unop_len),u8.unary_ops[e]=1,u8}static addBinaryOp(e,n,t){return u8.max_binop_len=Math.max(e.length,u8.max_binop_len),u8.binary_ops[e]=n,t?u8.right_associative.add(e):u8.right_associative.delete(e),u8}static addIdentifierChar(e){return u8.additional_identifier_chars.add(e),u8}static addLiteral(e,n){return u8.literals[e]=n,u8}static removeUnaryOp(e){return delete u8.unary_ops[e],e.length===u8.max_unop_len&&(u8.max_unop_len=u8.getMaxKeyLen(u8.unary_ops)),u8}static removeAllUnaryOps(){return u8.unary_ops={},u8.max_unop_len=0,u8}static removeIdentifierChar(e){return u8.additional_identifier_chars.delete(e),u8}static removeBinaryOp(e){return delete u8.binary_ops[e],e.length===u8.max_binop_len&&(u8.max_binop_len=u8.getMaxKeyLen(u8.binary_ops)),u8.right_associative.delete(e),u8}static removeAllBinaryOps(){return u8.binary_ops={},u8.max_binop_len=0,u8}static removeLiteral(e){return delete u8.literals[e],u8}static removeAllLiterals(){return u8.literals={},u8}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 u8(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 u8.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!u8.binary_ops[String.fromCharCode(e)]||u8.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return u8.isIdentifierStart(e)||u8.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(u8.hooks[e]){let t={context:this,node:n};return u8.hooks.run(e,t),t.node}return n}searchHook(e){if(u8.hooks[e]){let n={context:this};return u8.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===u8.SPACE_CODE||e===u8.TAB_CODE||e===u8.LF_CODE||e===u8.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:u8.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,a;for(;this.index<this.expr.length;)if((t=this.code)===u8.SEMCOL_CODE||t===u8.COMMA_CODE)this.index++;else if(a=this.gobbleExpression())n.push(a);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,u8.max_binop_len),n=e.length;for(;n>0;){if(u8.binary_ops.hasOwnProperty(e)&&(!u8.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!u8.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,a,o,r,i,s,l;if(!(r=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return r;for(o={value:n,prec:u8.binaryPrecedence(n),right_a:u8.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),a=[r,o,i];n=this.gobbleBinaryOp();){if(0===(t=u8.binaryPrecedence(n))){this.index-=n.length;break}o={value:n,prec:t,right_a:u8.right_associative.has(n)},l=n;let s=e=>o.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;a.length>2&&s(a[a.length-2]);)i=a.pop(),n=a.pop().value,r=a.pop(),e={type:u8.BINARY_EXP,operator:n,left:r,right:i},a.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),a.push(o,e)}for(s=a.length-1,e=a[s];s>1;)e={type:u8.BINARY_EXP,operator:a[s-1].value,left:a[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,a;if(this.gobbleSpaces(),a=this.searchHook("gobble-token"))return this.runHook("after-token",a);if(e=this.code,u8.isDecimalDigit(e)||e===u8.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===u8.SQUOTE_CODE||e===u8.DQUOTE_CODE)a=this.gobbleStringLiteral();else if(e===u8.OBRACK_CODE)a=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,u8.max_unop_len)).length;t>0;){if(u8.unary_ops.hasOwnProperty(n)&&(!u8.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!u8.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:u8.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}u8.isIdentifierStart(e)?(a=this.gobbleIdentifier(),u8.literals.hasOwnProperty(a.name)?a={type:u8.LITERAL,value:u8.literals[a.name],raw:a.name}:a.name===u8.this_str&&(a={type:u8.THIS_EXP})):e===u8.OPAREN_CODE&&(a=this.gobbleGroup())}return a?(a=this.gobbleTokenProperty(a),this.runHook("after-token",a)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===u8.PERIOD_CODE||n===u8.OBRACK_CODE||n===u8.OPAREN_CODE||n===u8.QUMARK_CODE;){let t;if(n===u8.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==u8.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===u8.OBRACK_CODE?((e={type:u8.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==u8.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===u8.OPAREN_CODE?e={type:u8.CALL_EXP,arguments:this.gobbleArguments(u8.CPAREN_CODE),callee:e}:(n===u8.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:u8.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(;u8.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===u8.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);u8.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++));u8.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);u8.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,u8.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===u8.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===u8.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:u8.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),a=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){a=!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 a||this.throwError('Unclosed quote after "'+e+'"'),{type:u8.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(u8.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,u8.isIdentifierPart(e))this.index++;else break;return{type:u8.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,a=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){t=!0,this.index++,e===u8.CPAREN_CODE&&a&&a>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===u8.COMMA_CODE){if(this.index++,++a!==n.length){if(e===u8.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===u8.CBRACK_CODE)for(let e=n.length;e<a;e++)n.push(null)}}else if(n.length!==a&&0!==a)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==u8.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(u8.CPAREN_CODE);if(this.code===u8.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:u8.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:u8.ARRAY_EXP,elements:this.gobbleArguments(u8.CBRACK_CODE)}}}Object.assign(u8,{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)})}}(u8),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"}),u8.max_unop_len=u8.getMaxKeyLen(u8.unary_ops),u8.max_binop_len=u8.getMaxKeyLen(u8.binary_ops);let u7=e=>new u8(e).parse(),u9=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(u8).filter(e=>!u9.includes(e)&&void 0===u7[e]).forEach(e=>{u7[e]=u8[e]}),u7.Jsep=u8,u7.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,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:a,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let a=t;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;n.node.test=a.right,a.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let pe="ArrowFunctionExpression",pn={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)}},pt={...pn,Promise};function pa(e,n={}){return pc(e,n,pd)}async function po(e,n={}){return pu(e,n,pd)}function pr(e,n={}){return pc(e,n,pf)}function pi(e,n={}){return pu(e,n,pf)}function ps(e,n={}){return pc(e,n,pm)}function pl(e,n={}){return pu(e,n,pm)}function pc(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 a=py(n,pn),o=ph("string"==typeof e?u7(e):e,a);if(t(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function pu(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 a=py(n,pt);return Promise.resolve(ph("string"==typeof e?u7(e):e,a)).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 pp(e){return u7(e)}function pd(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function pf(e){return"boolean"==typeof e}function pm(e){return"number"==typeof e}function ph(e,n){switch(e.type){case"UnaryExpression":var t,a,o,r,i,s,l,c,u,p,d,f,m=e,h=n;let g=ph(m.argument,h);switch(m.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${m.operator}''`}case"BinaryExpression":var y=e,b=n;let v=ph(y.left,b),$=ph(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,a=n,ph(t.test,a)?ph(t.consequent,a):ph(t.alternate,a);case"CallExpression":var A=e,k=n;let w=A.arguments?.map(pb(k)),x=ph(A.callee,k);if(x){if("function"!=typeof x)throw`${pv(A.callee)} is not a function`}else throw`No function named ${pv(A.callee)} is defined in this context`;return x(...w);case"ArrowFunctionExpression":let C;return o=e,r=n,C=o.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,a)=>{let o=e[a];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}(o)&&n.push([t,o]),n},[]));return ph(o.body,r.addVariables(n))}).bind(r.thisObj??null);case"MemberExpression":return function(e,n){let t,a=ph(e.object,n);if(void 0===a)switch(e.object.type){case"Identifier":{let t=pg(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=pg(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 o=a;if("string"==typeof a)o=String.prototype;else if("number"==typeof a)o=Number.prototype;else if("function"==typeof a);else if("object"!=typeof a)throw`VisitMemberExpression does not support member access on type ${typeof a}`;switch(n.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":t=ph(e.property,n);break;default:{let o=ph(e.property,n);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};p_(o),t=a[o]}}return"function"==typeof t?t.bind(a):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(pb(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(pb(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(pb(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 p_((u=e).value),u.value;case"Identifier":var M=e,z=n;p_(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return p_(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return p_(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=n,P=p.expressions?.map(pb(d))??[],(T=p.quasis?.map(pb(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.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 pg(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return pg(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function py(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 pb(e){return function(n){return null===n?null:ph(n,e)}}function p_(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pv(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function p$(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:{...pt},isLocalExpression:!1,variables:new Set};return pA("string"==typeof e?u7(e):e,n),[...n.variables]}function pA(e,n){switch(e.type){case"UnaryExpression":return a=e,o=n,pA(a.argument,o);case"BinaryExpression":return r=e,i=n,[pA(r.left,i),pA(r.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[pA(s.consequent,l),pA(s.test,l),pA(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,u=n,t=pA(c.callee,u),c.arguments?.map(pk(u)),t;case"ArrowFunctionExpression":var a,o,r,i,s,l,c,u,p,d,f,m,h,g,y,b,v,$,A=e,k=n;let w={...k};w.isLocalExpression=!0;let x=A.params?.map(pk(w))??[],C=pA(A.body,w)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||k.variables.add(e);return;case"MemberExpression":let E;return p=e,d=n,pA(p.object,d),void((E={...d}).isLocalExpression=!0,pA(p.property,E));case"ArrayExpression":return f=e,m=n,void f.elements?.map(pk(m));case"SequenceExpression":return h=e,g=n,void h.expressions?.map(pk(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(pk(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(pk($)),v.quasis?.map(pk($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pk(e){return function(n){return null===n?null:pA(n,e)}}u7.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:pe,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=pe,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)})}}),u7.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 a=n.node;for(;a.type===e.MEMBER_EXP||a.type===e.CALL_EXP&&a.callee.type===e.MEMBER_EXP;)a=a.type===e.MEMBER_EXP?a.object:a.callee.object;a.type="NewExpression"}})}}),u7.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,a="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:a+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(a+=this.expr.charAt(this.index++),o());let r=this.char;("e"===r||"E"===r)&&(a+=this.expr.charAt(this.index++),("+"===(r=this.char)||"-"===r)&&(a+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+a+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+a+this.char+")");else if(i===e.PERIOD_CODE){a.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:a},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(a),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(a){if(48===this.code){var o,r,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let u="";for(;o=this.code,r=c,95===o||r.some(([e,n])=>o>=e&&o<=n);)95===this.code?this.index++:u+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,a);return}this.throwError("unexpected char within number")}a.node={type:e.LITERAL,value:parseInt(u,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,a)})}}),u7.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,a=!1;for(;this.index<this.expr.length;){if(47===this.code&&!a){let a,o=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{a=new RegExp(o,r)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:a,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?a=!0:a&&this.code===e.CBRACK_CODE&&(a=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),u7.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,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:a,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let a=t;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;n.node.test=a.right,a.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),u7.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},a="",o="",r=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:o,cooked:a},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(),o="",a="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(o+=i,i=this.expr.charAt(++this.index),o+=i,i){case"n":a+="\n";break;case"r":a+="\r";break;case"t":a+=" ";break;case"b":a+="\b";break;case"f":a+="\f";break;case"v":a+="\v";break;default:a+=i}else a+=i,o+=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})}}),u7.addBinaryOp("in",7),u7.addBinaryOp("??",1);let pw=H("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:",""),a=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...a}}return e}()});function px(e,n,t){pw.setState(a=>({flags:{...a.flags,[e]:{enabled:a.flags[e]?.enabled??!1,label:n,description:t}}}))}function pC(){let e=pw.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 pE(e){return pw.getState().flags[e].enabled}function pS(e,n){pw.subscribe(t=>{n(t.flags[e].enabled)})}function pD(e,n){pw.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function pM(e){return!window.offlineEnabled||(e??navigator.onLine)}pw.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 pz=e7(function(e,n,t){eX(e,n,t)});function pO(e=!0,n=!1){return pP(pM(),e,n)}function pP(e,n=!0,t=!1){return!!(e?n:t)}let pT=U("extensionsInternal",{slots:{},extensions:{}}),pB=U("extensionRenderings",{renderings:new Map}),pI=()=>H("extensionsInternal",{slots:{},extensions:{}}),pN=()=>H("extensionRenderings",{renderings:new Map});function pj(e){let n=pT.getState(),t=e(n);t!==n&&pT.setState(t)}let pR=null,pF=null;function pL(){let e=pB.getState();return pR&&e===pF||(pR=new Map(e.renderings),pF=e,function(e){for(let n of(pZ.clear(),e.values()))pQ(n,1);pX=!0}(pR)),pR}function pW(e){pF={renderings:e},pB.setState(pF,!0)}function pG(e){let n=pL();n.has(e.renderingId)||(n.set(e.renderingId,e),pQ(e,1),pW(n))}function pV(e){let n=pL(),t=n.get(e);t&&(n.delete(e),pQ(t,-1),pW(n))}let pU=()=>H("extensions",{slots:{}}),pq=0,pH=new Set;function pK(e){pq++;try{return e()}finally{if(0==--pq&&pH.size>0){let e=Array.from(pH);for(let n of(pH.clear(),e))pY(n)}}}function pY(e){try{e()}catch(n){console.error(`The extension system's '${e.name}' recomputation failed`,n)}}function pJ(e){pq>0?pH.add(e):pY(e)}let pZ=new Map,pX=!1;function pQ(e,n){let t=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),a=pZ.get(t);if(!a){if(n<0)return;pZ.set(t,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),pX=!0;return}a.count+=n,a.count<1&&(pZ.delete(t),pX=!0)}function p0(){var e,n;if(pL(),!pX)return;pX=!1;let t=Array.from(pZ.values(),({record:e})=>e);t.sort(p1),e=n0.getState().mountedExtensions,n=t,e.length===n.length&&e.every((e,t)=>0===p1(e,n[t]))||n0.setState({mountedExtensions:t})}function p1(e,n){return p2(e.slotName,n.slotName)||p2(e.extensionId,n.extensionId)||p2(e.slotModuleName,n.slotModuleName)||p2(e.extensionModuleName,n.extensionModuleName)}function p2(e,n){return e===n?0:e<n?-1:1}p0(),pB.subscribe(()=>pJ(p0));let p3=pI(),p5=pU(),p4=n2(),p6=n4(),p8=new Set,p7=!1;function p9(e){if(null===e)p8=null;else if(null!==p8)for(let n of e)p8.add(n);pJ(de)}function de(){if(!p7){p7=!0;try{for(let e=1;;e++){let n=p8;if(null!==n&&0===n.size)return;p8=new Set;try{!function(e,n,t,a,o,r=null){let i=p5.getState().slots,s={},l=!1,c=pM(),u=Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[a,p]of Object.entries(e.slots)){let d=i[a];if(d&&r&&!r.has(a)){s[a]=d;continue}let{config:f}=n5(n,p.name),m=function(e,n,t,a,o,r,i){let s=function(e,n){let t=e.add||[],a=e.remove||[],o=e.order||[],{extensions:r}=p3.getState();return[...n,...t].filter(e=>!a.includes(e)).sort((e,t)=>dd(e,o,r[dr(e)]?.order,n)-dd(t,o,r[dr(t)]?.order,n))}(t,n.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=n8(a,e,c),u=n7(t,e,c),p=u?pz({},s,u):s,d=dr(c),f=n.extensions[d];if(f){let e=p?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!i?.user||!oU(e,i.user))||f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!pP(r,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:p?.["Display conditions"]?.expression||f.displayExpression})}}return l}(a,e,f,t,u,c,o.session);d&&d.moduleName===p.moduleName&&nn(d.candidateExtensions,m)?s[a]=d:(s[a]={moduleName:p.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&p5.setState({slots:s})}(p3.getState(),p4.getState(),p6.getState(),pw.getState(),oj.getState(),n)}catch(e){throw p8=null===n||null===p8?null:new Set([...n,...p8]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{p7=!1}}}function dn(e,n){let t=new Set;for(let a of Object.keys(e))e[a]!==n[a]&&t.add(a);for(let a of Object.keys(n))a in e||t.add(a);return t}function dt(){p9(null)}function da(e,n){return{moduleName:n,name:e,attachedIds:[]}}function dr(e){let[n]=e.split("#");return n}function di(e,n){let t=dr(n);return e.extensions[t]}function ds(e){return di(p3.getState(),e)}p3.subscribe((e,n)=>{p9(e.extensions!==n.extensions?null:dn(e.slots,n.slots))}),p4.subscribe((e,n)=>{p9(dn(e.slots,n.slots))}),p6.subscribe((e,n)=>{p9(dn(e.configs,n.configs))}),pw.subscribe(()=>p9(null)),oj.subscribe(()=>p9(null)),dt(),y(dt);let dl=e=>pj(n=>({...n,extensions:{...n.extensions,[e.name]:{...e}}}));function dc(e,n){pj(t=>{let a=t.slots[e];return a?{...t,slots:{...t.slots,[e]:{...a,attachedIds:[...a.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...da(e),attachedIds:[n]}}}})}function du(e,n){pj(t=>{let a=t.slots[e];return a&&a.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...a,attachedIds:a.attachedIds.filter(e=>e!==n)}}}:t})}function dp(e){pj(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function dd(e,n,t,a){let o=n.indexOf(e);if(-1!==o)return o;{if(void 0!==t)return 1e3+t;let n=a.indexOf(e);return -1!==n?2e3+n:3e3}}function df(e,n){return function(e,n,t=null,a){let o;return e.filter(e=>{let r=e.displayConditionExpression;if("string"!=typeof r||0===r.trim().length)return!0;o??(o=n&&"object"==typeof n?{session:t,...n}:{session:t});try{return!!pr(r,o)}catch(n){return console.error(`Error while evaluating expression '${r}' for ${e.id}`+(a?` in ${a}`:""),n),!1}})}(dm(e),n,oj.getState().session,e)}function dm(e){return p5.getState().slots[e]?.candidateExtensions??[]}let dh=(e,n)=>p3.setState(t=>{let a=t.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}.`),t;if(a&&a==e)return t;if(t.slots[n])return{...t,slots:{...t.slots,[n]:{...t.slots[n],moduleName:e}}};let o=da(n,e);return{...t,slots:{...t.slots,[n]:{...o}}}}),dg=()=>{p8=null,pj(()=>({slots:{},extensions:{}})),pN().setState({renderings:new Map}),p5.setState({slots:{}})},dy=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function db({name:e,basePath:n,mode:t,componentContext:a,state:o}){dy.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:a,state:o})}function d_(e){dy.getState().slotName===e&&dy.setState(dy.getInitialState(),!0)}let dv=U("modalRegistry",{modals:{}});function d$(e){dv.setState(n=>(n.modals[e.name]=e,n))}function dA(e){let n=dv.getState().modals[e];if(!n){let t=ds(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.`),d$(n))}return n}let dk=U("workspaceRegistrations",{workspaces:{}}),dw=U("workspaceGroups",{workspaceGroups:{}});function dx(e){dk.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 dC(e){dw.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 dE=new Set;function dS(e){let n=dk.getState().workspaces;if(n[e])return n[e];{let n=ds(e);if(n){var t;let a;return dE.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.`),dE.add(e)),{name:n.name,title:(t=n,"string"==typeof(a=t?.meta?.title)?a:a&&"object"==typeof a?rT(t.moduleName,a.key,a.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 dD(e){let n=dw.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let dM=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function dz(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=dM.getState(),a=n[e];if(a){let n=t[a.window];if(n)return n;throw Error(`No workspace window found with name: ${a.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function dO(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=dM.getState(),a=t[e];if(a){let t=n[a.group];if(t)return t;throw Error(`No workspace group found with name: ${a.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function dP(e){let{openedWindows:n}=dM.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function dT(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=dM.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);a[t.name]={...t,moduleName:e}}dM.setState({registeredGroupsByName:a})}function dB(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=dM.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};a[t.name]=n}dM.setState({registeredWindowsByName:a})}function dI(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=dM.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};a[t.name]=n}dM.setState({registeredWorkspacesByName:a})}let dN=0,dj=null,dR={bootstrap:{millis:15e3,dieOnTimeout:!0},mount:{millis:15e3,dieOnTimeout:!0},unmount:{millis:15e3,dieOnTimeout:!0}};async function dF(e,n){return(await (dj??(dj=new Promise((e,n)=>{aP({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:n=>(e(n.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(n)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),aP))),dj))("function"==typeof e?()=>e().then(e=>({timeouts:dR,...e})):{timeouts:dR,...e},n)}function dL(){return dW}function dW(e,n){let t,a=dF(e,n).then(e=>t=e);return{mount:()=>a.then(e=>e.mount()),unmount:()=>a.then(e=>e.unmount()),update:e=>a.then(n=>n.update?.(e)),getStatus:()=>t?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return a.then(e=>e.loadPromise)},get bootstrapPromise(){return a.then(e=>e.bootstrapPromise)},get mountPromise(){return a.then(e=>e.mountPromise)},get unmountPromise(){return a.then(e=>e.unmountPromise)}}}async function dG(e,n,t,a,o=e=>e,r={}){let i=dr(a),s=ds(a),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(pO(p,d)){let s,p=dN++,d=`${n}/${a}-${p}`;e.dataset.extensionRenderingId=d;let m=e=>{try{pV(d)}catch(n){console.error(e,n)}};try{pG({renderingId:d,extensionName:i,extensionModuleName:u,extensionId:a,slotName:n,slotModuleName:t})}catch(e){throw m(`Recomputing configuration after registering '${a}' failed also failed`),e}try{s=await f()}catch(e){throw m(`Recomputing configuration after '${a}' failed to load also failed`),e}try{l=await dF(o({...s,name:`${n}/${i}-${p}`}),{...r,_meta:c,_extensionContext:{extensionId:a,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:u},domElement:e})}catch(e){throw m(`Recomputing configuration after '${a}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${a}' in slot '${n}' failed to mount`,e),m(`Recomputing configuration after '${a}' failed to mount also failed`)}),l.unmountPromise.then(()=>m(`Recomputing configuration after unmounting '${a}' failed`),e=>{console.error(`Extension '${a}' in slot '${n}' failed to unmount`,e),m(`Recomputing configuration after '${a}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${a} into ${n} but no DOM element was available.`);return l}var dV=t(60695),dU=t.n(dV);let dq=(0,dV.createContext)({moduleName:"",featureName:""});function dH({to:e,templateParams:n,onBeforeNavigate:t,children:a,...o}){return(0,dV.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),dU().createElement("a",{onClick:a=>{0===a.button&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&!a.metaKey&&(a.preventDefault(),t?.(a),o$({to:e,templateParams:n})),0===a.button&&(a.ctrlKey||a.metaKey)&&t?.(a),0===a.button&&a.shiftKey&&t?.(a),1===a.button&&t?.(a)},href:o_(e,n),...o},a)}let dK=({state:e,children:n,...t})=>{let{extension:a}=(0,dV.useContext)(dq),o=(0,dV.useRef)(null),r=(0,dV.useRef)(Promise.resolve()),i=(0,dV.useRef)(!1),s=(0,dV.useRef)(!1),l=(0,dV.useRef)(e),c=(0,dV.useCallback)(e=>{if(!e)return;let n=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":r.current?.then(n,n);break;default:e.mountPromise.then(n,()=>{})}},[]),u=(0,dV.useCallback)((e,n)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(r.current=Promise.all([e.mountPromise,r.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...n})}).catch(e=>{let n=o.current?.getStatus();"UNMOUNTING"!==n&&"NOT_MOUNTED"!==n&&"UNLOADING"!==n&&console.error(`The extension '${a?.extensionId}' failed to update`,e)}))},[]),p=(0,dV.useCallback)(n=>{n&&!o.current&&!s.current&&a?.extensionSlotName&&a.extensionSlotModuleName&&(s.current=!0,dG(n,a.extensionSlotName,a.extensionSlotModuleName,a.extensionId,void 0,e).then(n=>{(s.current=!1,o.current=n,i.current)?c(n):n&&l.current!==e&&u(n,l.current)},()=>{s.current=!1}))},[]);return(0,dV.useEffect)(()=>(i.current=!1,()=>{i.current=!0,c(o.current)}),[]),(0,dV.useEffect)(()=>{l.current=e,o.current&&u(o.current,e)},[e]),a?dU().createElement("div",{ref:p,"data-extension-id":a?.extensionId,style:{position:"relative"},...t}):null};function dY(e){let n=(0,dV.useRef)(e);return j(n.current,e)||(n.current=e),n.current}function dJ(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[a,o]of Object.entries(n)){let n=function(...n){e.setState(e=>o(e,...n))};t[a]=n}return t}let dZ=e=>e;function dX(e,n=dZ,t){let a=(0,dV.useCallback)(n=>e.subscribe(n),[e]),o=(0,dV.useCallback)(()=>n(e.getState()),[e,n]),r=(0,dV.useSyncExternalStore)(a,o,o),i=(0,dV.useMemo)(()=>t?dJ(e,t):null,[e,t]);return(0,dV.useMemo)(()=>i?{...r,...i}:r,[r,i])}function dQ(e,n){return dX(e,dZ,n)}function d0(e){return function(n){let t=(0,dV.useCallback)(n=>e.subscribe(n),[]),a=(0,dV.useCallback)(()=>e.getState(),[]),o=(0,dV.useSyncExternalStore)(t,a,a),r=(0,dV.useMemo)(()=>n?dJ(e,n):null,[n]);return(0,dV.useMemo)(()=>r?{...o,...r}:o,[o,r])}}let d1=[];Object.freeze(d1);let d2={candidateExtensions:d1};Object.freeze(d2);let d3=e=>{let n=(0,dV.useCallback)(n=>n.slots?.[e]??d2,[e]);return dX(pU(),n)},d5=e=>e.session;function d4(e,n){let{candidateExtensions:t}=d3(e),a=dX(oj,d5),o=dY(n);return(0,dV.useMemo)(()=>df(e,o),[e,o,a,t])}function d6(e,n){let{moduleName:t}=(0,dV.useContext)(dq);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,dV.useEffect)(()=>{dh(t,e)},[t,e]),{extensions:d4(e,n),extensionSlotName:e,extensionSlotModuleName:t}}function d8(e){return e}function d7({name:e,extensionSlotName:n,select:t=d8,children:a,state:o,style:r,...i}){if(a&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??n,l=(0,dV.useRef)(null),{extensions:c,extensionSlotModuleName:u}=d6(s,o),p=(0,dV.useMemo)(()=>t(c),[t,c]),d=(0,dV.useMemo)(()=>{if("function"==typeof a&&!dU().isValidElement(a))return p.map(e=>a(e,o))},[a,p]);return dU().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...r,position:"relative"},...i},s&&p?.map((e,n)=>dU().createElement(dq.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[n]??("function"!=typeof a?a:null)??dU().createElement(dK,{state:o}))))}var d9=t(5338);function fe(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,a)}return t}function fn(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?fe(Object(t),!0).forEach(function(n){var a,o,r;a=e,o=n,r=t[n],o in a?Object.defineProperty(a,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):a[o]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):fe(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function ft(e){return(ft="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 fa(e){return(fa="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 fo(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(fa(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(fa(e)));return e}}var fr=null;try{fr=require("react").createContext()}catch(e){}var fi={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 fs(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function fl(e,n){return new Promise(function(t,a){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 o,r=fd(e,n,function(){t(this)}),i=fo(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,a=e.elementToRender,o=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(o);return i.render(a),i;case"hydrateRoot":return r(o,a);default:return r(a,o),null}}({elementToRender:r,domElement:i,reactDom:fp(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function fc(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var a=e.renderResults[n.name];a&&a.unmount?a.unmount():fp(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function fu(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var a=fd(e,n,null),o=e.renderResults[n.name];if(o&&o.render)o.render(a);else{var r=fo(e,n)();fp(e).render(a,r)}})}function fp(e){return e.ReactDOMClient||e.ReactDOM}function fd(e,n,t){var a=e.React.createElement(e.rootComponent,n),o=fr?e.React.createElement(fr.Provider,{value:n},a):a;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),o=e.React.createElement(e.errorBoundaryClass,n,o)),o=e.React.createElement(e.SingleSpaRoot,fn(fn({},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])}}),o)}var ff=t(70287),fm=t(59324),fh=t(32108);let fg={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fy=new Map;(0,fh.initCache)(fy);let fb={errorRetryCount:3,fetcher:oB,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof oN){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>fy};function f_(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},fg,e),t={...fb,...n.swrConfig};return function(e){var a,o,r,i,s;return r=o=class extends(a=dU().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 dU().createElement("div",null,"An error has occurred. Please try reloading the page.");{let a=dU().createElement(dV.Suspense,{fallback:null},dU().createElement(fm.BE,{value:t},dU().createElement(dq.Provider,{value:this.state.config},n.disableTranslations?dU().createElement(e,this.props):dU().createElement(ff.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},dU().createElement(e,this.props)))));return n.strictMode&&dU().StrictMode?dU().createElement(dU().StrictMode,null,a):a}}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,o}}function fv(e,n){return function(e){if("object"!==ft(e))throw Error("single-spa-react requires a configuration object");var n,t=fn(fn({},fi),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");!fr&&t.React.createContext&&(fr=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 a={bootstrap:fs.bind(null,t),mount:fl.bind(null,t),unmount:fc.bind(null,t)};return t.parcelCanUpdate&&(a.update=fu.bind(null,t)),a}({React:dU(),ReactDOMClient:d9,rootComponent:f_(n)(e)})}function f$(e,n){return()=>e().then(({default:e})=>fv(e,n))}function fA(e,n){return()=>Promise.resolve(fv(e,n))}let fk=f$,fw=W()(()=>({}));q("openmrs-app-context",fw);let fx={};function fC(e,n=e=>e){let t=fw.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function fE(e,n){fw.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function fS(e){return null===e?null:Object.freeze(Object.assign({},e))}let fD=new Map;function fM(e,n){let t=(0,dV.useRef)(n??{}),a=(0,dV.useRef)(n=>fE(e,n)),o=(0,dV.useRef)(Symbol());return(0,dV.useEffect)(()=>{let t=n??{},a=o.current;return null===fC(e)?!function(e,n=fx){fw.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===fx?{}: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.`),fE(e,()=>t)),fD.set(e,a),()=>{fD.get(e)===a&&(fw.setState(n=>(e in n&&delete n[e],n)),fD.delete(e))}},[e]),(0,dV.useEffect)(()=>{let a=n??{};j(t.current,a)||(fE(e,()=>a),t.current=a)},[n]),a.current}function fz({namespace:e,value:n}){return fM(e,n),null}let fO=({children:e,value:n,fallback:t})=>n?dU().createElement(dU().Fragment,null,e):t?dU().createElement(dU().Fragment,null,t):null;function fP(){let e=(0,dV.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,dV.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function fT(e,n=e=>e??{}){let[t,a]=(0,dV.useState)(()=>{if(fB(e))return;let t=fC(e);if(null!==t)return n?n(t):t});return(0,dV.useEffect)(()=>{if(fB(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,dV.useEffect)(()=>{var t;let o;return(t=e=>{if(null==e)return void a(void 0);let t=n?n(e):e;a(e=>j(e,t)?e:t)})(fS(o=fC(e))),fw.subscribe(n=>{let a=e in n?n[e]:null;a!==o&&(o=a,t(fS(a)))})},[e,n]),t}function fB(e){return"string"!=typeof e||0===e.trim().length}function fI(e){let n=d4(e);return(0,dV.useMemo)(()=>n.map(e=>e.id),[n])}function fN(e){return d3(e).candidateExtensions}function fj(e,n){let{data:t,error:a,mutate:o,isLoading:r,isValidating:i}=(0,fm.Ay)(`${i$}?patient=${e}&includeEncounterless=${n}`,oB);return(0,dV.useMemo)(()=>({isLoading:r,data:t?.data.results??[],error:a,mutate:o,isValidating:i}),[t,a,r,i,o])}function fR(e){(0,dV.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let fF={},fL=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let oj=U("session",{loaded:!1,session:null}),oR=0;function oF(e={includeAuthStatus:!0}){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oG(),new er.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(oj.getState()),oj.subscribe(t)})}function oL(){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oG(),oj}function oW(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 oG(e,n){oR=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),oJ(oB(oP,{headers:t}))}function oV(){oj.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oU(e,n){var t,a;if(void 0===n)return!e;if(!e)return!0;return t=e,a=n,("string"==typeof t?!J(a.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!J(a.privileges.find(n=>e===n.display))):(J(t)||console.error(`Could not understand privileges "${t}"`),!0))||!J(n.roles.find(e=>"System Developer"===e.display))}function oq(){let e,n;return new Promise(t=>{let a=a=>{a.loaded&&a.session.user&&(e=a.session.user,t(a.session.user),n&&n())};a(oj.getState()),e||(n=oj.subscribe(a))})}function oH(){return new Promise((e,n)=>{oF().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function oK(e,n){return oJ(oB(oP,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function oY(e,n,t){return t||(t=new AbortController),await oB(`${oz}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),oG()}function oJ(e){return new Promise((n,t)=>{e.then(e=>{let a;"object"==typeof e?.data?(a={loaded:!0,session:e.data},oj.setState(a),n(a)):(a={loaded:!1,session:null},oj.setState(a),t(a))}).catch(e=>{B(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};oj.setState(n),t(n)})})}function oZ(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oj.subscribe(e=>{e.loaded&&e.session&&oW(e.session)});let oX={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function oQ(){th("@openmrs/esm-api",oD),oG()}let o0={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"},o1=e=>"string"==typeof e,o2=()=>{let e,n,t=new Promise((t,a)=>{e=t,n=a});return t.resolve=e,t.reject=n,t},o3=e=>null==e?"":""+e,o5=/###/g,o4=e=>e&&e.indexOf("###")>-1?e.replace(o5,"."):e,o6=e=>!e||o1(e),o8=(e,n,t)=>{let a=o1(n)?n.split("."):n,o=0;for(;o<a.length-1;){if(o6(e))return{};let n=o4(a[o]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++o}return o6(e)?{}:{obj:e,k:o4(a[o])}},o7=(e,n,t)=>{let{obj:a,k:o}=o8(e,n,Object);if(void 0!==a||1===n.length){a[o]=t;return}let r=n[n.length-1],i=n.slice(0,n.length-1),s=o8(e,i,Object);for(;void 0===s.obj&&i.length;)r=`${i[i.length-1]}.${r}`,s=o8(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},o9=(e,n)=>{let{obj:t,k:a}=o8(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,a))return t[a]},re=(e,n,t)=>{for(let a in n)"__proto__"!==a&&"constructor"!==a&&(a in e?o1(e[a])||e[a]instanceof String||o1(n[a])||n[a]instanceof String?t&&(e[a]=n[a]):re(e[a],n[a],t):e[a]=n[a]);return e};var rn={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let rt=e=>o1(e)?e.replace(/[&<>"'\/]/g,e=>rn[e]):e,ra=[" ",",","?","!",";"],ro=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),rr=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let a=n.split(t),o=e;for(let e=0;e<a.length;){let n;if(!o||"object"!=typeof o)return;let r="";for(let i=e;i<a.length;++i)if(i!==e&&(r+=t),r+=a[i],void 0!==(n=o[r])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<a.length-1)continue;e+=i-e+1;break}o=n}return o},ri=e=>e?.replace("_","-"),rs={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 rl{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||rs,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,a){return a&&!this.debug?null:(o1(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new rl(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new rl(this.logger,e)}}var rc=new rl;class ru{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 a=0;a<t;a++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,a])=>{for(let o=0;o<a;o++)t.apply(t,[e,...n])})}}class rp extends ru{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,a={}){let o,r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=void 0!==a.ignoreJSONStructure?a.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],t&&(Array.isArray(t)?o.push(...t):o1(t)&&r?o.push(...t.split(r)):o.push(t)));let s=o9(this.data,o);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=o[0],n=o[1],t=o.slice(2).join(".")),!s&&i&&o1(t))?rr(this.data?.[e]?.[n],t,r):s}addResource(e,n,t,a,o={silent:!1}){let r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(r?t.split(r):t)),e.indexOf(".")>-1&&(i=e.split("."),a=n,n=i[1]),this.addNamespaces(n),o7(this.data,i,a),o.silent||this.emit("added",e,n,t,a)}addResources(e,n,t,a={silent:!1}){for(let a in t)(o1(t[a])||Array.isArray(t[a]))&&this.addResource(e,n,a,t[a],{silent:!0});a.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,a,o,r={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),a=t,t=n,n=i[1]),this.addNamespaces(n);let s=o9(this.data,i)||{};r.skipCopy||(t=JSON.parse(JSON.stringify(t))),a?re(s,t,o):s={...s,...t},o7(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 rd={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,a,o){return e.forEach(e=>{n=this.processors[e]?.process(n,t,a,o)??n}),n}};let rf=Symbol("i18next/PATH_KEY");function rm(e,n){let t,a,o,{[rf]:r}=e((a=[],(o=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===rf)?a:(a.push(n),(t=Proxy.revocable(e,o)).proxy),Proxy.revocable(Object.create(null),o).proxy));return r.join(n?.keySeparator??".")}let rh={},rg=e=>!o1(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ry extends ru{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=rc.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let a=this.resolve(e,t);if(a?.res===void 0)return!1;let o=rg(a.res);return!1!==t.returnObjects||!o}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let a=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=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 a=ra.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===a.length)return!0;let o=ro.getRegExp(`(${a.map(e=>"?"===e?"\\?":e).join("|")})`),r=!o.test(e);if(!r){let n=e.indexOf(t);n>0&&!o.test(e.substring(0,n))&&(r=!0)}return r})(e,t,a);if(r&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:o1(o)?[o]:o};let r=e.split(t);(t!==a||t===a&&this.options.ns.indexOf(r[0])>-1)&&(o=r.shift()),e=r.join(a)}return{key:e,namespaces:o1(o)?[o]:o}}translate(e,n,t){let a="object"==typeof n?{...n}:n;if("object"!=typeof a&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof a&&(a={...a}),a||(a={}),null==e)return"";"function"==typeof e&&(e=rm(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==a.returnDetails?a.returnDetails:this.options.returnDetails,r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],a),l=s[s.length-1],c=void 0!==a.nsSeparator?a.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let u=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?o?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:`${l}${c}${i}`:o?{res:i,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:i;let d=this.resolve(e,a),f=d?.res,m=d?.usedKey||i,h=d?.exactUsedKey||i,g=void 0!==a.joinArrays?a.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==a.count&&!o1(a.count),v=ry.hasDefaultValue(a),$=b?this.pluralResolver.getSuffix(u,a.count,a):"",A=a.ordinal&&b?this.pluralResolver.getSuffix(u,a.count,{ordinal:!1}):"",k=b&&!a.ordinal&&0===a.count,w=k&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${$}`]||a[`defaultValue${A}`]||a.defaultValue,x=f;y&&!f&&v&&(x=w);let C=rg(x),E=Object.prototype.toString.apply(x);if(y&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(o1(g)&&Array.isArray(x))){if(!a.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(m,x,{...a,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return o?(d.res=e,d.usedParams=this.getUsedParamsDetails(a),d):e}if(r){let e=Array.isArray(x),n=e?[]:{},t=e?h:m;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let o=`${t}${r}${e}`;v&&!f?n[e]=this.translate(o,{...a,defaultValue:rg(w)?w[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(o,{...a,joinArrays:!1,ns:s}),n[e]===o&&(n[e]=x[e])}f=n}}else if(y&&o1(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,a,t));else{let n=!1,o=!1;!this.isValidLookup(f)&&v&&(n=!0,f=w),this.isValidLookup(f)||(o=!0,f=i);let s=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:f,p=v&&w!==f&&this.options.updateMissing;if(o||n||p){if(this.logger.log(p?"updateKey":"missingKey",u,l,i,p?w:f),r){let e=this.resolve(i,{...a,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,a.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(a.lng||this.language):e.push(a.lng||this.language);let t=(e,n,t)=>{let o=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,o,p,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,o,p,a),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,a);k&&a[`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,a[`defaultValue${n}`]||w)})}):t(e,i,w))}f=this.extendTranslation(f,e,a,d,t),o&&f===i&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${i}`),(o||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${i}`:i,n?f:void 0,a))}return o?(d.res=f,d.usedParams=this.getUsedParamsDetails(a),d):f}extendTranslation(e,n,t,a,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!t.skipInterpolation){let r;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=o1(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&&!o1(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||a.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);r<(n&&n.length)&&(t.nest=!1)}!t.lng&&a&&a.res&&(t.lng=this.language||a.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[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=o1(r)?[r]:r;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=rd.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,a,o,r,i;return o1(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;a=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let u=void 0!==n.count&&!o1(n.count),p=u&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(o1(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,!rh[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(rh[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${a}" 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(a=>{let i;if(this.isValidLookup(t))return;r=a;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,a,e,n);else{let e;u&&(e=this.pluralResolver.getSuffix(a,n.count,n));let t=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&0===e.indexOf(o)&&s.push(l+e.replace(o,this.options.pluralSeparator)),s.push(l+e),p&&s.push(l+t)),d){let a=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(a),u&&(n.ordinal&&0===e.indexOf(o)&&s.push(a+e.replace(o,this.options.pluralSeparator)),s.push(a+e),p&&s.push(a+t))}}for(;i=s.pop();)this.isValidLookup(t)||(o=i,t=this.getResource(a,e,i,n))}))})}),{res:t,usedKey:a,exactUsedKey:o,usedLng:r,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,a):this.resourceStore.getResource(e,n,t,a)}getUsedParamsDetails(e={}){let n=e.replace&&!o1(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 rb{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=rc.create("languageUtils")}getScriptPartFromCode(e){if(!(e=ri(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=ri(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(o1(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 a=this.getLanguagePartFromCode(e);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(e=>{if(e===a||!(0>e.indexOf("-")&&0>a.indexOf("-"))&&(e.indexOf("-")>0&&0>a.indexOf("-")&&e.substring(0,e.indexOf("-"))===a||0===e.indexOf(a)&&a.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)),o1(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),a=[],o=e=>{e&&(this.isSupportedCode(e)?a.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return o1(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):o1(e)&&o(this.formatLanguageCode(e)),t.forEach(e=>{0>a.indexOf(e)&&o(this.formatLanguageCode(e))}),a}}let r_={zero:0,one:1,two:2,few:3,many:4,other:5},rv={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class r${constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=rc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,a=ri("dev"===e?"en":e),o=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:a,type:o});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];try{t=new Intl.PluralRules(a,{type:o})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),rv;if(!e.match(/-|_/))return rv;let a=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(a,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)=>r_[e]-r_[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let a=this.getRule(e,t);return a?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let rA=(e,n,t,a=".",o=!0)=>{let r,i=void 0!==(r=o9(e,t))?r:o9(n,t);return!i&&o&&o1(t)&&void 0===(i=rr(e,t,a))&&(i=rr(n,t,a)),i};class rk{constructor(e={}){this.logger=rc.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:a,prefix:o,prefixEscaped:r,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==n?n:rt,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==a&&a,this.prefix=o?o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):r||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):m||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,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,a){let o,r,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let o=rA(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,t,{...a,...n,interpolationkey:e}):o}let o=e.split(this.formatSeparator),r=o.shift().trim(),i=o.join(this.formatSeparator).trim();return this.format(rA(n,s,r,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...a,...n,interpolationkey:r})};this.resetRegExp();let c=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=a?.interpolation?.skipOnVariables!==void 0?a.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;o=n.regex.exec(e);){let t=o[1].trim();if(void 0===(r=l(t)))if("function"==typeof c){let n=c(e,o,a);r=o1(n)?n:""}else if(a&&Object.prototype.hasOwnProperty.call(a,t))r="";else if(u){r=o[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),r="";else o1(r)||this.useRawValueToEscape||(r=o3(r));let s=n.safeValue(r);if(e=e.replace(o[0],s),u?(n.regex.lastIndex+=r.length,n.regex.lastIndex-=o[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let a,o,r,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let a=e.split(RegExp(`${t}[ ]*{`)),o=`{${a[1]}`;e=a[0];let i=(o=this.interpolate(o,r)).match(/'/g),s=o.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(o=o.replace(/'/g,'"'));try{r=JSON.parse(o),n&&(r={...n,...r})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${o}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,e};for(;a=this.nestingRegexp.exec(e);){let s=[];(r=(r={...t}).replace&&!o1(r.replace)?r.replace:r).applyPostProcessor=!1,delete r.defaultValue;let l=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(-1!==l&&(s=a[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),a[1]=a[1].slice(0,l)),(o=n(i.call(this,a[1].trim(),r),r))&&a[0]===e&&!o1(o))return o;o1(o)||(o=o3(o)),o||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:a[1].trim()}),o.trim())),e=e.replace(a[0],o),this.regexp.lastIndex=0}return e}}let rw=e=>{let n={};return(t,a,o)=>{let r=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(r={...r,[o.interpolationkey]:void 0});let i=a+JSON.stringify(r),s=n[i];return s||(s=e(ri(a),o),n[i]=s),s(t)}},rx=e=>(n,t,a)=>e(ri(t),a)(n);class rC{constructor(e={}){this.logger=rc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?rw:rx;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()]=rw(n)}format(e,n,t,a={}){let o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&0>o[0].indexOf(")")&&o.find(e=>e.indexOf(")")>-1)){let e=o.findIndex(e=>e.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,e)].join(this.formatSeparator)}return o.reduce((e,n)=>{let{formatName:o,formatOptions:r}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let a=e.split("(");n=a[0].toLowerCase().trim();let o=a[1].substring(0,a[1].length-1);"currency"===n&&0>o.indexOf(":")?t.currency||(t.currency=o.trim()):"relativetime"===n&&0>o.indexOf(":")?t.range||(t.range=o.trim()):o.split(";").forEach(e=>{if(e){let[n,...a]=e.split(":"),o=a.join(":").trim().replace(/^'+|'+$/g,""),r=n.trim();t[r]||(t[r]=o),"false"===o&&(t[r]=!1),"true"===o&&(t[r]=!0),isNaN(o)||(t[r]=parseInt(o,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[o]){let n=e;try{let i=a?.formatParams?.[a.interpolationkey]||{},s=i.locale||i.lng||a.locale||a.lng||t;n=this.formats[o](e,s,{...r,...a,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class rE extends ru{constructor(e,n,t,a={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=a,this.logger=rc.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,a.backend,a)}queueLoad(e,n,t,a){let o={},r={},i={},s={};return e.forEach(e=>{let a=!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,a=!1,void 0===r[i]&&(r[i]=!0),void 0===o[i]&&(o[i]=!0),void 0===s[n]&&(s[n]=!0)))}),a||(i[e]=!0)}),(Object.keys(o).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(o),pending:Object.keys(r),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let a=e.split("|"),o=a[0],r=a[1];n&&this.emit("failedLoading",o,r,n),!n&&t&&this.store.addResourceBundle(o,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,a)=>{let{obj:o,k:r}=o8(e,n,Object);o[r]=o[r]||[],o[r].push(t)})(t.loaded,[o],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,a=0,o=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:a,wait:o,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&&a<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,a+1,2*o,r)},o):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={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();o1(e)&&(e=this.languageUtils.toResolveHierarchy(e)),o1(n)&&(n=[n]);let o=this.queueLoad(e,n,t,a);if(!o.toLoad.length)return o.pending.length||a(),null;o.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("|"),a=t[0],o=t[1];this.read(a,o,"read",void 0,void 0,(t,r)=>{t&&this.logger.warn(`${n}loading namespace ${o} for language ${a} failed`,t),!t&&r&&this.logger.log(`${n}loaded namespace ${o} for language ${a}`,r),this.loaded(e,t,r)})}saveMissing(e,n,t,a,o,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:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;(o=5===l.length?l(e,n,t,a,s):l(e,n,t,a))&&"function"==typeof o.then?o.then(e=>i(null,e)).catch(i):i(null,o)}catch(e){i(e)}else l(e,n,t,a,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,a)}}}let rS=()=>({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]),o1(e[1])&&(n.defaultValue=e[1]),o1(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}),rD=e=>(o1(e.ns)&&(e.ns=[e.ns]),o1(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),o1(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),rM=()=>{};class rz extends ru{constructor(e={},n){if(super(),this.options=rD(e),this.services={},this.logger=rc,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&&(o1(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=rS();this.options={...t,...this.options,...rD(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 a=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?rc.init(a(this.modules.logger),this.options):rc.init(null,this.options),e=this.modules.formatter?this.modules.formatter:rC;let n=new rb(this.options);this.store=new rp(this.options.resources,this.options);let o=this.services;o.logger=rc,o.resourceStore=this.store,o.languageUtils=n,o.pluralResolver=new r$(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)&&(o.formatter=a(e),o.formatter.init&&o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new rk(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new rE(a(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(o.languageDetector=a(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=a(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new ry(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=rM),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 o=o2(),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),o.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),o}loadResources(e,n=rM){let t=n,a=o1(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(a?.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)})};a?n(a):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 a=o2();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=rM),this.services.backendConnector.reload(e,n,e=>{a.resolve(),t(e)}),a}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&&rd.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=o2();this.emit("languageChanging",e);let a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(o,r)=>{r?this.isLanguageChangingTo===e&&(a(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(o,(...e)=>this.t(...e))},r=n=>{e||n||!this.services.languageDetector||(n=[]);let t=o1(n)?n:n&&n[0],r=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(o1(n)?[n]:n);r&&(this.language||a(r),this.translator.language||this.translator.changeLanguage(r),this.services.languageDetector?.cacheUserLanguage?.(r)),this.loadResources(r,e=>{o(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 a=(e,n,...o)=>{let r,i;(r="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(o)):{...n}).lng=r.lng||a.lng,r.lngs=r.lngs||a.lngs,r.ns=r.ns||a.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||t||a.keyPrefix);let s=this.options.keySeparator||".";return r.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=rm(e,{...this.options,...n})),`${r.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=rm(e,{...this.options,...n})),i=r.keyPrefix?`${r.keyPrefix}${s}${e}`:e),this.t(i,r)};return o1(e)?a.lng=e:a.lngs=e,a.ns=n,a.keyPrefix=t,a}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],a=!!this.options&&this.options.fallbackLng,o=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)&&(!a||r(o,e)))}loadNamespaces(e,n){let t=o2();return this.options.ns?(o1(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=o2();o1(e)&&(e=[e]);let a=this.options.preload||[],o=e.filter(e=>0>a.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=a.concat(o),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 rb(rS());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 rz(e,n)}cloneInstance(e={},n=rM){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let a={...this.options,...e,isClone:!0},o=new rz(a);return(void 0!==e.debug||void 0!==e.prefix)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},t&&(o.store=new rp(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,a)=>(t[a]={...e[n][a]},t),e[n]),e),{}),a),o.services.resourceStore=o.store),o.translator=new ry(o.services,a),o.translator.on("*",(e,...n)=>{o.emit(e,...n)}),o.init(a,n),o.translator.options=a,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let rO=rz.createInstance();rO.createInstance=rz.createInstance,rO.createInstance,rO.dir,rO.init,rO.loadResources,rO.reloadResources,rO.use,rO.changeLanguage,rO.getFixedT,rO.t,rO.exists,rO.setDefaultNamespace,rO.hasLoadedNamespace,rO.loadNamespaces,rO.loadLanguages;let rP=rO.default||rO;function rT(e,n,t,a){return rP.t(n,{ns:e,defaultValue:t,...a})}function rB(e,n,t){return o0[e]?rT("core",e,n??o0[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}rP.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let rI="import-map-override:",rN="import-map-overrides-disabled",rj="import-map-overrides:change",rR=!1,rF=null,rL=null;async function rW(){return rL??(rL=rG().then(({map:e,complete:n})=>(n||(rL=null),e))),rL}async function rG(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[],t=!0;for(let a=0;a<e.length;a++){let o=e[a];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);n.push(await e.json())}else o.textContent&&n.push(JSON.parse(o.textContent))}catch(e){t=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${a}`,e)}}return{map:rV(n),complete:t}}function rV(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function rU(){let e={};try{let n=rJ();for(let t=0;t<localStorage.length;t++){let a=localStorage.key(t);if(a?.startsWith(rI)){let t=a.slice(rI.length);if(!n.includes(t)){let n=localStorage.getItem(a);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function rq(){let e=await rW();return rR?rV([e,rF??rU()]):e}async function rH(){return rW()}async function rK(){return rR?rV([await rW(),rU()]):rW()}function rY(e){if(!rR)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(rI)){let n=localStorage.getItem(t);n&&(e[t.slice(rI.length)]=n)}}return{imports:e}}return rU()}function rJ(){if(!rR)return[];try{let e=localStorage.getItem(rN);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function rZ(e){return!!rR&&rJ().includes(e)}function rX(e,n){if(!rR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(rI+e,n),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function rQ(e){if(!rR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(rI+e);let n=rJ().filter(n=>n!==e);n.length>0?localStorage.setItem(rN,JSON.stringify(n)):localStorage.removeItem(rN),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function r0(){if(!rR)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(rI)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(rN),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function r1(e){if(!rR)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=rJ().filter(n=>n!==e);n.length>0?localStorage.setItem(rN,JSON.stringify(n)):localStorage.removeItem(rN),window.dispatchEvent(new CustomEvent(rj))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let r2=!1;function r3(){!r2&&(r2=!0,(rR="development"===window.spaEnv)&&(rF=rU()))}function r5(e){return e.replace(/[\/\-@]/g,"_")}async function r4(e,n="./start",a){var o;let r,i=!a?.maxLoadingTime||a.maxLoadingTime<=0?6e5:a.maxLoadingTime;await Promise.race([r6(e,a?.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=r5(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(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 r6(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=r5(e);if(!window[t]){let t=n??await r8();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 a=t.imports[e];a.startsWith("./")&&(a=window.spaBase+a.substring(1));let o=e in rY().imports;try{return await function(e){var n;let t=(n=window)[r7]??(n[r7]=new Map),a=t.get(e);if(a)return a;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let r=new Promise((n,a)=>{let r=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(r),o.removeEventListener("load",s),o.removeEventListener("error",l)}function s(){i(),n()}function l(n){i(),t.delete(e),o.remove();let r=`Failed to load script from ${e}`;console.error(r,n),a(n.message??r)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return t.set(e,r),r}(a)}catch(e){return o&&M({kind:"error",title:rB("scriptLoadingFailed","Error: Script failed to load"),description:rB("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:a}),actionButtonLabel:rB("resetOverrides","Reset overrides"),onActionButtonClick(){r0(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function r8(){return rq()}let r7=Symbol.for("__openmrs_script_loading");function r9(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 ie(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,n])=>"string"==typeof e&&r9(n))}let it="openmrs-routes:",ia="openmrs-routes:change",io=!1,ir=null,ii=null;async function is(){return ii??(ii=il().then(({map:e,complete:n})=>(n||(ii=null),e))),ii}async function il(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[],t=!0;for(let a=0;a<e.length;a++){let o=e[a];try{let e;if(o.src){let n=await fetch(o.src);if(!n.ok)throw Error(`Request for ${o.src} returned ${n.status} ${n.statusText}`);e=await n.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&ie(e)&&n.push(e)}catch(e){t=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${a}`,e)}}return{map:ic(n),complete:t}}function ic(e){let n={routes:{}};for(let t of e)t&&"object"==typeof t&&!Array.isArray(t)&&(Object.assign(n.routes,t.routes),void 0===n.version&&void 0!==t.version&&(n.version=t.version));return n}async function iu(){let e={version:void 0,routes:{}};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(it)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(it.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(r9(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),a=await n.json();if(r9(a))return{moduleName:e,routes:a};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.routes[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 ip(){let e=await is();return io?ic([e,ir??await iu()]):e}async function id(){return is()}async function im(){return io?ic([await is(),await iu()]):is()}function ih(){if(!io)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(it)){let n=localStorage.getItem(t);n&&(e[t.slice(it.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function ig(e,n){if(!io)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(it+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!r9(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(it+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(it+e,JSON.stringify(n.toString()));else{if(!r9(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(it+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(ia))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function iy(e){if(!io)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(it+e),window.dispatchEvent(new CustomEvent(ia))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ib(){if(!io)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(it)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(ia))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let i_=null;function iv(){return i_||(i_=(io="development"===window.spaEnv)?iu().then(e=>{ir=e}):Promise.resolve())}let i$=`${oz}/attachment`;function iA(e,n){return oB(`${i$}/${e}`,{signal:n.signal})}function ik(e,n,t){return oB(`${i$}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function iw(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)),oB(`${i$}`,{method:"POST",body:t})}function ix(e,n){return oB(`${i$}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function iC(e,n){return new Promise(function(t){var a=new MessageChannel;a.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[a.port2])})}function iE(e,n){for(var t=0;t<n.length;t++){var a=n[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function iS(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var iD=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function iM(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var iz=function(e,n){this.type=e,Object.assign(this,n)};function iO(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function iP(){}var iT={type:"SKIP_WAITING"};function iB(e,n){if(!n)return e&&e.then?e.then(iP):Promise.resolve()}var iI=function(e){function n(n,t){var a,o;return void 0===t&&(t={}),(a=e.call(this)||this).nn={},a.tn=0,a.rn=new iD,a.en=new iD,a.on=new iD,a.un=0,a.an=new Set,a.cn=function(){var e=a.fn,n=e.installing;a.tn>0||!iM(n.scriptURL,a.sn.toString())||performance.now()>a.un+6e4?(a.vn=n,e.removeEventListener("updatefound",a.cn)):(a.hn=n,a.an.add(n),a.rn.resolve(n)),++a.tn,n.addEventListener("statechange",a.ln)},a.ln=function(e){var n=a.fn,t=e.target,o=t.state,r=t===a.vn,i={sw:t,isExternal:r,originalEvent:e};!r&&a.mn&&(i.isUpdate=!0),a.dispatchEvent(new iz(o,i)),"installed"===o?a.wn=self.setTimeout(function(){"installed"===o&&n.waiting===t&&a.dispatchEvent(new iz("waiting",i))},200):"activating"===o&&(clearTimeout(a.wn),r||a.en.resolve(t))},a.dn=function(e){var n=a.hn,t=n!==navigator.serviceWorker.controller;a.dispatchEvent(new iz("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:a.mn})),t||a.on.resolve(n)},o=function(e){var n=e.data,t=e.ports,o=e.source;return iO(a.getSW(),function(){a.an.has(o)&&a.dispatchEvent(new iz("message",{data:n,originalEvent:e,ports:t,sw:o}))})},a.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},a.sn=n,a.nn=t,navigator.serviceWorker.addEventListener("message",a.gn),a}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,a,o=n.prototype;return o.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var a,o,r,i=this;return a=function(){if(!t&&"complete"!==document.readyState)return iB(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),iO(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&&iM(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new iz("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=a())&&r.then?r.then(o):o(r)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?iB(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return iO(this.getSW(),function(n){return iC(n,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&iC(this.fn.waiting,iT)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&iM(e.scriptURL,this.sn.toString())?e:void 0},o.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 iO(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}}],iE(n.prototype,t),a&&iE(n,a),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 iS(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)?iS(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 iN(e,n){if(void 0!==d)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),d;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new iI(e,n);return d=t.register().then(()=>t.controlling.then(()=>t))}function ij(){return d??Promise.resolve(void 0)}let iR="x-omrs-offline-response-body",iF="x-omrs-offline-response-status",iL="x-omrs-offline-caching-strategy";async function iW(e){let n=await ij();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 iG(){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 iV(){return!window.indexedDB}async function iU(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function iq(){return await iU()||await iV()||await iG()}let iH="openmrs3:offline-mode",iK="unavailable";function iY(){return{current:iK,notAvailable:"unavailable"===iK,active:"on"===iK}}function iJ(e){"unavailable"!==iK&&"unavailable"!==e&&(localStorage.setItem(iH,"on"===e?"active":"disabled"),iK=e)}async function iZ(){await iq()||(iK="active"===localStorage.getItem(iH)?"on":"off"),navigator.onLine}let iX="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,iQ=Object.keys,i0=Array.isArray;function i1(e,n){return"object"!=typeof n||iQ(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||iX.Promise||(iX.Promise=Promise);let i2=Object.getPrototypeOf,i3={}.hasOwnProperty;function i5(e,n){return i3.call(e,n)}function i4(e,n){"function"==typeof n&&(n=n(i2(e))),("u"<typeof Reflect?iQ:Reflect.ownKeys)(n).forEach(t=>{i8(e,t,n[t])})}let i6=Object.defineProperty;function i8(e,n,t,a){i6(e,n,i1(t&&i5(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},a))}function i7(e){return{from:function(n){return e.prototype=Object.create(n.prototype),i8(e.prototype,"constructor",e),{extend:i4.bind(null,e.prototype)}}}}let i9=Object.getOwnPropertyDescriptor;function se(e,n){let t;return i9(e,n)||(t=i2(e))&&se(t,n)}let sn=[].slice;function st(e,n,t){return sn.call(e,n,t)}function sa(e,n){return n(e)}function so(e){if(!e)throw Error("Assertion Failed")}function sr(e){iX.setImmediate?setImmediate(e):setTimeout(e,0)}function si(e,n){return e.reduce((e,t,a)=>{var o=n(t,a);return o&&(e[o[0]]=o[1]),e},{})}function ss(e,n){if(i5(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],a=0,o=n.length;a<o;++a){var r=ss(e,n[a]);t.push(r)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return void 0===s?void 0:ss(s,n.substr(i+1))}}function sl(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){so("string"!=typeof t&&"length"in t);for(var a=0,o=n.length;a<o;++a)sl(e,n[a],t[a])}else{var r=n.indexOf(".");if(-1!==r){var i=n.substr(0,r),s=n.substr(r+1);if(""===s)void 0===t?i0(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&i5(e,i)||(l=e[i]={}),sl(l,s,t)}}else void 0===t?i0(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function sc(e){var n={};for(var t in e)i5(e,t)&&(n[t]=e[t]);return n}let su=[].concat;function sp(e){return su.apply([],e)}let sd="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(sp([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>iX[e]),sf=sd.map(e=>iX[e]);si(sd,e=>[e,!0]);let sm=null;function sh(e){sm="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=sm&&sm.get(n);if(t)return t;if(i0(n)){t=[],sm&&sm.set(n,t);for(var a=0,o=n.length;a<o;++a)t.push(e(n[a]))}else if(sf.indexOf(n.constructor)>=0)t=n;else{let a=i2(n);for(var r in t=a===Object.prototype?{}:Object.create(a),sm&&sm.set(n,t),n)i5(n,r)&&(t[r]=e(n[r]))}return t}(e);return sm=null,n}let{toString:sg}={};function sy(e){return sg.call(e).slice(8,-1)}let sb="u">typeof Symbol?Symbol.iterator:"@@iterator",s_="symbol"==typeof sb?function(e){var n;return null!=e&&(n=e[sb])&&n.apply(e)}:function(){return null},sv={};function s$(e){var n,t,a,o;if(1==arguments.length){if(i0(e))return e.slice();if(this===sv&&"string"==typeof e)return[e];if(o=s_(e)){for(t=[];!(a=o.next()).done;)t.push(a.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 sA="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var sk="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),sw=()=>!0;let sx=!Error("").stack;function sC(){if(sx)try{throw sC.arguments,Error()}catch(e){return e}return Error()}function sE(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(sw).map(e=>"\n"+e).join("")):""}var sS=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sD=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(sS),sM={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 sz(e,n){this._e=sC(),this.name=e,this.message=n}function sO(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function sP(e,n,t,a){this._e=sC(),this.failures=n,this.failedKeys=a,this.successCount=t,this.message=sO(e,n)}function sT(e,n){this._e=sC(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=sO(e,n)}i7(sz).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+sE(this._e,2))}},toString:function(){return this.name+": "+this.message}}),i7(sP).from(sz),i7(sT).from(sz);var sB=sD.reduce((e,n)=>(e[n]=n+"Error",e),{}),sI=sD.reduce((e,n)=>{var t=n+"Error";function a(e,a){this._e=sC(),this.name=t,e?"string"==typeof e?(this.message=`${e}${a?"\n "+a:""}`,this.inner=a||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sM[n]||t,this.inner=null)}return i7(a).from(sz),e[n]=a,e},{});sI.Syntax=SyntaxError,sI.Type=TypeError,sI.Range=RangeError;var sN=sS.reduce((e,n)=>(e[n+"Error"]=sI[n],e),{}),sj=sD.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=sI[n]),e),{});function sR(){}function sF(e){return e}function sL(e,n){return null==e||e===sF?n:function(t){return n(e(t))}}function sW(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function sG(e,n){return e===sR?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var a=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var r=n.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?sW(a,this.onsuccess):a),o&&(this.onerror=this.onerror?sW(o,this.onerror):o),void 0!==r?r:t}}function sV(e,n){return e===sR?n:function(){e.apply(this,arguments);var t=this.onsuccess,a=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?sW(t,this.onsuccess):t),a&&(this.onerror=this.onerror?sW(a,this.onerror):a)}}function sU(e,n){return e===sR?n:function(t){var a=e.apply(this,arguments);i1(t,a);var o=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?sW(o,this.onsuccess):o),r&&(this.onerror=this.onerror?sW(r,this.onerror):r),void 0===a?void 0===i?void 0:i:i1(a,i)}}function sq(e,n){return e===sR?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sH(e,n){return e===sR?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var a=this,o=arguments.length,r=Array(o);o--;)r[o]=arguments[o];return t.then(function(){return n.apply(a,r)})}return n.apply(this,arguments)}}sj.ModifyError=sP,sj.DexieError=sz,sj.BulkError=sT;var sK={};let[sY,sJ,sZ]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,i2(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,i2(n),e]})(),sX=sJ&&sJ.then,sQ=sY&&sY.constructor,s0=!!sZ;var s1=!1,s2=sZ?()=>{sZ.then(lf)}:iX.setImmediate?setImmediate.bind(null,lf):iX.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{lf(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(lf,0)},s3=function(e,n){lt.push([e,n]),s4&&(s2(),s4=!1)},s5=!0,s4=!0,s6=[],s8=[],s7=null,s9=sF,le={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lN,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lN(e[0],e[1])}catch(e){}})}},ln=le,lt=[],la=0,lo=[];function lr(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=sR,this._lib=!1;var n=this._PSD=ln;if(sk&&(this._stackHolder=sC(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sK)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&ll(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 a=n._lib&&lm();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof lr?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,lc(n)),a&&lh()}},ll.bind(null,n))}catch(e){ll(n,e)}}(this,e)}let li={get:function(){var e=ln,n=lk;function t(t,a){var o=!e.global&&(e!==ln||n!==lk);let r=o&&!lE();var i=new lr((n,i)=>{lu(this,new ls(lT(t,e,o,r),lT(a,e,o,r),n,i,e))});return sk&&ld(i,this),i}return t.prototype=sK,t},set:function(e){i8(this,"then",e&&e.prototype===sK?li:{get:function(){return e},set:li.set})}};function ls(e,n,t,a,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=a,this.psd=o}function ll(e,n){if(s8.push(n),null===e._state){var t=e._lib&&lm();n=s9(n),e._state=!1,e._value=n,sk&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=se(n,"stack");n._promise=e,i8(n,"stack",{get:()=>s1?t&&(t.get?t.get.apply(n):t.value):e.stack})}),s6.some(n=>n._value===e._value)||s6.push(e),lc(e),t&&lh()}}function lc(e){var n=e._listeners;e._listeners=[];for(var t=0,a=n.length;t<a;++t)lu(e,n[t]);var o=e._PSD;--o.ref||o.finalize(),0===la&&(++la,s3(()=>{0==--la&&lg()},[]))}function lu(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,++la,s3(lp,[t,e,n])}else e._listeners.push(n)}function lp(e,n,t){try{s7=n;var a,o=n._value;n._state?a=e(o):(s8.length&&(s8=[]),a=e(o),-1===s8.indexOf(o)&&function(e){for(var n=s6.length;n;)if(s6[--n]._value===e._value)return void s6.splice(n,1)}(n)),t.resolve(a)}catch(e){t.reject(e)}finally{s7=null,0==--la&&lg(),--t.psd.ref||t.psd.finalize()}}function ld(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function lf(){lm()&&lh()}function lm(){var e=s5;return s5=!1,s4=!1,e}function lh(){var e,n,t;do for(;lt.length>0;)for(e=lt,lt=[],t=e.length,n=0;n<t;++n){var a=e[n];a[0].apply(null,a[1])}while(lt.length>0);s5=!0,s4=!0}function lg(){var e=s6;s6=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=lo.slice(0),t=n.length;t;)n[--t]()}function ly(e){return new lr(sK,!1,e)}function lb(e,n){var t=ln;return function(){var a=lm(),o=ln;try{return lz(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{lz(o,!1),a&&lh()}}}i4(lr.prototype,{then:li,_then:function(e,n){lu(this,new ls(null,null,e,n,ln))},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):ly(e)):this.then(null,e=>e&&e.name===n?t(e):ly(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),ly(n)))},stack:{get:function(){if(this._stack)return this._stack;try{s1=!0;var e=(function e(n,t,a){if(t.length===a)return t;var o="";if(!1===n._state){var r,i,s=n._value;null!=s?(r=s.name||"Error",i=s.message||s,o=sE(s,0)):(r=s,i=""),t.push(r+(i?": "+i:"")+o)}return sk&&((o=sE(n._stackHolder,2))&&-1===t.indexOf(o)&&t.push(o),n._prev&&e(n._prev,t,a)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{s1=!1}}},timeout:function(e,n){return e<1/0?new lr((t,a)=>{var o=setTimeout(()=>a(new sI.Timeout(n)),e);this.then(t,a).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&i8(lr.prototype,Symbol.toStringTag,"Dexie.Promise"),le.env=lO(),i4(lr,{all:function(){var e=s$.apply(null,arguments).map(lS);return new lr(function(n,t){0===e.length&&n([]);var a=e.length;e.forEach((o,r)=>lr.resolve(o).then(t=>{e[r]=t,--a||n(e)},t))})},resolve:e=>{if(e instanceof lr)return e;if(e&&"function"==typeof e.then)return new lr((n,t)=>{e.then(n,t)});var n=new lr(sK,!0,e);return ld(n,s7),n},reject:ly,race:function(){var e=s$.apply(null,arguments).map(lS);return new lr((n,t)=>{e.map(e=>lr.resolve(e).then(n,t))})},PSD:{get:()=>ln,set:e=>ln=e},totalEchoes:{get:()=>lk},newPSD:lx,usePSD:lP,scheduler:{get:()=>s3,set:e=>{s3=e}},rejectionMapper:{get:()=>s9,set:e=>{s9=e}},follow:(e,n)=>new lr((t,a)=>lx((n,t)=>{var a=ln;a.unhandleds=[],a.onunhandled=t,a.finalize=sW(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},lo.push(function n(){e(),lo.splice(lo.indexOf(n),1)}),++la,s3(()=>{0==--la&&lg()},[])},a.finalize),e()},n,t,a))}),sQ&&(sQ.allSettled&&i8(lr,"allSettled",function(){let e=s$.apply(null,arguments).map(lS);return new lr(n=>{0===e.length&&n([]);let t=e.length,a=Array(t);e.forEach((e,o)=>lr.resolve(e).then(e=>a[o]={status:"fulfilled",value:e},e=>a[o]={status:"rejected",reason:e}).then(()=>--t||n(a)))})}),sQ.any&&"u">typeof AggregateError&&i8(lr,"any",function(){let e=s$.apply(null,arguments).map(lS);return new lr((n,t)=>{0===e.length&&t(AggregateError([]));let a=e.length,o=Array(a);e.forEach((e,r)=>lr.resolve(e).then(e=>n(e),e=>{o[r]=e,--a||t(AggregateError(o))}))})}));let l_={awaits:0,echoes:0,id:0};var lv=0,l$=[],lA=0,lk=0,lw=0;function lx(e,n,t,a){var o=ln,r=Object.create(o);r.parent=o,r.ref=0,r.global=!1,r.id=++lw;var i=le.env;r.env=s0?{Promise:lr,PromiseProp:{value:lr,configurable:!0,writable:!0},all:lr.all,race:lr.race,allSettled:lr.allSettled,any:lr.any,resolve:lr.resolve,reject:lr.reject,nthen:lB(i.nthen,r),gthen:lB(i.gthen,r)}:{},n&&i1(r,n),++o.ref,r.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lP(r,e,t,a);return 0===r.ref&&r.finalize(),s}function lC(){return l_.id||(l_.id=++lv),++l_.awaits,l_.echoes+=100,l_.id}function lE(){return!!l_.awaits&&(0==--l_.awaits&&(l_.id=0),l_.echoes=100*l_.awaits,!0)}function lS(e){return l_.echoes&&e&&e.constructor===sQ?(lC(),e.then(e=>(lE(),e),e=>(lE(),lj(e)))):e}function lD(e){++lk,l_.echoes&&0!=--l_.echoes||(l_.echoes=l_.id=0),l$.push(ln),lz(e,!0)}function lM(){var e=l$[l$.length-1];l$.pop(),lz(e,!1)}function lz(e,n){var t,a=ln;if((n?!l_.echoes||lA++&&e===ln:!lA||--lA&&e===ln)||(t=n?lD.bind(null,e):lM,sX.call(sY,t)),e!==ln&&(ln=e,a===le&&(le.env=lO()),s0)){var o=le.env.Promise,r=e.env;sJ.then=r.nthen,o.prototype.then=r.gthen,(a.global||e.global)&&(Object.defineProperty(iX,"Promise",r.PromiseProp),o.all=r.all,o.race=r.race,o.resolve=r.resolve,o.reject=r.reject,r.allSettled&&(o.allSettled=r.allSettled),r.any&&(o.any=r.any))}}function lO(){var e=iX.Promise;return s0?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(iX,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:sJ.then,gthen:e.prototype.then}:{}}function lP(e,n,t,a,o){var r=ln;try{return lz(e,!0),n(t,a,o)}finally{lz(r,!1)}}function lT(e,n,t,a){return"function"!=typeof e?e:function(){var o,r=ln;t&&lC(),lz(n,!0);try{return e.apply(this,arguments)}finally{lz(r,!1),a&&(o=lE,sX.call(sY,o))}}}function lB(e,n){return function(t,a){return e.call(this,lT(t,n),lT(a,n))}}-1===(""+sX).indexOf("[native code]")&&(lC=lE=sR);let lI="unhandledrejection";function lN(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var a,o={promise:n,reason:e};if(iX.document&&document.createEvent?((a=document.createEvent("Event")).initEvent(lI,!0,!0),i1(a,o)):iX.CustomEvent&&i1(a=new CustomEvent(lI,{detail:o}),o),a&&iX.dispatchEvent&&(dispatchEvent(a),!iX.PromiseRejectionEvent&&iX.onunhandledrejection))try{iX.onunhandledrejection(a)}catch(e){}sk&&a&&!a.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var lj=lr.reject;let lR="3.2.4",lF=String.fromCharCode(65535),lL=-1/0,lW="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lG="String expected.",lV=[],lU="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lq=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lH="__dbnames",lK="readonly",lY="readwrite";function lJ(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let lZ={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lX(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=sh(n))[e],n)}class lQ{_trans(e,n,t){let a=this._tx||ln.trans,o=this.name;function r(e,t,a){if(!a.schema[o])throw new sI.NotFound("Table "+o+" not part of transaction");return n(a.idbtrans,a)}let i=lm();try{return a&&a.db===this.db?a===ln.trans?a._promise(e,r,t):lx(()=>a._promise(e,r,t),{trans:a,transless:ln.transless||ln}):function e(n,t,a,o){if(n.idbdb&&(n._state.openComplete||ln.letThrough||n._vip)){var r=n._createTransaction(t,a,n._dbSchema);try{r.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===sB.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,a,o))):lj(r)}return r._promise(t,(e,n)=>lx(()=>(ln.trans=r,o(e,n,r)))).then(e=>r._completion.then(()=>e))}if(n._state.openComplete)return lj(new sI.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return lj(new sI.DatabaseClosed);n.open().catch(sR)}return n._state.dbReadyPromise.then(()=>e(n,t,a,o))}(this.db,e,[this.name],r)}finally{i&&lh()}}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(i0(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=iQ(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=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==lF)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&sk&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:a}=this.schema,o=this.db._deps.indexedDB;function r(e,n){try{return 0===o.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],o)=>{let i=a[o],s=e[o];return[n||i,n||!i?lJ(t,i&&i.multi?e=>{let n=ss(e,o);return i0(n)&&n.some(e=>r(s,e))}:e=>r(s,ss(e,o))):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,i0(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 a in n)if(i5(n,a))try{t[a]=n[a]}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){i1(this,e)})}add(e,n){let{auto:t,keyPath:a}=this.schema.primKey,o=e;return a&&t&&(o=lX(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[o]})).then(e=>e.numFailures?lr.reject(e.failures[0]):e.lastResult).then(n=>{if(a)try{sl(e,a,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||i0(e))return this.where(":id").equals(e).modify(n);{let t=ss(e,this.schema.primKey.keyPath);if(void 0===t)return lj(new sI.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?iQ(n).forEach(t=>{sl(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:a}=this.schema.primKey,o=e;return a&&t&&(o=lX(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=n?[n]:null})).then(e=>e.numFailures?lr.reject(e.failures[0]):e.lastResult).then(n=>{if(a)try{sl(e,a,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?lr.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lZ})).then(e=>e.numFailures?lr.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 a=Array.isArray(n)?n:void 0,o=(t=t||(a?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&a)throw new sI.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new sI.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(lX(r)):e;return this.core.mutate({trans:n,type:"add",keys:a,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:a})=>{if(0===e)return o?n:t;throw new sT(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,a)})})}bulkPut(e,n,t){let a=Array.isArray(n)?n:void 0,o=(t=t||(a?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&a)throw new sI.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new sI.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(lX(r)):e;return this.core.mutate({trans:n,type:"put",keys:a,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:a})=>{if(0===e)return o?n:t;throw new sT(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,a)})})}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:a})=>{if(0===e)return t;throw new sT(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,a)})}}function l0(e){var n={},t=function(t,a){if(a){for(var o=arguments.length,r=Array(o-1);--o;)r[o-1]=arguments[o];return n[t].subscribe.apply(null,r),e}if("string"==typeof t)return n[t]};t.addEventType=r;for(var a=1,o=arguments.length;a<o;++a)r(arguments[a]);return t;function r(e,a,o){if("object"!=typeof e){a||(a=sq),o||(o=sR);var i={subscribers:[],fire:o,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=a(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(a,o)}};return n[e]=t[e]=i,i}iQ(e).forEach(function(n){var t=e[n];if(i0(t))r(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new sI.InvalidArgument("Invalid event config");var a=r(n,sF,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];a.subscribers.forEach(function(e){sr(function(){e.apply(null,n)})})})}})}}function l1(e,n){return i7(n).from({prototype:e}),n}function l2(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function l3(e,n){e.filter=lJ(e.filter,n)}function l5(e,n,t){var a=e.replayFilter;e.replayFilter=a?()=>lJ(a(),n()):n,e.justLimit=t&&!a}function l4(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new sI.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function l6(e,n,t){let a=l4(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:a,range:e.range}})}function l8(e,n,t,a){let o=e.replayFilter?lJ(e.filter,e.replayFilter()):e.filter;if(e.or){let r={},i=(e,t,a)=>{if(!o||o(t,a,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),i5(r,s)||(r[s]=!0,n(e,t,a))}};return Promise.all([e.or._iterate(i,t),l7(l6(e,a,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return l7(l6(e,a,t),lJ(e.algorithm,o),n,!e.keysOnly&&e.valueMapper)}function l7(e,n,t,a){var o=lb(a?(e,n,o)=>t(a(e),n,o):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=sR},n=>{e.fail(n),t=sR})||o(e.value,e,e=>t=e),t()})})}function l9(e,n){try{let t=ce(e),a=ce(n);if(t!==a)return"Array"===t?1:"Array"===a?-1:"binary"===t?1:"binary"===a?-1:"string"===t?1:"string"===a?-1:"Date"===t?1:"Date"!==a?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,a=n.length,o=t<a?t:a;for(let t=0;t<o;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===a?0:t<a?-1:1}(cn(e),cn(n));case"Array":return function(e,n){let t=e.length,a=n.length,o=t<a?t:a;for(let t=0;t<o;++t){let a=l9(e[t],n[t]);if(0!==a)return a}return t===a?0:t<a?-1:1}(e,n)}}catch(e){}return NaN}function ce(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=sy(e);return"ArrayBuffer"===t?"binary":t}function cn(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class ct{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,lj.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,lj.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=lJ(n.algorithm,e)}_iterate(e,n){return l8(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&i1(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>l8(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(l2(n,!0))return t.count({trans:e,query:{index:l4(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var a=0;return l8(n,()=>(++a,!1),e,t).then(()=>a)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),a=t[0],o=t.length-1;function r(e,n){return n?r(e[t[n]],n-1):e[a]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=r(e,o),a=r(n,o);return t<a?-i:t>a?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&&l2(n,!0)&&n.limit>0){let{valueMapper:t}=n,a=l4(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:a,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return l8(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,l2(n)?l5(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):l5(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),l5(this._ctx,()=>{var n=e;return function(e,t,a){return--n<=0&&t(a),n>=0}},!0),this}until(e,n){return l3(this._ctx,function(t,a,o){return!e(t.value)||(a(o),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 l3(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=lJ(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&&l2(n,!0)&&n.limit>0)return this._read(e=>{var t=l4(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 l3(this._ctx,function(e){var n=e.primaryKey.toString(),a=i5(t,n);return t[n]=!0,!a}),this}modify(e){var n=this._ctx;return this._write(t=>{var a;if("function"==typeof e)a=e;else{var o=iQ(e),r=o.length;a=function(n){for(var t=!1,a=0;a<r;++a){var i=o[a],s=e[i];ss(n,i)!==s&&(sl(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,n)=>{let{failures:t,numFailures:a}=n;for(let n of(p+=e-a,iQ(t)))u.push(t[n])};return this.clone().primaryKeys().then(o=>{let r=u=>{let p=Math.min(c,o.length-u);return i.getMany({trans:t,keys:o.slice(u,u+p),cache:"immutable"}).then(d=>{let m=[],h=[],g=s?[]:null,y=[];for(let e=0;e<p;++e){let n=d[e],t={value:sh(n),primKey:o[u+e]};!1!==a.call(t,t.value,t)&&(null==t.value?y.push(o[u+e]):s||0===l9(l(n),l(t.value))?(h.push(t.value),s&&g.push(o[u+e])):(y.push(o[u+e]),m.push(t.value)))}let b=l2(n)&&n.limit===1/0&&("function"!=typeof e||e===ca)&&{index:n.index,range:n.range};return Promise.resolve(m.length>0&&i.mutate({trans:t,type:"add",values:m}).then(e=>{for(let n in e.failures)y.splice(parseInt(n),1);f(m.length,e)})).then(()=>(h.length>0||b&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:h,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(h.length,e))).then(()=>(y.length>0||b&&e===ca)&&i.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>o.length>u+p&&r(u+c))})};return r(0).then(()=>{if(u.length>0)throw new sP("Error modifying one or more objects",u,p,d);return o.length})})})}delete(){var e=this._ctx,n=e.range;return l2(e)&&(e.isPrimKey&&!lU||3===n.type)?this._write(t=>{let{primaryKey:a}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:a,range:n}}).then(a=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:o})=>{if(o)throw new sP("Could not delete some values",Object.keys(e).map(n=>e[n]),a-o);return a-o}))}):this.modify(ca)}}let ca=(e,n)=>n.value=null;function co(e,n){return e<n?-1:+(e!==n)}function cr(e,n){return e>n?-1:+(e!==n)}function ci(e,n,t){var a=e instanceof cp?new e.Collection(e):e;return a._ctx.error=t?new t(n):TypeError(n),a}function cs(e){return new e.Collection(e,()=>cu("")).limit(0)}function cl(e,n,t,a){var o,r,i,s,l,c,u,p=t.length;if(!t.every(e=>"string"==typeof e))return ci(e,lG);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),r="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?co:cr;var n=t.map(function(e){return{lower:r(e),upper:o(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,u="next"===e?"":a}d("next");var f=new e.Collection(e,()=>cc(s[0],l[p-1]+a));f._ondirectionchange=function(e){d(e)};var m=0;return f._addAlgorithm(function(e,t,a){var o=e.key;if("string"!=typeof o)return!1;var d=r(o);if(n(d,l,m))return!0;for(var f=null,h=m;h<p;++h){var g=function(e,n,t,a,o,r){for(var i=Math.min(e.length,a.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==a[l])return 0>o(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>o(e[l],a[l])?e.substr(0,l)+a[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>o(e[l],c)&&(s=l)}return i<a.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)+a[s]+t.substr(s+1)}(o,d,s[h],l[h],i,c);null===g&&null===f?m=h+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+u)}:a),!1}),f}function cc(e,n,t,a){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:a}}function cu(e){return{type:1,lower:e,upper:e}}class cp{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,a){t=!1!==t,a=!0===a;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||a)&&(!t||!a)?cs(this):new this.Collection(this,()=>cc(e,n,!t,!a))}catch(e){return ci(this,lW)}}equals(e){return null==e?ci(this,lW):new this.Collection(this,()=>cu(e))}above(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(e,void 0,!0))}aboveOrEqual(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(e,void 0,!1))}below(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(void 0,e,!1,!0))}belowOrEqual(e){return null==e?ci(this,lW):new this.Collection(this,()=>cc(void 0,e))}startsWith(e){return"string"!=typeof e?ci(this,lG):this.between(e,e+lF,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):cl(this,(e,n)=>0===e.indexOf(n[0]),[e],lF)}equalsIgnoreCase(e){return cl(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=s$.apply(sv,arguments);return 0===e.length?cs(this):cl(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=s$.apply(sv,arguments);return 0===e.length?cs(this):cl(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,lF)}anyOf(){let e=s$.apply(sv,arguments),n=this._cmp;try{e.sort(n)}catch(e){return ci(this,lW)}if(0===e.length)return cs(this);let t=new this.Collection(this,()=>cc(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let a=0;return t._addAlgorithm((t,o,r)=>{let i=t.key;for(;n(i,e[a])>0;)if(++a===e.length)return o(r),!1;return 0===n(i,e[a])||(o(()=>{t.continue(e[a])}),!1)}),t}notEqual(e){return this.inAnyRange([[lL,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=s$.apply(sv,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return ci(this,lW)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[lL,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,a=this._ascending,o=this._descending,r=this._min,i=this._max;if(0===e.length)return cs(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=a(e[0],e[1])))return ci(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sI.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,u=a;function p(e,n){return u(e[0],n[0])}try{(c=e.reduce(function(e,n){let a=0,o=e.length;for(;a<o;++a){let o=e[a];if(0>t(n[0],o[1])&&t(n[1],o[0])>0){o[0]=r(o[0],n[0]),o[1]=i(o[1],n[1]);break}}return a===o&&e.push(n),e},[])).sort(p)}catch(e){return ci(this,lW)}let d=0,f=l?e=>a(e,c[d][1])>0:e=>a(e,c[d][1])>=0,m=s?e=>o(e,c[d][0])>0:e=>o(e,c[d][0])>=0,h=f,g=new this.Collection(this,()=>cc(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(h=f,u=a):(h=m,u=o),c.sort(p)},g._addAlgorithm((e,n,t)=>{for(var o=e.key;h(o);)if(++d===c.length)return n(t),!1;return!!(!f(o)&&!m(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||n(()=>{u===a?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=s$.apply(sv,arguments);return e.every(e=>"string"==typeof e)?0===e.length?cs(this):this.inAnyRange(e.map(e=>[e,e+lF])):ci(this,"startsWithAnyOf() only works with strings")}}function cd(e){return lb(function(n){return cf(n),e(n.target.error),!1})}function cf(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let cm="storagemutated",ch="x-storagemutated-1",cg=l0(null,cm);class cy{_lock(){return so(!ln.global),++this._reculock,1!==this._reculock||ln.global||(ln.lockOwnerFor=this),this}_unlock(){if(so(!ln.global),0==--this._reculock)for(ln.global||(ln.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lP(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&ln.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(so(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new sI.DatabaseClosed(t);case"MissingAPIError":throw new sI.MissingAPI(t.message,t);default:throw new sI.OpenFailed(t)}if(!this.active)throw new sI.TransactionInactive;return so(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=lb(n=>{cf(n),this._reject(e.error)}),e.onabort=lb(n=>{cf(n),this.active&&this._reject(new sI.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=lb(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&cg.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return lj(new sI.ReadOnly("Transaction is readonly"));if(!this.active)return lj(new sI.TransactionInactive);if(this._locked())return new lr((a,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(a,o)},ln])});if(t)return lx(()=>{var e=new lr((e,t)=>{this._lock();let a=n(e,t,this);a&&a.then&&a.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var a=new lr((e,t)=>{var a=n(e,t,this);a&&a.then&&a.then(e,t)});return a._lib=!0,a}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=lr.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var a=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(a.get(-1/0).onsuccess=e)}()}var o=n._waitingFor;return new lr((e,a)=>{t.then(t=>n._waitingQueue.push(lb(e.bind(null,t))),e=>n._waitingQueue.push(lb(a.bind(null,e)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sI.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(i5(n,e))return n[e];let t=this.schema[e];if(!t)throw new sI.NotFound("Table "+e+" not part of transaction");let a=new this.db.Table(e,t,this);return a.core=this.db.core.table(e),n[e]=a,a}}function cb(e,n,t,a,o,r,i){return{name:e,keyPath:n,unique:t,multi:a,auto:o,compound:r,src:(t&&!i?"&":"")+(a?"*":"")+(o?"++":"")+c_(n)}}function c_(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function cv(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:si(t,e=>[e.name,e])}}let c$=e=>{try{return e.only([[]]),c$=()=>[[]],[[]]}catch(e){return c$=()=>lF,lF}};function cA(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>ss(n,e):n=>ss(n,e)}function ck(e){return[].slice.call(e)}let cw=0;function cx(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function cC({_novip:e},n){let t=n.db,a=function(e,n,{IDBKeyRange:t,indexedDB:a},o){var r;return{dbcore:(r=function(e,n,t){let a;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:a,lowerOpen:o,upperOpen:r}=e;return void 0===t?void 0===a?null:n.upperBound(a,!!r):void 0===a?n.lowerBound(t,!!o):n.bound(t,a,!!o,!!r)}let{schema:r,hasGetAll:i}=(a=ck(e.objectStoreNames),{schema:{name:e.name,tables:a.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,a=i0(n),o=null==n,r={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:a,keyPath:n,autoIncrement:t,unique:!0,extractKey:cA(n)},indexes:ck(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:a,keyPath:o}=e,i={name:n,compound:i0(o),keyPath:o,unique:t,multiEntry:a,extractKey:cA(o)};return r[cx(o)]=i,i}),getIndexByKeyPath:e=>r[cx(e)]};return r[":id"]=i.primaryKey,null!=n&&(r[cx(n)]=i.primaryKey),i})},hasGetAll:a.length>0&&"getAll"in t.objectStore(a[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:a,values:r,range:i}){return new Promise((s,l)=>{let c;s=lb(s);let u=e.objectStore(n),p=null==u.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=a||r||{length:1};if(a&&r&&a.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 m=[],h=[],g=0,y=e=>{++g,cf(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:h,results:[],lastResult:void 0});3===i.type?m.push(c=u.clear()):m.push(c=u.delete(o(i)))}else{let[e,n]=d?p?[r,a]:[r,null]:[a,null];if(d)for(let a=0;a<f;++a)m.push(c=n&&void 0!==n[a]?u[t](e[a],n[a]):u[t](e[a])),c.onerror=y;else for(let n=0;n<f;++n)m.push(c=u[t](e[n])),c.onerror=y}let b=e=>{let n=e.target.result;m.forEach((e,n)=>null!=e.error&&(h[n]=e.error)),s({numFailures:g,failures:h,results:"delete"===t?a:m.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((a,o)=>{a=lb(a);let r=e.objectStore(n),i=t.length,s=Array(i),l,c=0,u=0,p=e=>{let n=e.target;s[n._pos]=n.result,++u===c&&a(s)},d=cd(o);for(let e=0;e<i;++e)null!=t[e]&&((l=r.get(t[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&a(s)}),get:({trans:e,key:t})=>new Promise((a,o)=>{a=lb(a);let r=e.objectStore(n).get(t);r.onsuccess=e=>a(e.target.result),r.onerror=cd(o)}),query:e=>new Promise((t,a)=>{t=lb(t);let{trans:r,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=r.objectStore(n),m=p.isPrimaryKey?f:f.index(p.name),h=o(d);if(0===l)return t({result:[]});if(i){let e=s?m.getAll(h,u):m.getAllKeys(h,u);e.onsuccess=e=>t({result:e.target.result}),e.onerror=cd(a)}else{let e=0,n=!s&&"openKeyCursor"in m?m.openKeyCursor(h):m.openCursor(h),o=[];n.onsuccess=a=>{let r=n.result;return r?(o.push(s?r.value:r.primaryKey),++e===l?t({result:o}):void r.continue()):t({result:o})},n.onerror=cd(a)}}),openCursor:function({trans:e,values:t,query:a,reverse:r,unique:i}){return new Promise((s,l)=>{s=lb(s);let{index:c,range:u}=a,p=e.objectStore(n),d=c.isPrimaryKey?p:p.index(c.name),f=r?i?"prevunique":"prev":i?"nextunique":"next",m=!t&&"openKeyCursor"in d?d.openKeyCursor(o(u),f):d.openCursor(o(u),f);m.onerror=cd(l),m.onsuccess=lb(n=>{let t=m.result;if(!t)return void s(null);t.___id=++cw,t.done=!1;let a=t.continue.bind(t),o=t.continuePrimaryKey;o&&(o=o.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=lb(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=lb(e),m.onerror=cd(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(m.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return m.onsuccess=lb(e=>{m.onsuccess=s,s()}),t.continue=a,t.continuePrimaryKey=o,t.advance=r,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:a,range:r}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=a.isPrimaryKey?s:s.index(a.name),c=o(r),u=c?l.count(c):l.count();u.onsuccess=lb(n=>e(n.target.result)),u.onerror=cd(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:c$(n),schema:r}}(n,t,o),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),r))}}(e._middlewares,t,e._deps,n);e.core=a.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 cE({_novip:e},n,t,a){t.forEach(t=>{let o=a[t];n.forEach(n=>{let a=se(n,t);(!a||"value"in a&&void 0===a.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?i8(n,t,{get(){return this.table(t)},set(e){i6(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,o))})})}function cS({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function cD(e,n){return e._cfg.version-n._cfg.version}function cM(e,n){let t,a={del:[],add:[],change:[]};for(t in e)n[t]||a.del.push(t);for(t in n){let o=e[t],r=n[t];if(o){let e={name:t,def:r,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(r.primKey.keyPath||"")&&(o.primKey.auto===r.primKey.auto||lU)){let n,t=o.idxByName,i=r.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let a=t[n],o=i[n];a?a.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&a.change.push(e)}else e.recreate=!0,a.change.push(e)}else a.add.push([t,r])}return a}function cz(e,n,t,a){let o=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return a.forEach(e=>cO(o,e)),o}function cO(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function cP(e,n,t){let a={};return st(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),o=n.keyPath,r=cb(c_(o),o||"",!1,!1,!!n.autoIncrement,o&&"string"!=typeof o,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);o=t.keyPath;var s=cb(t.name,o,!!t.unique,!!t.multiEntry,!1,o&&"string"!=typeof o,!1);i.push(s)}a[e]=cv(e,r,i)}),a}function cT({_novip:e},n,t){let a=t.db.objectStoreNames;for(let o=0;o<a.length;++o){let r=a[o],i=t.objectStore(r);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],a=i.index(t).keyPath,o="string"==typeof a?a:"["+st(a).join("+")+"]";if(n[r]){let e=n[r].idxByName[o];e&&(e.name=t,delete n[r].idxByName[o],n[r].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&iX.WorkerGlobalScope&&iX instanceof iX.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class cB{_parseStoresSpec(e,n){iQ(e).forEach(t=>{if(null!==e[t]){var a=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),a=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return cb(t,a||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),i0(a),0===n)}),o=a.shift();if(o.multi)throw new sI.Schema("Primary key cannot be multi-valued");a.forEach(e=>{if(e.auto)throw new sI.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sI.Schema("Index must have a name and cannot be an empty string")}),n[t]=cv(t,o,a)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?i1(this._cfg.storesSource,e):e;let t=n._versions,a={},o={};return t.forEach(e=>{i1(a,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(a,o)}),n._dbSchema=o,cS(n,[n._allTables,n,n.Transaction.prototype]),cE(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],iQ(o),o),n._storeNames=iQ(o),this}upgrade(e){return this._cfg.contentUpgrade=sH(this._cfg.contentUpgrade||sR,e),this}}function cI(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new c1(lH,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function cN(e){return e&&"function"==typeof e.databases}function cj(e){return lx(function(){return ln.letThrough=!0,e()})}function cR(e){var n=n=>e.next(n),t=o(n),a=o(n=>e.throw(n));function o(e){return n=>{var o=e(n),r=o.value;return o.done?r:r&&"function"==typeof r.then?r.then(t,a):i0(r)?Promise.all(r).then(t,a):t(r)}}return o(n)()}function cF(e,n,t){var a=arguments.length;if(a<2)throw new sI.InvalidArgument("Too few arguments");for(var o=Array(a-1);--a;)o[a-1]=arguments[a];return t=o.pop(),[e,sp(o),t]}function cL(e,n,t){let a=i0(e)?e.slice():[e];for(let e=0;e<t;++e)a.push(n);return a}let cW={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:a}=t,o={},r=[];function i(e,n,t){let a=cx(e),s=o[a]=o[a]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,u={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:cA(e),unique:!c&&t.unique};return s.push(u),u.isPrimaryKey||r.push(u),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),u}let s=i(a.primaryKey.keyPath,0,a.primaryKey);for(let e of(o[":id"]=[s],a.indexes))i(e.keyPath,0,e);function l(n){var t,a;let o=n.query.index;return o.isVirtual?{...n,query:{index:o,range:(t=n.query.range,a=o.keyTail,{type:1===t.type?2:t.type,lower:cL(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,a),lowerOpen:!0,upper:cL(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,a),upperOpen:!0})}}:n}return{...t,schema:{...a,primaryKey:s,indexes:r,getIndexByKeyPath:function(e){let n=o[cx(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:a,isVirtual:o,keyLength:r}=n.query.index;return o?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(o){null!=o?t.continue(cL(o,n.reverse?e.MAX_KEY:e.MIN_KEY,a)):n.unique?t.continue(t.key.slice(0,r).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,a)):t.continue()}},continuePrimaryKey:{value(n,o){t.continuePrimaryKey(cL(n,e.MAX_KEY,a),o)}},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 cG(e,n,t,a){return t=t||{},a=a||"",iQ(e).forEach(o=>{if(i5(n,o)){var r=e[o],i=n[o];if("object"==typeof r&&"object"==typeof i&&r&&i){let e=sy(r);e!==sy(i)?t[a+o]=n[o]:"Object"===e?cG(r,i,t,a+o+"."):r!==i&&(t[a+o]=n[o])}else r!==i&&(t[a+o]=n[o])}else t[a+o]=void 0}),iQ(n).forEach(o=>{i5(e,o)||(t[a+o]=n[o])}),t}let cV={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:a}=t.schema;return{...t,mutate(e){let o=ln.trans,{deleting:r,creating:i,updating:s}=o.table(n).hook;switch(e.type){case"add":if(i.fire===sR)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===sR&&s.fire===sR)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(r.fire===sR)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(r.fire===sR)break;return o._promise("readwrite",()=>(function e(n,o,r){return t.query({trans:n,values:!1,query:{index:a,range:o},limit:r}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(a=>a.numFailures>0?Promise.reject(a.failures[0]):t.length<r?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...o,lower:t[t.length-1],lowerOpen:!0},r)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,o;let l=ln.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(a.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"===(o=e).type?Promise.resolve([]):t.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(n=>{let o=c.map((t,o)=>{let c=n[o],u={onerror:null,onsuccess:null};if("delete"===e.type)r.fire.call(u,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(u,t,e.values[o],l);null==t&&null!=n&&(t=n,e.keys[o]=t,a.outbound||sl(e.values[o],a.keyPath,t))}else{let n=cG(c,e.values[o]),a=s.fire.call(u,n,t,c,l);if(a){let n=e.values[o];Object.keys(a).forEach(e=>{i5(n,e)?n[e]=a[e]:sl(n,e,a[e])})}}return u});return t.mutate(e).then(({failures:t,results:a,numFailures:r,lastResult:i})=>{for(let r=0;r<c.length;++r){let i=a?a[r]:c[r],s=o[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:a,numFailures:r,lastResult:i}}).catch(e=>(o.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cU(e,n,t){try{if(!n||n.keys.length<e.length)return null;let a=[];for(let o=0,r=0;o<n.keys.length&&r<e.length;++o)0===l9(n.keys[o],e[r])&&(a.push(t?sh(n.values[o]):n.values[o]),++r);return a.length===e.length?a:null}catch(e){return null}}let cq={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=cU(e.keys,e.trans._cache,"clone"===e.cache);return n?lr.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sh(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cH(e){return!("from"in e)}let cK=function(e,n){if(!this){let n=new cK;return e&&"d"in e&&i1(n,e),n}i1(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function cY(e,n,t){let a=l9(n,t);if(isNaN(a))return;if(a>0)throw RangeError();if(cH(e))return i1(e,{from:n,to:t,d:1});let o=e.l,r=e.r;if(0>l9(t,e.from))return o?cY(o,n,t):e.l={from:n,to:t,d:1,l:null,r:null},cX(e);if(l9(n,e.to)>0)return r?cY(r,n,t):e.r={from:n,to:t,d:1,l:null,r:null},cX(e);0>l9(n,e.from)&&(e.from=n,e.l=null,e.d=r?r.d+1:1),l9(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;o&&!e.l&&cJ(e,o),r&&i&&cJ(e,r)}function cJ(e,n){cH(n)||function e(n,{from:t,to:a,l:o,r:r}){cY(n,t,a),o&&e(n,o),r&&e(n,r)}(e,n)}function cZ(e){let n=cH(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>l9(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>=l9(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 cX(e){var n,t;let a=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),o=a>1?"r":a<-1?"l":"";if(o){let n="r"===o?"l":"r",t={...e},a=e[o];e.from=a.from,e.to=a.to,e[o]=a[o],t[o]=a[n],e[n]=t,t.d=cQ(t)}e.d=cQ(e)}function cQ({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}i4(cK.prototype,{add(e){return cJ(this,e),this},addKey(e){return cY(this,e,e),this},addKeys(e){return e.forEach(e=>cY(this,e,e)),this},[sb](){return cZ(this)}});let c0={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new cK(e.MIN_KEY,e.MAX_KEY);return{...e,table:a=>{let o=e.table(a),{schema:r}=o,{primaryKey:i}=r,{extractKey:s,outbound:l}=i,c={...o,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${a}/${e}`;return s[t]||(s[t]=new cK)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],m=e.trans._cache;return o.mutate(e).then(e=>{if(i0(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let n=cU(d,m);n||"add"===p||u.addKeys(d),(n||f)&&r.indexes.forEach(function(e){let t=l(e.name||"");function a(n){return null!=n?e.extractKey(n):null}let o=n=>e.multiEntry&&i0(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let r=n&&a(n[t]),i=f&&a(f[t]);0!==l9(r,i)&&(null!=r&&o(r),null!=i&&o(i))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(t),u.add(t),r.indexes.forEach(e=>l(e.name).add(t));return e})}},u=({query:{index:n,range:t}})=>{var a,o;return[n,new cK(null!=(a=t.lower)?a:e.MIN_KEY,null!=(o=t.upper)?o:e.MAX_KEY)]},p={get:e=>[i,new cK(e.key)],getMany:e=>[i,(new cK).addKeys(e.keys)],count:u,query:u,openCursor:u};return iQ(p).forEach(e=>{c[e]=function(r){let{subscr:i}=ln;if(i){let c=e=>{let t=`idb://${n}/${a}/${e}`;return i[t]||(i[t]=new cK)},u=c(""),d=c(":dels"),[f,m]=p[e](r);if(c(f.name||"").add(m),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&r.values&&o.query({...r,values:!1});return o[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&r.values)return n.then(({result:e})=>(u.addKeys(e),t));let e=r.values?t.result.map(s):t.result;r.values?u.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&&u.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return o[e].apply(this,arguments)}}),c}}}};class c1{constructor(e,n){var t;this._middlewares={},this.verno=0;const a=c1.dependencies;this._options=n={addons:c1.addons,autoOpen:!0,indexedDB:a.indexedDB,IDBKeyRange:a.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=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:sR,dbReadyPromise:null,cancelOpen:sR,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};r.dbReadyPromise=new lr(e=>{r.dbReadyResolve=e}),r.openCanceller=new lr((e,n)=>{r.cancelOpen=n}),this._state=r,this.name=e,this.on=l0(this,"populate","blocked","versionchange","close",{ready:[sH,sR]}),this.on.ready.subscribe=sa(this.on.ready.subscribe,e=>(n,t)=>{c1.vip(()=>{let a=this._state;if(a.openComplete)a.dbOpenError||lr.resolve().then(n),t&&e(n);else if(a.onReadyBeingFired)a.onReadyBeingFired.push(n),t&&e(n);else{e(n);let a=this;t||e(function e(){a.on.ready.unsubscribe(n),a.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,l1(ct.prototype,function(e,n){this.db=t;let a=lZ,o=null;if(n)try{a=n()}catch(e){o=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:a,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:r.or,valueMapper:s!==sF?s:null}})),this.Table=function(e){return l1(lQ.prototype,function(n,t,a){this.db=e,this._tx=a,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:l0(null,{creating:[sG,sR],reading:[sL,sF],updating:[sU,sR],deleting:[sV,sR]})})}(this),this.Transaction=function(e){return l1(cy.prototype,function(n,t,a,o,r){this.db=e,this.mode=n,this.storeNames=t,this.schema=a,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=l0(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 lr((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(),lj(e)})})}(this),this.Version=function(e){return l1(cB.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return l1(cp.prototype,function(n,t,a){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:a};let o=e._deps.indexedDB;if(!o)throw new sI.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,n)=>o.cmp(n,e),this._max=(e,n)=>o.cmp(e,n)>0?e:n,this._min=(e,n)=>0>o.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=c$(n.IDBKeyRange),this._createTransaction=(e,n,t,a)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,a),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lV.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(cW),this.use(cV),this.use(c0),this.use(cq),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sI.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sI.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(cD),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ln.letThrough||this._vip)?e():new lr((e,n)=>{if(this._state.openComplete)return n(new sI.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new sI.DatabaseClosed);this.open().catch(sR)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:a}){a&&this.unuse({stack:e,name:a});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:n,level:null==t?10:t,name:a}),o.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:a}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?lj(t.dbOpenError):e);sk&&(t.openCanceller._stackHolder=sC()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let o=t.openCanceller;function r(){if(t.openCanceller!==o)throw new sI.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1;return lr.race([o,("u"<typeof navigator?lr.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(()=>new lr((n,o)=>{if(r(),!a)throw new sI.MissingAPI;let i=e.name,c=t.autoSchema?a.open(i):a.open(i,Math.round(10*e.verno));if(!c)throw new sI.MissingAPI;c.onerror=cd(o),c.onblocked=lb(e._fireOnBlocked),c.onupgradeneeded=lb(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=cf,s.abort(),c.result.close();let e=a.deleteDatabase(i);e.onsuccess=e.onerror=lb(()=>{o(new sI.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,a,i,d;s.onerror=cd(o);var r,u,p=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=p<1,e._novip.idbdb=c.result,r=p/10,u=s,t=e._dbSchema,(a=e._createTransaction("readwrite",e._storeNames,t)).create(u),a._completion.catch(o),i=a._reject.bind(a),d=ln.transless||ln,lx(()=>{ln.trans=a,ln.transless=d,0===r?(iQ(t).forEach(e=>{cz(u,e,t[e].primKey,t[e].indexes)}),cC(e,u),lr.follow(()=>e.on.populate.fire(a)).catch(i)):(function({_novip:e},n,t,a){let o=[],r=e._versions,i=e._dbSchema=cP(e,e.idbdb,a),s=!1;return r.filter(e=>e._cfg.version>=n).forEach(r=>{o.push(()=>{let o=i,l=r._cfg.dbschema;cT(e,o,a),cT(e,l,a),i=e._dbSchema=l;let c=cM(o,l);c.add.forEach(e=>{cz(a,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new sI.Upgrade("Not yet support for changing primary key");{let n=a.objectStore(e.name);e.add.forEach(e=>cO(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),cO(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let u=r._cfg.contentUpgrade;if(u&&r._cfg.version>n){let n;cC(e,a),t._memoizedTables={},s=!0;let r=sc(l);c.del.forEach(e=>{r[e]=o[e]}),cS(e,[e.Transaction.prototype]),cE(e,[e.Transaction.prototype],iQ(r),r),t.schema=r;let i=sA(u);i&&lC();let p=lr.follow(()=>{if((n=u(t))&&i){var e=lE.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?lr.resolve(n):p.then(()=>n)}}),o.push(n=>{var a;s&&lU||(a=r._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==a[e]&&n.db.deleteObjectStore(e))),cS(e,[e.Transaction.prototype]),cE(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return o.length?lr.resolve(o.shift()(t.idbtrans)).then(e):lr.resolve()})().then(()=>{var e;iQ(e=i).forEach(n=>{a.db.objectStoreNames.contains(n)||cz(a,n,e[n].primKey,e[n].indexes)})})})(e,r,a,u).catch(i)})}},o),c.onsuccess=lb(()=>{s=null;let a=e._novip.idbdb=c.result,o=st(a.objectStoreNames);if(o.length>0)try{let n,r=a.transaction(1===o.length?o[0]:o,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let a=e._dbSchema=cP(0,n,t);e._storeNames=st(n.objectStoreNames,0),cE(e,[e._allTables],iQ(a),a)}(e,a,r):(cT(e,e._dbSchema,r),((n=cM(cP(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.")),cC(e,r)}catch(e){}lV.push(e),a.onversionchange=lb(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),a.onclose=lb(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){cN(e)||t===lH||cI(e,n).put({name:t}).catch(sR)}(e._deps,i),n()},o)}))]).then(()=>(r(),t.onReadyBeingFired=[],lr.resolve(cj(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let a=t.onReadyBeingFired.reduce(sH,sR);return t.onReadyBeingFired=[],lr.resolve(cj(()=>a(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 o===t.openCanceller&&e._close(),lj(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=lV.indexOf(this);if(n>=0&&lV.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new lr(n=>{e.dbReadyResolve=n}),e.openCanceller=new lr((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sI.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new lr((t,a)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lb(()=>{!function({indexedDB:e,IDBKeyRange:n},t){cN(e)||t===lH||cI(e,n).delete(t).catch(sR)}(this._deps,this.name),t()}),e.onerror=cd(a),e.onblocked=this._fireOnBlocked};if(e)throw new sI.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(o):o()})}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 iQ(this._allTables).map(e=>this._allTables[e])}transaction(){let e=cF.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let a,o,r=ln.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=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===lK)a=lK;else{if("rw"!=e&&e!=lY)throw new sI.InvalidArgument("Invalid transaction mode: "+e);a=lY}if(r){if(r.mode===lK&&a===lY){if(!i)throw new sI.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&o.forEach(e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!i)throw new sI.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)}):lj(e)}let s=(function e(n,t,a,o,r){return lr.resolve().then(()=>{let i,s=ln.transless||ln,l=n._createTransaction(t,a,n._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===sB.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,a,null,r))):lj(o)}let c=sA(r);c&&lC();let u=lr.follow(()=>{if(i=r.call(l,l))if(c){var e=lE.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=cR(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?lr.resolve(i).then(e=>l.active?e:lj(new sI.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>i)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),lj(e)))})}).bind(null,this,a,o,r,t);return r?r._promise(a,s,"lock"):ln.trans?lP(ln.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!i5(this._allTables,e))throw new sI.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let c2="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class c3{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[c2](){return this}}function c5(e,n){return iQ(n).forEach(t=>{cJ(e[t]||(e[t]=new cK),n[t])}),e}try{r={indexedDB:iX.indexedDB||iX.mozIndexedDB||iX.webkitIndexedDB||iX.msIndexedDB,IDBKeyRange:iX.IDBKeyRange||iX.webkitIDBKeyRange}}catch(e){r={indexedDB:null,IDBKeyRange:null}}function c4(e){let n=c6;try{c6=!0,cg.storagemutated.fire(e)}finally{c6=n}}i4(c1,{...sj,delete:e=>new c1(e,{addons:[]}).delete(),exists:e=>new c1(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return cN(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lH)):cI(e,n).toCollection().primaryKeys()})(c1.dependencies).then(e)}catch(e){return lj(new sI.MissingAPI)}},defineClass:()=>function(e){i1(this,e)},ignoreTransaction:e=>ln.trans?lP(ln.transless,e):e(),vip:cj,async:function(e){return function(){try{var n=cR(e.apply(this,arguments));return n&&"function"==typeof n.then?n:lr.resolve(n)}catch(e){return lj(e)}}},spawn:function(e,n,t){try{var a=cR(e.apply(t,n||[]));return a&&"function"==typeof a.then?a:lr.resolve(a)}catch(e){return lj(e)}},currentTransaction:{get:()=>ln.trans||null},waitFor:function(e,n){let t=lr.resolve("function"==typeof e?c1.ignoreTransaction(e):e).timeout(n||6e4);return ln.trans?ln.trans.waitFor(t):t},Promise:lr,debug:{get:()=>sk,set:e=>{sk=e,sw="dexie"===e?()=>!0:lq}},derive:i7,extend:i1,props:i4,override:sa,Events:l0,on:cg,liveQuery:function(e){let n,t=!1,a=new c3(a=>{let o=sA(e),r=!1,i={},s={},l={get closed(){return r},unsubscribe:()=>{r=!0,cg.storagemutated.unsubscribe(d)}};a.start&&a.start(l);let c=!1,u=!1;function p(){return iQ(s).some(e=>i[e]&&function(e,n){let t=cZ(n),a=t.next();if(a.done)return!1;let o=a.value,r=cZ(e),i=r.next(o.from),s=i.value;for(;!a.done&&!i.done;){if(0>=l9(s.from,o.to)&&l9(s.to,o.from)>=0)return!0;0>l9(o.from,s.from)?o=(a=t.next(s.from)).value:s=(i=r.next(o.from)).value}return!1}(i[e],s[e]))}let d=e=>{c5(i,e),p()&&f()},f=()=>{let m,h;if(c||r)return;i={};let g={},y=(o&&lC(),m=()=>lx(e,{subscr:g,trans:null}),h=ln.trans?lP(ln.transless,m):m(),o&&h.then(lE,lE),h);u||(cg(cm,d),u=!0),c=!0,Promise.resolve(y).then(e=>{t=!0,n=e,c=!1,r||(p()?f():(i={},s=g,a.next&&a.next(e)))},e=>{c=!1,t=!1,a.error&&a.error(e),l.unsubscribe()})};return f(),l});return a.hasValue=()=>t,a.getValue=()=>n,a},extendObservabilitySet:c5,getByKeyPath:ss,setByKeyPath:sl,delByKeyPath:function(e,n){"string"==typeof n?sl(e,n,void 0):"length"in n&&[].map.call(n,function(n){sl(e,n,void 0)})},shallowClone:sc,deepClone:sh,getObjectDiff:cG,cmp:l9,asap:sr,minKey:lL,addons:[],connections:lV,errnames:sB,dependencies:r,semVer:lR,version:lR.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),c1.maxKey=c$(c1.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(cg(cm,e=>{if(!c6){let n;lU?(n=document.createEvent("CustomEvent")).initCustomEvent(ch,!0,!0,e):n=new CustomEvent(ch,{detail:e}),c6=!0,dispatchEvent(n),c6=!1}}),addEventListener(ch,({detail:e})=>{c6||c4(e)}));let c6=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(ch);"function"==typeof e.unref&&e.unref(),cg(cm,n=>{c6||e.postMessage(n)}),e.onmessage=e=>{e.data&&c4(e.data)}}else if("u">typeof self&&"u">typeof navigator){cg(cm,e=>{try{c6||("u">typeof localStorage&&localStorage.setItem(ch,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:ch,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===ch){let n=JSON.parse(e.newValue);n&&c4(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===ch&&c4(e.changedParts)})}function c8(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}lr.rejectionMapper=function(e,n){if(!e||e instanceof sz||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sN[e.name])return e;var t=new sN[e.name](n||e.message,e);return"stack"in e&&i8(t,"stack",{get:function(){return this.inner.stack}}),t},sw=lq;class c7 extends c1{constructor(){super("EsmOffline"),c8(this,"syncQueue",void 0),c8(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 c9(){return new c7}let ue=new c7,un={},ut=U("offline-synchronization",{});function ua(){return ut}async function uo(){if(ut.getState().synchronization)return;let e=await ue.syncQueue.count(),n={},t=Object.entries(un),a=t.length,o={},r=new AbortController,i=()=>{let e=ut.getState().synchronization;ut.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{ut.setState({synchronization:{totalCount:e,pendingCount:e,abortController:r}});for(let e=0;e<a&&t.length>0;e++)for(let e=t.length;e--;){let[a,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(o[a]={},await Promise.all(l),n[a]=ur(s,o,r,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{ut.setState({synchronization:void 0})}}async function ur({type:e,dependsOn:n,process:t},a,o,r){let i=[],s=[],l=await ui();await ue.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[u,p,{id:d,dependencies:f=[]}]=i[c];try{let r=await t(p,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?a[t][e]:void 0)});void 0!==d&&(a[e][d]=r),await ue.syncQueue.delete(u)}catch(e){await ue.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{r()}}}async function ui(){let e=await oq();return e?.uuid||"*"}async function us(e,n,t,a){let o=a&&a.id;return void 0!==o&&await ue.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(c1.errnames.DatabaseClosed),await ue.syncQueue.add({type:n,content:t,userId:e,descriptor:a||{},createdOn:new Date}).catch(c1.errnames.DatabaseClosed,()=>-1)}async function ul(e,n,t){let a=await ui();return await us(a,e,n,t)}async function uc(e,n){return(await uu(e,n)).map(e=>e.content)}async function uu(e,n){return await ue.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(c1.errnames.DatabaseClosed,()=>[])}async function up(e){let n=await ui();return await uc(n,e)}async function ud(e){let n=await ui();return await uu(n,e)}async function uf(e){return await ue.syncQueue.get(e).catch(c1.errnames.DatabaseClosed,()=>void 0)}function um(e){return!!un[e]?.options.onBeginEditSyncItem}async function uh(e){let n=await uf(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=un[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 ug(e){await ue.syncQueue.delete(e).catch(c1.errnames.DatabaseClosed)}function uy(e,n,t,a={}){un[e]={type:e,dependsOn:n,process:t,options:a}}let ub="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),u_=new Uint8Array(16),uv=[];for(let e=0;e<256;++e)uv.push((e+256).toString(16).slice(1));let u$=function(e,n,t){if(ub&&!n&&!e)return ub();let a=(e=e||{}).random||(e.rng||function(){if(!i&&!(i="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 i(u_)})();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=a[e];return n}return function(e,n=0){return uv[e[n+0]]+uv[e[n+1]]+uv[e[n+2]]+uv[e[n+3]]+"-"+uv[e[n+4]]+uv[e[n+5]]+"-"+uv[e[n+6]]+uv[e[n+7]]+"-"+uv[e[n+8]]+uv[e[n+9]]+"-"+uv[e[n+10]]+uv[e[n+11]]+uv[e[n+12]]+uv[e[n+13]]+uv[e[n+14]]+uv[e[n+15]]}(a)},uA="OFFLINE+";function uk(){return uA+u$()}function uw(e){return e.startsWith(uA)}let ux={};function uC(){return Object.values(ux)}function uE(e){ux[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.`),ux[e.id]=e}async function uS(e){let n=await uI();return await uD(n,e)}async function uD(e,n){let t=new c7;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(c1.errnames.DatabaseClosed,()=>[])}async function uM(e,n){let t=await uI();return await uz(t,e,n)}async function uz(e,n,t){let a=new c7,o=await a.dynamicOfflineData.get({type:n,identifier:t}).catch(c1.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await a.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(c1.errnames.DatabaseClosed):await a.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(c1.errnames.DatabaseClosed)}async function uO(e,n){let t=await uI();return await uP(t,e,n)}async function uP(e,n,t){let a=new c7,o=await a.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(c1.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await a.dynamicOfflineData.update(o.id,{users:o.users.filter(n=>n!==e)}).catch(c1.errnames.DatabaseClosed):await a.dynamicOfflineData.delete(o.id).catch(c1.errnames.DatabaseClosed))}async function uT(e,n){let t=await uS(e);await Promise.all(t.map(async e=>uB(e.type,e.identifier,n)))}async function uB(e,n,t){await uM(e,n);let a=new c7,o=await uI(),r=await a.dynamicOfflineData.get({type:e,identifier:n}).catch(c1.errnames.DatabaseClosed,()=>void 0),i=uC().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),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:u};r.id&&await a.dynamicOfflineData.update(r.id,{syncState:p}).catch(c1.errnames.DatabaseClosed)}async function uI(){let e=(await oq()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let uN=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function uj(){return uL(),uN}function uR(e,n){uL(),uE({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 uF(e){uL(),await uB("patient",e)}function uL(){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 uW(e,n,t=!0){if(e){let a=null,[o,r]=await Promise.all([oB(`${oO}/Patient/${e}`,n).catch(e=>a=e),t?uG(e):Promise.resolve(null)]);if(o.ok)return o.data;if(r)return r;if(a)throw a}return null}async function uG(e){let n=(await up("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function uV(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function uU(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 uq=t(56170);function uH(e){return{uuid:e.uuid,display:e.display}}function uK(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let a=t.toString();return oI(`${oz}/location${a?"?"+a:""}`).pipe((0,uq.map)(e=>e.data.results.map(uH))).pipe((0,uq.take)(1))}function uY(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uJ(){return oI(`${oz}/visittype`).pipe((0,uq.map)(e=>e.data.results.map(uY))).pipe((0,uq.take)(1))}var uZ=((en={}).NEWVISIT="startVisit",en.EDITVISIT="editVisit",en.LOADING="loadingVisit",en),uX=((et={}).NOTSTARTED="notStarted",et.ONGOING="ongoing",et);let uQ="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))",u0=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function u1(){return H("visit",u0)}function u2(e,n){u1().setState({patientUuid:e,manuallySetVisitUuid:n})}function u3(e,n){return oB(`${oz}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function u5(e,n,t){return oB(`${oz}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function u4(e,n,t){return oB(`${oz}/visit?patient=${e}&v=${t??uQ}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}u1().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let u6=new er.BehaviorSubject(null);class u8{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+u8.version}static addUnaryOp(e){return u8.max_unop_len=Math.max(e.length,u8.max_unop_len),u8.unary_ops[e]=1,u8}static addBinaryOp(e,n,t){return u8.max_binop_len=Math.max(e.length,u8.max_binop_len),u8.binary_ops[e]=n,t?u8.right_associative.add(e):u8.right_associative.delete(e),u8}static addIdentifierChar(e){return u8.additional_identifier_chars.add(e),u8}static addLiteral(e,n){return u8.literals[e]=n,u8}static removeUnaryOp(e){return delete u8.unary_ops[e],e.length===u8.max_unop_len&&(u8.max_unop_len=u8.getMaxKeyLen(u8.unary_ops)),u8}static removeAllUnaryOps(){return u8.unary_ops={},u8.max_unop_len=0,u8}static removeIdentifierChar(e){return u8.additional_identifier_chars.delete(e),u8}static removeBinaryOp(e){return delete u8.binary_ops[e],e.length===u8.max_binop_len&&(u8.max_binop_len=u8.getMaxKeyLen(u8.binary_ops)),u8.right_associative.delete(e),u8}static removeAllBinaryOps(){return u8.binary_ops={},u8.max_binop_len=0,u8}static removeLiteral(e){return delete u8.literals[e],u8}static removeAllLiterals(){return u8.literals={},u8}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 u8(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 u8.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!u8.binary_ops[String.fromCharCode(e)]||u8.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return u8.isIdentifierStart(e)||u8.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(u8.hooks[e]){let t={context:this,node:n};return u8.hooks.run(e,t),t.node}return n}searchHook(e){if(u8.hooks[e]){let n={context:this};return u8.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===u8.SPACE_CODE||e===u8.TAB_CODE||e===u8.LF_CODE||e===u8.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:u8.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,a;for(;this.index<this.expr.length;)if((t=this.code)===u8.SEMCOL_CODE||t===u8.COMMA_CODE)this.index++;else if(a=this.gobbleExpression())n.push(a);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,u8.max_binop_len),n=e.length;for(;n>0;){if(u8.binary_ops.hasOwnProperty(e)&&(!u8.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!u8.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,a,o,r,i,s,l;if(!(r=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return r;for(o={value:n,prec:u8.binaryPrecedence(n),right_a:u8.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),a=[r,o,i];n=this.gobbleBinaryOp();){if(0===(t=u8.binaryPrecedence(n))){this.index-=n.length;break}o={value:n,prec:t,right_a:u8.right_associative.has(n)},l=n;let s=e=>o.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;a.length>2&&s(a[a.length-2]);)i=a.pop(),n=a.pop().value,r=a.pop(),e={type:u8.BINARY_EXP,operator:n,left:r,right:i},a.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),a.push(o,e)}for(s=a.length-1,e=a[s];s>1;)e={type:u8.BINARY_EXP,operator:a[s-1].value,left:a[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,a;if(this.gobbleSpaces(),a=this.searchHook("gobble-token"))return this.runHook("after-token",a);if(e=this.code,u8.isDecimalDigit(e)||e===u8.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===u8.SQUOTE_CODE||e===u8.DQUOTE_CODE)a=this.gobbleStringLiteral();else if(e===u8.OBRACK_CODE)a=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,u8.max_unop_len)).length;t>0;){if(u8.unary_ops.hasOwnProperty(n)&&(!u8.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!u8.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:u8.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}u8.isIdentifierStart(e)?(a=this.gobbleIdentifier(),u8.literals.hasOwnProperty(a.name)?a={type:u8.LITERAL,value:u8.literals[a.name],raw:a.name}:a.name===u8.this_str&&(a={type:u8.THIS_EXP})):e===u8.OPAREN_CODE&&(a=this.gobbleGroup())}return a?(a=this.gobbleTokenProperty(a),this.runHook("after-token",a)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===u8.PERIOD_CODE||n===u8.OBRACK_CODE||n===u8.OPAREN_CODE||n===u8.QUMARK_CODE;){let t;if(n===u8.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==u8.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===u8.OBRACK_CODE?((e={type:u8.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==u8.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===u8.OPAREN_CODE?e={type:u8.CALL_EXP,arguments:this.gobbleArguments(u8.CPAREN_CODE),callee:e}:(n===u8.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:u8.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(;u8.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===u8.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);u8.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++));u8.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);u8.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,u8.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===u8.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===u8.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:u8.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),a=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){a=!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 a||this.throwError('Unclosed quote after "'+e+'"'),{type:u8.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(u8.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,u8.isIdentifierPart(e))this.index++;else break;return{type:u8.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,a=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){t=!0,this.index++,e===u8.CPAREN_CODE&&a&&a>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===u8.COMMA_CODE){if(this.index++,++a!==n.length){if(e===u8.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===u8.CBRACK_CODE)for(let e=n.length;e<a;e++)n.push(null)}}else if(n.length!==a&&0!==a)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==u8.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(u8.CPAREN_CODE);if(this.code===u8.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:u8.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:u8.ARRAY_EXP,elements:this.gobbleArguments(u8.CBRACK_CODE)}}}Object.assign(u8,{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)})}}(u8),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"}),u8.max_unop_len=u8.getMaxKeyLen(u8.unary_ops),u8.max_binop_len=u8.getMaxKeyLen(u8.binary_ops);let u7=e=>new u8(e).parse(),u9=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(u8).filter(e=>!u9.includes(e)&&void 0===u7[e]).forEach(e=>{u7[e]=u8[e]}),u7.Jsep=u8,u7.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,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:a,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let a=t;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;n.node.test=a.right,a.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let pe="ArrowFunctionExpression",pn={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)}},pt={...pn,Promise};function pa(e,n={}){return pc(e,n,pd)}async function po(e,n={}){return pu(e,n,pd)}function pr(e,n={}){return pc(e,n,pf)}function pi(e,n={}){return pu(e,n,pf)}function ps(e,n={}){return pc(e,n,pm)}function pl(e,n={}){return pu(e,n,pm)}function pc(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 a=py(n,pn),o=ph("string"==typeof e?u7(e):e,a);if(t(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function pu(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 a=py(n,pt);return Promise.resolve(ph("string"==typeof e?u7(e):e,a)).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 pp(e){return u7(e)}function pd(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function pf(e){return"boolean"==typeof e}function pm(e){return"number"==typeof e}function ph(e,n){switch(e.type){case"UnaryExpression":var t,a,o,r,i,s,l,c,u,p,d,f,m=e,h=n;let g=ph(m.argument,h);switch(m.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${m.operator}''`}case"BinaryExpression":var y=e,b=n;let v=ph(y.left,b),$=ph(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,a=n,ph(t.test,a)?ph(t.consequent,a):ph(t.alternate,a);case"CallExpression":var A=e,k=n;let w=A.arguments?.map(pb(k)),x=ph(A.callee,k);if(x){if("function"!=typeof x)throw`${pv(A.callee)} is not a function`}else throw`No function named ${pv(A.callee)} is defined in this context`;return x(...w);case"ArrowFunctionExpression":let C;return o=e,r=n,C=o.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,a)=>{let o=e[a];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}(o)&&n.push([t,o]),n},[]));return ph(o.body,r.addVariables(n))}).bind(r.thisObj??null);case"MemberExpression":return function(e,n){let t,a=ph(e.object,n);if(void 0===a)switch(e.object.type){case"Identifier":{let t=pg(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=pg(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 o=a;if("string"==typeof a)o=String.prototype;else if("number"==typeof a)o=Number.prototype;else if("function"==typeof a);else if("object"!=typeof a)throw`VisitMemberExpression does not support member access on type ${typeof a}`;switch(n.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":t=ph(e.property,n);break;default:{let o=ph(e.property,n);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};p_(o),t=a[o]}}return"function"==typeof t?t.bind(a):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(pb(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(pb(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(pb(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 p_((u=e).value),u.value;case"Identifier":var M=e,z=n;p_(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return p_(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return p_(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=n,P=p.expressions?.map(pb(d))??[],(T=p.quasis?.map(pb(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.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 pg(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return pg(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function py(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 pb(e){return function(n){return null===n?null:ph(n,e)}}function p_(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pv(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function p$(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:{...pt},isLocalExpression:!1,variables:new Set};return pA("string"==typeof e?u7(e):e,n),[...n.variables]}function pA(e,n){switch(e.type){case"UnaryExpression":return a=e,o=n,pA(a.argument,o);case"BinaryExpression":return r=e,i=n,[pA(r.left,i),pA(r.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[pA(s.consequent,l),pA(s.test,l),pA(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,u=n,t=pA(c.callee,u),c.arguments?.map(pk(u)),t;case"ArrowFunctionExpression":var a,o,r,i,s,l,c,u,p,d,f,m,h,g,y,b,v,$,A=e,k=n;let w={...k};w.isLocalExpression=!0;let x=A.params?.map(pk(w))??[],C=pA(A.body,w)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||k.variables.add(e);return;case"MemberExpression":let E;return p=e,d=n,pA(p.object,d),void((E={...d}).isLocalExpression=!0,pA(p.property,E));case"ArrayExpression":return f=e,m=n,void f.elements?.map(pk(m));case"SequenceExpression":return h=e,g=n,void h.expressions?.map(pk(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(pk(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(pk($)),v.quasis?.map(pk($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pk(e){return function(n){return null===n?null:pA(n,e)}}u7.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:pe,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=pe,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)})}}),u7.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 a=n.node;for(;a.type===e.MEMBER_EXP||a.type===e.CALL_EXP&&a.callee.type===e.MEMBER_EXP;)a=a.type===e.MEMBER_EXP?a.object:a.callee.object;a.type="NewExpression"}})}}),u7.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,a="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:a+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(a+=this.expr.charAt(this.index++),o());let r=this.char;("e"===r||"E"===r)&&(a+=this.expr.charAt(this.index++),("+"===(r=this.char)||"-"===r)&&(a+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+a+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+a+this.char+")");else if(i===e.PERIOD_CODE){a.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:a},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(a),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(a){if(48===this.code){var o,r,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let u="";for(;o=this.code,r=c,95===o||r.some(([e,n])=>o>=e&&o<=n);)95===this.code?this.index++:u+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,a);return}this.throwError("unexpected char within number")}a.node={type:e.LITERAL,value:parseInt(u,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,a)})}}),u7.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,a=!1;for(;this.index<this.expr.length;){if(47===this.code&&!a){let a,o=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{a=new RegExp(o,r)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:a,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?a=!0:a&&this.code===e.CBRACK_CODE&&(a=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),u7.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,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:a,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let a=t;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;n.node.test=a.right,a.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),u7.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},a="",o="",r=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:o,cooked:a},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(),o="",a="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(o+=i,i=this.expr.charAt(++this.index),o+=i,i){case"n":a+="\n";break;case"r":a+="\r";break;case"t":a+=" ";break;case"b":a+="\b";break;case"f":a+="\f";break;case"v":a+="\v";break;default:a+=i}else a+=i,o+=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})}}),u7.addBinaryOp("in",7),u7.addBinaryOp("??",1);let pw=H("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:",""),a=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...a}}return e}()});function px(e,n,t){pw.setState(a=>({flags:{...a.flags,[e]:{enabled:a.flags[e]?.enabled??!1,label:n,description:t}}}))}function pC(){let e=pw.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 pE(e){return pw.getState().flags[e].enabled}function pS(e,n){pw.subscribe(t=>{n(t.flags[e].enabled)})}function pD(e,n){pw.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function pM(e){return!window.offlineEnabled||(e??navigator.onLine)}pw.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 pz=e7(function(e,n,t){eX(e,n,t)});function pO(e=!0,n=!1){return pP(pM(),e,n)}function pP(e,n=!0,t=!1){return!!(e?n:t)}let pT=U("extensionsInternal",{slots:{},extensions:{}}),pB=U("extensionRenderings",{renderings:new Map}),pI=()=>H("extensionsInternal",{slots:{},extensions:{}}),pN=()=>H("extensionRenderings",{renderings:new Map});function pj(e){let n=pT.getState(),t=e(n);t!==n&&pT.setState(t)}let pR=null,pF=null;function pL(){let e=pB.getState();return pR&&e===pF||(pR=new Map(e.renderings),pF=e,function(e){for(let n of(pZ.clear(),e.values()))pQ(n,1);pX=!0}(pR)),pR}function pW(e){pF={renderings:e},pB.setState(pF,!0)}function pG(e){let n=pL();n.has(e.renderingId)||(n.set(e.renderingId,e),pQ(e,1),pW(n))}function pV(e){let n=pL(),t=n.get(e);t&&(n.delete(e),pQ(t,-1),pW(n))}let pU=()=>H("extensions",{slots:{}}),pq=0,pH=new Set;function pK(e){pq++;try{return e()}finally{if(0==--pq&&pH.size>0){let e=Array.from(pH);for(let n of(pH.clear(),e))pY(n)}}}function pY(e){try{e()}catch(n){console.error(`The extension system's '${e.name}' recomputation failed`,n)}}function pJ(e){pq>0?pH.add(e):pY(e)}let pZ=new Map,pX=!1;function pQ(e,n){let t=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),a=pZ.get(t);if(!a){if(n<0)return;pZ.set(t,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),pX=!0;return}a.count+=n,a.count<1&&(pZ.delete(t),pX=!0)}function p0(){var e,n;if(pL(),!pX)return;pX=!1;let t=Array.from(pZ.values(),({record:e})=>e);t.sort(p1),e=n0.getState().mountedExtensions,n=t,e.length===n.length&&e.every((e,t)=>0===p1(e,n[t]))||n0.setState({mountedExtensions:t})}function p1(e,n){return p2(e.slotName,n.slotName)||p2(e.extensionId,n.extensionId)||p2(e.slotModuleName,n.slotModuleName)||p2(e.extensionModuleName,n.extensionModuleName)}function p2(e,n){return e===n?0:e<n?-1:1}p0(),pB.subscribe(()=>pJ(p0));let p3=pI(),p5=pU(),p4=n2(),p6=n4(),p8=new Set,p7=!1;function p9(e){if(null===e)p8=null;else if(null!==p8)for(let n of e)p8.add(n);pJ(de)}function de(){if(!p7){p7=!0;try{for(let e=1;;e++){let n=p8;if(null!==n&&0===n.size)return;p8=new Set;try{!function(e,n,t,a,o,r=null){let i=p5.getState().slots,s={},l=!1,c=pM(),u=Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[a,p]of Object.entries(e.slots)){let d=i[a];if(d&&r&&!r.has(a)){s[a]=d;continue}let{config:f}=n5(n,p.name),m=function(e,n,t,a,o,r,i){let s=function(e,n){let t=e.add||[],a=e.remove||[],o=e.order||[],{extensions:r}=p3.getState();return[...n,...t].filter(e=>!a.includes(e)).sort((e,t)=>dd(e,o,r[dr(e)]?.order,n)-dd(t,o,r[dr(t)]?.order,n))}(t,n.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=n8(a,e,c),u=n7(t,e,c),p=u?pz({},s,u):s,d=dr(c),f=n.extensions[d];if(f){let e=p?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!i?.user||!oU(e,i.user))||f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!pP(r,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:p?.["Display conditions"]?.expression||f.displayExpression})}}return l}(a,e,f,t,u,c,o.session);d&&d.moduleName===p.moduleName&&nn(d.candidateExtensions,m)?s[a]=d:(s[a]={moduleName:p.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&p5.setState({slots:s})}(p3.getState(),p4.getState(),p6.getState(),pw.getState(),oj.getState(),n)}catch(e){throw p8=null===n||null===p8?null:new Set([...n,...p8]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{p7=!1}}}function dn(e,n){let t=new Set;for(let a of Object.keys(e))e[a]!==n[a]&&t.add(a);for(let a of Object.keys(n))a in e||t.add(a);return t}function dt(){p9(null)}function da(e,n){return{moduleName:n,name:e,attachedIds:[]}}function dr(e){let[n]=e.split("#");return n}function di(e,n){let t=dr(n);return e.extensions[t]}function ds(e){return di(p3.getState(),e)}p3.subscribe((e,n)=>{p9(e.extensions!==n.extensions?null:dn(e.slots,n.slots))}),p4.subscribe((e,n)=>{p9(dn(e.slots,n.slots))}),p6.subscribe((e,n)=>{p9(dn(e.configs,n.configs))}),pw.subscribe(()=>p9(null)),oj.subscribe(()=>p9(null)),dt(),y(dt);let dl=e=>pj(n=>({...n,extensions:{...n.extensions,[e.name]:{...e}}}));function dc(e,n){pj(t=>{let a=t.slots[e];return a?{...t,slots:{...t.slots,[e]:{...a,attachedIds:[...a.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...da(e),attachedIds:[n]}}}})}function du(e,n){pj(t=>{let a=t.slots[e];return a&&a.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...a,attachedIds:a.attachedIds.filter(e=>e!==n)}}}:t})}function dp(e){pj(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function dd(e,n,t,a){let o=n.indexOf(e);if(-1!==o)return o;{if(void 0!==t)return 1e3+t;let n=a.indexOf(e);return -1!==n?2e3+n:3e3}}function df(e,n){return function(e,n,t=null,a){let o;return e.filter(e=>{let r=e.displayConditionExpression;if("string"!=typeof r||0===r.trim().length)return!0;o??(o=n&&"object"==typeof n?{session:t,...n}:{session:t});try{return!!pr(r,o)}catch(n){return console.error(`Error while evaluating expression '${r}' for ${e.id}`+(a?` in ${a}`:""),n),!1}})}(dm(e),n,oj.getState().session,e)}function dm(e){return p5.getState().slots[e]?.candidateExtensions??[]}let dh=(e,n)=>p3.setState(t=>{let a=t.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}.`),t;if(a&&a==e)return t;if(t.slots[n])return{...t,slots:{...t.slots,[n]:{...t.slots[n],moduleName:e}}};let o=da(n,e);return{...t,slots:{...t.slots,[n]:{...o}}}}),dg=()=>{p8=null,pj(()=>({slots:{},extensions:{}})),pN().setState({renderings:new Map}),p5.setState({slots:{}})},dy=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function db({name:e,basePath:n,mode:t,componentContext:a,state:o}){dy.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:a,state:o})}function d_(e){dy.getState().slotName===e&&dy.setState(dy.getInitialState(),!0)}let dv=U("modalRegistry",{modals:{}});function d$(e){dv.setState(n=>(n.modals[e.name]=e,n))}function dA(e){let n=dv.getState().modals[e];if(!n){let t=ds(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.`),d$(n))}return n}let dk=U("workspaceRegistrations",{workspaces:{}}),dw=U("workspaceGroups",{workspaceGroups:{}});function dx(e){dk.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 dC(e){dw.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 dE=new Set;function dS(e){let n=dk.getState().workspaces;if(n[e])return n[e];{let n=ds(e);if(n){var t;let a;return dE.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.`),dE.add(e)),{name:n.name,title:(t=n,"string"==typeof(a=t?.meta?.title)?a:a&&"object"==typeof a?rT(t.moduleName,a.key,a.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 dD(e){let n=dw.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let dM=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function dz(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=dM.getState(),a=n[e];if(a){let n=t[a.window];if(n)return n;throw Error(`No workspace window found with name: ${a.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function dO(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=dM.getState(),a=t[e];if(a){let t=n[a.group];if(t)return t;throw Error(`No workspace group found with name: ${a.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function dP(e){let{openedWindows:n}=dM.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function dT(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=dM.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);a[t.name]={...t,moduleName:e}}dM.setState({registeredGroupsByName:a})}function dB(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=dM.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};a[t.name]=n}dM.setState({registeredWindowsByName:a})}function dI(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=dM.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};a[t.name]=n}dM.setState({registeredWorkspacesByName:a})}let dN=0,dj=null,dR={bootstrap:{millis:15e3,dieOnTimeout:!0},mount:{millis:15e3,dieOnTimeout:!0},unmount:{millis:15e3,dieOnTimeout:!0}};async function dF(e,n){return(await (dj??(dj=new Promise((e,n)=>{aP({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:n=>(e(n.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(n)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),aP))),dj))("function"==typeof e?()=>e().then(e=>({timeouts:dR,...e})):{timeouts:dR,...e},n)}function dL(){return dW}function dW(e,n){let t,a=dF(e,n).then(e=>t=e);return{mount:()=>a.then(e=>e.mount()),unmount:()=>a.then(e=>e.unmount()),update:e=>a.then(n=>n.update?.(e)),getStatus:()=>t?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return a.then(e=>e.loadPromise)},get bootstrapPromise(){return a.then(e=>e.bootstrapPromise)},get mountPromise(){return a.then(e=>e.mountPromise)},get unmountPromise(){return a.then(e=>e.unmountPromise)}}}async function dG(e,n,t,a,o=e=>e,r={}){let i=dr(a),s=ds(a),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(pO(p,d)){let s,p=dN++,d=`${n}/${a}-${p}`;e.dataset.extensionRenderingId=d;let m=e=>{try{pV(d)}catch(n){console.error(e,n)}};try{pG({renderingId:d,extensionName:i,extensionModuleName:u,extensionId:a,slotName:n,slotModuleName:t})}catch(e){throw m(`Recomputing configuration after registering '${a}' failed also failed`),e}try{s=await f()}catch(e){throw m(`Recomputing configuration after '${a}' failed to load also failed`),e}try{l=await dF(o({...s,name:`${n}/${i}-${p}`}),{...r,_meta:c,_extensionContext:{extensionId:a,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:u},domElement:e})}catch(e){throw m(`Recomputing configuration after '${a}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${a}' in slot '${n}' failed to mount`,e),m(`Recomputing configuration after '${a}' failed to mount also failed`)}),l.unmountPromise.then(()=>m(`Recomputing configuration after unmounting '${a}' failed`),e=>{console.error(`Extension '${a}' in slot '${n}' failed to unmount`,e),m(`Recomputing configuration after '${a}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${a} into ${n} but no DOM element was available.`);return l}var dV=t(60695),dU=t.n(dV);let dq=(0,dV.createContext)({moduleName:"",featureName:""});function dH({to:e,templateParams:n,onBeforeNavigate:t,children:a,...o}){return(0,dV.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),dU().createElement("a",{onClick:a=>{0===a.button&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&!a.metaKey&&(a.preventDefault(),t?.(a),o$({to:e,templateParams:n})),0===a.button&&(a.ctrlKey||a.metaKey)&&t?.(a),0===a.button&&a.shiftKey&&t?.(a),1===a.button&&t?.(a)},href:o_(e,n),...o},a)}let dK=({state:e,children:n,...t})=>{let{extension:a}=(0,dV.useContext)(dq),o=(0,dV.useRef)(null),r=(0,dV.useRef)(Promise.resolve()),i=(0,dV.useRef)(!1),s=(0,dV.useRef)(!1),l=(0,dV.useRef)(e),c=(0,dV.useCallback)(e=>{if(!e)return;let n=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":r.current?.then(n,n);break;default:e.mountPromise.then(n,()=>{})}},[]),u=(0,dV.useCallback)((e,n)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(r.current=Promise.all([e.mountPromise,r.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...n})}).catch(e=>{let n=o.current?.getStatus();"UNMOUNTING"!==n&&"NOT_MOUNTED"!==n&&"UNLOADING"!==n&&console.error(`The extension '${a?.extensionId}' failed to update`,e)}))},[]),p=(0,dV.useCallback)(n=>{n&&!o.current&&!s.current&&a?.extensionSlotName&&a.extensionSlotModuleName&&(s.current=!0,dG(n,a.extensionSlotName,a.extensionSlotModuleName,a.extensionId,void 0,e).then(n=>{(s.current=!1,o.current=n,i.current)?c(n):n&&l.current!==e&&u(n,l.current)},()=>{s.current=!1}))},[]);return(0,dV.useEffect)(()=>(i.current=!1,()=>{i.current=!0,c(o.current)}),[]),(0,dV.useEffect)(()=>{l.current=e,o.current&&u(o.current,e)},[e]),a?dU().createElement("div",{ref:p,"data-extension-id":a?.extensionId,style:{position:"relative"},...t}):null};function dY(e){let n=(0,dV.useRef)(e);return j(n.current,e)||(n.current=e),n.current}function dJ(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[a,o]of Object.entries(n)){let n=function(...n){e.setState(e=>o(e,...n))};t[a]=n}return t}let dZ=e=>e;function dX(e,n=dZ,t){let a=(0,dV.useCallback)(n=>e.subscribe(n),[e]),o=(0,dV.useCallback)(()=>n(e.getState()),[e,n]),r=(0,dV.useSyncExternalStore)(a,o,o),i=(0,dV.useMemo)(()=>t?dJ(e,t):null,[e,t]);return(0,dV.useMemo)(()=>i?{...r,...i}:r,[r,i])}function dQ(e,n){return dX(e,dZ,n)}function d0(e){return function(n){let t=(0,dV.useCallback)(n=>e.subscribe(n),[]),a=(0,dV.useCallback)(()=>e.getState(),[]),o=(0,dV.useSyncExternalStore)(t,a,a),r=(0,dV.useMemo)(()=>n?dJ(e,n):null,[n]);return(0,dV.useMemo)(()=>r?{...o,...r}:o,[o,r])}}let d1=[];Object.freeze(d1);let d2={candidateExtensions:d1};Object.freeze(d2);let d3=e=>{let n=(0,dV.useCallback)(n=>n.slots?.[e]??d2,[e]);return dX(pU(),n)},d5=e=>e.session;function d4(e,n){let{candidateExtensions:t}=d3(e),a=dX(oj,d5),o=dY(n);return(0,dV.useMemo)(()=>df(e,o),[e,o,a,t])}function d6(e,n){let{moduleName:t}=(0,dV.useContext)(dq);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,dV.useEffect)(()=>{dh(t,e)},[t,e]),{extensions:d4(e,n),extensionSlotName:e,extensionSlotModuleName:t}}function d8(e){return e}function d7({name:e,extensionSlotName:n,select:t=d8,children:a,state:o,style:r,...i}){if(a&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??n,l=(0,dV.useRef)(null),{extensions:c,extensionSlotModuleName:u}=d6(s,o),p=(0,dV.useMemo)(()=>t(c),[t,c]),d=(0,dV.useMemo)(()=>{if("function"==typeof a&&!dU().isValidElement(a))return p.map(e=>a(e,o))},[a,p]);return dU().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...r,position:"relative"},...i},s&&p?.map((e,n)=>dU().createElement(dq.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[n]??("function"!=typeof a?a:null)??dU().createElement(dK,{state:o}))))}var d9=t(5338);function fe(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,a)}return t}function fn(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?fe(Object(t),!0).forEach(function(n){var a,o,r;a=e,o=n,r=t[n],o in a?Object.defineProperty(a,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):a[o]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):fe(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function ft(e){return(ft="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 fa(e){return(fa="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 fo(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(fa(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(fa(e)));return e}}var fr=null;try{fr=require("react").createContext()}catch(e){}var fi={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 fs(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function fl(e,n){return new Promise(function(t,a){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 o,r=fd(e,n,function(){t(this)}),i=fo(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,a=e.elementToRender,o=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(o);return i.render(a),i;case"hydrateRoot":return r(o,a);default:return r(a,o),null}}({elementToRender:r,domElement:i,reactDom:fp(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function fc(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var a=e.renderResults[n.name];a&&a.unmount?a.unmount():fp(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function fu(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var a=fd(e,n,null),o=e.renderResults[n.name];if(o&&o.render)o.render(a);else{var r=fo(e,n)();fp(e).render(a,r)}})}function fp(e){return e.ReactDOMClient||e.ReactDOM}function fd(e,n,t){var a=e.React.createElement(e.rootComponent,n),o=fr?e.React.createElement(fr.Provider,{value:n},a):a;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),o=e.React.createElement(e.errorBoundaryClass,n,o)),o=e.React.createElement(e.SingleSpaRoot,fn(fn({},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])}}),o)}var ff=t(70287),fm=t(59324),fh=t(32108);let fg={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fy=new Map;(0,fh.initCache)(fy);let fb={errorRetryCount:3,fetcher:oB,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof oN){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>fy};function f_(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},fg,e),t={...fb,...n.swrConfig};return function(e){var a,o,r,i,s;return r=o=class extends(a=dU().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 dU().createElement("div",null,"An error has occurred. Please try reloading the page.");{let a=dU().createElement(dV.Suspense,{fallback:null},dU().createElement(fm.BE,{value:t},dU().createElement(dq.Provider,{value:this.state.config},n.disableTranslations?dU().createElement(e,this.props):dU().createElement(ff.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},dU().createElement(e,this.props)))));return n.strictMode&&dU().StrictMode?dU().createElement(dU().StrictMode,null,a):a}}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,o}}function fv(e,n){return function(e){if("object"!==ft(e))throw Error("single-spa-react requires a configuration object");var n,t=fn(fn({},fi),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");!fr&&t.React.createContext&&(fr=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 a={bootstrap:fs.bind(null,t),mount:fl.bind(null,t),unmount:fc.bind(null,t)};return t.parcelCanUpdate&&(a.update=fu.bind(null,t)),a}({React:dU(),ReactDOMClient:d9,rootComponent:f_(n)(e)})}function f$(e,n){return()=>e().then(({default:e})=>fv(e,n))}function fA(e,n){return()=>Promise.resolve(fv(e,n))}let fk=f$,fw=W()(()=>({}));q("openmrs-app-context",fw);let fx={};function fC(e,n=e=>e){let t=fw.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function fE(e,n){fw.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function fS(e){return null===e?null:Object.freeze(Object.assign({},e))}let fD=new Map;function fM(e,n){let t=(0,dV.useRef)(n??{}),a=(0,dV.useRef)(n=>fE(e,n)),o=(0,dV.useRef)(Symbol());return(0,dV.useEffect)(()=>{let t=n??{},a=o.current;return null===fC(e)?!function(e,n=fx){fw.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===fx?{}: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.`),fE(e,()=>t)),fD.set(e,a),()=>{fD.get(e)===a&&(fw.setState(n=>(e in n&&delete n[e],n)),fD.delete(e))}},[e]),(0,dV.useEffect)(()=>{let a=n??{};j(t.current,a)||(fE(e,()=>a),t.current=a)},[n]),a.current}function fz({namespace:e,value:n}){return fM(e,n),null}let fO=({children:e,value:n,fallback:t})=>n?dU().createElement(dU().Fragment,null,e):t?dU().createElement(dU().Fragment,null,t):null;function fP(){let e=(0,dV.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,dV.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function fT(e,n=e=>e??{}){let[t,a]=(0,dV.useState)(()=>{if(fB(e))return;let t=fC(e);if(null!==t)return n?n(t):t});return(0,dV.useEffect)(()=>{if(fB(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,dV.useEffect)(()=>{var t;let o;return(t=e=>{if(null==e)return void a(void 0);let t=n?n(e):e;a(e=>j(e,t)?e:t)})(fS(o=fC(e))),fw.subscribe(n=>{let a=e in n?n[e]:null;a!==o&&(o=a,t(fS(a)))})},[e,n]),t}function fB(e){return"string"!=typeof e||0===e.trim().length}function fI(e){let n=d4(e);return(0,dV.useMemo)(()=>n.map(e=>e.id),[n])}function fN(e){return d3(e).candidateExtensions}function fj(e,n){let{data:t,error:a,mutate:o,isLoading:r,isValidating:i}=(0,fm.Ay)(`${i$}?patient=${e}&includeEncounterless=${n}`,oB);return(0,dV.useMemo)(()=>({isLoading:r,data:t?.data.results??[],error:a,mutate:o,isValidating:i}),[t,a,r,i,o])}function fR(e){(0,dV.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let fF={},fL=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function fW(e){let{moduleName:n,extension:t}=(0,dV.useContext)(dq),a=e?.externalModuleName??n;if(!a&&!t)throw Error(fL);let o=function(e){let n=(0,dV.useMemo)(()=>n1(e),[e]),t=function(e){let[n,t]=(0,dV.useState)(()=>{let n=e.getState();return n.loaded&&n.config?n.config:null});return(0,dV.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&t(e.config)}),[e]),n}(n);if(!t)throw fF[e]||(fF[e]=new Promise(e=>{let t=n.subscribe(n=>{n.loaded&&n.config&&(e(n.config),t())})})),fF[e];return t}(a),r=function(e){let n=(0,dV.useMemo)(n4,[]),t=function(e,n){let[t,a]=(0,dV.useState)(n?()=>{let t=n8(e.getState(),n.extensionSlotName,n.extensionId);if(t.loaded&&t.config)return t.config}:null);return(0,dV.useEffect)(()=>{if(n)return e.subscribe(e=>{let o=n8(e,n.extensionSlotName,n.extensionId);o.loaded&&o.config&&!nn(o.config,t)&&a(o.config)})},[e,n,t]),t}(n,e);if(!t&&e){let t=`${e.extensionSlotName}-${e.extensionId}`;throw!fF[t]&&n&&(fF[t]=new Promise(t=>{let a=n.subscribe(n=>{let o=n8(n,e.extensionSlotName,e.extensionId);o.loaded&&o.config&&(t(o.config),a())})})),fF[t]}return t||{}}(t);return(0,dV.useMemo)(()=>e?.externalModuleName&&a===e.externalModuleName?{...o}:{...o,...r},[a,e?.externalModuleName,o,r])}let fG=d4;function fV(){let[e,n]=(0,dV.useState)(pM());return(0,dV.useEffect)(()=>y(({online:e})=>n(e)),[]),e}function fU(e,n=300){let[t,a]=(0,dV.useState)(e);return(0,dV.useEffect)(()=>{let t=setTimeout(()=>{a(e)},n);return()=>{clearTimeout(t)}},[e,n]),t}var fq=t(31760),fH=t.n(fq);let fK=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,n])=>`${e}:${n}`).join(",")}`;function fY(){let e=`${oz}/emrapi/configuration?v=${fK}`,n=fH()(e,oB);return(0,dV.useMemo)(()=>({emrConfiguration:n.data?.data,isLoadingEmrConfiguration:n.isLoading,mutateEmrConfiguration:n.mutate,errorFetchingEmrConfiguration:n.error}),[n])}let fJ=d0(pI());function fZ(e){let n=d4(e);return(0,dV.useMemo)(()=>Object.fromEntries(n.map(e=>[e.name,e.meta])),[n])}let fX=d0(pU());function fQ(e){let{flags:n}=dX(pw);return n[e]?.enabled??!1}function f0(){let[,e]=(0,dV.useState)(0);return(0,dV.useCallback)(()=>{e(e=>e+1)},[])}function f1(e,n,t={}){return f3(e,n,f2,t)}let f2={getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let a=new URL(oT(e.toString()),window.location.toString());return a.searchParams.set("limit",""+n),a.searchParams.set("startIndex",""+t),a.searchParams.set("totalCount","true"),a.toString()}},getNextUrl:e=>{let n=e?.links?.find(e=>"next"==e.rel)?.uri;if(!n)return null;{let e=new URL(n);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function f3(e,n,t,a={}){let{getPaginatedUrl:o,getTotalCount:r,getCurrentPageSize:i,getData:s}=t,{immutable:l,swrConfig:c}=a,u=a.fetcher??oB,[p,d]=(0,dV.useState)(1),f=(0,dV.useRef)(NaN),m=(0,dV.useRef)(NaN),h=(0,dV.useRef)(p),g=(0,dV.useRef)(!1),y=(0,dV.useRef)(!1),b=e?.toString()??"",[v,$]=(0,dV.useState)(b);b!==v&&($(b),d(1),h.current=1,f.current=NaN,m.current=NaN,g.current=!1,y.current=!1);let A=(p-1)*n,k=(0,dV.useMemo)(()=>o(e,n,A),[e,n,A]),{data:w,...x}=(l?fH():fm.Ay)(k,u,c);w?.data&&(f.current=r(w?.data),m.current=i(w?.data),g.current=!0);let C=Math.ceil(f.current/n),E=(0,dV.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let t=Math.ceil(f.current/n);!g.current||Number.isNaN(t)||e<=t?(h.current=e,d(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[n]);(0,dV.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(f.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${b} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(f.current/n));p>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${p}; returning to page ${e}.`),h.current=e,d(e))},[p,n,b,w]);let S=(0,dV.useCallback)(()=>{E(h.current+1)},[E]),D=(0,dV.useCallback)(()=>{E(h.current-1)},[E]);return{data:s(w?.data),totalPages:C,totalCount:f.current,currentPage:p,currentPageSize:m.current,paginated:C>1,showNextButton:p<C,showPreviousButton:p>1,goTo:E,goToNext:S,goToPrevious:D,...x}}function f5(e,n,t={}){return f3(e,n,f4(),t)}function f4(){return{getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let a=new URL(oT(e.toString()),window.location.toString());return a.searchParams.set("_count",""+n),a.searchParams.set("_getpagesoffset",""+t),a.toString()}},getNextUrl:e=>{let n=e?.link?.find(e=>"next"==e.relation)?.url;if(!n)return null;{let e=new URL(n);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var f6=t(89366),f8=t.n(f6);function f7(e,n={}){return f9(e,f2,n)}function f9(e,n,t={}){let{swrInfiniteConfig:a,immutable:o}=t,{getNextUrl:r,getTotalCount:i,getData:s}=n,l=t.fetcher??oB,c=(0,dV.useCallback)((t,a)=>0==t?e?.toString()??null:n.getNextUrl(a.data),[e]),{data:u,size:p,setSize:d,...f}=f8()(c,l,{...a,...o?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),m=r(u?.[u.length-1].data),h=i(u?.[0]?.data);return{data:u?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=m,loadMore:()=>{d((u?.length??0)+1)},nextUri:m,...f}}function me(e,n={}){return mn(e,f2,n)}function mn(e,n,t={}){let a=f9(e,n,t),{hasMore:o,error:r,data:i,loadMore:s,isLoading:l,nextUri:c}=a;return((0,dV.useEffect)(()=>{o&&!r&&s()},[o,c]),t.partialData)?a:{...a,data:o||r?void 0:i,isLoading:l||o}}function mt(e,n={}){return mn(e,f4(),n)}function ma(e,n={}){return f9(e,f4(),n)}function mo(){let e="tablet";return document.body.classList.forEach(n=>{switch(n){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function mr(){let[e,n]=(0,dV.useState)(mo);return(0,dV.useEffect)(()=>{let e=()=>{n(mo())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let mi=e=>"small-desktop"===e||"large-desktop"===e;function ms(e){let n=(0,dV.useContext)(dq);(0,dV.useEffect)(()=>(n&&n.moduleName&&(e.componentContext=n),db(e),()=>{d_(e.name)}),[n,e])}function ml(){return dX(dy)}function mc(e=null,n=null){let[t,a]=(0,dV.useState)([]);return(0,dV.useEffect)(()=>{let t=uK(e,n).subscribe(e=>{a(e)},e=>{console.error(e)});return()=>t.unsubscribe()},[e,n]),t}function mu(e,n=!0){let t=(0,dV.useRef)(null);return(0,dV.useEffect)(()=>{let a=a=>{n&&t.current&&a.target&&a.target instanceof Node&&(t.current.contains(a.target)||e(a))};return window.addEventListener("mousedown",a),window.addEventListener("touchstart",a),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("touchstart",a)}},[e,n]),t}function mp(e){let n=(0,dV.useRef)();return(0,dV.useEffect)(()=>{let t=new IntersectionObserver(n=>{for(let t of n)if(t.isIntersecting)return void e()},{threshold:1});return n.current&&t.observe(n.current),()=>{n.current&&t.unobserve(n.current)}},[n.current,e]),n}function md(e,n={}){let{abortController:t,fetchInit:a,url:o,swrConfig:r}=n,i=fP(),s=(0,dV.useMemo)(()=>a?.signal??t?.signal??i.signal,[t?.signal,a?.signal,i.signal]),l=(0,dV.useCallback)(e=>oB(function(e,n){if(n)return"function"==typeof n?n(e):n;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,o),{...a,signal:s}),[s,a,o]);return(0,fm.Ay)(e,l,r)}function mf(e=[],n=10){let[t,a]=(0,dV.useState)(1),o=(0,dV.useMemo)(()=>"number"==typeof n&&n>0?Math.max(1,Math.ceil(e.length/n)):1,[e.length,n]);t>o&&a(o);let r=Math.min(Math.max(1,t),o),i=(0,dV.useMemo)(()=>{let t=(r-1)*n,a=(r+0)*n;return e.slice(t,a)},[e,r,n]),s=(0,dV.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):a(e)},[]),l=(0,dV.useCallback)(()=>{a(e=>e+1)},[]),c=(0,dV.useCallback)(()=>{a(e=>Math.max(1,e-1))},[]);return(0,dV.useMemo)(()=>({results:i,totalPages:o,currentPage:r,paginated:e.length>n,showNextButton:r<o,showPreviousButton:r>1,goTo:s,goToNext:l,goToPrevious:c}),[i,o,e.length,n,r,s,l,c])}function mm(e,n,t,a){return{pageSizes:(0,dV.useMemo)(()=>{let t=Math.ceil(n/e);return isNaN(t)&&(t=0),[...Array(t).keys()].map(n=>(n+1)*e)},[e,n]),pageItemsCount:(0,dV.useMemo)(()=>e>n?n:e*t>n?e*(t-1)+a:e*t,[e,n,t,a])}}function mh(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function mg(e){let[n,t]=(0,dV.useState)(e??mh()),{data:a,error:o,isValidating:r}=(0,fm.Ay)(n?["patient",n]:null,()=>uW(n,{}));return(0,dV.useEffect)(()=>{let e=()=>{let e=mh();e!==n&&t(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[n]),(0,dV.useMemo)(()=>({isLoading:r&&!o&&!a,patient:a,patientUuid:n,error:o}),[r,o,a,n])}function my(){let e=`${oz}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:n,error:t,isLoading:a}=(0,fm.Ay)(e,oB);return(0,dV.useMemo)(()=>({primaryIdentifierCode:n?.data?.results[0]?.metadataUuid,isLoading:a,error:t}),[n,t,a])}function mb(e){let{extensions:n,extensionSlotModuleName:t}=d6(e);return e?n.map(n=>({state:a})=>dU().createElement(dq.Provider,{value:{moduleName:t,featureName:"",extension:{extensionId:n.id,extensionSlotName:e,extensionSlotModuleName:t}}},dU().createElement(dK,{state:a}))):[]}function m_(){let e=(0,dV.useRef)(),[n,t]=(0,dV.useState)(null),a=null;if(!n){if(s){let e=oL().getState();e.loaded&&(a=e.session)}else s=new Promise(n=>{let t=({loaded:t,session:o})=>{t&&(n(o),a=o,e.current&&(e.current(),e.current=void 0))};t(oL().getState()),a||(e.current=oL().subscribe(t))});if(a)t(a);else throw s}(0,dV.useEffect)(()=>(e.current||(e.current=oL().subscribe(({loaded:e,session:n})=>{e&&(a=n,t(n))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let o=n||a;if(!o)if(s)throw console.warn("useSession is in an unexpected state. Attempting to recover."),s;else throw Error("useSession is in an invalid state.");return o}let mv=({privilege:e,fallback:n,children:t})=>{let[a,o]=(0,dV.useState)(null);return((0,dV.useEffect)(()=>{let e=oF({includeAuthStatus:!1}).subscribe(o);return()=>e.unsubscribe()},[]),a&&oU(e,a))?dU().createElement(dU().Fragment,null,t):n?dU().createElement(dU().Fragment,null,n):null};var m$=t(92542),mA=t.n(m$),mk=t(47581);let mw=new Map;function mx(){for(let e of Array.from(mw.values()))e()}let mC={setVisitContext:(e,n)=>null==n?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:n.uuid,patientUuid:n.patient?.uuid}};function mE(e){let n=(0,dV.useId)();return(0,dV.useEffect)(()=>{if(e)return mw.set(n,e),()=>{mw.delete(n)}},[n,e]),{...dQ(u1(),mC),mutateVisit:mx}}function mS(e,n=uQ){let t=(0,dV.useRef)(void 0),{patientUuid:a,manuallySetVisitUuid:o,setVisitContext:r}=mE((0,dV.useCallback)(()=>t.current?.(),[])),i=e&&a==e?o:null,s=`?patient=${e}&v=${n}&includeInactive=false`,l=`/${i}?v=${n}`,{data:c,error:u,mutate:p,isValidating:d}=(0,fm.Ay)(e?`${oz}/visit${s}`:null,oB),{data:f,error:m,mutate:h,isValidating:g}=(0,fm.Ay)(e&&i?`${oz}/visit${l}`:null,oB),y=(0,dV.useMemo)(()=>c?.data.results.find(e=>null===e.stopDatetime)??null,[c]),b=(0,dV.useMemo)(()=>i&&f?f.data:null,[f,i]),v=(0,dV.useRef)(null);(0,dV.useEffect)(()=>{!d&&y&&a===e&&null===o&&r(y),g||(v.current&&b&&v.current.uuid===b.uuid&&!v.current.stopDatetime&&b.stopDatetime&&r(null),v.current=b)},[b,o,y,d,g,a]);let $=(0,dV.useCallback)(()=>{p(),h()},[p,h]);(0,dV.useEffect)(()=>{t.current=$},[$]);let A=!!(!c||i&&!f),k=!!(i?m:u);return{error:u||m,mutate:$,isValidating:d||g,activeVisit:y,currentVisit:b,currentVisitIsRetrospective:!!i,isLoading:A&&!k}}function mD(){let[e,n]=(0,dV.useState)([]);return(0,dV.useEffect)(()=>{let e=uJ().subscribe(e=>{n(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}mA().extend(mk);let mM=new Map;async function mz(e,n){let t=n.indexOf("#"),a=t>=0,o=a?n.substring(0,t):e,r=a?n.substring(t+1):n,i=await r4(o);return i&&Object.hasOwn(i,r)&&"function"==typeof i[r]?mP(o,i).then(()=>i[r]()):(i?i&&Object.hasOwn(i,r)?console.warn(`The export ${n}, defined in ${e}'s routes.json, is not a function`):console.warn(`${o} does not define a component called "${r}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${o} for ${n} defined in ${e}'s routes.json`),mO)}let mO={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function mP(e,n){if(e in mM)await mM[e];else{let t=n??await r4(e);await (mM[e]=new Promise((n,a)=>{if(Object.hasOwn(t,"startupApp")){let o=t.startupApp;if("function"==typeof o)return Promise.resolve(o()).then(()=>{ty(e),n(null)}).catch(a)}ty(e),n(null)}))}}function mT(e,n){let t=n.name;if(!t)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
|
|
17
17
|
registered. To fix this, ensure that you define the "name" field inside the
|
|
18
18
|
extension definition.`,n);n.slots&&n.slot&&console.warn(`The extension ${t} from ${e} declares both a 'slots' property and
|