@careevolution/mydatahelps-js 4.3.0 → 4.4.0
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.d.ts +1 -1
- package/MyDataHelps.js +14 -4
- package/MyDataHelps.min.js +1 -1
- package/MyDataHelps.min.js.map +1 -1
- package/README.md +3 -1
- package/package.json +1 -1
- package/types.d.ts +4 -0
package/MyDataHelps.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class MyDataHelps {
|
|
|
6
6
|
language: string;
|
|
7
7
|
token: Model.Token;
|
|
8
8
|
tokenExpires: number;
|
|
9
|
-
startSurvey(surveyName: string): void;
|
|
9
|
+
startSurvey(surveyName: string, options?: Model.StartSurveyOptions): void;
|
|
10
10
|
completeStep(answer: any): void;
|
|
11
11
|
querySurveyAnswers(queryParameters: Model.SurveyAnswersQuery): Promise<Model.SurveyAnswersPage>;
|
|
12
12
|
querySurveyResults(queryParameters: Model.SurveyResultsQuery): Promise<Model.SurveyResultsPage>;
|
package/MyDataHelps.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
// @ts-ignore : let rollup handle CSS injection
|
|
2
2
|
class MyDataHelps {
|
|
3
3
|
// Surveys
|
|
4
|
-
startSurvey(surveyName) {
|
|
4
|
+
startSurvey(surveyName, options) {
|
|
5
5
|
if (this.isStandaloneMode()) {
|
|
6
|
-
|
|
6
|
+
const params = new URLSearchParams();
|
|
7
|
+
params.set('surveyName', surveyName);
|
|
8
|
+
if (options?.editResultID) {
|
|
9
|
+
params.set('editResultID', options.editResultID);
|
|
10
|
+
}
|
|
11
|
+
if (options?.event) {
|
|
12
|
+
params.set('event', options.event);
|
|
13
|
+
}
|
|
14
|
+
this.startDelegatedSurvey(`${this.baseUrl}/survey?${params.toString()}`);
|
|
7
15
|
}
|
|
8
16
|
else if (window.webkit.messageHandlers.StartParticipantSurvey) {
|
|
9
17
|
let messageID = this.nextMessageID();
|
|
10
18
|
window.webkit.messageHandlers.StartParticipantSurvey.postMessage({
|
|
11
19
|
messageID: messageID,
|
|
12
|
-
surveyName: surveyName
|
|
20
|
+
surveyName: surveyName,
|
|
21
|
+
options: options
|
|
13
22
|
});
|
|
14
23
|
}
|
|
15
24
|
}
|
|
@@ -1441,7 +1450,8 @@ class MyDataHelps {
|
|
|
1441
1450
|
window.parent.postMessage({
|
|
1442
1451
|
name: 'StartParticipantSurvey',
|
|
1443
1452
|
messageID: data.messageID,
|
|
1444
|
-
surveyName: data.surveyName
|
|
1453
|
+
surveyName: data.surveyName,
|
|
1454
|
+
options: data.options
|
|
1445
1455
|
}, applicationHost);
|
|
1446
1456
|
},
|
|
1447
1457
|
"OpenExternalLink": function (data) {
|
package/MyDataHelps.min.js
CHANGED
|
@@ -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}`,a=this;return this.connect().then((function(){return a.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(){}))}getDeviceDataAllDataTypes(t,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`;return this.connect().then((()=>this.makeRequest(a,"GET",null))).then(e.validateResponse).then((e=>e.json()))}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,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`,r=this;return this.connect().then((function(){return r.makeRequest(a,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getExternalAccountProviders(t,n,s,a){let r={};t&&(r.search=t),n&&(r.category=n),s&&(r.pageSize=s),a&&(r.pageNumber=a);const o="externalaccountproviders?"+new URLSearchParams(r).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(((a,r)=>{const o=t.nextMessageID();if(t.messageHandlers[o]=function(e){e&&e.success?a():r(e.errorMessage)},this.standaloneMode){let t=s?.standaloneModeFinalRedirectPath||window.location.href;const a=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 a.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){r(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 a=s.nextMessageID();s.messageHandlers[a]=function(t){t.success?e(t):n(t)},window.webkit.messageHandlers.DeleteProviderAccount.postMessage({messageID:a,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 a=this,r="files?category="+n+"&fileName="+encodeURIComponent(s??t.name);return this.connect().then((function(){return a.makeRequest(r,"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 a=e.nextMessageID();e.messageHandlers[a]=function(r){r.success?(e.tokenExpires=Date.now()+1e3*r.data.expires_in,e.token=r.data,e.baseUrl=r.baseUrl,setTimeout(t,1e3*(r.data.expires_in-e.accessTokenRenewalBufferSeconds)),n(null)):(e.token=null,s(r.message)),e.messageHandlers[a]=null,e.refreshTokenPromise=null},window.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({messageID:a})}))};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,a){if(t.includes("?"))throw new Error('Cannot include query parameters directly in the "customApi" string. Provide as an argument for "queryParameters" instead.');let r="custom/"+t;if(n=n.toUpperCase(),null!=s&&("GET"===n||"DELETE"===n)){let e=new URLSearchParams(s).toString();r+="?"+e,s=null}const o=this;return this.connect().then((function(){return o.makeRequest(r,n,s)})).then((function(t){return e.validateResponse(t)})).then((function(e){return a?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 a=this.makeUrl(e,s),r=new Headers;r.append("Authorization","Bearer "+this.token.access_token),r.append("Accept","application/json, text/javascript, */*; q=0.01"),r.append("Accept-Language",this.getCurrentLanguage()),n&&r.append("Content-Type","application/json");let o={method:t,headers:r};return n&&(o.body=JSON.stringify(n)),fetch(a,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,a){if(document.getElementById(t))return void a("Survey already in progress");window.addEventListener("message",(function e(a){if(a.origin!==new URL(n.baseUrl).origin)return;let r=document.getElementById("mydatahelps-survey-frame").contentWindow;a.source===r&&("SurveyWindowInitialized"===a.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===a.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s(a.data)))}),!0);let r=document.createElement("div");r.className="mydatahelps-survey-modal",r.id=t,r.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(r),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 a=document.getElementById("mydatahelps-survey-frame").contentWindow;s.source===a&&("GetDelegatedAccessToken"===s.data.name?n.getParticipantInfo().then((e=>{a.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,t){if(this.isStandaloneMode()){const n=new URLSearchParams;n.set("surveyName",e),t?.editResultID&&n.set("editResultID",t.editResultID),t?.event&&n.set("event",t.event),this.startDelegatedSurvey(`${this.baseUrl}/survey?${n.toString()}`)}else if(window.webkit.messageHandlers.StartParticipantSurvey){let n=this.nextMessageID();window.webkit.messageHandlers.StartParticipantSurvey.postMessage({messageID:n,surveyName:e,options:t})}}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}`,a=this;return this.connect().then((function(){return a.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(){}))}getDeviceDataAllDataTypes(t,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`;return this.connect().then((()=>this.makeRequest(a,"GET",null))).then(e.validateResponse).then((e=>e.json()))}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,n){const s={};void 0!==t&&(s.enabled=t.toString()),n&&(s.namespace=n);const a=`devicedata/allDataTypes?${new URLSearchParams(s).toString()}`,r=this;return this.connect().then((function(){return r.makeRequest(a,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getExternalAccountProviders(t,n,s,a){let r={};t&&(r.search=t),n&&(r.category=n),s&&(r.pageSize=s),a&&(r.pageNumber=a);const o="externalaccountproviders?"+new URLSearchParams(r).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(((a,r)=>{const o=t.nextMessageID();if(t.messageHandlers[o]=function(e){e&&e.success?a():r(e.errorMessage)},this.standaloneMode){let t=s?.standaloneModeFinalRedirectPath||window.location.href;const a=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 a.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){r(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 a=s.nextMessageID();s.messageHandlers[a]=function(t){t.success?e(t):n(t)},window.webkit.messageHandlers.DeleteProviderAccount.postMessage({messageID:a,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 a=this,r="files?category="+n+"&fileName="+encodeURIComponent(s??t.name);return this.connect().then((function(){return a.makeRequest(r,"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 a=e.nextMessageID();e.messageHandlers[a]=function(r){r.success?(e.tokenExpires=Date.now()+1e3*r.data.expires_in,e.token=r.data,e.baseUrl=r.baseUrl,setTimeout(t,1e3*(r.data.expires_in-e.accessTokenRenewalBufferSeconds)),n(null)):(e.token=null,s(r.message)),e.messageHandlers[a]=null,e.refreshTokenPromise=null},window.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({messageID:a})}))};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,a){if(t.includes("?"))throw new Error('Cannot include query parameters directly in the "customApi" string. Provide as an argument for "queryParameters" instead.');let r="custom/"+t;if(n=n.toUpperCase(),null!=s&&("GET"===n||"DELETE"===n)){let e=new URLSearchParams(s).toString();r+="?"+e,s=null}const o=this;return this.connect().then((function(){return o.makeRequest(r,n,s)})).then((function(t){return e.validateResponse(t)})).then((function(e){return a?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,options:e.options},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 a=this.makeUrl(e,s),r=new Headers;r.append("Authorization","Bearer "+this.token.access_token),r.append("Accept","application/json, text/javascript, */*; q=0.01"),r.append("Accept-Language",this.getCurrentLanguage()),n&&r.append("Content-Type","application/json");let o={method:t,headers:r};return n&&(o.body=JSON.stringify(n)),fetch(a,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,a){if(document.getElementById(t))return void a("Survey already in progress");window.addEventListener("message",(function e(a){if(a.origin!==new URL(n.baseUrl).origin)return;let r=document.getElementById("mydatahelps-survey-frame").contentWindow;a.source===r&&("SurveyWindowInitialized"===a.data.name?document.getElementById(t).className+=" loaded":"SurveyFinished"===a.data.name&&(document.getElementById(t).remove(),document.body.className=document.body.className.replace("no-scroll",""),window.removeEventListener("message",e,!0),s(a.data)))}),!0);let r=document.createElement("div");r.className="mydatahelps-survey-modal",r.id=t,r.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(r),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 a=document.getElementById("mydatahelps-survey-frame").contentWindow;s.source===a&&("GetDelegatedAccessToken"===s.data.name?n.getParticipantInfo().then((e=>{a.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
|
package/MyDataHelps.min.js.map
CHANGED
|
@@ -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\tgetDeviceDataAllDataTypes(enabled?: boolean, namespace?: string): Promise<Model.SupportedDeviceDataType[]> {\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\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${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\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, namespace?: string): 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\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\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","getDeviceDataAllDataTypes","enabled","namespace","queryDeviceDataV2","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","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,KAAK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AA3C,GACP,MACMyB,EAAS,IAAInT,gBAAgBzB,OAAOgK,SAASf,QACnD,GAAI2L,EAAO5E,IAFa,OAE2C,UAAhC4E,EAAO3E,IAFlB,MAGvB,OAAO,CAER,EAKF,MAAMtO,EAAM,IAAInC,EAEhBQ,OAAOR,YAAcmC,EAGrB3B,OAAO+V,eAAiB,CAAA,EACxB/V,OAAO+V,eAAejP,gBAAkB,SAAUC,GACjD/G,OAAOR,YAAYsH,gBAAgBC,EACpC"}
|
|
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, options?: Model.StartSurveyOptions): void {\n\t\tif (this.isStandaloneMode()) {\n\t\t\tconst params = new URLSearchParams();\n\t\t\tparams.set('surveyName', surveyName);\n\t\t\tif (options?.editResultID) {\n\t\t\t\tparams.set('editResultID', options.editResultID);\n\t\t\t}\n\t\t\tif (options?.event) {\n\t\t\t\tparams.set('event', options.event);\n\t\t\t}\n\t\t\tthis.startDelegatedSurvey(`${this.baseUrl}/survey?${params.toString()}`);\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\toptions: options\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\tgetDeviceDataAllDataTypes(enabled?: boolean, namespace?: string): Promise<Model.SupportedDeviceDataType[]> {\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\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${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\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, namespace?: string): 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\tif (namespace) {\n\t\t\tqueryParameters['namespace'] = namespace;\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\toptions: data.options\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","options","this","isStandaloneMode","params","URLSearchParams","set","editResultID","event","startDelegatedSurvey","baseUrl","toString","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","mdh","connect","then","makeRequest","response","validateResponse","json","querySurveyResults","insertedBefore","insertedAfter","deleteSurveyResult","resultID","encodeURIComponent","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","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","getDeviceDataAllDataTypes","enabled","namespace","queryDeviceDataV2","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","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","property","mdhSurveyModalId","getElementById","listener","frame","contentWindow","className","remove","removeEventListener","surveyModal","createElement","innerHTML","participant","accessToken","participantID","opener","parseInt","close","RKStudioClient"],"mappings":"MAMaA,EASZ,WAAAC,CAAYC,EAAoBC,GAC/B,GAAIC,KAAKC,mBAAoB,CAC5B,MAAMC,EAAS,IAAIC,gBACnBD,EAAOE,IAAI,aAAcN,GACrBC,GAASM,cACZH,EAAOE,IAAI,eAAgBL,EAAQM,cAEhCN,GAASO,OACZJ,EAAOE,IAAI,QAASL,EAAQO,OAE7BN,KAAKO,qBAAqB,GAAGP,KAAKQ,kBAAkBN,EAAOO,aAC3D,MACI,GAAIC,OAAOC,OAAOC,gBAAgBC,uBAAwB,CAC9D,IAAIC,EAAYd,KAAKe,gBACrBL,OAAOC,OAAOC,gBAAgBC,uBAAuBG,YAAY,CAChEF,UAAWA,EACXhB,WAAYA,EACZC,QAASA,GAEV,CACD,CAED,YAAAkB,CAAaC,GAKZ,GAJIA,UAAyCA,EAAS,IAChC,iBAAXA,IACVA,EAASC,KAAKC,UAAUF,IAErBR,OAAOC,OAAOC,gBAAgBS,YACjCX,OAAOC,OAAOC,gBAAgBS,YAAYL,YAAYE,QAElD,GAAIR,OAAOC,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AAkB,SAAUC,GACjD5G,OAAOd,YAAYyH,gBAAgBC,EACpC"}
|
package/README.md
CHANGED
|
@@ -12,4 +12,6 @@ Visit the [CareEvolution's MyDataHelps Developer Center](https://developer.mydat
|
|
|
12
12
|
|
|
13
13
|
To get started with MyDataHelps.js, see the [SDK Documentation](https://developer.mydatahelps.org/sdk/).
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Internal Wiki
|
|
16
|
+
|
|
17
|
+
CE developers: See [wiki](https://github.com/CareEvolution/MyDataHelps.js/wiki) for instructions on testing, releasing a new version, etc.
|
package/package.json
CHANGED