@careevolution/mydatahelps-js 4.2.0 → 4.2.1

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/MyDataHelps.js CHANGED
@@ -724,7 +724,7 @@ class MyDataHelps {
724
724
  }
725
725
  getFeaturedProviders(context) {
726
726
  const queryParameters = {};
727
- if (context !== undefined) {
727
+ if (context) {
728
728
  queryParameters['featuredProvidersContext'] = context;
729
729
  }
730
730
  const queryString = new URLSearchParams(queryParameters).toString();
@@ -1,2 +1,2 @@
1
- class e{startSurvey(e){if(this.isStandaloneMode())this.startDelegatedSurvey(`${this.baseUrl}/survey?surveyName=${encodeURIComponent(e)}`);else if(window.webkit.messageHandlers.StartParticipantSurvey){let t=this.nextMessageID();window.webkit.messageHandlers.StartParticipantSurvey.postMessage({messageID:t,surveyName:e})}}completeStep(e){if(null==e&&(e=""),"string"!=typeof e&&(e=JSON.stringify(e)),window.webkit.messageHandlers.ResearchKit)window.webkit.messageHandlers.ResearchKit.postMessage(e);else if(window.webkit.messageHandlers.CompleteStep){let t=this.nextMessageID();window.webkit.messageHandlers.CompleteStep.postMessage({messageID:t,answer:e})}}querySurveyAnswers(t){(t=Object.assign({},t)).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("stepIdentifier")&&(t.stepIdentifier=e.reduceArrayAndEscape(t.stepIdentifier)),t.hasOwnProperty("resultIdentifier")&&(t.resultIdentifier=e.reduceArrayAndEscape(t.resultIdentifier)),t.hasOwnProperty("answer")&&(t.answer=e.reduceArrayAndEscape(t.answer)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after));const n="surveyanswers?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}querySurveyResults(t){(t={...t}).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("event")&&(t.event=e.reduceArrayAndEscape(t.event)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter));const n="surveyresults?"+new URLSearchParams(t).toString();return this.connect().then((()=>this.makeRequest(n,"GET",null))).then(e.validateResponse).then((e=>e.json()))}deleteSurveyResult(t){const n="surveyresults/"+encodeURIComponent(t),s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}querySurveyTasks(t){(t=Object.assign({},t)).hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status)),t.hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName));const n="surveytasks?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryInboxItems(t){(t=((e,t)=>{for(const n of Object.keys(t)){const s=t[n];void 0!==s&&(e[n]=s)}return e})({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status));const n="inbox?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getInboxItem(t){const n=`inbox/${t}`,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}updateInboxItem(t,n){const s=`inbox/${t}/${n}`,r=this;return this.connect().then((function(){return r.makeRequest(s,"PUT",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}startEmbeddedSurvey(e,t,n){n||(n=this.getCurrentLanguage());let s=this.baseUrl+"mydatahelps/"+e+"/surveylink/"+t+"?lang="+n;return this.startEmbeddedSurveyInternal(s)}openExternalUrl(e){window.webkit.messageHandlers.OpenExternalLink&&window.webkit.messageHandlers.OpenExternalLink.postMessage(e)}openEmbeddedUrl(e){window.webkit.messageHandlers.OpenEmbeddedLink&&window.webkit.messageHandlers.OpenEmbeddedLink.postMessage(e)}showTab(e){window.webkit.messageHandlers.ShowTab&&window.webkit.messageHandlers.ShowTab.postMessage(e)}openApplication(e,t){if(window.webkit.messageHandlers.OpenExternalApplication){let n=this.nextMessageID();window.webkit.messageHandlers.OpenExternalApplication.postMessage({messageID:n,url:e,modal:!(!t||!t.modal)})}}dismiss(){window.webkit.messageHandlers.Dismiss&&window.webkit.messageHandlers.Dismiss.postMessage({})}back(){window.webkit.messageHandlers.PopNavigation&&window.webkit.messageHandlers.PopNavigation.postMessage({})}showDashboard(e,t){window.webkit.messageHandlers.ShowParticipantDashboard&&window.webkit.messageHandlers.ShowParticipantDashboard.postMessage({dashboardKey:e,modal:!(!t||!t.modal),title:t&&t.title?t.title:void 0})}showWebVisualization(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualization&&window.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({visualizationKey:e,parameters:t,modal:!(!n||!n.modal),title:n&&n.title?n.title:void 0})}showWebVisualizationPdf(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF&&window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({visualizationKey:e,parameters:t,landscape:!(!n||!n.landscape),htmlViewerZoom:n&&n.htmlViewerZoom})}showProject(e){window.webkit.messageHandlers.ShowProject&&window.webkit.messageHandlers.ShowProject.postMessage({code:e})}joinProject(e){window.webkit.messageHandlers.JoinProject&&window.webkit.messageHandlers.JoinProject.postMessage({code:e})}on(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");this.registeredEventHandlers[e]||(this.registeredEventHandlers[e]=[]),this.registeredEventHandlers[e].push(t)}off(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");if(!this.registeredEventHandlers[e])return;let n=this.registeredEventHandlers[e].indexOf(t);-1!==n&&this.registeredEventHandlers[e].splice(n,1)}triggerEvent(e){let t=e.type;this.supportedEvents.includes(t)&&this.registeredEventHandlers[t]&&this.registeredEventHandlers[t].forEach((function(t){t(e)}))}setActionResult(e){Object.prototype.hasOwnProperty.call(this.messageHandlers,e.messageID)&&"function"==typeof this.messageHandlers[e.messageID]?this.messageHandlers[e.messageID](e):console.error(`Invalid messageID: ${e.messageID}`)}getParticipantInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("participant","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistParticipantInfo(e,t){const n=this;return this.connect().then((function(){return n.makeRequest("participant","PUT",{demographics:e,customFields:t})})).then((async function(e){if(!e.ok)throw(await e.json()).message;return e.json()})).catch((function(e){console.log("Unable to persist participant: "+e)}))}getProjectInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("project","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryDeviceData(t){(t=Object.assign({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter));const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistDeviceData(t){const n=this;return this.connect().then((function(){return n.makeRequest("devicedata","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryDeviceDataV2(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2Aggregate(t){(t=Object.assign({},t)).hasOwnProperty("aggregateFunctions")&&(t.aggregateFunctions=e.reduceArrayAndEscape(t.aggregateFunctions)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2DailySleep(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate/dailysleep?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataV2AllDataTypes(t){const n={};void 0!==t&&(n.enabled=t.toString());const s=`devicedata/allDataTypes?${new URLSearchParams(n).toString()}`,r=this;return this.connect().then((function(){return r.makeRequest(s,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getExternalAccountProviders(t,n,s,r){let a={};t&&(a.search=t),n&&(a.category=n),s&&(a.pageSize=s),r&&(a.pageNumber=r);const o="externalaccountproviders?"+new URLSearchParams(a).toString(),i=this;return this.connect().then((function(){return i.makeRequest(o,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}connectExternalAccount(n,s){return new Promise(((r,a)=>{const o=t.nextMessageID();if(t.messageHandlers[o]=function(e){e&&e.success?r():a(e.errorMessage)},this.standaloneMode){let t=s?.standaloneModeFinalRedirectPath||window.location.href;const r=this;let i;if(s?.openNewWindow){t=`${t.split("?")[0]}?connectExternalAccount=true&messageID=${o}&success=%SUCCESSVALUE%`;let e=null;if(s?.width&&s?.height){const t=s?.width,n=s?.height;e="width="+t+",height="+n+",top="+(window.outerHeight/2+window.screenY-n/2)+",left="+(window.outerWidth/2+window.screenX-t/2)}i=window.open(`${this.baseUrl}home/loading`,"providerauth",e)}const d=new URLSearchParams({finalRedirectPath:t}).toString(),c="externalaccountproviders/"+n+"/connect?"+d;this.connect().then((function(){return r.makeRequest(c,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.text()})).then((function(e){i?i.location=e.replace(/['"]+/g,""):window.top.location=e.replace(/['"]+/g,"")})).catch((function(e){a(e)}))}else window.webkit.messageHandlers.ConnectExternalAccount&&window.webkit.messageHandlers.ConnectExternalAccount.postMessage({externalAccountProviderID:n,messageID:o,...s})}))}getExternalAccounts(){const t=this;return this.connect().then((function(){return t.makeRequest("externalaccounts","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}refreshExternalAccount(t){const n="externalaccounts/refresh/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}deleteExternalAccount(t){const n="externalaccounts/delete/"+encodeURIComponent(t),s=this;return this.isStandaloneMode()?this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})):new Promise((function(e,n){if(window.webkit.messageHandlers.DeleteProviderAccount){const r=s.nextMessageID();s.messageHandlers[r]=function(t){t.success?e(t):n(t)},window.webkit.messageHandlers.DeleteProviderAccount.postMessage({messageID:r,accountID:t})}else n()}))}getFeaturedProviders(t){const n={};void 0!==t&&(n.featuredProvidersContext=t);const s=`featuredexternalaccountproviders?${new URLSearchParams(n).toString()}`;return this.connect().then((()=>this.makeRequest(s,"GET",null))).then(e.validateResponse).then((e=>e.json()))}queryNotifications(t){(t=Object.assign({},t)).hasOwnProperty("sentBefore")&&(t.sentBefore=e.convertDateToIsoString(t.sentBefore)),t.hasOwnProperty("sentAfter")&&(t.sentAfter=e.convertDateToIsoString(t.sentAfter));const n="notifications?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitDailySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/dailySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitSleepLogs(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/sleepLogs?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthActivitySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/activitySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthWorkouts(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/workouts?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}uploadFile(t,n,s){if(t.size>209715200)throw new Error("File size exceeds the maximum allowed size of 200MB.");const r=this,a="files?category="+n+"&fileName="+encodeURIComponent(s??t.name);return this.connect().then((function(){return r.makeRequest(a,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()})).then((function(e){return fetch(e.preSignedUrl,{method:"PUT",body:t,headers:{"Content-Type":t.type,"x-amz-server-side-encryption":"AES256"}})})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryFiles(t){const n="files?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getFileDownloadUrl(t){if(!t)throw new Error("Please specify the key of the file to download.");const n="files/download?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteFile(t){if(!t)throw new Error("Please specify the key of the file to delete.");const n="files?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}connect(){const e=this;let t=function(){e.token=null,e.refreshTokenPromise=new Promise((function(n,s){let r=e.nextMessageID();e.messageHandlers[r]=function(a){a.success?(e.tokenExpires=Date.now()+1e3*a.data.expires_in,e.token=a.data,e.baseUrl=a.baseUrl,setTimeout(t,1e3*(a.data.expires_in-e.accessTokenRenewalBufferSeconds)),n(null)):(e.token=null,s(a.message)),e.messageHandlers[r]=null,e.refreshTokenPromise=null},window.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({messageID:r})}))};if(this.token&&Date.now()<this.tokenExpires)return Promise.resolve();if(this.isStandaloneMode()&&!this.isEmbeddedMode()){let e=this.token?"access token is expired or invalid":"access token must be explicitly provided using the setParticipantAccess method";return console.log(e),Promise.reject(e)}return this.refreshTokenPromise||t(),this.refreshTokenPromise}setParticipantAccessToken(e,t){this.enableStandaloneMode(),this.token=e,t&&(this.baseUrl=t),this.tokenExpires=Date.now()+1e3*this.token.expires_in;const n=this;setTimeout((function(){n.triggerEvent({type:"tokenWillExpire"})}),1e3*(this.token.expires_in-this.accessTokenRenewalBufferSeconds))}isStandaloneMode(){return this.standaloneMode}isEmbeddedMode(){return this.embeddedMode}enableStandaloneMode(e=!1,t){this.standaloneMode=!0,this.embeddedMode=e,t&&(this.baseUrl=t),window.webkit&&(window.webkit.messageHandlers=e?{GetDelegatedAccessToken:window.webkit.messageHandlers.GetDelegatedAccessToken,OpenExternalLink:window.webkit.messageHandlers.OpenExternalLink,OpenEmbeddedLink:window.webkit.messageHandlers.OpenEmbeddedLink,OpenExternalApplication:window.webkit.messageHandlers.OpenExternalApplication,PopNavigation:window.webkit.messageHandlers.PopNavigation,Dismiss:window.webkit.messageHandlers.Dismiss}:{})}setStatusBarStyle(e){window.webkit.messageHandlers.SetStatusBarStyle&&window.webkit.messageHandlers.SetStatusBarStyle.postMessage({style:e})}getDeviceInfo(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetDeviceInfo){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetDeviceInfo.postMessage({messageID:n})}else n()}))}setSupportedLanguages(e){this.supportedLanguages.length=0;for(let t=0;t<e.length;t++)this.supportedLanguages.push(e[t].replace("_","-"))}getStepConfiguration(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetStepConfiguration){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetStepConfiguration.postMessage({messageID:n})}else n()}))}getSurveyContext(){let e=this;return new Promise((function(t,n){e.isStandaloneMode()&&t(null),e.getDeviceInfo().then((function(s){if("Web"!==s.platform)t({surveyMode:"Survey"});else if(window.webkit.messageHandlers.GetSurveyContext){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetSurveyContext.postMessage({messageID:n})}else n()})).catch((function(e){n()}))}))}getCurrentSurveyAnswers(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetCurrentSurveyAnswers){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({messageID:n})}else n()}))}setCurrentLanguage(e){if(e){let t=this.getSupportedLanguage(e);t?this.language=t:console.warn(`language ${e} not supported`)}else this.language=e}getCurrentLanguage(){let e,t=new URLSearchParams(window.location.search);if(t.has("lang")){if(e=this.getSupportedLanguage(t.get("lang")),e)return e;console.warn(`language ${t.get("lang")} not supported`)}return this.language||navigator.language}showGoogleFitSettings(){window.webkit.messageHandlers.ShowGoogleFitSettings&&window.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({})}showHealthConnectSettings(){window.webkit.messageHandlers.HealthConnectSettings&&window.webkit.messageHandlers.HealthConnectSettings.postMessage({})}showHealthConnectPrompt(){window.webkit.messageHandlers.HealthConnectPrompt&&window.webkit.messageHandlers.HealthConnectPrompt.postMessage({})}getHealthConnectStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectStatus.postMessage({messageID:n})}else n()}))}showHealthConnectPhrPrompt(){window.webkit.messageHandlers.HealthConnectPhrPrompt&&window.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({})}getHealthConnectPhrStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectPhrStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({messageID:n})}else n()}))}requestReview(e){window.webkit.messageHandlers.RequestReview&&window.webkit.messageHandlers.RequestReview.postMessage({cooldownDays:e})}trackCustomEvent(t){const n=this;return this.connect().then((function(){return n.makeRequest("customevents","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}getDataCollectionSettings(){const t=this;return this.connect().then((function(){return t.makeRequest("datacollectionsettings","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDataAvailability(){const t=this;return this.connect().then((function(){return t.makeRequest("dataavailability","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}invokeCustomApi(t,n,s,r){if(t.includes("?"))throw new Error('Cannot include query parameters directly in the "customApi" string. Provide as an argument for "queryParameters" instead.');let a="custom/"+t;if(n=n.toUpperCase(),null!=s&&("GET"===n||"DELETE"===n)){let e=new URLSearchParams(s).toString();a+="?"+e,s=null}const o=this;return this.connect().then((function(){return o.makeRequest(a,n,s)})).then((function(t){return e.validateResponse(t)})).then((function(e){return r?e.json():void 0}))}constructor(){if(this.baseUrl="https://mydatahelps.org/",this.acceptableParentDomains=["localhost","careevolution.com","internal","b3-deploys.com","mydatahelps.org","platform.joinallofus.org","careevolution.dev","ce.dev","mydatahelps.dev"],this.accessTokenRenewalBufferSeconds=120,this.unsupportedActions=["SetHeight","ResearchKit"],this.supportedEvents=["surveyDidFinish","applicationDidBecomeVisible","externalAccountSyncComplete","tokenWillExpire","healthConnectSyncComplete","healthConnectPhrSyncComplete"],this.supportedLanguages=[],this.currentMessageID=1,this.messageHandlers=[],this.registeredEventHandlers={},this.refreshTokenPromise=null,this.standaloneMode=!1,this.embeddedMode=!1,this.handleConnectExternalAccountResponse())return;let e,t=this,n=function(){let e=document.location.ancestorOrigins;if(e&&e[0])return e[0];return"*"}();function s(e){if("*"===e)return!0;let n=new URL(e);for(let e=0;e<t.acceptableParentDomains.length;e++)if(n.hostname===t.acceptableParentDomains[e]||n.hostname.endsWith("."+t.acceptableParentDomains[e]))return!0;return!1}s(n)||console.log("Detected unsupported parent origin domain."),e=window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.ResearchKit?{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},GetSurveyContext:function(e){window.parent.postMessage({name:"GetSurveyContext",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}}:{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},GetDeviceInfo:function(e){window.parent.postMessage({name:"GetDeviceInfo",messageID:e.messageID},n)},StartParticipantSurvey:function(e){window.parent.postMessage({name:"StartParticipantSurvey",messageID:e.messageID,surveyName:e.surveyName},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},OpenExternalApplication:function(e){window.parent.postMessage({name:"OpenApplication",messageID:e.messageID,url:e.url,modal:e.modal},n)},Dismiss:function(){window.parent.postMessage({name:"Dismiss"},n)},PopNavigation:function(){window.parent.postMessage({name:"Back"},n)},ShowTab:function(e){window.parent.postMessage({name:"ShowTab",tabKey:e},n)},ShowParticipantDashboard:function(e){window.parent.postMessage({name:"ShowParticipantDashboard",dashboardKey:e.dashboardKey,modal:e.modal},n)},ShowParticipantWebVisualization:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualization",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal},n)},ShowParticipantWebVisualizationPDF:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualizationPDF",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal,landscape:e.landscape,htmlViewerZoom:e.htmlViewerZoom},n)},DeleteProviderAccount:function(e){window.parent.postMessage({name:"DeleteProviderAccount",messageID:e.messageID,accountID:e.accountID},n)},ConnectExternalAccount:function(e){window.parent.postMessage({name:"ConnectExternalAccount",externalAccountProviderID:e.externalAccountProviderID,messageID:e.messageID,openNewWindow:e.openNewWindow,width:e.width,height:e.height},n)},ShowProject:function(e){window.parent.postMessage({name:"ShowProject",code:e.code},n)},JoinProject:function(e){window.parent.postMessage({name:"JoinProject",code:e.code},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}},window.webkit&&window.webkit.messageHandlers&&function(){for(let t in e)if(window.webkit.messageHandlers[t])return!0;for(let e in t.unsupportedActions)if(window.webkit.messageHandlers[t.unsupportedActions[e]])return!0;return!1}()||(window.webkit={messageHandlers:{}}),function(e){for(let t in e)if(!window.webkit.messageHandlers[t])try{window.webkit.messageHandlers[t]={postMessage:e[t]}}catch(e){return void console.log("Unable to add missing actions on this platform: "+e)}}(e),window.addEventListener("message",(function(e){if(!function(e){return!(!t.isStandaloneMode()||e.origin!==window.location.origin)||("*"===n?s(e.origin):e.origin===n)}(e))throw console.error("message.origin '"+e.origin+"' is not allowed."),"message.origin '"+e.origin+"' is not allowed.";e.data.messageID?t.setActionResult(e.data):t.triggerEvent(e.data)}),!1),this.hasEmbeddedModeUrlParameter()&&t.enableStandaloneMode(!0)}nextMessageID(){return this.currentMessageID++}makeUrl(e,t){if(!this.baseUrl)throw console.error("Cannot use makeUrl without MyDataHelps.baseUrl."),"Cannot use makeUrl without MyDataHelps.baseUrl.";return this.baseUrl+"api/"+t+"/delegated/"+e}makeRequest(e,t,n,s="v1"){if(!this.token||!this.token.access_token)throw"No access_token available for request authorization.";let r=this.makeUrl(e,s),a=new Headers;a.append("Authorization","Bearer "+this.token.access_token),a.append("Accept","application/json, text/javascript, */*; q=0.01"),a.append("Accept-Language",this.getCurrentLanguage()),n&&a.append("Content-Type","application/json");let o={method:t,headers:a};return n&&(o.body=JSON.stringify(n)),fetch(r,o)}getSupportedLanguage(e){return e=e.replace("_","-"),0===this.supportedLanguages.length||this.supportedLanguages.find((t=>t===e))||e.indexOf("-")>0&&(e=e.substring(0,e.indexOf("-")),this.supportedLanguages.find((t=>t===e)))?e:void 0}static validateResponse(e){if(!e.ok)throw e.statusText;return e}static escapeParam(e){return String(e).replaceAll("\\","\\\\").replaceAll(",","\\,")}static reduceArrayAndEscape(t){if(Array.isArray(t)){return t.map((function(t){return e.escapeParam(t)})).join(",")}return this.escapeParam(t)}static convertDateToIsoString(e){let t=new Date(e);if(isNaN(t.getTime()))throw"Cannot interpret parameter as Date";return t.toISOString()}static flattenPropertyShallow(t,n){if(void 0!==t[n]&&null!==t[n]){for(var s in t[n])t[n].hasOwnProperty(s)&&(t[`${n}.${s}`]=e.escapeParam(t[n][s]));delete t[n]}}startEmbeddedSurveyInternal(e){let t="mydatahelps-survey-modal",n=this;return new Promise((function(s,r){if(document.getElementById(t))return void r("Survey already in progress");window.addEventListener("message",(function e(r){if(r.origin!==new URL(n.baseUrl).origin)return;let a=document.getElementById("mydatahelps-survey-frame").contentWindow;r.source===a&&("SurveyWindowInitialized"===r.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===r.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s(r.data)))}),!0);let a=document.createElement("div");a.className="mydatahelps-survey-modal",a.id=t,a.innerHTML="<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='"+e+"'></iframe></div>",document.body.append(a),document.body.className+=" no-scroll"}))}startDelegatedSurvey(e){let t="mydatahelps-survey-modal",n=this;if(document.getElementById(t))return;window.addEventListener("message",(function e(s){if(s.origin!==new URL(n.baseUrl).origin)return;let r=document.getElementById("mydatahelps-survey-frame").contentWindow;s.source===r&&("GetDelegatedAccessToken"===s.data.name?n.getParticipantInfo().then((e=>{r.postMessage({name:"DelegatedAccessTokenResponse",accessToken:n.token,baseUrl:n.baseUrl,participantID:e.participantID},"*")})):"SurveyWindowInitialized"===s.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===s.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s.data.type="surveyDidFinish",n.triggerEvent(s.data)))}),!0);let s=document.createElement("div");s.className="mydatahelps-survey-modal",s.id=t,s.innerHTML=`<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${e}&lang=${n.getCurrentLanguage()}'></iframe></div>`,document.body.append(s),document.body.className+=" no-scroll"}handleConnectExternalAccountResponse(){const e=new URLSearchParams(window.location.search);if(window.opener&&e.get("connectExternalAccount")&&e.get("messageID")&&e.get("success"))return window.opener.postMessage({name:"ConnectExternalAccountResponse",messageID:parseInt(e.get("messageID")),success:"true"===e.get("success")},window.location.origin),window.close(),!0}hasEmbeddedModeUrlParameter(){const e=new URLSearchParams(window.location.search);if(e.has("_e")&&"false"!==e.get("_e"))return!0}}const t=new e;window.MyDataHelps=t,window.RKStudioClient={},window.RKStudioClient.setActionResult=function(e){window.MyDataHelps.setActionResult(e)};export{e as MyDataHelps,t as default};
1
+ class e{startSurvey(e){if(this.isStandaloneMode())this.startDelegatedSurvey(`${this.baseUrl}/survey?surveyName=${encodeURIComponent(e)}`);else if(window.webkit.messageHandlers.StartParticipantSurvey){let t=this.nextMessageID();window.webkit.messageHandlers.StartParticipantSurvey.postMessage({messageID:t,surveyName:e})}}completeStep(e){if(null==e&&(e=""),"string"!=typeof e&&(e=JSON.stringify(e)),window.webkit.messageHandlers.ResearchKit)window.webkit.messageHandlers.ResearchKit.postMessage(e);else if(window.webkit.messageHandlers.CompleteStep){let t=this.nextMessageID();window.webkit.messageHandlers.CompleteStep.postMessage({messageID:t,answer:e})}}querySurveyAnswers(t){(t=Object.assign({},t)).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("stepIdentifier")&&(t.stepIdentifier=e.reduceArrayAndEscape(t.stepIdentifier)),t.hasOwnProperty("resultIdentifier")&&(t.resultIdentifier=e.reduceArrayAndEscape(t.resultIdentifier)),t.hasOwnProperty("answer")&&(t.answer=e.reduceArrayAndEscape(t.answer)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after));const n="surveyanswers?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}querySurveyResults(t){(t={...t}).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("event")&&(t.event=e.reduceArrayAndEscape(t.event)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter));const n="surveyresults?"+new URLSearchParams(t).toString();return this.connect().then((()=>this.makeRequest(n,"GET",null))).then(e.validateResponse).then((e=>e.json()))}deleteSurveyResult(t){const n="surveyresults/"+encodeURIComponent(t),s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}querySurveyTasks(t){(t=Object.assign({},t)).hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status)),t.hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName));const n="surveytasks?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryInboxItems(t){(t=((e,t)=>{for(const n of Object.keys(t)){const s=t[n];void 0!==s&&(e[n]=s)}return e})({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status));const n="inbox?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getInboxItem(t){const n=`inbox/${t}`,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}updateInboxItem(t,n){const s=`inbox/${t}/${n}`,r=this;return this.connect().then((function(){return r.makeRequest(s,"PUT",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}startEmbeddedSurvey(e,t,n){n||(n=this.getCurrentLanguage());let s=this.baseUrl+"mydatahelps/"+e+"/surveylink/"+t+"?lang="+n;return this.startEmbeddedSurveyInternal(s)}openExternalUrl(e){window.webkit.messageHandlers.OpenExternalLink&&window.webkit.messageHandlers.OpenExternalLink.postMessage(e)}openEmbeddedUrl(e){window.webkit.messageHandlers.OpenEmbeddedLink&&window.webkit.messageHandlers.OpenEmbeddedLink.postMessage(e)}showTab(e){window.webkit.messageHandlers.ShowTab&&window.webkit.messageHandlers.ShowTab.postMessage(e)}openApplication(e,t){if(window.webkit.messageHandlers.OpenExternalApplication){let n=this.nextMessageID();window.webkit.messageHandlers.OpenExternalApplication.postMessage({messageID:n,url:e,modal:!(!t||!t.modal)})}}dismiss(){window.webkit.messageHandlers.Dismiss&&window.webkit.messageHandlers.Dismiss.postMessage({})}back(){window.webkit.messageHandlers.PopNavigation&&window.webkit.messageHandlers.PopNavigation.postMessage({})}showDashboard(e,t){window.webkit.messageHandlers.ShowParticipantDashboard&&window.webkit.messageHandlers.ShowParticipantDashboard.postMessage({dashboardKey:e,modal:!(!t||!t.modal),title:t&&t.title?t.title:void 0})}showWebVisualization(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualization&&window.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({visualizationKey:e,parameters:t,modal:!(!n||!n.modal),title:n&&n.title?n.title:void 0})}showWebVisualizationPdf(e,t,n){window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF&&window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({visualizationKey:e,parameters:t,landscape:!(!n||!n.landscape),htmlViewerZoom:n&&n.htmlViewerZoom})}showProject(e){window.webkit.messageHandlers.ShowProject&&window.webkit.messageHandlers.ShowProject.postMessage({code:e})}joinProject(e){window.webkit.messageHandlers.JoinProject&&window.webkit.messageHandlers.JoinProject.postMessage({code:e})}on(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");this.registeredEventHandlers[e]||(this.registeredEventHandlers[e]=[]),this.registeredEventHandlers[e].push(t)}off(e,t){if(!this.supportedEvents.includes(e))throw new Error(e+" is not a supported event type.");if(!this.registeredEventHandlers[e])return;let n=this.registeredEventHandlers[e].indexOf(t);-1!==n&&this.registeredEventHandlers[e].splice(n,1)}triggerEvent(e){let t=e.type;this.supportedEvents.includes(t)&&this.registeredEventHandlers[t]&&this.registeredEventHandlers[t].forEach((function(t){t(e)}))}setActionResult(e){Object.prototype.hasOwnProperty.call(this.messageHandlers,e.messageID)&&"function"==typeof this.messageHandlers[e.messageID]?this.messageHandlers[e.messageID](e):console.error(`Invalid messageID: ${e.messageID}`)}getParticipantInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("participant","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistParticipantInfo(e,t){const n=this;return this.connect().then((function(){return n.makeRequest("participant","PUT",{demographics:e,customFields:t})})).then((async function(e){if(!e.ok)throw(await e.json()).message;return e.json()})).catch((function(e){console.log("Unable to persist participant: "+e)}))}getProjectInfo(){const t=this;return this.connect().then((function(){return t.makeRequest("project","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteDeviceDataPoint(t){const n="devicedata/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryDeviceData(t){(t=Object.assign({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter));const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}persistDeviceData(t){const n=this;return this.connect().then((function(){return n.makeRequest("devicedata","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryDeviceDataV2(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2Aggregate(t){(t=Object.assign({},t)).hasOwnProperty("aggregateFunctions")&&(t.aggregateFunctions=e.reduceArrayAndEscape(t.aggregateFunctions)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2DailySleep(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate/dailysleep?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataV2AllDataTypes(t){const n={};void 0!==t&&(n.enabled=t.toString());const s=`devicedata/allDataTypes?${new URLSearchParams(n).toString()}`,r=this;return this.connect().then((function(){return r.makeRequest(s,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getExternalAccountProviders(t,n,s,r){let a={};t&&(a.search=t),n&&(a.category=n),s&&(a.pageSize=s),r&&(a.pageNumber=r);const o="externalaccountproviders?"+new URLSearchParams(a).toString(),i=this;return this.connect().then((function(){return i.makeRequest(o,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}connectExternalAccount(n,s){return new Promise(((r,a)=>{const o=t.nextMessageID();if(t.messageHandlers[o]=function(e){e&&e.success?r():a(e.errorMessage)},this.standaloneMode){let t=s?.standaloneModeFinalRedirectPath||window.location.href;const r=this;let i;if(s?.openNewWindow){t=`${t.split("?")[0]}?connectExternalAccount=true&messageID=${o}&success=%SUCCESSVALUE%`;let e=null;if(s?.width&&s?.height){const t=s?.width,n=s?.height;e="width="+t+",height="+n+",top="+(window.outerHeight/2+window.screenY-n/2)+",left="+(window.outerWidth/2+window.screenX-t/2)}i=window.open(`${this.baseUrl}home/loading`,"providerauth",e)}const d=new URLSearchParams({finalRedirectPath:t}).toString(),c="externalaccountproviders/"+n+"/connect?"+d;this.connect().then((function(){return r.makeRequest(c,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.text()})).then((function(e){i?i.location=e.replace(/['"]+/g,""):window.top.location=e.replace(/['"]+/g,"")})).catch((function(e){a(e)}))}else window.webkit.messageHandlers.ConnectExternalAccount&&window.webkit.messageHandlers.ConnectExternalAccount.postMessage({externalAccountProviderID:n,messageID:o,...s})}))}getExternalAccounts(){const t=this;return this.connect().then((function(){return t.makeRequest("externalaccounts","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}refreshExternalAccount(t){const n="externalaccounts/refresh/"+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}deleteExternalAccount(t){const n="externalaccounts/delete/"+encodeURIComponent(t),s=this;return this.isStandaloneMode()?this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})):new Promise((function(e,n){if(window.webkit.messageHandlers.DeleteProviderAccount){const r=s.nextMessageID();s.messageHandlers[r]=function(t){t.success?e(t):n(t)},window.webkit.messageHandlers.DeleteProviderAccount.postMessage({messageID:r,accountID:t})}else n()}))}getFeaturedProviders(t){const n={};t&&(n.featuredProvidersContext=t);const s=`featuredexternalaccountproviders?${new URLSearchParams(n).toString()}`;return this.connect().then((()=>this.makeRequest(s,"GET",null))).then(e.validateResponse).then((e=>e.json()))}queryNotifications(t){(t=Object.assign({},t)).hasOwnProperty("sentBefore")&&(t.sentBefore=e.convertDateToIsoString(t.sentBefore)),t.hasOwnProperty("sentAfter")&&(t.sentAfter=e.convertDateToIsoString(t.sentAfter));const n="notifications?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitDailySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/dailySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryFitbitSleepLogs(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="fitbit/sleepLogs?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthActivitySummaries(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/activitySummaries?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryAppleHealthWorkouts(t){(t=Object.assign({},t)).hasOwnProperty("startDate")&&(t.startDate=e.convertDateToIsoString(t.startDate)),t.hasOwnProperty("endDate")&&(t.endDate=e.convertDateToIsoString(t.endDate));const n="appleHealth/workouts?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}uploadFile(t,n,s){if(t.size>209715200)throw new Error("File size exceeds the maximum allowed size of 200MB.");const r=this,a="files?category="+n+"&fileName="+encodeURIComponent(s??t.name);return this.connect().then((function(){return r.makeRequest(a,"POST",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()})).then((function(e){return fetch(e.preSignedUrl,{method:"PUT",body:t,headers:{"Content-Type":t.type,"x-amz-server-side-encryption":"AES256"}})})).then((function(t){return e.validateResponse(t)})).then((function(){}))}queryFiles(t){const n="files?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getFileDownloadUrl(t){if(!t)throw new Error("Please specify the key of the file to download.");const n="files/download?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}deleteFile(t){if(!t)throw new Error("Please specify the key of the file to delete.");const n="files?key="+t,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}connect(){const e=this;let t=function(){e.token=null,e.refreshTokenPromise=new Promise((function(n,s){let r=e.nextMessageID();e.messageHandlers[r]=function(a){a.success?(e.tokenExpires=Date.now()+1e3*a.data.expires_in,e.token=a.data,e.baseUrl=a.baseUrl,setTimeout(t,1e3*(a.data.expires_in-e.accessTokenRenewalBufferSeconds)),n(null)):(e.token=null,s(a.message)),e.messageHandlers[r]=null,e.refreshTokenPromise=null},window.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({messageID:r})}))};if(this.token&&Date.now()<this.tokenExpires)return Promise.resolve();if(this.isStandaloneMode()&&!this.isEmbeddedMode()){let e=this.token?"access token is expired or invalid":"access token must be explicitly provided using the setParticipantAccess method";return console.log(e),Promise.reject(e)}return this.refreshTokenPromise||t(),this.refreshTokenPromise}setParticipantAccessToken(e,t){this.enableStandaloneMode(),this.token=e,t&&(this.baseUrl=t),this.tokenExpires=Date.now()+1e3*this.token.expires_in;const n=this;setTimeout((function(){n.triggerEvent({type:"tokenWillExpire"})}),1e3*(this.token.expires_in-this.accessTokenRenewalBufferSeconds))}isStandaloneMode(){return this.standaloneMode}isEmbeddedMode(){return this.embeddedMode}enableStandaloneMode(e=!1,t){this.standaloneMode=!0,this.embeddedMode=e,t&&(this.baseUrl=t),window.webkit&&(window.webkit.messageHandlers=e?{GetDelegatedAccessToken:window.webkit.messageHandlers.GetDelegatedAccessToken,OpenExternalLink:window.webkit.messageHandlers.OpenExternalLink,OpenEmbeddedLink:window.webkit.messageHandlers.OpenEmbeddedLink,OpenExternalApplication:window.webkit.messageHandlers.OpenExternalApplication,PopNavigation:window.webkit.messageHandlers.PopNavigation,Dismiss:window.webkit.messageHandlers.Dismiss}:{})}setStatusBarStyle(e){window.webkit.messageHandlers.SetStatusBarStyle&&window.webkit.messageHandlers.SetStatusBarStyle.postMessage({style:e})}getDeviceInfo(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetDeviceInfo){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetDeviceInfo.postMessage({messageID:n})}else n()}))}setSupportedLanguages(e){this.supportedLanguages.length=0;for(let t=0;t<e.length;t++)this.supportedLanguages.push(e[t].replace("_","-"))}getStepConfiguration(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetStepConfiguration){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetStepConfiguration.postMessage({messageID:n})}else n()}))}getSurveyContext(){let e=this;return new Promise((function(t,n){e.isStandaloneMode()&&t(null),e.getDeviceInfo().then((function(s){if("Web"!==s.platform)t({surveyMode:"Survey"});else if(window.webkit.messageHandlers.GetSurveyContext){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetSurveyContext.postMessage({messageID:n})}else n()})).catch((function(e){n()}))}))}getCurrentSurveyAnswers(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.GetCurrentSurveyAnswers){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({messageID:n})}else n()}))}setCurrentLanguage(e){if(e){let t=this.getSupportedLanguage(e);t?this.language=t:console.warn(`language ${e} not supported`)}else this.language=e}getCurrentLanguage(){let e,t=new URLSearchParams(window.location.search);if(t.has("lang")){if(e=this.getSupportedLanguage(t.get("lang")),e)return e;console.warn(`language ${t.get("lang")} not supported`)}return this.language||navigator.language}showGoogleFitSettings(){window.webkit.messageHandlers.ShowGoogleFitSettings&&window.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({})}showHealthConnectSettings(){window.webkit.messageHandlers.HealthConnectSettings&&window.webkit.messageHandlers.HealthConnectSettings.postMessage({})}showHealthConnectPrompt(){window.webkit.messageHandlers.HealthConnectPrompt&&window.webkit.messageHandlers.HealthConnectPrompt.postMessage({})}getHealthConnectStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectStatus.postMessage({messageID:n})}else n()}))}showHealthConnectPhrPrompt(){window.webkit.messageHandlers.HealthConnectPhrPrompt&&window.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({})}getHealthConnectPhrStatus(){let e=this;return new Promise((function(t,n){if(e.isStandaloneMode())t(null);else if(window.webkit.messageHandlers.HealthConnectPhrStatus){let n=e.nextMessageID();e.messageHandlers[n]=function(e){t(e.data)},window.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({messageID:n})}else n()}))}requestReview(e){window.webkit.messageHandlers.RequestReview&&window.webkit.messageHandlers.RequestReview.postMessage({cooldownDays:e})}trackCustomEvent(t){const n=this;return this.connect().then((function(){return n.makeRequest("customevents","POST",t)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}getDataCollectionSettings(){const t=this;return this.connect().then((function(){return t.makeRequest("datacollectionsettings","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDataAvailability(){const t=this;return this.connect().then((function(){return t.makeRequest("dataavailability","GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}invokeCustomApi(t,n,s,r){if(t.includes("?"))throw new Error('Cannot include query parameters directly in the "customApi" string. Provide as an argument for "queryParameters" instead.');let a="custom/"+t;if(n=n.toUpperCase(),null!=s&&("GET"===n||"DELETE"===n)){let e=new URLSearchParams(s).toString();a+="?"+e,s=null}const o=this;return this.connect().then((function(){return o.makeRequest(a,n,s)})).then((function(t){return e.validateResponse(t)})).then((function(e){return r?e.json():void 0}))}constructor(){if(this.baseUrl="https://mydatahelps.org/",this.acceptableParentDomains=["localhost","careevolution.com","internal","b3-deploys.com","mydatahelps.org","platform.joinallofus.org","careevolution.dev","ce.dev","mydatahelps.dev"],this.accessTokenRenewalBufferSeconds=120,this.unsupportedActions=["SetHeight","ResearchKit"],this.supportedEvents=["surveyDidFinish","applicationDidBecomeVisible","externalAccountSyncComplete","tokenWillExpire","healthConnectSyncComplete","healthConnectPhrSyncComplete"],this.supportedLanguages=[],this.currentMessageID=1,this.messageHandlers=[],this.registeredEventHandlers={},this.refreshTokenPromise=null,this.standaloneMode=!1,this.embeddedMode=!1,this.handleConnectExternalAccountResponse())return;let e,t=this,n=function(){let e=document.location.ancestorOrigins;if(e&&e[0])return e[0];return"*"}();function s(e){if("*"===e)return!0;let n=new URL(e);for(let e=0;e<t.acceptableParentDomains.length;e++)if(n.hostname===t.acceptableParentDomains[e]||n.hostname.endsWith("."+t.acceptableParentDomains[e]))return!0;return!1}s(n)||console.log("Detected unsupported parent origin domain."),e=window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.ResearchKit?{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},GetSurveyContext:function(e){window.parent.postMessage({name:"GetSurveyContext",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}}:{GetDelegatedAccessToken:function(e){window.parent.postMessage({name:"GetDelegatedAccessToken",messageID:e.messageID},n)},GetDeviceInfo:function(e){window.parent.postMessage({name:"GetDeviceInfo",messageID:e.messageID},n)},StartParticipantSurvey:function(e){window.parent.postMessage({name:"StartParticipantSurvey",messageID:e.messageID,surveyName:e.surveyName},n)},OpenExternalLink:function(e){window.parent.postMessage({name:"OpenExternalUrl",url:e},n)},OpenEmbeddedLink:function(e){window.parent.postMessage({name:"OpenEmbeddedUrl",url:e},n)},OpenExternalApplication:function(e){window.parent.postMessage({name:"OpenApplication",messageID:e.messageID,url:e.url,modal:e.modal},n)},Dismiss:function(){window.parent.postMessage({name:"Dismiss"},n)},PopNavigation:function(){window.parent.postMessage({name:"Back"},n)},ShowTab:function(e){window.parent.postMessage({name:"ShowTab",tabKey:e},n)},ShowParticipantDashboard:function(e){window.parent.postMessage({name:"ShowParticipantDashboard",dashboardKey:e.dashboardKey,modal:e.modal},n)},ShowParticipantWebVisualization:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualization",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal},n)},ShowParticipantWebVisualizationPDF:function(e){window.parent.postMessage({name:"ShowParticipantWebVisualizationPDF",visualizationKey:e.visualizationKey,parameters:e.parameters,modal:e.modal,landscape:e.landscape,htmlViewerZoom:e.htmlViewerZoom},n)},DeleteProviderAccount:function(e){window.parent.postMessage({name:"DeleteProviderAccount",messageID:e.messageID,accountID:e.accountID},n)},ConnectExternalAccount:function(e){window.parent.postMessage({name:"ConnectExternalAccount",externalAccountProviderID:e.externalAccountProviderID,messageID:e.messageID,openNewWindow:e.openNewWindow,width:e.width,height:e.height},n)},ShowProject:function(e){window.parent.postMessage({name:"ShowProject",code:e.code},n)},JoinProject:function(e){window.parent.postMessage({name:"JoinProject",code:e.code},n)},GetCurrentSurveyAnswers:function(e){window.parent.postMessage({name:"GetCurrentSurveyAnswers",messageID:e.messageID},n)},GetStepConfiguration:function(e){window.parent.postMessage({name:"GetStepConfiguration",messageID:e.messageID},n)},CompleteStep:function(e){window.parent.postMessage({name:"CompleteStep",messageID:e.messageID,answer:e.answer},n)}},window.webkit&&window.webkit.messageHandlers&&function(){for(let t in e)if(window.webkit.messageHandlers[t])return!0;for(let e in t.unsupportedActions)if(window.webkit.messageHandlers[t.unsupportedActions[e]])return!0;return!1}()||(window.webkit={messageHandlers:{}}),function(e){for(let t in e)if(!window.webkit.messageHandlers[t])try{window.webkit.messageHandlers[t]={postMessage:e[t]}}catch(e){return void console.log("Unable to add missing actions on this platform: "+e)}}(e),window.addEventListener("message",(function(e){if(!function(e){return!(!t.isStandaloneMode()||e.origin!==window.location.origin)||("*"===n?s(e.origin):e.origin===n)}(e))throw console.error("message.origin '"+e.origin+"' is not allowed."),"message.origin '"+e.origin+"' is not allowed.";e.data.messageID?t.setActionResult(e.data):t.triggerEvent(e.data)}),!1),this.hasEmbeddedModeUrlParameter()&&t.enableStandaloneMode(!0)}nextMessageID(){return this.currentMessageID++}makeUrl(e,t){if(!this.baseUrl)throw console.error("Cannot use makeUrl without MyDataHelps.baseUrl."),"Cannot use makeUrl without MyDataHelps.baseUrl.";return this.baseUrl+"api/"+t+"/delegated/"+e}makeRequest(e,t,n,s="v1"){if(!this.token||!this.token.access_token)throw"No access_token available for request authorization.";let r=this.makeUrl(e,s),a=new Headers;a.append("Authorization","Bearer "+this.token.access_token),a.append("Accept","application/json, text/javascript, */*; q=0.01"),a.append("Accept-Language",this.getCurrentLanguage()),n&&a.append("Content-Type","application/json");let o={method:t,headers:a};return n&&(o.body=JSON.stringify(n)),fetch(r,o)}getSupportedLanguage(e){return e=e.replace("_","-"),0===this.supportedLanguages.length||this.supportedLanguages.find((t=>t===e))||e.indexOf("-")>0&&(e=e.substring(0,e.indexOf("-")),this.supportedLanguages.find((t=>t===e)))?e:void 0}static validateResponse(e){if(!e.ok)throw e.statusText;return e}static escapeParam(e){return String(e).replaceAll("\\","\\\\").replaceAll(",","\\,")}static reduceArrayAndEscape(t){if(Array.isArray(t)){return t.map((function(t){return e.escapeParam(t)})).join(",")}return this.escapeParam(t)}static convertDateToIsoString(e){let t=new Date(e);if(isNaN(t.getTime()))throw"Cannot interpret parameter as Date";return t.toISOString()}static flattenPropertyShallow(t,n){if(void 0!==t[n]&&null!==t[n]){for(var s in t[n])t[n].hasOwnProperty(s)&&(t[`${n}.${s}`]=e.escapeParam(t[n][s]));delete t[n]}}startEmbeddedSurveyInternal(e){let t="mydatahelps-survey-modal",n=this;return new Promise((function(s,r){if(document.getElementById(t))return void r("Survey already in progress");window.addEventListener("message",(function e(r){if(r.origin!==new URL(n.baseUrl).origin)return;let a=document.getElementById("mydatahelps-survey-frame").contentWindow;r.source===a&&("SurveyWindowInitialized"===r.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===r.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s(r.data)))}),!0);let a=document.createElement("div");a.className="mydatahelps-survey-modal",a.id=t,a.innerHTML="<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='"+e+"'></iframe></div>",document.body.append(a),document.body.className+=" no-scroll"}))}startDelegatedSurvey(e){let t="mydatahelps-survey-modal",n=this;if(document.getElementById(t))return;window.addEventListener("message",(function e(s){if(s.origin!==new URL(n.baseUrl).origin)return;let r=document.getElementById("mydatahelps-survey-frame").contentWindow;s.source===r&&("GetDelegatedAccessToken"===s.data.name?n.getParticipantInfo().then((e=>{r.postMessage({name:"DelegatedAccessTokenResponse",accessToken:n.token,baseUrl:n.baseUrl,participantID:e.participantID},"*")})):"SurveyWindowInitialized"===s.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===s.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s.data.type="surveyDidFinish",n.triggerEvent(s.data)))}),!0);let s=document.createElement("div");s.className="mydatahelps-survey-modal",s.id=t,s.innerHTML=`<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${e}&lang=${n.getCurrentLanguage()}'></iframe></div>`,document.body.append(s),document.body.className+=" no-scroll"}handleConnectExternalAccountResponse(){const e=new URLSearchParams(window.location.search);if(window.opener&&e.get("connectExternalAccount")&&e.get("messageID")&&e.get("success"))return window.opener.postMessage({name:"ConnectExternalAccountResponse",messageID:parseInt(e.get("messageID")),success:"true"===e.get("success")},window.location.origin),window.close(),!0}hasEmbeddedModeUrlParameter(){const e=new URLSearchParams(window.location.search);if(e.has("_e")&&"false"!==e.get("_e"))return!0}}const t=new e;window.MyDataHelps=t,window.RKStudioClient={},window.RKStudioClient.setActionResult=function(e){window.MyDataHelps.setActionResult(e)};export{e as MyDataHelps,t as default};
2
2
  //# sourceMappingURL=MyDataHelps.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MyDataHelps.min.js","sources":["../../src/MyDataHelps.ts"],"sourcesContent":["// @ts-ignore : let rollup handle CSS injection\nimport \"../MyDataHelps.css\";\n\nimport * as Model from \"./types\";\nimport { StringMap } from \"./types\";\n\nexport class MyDataHelps {\n\n\tbaseUrl: string = 'https://mydatahelps.org/';\n\tlanguage: string;\n\ttoken: Model.Token;\n\ttokenExpires: number;\n\n\t// Surveys\n\n\tstartSurvey(surveyName: string): void {\n\t\tif (this.isStandaloneMode()) {\n\t\t\tthis.startDelegatedSurvey(`${this.baseUrl}/survey?surveyName=${encodeURIComponent(surveyName)}`);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.StartParticipantSurvey) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.StartParticipantSurvey.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tsurveyName: surveyName\n\t\t\t});\n\t\t}\n\t}\n\n\tcompleteStep(answer: any): void {\n\t\tif (answer === undefined || answer === null) answer = '';\n\t\tif (typeof answer !== 'string') {\n\t\t\tanswer = JSON.stringify(answer);\n\t\t}\n\t\tif (window.webkit.messageHandlers.ResearchKit) {\n\t\t\twindow.webkit.messageHandlers.ResearchKit.postMessage(answer);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.CompleteStep) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.CompleteStep.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tanswer: answer\n\t\t\t});\n\t\t}\n\t}\n\n\tquerySurveyAnswers(queryParameters: Model.SurveyAnswersQuery): Promise<Model.SurveyAnswersPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"stepIdentifier\")) {\n\t\t\tqueryParameters.stepIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.stepIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"resultIdentifier\")) {\n\t\t\tqueryParameters.resultIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.resultIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"answer\")) {\n\t\t\tqueryParameters.answer = MyDataHelps.reduceArrayAndEscape(queryParameters.answer);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyanswers?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tquerySurveyResults(queryParameters: Model.SurveyResultsQuery): Promise<Model.SurveyResultsPage> {\n\t\tqueryParameters = { ...queryParameters }\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"event\")) {\n\t\t\tqueryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyresults?' + queryString;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\tdeleteSurveyResult(resultID: string): Promise<void> {\n\t\tconst endpoint = 'surveyresults/' + encodeURIComponent(resultID);\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tquerySurveyTasks(queryParameters: Model.SurveyTaskQueryParameters): Promise<Model.SurveyTasksPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.SurveyTaskStatus;\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveytasks?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryInboxItems(queryParameters: Model.InboxItemQueryParameters): Promise<Model.InboxItemsPage> {\n\t\tconst assignDefined = (target: any, source: any): any => {\n\t\t\tfor (const key of Object.keys(source)) {\n\t\t\t\tconst value = source[key];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\ttarget[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tqueryParameters = assignDefined({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type) as Model.InboxItemType;\n\t\t}\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.InboxItemStatus;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'inbox?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetInboxItem(id: Model.Guid): Promise<Model.InboxItem> {\n\t\tconst endpoint = `inbox/${id}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tupdateInboxItem(id: Model.Guid, update: Model.InboxItemUpdate): Promise<Model.InboxItemUpdateResult> {\n\t\tconst endpoint = `inbox/${id}/${update}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tstartEmbeddedSurvey(linkIdentifier: string, surveyName: string, language: string): Promise<any> {\n\t\tif (!language) {\n\t\t\tlanguage = this.getCurrentLanguage();\n\t\t}\n\t\tlet surveyUrl = this.baseUrl + \"mydatahelps/\" + linkIdentifier + '/surveylink/' + surveyName + \"?lang=\" + language;\n\t\treturn this.startEmbeddedSurveyInternal(surveyUrl);\n\t}\n\n\t// Navigation\n\n\topenExternalUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalLink) {\n\t\t\twindow.webkit.messageHandlers.OpenExternalLink.postMessage(url);\n\t\t}\n\t}\n\n\topenEmbeddedUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenEmbeddedLink) {\n\t\t\twindow.webkit.messageHandlers.OpenEmbeddedLink.postMessage(url);\n\t\t}\n\t}\n\n\tshowTab(tabKey: string): void {\n\t\tif (window.webkit.messageHandlers.ShowTab) {\n\t\t\twindow.webkit.messageHandlers.ShowTab.postMessage(tabKey);\n\t\t}\n\t}\n\n\topenApplication(url: string, options?: Model.OpenApplicationOptions): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalApplication) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.OpenExternalApplication.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\turl: url,\n\t\t\t\tmodal: !!(options && options.modal)\n\t\t\t});\n\t\t}\n\t}\n\n\tdismiss(): void {\n\t\tif (window.webkit.messageHandlers.Dismiss) {\n\t\t\twindow.webkit.messageHandlers.Dismiss.postMessage({});\n\t\t}\n\t}\n\n\tback(): void {\n\t\tif (window.webkit.messageHandlers.PopNavigation) {\n\t\t\twindow.webkit.messageHandlers.PopNavigation.postMessage({});\n\t\t}\n\t}\n\n\tshowDashboard(dashboardKey: string, options?: Model.ShowDashboardOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantDashboard) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantDashboard.postMessage({\n\t\t\t\tdashboardKey: dashboardKey,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualization(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualization) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualizationPdf(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationPdfOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tlandscape: !!(options && options.landscape),\n\t\t\t\thtmlViewerZoom: options && options.htmlViewerZoom\n\t\t\t});\n\t\t}\n\t}\n\n\tshowProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.ShowProject) {\n\t\t\twindow.webkit.messageHandlers.ShowProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\tjoinProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.JoinProject) {\n\t\t\twindow.webkit.messageHandlers.JoinProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\t//Events\n\n\ton(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName] = [];\n\t\t}\n\n\t\tthis.registeredEventHandlers[eventName].push(callback);\n\t}\n\n\toff(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) return;\n\n\t\tlet eventHandlerIndex = this.registeredEventHandlers[eventName].indexOf(callback);\n\n\t\tif (eventHandlerIndex !== -1) {\n\t\t\tthis.registeredEventHandlers[eventName].splice(eventHandlerIndex, 1);\n\t\t}\n\t}\n\n\ttriggerEvent(event: Model.EventData): void {\n\t\tlet eventName = event.type;\n\t\tif (this.supportedEvents.includes(eventName) && this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName].forEach(function (handler) {\n\t\t\t\thandler(event);\n\t\t\t});\n\t\t}\n\t}\n\n\tsetActionResult(data: Model.EventData): void {\n\t\tif (Object.prototype.hasOwnProperty.call(this.messageHandlers, data.messageID) &&\n\t\t\ttypeof this.messageHandlers[data.messageID] === 'function') {\n\t\t\tthis.messageHandlers[data.messageID](data);\n\t\t} else {\n\t\t\tconsole.error(`Invalid messageID: ${data.messageID}`);\n\t\t}\n\t}\n\n\t// Participant Info\n\n\tgetParticipantInfo(): Promise<Model.ParticipantInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'participant';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistParticipantInfo(demographics: Partial<Model.ParticipantDemographics> | undefined, customFields: StringMap): Promise<Model.ParticipantInfo> {\n\t\tconst endpoint = 'participant';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', { demographics, customFields });\n\t\t\t})\n\t\t\t.then(async function (response) {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tvar errorJson = await response.json();\n\t\t\t\t\tthrow errorJson.message;\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.log(\"Unable to persist participant: \" + error);\n\t\t\t});\n\t}\n\n\tgetProjectInfo(): Promise<Model.ProjectInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'project';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Device Data\n\n\tgetDeviceDataPoint(id: Model.Guid): Promise<Model.DeviceDataPoint> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteDeviceDataPoint(id: Model.Guid): Promise<void> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryDeviceData(queryParameters: Model.DeviceDataPointQuery): Promise<Model.DeviceDataPointsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistDeviceData(deviceDataPoints: Model.PersistableDeviceDataPoint[]): Promise<void> {\n\t\tconst endpoint = 'devicedata';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', deviceDataPoints);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Device Data V2\n\n\tqueryDeviceDataV2(queryParameters: Model.DeviceDataV2Query): Promise<Model.DeviceDataV2Page> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2Aggregate(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2AggregatePage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"aggregateFunctions\")) {\n\t\t\tqueryParameters.aggregateFunctions = MyDataHelps.reduceArrayAndEscape(queryParameters.aggregateFunctions);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2DailySleep(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2DailySleepPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate/dailysleep?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDeviceDataV2AllDataTypes(enabled?: boolean): Promise<Model.SupportedDeviceDataV2DataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// External Accounts\n\n\tgetExternalAccountProviders(search: string | null, category: string | null, pageSize: number, pageNumber: number): Promise<Model.ExternalAccountProvidersPage> {\n\t\tlet searchParameters: any = {};\n\t\tif (!!search) searchParameters.search = search;\n\t\tif (!!category) searchParameters.category = category;\n\t\tif (!!pageSize) searchParameters.pageSize = pageSize;\n\t\tif (!!pageNumber) searchParameters.pageNumber = pageNumber;\n\n\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\tconst endpoint = 'externalaccountproviders?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tconnectExternalAccount(externalAccountProviderID: number, options?: Model.ConnectExternalAccountOptions): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\n\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\tmdh.messageHandlers[messageID] = function (connectProviderAccountResponse) {\n\t\t\t\tif (connectProviderAccountResponse && connectProviderAccountResponse.success) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject(connectProviderAccountResponse.errorMessage)\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (this.standaloneMode) {\n\t\t\t\tlet standaloneModeFinalRedirectPath = options?.standaloneModeFinalRedirectPath || window.location.href;\n\t\t\t\tconst mdh = this;\n\n\t\t\t\t// DEV: Safari blocks popups in AJAX responses. Work-around is to open a blank window before the request and set the URL later\n\t\t\t\tlet providerAuthWindow;\n\t\t\t\tif (options?.openNewWindow) {\n\t\t\t\t\tstandaloneModeFinalRedirectPath = `${standaloneModeFinalRedirectPath.split('?')[0]}?connectExternalAccount=true&messageID=${messageID}&success=%SUCCESSVALUE%`;\n\t\t\t\t\tlet windowFeatures = null;\n\t\t\t\t\tif (options?.width && options?.height) {\n\t\t\t\t\t\tconst w = options?.width;\n\t\t\t\t\t\tconst h = options?.height;\n\t\t\t\t\t\tconst y = window.outerHeight / 2 + window.screenY - (h / 2);\n\t\t\t\t\t\tconst x = window.outerWidth / 2 + window.screenX - (w / 2);\n\t\t\t\t\t\twindowFeatures = \"width=\" + w + \",height=\" + h + \",top=\" + y + \",left=\" + x;\n\t\t\t\t\t}\n\t\t\t\t\tproviderAuthWindow = window.open(`${this.baseUrl}home/loading`, 'providerauth', windowFeatures);\n\t\t\t\t}\n\n\t\t\t\tconst searchParameters = { finalRedirectPath: standaloneModeFinalRedirectPath };\n\t\t\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\t\t\tconst endpoint = \"externalaccountproviders/\" + externalAccountProviderID + \"/connect?\" + queryString;\n\n\t\t\t\tthis\n\t\t\t\t\t.connect()\n\t\t\t\t\t.then(function () {\n\t\t\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn response.text();\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (redirectUrl) {\n\t\t\t\t\t\tif (providerAuthWindow) {\n\t\t\t\t\t\t\tproviderAuthWindow.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twindow.top.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function (error) {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t});\n\t\t\t} else if (window.webkit.messageHandlers.ConnectExternalAccount) {\n\t\t\t\twindow.webkit.messageHandlers.ConnectExternalAccount.postMessage({\n\t\t\t\t\texternalAccountProviderID: externalAccountProviderID,\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tgetExternalAccounts(): Promise<Model.ExternalAccount[]> {\n\t\tconst endpoint = 'externalaccounts';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\trefreshExternalAccount(accountID: number): Promise<void> {\n\t\tconst endpoint = 'externalaccounts/refresh/' + accountID;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tdeleteExternalAccount(accountID: number): Promise<any> {\n\t\tconst endpoint = 'externalaccounts/delete/' + encodeURIComponent(accountID);\n\t\tconst mdh = this;\n\n\t\tif (this.isStandaloneMode()) {\n\t\t\treturn this\n\t\t\t\t.connect()\n\t\t\t\t.then(function () {\n\t\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t\t})\n\t\t\t\t.then(function (response) {\n\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t});\n\t\t}\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (window.webkit.messageHandlers.DeleteProviderAccount) {\n\t\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deleteProviderAccountResponse) {\n\t\t\t\t\tif (!deleteProviderAccountResponse.success) {\n\t\t\t\t\t\treject(deleteProviderAccountResponse)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(deleteProviderAccountResponse);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.DeleteProviderAccount.postMessage({\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\taccountID: accountID\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetFeaturedProviders(context?: string): Promise<Model.ExternalAccountProvider[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (context !== undefined) {\n\t\t\tqueryParameters['featuredProvidersContext'] = context;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `featuredexternalaccountproviders?${queryString}`;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\t// Notifications\n\n\tqueryNotifications(queryParameters: Model.NotificationQueryParameters): Promise<Model.NotificationsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"sentBefore\")) {\n\t\t\tqueryParameters.sentBefore = MyDataHelps.convertDateToIsoString(queryParameters.sentBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"sentAfter\")) {\n\t\t\tqueryParameters.sentAfter = MyDataHelps.convertDateToIsoString(queryParameters.sentAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'notifications?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Fitbit\n\n\tqueryFitbitDailySummaries(queryParameters: Model.FitbitQuery): Promise<Model.FitbitDailySummariesPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/dailySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryFitbitSleepLogs(queryParameters: Model.FitbitQuery): Promise<Model.FitbitSleepLogsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/sleepLogs?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// AppleHealth\n\n\tqueryAppleHealthActivitySummaries(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthActivitySummaryPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/activitySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryAppleHealthWorkouts(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthWorkoutPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/workouts?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Files\n\n\tuploadFile(file: File, category: string, fileName?: string): Promise<void> {\n\n\t\tif (file.size > 200 * 1024 * 1024) {\n\t\t\tthrow new Error(\"File size exceeds the maximum allowed size of 200MB.\");\n\t\t}\n\n\t\tconst mdh = this;\n\t\tconst endpoint = 'files?category=' + category + '&fileName=' + encodeURIComponent(fileName ?? file.name);\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.then(function (json) {\n\t\t\t\treturn fetch(json.preSignedUrl, {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\tbody: file,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': file.type,\n\t\t\t\t\t\t'x-amz-server-side-encryption': 'AES256'\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryFiles(queryParameters: Model.UploadedFileQuery): Promise<Model.UploadedFilesPage> {\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'files?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetFileDownloadUrl(key: string): Promise<Model.DownloadedFile> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to download.\");\n\n\t\tconst endpoint = 'files/download?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteFile(key: string): Promise<void> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to delete.\");\n\n\t\tconst endpoint = 'files?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Authorization\n\n\tconnect(): Promise<void> {\n\t\tconst mdh = this;\n\t\tlet refreshDelegatedAccessToken = function () {\n\t\t\tmdh.token = null;\n\n\t\t\tmdh.refreshTokenPromise = new Promise(function (resolve, reject) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (tokenResponse) {\n\t\t\t\t\tif (tokenResponse.success) {\n\t\t\t\t\t\tmdh.tokenExpires = Date.now() + (tokenResponse.data.expires_in * 1000);\n\t\t\t\t\t\tmdh.token = tokenResponse.data;\n\t\t\t\t\t\tmdh.baseUrl = tokenResponse.baseUrl;\n\t\t\t\t\t\tsetTimeout(refreshDelegatedAccessToken, ((tokenResponse.data.expires_in - mdh.accessTokenRenewalBufferSeconds) * 1000));\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmdh.token = null;\n\t\t\t\t\t\treject(tokenResponse.message);\n\t\t\t\t\t}\n\t\t\t\t\tmdh.messageHandlers[messageID] = null;\n\t\t\t\t\tmdh.refreshTokenPromise = null;\n\t\t\t\t};\n\n\t\t\t\twindow.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({ messageID: messageID });\n\t\t\t});\n\t\t};\n\n\t\tif (this.token && Date.now() < this.tokenExpires) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\tif (this.isStandaloneMode() && !this.isEmbeddedMode()) {\n\t\t\tlet error = this.token ? \"access token is expired or invalid\" : \"access token must be explicitly provided using the setParticipantAccess method\";\n\t\t\tconsole.log(error);\n\t\t\treturn Promise.reject(error);\n\t\t}\n\n\t\tif (!this.refreshTokenPromise) {\n\t\t\trefreshDelegatedAccessToken();\n\t\t}\n\n\t\t// Re-use promise if refresh already in progress\n\t\treturn this.refreshTokenPromise;\n\t}\n\n\tsetParticipantAccessToken(token: Model.Token, baseUrl?: string): void {\n\t\tthis.enableStandaloneMode();\n\t\tthis.token = token;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tthis.tokenExpires = Date.now() + (this.token.expires_in * 1000);\n\t\tconst mdh = this;\n\t\tsetTimeout(function () {\n\t\t\tmdh.triggerEvent({ type: \"tokenWillExpire\" });\n\t\t}, ((this.token.expires_in - this.accessTokenRenewalBufferSeconds) * 1000));\n\t}\n\n\t// Miscellaneous\n\n\tisStandaloneMode() {\n\t\treturn this.standaloneMode;\n\t}\n\n\tisEmbeddedMode() {\n\t\treturn this.embeddedMode;\n\t}\n\n\tenableStandaloneMode(embeddedMode: boolean = false, baseUrl?: string) {\n\t\tthis.standaloneMode = true;\n\t\tthis.embeddedMode = embeddedMode;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tif (window.webkit) {\n\t\t\twindow.webkit.messageHandlers = embeddedMode ? {\n\t\t\t\tGetDelegatedAccessToken: window.webkit.messageHandlers.GetDelegatedAccessToken,\n\t\t\t\tOpenExternalLink: window.webkit.messageHandlers.OpenExternalLink,\n\t\t\t\tOpenEmbeddedLink: window.webkit.messageHandlers.OpenEmbeddedLink,\n\t\t\t\tOpenExternalApplication: window.webkit.messageHandlers.OpenExternalApplication,\n\t\t\t\tPopNavigation: window.webkit.messageHandlers.PopNavigation,\n\t\t\t\tDismiss: window.webkit.messageHandlers.Dismiss,\n\t\t\t} : {};\n\t\t}\n\t}\n\n\tsetStatusBarStyle(style: Model.StatusBarStyle): void {\n\t\tif (window.webkit.messageHandlers.SetStatusBarStyle) {\n\t\t\twindow.webkit.messageHandlers.SetStatusBarStyle.postMessage({ style: style });\n\t\t}\n\t}\n\n\tgetDeviceInfo(): Promise<Model.DeviceInfo> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.DeviceInfo>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetDeviceInfo) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deviceInfoResponse) {\n\t\t\t\t\tresolve(deviceInfoResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetDeviceInfo.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetSupportedLanguages(languages: string[]) {\n\t\tthis.supportedLanguages.length = 0;\n\t\tfor (let i = 0; i < languages.length; i++) {\n\t\t\tthis.supportedLanguages.push(languages[i].replace(\"_\", \"-\"));\n\t\t}\n\t}\n\n\tgetStepConfiguration(): Promise<Model.StepConfiguration> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.StepConfiguration>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetStepConfiguration) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (stepConfigurationResponse) {\n\t\t\t\t\tresolve(stepConfigurationResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetStepConfiguration.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetSurveyContext(): Promise<Model.SurveyContext> {\n\t\tlet mdh = this;\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t}\n\t\t\tmdh.getDeviceInfo().then(function (deviceInfo) {\n\t\t\t\tif (deviceInfo.platform !== \"Web\") {\n\t\t\t\t\tresolve({ surveyMode: \"Survey\" });\n\t\t\t\t}\n\t\t\t\telse if (window.webkit.messageHandlers.GetSurveyContext) {\n\t\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\t\tmdh.messageHandlers[messageID] = function (surveyContextResponse) {\n\t\t\t\t\t\tresolve(surveyContextResponse.data);\n\t\t\t\t\t};\n\t\t\t\t\twindow.webkit.messageHandlers.GetSurveyContext.postMessage({ messageID: messageID });\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treject();\n\t\t\t\t}\n\t\t\t}).catch(function (error) {\n\t\t\t\treject();\n\t\t\t});\n\t\t});\n\t}\n\n\tgetCurrentSurveyAnswers(): Promise<Model.CurrentSurveyAnswer[]> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.CurrentSurveyAnswer[]>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetCurrentSurveyAnswers) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (currentSurveyAnswersResponse) {\n\t\t\t\t\tresolve(currentSurveyAnswersResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetCurrentLanguage(language: string) {\n\t\tif (language) {\n\t\t\tlet supportedLanguage = this.getSupportedLanguage(language);\n\t\t\tif (supportedLanguage) {\n\t\t\t\tthis.language = supportedLanguage;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${language} not supported`);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.language = language;\n\t\t}\n\t}\n\n\tgetCurrentLanguage(): string {\n\t\tlet searchParams = new URLSearchParams(window.location.search);\n\t\tlet lang;\n\t\tif (searchParams.has(\"lang\")) {\n\t\t\tlang = this.getSupportedLanguage(searchParams.get(\"lang\"));\n\t\t\tif (lang) {\n\t\t\t\treturn lang;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${searchParams.get(\"lang\")} not supported`);\n\t\t\t}\n\t\t}\n\t\treturn this.language || navigator.language;\n\t}\n\n\tshowGoogleFitSettings(): void {\n\t\tif (window.webkit.messageHandlers.ShowGoogleFitSettings) {\n\t\t\twindow.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectSettings(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectSettings) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectStatus(): Promise<Model.HealthConnectStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tshowHealthConnectPhrPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPhrPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectPhrStatus(): Promise<Model.HealthConnectPhrStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectPhrStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectPhrStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\trequestReview(cooldownDays?: number): void {\n\t\tif (window.webkit.messageHandlers.RequestReview) {\n\t\t\twindow.webkit.messageHandlers.RequestReview.postMessage({ cooldownDays: cooldownDays });\n\t\t}\n\t}\n\n\ttrackCustomEvent(event: Model.CustomEventInfo): Promise<void> {\n\t\tconst endpoint = 'customevents';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', event);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tgetDataCollectionSettings(): Promise<Model.DataCollectionSettings> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'datacollectionsettings';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDataAvailability(): Promise<Model.DataAvailability> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'dataavailability';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tinvokeCustomApi(customApi: string, method: string, queryParameters: string | string[][] | Record<string, string> | URLSearchParams | null | undefined, jsonResponse: boolean): Promise<any> {\n\t\tif (customApi.includes('?')) {\n\t\t\tthrow new Error(\"Cannot include query parameters directly in the \\\"customApi\\\" string. Provide as an argument for \\\"queryParameters\\\" instead.\");\n\t\t}\n\n\t\tlet endpoint = 'custom/' + customApi;\n\t\tmethod = method.toUpperCase();\n\t\tif (queryParameters !== null && queryParameters !== undefined && (method === 'GET' || method === 'DELETE')) {\n\t\t\tlet parameterString = new URLSearchParams(queryParameters).toString();\n\t\t\tendpoint += \"?\" + parameterString;\n\t\t\tqueryParameters = null;\n\t\t}\n\n\t\tconst mdh = this;\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, method, queryParameters);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn jsonResponse ? response.json() : undefined;\n\t\t\t});\n\t}\n\n\tconstructor() {\n\t\tif (this.handleConnectExternalAccountResponse()) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet mdh = this;\n\t\tlet applicationHost = getParentOrigin();\n\t\tlet supportedActions;\n\n\t\tfunction getParentOrigin(): string {\n\t\t\tlet ancestorOrigins = document.location.ancestorOrigins;\n\t\t\tif (ancestorOrigins && ancestorOrigins[0]) {\n\t\t\t\treturn ancestorOrigins[0];\n\t\t\t}\n\n\t\t\treturn '*';\n\t\t}\n\n\t\tfunction acceptableOrigin(origin) {\n\t\t\tif (origin === '*') return true;\n\n\t\t\tlet sourceURL = new URL(origin);\n\t\t\tfor (let k = 0; k < mdh.acceptableParentDomains.length; k++) {\n\t\t\t\tif (sourceURL.hostname === mdh.acceptableParentDomains[k] || sourceURL.hostname.endsWith(\".\" + mdh.acceptableParentDomains[k])) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction validateWindowMessageOrigin(message) {\n\t\t\tif (mdh.isStandaloneMode() && message.origin === window.location.origin) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (applicationHost === \"*\") {\n\t\t\t\treturn acceptableOrigin(message.origin);\n\t\t\t}\n\n\t\t\treturn message.origin === applicationHost;\n\t\t}\n\n\t\tfunction addActions(actions) {\n\t\t\tfor (let action in actions) {\n\t\t\t\tif (!window.webkit.messageHandlers[action]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\twindow.webkit.messageHandlers[action] = { postMessage: actions[action] };\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.log(\"Unable to add missing actions on this platform: \" + error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction receiveWindowMessage(message) {\n\t\t\tif (!validateWindowMessageOrigin(message)) {\n\t\t\t\t// todo: this can generate tons of console errors when hosting some apps within webappstep (youtube content, for example )\n\t\t\t\tconsole.error(\"message.origin '\" + message.origin + \"' is not allowed.\");\n\t\t\t\tthrow \"message.origin '\" + message.origin + \"' is not allowed.\";\n\t\t\t}\n\n\t\t\tif (message.data.messageID) {\n\t\t\t\tmdh.setActionResult(message.data);\n\t\t\t} else {\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}\n\n\t\tfunction windowHasAnyActions() {\n\t\t\tfor (let action in supportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[action]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let action in mdh.unsupportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[mdh.unsupportedActions[action]]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!acceptableOrigin(applicationHost)) {\n\t\t\tconsole.log(\"Detected unsupported parent origin domain.\");\n\t\t}\n\n\t\tif (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ResearchKit) {\n\t\t\t// Presence of ResearchKit handler indicates the SDK is being used from within a WebViewStep. For pre-SDK backwards compatiblity,\n\t\t\t// WebViewStep setup registers the following handlers: GetDeviceInfo, DeleteProviderAccount, ConnectExternalAccount\n\t\t\t// ShowParticipantWebVisualizationPDF, ResearchKit\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenExternalUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenEmbeddedUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetSurveyContext\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetSurveyContext',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost);\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t} else {\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetDeviceInfo\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'GetDeviceInfo', messageID: data.messageID }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"StartParticipantSurvey\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'StartParticipantSurvey',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tsurveyName: data.surveyName\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenExternalUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenEmbeddedUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalApplication\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenApplication',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"Dismiss\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Dismiss' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"PopNavigation\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Back' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowTab\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowTab', tabKey: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantDashboard\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantDashboard',\n\t\t\t\t\t\tdashboardKey: data.dashboardKey,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualization\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualization',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualizationPDF\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualizationPDF',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal,\n\t\t\t\t\t\tlandscape: data.landscape,\n\t\t\t\t\t\thtmlViewerZoom: data.htmlViewerZoom\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"DeleteProviderAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'DeleteProviderAccount',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\taccountID: data.accountID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ConnectExternalAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ConnectExternalAccount',\n\t\t\t\t\t\texternalAccountProviderID: data.externalAccountProviderID,\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\topenNewWindow: data.openNewWindow,\n\t\t\t\t\t\twidth: data.width,\n\t\t\t\t\t\theight: data.height\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"JoinProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'JoinProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tif (!window.webkit || !window.webkit.messageHandlers || !windowHasAnyActions()) {\n\t\t\twindow.webkit = {\n\t\t\t\tmessageHandlers: {}\n\t\t\t};\n\t\t}\n\n\t\taddActions(supportedActions);\n\n\t\twindow.addEventListener(\"message\", receiveWindowMessage, false);\n\n\t\tif (this.hasEmbeddedModeUrlParameter()) {\n\t\t\tmdh.enableStandaloneMode(true);\n\t\t}\n\t}\n\n\tprivate readonly acceptableParentDomains = [\n\t\t'localhost',\n\t\t'careevolution.com',\n\t\t'internal',\n\t\t'b3-deploys.com',\n\t\t'mydatahelps.org',\n\t\t'platform.joinallofus.org',\n\t\t'careevolution.dev',\n\t\t'ce.dev',\n\t\t'mydatahelps.dev'\n\t];\n\n\tprivate readonly accessTokenRenewalBufferSeconds = 120;\n\tprivate readonly unsupportedActions = [\"SetHeight\", \"ResearchKit\"];\n\tprivate readonly supportedEvents = [\"surveyDidFinish\", \"applicationDidBecomeVisible\", \"externalAccountSyncComplete\", \"tokenWillExpire\", \"healthConnectSyncComplete\", \"healthConnectPhrSyncComplete\"];\n\tprivate readonly supportedLanguages = [];\n\n\tprivate currentMessageID = 1;\n\tprivate messageHandlers = [];\n\tprivate registeredEventHandlers = {};\n\tprivate refreshTokenPromise = null;\n\tprivate standaloneMode = false;\n\tprivate embeddedMode = false;\n\n\tprivate nextMessageID() {\n\t\treturn this.currentMessageID++;\n\t}\n\n\tprivate makeUrl(endpoint, apiVersion) {\n\t\tif (!this.baseUrl) {\n\t\t\tconsole.error(\"Cannot use makeUrl without MyDataHelps.baseUrl.\");\n\t\t\tthrow \"Cannot use makeUrl without MyDataHelps.baseUrl.\";\n\t\t}\n\n\t\treturn this.baseUrl + 'api/' + apiVersion + '/delegated/' + endpoint;\n\t}\n\n\tprivate makeRequest(endpoint, method, body, apiVersion = \"v1\") {\n\t\tif (!this.token || !this.token.access_token) {\n\t\t\tthrow \"No access_token available for request authorization.\";\n\t\t}\n\n\t\tlet url = this.makeUrl(endpoint, apiVersion);\n\n\t\tlet headers = new Headers();\n\t\theaders.append('Authorization', 'Bearer ' + this.token.access_token);\n\t\theaders.append('Accept', 'application/json, text/javascript, */*; q=0.01');\n\t\theaders.append('Accept-Language', this.getCurrentLanguage());\n\t\tif (!!body) {\n\t\t\theaders.append('Content-Type', 'application/json');\n\t\t}\n\n\t\tlet init: any = {\n\t\t\tmethod: method,\n\t\t\theaders: headers\n\t\t};\n\t\tif (!!body) {\n\t\t\tinit.body = JSON.stringify(body);\n\t\t}\n\n\t\treturn fetch(url, init);\n\t}\n\n\tprivate getSupportedLanguage(language: string): string {\n\t\tlanguage = language.replace(\"_\", \"-\");\n\t\tif (this.supportedLanguages.length === 0) {\n\t\t\treturn language;\n\t\t} else {\n\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\treturn language;\n\t\t\t} else if (language.indexOf(\"-\") > 0) {\n\t\t\t\tlanguage = language.substring(0, language.indexOf(\"-\"));\n\t\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\t\treturn language;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static validateResponse(response) {\n\t\tif (!response.ok) {\n\t\t\tthrow response.statusText;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprivate static escapeParam(param) {\n\t\treturn String(param)\n\t\t\t.replaceAll(\"\\\\\", \"\\\\\\\\\")\n\t\t\t.replaceAll(\",\", \"\\\\,\");\n\t}\n\n\tprivate static reduceArrayAndEscape(param) {\n\t\tif (Array.isArray(param)) {\n\t\t\tlet escapedParams = param.map(function (elem) {\n\t\t\t\treturn MyDataHelps.escapeParam(elem);\n\t\t\t});\n\t\t\treturn escapedParams.join(\",\");\n\t\t}\n\n\t\treturn this.escapeParam(param);\n\t}\n\n\tprivate static convertDateToIsoString(date) {\n\t\tlet paramAsDate = new Date(date);\n\t\tif (isNaN(paramAsDate.getTime())) {\n\t\t\tthrow \"Cannot interpret parameter as Date\";\n\t\t}\n\n\t\treturn paramAsDate.toISOString();\n\t}\n\n\tprivate static flattenPropertyShallow(params, property) {\n\t\tif (params[property] === undefined || params[property] === null) return;\n\n\t\tfor (var key in params[property]) {\n\t\t\tif (params[property].hasOwnProperty(key)) {\n\t\t\t\tparams[`${property}.${key}`] = MyDataHelps.escapeParam(params[property][key]);\n\t\t\t}\n\t\t}\n\n\t\tdelete params[property];\n\t}\n\n\tprivate startEmbeddedSurveyInternal(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\t\treject(\"Survey already in progress\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\t\tif (message.source !== frame) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t\t} else if (message.data.name === 'SurveyFinished') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\t\tresolve(message.data);\n\t\t\t\t}\n\t\t\t}, true);\n\n\t\t\tlet surveyModal = document.createElement('div');\n\t\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\t\tsurveyModal.id = mdhSurveyModalId;\n\t\t\tsurveyModal.innerHTML = \"<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='\" + surveyUrl + \"'></iframe></div>\";\n\t\t\tdocument.body.append(surveyModal);\n\t\t\tdocument.body.className += ' no-scroll';\n\t\t});\n\t}\n\n\tprivate startDelegatedSurvey(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\treturn;\n\t\t}\n\n\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\tif (message.source !== frame) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (message.data.name === 'GetDelegatedAccessToken') {\n\t\t\t\tmdh.getParticipantInfo().then((participant) => {\n\t\t\t\t\tframe.postMessage({ name: \"DelegatedAccessTokenResponse\", accessToken: mdh.token, baseUrl: mdh.baseUrl, participantID: participant.participantID }, '*');\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyFinished') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\tmessage.data.type = 'surveyDidFinish';\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}, true);\n\n\t\tlet surveyModal = document.createElement('div');\n\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\tsurveyModal.id = mdhSurveyModalId;\n\t\tsurveyModal.innerHTML = `<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${surveyUrl}&lang=${mdh.getCurrentLanguage()}'></iframe></div>`;\n\t\tdocument.body.append(surveyModal);\n\t\tdocument.body.className += ' no-scroll';\n\t}\n\n\tprivate handleConnectExternalAccountResponse() {\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (window.opener && params.get('connectExternalAccount') && params.get('messageID') && params.get('success')) {\n\t\t\twindow.opener.postMessage({\n\t\t\t\tname: 'ConnectExternalAccountResponse',\n\t\t\t\tmessageID: parseInt(params.get('messageID')),\n\t\t\t\tsuccess: params.get('success') === 'true'\n\t\t\t}, window.location.origin);\n\t\t\twindow.close();\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate hasEmbeddedModeUrlParameter() {\n\t\tconst embeddedModeKey = '_e';\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.has(embeddedModeKey) && params.get(embeddedModeKey) !== 'false') {\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n//iOS/Android directly invoke window.MyDataHelps and window.RKStudioClient\n//so it's necessary to explicitly ensure they are present on the window\nconst mdh = new MyDataHelps();\n\nwindow.MyDataHelps = mdh;\n\n// For backwards compatibility\nwindow.RKStudioClient = {};\nwindow.RKStudioClient.setActionResult = function (data) {\n\twindow.MyDataHelps.setActionResult(data);\n};\n\nexport default mdh;\nexport * from './types';\n"],"names":["MyDataHelps","startSurvey","surveyName","this","isStandaloneMode","startDelegatedSurvey","baseUrl","encodeURIComponent","window","webkit","messageHandlers","StartParticipantSurvey","messageID","nextMessageID","postMessage","completeStep","answer","JSON","stringify","ResearchKit","CompleteStep","querySurveyAnswers","queryParameters","Object","assign","hasOwnProperty","reduceArrayAndEscape","stepIdentifier","resultIdentifier","before","convertDateToIsoString","after","endpoint","URLSearchParams","toString","mdh","connect","then","makeRequest","response","validateResponse","json","querySurveyResults","event","insertedBefore","insertedAfter","deleteSurveyResult","resultID","querySurveyTasks","status","queryInboxItems","target","source","key","keys","value","undefined","assignDefined","type","getInboxItem","id","updateInboxItem","update","startEmbeddedSurvey","linkIdentifier","language","getCurrentLanguage","surveyUrl","startEmbeddedSurveyInternal","openExternalUrl","url","OpenExternalLink","openEmbeddedUrl","OpenEmbeddedLink","showTab","tabKey","ShowTab","openApplication","options","OpenExternalApplication","modal","dismiss","Dismiss","back","PopNavigation","showDashboard","dashboardKey","ShowParticipantDashboard","title","showWebVisualization","visualizationKey","parameters","ShowParticipantWebVisualization","showWebVisualizationPdf","ShowParticipantWebVisualizationPDF","landscape","htmlViewerZoom","showProject","projectCode","ShowProject","code","joinProject","JoinProject","on","eventName","callback","supportedEvents","includes","Error","registeredEventHandlers","push","off","eventHandlerIndex","indexOf","splice","triggerEvent","forEach","handler","setActionResult","data","prototype","call","console","error","getParticipantInfo","persistParticipantInfo","demographics","customFields","async","ok","message","catch","log","getProjectInfo","getDeviceDataPoint","deleteDeviceDataPoint","queryDeviceData","observedBefore","observedAfter","persistDeviceData","deviceDataPoints","queryDeviceDataV2","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","enabled","getExternalAccountProviders","search","category","pageSize","pageNumber","searchParameters","connectExternalAccount","externalAccountProviderID","Promise","resolve","reject","connectProviderAccountResponse","success","errorMessage","standaloneMode","standaloneModeFinalRedirectPath","location","href","providerAuthWindow","openNewWindow","split","windowFeatures","width","height","w","h","outerHeight","screenY","outerWidth","screenX","open","queryString","finalRedirectPath","text","redirectUrl","replace","top","ConnectExternalAccount","getExternalAccounts","refreshExternalAccount","accountID","deleteExternalAccount","DeleteProviderAccount","deleteProviderAccountResponse","getFeaturedProviders","context","queryNotifications","sentBefore","sentAfter","queryFitbitDailySummaries","startDate","endDate","queryFitbitSleepLogs","queryAppleHealthActivitySummaries","queryAppleHealthWorkouts","uploadFile","file","fileName","size","name","fetch","preSignedUrl","method","body","headers","queryFiles","getFileDownloadUrl","deleteFile","refreshDelegatedAccessToken","token","refreshTokenPromise","tokenResponse","tokenExpires","Date","now","expires_in","setTimeout","accessTokenRenewalBufferSeconds","GetDelegatedAccessToken","isEmbeddedMode","setParticipantAccessToken","enableStandaloneMode","embeddedMode","setStatusBarStyle","style","SetStatusBarStyle","getDeviceInfo","GetDeviceInfo","deviceInfoResponse","setSupportedLanguages","languages","supportedLanguages","length","i","getStepConfiguration","GetStepConfiguration","stepConfigurationResponse","getSurveyContext","deviceInfo","platform","surveyMode","GetSurveyContext","surveyContextResponse","getCurrentSurveyAnswers","GetCurrentSurveyAnswers","currentSurveyAnswersResponse","setCurrentLanguage","supportedLanguage","getSupportedLanguage","warn","lang","searchParams","has","get","navigator","showGoogleFitSettings","ShowGoogleFitSettings","showHealthConnectSettings","HealthConnectSettings","showHealthConnectPrompt","HealthConnectPrompt","getHealthConnectStatus","HealthConnectStatus","statusResponse","showHealthConnectPhrPrompt","HealthConnectPhrPrompt","getHealthConnectPhrStatus","HealthConnectPhrStatus","requestReview","cooldownDays","RequestReview","trackCustomEvent","getDataCollectionSettings","getDataAvailability","invokeCustomApi","customApi","jsonResponse","toUpperCase","parameterString","constructor","acceptableParentDomains","unsupportedActions","currentMessageID","handleConnectExternalAccountResponse","supportedActions","applicationHost","ancestorOrigins","document","getParentOrigin","acceptableOrigin","origin","sourceURL","URL","k","hostname","endsWith","parent","action","windowHasAnyActions","actions","addActions","addEventListener","validateWindowMessageOrigin","hasEmbeddedModeUrlParameter","makeUrl","apiVersion","access_token","Headers","append","init","find","l","substring","statusText","escapeParam","param","String","replaceAll","Array","isArray","map","elem","join","date","paramAsDate","isNaN","getTime","toISOString","params","property","mdhSurveyModalId","getElementById","listener","frame","contentWindow","className","remove","removeEventListener","surveyModal","createElement","innerHTML","participant","accessToken","participantID","opener","parseIn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"MyDataHelps.min.js","sources":["../../src/MyDataHelps.ts"],"sourcesContent":["// @ts-ignore : let rollup handle CSS injection\nimport \"../MyDataHelps.css\";\n\nimport * as Model from \"./types\";\nimport { StringMap } from \"./types\";\n\nexport class MyDataHelps {\n\n\tbaseUrl: string = 'https://mydatahelps.org/';\n\tlanguage: string;\n\ttoken: Model.Token;\n\ttokenExpires: number;\n\n\t// Surveys\n\n\tstartSurvey(surveyName: string): void {\n\t\tif (this.isStandaloneMode()) {\n\t\t\tthis.startDelegatedSurvey(`${this.baseUrl}/survey?surveyName=${encodeURIComponent(surveyName)}`);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.StartParticipantSurvey) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.StartParticipantSurvey.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tsurveyName: surveyName\n\t\t\t});\n\t\t}\n\t}\n\n\tcompleteStep(answer: any): void {\n\t\tif (answer === undefined || answer === null) answer = '';\n\t\tif (typeof answer !== 'string') {\n\t\t\tanswer = JSON.stringify(answer);\n\t\t}\n\t\tif (window.webkit.messageHandlers.ResearchKit) {\n\t\t\twindow.webkit.messageHandlers.ResearchKit.postMessage(answer);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.CompleteStep) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.CompleteStep.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tanswer: answer\n\t\t\t});\n\t\t}\n\t}\n\n\tquerySurveyAnswers(queryParameters: Model.SurveyAnswersQuery): Promise<Model.SurveyAnswersPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"stepIdentifier\")) {\n\t\t\tqueryParameters.stepIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.stepIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"resultIdentifier\")) {\n\t\t\tqueryParameters.resultIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.resultIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"answer\")) {\n\t\t\tqueryParameters.answer = MyDataHelps.reduceArrayAndEscape(queryParameters.answer);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyanswers?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tquerySurveyResults(queryParameters: Model.SurveyResultsQuery): Promise<Model.SurveyResultsPage> {\n\t\tqueryParameters = { ...queryParameters }\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"event\")) {\n\t\t\tqueryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyresults?' + queryString;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\tdeleteSurveyResult(resultID: string): Promise<void> {\n\t\tconst endpoint = 'surveyresults/' + encodeURIComponent(resultID);\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tquerySurveyTasks(queryParameters: Model.SurveyTaskQueryParameters): Promise<Model.SurveyTasksPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.SurveyTaskStatus;\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveytasks?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryInboxItems(queryParameters: Model.InboxItemQueryParameters): Promise<Model.InboxItemsPage> {\n\t\tconst assignDefined = (target: any, source: any): any => {\n\t\t\tfor (const key of Object.keys(source)) {\n\t\t\t\tconst value = source[key];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\ttarget[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tqueryParameters = assignDefined({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type) as Model.InboxItemType;\n\t\t}\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.InboxItemStatus;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'inbox?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetInboxItem(id: Model.Guid): Promise<Model.InboxItem> {\n\t\tconst endpoint = `inbox/${id}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tupdateInboxItem(id: Model.Guid, update: Model.InboxItemUpdate): Promise<Model.InboxItemUpdateResult> {\n\t\tconst endpoint = `inbox/${id}/${update}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tstartEmbeddedSurvey(linkIdentifier: string, surveyName: string, language: string): Promise<any> {\n\t\tif (!language) {\n\t\t\tlanguage = this.getCurrentLanguage();\n\t\t}\n\t\tlet surveyUrl = this.baseUrl + \"mydatahelps/\" + linkIdentifier + '/surveylink/' + surveyName + \"?lang=\" + language;\n\t\treturn this.startEmbeddedSurveyInternal(surveyUrl);\n\t}\n\n\t// Navigation\n\n\topenExternalUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalLink) {\n\t\t\twindow.webkit.messageHandlers.OpenExternalLink.postMessage(url);\n\t\t}\n\t}\n\n\topenEmbeddedUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenEmbeddedLink) {\n\t\t\twindow.webkit.messageHandlers.OpenEmbeddedLink.postMessage(url);\n\t\t}\n\t}\n\n\tshowTab(tabKey: string): void {\n\t\tif (window.webkit.messageHandlers.ShowTab) {\n\t\t\twindow.webkit.messageHandlers.ShowTab.postMessage(tabKey);\n\t\t}\n\t}\n\n\topenApplication(url: string, options?: Model.OpenApplicationOptions): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalApplication) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.OpenExternalApplication.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\turl: url,\n\t\t\t\tmodal: !!(options && options.modal)\n\t\t\t});\n\t\t}\n\t}\n\n\tdismiss(): void {\n\t\tif (window.webkit.messageHandlers.Dismiss) {\n\t\t\twindow.webkit.messageHandlers.Dismiss.postMessage({});\n\t\t}\n\t}\n\n\tback(): void {\n\t\tif (window.webkit.messageHandlers.PopNavigation) {\n\t\t\twindow.webkit.messageHandlers.PopNavigation.postMessage({});\n\t\t}\n\t}\n\n\tshowDashboard(dashboardKey: string, options?: Model.ShowDashboardOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantDashboard) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantDashboard.postMessage({\n\t\t\t\tdashboardKey: dashboardKey,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualization(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualization) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualizationPdf(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationPdfOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tlandscape: !!(options && options.landscape),\n\t\t\t\thtmlViewerZoom: options && options.htmlViewerZoom\n\t\t\t});\n\t\t}\n\t}\n\n\tshowProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.ShowProject) {\n\t\t\twindow.webkit.messageHandlers.ShowProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\tjoinProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.JoinProject) {\n\t\t\twindow.webkit.messageHandlers.JoinProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\t//Events\n\n\ton(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName] = [];\n\t\t}\n\n\t\tthis.registeredEventHandlers[eventName].push(callback);\n\t}\n\n\toff(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) return;\n\n\t\tlet eventHandlerIndex = this.registeredEventHandlers[eventName].indexOf(callback);\n\n\t\tif (eventHandlerIndex !== -1) {\n\t\t\tthis.registeredEventHandlers[eventName].splice(eventHandlerIndex, 1);\n\t\t}\n\t}\n\n\ttriggerEvent(event: Model.EventData): void {\n\t\tlet eventName = event.type;\n\t\tif (this.supportedEvents.includes(eventName) && this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName].forEach(function (handler) {\n\t\t\t\thandler(event);\n\t\t\t});\n\t\t}\n\t}\n\n\tsetActionResult(data: Model.EventData): void {\n\t\tif (Object.prototype.hasOwnProperty.call(this.messageHandlers, data.messageID) &&\n\t\t\ttypeof this.messageHandlers[data.messageID] === 'function') {\n\t\t\tthis.messageHandlers[data.messageID](data);\n\t\t} else {\n\t\t\tconsole.error(`Invalid messageID: ${data.messageID}`);\n\t\t}\n\t}\n\n\t// Participant Info\n\n\tgetParticipantInfo(): Promise<Model.ParticipantInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'participant';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistParticipantInfo(demographics: Partial<Model.ParticipantDemographics> | undefined, customFields: StringMap): Promise<Model.ParticipantInfo> {\n\t\tconst endpoint = 'participant';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', { demographics, customFields });\n\t\t\t})\n\t\t\t.then(async function (response) {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tvar errorJson = await response.json();\n\t\t\t\t\tthrow errorJson.message;\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.log(\"Unable to persist participant: \" + error);\n\t\t\t});\n\t}\n\n\tgetProjectInfo(): Promise<Model.ProjectInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'project';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Device Data\n\n\tgetDeviceDataPoint(id: Model.Guid): Promise<Model.DeviceDataPoint> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteDeviceDataPoint(id: Model.Guid): Promise<void> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryDeviceData(queryParameters: Model.DeviceDataPointQuery): Promise<Model.DeviceDataPointsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistDeviceData(deviceDataPoints: Model.PersistableDeviceDataPoint[]): Promise<void> {\n\t\tconst endpoint = 'devicedata';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', deviceDataPoints);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Device Data V2\n\n\tqueryDeviceDataV2(queryParameters: Model.DeviceDataV2Query): Promise<Model.DeviceDataV2Page> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2Aggregate(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2AggregatePage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"aggregateFunctions\")) {\n\t\t\tqueryParameters.aggregateFunctions = MyDataHelps.reduceArrayAndEscape(queryParameters.aggregateFunctions);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2DailySleep(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2DailySleepPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate/dailysleep?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDeviceDataV2AllDataTypes(enabled?: boolean): Promise<Model.SupportedDeviceDataV2DataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// External Accounts\n\n\tgetExternalAccountProviders(search: string | null, category: string | null, pageSize: number, pageNumber: number): Promise<Model.ExternalAccountProvidersPage> {\n\t\tlet searchParameters: any = {};\n\t\tif (!!search) searchParameters.search = search;\n\t\tif (!!category) searchParameters.category = category;\n\t\tif (!!pageSize) searchParameters.pageSize = pageSize;\n\t\tif (!!pageNumber) searchParameters.pageNumber = pageNumber;\n\n\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\tconst endpoint = 'externalaccountproviders?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tconnectExternalAccount(externalAccountProviderID: number, options?: Model.ConnectExternalAccountOptions): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\n\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\tmdh.messageHandlers[messageID] = function (connectProviderAccountResponse) {\n\t\t\t\tif (connectProviderAccountResponse && connectProviderAccountResponse.success) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject(connectProviderAccountResponse.errorMessage)\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (this.standaloneMode) {\n\t\t\t\tlet standaloneModeFinalRedirectPath = options?.standaloneModeFinalRedirectPath || window.location.href;\n\t\t\t\tconst mdh = this;\n\n\t\t\t\t// DEV: Safari blocks popups in AJAX responses. Work-around is to open a blank window before the request and set the URL later\n\t\t\t\tlet providerAuthWindow;\n\t\t\t\tif (options?.openNewWindow) {\n\t\t\t\t\tstandaloneModeFinalRedirectPath = `${standaloneModeFinalRedirectPath.split('?')[0]}?connectExternalAccount=true&messageID=${messageID}&success=%SUCCESSVALUE%`;\n\t\t\t\t\tlet windowFeatures = null;\n\t\t\t\t\tif (options?.width && options?.height) {\n\t\t\t\t\t\tconst w = options?.width;\n\t\t\t\t\t\tconst h = options?.height;\n\t\t\t\t\t\tconst y = window.outerHeight / 2 + window.screenY - (h / 2);\n\t\t\t\t\t\tconst x = window.outerWidth / 2 + window.screenX - (w / 2);\n\t\t\t\t\t\twindowFeatures = \"width=\" + w + \",height=\" + h + \",top=\" + y + \",left=\" + x;\n\t\t\t\t\t}\n\t\t\t\t\tproviderAuthWindow = window.open(`${this.baseUrl}home/loading`, 'providerauth', windowFeatures);\n\t\t\t\t}\n\n\t\t\t\tconst searchParameters = { finalRedirectPath: standaloneModeFinalRedirectPath };\n\t\t\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\t\t\tconst endpoint = \"externalaccountproviders/\" + externalAccountProviderID + \"/connect?\" + queryString;\n\n\t\t\t\tthis\n\t\t\t\t\t.connect()\n\t\t\t\t\t.then(function () {\n\t\t\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn response.text();\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (redirectUrl) {\n\t\t\t\t\t\tif (providerAuthWindow) {\n\t\t\t\t\t\t\tproviderAuthWindow.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twindow.top.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function (error) {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t});\n\t\t\t} else if (window.webkit.messageHandlers.ConnectExternalAccount) {\n\t\t\t\twindow.webkit.messageHandlers.ConnectExternalAccount.postMessage({\n\t\t\t\t\texternalAccountProviderID: externalAccountProviderID,\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tgetExternalAccounts(): Promise<Model.ExternalAccount[]> {\n\t\tconst endpoint = 'externalaccounts';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\trefreshExternalAccount(accountID: number): Promise<void> {\n\t\tconst endpoint = 'externalaccounts/refresh/' + accountID;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tdeleteExternalAccount(accountID: number): Promise<any> {\n\t\tconst endpoint = 'externalaccounts/delete/' + encodeURIComponent(accountID);\n\t\tconst mdh = this;\n\n\t\tif (this.isStandaloneMode()) {\n\t\t\treturn this\n\t\t\t\t.connect()\n\t\t\t\t.then(function () {\n\t\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t\t})\n\t\t\t\t.then(function (response) {\n\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t});\n\t\t}\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (window.webkit.messageHandlers.DeleteProviderAccount) {\n\t\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deleteProviderAccountResponse) {\n\t\t\t\t\tif (!deleteProviderAccountResponse.success) {\n\t\t\t\t\t\treject(deleteProviderAccountResponse)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(deleteProviderAccountResponse);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.DeleteProviderAccount.postMessage({\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\taccountID: accountID\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetFeaturedProviders(context?: string): Promise<Model.ExternalAccountProvider[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (context) {\n\t\t\tqueryParameters['featuredProvidersContext'] = context;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `featuredexternalaccountproviders?${queryString}`;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\t// Notifications\n\n\tqueryNotifications(queryParameters: Model.NotificationQueryParameters): Promise<Model.NotificationsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"sentBefore\")) {\n\t\t\tqueryParameters.sentBefore = MyDataHelps.convertDateToIsoString(queryParameters.sentBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"sentAfter\")) {\n\t\t\tqueryParameters.sentAfter = MyDataHelps.convertDateToIsoString(queryParameters.sentAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'notifications?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Fitbit\n\n\tqueryFitbitDailySummaries(queryParameters: Model.FitbitQuery): Promise<Model.FitbitDailySummariesPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/dailySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryFitbitSleepLogs(queryParameters: Model.FitbitQuery): Promise<Model.FitbitSleepLogsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/sleepLogs?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// AppleHealth\n\n\tqueryAppleHealthActivitySummaries(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthActivitySummaryPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/activitySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryAppleHealthWorkouts(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthWorkoutPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/workouts?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Files\n\n\tuploadFile(file: File, category: string, fileName?: string): Promise<void> {\n\n\t\tif (file.size > 200 * 1024 * 1024) {\n\t\t\tthrow new Error(\"File size exceeds the maximum allowed size of 200MB.\");\n\t\t}\n\n\t\tconst mdh = this;\n\t\tconst endpoint = 'files?category=' + category + '&fileName=' + encodeURIComponent(fileName ?? file.name);\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.then(function (json) {\n\t\t\t\treturn fetch(json.preSignedUrl, {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\tbody: file,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': file.type,\n\t\t\t\t\t\t'x-amz-server-side-encryption': 'AES256'\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryFiles(queryParameters: Model.UploadedFileQuery): Promise<Model.UploadedFilesPage> {\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'files?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetFileDownloadUrl(key: string): Promise<Model.DownloadedFile> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to download.\");\n\n\t\tconst endpoint = 'files/download?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteFile(key: string): Promise<void> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to delete.\");\n\n\t\tconst endpoint = 'files?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Authorization\n\n\tconnect(): Promise<void> {\n\t\tconst mdh = this;\n\t\tlet refreshDelegatedAccessToken = function () {\n\t\t\tmdh.token = null;\n\n\t\t\tmdh.refreshTokenPromise = new Promise(function (resolve, reject) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (tokenResponse) {\n\t\t\t\t\tif (tokenResponse.success) {\n\t\t\t\t\t\tmdh.tokenExpires = Date.now() + (tokenResponse.data.expires_in * 1000);\n\t\t\t\t\t\tmdh.token = tokenResponse.data;\n\t\t\t\t\t\tmdh.baseUrl = tokenResponse.baseUrl;\n\t\t\t\t\t\tsetTimeout(refreshDelegatedAccessToken, ((tokenResponse.data.expires_in - mdh.accessTokenRenewalBufferSeconds) * 1000));\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmdh.token = null;\n\t\t\t\t\t\treject(tokenResponse.message);\n\t\t\t\t\t}\n\t\t\t\t\tmdh.messageHandlers[messageID] = null;\n\t\t\t\t\tmdh.refreshTokenPromise = null;\n\t\t\t\t};\n\n\t\t\t\twindow.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({ messageID: messageID });\n\t\t\t});\n\t\t};\n\n\t\tif (this.token && Date.now() < this.tokenExpires) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\tif (this.isStandaloneMode() && !this.isEmbeddedMode()) {\n\t\t\tlet error = this.token ? \"access token is expired or invalid\" : \"access token must be explicitly provided using the setParticipantAccess method\";\n\t\t\tconsole.log(error);\n\t\t\treturn Promise.reject(error);\n\t\t}\n\n\t\tif (!this.refreshTokenPromise) {\n\t\t\trefreshDelegatedAccessToken();\n\t\t}\n\n\t\t// Re-use promise if refresh already in progress\n\t\treturn this.refreshTokenPromise;\n\t}\n\n\tsetParticipantAccessToken(token: Model.Token, baseUrl?: string): void {\n\t\tthis.enableStandaloneMode();\n\t\tthis.token = token;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tthis.tokenExpires = Date.now() + (this.token.expires_in * 1000);\n\t\tconst mdh = this;\n\t\tsetTimeout(function () {\n\t\t\tmdh.triggerEvent({ type: \"tokenWillExpire\" });\n\t\t}, ((this.token.expires_in - this.accessTokenRenewalBufferSeconds) * 1000));\n\t}\n\n\t// Miscellaneous\n\n\tisStandaloneMode() {\n\t\treturn this.standaloneMode;\n\t}\n\n\tisEmbeddedMode() {\n\t\treturn this.embeddedMode;\n\t}\n\n\tenableStandaloneMode(embeddedMode: boolean = false, baseUrl?: string) {\n\t\tthis.standaloneMode = true;\n\t\tthis.embeddedMode = embeddedMode;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tif (window.webkit) {\n\t\t\twindow.webkit.messageHandlers = embeddedMode ? {\n\t\t\t\tGetDelegatedAccessToken: window.webkit.messageHandlers.GetDelegatedAccessToken,\n\t\t\t\tOpenExternalLink: window.webkit.messageHandlers.OpenExternalLink,\n\t\t\t\tOpenEmbeddedLink: window.webkit.messageHandlers.OpenEmbeddedLink,\n\t\t\t\tOpenExternalApplication: window.webkit.messageHandlers.OpenExternalApplication,\n\t\t\t\tPopNavigation: window.webkit.messageHandlers.PopNavigation,\n\t\t\t\tDismiss: window.webkit.messageHandlers.Dismiss,\n\t\t\t} : {};\n\t\t}\n\t}\n\n\tsetStatusBarStyle(style: Model.StatusBarStyle): void {\n\t\tif (window.webkit.messageHandlers.SetStatusBarStyle) {\n\t\t\twindow.webkit.messageHandlers.SetStatusBarStyle.postMessage({ style: style });\n\t\t}\n\t}\n\n\tgetDeviceInfo(): Promise<Model.DeviceInfo> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.DeviceInfo>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetDeviceInfo) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deviceInfoResponse) {\n\t\t\t\t\tresolve(deviceInfoResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetDeviceInfo.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetSupportedLanguages(languages: string[]) {\n\t\tthis.supportedLanguages.length = 0;\n\t\tfor (let i = 0; i < languages.length; i++) {\n\t\t\tthis.supportedLanguages.push(languages[i].replace(\"_\", \"-\"));\n\t\t}\n\t}\n\n\tgetStepConfiguration(): Promise<Model.StepConfiguration> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.StepConfiguration>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetStepConfiguration) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (stepConfigurationResponse) {\n\t\t\t\t\tresolve(stepConfigurationResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetStepConfiguration.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetSurveyContext(): Promise<Model.SurveyContext> {\n\t\tlet mdh = this;\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t}\n\t\t\tmdh.getDeviceInfo().then(function (deviceInfo) {\n\t\t\t\tif (deviceInfo.platform !== \"Web\") {\n\t\t\t\t\tresolve({ surveyMode: \"Survey\" });\n\t\t\t\t}\n\t\t\t\telse if (window.webkit.messageHandlers.GetSurveyContext) {\n\t\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\t\tmdh.messageHandlers[messageID] = function (surveyContextResponse) {\n\t\t\t\t\t\tresolve(surveyContextResponse.data);\n\t\t\t\t\t};\n\t\t\t\t\twindow.webkit.messageHandlers.GetSurveyContext.postMessage({ messageID: messageID });\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treject();\n\t\t\t\t}\n\t\t\t}).catch(function (error) {\n\t\t\t\treject();\n\t\t\t});\n\t\t});\n\t}\n\n\tgetCurrentSurveyAnswers(): Promise<Model.CurrentSurveyAnswer[]> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.CurrentSurveyAnswer[]>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetCurrentSurveyAnswers) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (currentSurveyAnswersResponse) {\n\t\t\t\t\tresolve(currentSurveyAnswersResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetCurrentLanguage(language: string) {\n\t\tif (language) {\n\t\t\tlet supportedLanguage = this.getSupportedLanguage(language);\n\t\t\tif (supportedLanguage) {\n\t\t\t\tthis.language = supportedLanguage;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${language} not supported`);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.language = language;\n\t\t}\n\t}\n\n\tgetCurrentLanguage(): string {\n\t\tlet searchParams = new URLSearchParams(window.location.search);\n\t\tlet lang;\n\t\tif (searchParams.has(\"lang\")) {\n\t\t\tlang = this.getSupportedLanguage(searchParams.get(\"lang\"));\n\t\t\tif (lang) {\n\t\t\t\treturn lang;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${searchParams.get(\"lang\")} not supported`);\n\t\t\t}\n\t\t}\n\t\treturn this.language || navigator.language;\n\t}\n\n\tshowGoogleFitSettings(): void {\n\t\tif (window.webkit.messageHandlers.ShowGoogleFitSettings) {\n\t\t\twindow.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectSettings(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectSettings) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectStatus(): Promise<Model.HealthConnectStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tshowHealthConnectPhrPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPhrPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectPhrStatus(): Promise<Model.HealthConnectPhrStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectPhrStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectPhrStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\trequestReview(cooldownDays?: number): void {\n\t\tif (window.webkit.messageHandlers.RequestReview) {\n\t\t\twindow.webkit.messageHandlers.RequestReview.postMessage({ cooldownDays: cooldownDays });\n\t\t}\n\t}\n\n\ttrackCustomEvent(event: Model.CustomEventInfo): Promise<void> {\n\t\tconst endpoint = 'customevents';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', event);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tgetDataCollectionSettings(): Promise<Model.DataCollectionSettings> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'datacollectionsettings';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDataAvailability(): Promise<Model.DataAvailability> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'dataavailability';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tinvokeCustomApi(customApi: string, method: string, queryParameters: string | string[][] | Record<string, string> | URLSearchParams | null | undefined, jsonResponse: boolean): Promise<any> {\n\t\tif (customApi.includes('?')) {\n\t\t\tthrow new Error(\"Cannot include query parameters directly in the \\\"customApi\\\" string. Provide as an argument for \\\"queryParameters\\\" instead.\");\n\t\t}\n\n\t\tlet endpoint = 'custom/' + customApi;\n\t\tmethod = method.toUpperCase();\n\t\tif (queryParameters !== null && queryParameters !== undefined && (method === 'GET' || method === 'DELETE')) {\n\t\t\tlet parameterString = new URLSearchParams(queryParameters).toString();\n\t\t\tendpoint += \"?\" + parameterString;\n\t\t\tqueryParameters = null;\n\t\t}\n\n\t\tconst mdh = this;\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, method, queryParameters);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn jsonResponse ? response.json() : undefined;\n\t\t\t});\n\t}\n\n\tconstructor() {\n\t\tif (this.handleConnectExternalAccountResponse()) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet mdh = this;\n\t\tlet applicationHost = getParentOrigin();\n\t\tlet supportedActions;\n\n\t\tfunction getParentOrigin(): string {\n\t\t\tlet ancestorOrigins = document.location.ancestorOrigins;\n\t\t\tif (ancestorOrigins && ancestorOrigins[0]) {\n\t\t\t\treturn ancestorOrigins[0];\n\t\t\t}\n\n\t\t\treturn '*';\n\t\t}\n\n\t\tfunction acceptableOrigin(origin) {\n\t\t\tif (origin === '*') return true;\n\n\t\t\tlet sourceURL = new URL(origin);\n\t\t\tfor (let k = 0; k < mdh.acceptableParentDomains.length; k++) {\n\t\t\t\tif (sourceURL.hostname === mdh.acceptableParentDomains[k] || sourceURL.hostname.endsWith(\".\" + mdh.acceptableParentDomains[k])) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction validateWindowMessageOrigin(message) {\n\t\t\tif (mdh.isStandaloneMode() && message.origin === window.location.origin) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (applicationHost === \"*\") {\n\t\t\t\treturn acceptableOrigin(message.origin);\n\t\t\t}\n\n\t\t\treturn message.origin === applicationHost;\n\t\t}\n\n\t\tfunction addActions(actions) {\n\t\t\tfor (let action in actions) {\n\t\t\t\tif (!window.webkit.messageHandlers[action]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\twindow.webkit.messageHandlers[action] = { postMessage: actions[action] };\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.log(\"Unable to add missing actions on this platform: \" + error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction receiveWindowMessage(message) {\n\t\t\tif (!validateWindowMessageOrigin(message)) {\n\t\t\t\t// todo: this can generate tons of console errors when hosting some apps within webappstep (youtube content, for example )\n\t\t\t\tconsole.error(\"message.origin '\" + message.origin + \"' is not allowed.\");\n\t\t\t\tthrow \"message.origin '\" + message.origin + \"' is not allowed.\";\n\t\t\t}\n\n\t\t\tif (message.data.messageID) {\n\t\t\t\tmdh.setActionResult(message.data);\n\t\t\t} else {\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}\n\n\t\tfunction windowHasAnyActions() {\n\t\t\tfor (let action in supportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[action]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let action in mdh.unsupportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[mdh.unsupportedActions[action]]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!acceptableOrigin(applicationHost)) {\n\t\t\tconsole.log(\"Detected unsupported parent origin domain.\");\n\t\t}\n\n\t\tif (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ResearchKit) {\n\t\t\t// Presence of ResearchKit handler indicates the SDK is being used from within a WebViewStep. For pre-SDK backwards compatiblity,\n\t\t\t// WebViewStep setup registers the following handlers: GetDeviceInfo, DeleteProviderAccount, ConnectExternalAccount\n\t\t\t// ShowParticipantWebVisualizationPDF, ResearchKit\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenExternalUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenEmbeddedUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetSurveyContext\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetSurveyContext',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost);\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t} else {\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetDeviceInfo\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'GetDeviceInfo', messageID: data.messageID }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"StartParticipantSurvey\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'StartParticipantSurvey',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tsurveyName: data.surveyName\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenExternalUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenEmbeddedUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalApplication\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenApplication',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"Dismiss\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Dismiss' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"PopNavigation\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Back' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowTab\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowTab', tabKey: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantDashboard\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantDashboard',\n\t\t\t\t\t\tdashboardKey: data.dashboardKey,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualization\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualization',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualizationPDF\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualizationPDF',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal,\n\t\t\t\t\t\tlandscape: data.landscape,\n\t\t\t\t\t\thtmlViewerZoom: data.htmlViewerZoom\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"DeleteProviderAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'DeleteProviderAccount',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\taccountID: data.accountID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ConnectExternalAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ConnectExternalAccount',\n\t\t\t\t\t\texternalAccountProviderID: data.externalAccountProviderID,\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\topenNewWindow: data.openNewWindow,\n\t\t\t\t\t\twidth: data.width,\n\t\t\t\t\t\theight: data.height\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"JoinProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'JoinProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tif (!window.webkit || !window.webkit.messageHandlers || !windowHasAnyActions()) {\n\t\t\twindow.webkit = {\n\t\t\t\tmessageHandlers: {}\n\t\t\t};\n\t\t}\n\n\t\taddActions(supportedActions);\n\n\t\twindow.addEventListener(\"message\", receiveWindowMessage, false);\n\n\t\tif (this.hasEmbeddedModeUrlParameter()) {\n\t\t\tmdh.enableStandaloneMode(true);\n\t\t}\n\t}\n\n\tprivate readonly acceptableParentDomains = [\n\t\t'localhost',\n\t\t'careevolution.com',\n\t\t'internal',\n\t\t'b3-deploys.com',\n\t\t'mydatahelps.org',\n\t\t'platform.joinallofus.org',\n\t\t'careevolution.dev',\n\t\t'ce.dev',\n\t\t'mydatahelps.dev'\n\t];\n\n\tprivate readonly accessTokenRenewalBufferSeconds = 120;\n\tprivate readonly unsupportedActions = [\"SetHeight\", \"ResearchKit\"];\n\tprivate readonly supportedEvents = [\"surveyDidFinish\", \"applicationDidBecomeVisible\", \"externalAccountSyncComplete\", \"tokenWillExpire\", \"healthConnectSyncComplete\", \"healthConnectPhrSyncComplete\"];\n\tprivate readonly supportedLanguages = [];\n\n\tprivate currentMessageID = 1;\n\tprivate messageHandlers = [];\n\tprivate registeredEventHandlers = {};\n\tprivate refreshTokenPromise = null;\n\tprivate standaloneMode = false;\n\tprivate embeddedMode = false;\n\n\tprivate nextMessageID() {\n\t\treturn this.currentMessageID++;\n\t}\n\n\tprivate makeUrl(endpoint, apiVersion) {\n\t\tif (!this.baseUrl) {\n\t\t\tconsole.error(\"Cannot use makeUrl without MyDataHelps.baseUrl.\");\n\t\t\tthrow \"Cannot use makeUrl without MyDataHelps.baseUrl.\";\n\t\t}\n\n\t\treturn this.baseUrl + 'api/' + apiVersion + '/delegated/' + endpoint;\n\t}\n\n\tprivate makeRequest(endpoint, method, body, apiVersion = \"v1\") {\n\t\tif (!this.token || !this.token.access_token) {\n\t\t\tthrow \"No access_token available for request authorization.\";\n\t\t}\n\n\t\tlet url = this.makeUrl(endpoint, apiVersion);\n\n\t\tlet headers = new Headers();\n\t\theaders.append('Authorization', 'Bearer ' + this.token.access_token);\n\t\theaders.append('Accept', 'application/json, text/javascript, */*; q=0.01');\n\t\theaders.append('Accept-Language', this.getCurrentLanguage());\n\t\tif (!!body) {\n\t\t\theaders.append('Content-Type', 'application/json');\n\t\t}\n\n\t\tlet init: any = {\n\t\t\tmethod: method,\n\t\t\theaders: headers\n\t\t};\n\t\tif (!!body) {\n\t\t\tinit.body = JSON.stringify(body);\n\t\t}\n\n\t\treturn fetch(url, init);\n\t}\n\n\tprivate getSupportedLanguage(language: string): string {\n\t\tlanguage = language.replace(\"_\", \"-\");\n\t\tif (this.supportedLanguages.length === 0) {\n\t\t\treturn language;\n\t\t} else {\n\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\treturn language;\n\t\t\t} else if (language.indexOf(\"-\") > 0) {\n\t\t\t\tlanguage = language.substring(0, language.indexOf(\"-\"));\n\t\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\t\treturn language;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static validateResponse(response) {\n\t\tif (!response.ok) {\n\t\t\tthrow response.statusText;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprivate static escapeParam(param) {\n\t\treturn String(param)\n\t\t\t.replaceAll(\"\\\\\", \"\\\\\\\\\")\n\t\t\t.replaceAll(\",\", \"\\\\,\");\n\t}\n\n\tprivate static reduceArrayAndEscape(param) {\n\t\tif (Array.isArray(param)) {\n\t\t\tlet escapedParams = param.map(function (elem) {\n\t\t\t\treturn MyDataHelps.escapeParam(elem);\n\t\t\t});\n\t\t\treturn escapedParams.join(\",\");\n\t\t}\n\n\t\treturn this.escapeParam(param);\n\t}\n\n\tprivate static convertDateToIsoString(date) {\n\t\tlet paramAsDate = new Date(date);\n\t\tif (isNaN(paramAsDate.getTime())) {\n\t\t\tthrow \"Cannot interpret parameter as Date\";\n\t\t}\n\n\t\treturn paramAsDate.toISOString();\n\t}\n\n\tprivate static flattenPropertyShallow(params, property) {\n\t\tif (params[property] === undefined || params[property] === null) return;\n\n\t\tfor (var key in params[property]) {\n\t\t\tif (params[property].hasOwnProperty(key)) {\n\t\t\t\tparams[`${property}.${key}`] = MyDataHelps.escapeParam(params[property][key]);\n\t\t\t}\n\t\t}\n\n\t\tdelete params[property];\n\t}\n\n\tprivate startEmbeddedSurveyInternal(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\t\treject(\"Survey already in progress\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\t\tif (message.source !== frame) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t\t} else if (message.data.name === 'SurveyFinished') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\t\tresolve(message.data);\n\t\t\t\t}\n\t\t\t}, true);\n\n\t\t\tlet surveyModal = document.createElement('div');\n\t\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\t\tsurveyModal.id = mdhSurveyModalId;\n\t\t\tsurveyModal.innerHTML = \"<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='\" + surveyUrl + \"'></iframe></div>\";\n\t\t\tdocument.body.append(surveyModal);\n\t\t\tdocument.body.className += ' no-scroll';\n\t\t});\n\t}\n\n\tprivate startDelegatedSurvey(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\treturn;\n\t\t}\n\n\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\tif (message.source !== frame) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (message.data.name === 'GetDelegatedAccessToken') {\n\t\t\t\tmdh.getParticipantInfo().then((participant) => {\n\t\t\t\t\tframe.postMessage({ name: \"DelegatedAccessTokenResponse\", accessToken: mdh.token, baseUrl: mdh.baseUrl, participantID: participant.participantID }, '*');\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyFinished') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\tmessage.data.type = 'surveyDidFinish';\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}, true);\n\n\t\tlet surveyModal = document.createElement('div');\n\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\tsurveyModal.id = mdhSurveyModalId;\n\t\tsurveyModal.innerHTML = `<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${surveyUrl}&lang=${mdh.getCurrentLanguage()}'></iframe></div>`;\n\t\tdocument.body.append(surveyModal);\n\t\tdocument.body.className += ' no-scroll';\n\t}\n\n\tprivate handleConnectExternalAccountResponse() {\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (window.opener && params.get('connectExternalAccount') && params.get('messageID') && params.get('success')) {\n\t\t\twindow.opener.postMessage({\n\t\t\t\tname: 'ConnectExternalAccountResponse',\n\t\t\t\tmessageID: parseInt(params.get('messageID')),\n\t\t\t\tsuccess: params.get('success') === 'true'\n\t\t\t}, window.location.origin);\n\t\t\twindow.close();\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate hasEmbeddedModeUrlParameter() {\n\t\tconst embeddedModeKey = '_e';\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.has(embeddedModeKey) && params.get(embeddedModeKey) !== 'false') {\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n//iOS/Android directly invoke window.MyDataHelps and window.RKStudioClient\n//so it's necessary to explicitly ensure they are present on the window\nconst mdh = new MyDataHelps();\n\nwindow.MyDataHelps = mdh;\n\n// For backwards compatibility\nwindow.RKStudioClient = {};\nwindow.RKStudioClient.setActionResult = function (data) {\n\twindow.MyDataHelps.setActionResult(data);\n};\n\nexport default mdh;\nexport * from './types';\n"],"names":["MyDataHelps","startSurvey","surveyName","this","isStandaloneMode","startDelegatedSurvey","baseUrl","encodeURIComponent","window","webkit","messageHandlers","StartParticipantSurvey","messageID","nextMessageID","postMessage","completeStep","answer","JSON","stringify","ResearchKit","CompleteStep","querySurveyAnswers","queryParameters","Object","assign","hasOwnProperty","reduceArrayAndEscape","stepIdentifier","resultIdentifier","before","convertDateToIsoString","after","endpoint","URLSearchParams","toString","mdh","connect","then","makeRequest","response","validateResponse","json","querySurveyResults","event","insertedBefore","insertedAfter","deleteSurveyResult","resultID","querySurveyTasks","status","queryInboxItems","target","source","key","keys","value","undefined","assignDefined","type","getInboxItem","id","updateInboxItem","update","startEmbeddedSurvey","linkIdentifier","language","getCurrentLanguage","surveyUrl","startEmbeddedSurveyInternal","openExternalUrl","url","OpenExternalLink","openEmbeddedUrl","OpenEmbeddedLink","showTab","tabKey","ShowTab","openApplication","options","OpenExternalApplication","modal","dismiss","Dismiss","back","PopNavigation","showDashboard","dashboardKey","ShowParticipantDashboard","title","showWebVisualization","visualizationKey","parameters","ShowParticipantWebVisualization","showWebVisualizationPdf","ShowParticipantWebVisualizationPDF","landscape","htmlViewerZoom","showProject","projectCode","ShowProject","code","joinProject","JoinProject","on","eventName","callback","supportedEvents","includes","Error","registeredEventHandlers","push","off","eventHandlerIndex","indexOf","splice","triggerEvent","forEach","handler","setActionResult","data","prototype","call","console","error","getParticipantInfo","persistParticipantInfo","demographics","customFields","async","ok","message","catch","log","getProjectInfo","getDeviceDataPoint","deleteDeviceDataPoint","queryDeviceData","observedBefore","observedAfter","persistDeviceData","deviceDataPoints","queryDeviceDataV2","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","enabled","getExternalAccountProviders","search","category","pageSize","pageNumber","searchParameters","connectExternalAccount","externalAccountProviderID","Promise","resolve","reject","connectProviderAccountResponse","success","errorMessage","standaloneMode","standaloneModeFinalRedirectPath","location","href","providerAuthWindow","openNewWindow","split","windowFeatures","width","height","w","h","outerHeight","screenY","outerWidth","screenX","open","queryString","finalRedirectPath","text","redirectUrl","replace","top","ConnectExternalAccount","getExternalAccounts","refreshExternalAccount","accountID","deleteExternalAccount","DeleteProviderAccount","deleteProviderAccountResponse","getFeaturedProviders","context","queryNotifications","sentBefore","sentAfter","queryFitbitDailySummaries","startDate","endDate","queryFitbitSleepLogs","queryAppleHealthActivitySummaries","queryAppleHealthWorkouts","uploadFile","file","fileName","size","name","fetch","preSignedUrl","method","body","headers","queryFiles","getFileDownloadUrl","deleteFile","refreshDelegatedAccessToken","token","refreshTokenPromise","tokenResponse","tokenExpires","Date","now","expires_in","setTimeout","accessTokenRenewalBufferSeconds","GetDelegatedAccessToken","isEmbeddedMode","setParticipantAccessToken","enableStandaloneMode","embeddedMode","setStatusBarStyle","style","SetStatusBarStyle","getDeviceInfo","GetDeviceInfo","deviceInfoResponse","setSupportedLanguages","languages","supportedLanguages","length","i","getStepConfiguration","GetStepConfiguration","stepConfigurationResponse","getSurveyContext","deviceInfo","platform","surveyMode","GetSurveyContext","surveyContextResponse","getCurrentSurveyAnswers","GetCurrentSurveyAnswers","currentSurveyAnswersResponse","setCurrentLanguage","supportedLanguage","getSupportedLanguage","warn","lang","searchParams","has","get","navigator","showGoogleFitSettings","ShowGoogleFitSettings","showHealthConnectSettings","HealthConnectSettings","showHealthConnectPrompt","HealthConnectPrompt","getHealthConnectStatus","HealthConnectStatus","statusResponse","showHealthConnectPhrPrompt","HealthConnectPhrPrompt","getHealthConnectPhrStatus","HealthConnectPhrStatus","requestReview","cooldownDays","RequestReview","trackCustomEvent","getDataCollectionSettings","getDataAvailability","invokeCustomApi","customApi","jsonResponse","toUpperCase","parameterString","constructor","acceptableParentDomains","unsupportedActions","currentMessageID","handleConnectExternalAccountResponse","supportedActions","applicationHost","ancestorOrigins","document","getParentOrigin","acceptableOrigin","origin","sourceURL","URL","k","hostname","endsWith","parent","action","windowHasAnyActions","actions","addActions","addEventListener","validateWindowMessageOrigin","hasEmbeddedModeUrlParameter","makeUrl","apiVersion","access_token","Headers","append","init","find","l","substring","statusText","escapeParam","param","String","replaceAll","Array","isArray","map","elem","join","date","paramAsDate","isNaN","getTime","toISOString","params","property","mdhSurveyModalId","getElementById","listener","frame","contentWindow","className","remove","removeEventListener","surveyModal","createElement","innerHTML","participant","accessToken","participantID","opener","parseInt","close","RKStudioClient"],"mappings":"MAMaA,EASZ,WAAAC,CAAYC,GACX,GAAIC,KAAKC,mBACRD,KAAKE,qBAAqB,GAAGF,KAAKG,6BAA6BC,mBAAmBL,WAE9E,GAAIM,OAAOC,OAAOC,gBAAgBC,uBAAwB,CAC9D,IAAIC,EAAYT,KAAKU,gBACrBL,OAAOC,OAAOC,gBAAgBC,uBAAuBG,YAAY,CAChEF,UAAWA,EACXV,WAAYA,GAEb,CACD,CAED,YAAAa,CAAaC,GAKZ,GAJIA,UAAyCA,EAAS,IAChC,iBAAXA,IACVA,EAASC,KAAKC,UAAUF,IAErBR,OAAOC,OAAOC,gBAAgBS,YACjCX,OAAOC,OAAOC,gBAAgBS,YAAYL,YAAYE,QAElD,GAAIR,OAAOC,OAAOC,gBAAgBU,aA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KAAKyG,OAAO8B,GACrBnD,SAASpF,KAAKoI,WAAa,YAC3B,CAEO,oCAAApD,GACP,MAAM6C,EAAS,IAAIjT,gBAAgBzB,OAAO8J,SAASf,QACnD,GAAI/I,OAAO0V,QAAUhB,EAAO3E,IAAI,2BAA6B2E,EAAO3E,IAAI,cAAgB2E,EAAO3E,IAAI,WAOlG,OANA/P,OAAO0V,OAAOpV,YAAY,CACzBmM,KAAM,iCACNrM,UAAWuV,SAASjB,EAAO3E,IAAI,cAC/BrG,QAAmC,SAA1BgL,EAAO3E,IAAI,YAClB/P,OAAO8J,SAASsI,QACnBpS,OAAO4V,SACA,CAER,CAEO,2BAAA3C,GACP,MACMyB,EAAS,IAAIjT,gBAAgBzB,OAAO8J,SAASf,QACnD,GAAI2L,EAAO5E,IAFa,OAE2C,UAAhC4E,EAAO3E,IAFlB,MAGvB,OAAO,CAER,EAKF,MAAMpO,EAAM,IAAInC,EAEhBQ,OAAOR,YAAcmC,EAGrB3B,OAAO6V,eAAiB,CAAA,EACxB7V,OAAO6V,eAAe/O,gBAAkB,SAAUC,GACjD/G,OAAOR,YAAYsH,gBAAgBC,EACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careevolution/mydatahelps-js",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "MyDataHelps client to be used by external applications for integrations inside the MyDataHelps platform",
5
5
  "type": "module",
6
6
  "types": "MyDataHelps.d.ts",