text: window.FHIR=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SMART_KEY=t.patientParams=t.fhirVersions=t.patientCompartment=void 0,t.patientCompartment=["Account","AdverseEvent","AllergyIntolerance","Appointment","AppointmentResponse","AuditEvent","Basic","BodySite","BodyStructure","CarePlan","CareTeam","ChargeItem","Claim","ClaimResponse","ClinicalImpression","Communication","CommunicationRequest","Composition","Condition","Consent","Coverage","CoverageEligibilityRequest","CoverageEligibilityResponse","DetectedIssue","DeviceRequest","DeviceUseRequest","DeviceUseStatement","DiagnosticOrder","DiagnosticReport","DocumentManifest","DocumentReference","EligibilityRequest","Encounter","EnrollmentRequest","EpisodeOfCare","ExplanationOfBenefit","FamilyMemberHistory","Flag","Goal","Group","ImagingManifest","ImagingObjectSelection","ImagingStudy","Immunization","ImmunizationEvaluation","ImmunizationRecommendation","Invoice","List","MeasureReport","Media","MedicationAdministration","MedicationDispense","MedicationOrder","MedicationRequest","MedicationStatement","MolecularSequence","NutritionOrder","Observation","Order","Patient","Person","Procedure","ProcedureRequest","Provenance","QuestionnaireResponse","ReferralRequest","RelatedPerson","RequestGroup","ResearchSubject","RiskAssessment","Schedule","ServiceRequest","Specimen","SupplyDelivery","SupplyRequest","VisionPrescription"],t.fhirVersions={"0.4.0":2,"0.5.0":2,"1.0.0":2,"1.0.1":2,"1.0.2":2,"1.1.0":3,"1.4.0":3,"1.6.0":3,"1.8.0":3,"3.0.0":3,"3.0.1":3,"3.3.0":4,"3.5.0":4,"4.0.0":4,"4.0.1":4},t.patientParams=["patient","subject","requester","member","actor","beneficiary"],t.SMART_KEY="SMART_KEY"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getTargetWindow=t.getPatientParam=t.byCodes=t.byCode=t.getAccessTokenExpiration=t.jwtDecode=t.createPKCEChallenge=t.randomString=t.absolute=t.makeArray=t.setPath=t.getPath=t.fetchConformanceStatement=t.getAndCache=t.request=t.responseToJSON=t.checkResponse=t.units=t.debug=void 0;const n=r(7),o=r(8),s=r(0),i=r(9),a=r(10),{fetch:c}=window,u=a("FHIR");t.debug=u;const l={};function h({value:e,code:t}){if("number"!=typeof e)throw new Error("Found a non-numerical unit: "+e+" "+t)}async function f(e){if(!e.ok){const t=new o.default(e);throw await t.parse(),t}return e}function d(e){return e.text().then(e=>e.length?JSON.parse(e):"")}function p(e,t={}){const{includeResponse:r,...n}=t;return c(e,{mode:"cors",...n,headers:{accept:"application/json",...n.headers}}).then(f).then(e=>{const t=e.headers.get("Content-Type")+"";return t.match(/\bjson\b/i)?d(e).then(t=>({res:e,body:t})):t.match(/^text\//i)?e.text().then(t=>({res:e,body:t})):{res:e}}).then(({res:e,body:t})=>{if(!t&&201==e.status){const t=e.headers.get("location")+"";if(t)return p(t,{...n,method:"GET",body:null,includeResponse:r})}return r?{body:t,response:e}:void 0===t?e:t})}function g(e,t,r=!1){return r||!l[e]?(l[e]=p(e,t),l[e]):Promise.resolve(l[e])}function m(e,t=""){if(!(t=t.trim()))return e;let r=t.split("."),n=e;for(;n&&r.length;){const e=r.shift();if(!e&&Array.isArray(n))return n.map(e=>m(e,r.join(".")));n=n[e]}return n}function w(e){return Array.isArray(e)?e:[e]}function y(e=8,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){const r=[],n=t.length;for(;e--;)r.push(t.charAt(Math.floor(Math.random()*n)));return r.join("")}function v(e,t){const r=e.split(".")[1];return r?JSON.parse(t.atob(r)):null}function C(e,t){const r={};function n(e,t){e&&Array.isArray(e.coding)&&e.coding.forEach(({code:e})=>{e&&(r[e]=r[e]||[],r[e].push(t))})}return w(e).forEach(e=>{"Observation"===e.resourceType&&e[t]&&(Array.isArray(e[t])?e[t].forEach(t=>n(t,e)):n(e[t],e))}),r}t.units={cm({code:e,value:t}){if(h({code:e,value:t}),"cm"==e)return t;if("m"==e)return 100*t;if("in"==e)return 2.54*t;if("[in_us]"==e)return 2.54*t;if("[in_i]"==e)return 2.54*t;if("ft"==e)return 30.48*t;if("[ft_us]"==e)return 30.48*t;throw new Error("Unrecognized length unit: "+e)},kg({code:e,value:t}){if(h({code:e,value:t}),"kg"==e)return t;if("g"==e)return t/1e3;if(e.match(/lb/))return t/2.20462;if(e.match(/oz/))return t/35.274;throw new Error("Unrecognized weight unit: "+e)},any:e=>(h(e),e.value)},t.checkResponse=f,t.responseToJSON=d,t.request=p,t.getAndCache=g,t.fetchConformanceStatement=function(e="/",t){const r=String(e).replace(/\/*$/,"/")+"metadata";return g(r,t).catch(e=>{throw new Error(`Failed to fetch the conformance statement from "${r}". ${e}`)})},t.getPath=m,t.setPath=function(e,t,r,n=!1){return t.trim().split(".").reduce((e,t,o,s)=>{if(!e||o!==s.length-1)return e&&void 0===e[t]&&n&&(e[t]=s[o+1].match(/^[0-9]+$/)?[]:{}),e?e[t]:void 0;e[t]=r},e),e},t.makeArray=w,t.absolute=function(e,t){return e.match(/^http/)||e.match(/^urn/)?e:String(t||"").replace(/\/+$/,"")+"/"+e.replace(/^\/+/,"")},t.randomString=y,t.createPKCEChallenge=function(){const e=y(43,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~");return{code_verifier:e,code_challenge:n.stringify(i(e)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}},t.jwtDecode=v,t.getAccessTokenExpiration=function(e,t){const r=Math.floor(Date.now()/1e3);if(e.expires_in)return r+e.expires_in;if(e.access_token){let r=v(e.access_token,t);if(r&&r.exp)return r.exp}return r+300},t.byCode=C,t.byCodes=function(e,t){const r=C(e,t);return(...e)=>e.filter(e=>e+""in r).reduce((e,t)=>e.concat(r[t+""]),[])},t.getPatientParam=function(e,t){const r=(m(e,"rest.0.resource")||[]).find(e=>e.type===t);if(!r)throw new Error(`Resource "${t}" is not supported by this FHIR server`);if(!Array.isArray(r.searchParam))throw new Error(`No search parameters supported for "${t}" on this FHIR server`);if("Patient"==t&&r.searchParam.find(e=>"_id"==e.name))return"_id";const n=s.patientParams.find(e=>r.searchParam.find(t=>t.name==e));if(!n)throw new Error("I don't know what param to use for "+t);return n},t.getTargetWindow=async function(e,t=800,r=720){if("function"==typeof e&&(e=await e()),e&&"object"==typeof e)return e;if("string"!=typeof e)return u("Invalid target type '%s'. Failing back to '_self'.",typeof e),self;if("_self"==e)return self;if("_parent"==e)return parent;if("_top"==e)return top;if("_blank"==e){let e,t=null;try{if(t=window.open("","SMARTAuthPopup"),!t)throw new Error("Perhaps window.open was blocked")}catch(t){e=t}return t||(u("Cannot open window. Failing back to '_self'. %s",e),self)}if("popup"==e){let e,n=null;try{if(n=window.open("","SMARTAuthPopup",["height="+r,"width="+t,"menubar=0","resizable=1","status=0","top="+(screen.height-r)/2,"left="+(screen.width-t)/2].join(",")),!n)throw new Error("Perhaps the popup window was blocked")}catch(t){e=t}return n||(u("Cannot open window. Failing back to '_self'. %s",e),self)}const n=frames[e];return n||(u("Unknown target '%s'. Failing back to '_self'.",e),self)}},function(e,t,r){var n;e.exports=(n=n||function(e,t){var r=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),n={},o=n.lib={},s=o.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=o.WordArray=s.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,o=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<o;s++){var i=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=i<<24-(n+s)%4*8}else for(s=0;s<o;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],o=function(t){t=t;var r=987654321,n=4294967295;return function(){var o=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},s=0;s<t;s+=4){var a=o(4294967296*(r||e.random()));r=987654071*a(),n.push(4294967296*a()|0)}return new i.init(n,t)}}),a=n.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o<r;o++){var s=t[o>>>2]>>>24-o%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new i.init(r,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o<r;o++){var s=t[o>>>2]>>>24-o%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new i.init(r,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,o=r.sigBytes,s=this.blockSize,a=o/(4*s),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,u=e.min(4*c,o);if(c){for(var l=0;l<c;l+=s)this._doProcessBlock(n,l);var h=n.splice(0,c);r.sigBytes-=u}return new i.init(h,u)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(o.Hasher=h.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new f.HMAC.init(e,r).finalize(t)}}}),n.algo={});return n}(Math),n)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),o=r(14),s=r(0),{Response:i}=window,a=n.debug.extend("client");function c(e,t,r,o,s,i){const a=n.getPath(e,t);if(a){const c=Array.isArray(a);return Promise.all(n.makeArray(a).filter(Boolean).map((a,u)=>{const l=a.reference;if(l)return function(e,t,r,n){return t[e]||(t[e]=r.request({url:e,signal:n}).then(r=>(t[e]=r,r),r=>{throw delete t[e],r})),Promise.resolve(t[e])}(l,o,s,i).then(o=>{r&&(c?t.indexOf("..")>-1?n.setPath(e,""+t.replace("..",`.${u}.`),o):n.setPath(e,`${t}.${u}`,o):n.setPath(e,t,o))}).catch(e=>{if(404!==e.status)throw e})}))}}function u(e,t,r,o,s){let i=n.makeArray(t.resolveReferences).filter(Boolean).map(e=>String(e).trim()).filter(Boolean);if(i=i.filter((e,t)=>!(i.indexOf(e,t+1)>-1)||(a('Duplicated reference path "%s"',e),!1)),!i.length)return Promise.resolve();const u={};i.forEach(e=>{const t=e.split(".").length;u[t]||(u[t]=[]),u[t].push(e)});let l=Promise.resolve();return Object.keys(u).sort().forEach(n=>{const i=u[n];l=l.then(()=>Promise.all(i.map(n=>c(e,n,!!t.graph,r,o,s))))}),l}t.default=class{constructor(e,t){this.units=n.units;const r="string"==typeof t?{serverUrl:t}:t;if(!r.serverUrl||!r.serverUrl.match(/https?:\/\/.+/))throw new Error('A "serverUrl" option is required and must begin with "http(s)"');this.state=r,this.environment=e,this._refreshTask=null;const o=this;this.patient={get id(){return o.getPatientId()},read:e=>{const t=this.patient.id;return t?this.request({...e,url:"Patient/"+t}):Promise.reject(new Error("Patient is not available"))},request:(e,t={})=>this.patient.id?(async()=>{const r=await async function(e,t){const r=n.absolute("/",t.state.serverUrl);async function o(e){const r=e.pathname.split("/").pop();if(!r)throw new Error(`Invalid url "${e}"`);if(-1==s.patientCompartment.indexOf(r))throw new Error(`Cannot filter "${r}" resources by patient`);const o=await n.fetchConformanceStatement(t.state.serverUrl),i=n.getPatientParam(o,r);return e.searchParams.set(i,t.patient.id),e.href}return"string"==typeof e||e instanceof URL?{url:await o(new URL(e+"",r))}:(e.url=await o(new URL(e.url+"",r)),e)}(e,this);return this.request(r,t)})():Promise.reject(new Error("Patient is not available"))},this.encounter={get id(){return o.getEncounterId()},read:e=>{const t=this.encounter.id;return t?this.request({...e,url:"Encounter/"+t}):Promise.reject(new Error("Encounter is not available"))}},this.user={get fhirUser(){return o.getFhirUser()},get id(){return o.getUserId()},get resourceType(){return o.getUserType()},read:e=>{const t=this.user.fhirUser;return t?this.request({...e,url:t}):Promise.reject(new Error("User is not available"))}},this.connect(e.fhir)}connect(e){if("function"==typeof e){const t={baseUrl:this.state.serverUrl.replace(/\/$/,"")},r=this.getState("tokenResponse.access_token");if(r)t.auth={token:r};else{const{username:e,password:r}=this.state;e&&r&&(t.auth={user:e,pass:r})}this.api=e(t);const n=this.getState("tokenResponse.patient");n&&(this.patient.api=e({...t,patient:n}))}return this}getPatientId(){const e=this.state.tokenResponse;return e?e.patient?e.patient:((this.state.scope||"").match(/\blaunch(\/patient)?\b/)?a("The ID of the selected patient is not available. Please check if your server supports that."):a(o.default.noScopeForId,"patient","patient"),null):(this.state.authorizeUri?a(o.default.noIfNoAuth,"the ID of the selected patient"):a(o.default.noFreeContext,"selected patient"),null)}getEncounterId(){const e=this.state.tokenResponse;return e?e.encounter?e.encounter:((this.state.scope||"").match(/\blaunch(\/encounter)?\b/)?a("The ID of the selected encounter is not available. Please check if your server supports that, and that the selected patient has any recorded encounters."):a(o.default.noScopeForId,"encounter","encounter"),null):(this.state.authorizeUri?a(o.default.noIfNoAuth,"the ID of the selected encounter"):a(o.default.noFreeContext,"selected encounter"),null)}getIdToken(){const e=this.state.tokenResponse;if(e){const t=e.id_token,r=this.state.scope||"";if(!t){const e=r.match(/\bopenid\b/),t=r.match(/\bprofile\b/),n=r.match(/\bfhirUser\b/);return a(e&&(n||t)?"The id_token is not available. Please check if your server supports that.":"You are trying to get the id_token but you are not using the right scopes. Please add 'openid' and 'fhirUser' or 'profile' to the scopes you are requesting."),null}return n.jwtDecode(t,this.environment)}return this.state.authorizeUri?a(o.default.noIfNoAuth,"the id_token"):a(o.default.noFreeContext,"id_token"),null}getFhirUser(){const e=this.getIdToken();return e?e.fhirUser||e.profile:null}getUserId(){const e=this.getFhirUser();return e?e.split("/")[1]:null}getUserType(){const e=this.getFhirUser();return e?e.split("/")[0]:null}getAuthorizationHeader(){const e=this.getState("tokenResponse.access_token");if(e)return"Bearer "+e;const{username:t,password:r}=this.state;return t&&r?"Basic "+this.environment.btoa(t+":"+r):null}async _clearState(){const e=this.environment.getStorage(),t=await e.get(s.SMART_KEY);t&&await e.unset(t),await e.unset(s.SMART_KEY),this.state.tokenResponse={}}create(e,t){return this.request({...t,url:""+e.resourceType,method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",...(t||{}).headers}})}update(e,t){return this.request({...t,url:`${e.resourceType}/${e.id}`,method:"PUT",body:JSON.stringify(e),headers:{"Content-Type":"application/json",...(t||{}).headers}})}delete(e,t={}){return this.request({...t,url:e,method:"DELETE"})}async request(e,t={},r={}){var s;const a=n.debug.extend("client:request");if(!e)throw new Error("request requires an url or request options as argument");let c;"string"==typeof e||e instanceof URL?(c=String(e),e={}):c=String(e.url),c=n.absolute(c,this.state.serverUrl);const l={graph:!1!==t.graph,flat:!!t.flat,pageLimit:null!==(s=t.pageLimit)&&void 0!==s?s:1,resolveReferences:t.resolveReferences||[],useRefreshToken:!1!==t.useRefreshToken,onPage:"function"==typeof t.onPage?t.onPage:void 0},h=e.signal||void 0;let f;return(l.useRefreshToken?this.refreshIfNeeded({signal:h}).then(()=>e):Promise.resolve(e)).then(e=>{const t=this.getAuthorizationHeader();return t&&(e.headers={...e.headers,Authorization:t}),e}).then(e=>(a("%s, options: %O, fhirOptions: %O",c,e,l),n.request(c,e).then(t=>e.includeResponse?(f=t.response,t.body):t))).catch(async e=>{if(401==e.status){if(!this.getState("tokenResponse.access_token"))throw e.message+="\nThis app cannot be accessed directly. Please launch it as SMART app!",e;if(!l.useRefreshToken)throw a("Your session has expired and the useRefreshToken option is set to false. Please re-launch the app."),await this._clearState(),e.message+="\n"+o.default.expired,e;throw a("Auto-refresh failed! Please re-launch the app."),await this._clearState(),e.message+="\n"+o.default.expired,e}throw e}).catch(e=>{throw 403==e.status&&a("Permission denied! Please make sure that you have requested the proper scopes."),e}).then(t=>t?"string"==typeof t||t instanceof i?t:(async e=>("Bundle"==e.resourceType?await Promise.all((e.entry||[]).map(e=>u(e.resource,l,r,this,h))):await u(e,l,r,this,h),e))(t).then(async e=>{if(e&&"Bundle"==e.resourceType){const t=e.link||[];if(l.flat&&(e=(e.entry||[]).map(e=>e.resource)),l.onPage&&await l.onPage(e,{...r}),--l.pageLimit){const o=t.find(e=>"next"==e.relation);if(e=n.makeArray(e),o&&o.url){const t=await this.request({url:o.url,signal:h},l,r);return l.onPage?null:l.resolveReferences.length?(Object.assign(r,t.references),e.concat(n.makeArray(t.data||t))):e.concat(n.makeArray(t))}}}return e}).then(e=>{if(l.graph)r={};else if(!l.onPage&&l.resolveReferences.length)return{data:e,references:r};return e}).then(t=>e.includeResponse?{body:t,response:f}:t):t)}refreshIfNeeded(e={}){const t=this.getState("tokenResponse.access_token"),r=this.getState("tokenResponse.refresh_token"),n=this.state.expiresAt||0;return t&&r&&n-10<Date.now()/1e3?this.refresh(e):Promise.resolve(this.state)}refresh(e={}){var t,r;const o=n.debug.extend("client:refresh");o("Attempting to refresh with refresh_token...");const s=null===(r=null===(t=this.state)||void 0===t?void 0:t.tokenResponse)||void 0===r?void 0:r.refresh_token;if(!s)throw new Error("Unable to refresh. No refresh_token found.");const i=this.state.tokenUri;if(!i)throw new Error("Unable to refresh. No tokenUri found.");const a=this.getState("tokenResponse.scope")||"",c=a.search(/\boffline_access\b/)>-1,u=a.search(/\bonline_access\b/)>-1;if(!c&&!u)throw new Error("Unable to refresh. No offline_access or online_access scope found.");if(!this._refreshTask){const t={credentials:this.environment.options.refreshTokenWithCredentials||"same-origin",...e,method:"POST",mode:"cors",headers:{...e.headers||{},"content-type":"application/x-www-form-urlencoded"},body:"grant_type=refresh_token&refresh_token="+encodeURIComponent(s)};if(!("authorization"in t.headers)){const{clientSecret:e,clientId:r}=this.state;e&&(t.headers.authorization="Basic "+this.environment.btoa(r+":"+e))}this._refreshTask=n.request(i,t).then(e=>{if(!e.access_token)throw new Error("No access token received");return o("Received new access token response %O",e),Object.assign(this.state.tokenResponse,e),this.state.expiresAt=n.getAccessTokenExpiration(e,this.environment),this.state}).catch(e=>{var t,r;throw(null===(r=null===(t=this.state)||void 0===t?void 0:t.tokenResponse)||void 0===r?void 0:r.refresh_token)&&(o("Deleting the expired or invalid refresh token."),delete this.state.tokenResponse.refresh_token),e}).finally(()=>{this._refreshTask=null;const e=this.state.key;e?this.environment.getStorage().set(e,this.state):o("No 'key' found in Clint.state. Cannot persist the instance.")})}return this._refreshTask}byCode(e,t){return n.byCode(e,t)}byCodes(e,t){return n.byCodes(e,t)}getPath(e,t=""){return n.getPath(e,t)}getState(e=""){return n.getPath({...this.state},e)}getFhirVersion(){return n.fetchConformanceStatement(this.state.serverUrl).then(e=>e.fhirVersion)}getFhirRelease(){return this.getFhirVersion().then(e=>{var t;return null!==(t=s.fhirVersions[e])&&void 0!==t?t:0})}}},function(e,t,r){"use strict";const n=new(r(5).default),{ready:o,authorize:s,init:i,client:a,options:c}=n.getSmartApi();const u={AbortController:window.AbortController,client:a,oauth2:{settings:c,ready:o,authorize:s,init:i}};e.exports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),o=r(3),s=r(15);t.default=class{constructor(e={}){this._url=null,this._storage=null,this.options={replaceBrowserHistory:!0,fullSessionStorageSupport:!0,refreshTokenWithCredentials:"same-origin",...e}}relative(e){return new URL(e,this.getUrl().href).href}get fhir(){return"function"==typeof fhir?fhir:null}getUrl(){return this._url||(this._url=new URL(location+"")),this._url}redirect(e){location.href=e}getStorage(){return this._storage||(this._storage=new s.default),this._storage}getAbortController(){return AbortController}atob(e){return window.atob(e)}btoa(e){return window.btoa(e)}getSmartApi(){return{ready:(...e)=>n.ready(this,...e),authorize:e=>n.authorize(this,e),init:e=>n.init(this,e),client:e=>new o.default(this,e),options:this.options}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=t.ready=t.buildTokenRequest=t.completeAuth=t.onMessage=t.isInPopUp=t.isInFrame=t.authorize=t.getSecurityExtensions=t.fetchWellKnownJson=t.KEY=void 0;const n=r(1),o=r(3),s=r(0);Object.defineProperty(t,"KEY",{enumerable:!0,get:function(){return s.SMART_KEY}});const i=n.debug.extend("oauth2");function a(){return"object"==typeof window}function c(e="/",t){const r=String(e).replace(/\/*$/,"/")+".well-known/smart-configuration";return n.getAndCache(r,t).catch(e=>{throw new Error(`Failed to fetch the well-known json "${r}". ${e.message}`)})}function u(e="/",t){return c(e,t).then(e=>{if(!e.authorization_endpoint||!e.token_endpoint)throw new Error("Invalid wellKnownJson");return{registrationUri:e.registration_endpoint||"",authorizeUri:e.authorization_endpoint,tokenUri:e.token_endpoint}})}function l(e="/",t){return n.fetchConformanceStatement(e,t).then(e=>{const t=(n.getPath(e||{},"rest.0.security.extension")||[]).filter(e=>"http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris"===e.url).map(e=>e.extension)[0],r={registrationUri:"",authorizeUri:"",tokenUri:""};return t&&t.forEach(e=>{"register"===e.url&&(r.registrationUri=e.valueUri),"authorize"===e.url&&(r.authorizeUri=e.valueUri),"token"===e.url&&(r.tokenUri=e.valueUri)}),r})}function h(e){const t=e.length,r=[];let n=!1;return new Promise((o,s)=>{function i(e){r.push(e)===t&&s(new Error(r.map(e=>e.message).join("; ")))}e.forEach(t=>{t.promise.then(r=>function(t,r){t.complete=!0,n||(n=!0,e.forEach(e=>{e.complete||e.controller.abort()}),o(r))}(t,r),i)})})}function f(e,t="/"){const r=e.getAbortController(),n=new r,o=new r;return h([{controller:n,promise:u(t,{signal:n.signal})},{controller:o,promise:l(t,{signal:o.signal})}])}async function d(e,t={},r=!1){const o=e.getUrl();if(Array.isArray(t)){const n=o.searchParams.get("iss")||o.searchParams.get("fhirServiceUrl");if(!n)throw new Error('Passing in an "iss" url parameter is required if authorize uses multiple configurations');const s=t.find(e=>{if(e.issMatch){if("function"==typeof e.issMatch)return!!e.issMatch(n);if("string"==typeof e.issMatch)return e.issMatch===n;if(e.issMatch instanceof RegExp)return e.issMatch.test(n)}return!1});if(!s)throw new Error(`No configuration found matching the current "iss" parameter "${n}"`);return await d(e,s,r)}const{redirect_uri:c,clientSecret:u,fakeTokenResponse:l,patientId:h,encounterId:w,client_id:y,target:v,width:C,height:b,usePKCE:_}=t;let{iss:k,launch:S,fhirServiceUrl:P,redirectUri:R,scope:A="",clientId:F,completeInTarget:E}=t;const U=e.getStorage();k=o.searchParams.get("iss")||k,P=o.searchParams.get("fhirServiceUrl")||P,S=o.searchParams.get("launch")||S,F||(F=y),R||(R=c),R?R.match(/^https?\:\/\//)||(R=e.relative(R)):R=e.relative(".");const T=String(k||P||"");if(!T)throw new Error("No server url found. It must be specified as `iss` or as `fhirServiceUrl` parameter");let x;if(k&&i("Making %s launch...",S?"EHR":"standalone"),S&&!A.match(/launch/)&&(A+=" launch"),_){if(u)throw new Error("PKCE should only be used by public single-page web apps or native apps without a client secret");x=n.createPKCEChallenge()}if(a()){const e=p(),t=g();(e||t)&&!0!==E&&!1!==E&&(E=e,console.warn('Your app is being authorized from within an iframe or popup window. Please be explicit and provide a "completeInTarget" option. Use "true" to complete the authorization in the same window, or "false" to try to complete it in the parent or the opener window. See http://docs.smarthealthit.org/client-js/api.html'))}const I=await U.get(s.SMART_KEY);await U.unset(I);const M=n.randomString(16),O={clientId:F,scope:A,redirectUri:R,serverUrl:T,clientSecret:u,tokenResponse:{},key:M,completeInTarget:E,pkce:x};(!a()||n.getPath(e,"options.fullSessionStorageSupport"))&&await U.set(s.SMART_KEY,M),l&&Object.assign(O.tokenResponse,l),h&&Object.assign(O.tokenResponse,{patient:h}),w&&Object.assign(O.tokenResponse,{encounter:w});let j=R+"?state="+encodeURIComponent(M);if(P&&!k)return i("Making fake launch..."),await U.set(M,O),r?j:await e.redirect(j);const z=await f(e,T);if(Object.assign(O,z),await U.set(M,O),!O.authorizeUri)return r?j:await e.redirect(j);const q=["response_type=code","client_id="+encodeURIComponent(F||""),"scope="+encodeURIComponent(A),"redirect_uri="+encodeURIComponent(R),"aud="+encodeURIComponent(T),"state="+encodeURIComponent(M)];if(S&&q.push("launch="+encodeURIComponent(S)),O.pkce&&(q.push("code_challenge="+O.pkce.code_challenge),q.push("code_challenge_method=S256")),j=O.authorizeUri+"?"+q.join("&"),r)return j;if(!v||!a())return await e.redirect(j);{let e;if(e=await n.getTargetWindow(v,C,b),e!==self)try{e.sessionStorage.removeItem(I),e.sessionStorage.setItem(M,JSON.stringify(O))}catch(t){n.debug('Failed to modify window.sessionStorage. Perhaps it is from different origin?. Failing back to "_self". %s',t),e=self}if(e!==self)try{e.location.href=j,self.addEventListener("message",m)}catch(e){n.debug('Failed to modify window.location. Perhaps it is from different origin?. Failing back to "_self". %s',e),self.location.href=j}else self.location.href=j}}function p(){try{return self!==top&&parent!==self}catch(e){return!0}}function g(){try{return self===top&&!!opener&&opener!==self&&!!window.name}catch(e){return!1}}function m(e){"completeAuth"==e.data.type&&e.origin===new URL(self.location.href).origin&&(window.removeEventListener("message",m),window.location.href=e.data.url)}async function w(e){var t,r;const c=e.getUrl(),u=e.getStorage(),l=c.searchParams;let h=l.get("state");const f=l.get("code"),d=l.get("error"),m=l.get("error_description");if(h||(h=await u.get(s.SMART_KEY)),d||m)throw new Error([d,m].filter(Boolean).join(": "));if(i("key: %s, code: %s",h,f),!h)throw new Error("No 'state' parameter found. Please (re)launch the app.");let w=await u.get(h);const v=!a()||n.getPath(e,"options.fullSessionStorageSupport");if(a()&&w&&!w.completeInTarget){const e=p(),t=g();if((e||t)&&!c.searchParams.get("complete")){c.searchParams.set("complete","1");const{href:r,origin:n}=c;return e&&parent.postMessage({type:"completeAuth",url:r},n),t&&(opener.postMessage({type:"completeAuth",url:r},n),window.close()),new Promise(()=>{})}}c.searchParams.delete("complete");const C=l.has("state");if(a()&&n.getPath(e,"options.replaceBrowserHistory")&&(f||C)&&(f&&(l.delete("code"),i("Removed code parameter from the url.")),C&&v&&(l.delete("state"),i("Removed state parameter from the url.")),window.history.replaceState&&window.history.replaceState({},"",c.href)),!w)throw new Error("No state found! Please (re)launch the app.");if(!(!f||(null===(t=w.tokenResponse)||void 0===t?void 0:t.access_token))&&w.tokenUri){if(!f)throw new Error("'code' url parameter is required");i("Preparing to exchange the code for access token...");const t=y(e,f,w);i("Token request options: %O",t);const r=await n.request(w.tokenUri,t);if(i("Token response: %O",r),!r.access_token)throw new Error("Failed to obtain access token.");w.expiresAt=n.getAccessTokenExpiration(r,e),w={...w,tokenResponse:r},await u.set(h,w),i("Authorization successful!")}else i((null===(r=w.tokenResponse)||void 0===r?void 0:r.access_token)?"Already authorized":"No authorization needed");v&&await u.set(s.SMART_KEY,h);const b=new o.default(e,w);return i("Created client instance: %O",b),b}function y(e,t,r){const{redirectUri:n,clientSecret:o,tokenUri:s,clientId:a,pkce:c}=r;if(!n)throw new Error("Missing state.redirectUri");if(!s)throw new Error("Missing state.tokenUri");if(!a)throw new Error("Missing state.clientId");const u={method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:`code=${t}&grant_type=authorization_code&redirect_uri=${encodeURIComponent(n)}`};return o?(u.headers.Authorization="Basic "+e.btoa(a+":"+o),i("Using state.clientSecret to construct the authorization header: %s",u.headers.Authorization)):(i("No clientSecret found in state. Adding the clientId to the POST body"),u.body+="&client_id="+encodeURIComponent(a),c&&(i("PKCE is enabled for this auth. Adding the code_verifier to the POST body"),u.body+="&code_verifier="+c.code_verifier)),u}t.fetchWellKnownJson=c,t.getSecurityExtensions=f,t.authorize=d,t.isInFrame=p,t.isInPopUp=g,t.onMessage=m,t.completeAuth=w,t.buildTokenRequest=y,t.ready=async function(e,t,r){let n=w(e);return t&&(n=n.then(t)),r&&(n=n.catch(r)),n},t.init=async function(e,t){const r=e.getUrl(),n=r.searchParams.get("code"),i=r.searchParams.get("state");if(n&&i)return w(e);const a=e.getStorage(),c=i||await a.get(s.SMART_KEY),u=await a.get(c);return u?new o.default(e,u):d(e,t).then(()=>new Promise(()=>{}))}},function(e,t,r){var n,o,s;e.exports=(s=r(2),o=(n=s).lib.WordArray,n.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var o=[],s=0;s<r;s+=3)for(var i=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<r;a++)o.push(n.charAt(i>>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;o.length%4;)o.push(c);return o.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var s=0;s<r.length;s++)n[r.charCodeAt(s)]=s}var i=r.charAt(64);if(i){var a=e.indexOf(i);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],s=0,i=0;i<t;i++)if(i%4){var a=r[e.charCodeAt(i-1)]<<i%4*2,c=r[e.charCodeAt(i)]>>>6-i%4*2;n[s>>>2]|=(a|c)<<24-s%4*8,s++}return o.create(n,s)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},s.enc.Base64)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e){super(`${e.status} ${e.statusText}\nURL: ${e.url}`),this.name="HttpError",this.response=e,this.statusCode=e.status,this.status=e.status,this.statusText=e.statusText}async parse(){if(!this.response.bodyUsed)try{const e=this.response.headers.get("Content-Type")||"text/plain";if(e.match(/\bjson\b/i)){let e=await this.response.json();e.error?(this.message+="\n"+e.error,e.error_description&&(this.message+=": "+e.error_description)):this.message+="\n\n"+JSON.stringify(e,null,4)}else if(e.match(/^text\//i)){let e=await this.response.text();e&&(this.message+="\n\n"+e)}}catch{}return this}toJSON(){return{name:this.name,statusCode:this.statusCode,status:this.status,statusText:this.statusText,message:this.message}}}t.default=n},function(e,t,r){var n;e.exports=(n=r(2),function(e){var t=n,r=t.lib,o=r.WordArray,s=r.Hasher,i=t.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,o=0;o<64;)t(n)&&(o<8&&(a[o]=r(e.pow(n,.5))),c[o]=r(e.pow(n,1/3)),o++),n++}();var u=[],l=i.SHA256=s.extend({_doReset:function(){this._hash=new o.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],o=r[1],s=r[2],i=r[3],a=r[4],l=r[5],h=r[6],f=r[7],d=0;d<64;d++){if(d<16)u[d]=0|e[t+d];else{var p=u[d-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,m=u[d-2],w=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[d]=g+u[d-7]+w+u[d-16]}var y=n&o^n&s^o&s,v=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),C=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&l^~a&h)+c[d]+u[d];f=h,h=l,l=a,a=i+C|0,i=s,s=o,o=n,n=C+(v+y)|0}r[0]=r[0]+n|0,r[1]=r[1]+o|0,r[2]=r[2]+s|0,r[3]=r[3]+i|0,r[4]=r[4]+a|0,r[5]=r[5]+l|0,r[6]=r[6]+h|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;return r[o>>>5]|=128<<24-o%32,r[14+(o+64>>>9<<4)]=e.floor(n/4294967296),r[15+(o+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=s._createHelper(l),t.HmacSHA256=s._createHmacHelper(l)}(Math),n.SHA256)},function(e,t,r){(function(n){t.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))}),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r(12)(t);const{formatters:o}=e.exports;o.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(11))},function(e,t){var r,n,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c,u=[],l=!1,h=-1;function f(){l&&c&&(l=!1,c.length?u=c.concat(u):h=-1,u.length&&d())}function d(){if(!l){var e=a(f);l=!0;for(var t=u.length;t;){for(c=u,u=[];++h<t;)c&&c[h].run();h=-1,t=u.length}c=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function g(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new p(e,t)),1!==u.length||l||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=g,o.addListener=g,o.once=g,o.off=g,o.removeListener=g,o.removeAllListeners=g,o.emit=g,o.prependListener=g,o.prependOnceListener=g,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){e.exports=function(e){function t(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){let r;function i(...e){if(!i.enabled)return;const t=i,o=Number(new Date),s=o-(r||o);t.diff=s,t.prev=r,t.curr=o,r=o,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return r;a++;const s=n.formatters[o];if("function"==typeof s){const n=e[a];r=s.call(t,n),e.splice(a,1),a--}return r}),n.formatArgs.call(t,e);(t.log||n.log).apply(t,e)}return i.namespace=e,i.enabled=n.enabled(e),i.useColors=n.useColors(),i.color=t(e),i.destroy=o,i.extend=s,"function"==typeof n.init&&n.init(i),n.instances.push(i),i}function o(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function s(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){const e=[...n.names.map(i),...n.skips.map(i).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){const e=n.instances[t];e.enabled=n.enabled(e.namespace)}},n.enabled=function(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=r(13),Object.keys(e).forEach(t=>{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){var r=1e3,n=6e4,o=60*n,s=24*o;function i(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}e.exports=function(e,t){t=t||{};var a=typeof e;if("string"===a&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var i=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*i;case"weeks":case"week":case"w":return 6048e5*i;case"days":case"day":case"d":return i*s;case"hours":case"hour":case"hrs":case"hr":case"h":return i*o;case"minutes":case"minute":case"mins":case"min":case"m":return i*n;case"seconds":case"second":case"secs":case"sec":case"s":return i*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}(e);if("number"===a&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);if(t>=s)return i(e,t,s,"day");if(t>=o)return i(e,t,o,"hour");if(t>=n)return i(e,t,n,"minute");if(t>=r)return i(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=s)return Math.round(e/s)+"d";if(t>=o)return Math.round(e/o)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={expired:"Session expired! Please re-launch the app",noScopeForId:"Trying to get the ID of the selected %s. Please add 'launch' or 'launch/%s' to the requested scopes and try again.",noIfNoAuth:"You are trying to get %s but the app is not authorized yet.",noFreeContext:"Please don't use open fhir servers if you need to access launch context items like the %S."}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{async get(e){const t=sessionStorage[e];return t?JSON.parse(t):null}async set(e,t){return sessionStorage[e]=JSON.stringify(t),t}async unset(e){return e in sessionStorage&&(delete sessionStorage[e],!0)}}}]);
  //# sourceMappingURL=fhir-client.pure.min.js.map