@careevolution/mydatahelps-js 3.36.0 → 4.0.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 CHANGED
@@ -9,6 +9,7 @@ export declare class MyDataHelps {
9
9
  startSurvey(surveyName: string): void;
10
10
  completeStep(answer: any): void;
11
11
  querySurveyAnswers(queryParameters: Model.SurveyAnswersQuery): Promise<Model.SurveyAnswersPage>;
12
+ querySurveyResults(queryParameters: Model.SurveyResultsQuery): Promise<Model.SurveyResultsPage>;
12
13
  deleteSurveyResult(resultID: string): Promise<void>;
13
14
  querySurveyTasks(queryParameters: Model.SurveyTaskQueryParameters): Promise<Model.SurveyTasksPage>;
14
15
  queryInboxItems(queryParameters: Model.InboxItemQueryParameters): Promise<Model.InboxItemsPage>;
package/MyDataHelps.js CHANGED
@@ -1,30 +1,4 @@
1
- /******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- /* global Reflect, Promise */
16
-
17
-
18
- function __awaiter(thisArg, _arguments, P, generator) {
19
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
- return new (P || (P = Promise))(function (resolve, reject) {
21
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
- step((generator = generator.apply(thisArg, [])).next());
25
- });
26
- }
27
-
1
+ // @ts-ignore : let rollup handle CSS injection
28
2
  class MyDataHelps {
29
3
  // Surveys
30
4
  startSurvey(surveyName) {
@@ -91,6 +65,33 @@ class MyDataHelps {
91
65
  return response.json();
92
66
  });
93
67
  }
68
+ querySurveyResults(queryParameters) {
69
+ queryParameters = { ...queryParameters };
70
+ if (queryParameters.hasOwnProperty("surveyName")) {
71
+ queryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);
72
+ }
73
+ if (queryParameters.hasOwnProperty("event")) {
74
+ queryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);
75
+ }
76
+ if (queryParameters.hasOwnProperty("before")) {
77
+ queryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);
78
+ }
79
+ if (queryParameters.hasOwnProperty("after")) {
80
+ queryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);
81
+ }
82
+ if (queryParameters.hasOwnProperty("insertedBefore")) {
83
+ queryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);
84
+ }
85
+ if (queryParameters.hasOwnProperty("insertedAfter")) {
86
+ queryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);
87
+ }
88
+ const queryString = new URLSearchParams(queryParameters).toString();
89
+ const endpoint = 'surveyresults?' + queryString;
90
+ return this.connect()
91
+ .then(() => this.makeRequest(endpoint, 'GET', null))
92
+ .then(MyDataHelps.validateResponse)
93
+ .then(response => response.json());
94
+ }
94
95
  deleteSurveyResult(resultID) {
95
96
  const endpoint = 'surveyresults/' + encodeURIComponent(resultID);
96
97
  const mdh = this;
@@ -335,14 +336,12 @@ class MyDataHelps {
335
336
  .then(function () {
336
337
  return mdh.makeRequest(endpoint, 'PUT', { demographics, customFields });
337
338
  })
338
- .then(function (response) {
339
- return __awaiter(this, void 0, void 0, function* () {
340
- if (!response.ok) {
341
- var errorJson = yield response.json();
342
- throw errorJson.message;
343
- }
344
- return response.json();
345
- });
339
+ .then(async function (response) {
340
+ if (!response.ok) {
341
+ var errorJson = await response.json();
342
+ throw errorJson.message;
343
+ }
344
+ return response.json();
346
345
  })
347
346
  .catch(function (error) {
348
347
  console.log("Unable to persist participant: " + error);
@@ -608,16 +607,16 @@ class MyDataHelps {
608
607
  }
609
608
  };
610
609
  if (this.standaloneMode) {
611
- let standaloneModeFinalRedirectPath = (options === null || options === void 0 ? void 0 : options.standaloneModeFinalRedirectPath) || window.location.href;
610
+ let standaloneModeFinalRedirectPath = options?.standaloneModeFinalRedirectPath || window.location.href;
612
611
  const mdh = this;
613
612
  // DEV: Safari blocks popups in AJAX responses. Work-around is to open a blank window before the request and set the URL later
614
613
  let providerAuthWindow;
615
- if (options === null || options === void 0 ? void 0 : options.openNewWindow) {
614
+ if (options?.openNewWindow) {
616
615
  standaloneModeFinalRedirectPath = `${standaloneModeFinalRedirectPath.split('?')[0]}?connectExternalAccount=true&messageID=${messageID}&success=%SUCCESSVALUE%`;
617
616
  let windowFeatures = null;
618
- if ((options === null || options === void 0 ? void 0 : options.width) && (options === null || options === void 0 ? void 0 : options.height)) {
619
- const w = options === null || options === void 0 ? void 0 : options.width;
620
- const h = options === null || options === void 0 ? void 0 : options.height;
617
+ if (options?.width && options?.height) {
618
+ const w = options?.width;
619
+ const h = options?.height;
621
620
  const y = window.outerHeight / 2 + window.screenY - (h / 2);
622
621
  const x = window.outerWidth / 2 + window.screenX - (w / 2);
623
622
  windowFeatures = "width=" + w + ",height=" + h + ",top=" + y + ",left=" + x;
@@ -651,7 +650,11 @@ class MyDataHelps {
651
650
  });
652
651
  }
653
652
  else if (window.webkit.messageHandlers.ConnectExternalAccount) {
654
- window.webkit.messageHandlers.ConnectExternalAccount.postMessage(Object.assign({ externalAccountProviderID: externalAccountProviderID, messageID: messageID }, options));
653
+ window.webkit.messageHandlers.ConnectExternalAccount.postMessage({
654
+ externalAccountProviderID: externalAccountProviderID,
655
+ messageID: messageID,
656
+ ...options
657
+ });
655
658
  }
656
659
  });
657
660
  }
@@ -843,7 +846,7 @@ class MyDataHelps {
843
846
  throw new Error("File size exceeds the maximum allowed size of 200MB.");
844
847
  }
845
848
  const mdh = this;
846
- const endpoint = 'files?category=' + category + '&fileName=' + encodeURIComponent(fileName !== null && fileName !== void 0 ? fileName : file.name);
849
+ const endpoint = 'files?category=' + category + '&fileName=' + encodeURIComponent(fileName ?? file.name);
847
850
  return this
848
851
  .connect()
849
852
  .then(function () {
@@ -1,2 +1,2 @@
1
- function e(e,t,n,s){return new(n||(n=Promise))((function(t,a){function r(e){try{i(s.next(e))}catch(e){a(e)}}function o(e){try{i(s.throw(e))}catch(e){a(e)}}function i(e){var s;e.done?t(e.value):(s=e.value,s instanceof n?s:new n((function(e){e(s)}))).then(r,o)}i((s=s.apply(e,[])).next())}))}class t{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(e){(e=Object.assign({},e)).hasOwnProperty("surveyName")&&(e.surveyName=t.reduceArrayAndEscape(e.surveyName)),e.hasOwnProperty("stepIdentifier")&&(e.stepIdentifier=t.reduceArrayAndEscape(e.stepIdentifier)),e.hasOwnProperty("resultIdentifier")&&(e.resultIdentifier=t.reduceArrayAndEscape(e.resultIdentifier)),e.hasOwnProperty("answer")&&(e.answer=t.reduceArrayAndEscape(e.answer)),e.hasOwnProperty("before")&&(e.before=t.convertDateToIsoString(e.before)),e.hasOwnProperty("after")&&(e.after=t.convertDateToIsoString(e.after));const n="surveyanswers?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}deleteSurveyResult(e){const n="surveyresults/"+encodeURIComponent(e),s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(e){return t.validateResponse(e)})).then((function(){}))}querySurveyTasks(e){(e=Object.assign({},e)).hasOwnProperty("status")&&(e.status=t.reduceArrayAndEscape(e.status)),e.hasOwnProperty("surveyName")&&(e.surveyName=t.reduceArrayAndEscape(e.surveyName));const n="surveytasks?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}queryInboxItems(e){(e=((e,t)=>{for(const n of Object.keys(t)){const s=t[n];void 0!==s&&(e[n]=s)}return e})({},e)).hasOwnProperty("type")&&(e.type=t.reduceArrayAndEscape(e.type)),e.hasOwnProperty("status")&&(e.status=t.reduceArrayAndEscape(e.status));const n="inbox?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}getInboxItem(e){const n=`inbox/${e}`,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}updateInboxItem(e,n){const s=`inbox/${e}/${n}`,a=this;return this.connect().then((function(){return a.makeRequest(s,"PUT",null)})).then((function(e){return t.validateResponse(e)})).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 e=this;return this.connect().then((function(){return e.makeRequest("participant","GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}persistParticipantInfo(t,n){const s=this;return this.connect().then((function(){return s.makeRequest("participant","PUT",{demographics:t,customFields:n})})).then((function(t){return e(this,0,void 0,(function*(){if(!t.ok)throw(yield t.json()).message;return t.json()}))})).catch((function(e){console.log("Unable to persist participant: "+e)}))}getProjectInfo(){const e=this;return this.connect().then((function(){return e.makeRequest("project","GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}getDeviceDataPoint(e){const n="devicedata/"+e,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}deleteDeviceDataPoint(e){const n="devicedata/"+e,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(e){return t.validateResponse(e)})).then((function(){}))}queryDeviceData(e){(e=Object.assign({},e)).hasOwnProperty("type")&&(e.type=t.reduceArrayAndEscape(e.type)),e.hasOwnProperty("observedBefore")&&(e.observedBefore=t.convertDateToIsoString(e.observedBefore)),e.hasOwnProperty("observedAfter")&&(e.observedAfter=t.convertDateToIsoString(e.observedAfter));const n="devicedata?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}persistDeviceData(e){const n=this;return this.connect().then((function(){return n.makeRequest("devicedata","POST",e)})).then((function(e){return t.validateResponse(e)})).then((function(){}))}queryDeviceDataV2(e){(e=Object.assign({},e)).hasOwnProperty("observedBefore")&&(e.observedBefore=t.convertDateToIsoString(e.observedBefore)),e.hasOwnProperty("observedAfter")&&(e.observedAfter=t.convertDateToIsoString(e.observedAfter)),e.hasOwnProperty("insertedBefore")&&(e.insertedBefore=t.convertDateToIsoString(e.insertedBefore)),e.hasOwnProperty("insertedAfter")&&(e.insertedAfter=t.convertDateToIsoString(e.insertedAfter)),e.hasOwnProperty("modifiedBefore")&&(e.modifiedBefore=t.convertDateToIsoString(e.modifiedBefore)),e.hasOwnProperty("modifiedAfter")&&(e.modifiedAfter=t.convertDateToIsoString(e.modifiedAfter)),t.flattenPropertyShallow(e,"dataSource"),t.flattenPropertyShallow(e,"properties");const n="devicedata?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}queryDeviceDataV2Aggregate(e){(e=Object.assign({},e)).hasOwnProperty("aggregateFunctions")&&(e.aggregateFunctions=t.reduceArrayAndEscape(e.aggregateFunctions)),e.hasOwnProperty("observedBefore")&&(e.observedBefore=t.convertDateToIsoString(e.observedBefore)),e.hasOwnProperty("observedAfter")&&(e.observedAfter=t.convertDateToIsoString(e.observedAfter)),e.hasOwnProperty("insertedBefore")&&(e.insertedBefore=t.convertDateToIsoString(e.insertedBefore)),e.hasOwnProperty("insertedAfter")&&(e.insertedAfter=t.convertDateToIsoString(e.insertedAfter)),e.hasOwnProperty("modifiedBefore")&&(e.modifiedBefore=t.convertDateToIsoString(e.modifiedBefore)),e.hasOwnProperty("modifiedAfter")&&(e.modifiedAfter=t.convertDateToIsoString(e.modifiedAfter)),t.flattenPropertyShallow(e,"dataSource"),t.flattenPropertyShallow(e,"properties");const n="devicedata/aggregate?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}queryDeviceDataV2DailySleep(e){(e=Object.assign({},e)).hasOwnProperty("observedBefore")&&(e.observedBefore=t.convertDateToIsoString(e.observedBefore)),e.hasOwnProperty("observedAfter")&&(e.observedAfter=t.convertDateToIsoString(e.observedAfter)),e.hasOwnProperty("insertedBefore")&&(e.insertedBefore=t.convertDateToIsoString(e.insertedBefore)),e.hasOwnProperty("insertedAfter")&&(e.insertedAfter=t.convertDateToIsoString(e.insertedAfter)),e.hasOwnProperty("modifiedBefore")&&(e.modifiedBefore=t.convertDateToIsoString(e.modifiedBefore)),e.hasOwnProperty("modifiedAfter")&&(e.modifiedAfter=t.convertDateToIsoString(e.modifiedAfter)),t.flattenPropertyShallow(e,"dataSource"),t.flattenPropertyShallow(e,"properties");const n="devicedata/aggregate/dailysleep?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}getDeviceDataV2AllDataTypes(e){const n={};void 0!==e&&(n.enabled=e.toString());const s=`devicedata/allDataTypes?${new URLSearchParams(n).toString()}`,a=this;return this.connect().then((function(){return a.makeRequest(s,"GET",null,"v2")})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}getExternalAccountProviders(e,n,s,a){let r={};e&&(r.search=e),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(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}connectExternalAccount(e,s){return new Promise(((a,r)=>{const o=n.nextMessageID();if(n.messageHandlers[o]=function(e){e&&e.success?a():r(e.errorMessage)},this.standaloneMode){let n=(null==s?void 0:s.standaloneModeFinalRedirectPath)||window.location.href;const a=this;let i;if(null==s?void 0:s.openNewWindow){n=`${n.split("?")[0]}?connectExternalAccount=true&messageID=${o}&success=%SUCCESSVALUE%`;let e=null;if((null==s?void 0:s.width)&&(null==s?void 0:s.height)){const t=null==s?void 0:s.width,n=null==s?void 0: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:n}).toString(),c="externalaccountproviders/"+e+"/connect?"+d;this.connect().then((function(){return a.makeRequest(c,"POST",null)})).then((function(e){return t.validateResponse(e)})).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(Object.assign({externalAccountProviderID:e,messageID:o},s))}))}getExternalAccounts(){const e=this;return this.connect().then((function(){return e.makeRequest("externalaccounts","GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}refreshExternalAccount(e){const n="externalaccounts/refresh/"+e,s=this;return this.connect().then((function(){return s.makeRequest(n,"POST",null)})).then((function(e){return t.validateResponse(e)})).then((function(){}))}deleteExternalAccount(e){const n="externalaccounts/delete/"+encodeURIComponent(e),s=this;return this.isStandaloneMode()?this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(e){return t.validateResponse(e)})):new Promise((function(t,n){if(window.webkit.messageHandlers.DeleteProviderAccount){const a=s.nextMessageID();s.messageHandlers[a]=function(e){e.success?t(e):n(e)},window.webkit.messageHandlers.DeleteProviderAccount.postMessage({messageID:a,accountID:e})}else n()}))}queryNotifications(e){(e=Object.assign({},e)).hasOwnProperty("sentBefore")&&(e.sentBefore=t.convertDateToIsoString(e.sentBefore)),e.hasOwnProperty("sentAfter")&&(e.sentAfter=t.convertDateToIsoString(e.sentAfter));const n="notifications?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}queryFitbitDailySummaries(e){(e=Object.assign({},e)).hasOwnProperty("startDate")&&(e.startDate=t.convertDateToIsoString(e.startDate)),e.hasOwnProperty("endDate")&&(e.endDate=t.convertDateToIsoString(e.endDate));const n="fitbit/dailySummaries?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}queryFitbitSleepLogs(e){(e=Object.assign({},e)).hasOwnProperty("startDate")&&(e.startDate=t.convertDateToIsoString(e.startDate)),e.hasOwnProperty("endDate")&&(e.endDate=t.convertDateToIsoString(e.endDate));const n="fitbit/sleepLogs?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}queryAppleHealthActivitySummaries(e){(e=Object.assign({},e)).hasOwnProperty("startDate")&&(e.startDate=t.convertDateToIsoString(e.startDate)),e.hasOwnProperty("endDate")&&(e.endDate=t.convertDateToIsoString(e.endDate));const n="appleHealth/activitySummaries?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}queryAppleHealthWorkouts(e){(e=Object.assign({},e)).hasOwnProperty("startDate")&&(e.startDate=t.convertDateToIsoString(e.startDate)),e.hasOwnProperty("endDate")&&(e.endDate=t.convertDateToIsoString(e.endDate));const n="appleHealth/workouts?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}uploadFile(e,n,s){if(e.size>209715200)throw new Error("File size exceeds the maximum allowed size of 200MB.");const a=this,r="files?category="+n+"&fileName="+encodeURIComponent(null!=s?s:e.name);return this.connect().then((function(){return a.makeRequest(r,"POST",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()})).then((function(t){return fetch(t.preSignedUrl,{method:"PUT",body:e,headers:{"Content-Type":e.type,"x-amz-server-side-encryption":"AES256"}})})).then((function(e){return t.validateResponse(e)})).then((function(){}))}queryFiles(e){const n="files?"+new URLSearchParams(e).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}getFileDownloadUrl(e){if(!e)throw new Error("Please specify the key of the file to download.");const n="files/download?key="+e,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}deleteFile(e){if(!e)throw new Error("Please specify the key of the file to delete.");const n="files?key="+e,s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(e){return t.validateResponse(e)})).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(e){const n=this;return this.connect().then((function(){return n.makeRequest("customevents","POST",e)})).then((function(e){return t.validateResponse(e)})).then((function(){}))}getDataCollectionSettings(){const e=this;return this.connect().then((function(){return e.makeRequest("datacollectionsettings","GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}getDataAvailability(){const e=this;return this.connect().then((function(){return e.makeRequest("dataavailability","GET",null)})).then((function(e){return t.validateResponse(e)})).then((function(e){return e.json()}))}invokeCustomApi(e,n,s,a){if(e.includes("?"))throw new Error('Cannot include query parameters directly in the "customApi" string. Provide as an argument for "queryParameters" instead.');let r="custom/"+e;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(e){return t.validateResponse(e)})).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(e){if(Array.isArray(e)){return e.map((function(e){return t.escapeParam(e)})).join(",")}return this.escapeParam(e)}static convertDateToIsoString(e){let t=new Date(e);if(isNaN(t.getTime()))throw"Cannot interpret parameter as Date";return t.toISOString()}static flattenPropertyShallow(e,n){if(void 0!==e[n]&&null!==e[n]){for(var s in e[n])e[n].hasOwnProperty(s)&&(e[`${n}.${s}`]=t.escapeParam(e[n][s]));delete e[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 n=new t;window.MyDataHelps=n,window.RKStudioClient={},window.RKStudioClient.setActionResult=function(e){window.MyDataHelps.setActionResult(e)};export{t as MyDataHelps,n as default};
1
+ class e{startSurvey(e){if(this.isStandaloneMode())this.startDelegatedSurvey(`${this.baseUrl}/survey?surveyName=${encodeURIComponent(e)}`);else if(window.webkit.messageHandlers.StartParticipantSurvey){let t=this.nextMessageID();window.webkit.messageHandlers.StartParticipantSurvey.postMessage({messageID:t,surveyName:e})}}completeStep(e){if(null==e&&(e=""),"string"!=typeof e&&(e=JSON.stringify(e)),window.webkit.messageHandlers.ResearchKit)window.webkit.messageHandlers.ResearchKit.postMessage(e);else if(window.webkit.messageHandlers.CompleteStep){let t=this.nextMessageID();window.webkit.messageHandlers.CompleteStep.postMessage({messageID:t,answer:e})}}querySurveyAnswers(t){(t=Object.assign({},t)).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("stepIdentifier")&&(t.stepIdentifier=e.reduceArrayAndEscape(t.stepIdentifier)),t.hasOwnProperty("resultIdentifier")&&(t.resultIdentifier=e.reduceArrayAndEscape(t.resultIdentifier)),t.hasOwnProperty("answer")&&(t.answer=e.reduceArrayAndEscape(t.answer)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after));const n="surveyanswers?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}querySurveyResults(t){(t={...t}).hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName)),t.hasOwnProperty("event")&&(t.event=e.reduceArrayAndEscape(t.event)),t.hasOwnProperty("before")&&(t.before=e.convertDateToIsoString(t.before)),t.hasOwnProperty("after")&&(t.after=e.convertDateToIsoString(t.after)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter));const n="surveyresults?"+new URLSearchParams(t).toString();return this.connect().then((()=>this.makeRequest(n,"GET",null))).then(e.validateResponse).then((e=>e.json()))}deleteSurveyResult(t){const n="surveyresults/"+encodeURIComponent(t),s=this;return this.connect().then((function(){return s.makeRequest(n,"DELETE",null)})).then((function(t){return e.validateResponse(t)})).then((function(){}))}querySurveyTasks(t){(t=Object.assign({},t)).hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status)),t.hasOwnProperty("surveyName")&&(t.surveyName=e.reduceArrayAndEscape(t.surveyName));const n="surveytasks?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryInboxItems(t){(t=((e,t)=>{for(const n of Object.keys(t)){const s=t[n];void 0!==s&&(e[n]=s)}return e})({},t)).hasOwnProperty("type")&&(t.type=e.reduceArrayAndEscape(t.type)),t.hasOwnProperty("status")&&(t.status=e.reduceArrayAndEscape(t.status));const n="inbox?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getInboxItem(t){const n=`inbox/${t}`,s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null)})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}updateInboxItem(t,n){const s=`inbox/${t}/${n}`,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(){}))}queryDeviceDataV2(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2Aggregate(t){(t=Object.assign({},t)).hasOwnProperty("aggregateFunctions")&&(t.aggregateFunctions=e.reduceArrayAndEscape(t.aggregateFunctions)),t.hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}queryDeviceDataV2DailySleep(t){(t=Object.assign({},t)).hasOwnProperty("observedBefore")&&(t.observedBefore=e.convertDateToIsoString(t.observedBefore)),t.hasOwnProperty("observedAfter")&&(t.observedAfter=e.convertDateToIsoString(t.observedAfter)),t.hasOwnProperty("insertedBefore")&&(t.insertedBefore=e.convertDateToIsoString(t.insertedBefore)),t.hasOwnProperty("insertedAfter")&&(t.insertedAfter=e.convertDateToIsoString(t.insertedAfter)),t.hasOwnProperty("modifiedBefore")&&(t.modifiedBefore=e.convertDateToIsoString(t.modifiedBefore)),t.hasOwnProperty("modifiedAfter")&&(t.modifiedAfter=e.convertDateToIsoString(t.modifiedAfter)),e.flattenPropertyShallow(t,"dataSource"),e.flattenPropertyShallow(t,"properties");const n="devicedata/aggregate/dailysleep?"+new URLSearchParams(t).toString(),s=this;return this.connect().then((function(){return s.makeRequest(n,"GET",null,"v2")})).then((function(t){return e.validateResponse(t)})).then((function(e){return e.json()}))}getDeviceDataV2AllDataTypes(t){const n={};void 0!==t&&(n.enabled=t.toString());const s=`devicedata/allDataTypes?${new URLSearchParams(n).toString()}`,a=this;return this.connect().then((function(){return a.makeRequest(s,"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()}))}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};
2
2
  //# sourceMappingURL=MyDataHelps.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MyDataHelps.min.js","sources":["../../node_modules/tslib/tslib.es6.js","../../src/MyDataHelps.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","// @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\tdeleteSurveyResult(resultID: string): Promise<void> {\n\t\tconst endpoint = 'surveyresults/' + encodeURIComponent(resultID);\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tquerySurveyTasks(queryParameters: Model.SurveyTaskQueryParameters): Promise<Model.SurveyTasksPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.SurveyTaskStatus;\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveytasks?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryInboxItems(queryParameters: Model.InboxItemQueryParameters): Promise<Model.InboxItemsPage> {\n\t\tconst assignDefined = (target: any, source: any): any => {\n\t\t\tfor (const key of Object.keys(source)) {\n\t\t\t\tconst value = source[key];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\ttarget[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tqueryParameters = assignDefined({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type) as Model.InboxItemType;\n\t\t}\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.InboxItemStatus;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'inbox?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetInboxItem(id: Model.Guid): Promise<Model.InboxItem> {\n\t\tconst endpoint = `inbox/${id}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tupdateInboxItem(id: Model.Guid, update: Model.InboxItemUpdate): Promise<Model.InboxItemUpdateResult> {\n\t\tconst endpoint = `inbox/${id}/${update}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tstartEmbeddedSurvey(linkIdentifier: string, surveyName: string, language: string): Promise<any> {\n\t\tif (!language) {\n\t\t\tlanguage = this.getCurrentLanguage();\n\t\t}\n\t\tlet surveyUrl = this.baseUrl + \"mydatahelps/\" + linkIdentifier + '/surveylink/' + surveyName + \"?lang=\" + language;\n\t\treturn this.startEmbeddedSurveyInternal(surveyUrl);\n\t}\n\n\t// Navigation\n\n\topenExternalUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalLink) {\n\t\t\twindow.webkit.messageHandlers.OpenExternalLink.postMessage(url);\n\t\t}\n\t}\n\n\topenEmbeddedUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenEmbeddedLink) {\n\t\t\twindow.webkit.messageHandlers.OpenEmbeddedLink.postMessage(url);\n\t\t}\n\t}\n\n\tshowTab(tabKey: string): void {\n\t\tif (window.webkit.messageHandlers.ShowTab) {\n\t\t\twindow.webkit.messageHandlers.ShowTab.postMessage(tabKey);\n\t\t}\n\t}\n\n\topenApplication(url: string, options?: Model.OpenApplicationOptions): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalApplication) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.OpenExternalApplication.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\turl: url,\n\t\t\t\tmodal: !!(options && options.modal)\n\t\t\t});\n\t\t}\n\t}\n\n\tdismiss(): void {\n\t\tif (window.webkit.messageHandlers.Dismiss) {\n\t\t\twindow.webkit.messageHandlers.Dismiss.postMessage({});\n\t\t}\n\t}\n\n\tback(): void {\n\t\tif (window.webkit.messageHandlers.PopNavigation) {\n\t\t\twindow.webkit.messageHandlers.PopNavigation.postMessage({});\n\t\t}\n\t}\n\n\tshowDashboard(dashboardKey: string, options?: Model.ShowDashboardOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantDashboard) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantDashboard.postMessage({\n\t\t\t\tdashboardKey: dashboardKey,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualization(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualization) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualizationPdf(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationPdfOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tlandscape: !!(options && options.landscape),\n\t\t\t\thtmlViewerZoom: options && options.htmlViewerZoom\n\t\t\t});\n\t\t}\n\t}\n\n\tshowProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.ShowProject) {\n\t\t\twindow.webkit.messageHandlers.ShowProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\tjoinProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.JoinProject) {\n\t\t\twindow.webkit.messageHandlers.JoinProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\t//Events\n\n\ton(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName] = [];\n\t\t}\n\n\t\tthis.registeredEventHandlers[eventName].push(callback);\n\t}\n\n\toff(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) return;\n\n\t\tlet eventHandlerIndex = this.registeredEventHandlers[eventName].indexOf(callback);\n\n\t\tif (eventHandlerIndex !== -1) {\n\t\t\tthis.registeredEventHandlers[eventName].splice(eventHandlerIndex, 1);\n\t\t}\n\t}\n\n\ttriggerEvent(event: Model.EventData): void {\n\t\tlet eventName = event.type;\n\t\tif (this.supportedEvents.includes(eventName) && this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName].forEach(function (handler) {\n\t\t\t\thandler(event);\n\t\t\t});\n\t\t}\n\t}\n\n\tsetActionResult(data: Model.EventData): void {\n\t\tif (Object.prototype.hasOwnProperty.call(this.messageHandlers, data.messageID) &&\n\t\t\ttypeof this.messageHandlers[data.messageID] === 'function') {\n\t\t\tthis.messageHandlers[data.messageID](data);\n\t\t} else {\n\t\t\tconsole.error(`Invalid messageID: ${data.messageID}`);\n\t\t}\n\t}\n\n\t// Participant Info\n\n\tgetParticipantInfo(): Promise<Model.ParticipantInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'participant';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistParticipantInfo(demographics: Partial<Model.ParticipantDemographics> | undefined, customFields: StringMap): Promise<Model.ParticipantInfo> {\n\t\tconst endpoint = 'participant';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', { demographics, customFields });\n\t\t\t})\n\t\t\t.then(async function (response) {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tvar errorJson = await response.json();\n\t\t\t\t\tthrow errorJson.message;\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.log(\"Unable to persist participant: \" + error);\n\t\t\t});\n\t}\n\n\tgetProjectInfo(): Promise<Model.ProjectInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'project';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Device Data\n\n\tgetDeviceDataPoint(id: Model.Guid): Promise<Model.DeviceDataPoint> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteDeviceDataPoint(id: Model.Guid): Promise<void> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryDeviceData(queryParameters: Model.DeviceDataPointQuery): Promise<Model.DeviceDataPointsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistDeviceData(deviceDataPoints: Model.PersistableDeviceDataPoint[]): Promise<void> {\n\t\tconst endpoint = 'devicedata';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', deviceDataPoints);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Device Data V2\n\n\tqueryDeviceDataV2(queryParameters: Model.DeviceDataV2Query): Promise<Model.DeviceDataV2Page> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2Aggregate(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2AggregatePage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"aggregateFunctions\")) {\n\t\t\tqueryParameters.aggregateFunctions = MyDataHelps.reduceArrayAndEscape(queryParameters.aggregateFunctions);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2DailySleep(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2DailySleepPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate/dailysleep?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDeviceDataV2AllDataTypes(enabled?: boolean): Promise<Model.SupportedDeviceDataV2DataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// External Accounts\n\n\tgetExternalAccountProviders(search: string | null, category: string | null, pageSize: number, pageNumber: number): Promise<Model.ExternalAccountProvidersPage> {\n\t\tlet searchParameters: any = {};\n\t\tif (!!search) searchParameters.search = search;\n\t\tif (!!category) searchParameters.category = category;\n\t\tif (!!pageSize) searchParameters.pageSize = pageSize;\n\t\tif (!!pageNumber) searchParameters.pageNumber = pageNumber;\n\n\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\tconst endpoint = 'externalaccountproviders?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tconnectExternalAccount(externalAccountProviderID: number, options?: Model.ConnectExternalAccountOptions): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\n\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\tmdh.messageHandlers[messageID] = function (connectProviderAccountResponse) {\n\t\t\t\tif (connectProviderAccountResponse && connectProviderAccountResponse.success) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject(connectProviderAccountResponse.errorMessage)\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (this.standaloneMode) {\n\t\t\t\tlet standaloneModeFinalRedirectPath = options?.standaloneModeFinalRedirectPath || window.location.href;\n\t\t\t\tconst mdh = this;\n\n\t\t\t\t// DEV: Safari blocks popups in AJAX responses. Work-around is to open a blank window before the request and set the URL later\n\t\t\t\tlet providerAuthWindow;\n\t\t\t\tif (options?.openNewWindow) {\n\t\t\t\t\tstandaloneModeFinalRedirectPath = `${standaloneModeFinalRedirectPath.split('?')[0]}?connectExternalAccount=true&messageID=${messageID}&success=%SUCCESSVALUE%`;\n\t\t\t\t\tlet windowFeatures = null;\n\t\t\t\t\tif (options?.width && options?.height) {\n\t\t\t\t\t\tconst w = options?.width;\n\t\t\t\t\t\tconst h = options?.height;\n\t\t\t\t\t\tconst y = window.outerHeight / 2 + window.screenY - (h / 2);\n\t\t\t\t\t\tconst x = window.outerWidth / 2 + window.screenX - (w / 2);\n\t\t\t\t\t\twindowFeatures = \"width=\" + w + \",height=\" + h + \",top=\" + y + \",left=\" + x;\n\t\t\t\t\t}\n\t\t\t\t\tproviderAuthWindow = window.open(`${this.baseUrl}home/loading`, 'providerauth', windowFeatures);\n\t\t\t\t}\n\n\t\t\t\tconst searchParameters = { finalRedirectPath: standaloneModeFinalRedirectPath };\n\t\t\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\t\t\tconst endpoint = \"externalaccountproviders/\" + externalAccountProviderID + \"/connect?\" + queryString;\n\n\t\t\t\tthis\n\t\t\t\t\t.connect()\n\t\t\t\t\t.then(function () {\n\t\t\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn response.text();\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (redirectUrl) {\n\t\t\t\t\t\tif (providerAuthWindow) {\n\t\t\t\t\t\t\tproviderAuthWindow.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twindow.top.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function (error) {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t});\n\t\t\t} else if (window.webkit.messageHandlers.ConnectExternalAccount) {\n\t\t\t\twindow.webkit.messageHandlers.ConnectExternalAccount.postMessage({\n\t\t\t\t\texternalAccountProviderID: externalAccountProviderID,\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tgetExternalAccounts(): Promise<Model.ExternalAccount[]> {\n\t\tconst endpoint = 'externalaccounts';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\trefreshExternalAccount(accountID: number): Promise<void> {\n\t\tconst endpoint = 'externalaccounts/refresh/' + accountID;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tdeleteExternalAccount(accountID: number): Promise<any> {\n\t\tconst endpoint = 'externalaccounts/delete/' + encodeURIComponent(accountID);\n\t\tconst mdh = this;\n\n\t\tif (this.isStandaloneMode()) {\n\t\t\treturn this\n\t\t\t\t.connect()\n\t\t\t\t.then(function () {\n\t\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t\t})\n\t\t\t\t.then(function (response) {\n\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t});\n\t\t}\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (window.webkit.messageHandlers.DeleteProviderAccount) {\n\t\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deleteProviderAccountResponse) {\n\t\t\t\t\tif (!deleteProviderAccountResponse.success) {\n\t\t\t\t\t\treject(deleteProviderAccountResponse)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(deleteProviderAccountResponse);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.DeleteProviderAccount.postMessage({\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\taccountID: accountID\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\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":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","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","makeRequest","response","validateResponse","json","deleteSurveyResult","resultID","querySurveyTasks","status","queryInboxItems","target","source","key","keys","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","event","forEach","handler","setActionResult","data","prototype","call","console","error","getParticipantInfo","persistParticipantInfo","demographics","customFields","ok","message","catch","log","getProjectInfo","getDeviceDataPoint","deleteDeviceDataPoint","queryDeviceData","observedBefore","observedAfter","persistDeviceData","deviceDataPoints","queryDeviceDataV2","insertedBefore","insertedAfter","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","enabled","getExternalAccountProviders","search","category","pageSize","pageNumber","searchParameters","connectExternalAccount","externalAccountProviderID","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","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":"AAqEO,SAASA,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBO,K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iV,QAAUhB,EAAO3E,IAAI,2BAA6B2E,EAAO3E,IAAI,cAAgB2E,EAAO3E,IAAI,WAOlG,OANAtP,OAAOiV,OAAO3U,YAAY,CACzB0L,KAAM,iCACN5L,UAAW8U,SAASjB,EAAO3E,IAAI,cAC/BnG,QAAmC,SAA1B8K,EAAO3E,IAAI,YAClBtP,OAAOuJ,SAASoI,QACnB3R,OAAOmV,SACA,CAER,CAEO,2BAAA3C,GACP,MACMyB,EAAS,IAAIxS,gBAAgBzB,OAAOuJ,SAASZ,QACnD,GAAIsL,EAAO5E,IAFa,OAE2C,UAAhC4E,EAAO3E,IAFlB,MAGvB,OAAO,CAER,EAKF,MAAM3N,EAAM,IAAInC,EAEhBQ,OAAOR,YAAcmC,EAGrB3B,OAAOoV,eAAiB,CAAA,EACxBpV,OAAOoV,eAAe3O,gBAAkB,SAAUC,GACjD1G,OAAOR,YAAYiH,gBAAgBC,EACpC","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"MyDataHelps.min.js","sources":["../../src/MyDataHelps.ts"],"sourcesContent":["// @ts-ignore : let rollup handle CSS injection\nimport \"../MyDataHelps.css\";\n\nimport * as Model from \"./types\";\nimport { StringMap } from \"./types\";\n\nexport class MyDataHelps {\n\n\tbaseUrl: string = 'https://mydatahelps.org/';\n\tlanguage: string;\n\ttoken: Model.Token;\n\ttokenExpires: number;\n\n\t// Surveys\n\n\tstartSurvey(surveyName: string): void {\n\t\tif (this.isStandaloneMode()) {\n\t\t\tthis.startDelegatedSurvey(`${this.baseUrl}/survey?surveyName=${encodeURIComponent(surveyName)}`);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.StartParticipantSurvey) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.StartParticipantSurvey.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tsurveyName: surveyName\n\t\t\t});\n\t\t}\n\t}\n\n\tcompleteStep(answer: any): void {\n\t\tif (answer === undefined || answer === null) answer = '';\n\t\tif (typeof answer !== 'string') {\n\t\t\tanswer = JSON.stringify(answer);\n\t\t}\n\t\tif (window.webkit.messageHandlers.ResearchKit) {\n\t\t\twindow.webkit.messageHandlers.ResearchKit.postMessage(answer);\n\t\t}\n\t\telse if (window.webkit.messageHandlers.CompleteStep) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.CompleteStep.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\tanswer: answer\n\t\t\t});\n\t\t}\n\t}\n\n\tquerySurveyAnswers(queryParameters: Model.SurveyAnswersQuery): Promise<Model.SurveyAnswersPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"stepIdentifier\")) {\n\t\t\tqueryParameters.stepIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.stepIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"resultIdentifier\")) {\n\t\t\tqueryParameters.resultIdentifier = MyDataHelps.reduceArrayAndEscape(queryParameters.resultIdentifier);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"answer\")) {\n\t\t\tqueryParameters.answer = MyDataHelps.reduceArrayAndEscape(queryParameters.answer);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyanswers?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tquerySurveyResults(queryParameters: Model.SurveyResultsQuery): Promise<Model.SurveyResultsPage> {\n\t\tqueryParameters = { ...queryParameters }\n\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"event\")) {\n\t\t\tqueryParameters.event = MyDataHelps.reduceArrayAndEscape(queryParameters.event);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"before\")) {\n\t\t\tqueryParameters.before = MyDataHelps.convertDateToIsoString(queryParameters.before);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"after\")) {\n\t\t\tqueryParameters.after = MyDataHelps.convertDateToIsoString(queryParameters.after);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveyresults?' + queryString;\n\n\t\treturn this.connect()\n\t\t\t.then(() => this.makeRequest(endpoint, 'GET', null))\n\t\t\t.then(MyDataHelps.validateResponse)\n\t\t\t.then(response => response.json());\n\t}\n\n\tdeleteSurveyResult(resultID: string): Promise<void> {\n\t\tconst endpoint = 'surveyresults/' + encodeURIComponent(resultID);\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tquerySurveyTasks(queryParameters: Model.SurveyTaskQueryParameters): Promise<Model.SurveyTasksPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.SurveyTaskStatus;\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"surveyName\")) {\n\t\t\tqueryParameters.surveyName = MyDataHelps.reduceArrayAndEscape(queryParameters.surveyName);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'surveytasks?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryInboxItems(queryParameters: Model.InboxItemQueryParameters): Promise<Model.InboxItemsPage> {\n\t\tconst assignDefined = (target: any, source: any): any => {\n\t\t\tfor (const key of Object.keys(source)) {\n\t\t\t\tconst value = source[key];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\ttarget[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn target;\n\t\t};\n\n\t\tqueryParameters = assignDefined({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type) as Model.InboxItemType;\n\t\t}\n\n\t\tif (queryParameters.hasOwnProperty(\"status\")) {\n\t\t\tqueryParameters.status = MyDataHelps.reduceArrayAndEscape(queryParameters.status) as Model.InboxItemStatus;\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'inbox?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetInboxItem(id: Model.Guid): Promise<Model.InboxItem> {\n\t\tconst endpoint = `inbox/${id}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tupdateInboxItem(id: Model.Guid, update: Model.InboxItemUpdate): Promise<Model.InboxItemUpdateResult> {\n\t\tconst endpoint = `inbox/${id}/${update}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tstartEmbeddedSurvey(linkIdentifier: string, surveyName: string, language: string): Promise<any> {\n\t\tif (!language) {\n\t\t\tlanguage = this.getCurrentLanguage();\n\t\t}\n\t\tlet surveyUrl = this.baseUrl + \"mydatahelps/\" + linkIdentifier + '/surveylink/' + surveyName + \"?lang=\" + language;\n\t\treturn this.startEmbeddedSurveyInternal(surveyUrl);\n\t}\n\n\t// Navigation\n\n\topenExternalUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalLink) {\n\t\t\twindow.webkit.messageHandlers.OpenExternalLink.postMessage(url);\n\t\t}\n\t}\n\n\topenEmbeddedUrl(url: string): void {\n\t\tif (window.webkit.messageHandlers.OpenEmbeddedLink) {\n\t\t\twindow.webkit.messageHandlers.OpenEmbeddedLink.postMessage(url);\n\t\t}\n\t}\n\n\tshowTab(tabKey: string): void {\n\t\tif (window.webkit.messageHandlers.ShowTab) {\n\t\t\twindow.webkit.messageHandlers.ShowTab.postMessage(tabKey);\n\t\t}\n\t}\n\n\topenApplication(url: string, options?: Model.OpenApplicationOptions): void {\n\t\tif (window.webkit.messageHandlers.OpenExternalApplication) {\n\t\t\tlet messageID = this.nextMessageID();\n\t\t\twindow.webkit.messageHandlers.OpenExternalApplication.postMessage({\n\t\t\t\tmessageID: messageID,\n\t\t\t\turl: url,\n\t\t\t\tmodal: !!(options && options.modal)\n\t\t\t});\n\t\t}\n\t}\n\n\tdismiss(): void {\n\t\tif (window.webkit.messageHandlers.Dismiss) {\n\t\t\twindow.webkit.messageHandlers.Dismiss.postMessage({});\n\t\t}\n\t}\n\n\tback(): void {\n\t\tif (window.webkit.messageHandlers.PopNavigation) {\n\t\t\twindow.webkit.messageHandlers.PopNavigation.postMessage({});\n\t\t}\n\t}\n\n\tshowDashboard(dashboardKey: string, options?: Model.ShowDashboardOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantDashboard) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantDashboard.postMessage({\n\t\t\t\tdashboardKey: dashboardKey,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualization(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualization) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualization.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tmodal: !!(options && options.modal),\n\t\t\t\ttitle: options && options.title ? options.title : undefined\n\t\t\t});\n\t\t}\n\t}\n\n\tshowWebVisualizationPdf(visualizationKey: string, parameters: object, options: Model.ShowWebVisualizationPdfOptions): void {\n\t\tif (window.webkit.messageHandlers.ShowParticipantWebVisualizationPDF) {\n\t\t\twindow.webkit.messageHandlers.ShowParticipantWebVisualizationPDF.postMessage({\n\t\t\t\tvisualizationKey: visualizationKey,\n\t\t\t\tparameters: parameters,\n\t\t\t\tlandscape: !!(options && options.landscape),\n\t\t\t\thtmlViewerZoom: options && options.htmlViewerZoom\n\t\t\t});\n\t\t}\n\t}\n\n\tshowProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.ShowProject) {\n\t\t\twindow.webkit.messageHandlers.ShowProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\tjoinProject(projectCode: string): void {\n\t\tif (window.webkit.messageHandlers.JoinProject) {\n\t\t\twindow.webkit.messageHandlers.JoinProject.postMessage({ code: projectCode });\n\t\t}\n\t}\n\n\t//Events\n\n\ton(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName] = [];\n\t\t}\n\n\t\tthis.registeredEventHandlers[eventName].push(callback);\n\t}\n\n\toff(eventName: Model.EventName, callback: (EventData) => void): void {\n\n\t\tif (!this.supportedEvents.includes(eventName)) {\n\t\t\tthrow new Error(eventName + \" is not a supported event type.\");\n\t\t}\n\n\t\tif (!this.registeredEventHandlers[eventName]) return;\n\n\t\tlet eventHandlerIndex = this.registeredEventHandlers[eventName].indexOf(callback);\n\n\t\tif (eventHandlerIndex !== -1) {\n\t\t\tthis.registeredEventHandlers[eventName].splice(eventHandlerIndex, 1);\n\t\t}\n\t}\n\n\ttriggerEvent(event: Model.EventData): void {\n\t\tlet eventName = event.type;\n\t\tif (this.supportedEvents.includes(eventName) && this.registeredEventHandlers[eventName]) {\n\t\t\tthis.registeredEventHandlers[eventName].forEach(function (handler) {\n\t\t\t\thandler(event);\n\t\t\t});\n\t\t}\n\t}\n\n\tsetActionResult(data: Model.EventData): void {\n\t\tif (Object.prototype.hasOwnProperty.call(this.messageHandlers, data.messageID) &&\n\t\t\ttypeof this.messageHandlers[data.messageID] === 'function') {\n\t\t\tthis.messageHandlers[data.messageID](data);\n\t\t} else {\n\t\t\tconsole.error(`Invalid messageID: ${data.messageID}`);\n\t\t}\n\t}\n\n\t// Participant Info\n\n\tgetParticipantInfo(): Promise<Model.ParticipantInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'participant';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistParticipantInfo(demographics: Partial<Model.ParticipantDemographics> | undefined, customFields: StringMap): Promise<Model.ParticipantInfo> {\n\t\tconst endpoint = 'participant';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'PUT', { demographics, customFields });\n\t\t\t})\n\t\t\t.then(async function (response) {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tvar errorJson = await response.json();\n\t\t\t\t\tthrow errorJson.message;\n\t\t\t\t}\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.catch(function (error) {\n\t\t\t\tconsole.log(\"Unable to persist participant: \" + error);\n\t\t\t});\n\t}\n\n\tgetProjectInfo(): Promise<Model.ProjectInfo> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'project';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Device Data\n\n\tgetDeviceDataPoint(id: Model.Guid): Promise<Model.DeviceDataPoint> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteDeviceDataPoint(id: Model.Guid): Promise<void> {\n\t\tconst endpoint = 'devicedata/' + id;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryDeviceData(queryParameters: Model.DeviceDataPointQuery): Promise<Model.DeviceDataPointsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"type\")) {\n\t\t\tqueryParameters.type = MyDataHelps.reduceArrayAndEscape(queryParameters.type);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tpersistDeviceData(deviceDataPoints: Model.PersistableDeviceDataPoint[]): Promise<void> {\n\t\tconst endpoint = 'devicedata';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', deviceDataPoints);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Device Data V2\n\n\tqueryDeviceDataV2(queryParameters: Model.DeviceDataV2Query): Promise<Model.DeviceDataV2Page> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2Aggregate(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2AggregatePage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"aggregateFunctions\")) {\n\t\t\tqueryParameters.aggregateFunctions = MyDataHelps.reduceArrayAndEscape(queryParameters.aggregateFunctions);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryDeviceDataV2DailySleep(queryParameters: Model.DeviceDataV2AggregateQuery): Promise<Model.DeviceDataV2DailySleepPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"observedBefore\")) {\n\t\t\tqueryParameters.observedBefore = MyDataHelps.convertDateToIsoString(queryParameters.observedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"observedAfter\")) {\n\t\t\tqueryParameters.observedAfter = MyDataHelps.convertDateToIsoString(queryParameters.observedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedBefore\")) {\n\t\t\tqueryParameters.insertedBefore = MyDataHelps.convertDateToIsoString(queryParameters.insertedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"insertedAfter\")) {\n\t\t\tqueryParameters.insertedAfter = MyDataHelps.convertDateToIsoString(queryParameters.insertedAfter);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedBefore\")) {\n\t\t\tqueryParameters.modifiedBefore = MyDataHelps.convertDateToIsoString(queryParameters.modifiedBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"modifiedAfter\")) {\n\t\t\tqueryParameters.modifiedAfter = MyDataHelps.convertDateToIsoString(queryParameters.modifiedAfter);\n\t\t}\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"dataSource\");\n\t\tMyDataHelps.flattenPropertyShallow(queryParameters, \"properties\");\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'devicedata/aggregate/dailysleep?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDeviceDataV2AllDataTypes(enabled?: boolean): Promise<Model.SupportedDeviceDataV2DataType[]> {\n\t\tconst queryParameters: Record<string, string> = {};\n\n\t\tif (enabled !== undefined) {\n\t\t\tqueryParameters['enabled'] = enabled.toString();\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters).toString();\n\t\tconst endpoint = `devicedata/allDataTypes?${queryString}`;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null, 'v2');\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// External Accounts\n\n\tgetExternalAccountProviders(search: string | null, category: string | null, pageSize: number, pageNumber: number): Promise<Model.ExternalAccountProvidersPage> {\n\t\tlet searchParameters: any = {};\n\t\tif (!!search) searchParameters.search = search;\n\t\tif (!!category) searchParameters.category = category;\n\t\tif (!!pageSize) searchParameters.pageSize = pageSize;\n\t\tif (!!pageNumber) searchParameters.pageNumber = pageNumber;\n\n\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\tconst endpoint = 'externalaccountproviders?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tconnectExternalAccount(externalAccountProviderID: number, options?: Model.ConnectExternalAccountOptions): Promise<void> {\n\t\treturn new Promise<void>((resolve, reject) => {\n\n\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\tmdh.messageHandlers[messageID] = function (connectProviderAccountResponse) {\n\t\t\t\tif (connectProviderAccountResponse && connectProviderAccountResponse.success) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else {\n\t\t\t\t\treject(connectProviderAccountResponse.errorMessage)\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tif (this.standaloneMode) {\n\t\t\t\tlet standaloneModeFinalRedirectPath = options?.standaloneModeFinalRedirectPath || window.location.href;\n\t\t\t\tconst mdh = this;\n\n\t\t\t\t// DEV: Safari blocks popups in AJAX responses. Work-around is to open a blank window before the request and set the URL later\n\t\t\t\tlet providerAuthWindow;\n\t\t\t\tif (options?.openNewWindow) {\n\t\t\t\t\tstandaloneModeFinalRedirectPath = `${standaloneModeFinalRedirectPath.split('?')[0]}?connectExternalAccount=true&messageID=${messageID}&success=%SUCCESSVALUE%`;\n\t\t\t\t\tlet windowFeatures = null;\n\t\t\t\t\tif (options?.width && options?.height) {\n\t\t\t\t\t\tconst w = options?.width;\n\t\t\t\t\t\tconst h = options?.height;\n\t\t\t\t\t\tconst y = window.outerHeight / 2 + window.screenY - (h / 2);\n\t\t\t\t\t\tconst x = window.outerWidth / 2 + window.screenX - (w / 2);\n\t\t\t\t\t\twindowFeatures = \"width=\" + w + \",height=\" + h + \",top=\" + y + \",left=\" + x;\n\t\t\t\t\t}\n\t\t\t\t\tproviderAuthWindow = window.open(`${this.baseUrl}home/loading`, 'providerauth', windowFeatures);\n\t\t\t\t}\n\n\t\t\t\tconst searchParameters = { finalRedirectPath: standaloneModeFinalRedirectPath };\n\t\t\t\tconst queryString = new URLSearchParams(searchParameters).toString();\n\t\t\t\tconst endpoint = \"externalaccountproviders/\" + externalAccountProviderID + \"/connect?\" + queryString;\n\n\t\t\t\tthis\n\t\t\t\t\t.connect()\n\t\t\t\t\t.then(function () {\n\t\t\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (response) {\n\t\t\t\t\t\treturn response.text();\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (redirectUrl) {\n\t\t\t\t\t\tif (providerAuthWindow) {\n\t\t\t\t\t\t\tproviderAuthWindow.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twindow.top.location = redirectUrl.replace(/['\"]+/g, '');\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function (error) {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t});\n\t\t\t} else if (window.webkit.messageHandlers.ConnectExternalAccount) {\n\t\t\t\twindow.webkit.messageHandlers.ConnectExternalAccount.postMessage({\n\t\t\t\t\texternalAccountProviderID: externalAccountProviderID,\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\t...options\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tgetExternalAccounts(): Promise<Model.ExternalAccount[]> {\n\t\tconst endpoint = 'externalaccounts';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\trefreshExternalAccount(accountID: number): Promise<void> {\n\t\tconst endpoint = 'externalaccounts/refresh/' + accountID;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tdeleteExternalAccount(accountID: number): Promise<any> {\n\t\tconst endpoint = 'externalaccounts/delete/' + encodeURIComponent(accountID);\n\t\tconst mdh = this;\n\n\t\tif (this.isStandaloneMode()) {\n\t\t\treturn this\n\t\t\t\t.connect()\n\t\t\t\t.then(function () {\n\t\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t\t})\n\t\t\t\t.then(function (response) {\n\t\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t\t});\n\t\t}\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (window.webkit.messageHandlers.DeleteProviderAccount) {\n\t\t\t\tconst messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deleteProviderAccountResponse) {\n\t\t\t\t\tif (!deleteProviderAccountResponse.success) {\n\t\t\t\t\t\treject(deleteProviderAccountResponse)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolve(deleteProviderAccountResponse);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.DeleteProviderAccount.postMessage({\n\t\t\t\t\tmessageID: messageID,\n\t\t\t\t\taccountID: accountID\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\t// Notifications\n\n\tqueryNotifications(queryParameters: Model.NotificationQueryParameters): Promise<Model.NotificationsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"sentBefore\")) {\n\t\t\tqueryParameters.sentBefore = MyDataHelps.convertDateToIsoString(queryParameters.sentBefore);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"sentAfter\")) {\n\t\t\tqueryParameters.sentAfter = MyDataHelps.convertDateToIsoString(queryParameters.sentAfter);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'notifications?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Fitbit\n\n\tqueryFitbitDailySummaries(queryParameters: Model.FitbitQuery): Promise<Model.FitbitDailySummariesPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/dailySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryFitbitSleepLogs(queryParameters: Model.FitbitQuery): Promise<Model.FitbitSleepLogsPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'fitbit/sleepLogs?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// AppleHealth\n\n\tqueryAppleHealthActivitySummaries(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthActivitySummaryPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/activitySummaries?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tqueryAppleHealthWorkouts(queryParameters: Model.AppleHealthQuery): Promise<Model.AppleHealthWorkoutPage> {\n\t\tqueryParameters = Object.assign({}, queryParameters);\n\n\t\tif (queryParameters.hasOwnProperty(\"startDate\")) {\n\t\t\tqueryParameters.startDate = MyDataHelps.convertDateToIsoString(queryParameters.startDate);\n\t\t}\n\t\tif (queryParameters.hasOwnProperty(\"endDate\")) {\n\t\t\tqueryParameters.endDate = MyDataHelps.convertDateToIsoString(queryParameters.endDate);\n\t\t}\n\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'appleHealth/workouts?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\t// Files\n\n\tuploadFile(file: File, category: string, fileName?: string): Promise<void> {\n\n\t\tif (file.size > 200 * 1024 * 1024) {\n\t\t\tthrow new Error(\"File size exceeds the maximum allowed size of 200MB.\");\n\t\t}\n\n\t\tconst mdh = this;\n\t\tconst endpoint = 'files?category=' + category + '&fileName=' + encodeURIComponent(fileName ?? file.name);\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t})\n\t\t\t.then(function (json) {\n\t\t\t\treturn fetch(json.preSignedUrl, {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\tbody: file,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t'Content-Type': file.type,\n\t\t\t\t\t\t'x-amz-server-side-encryption': 'AES256'\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tqueryFiles(queryParameters: Model.UploadedFileQuery): Promise<Model.UploadedFilesPage> {\n\t\tconst queryString = new URLSearchParams(queryParameters as Record<string, any>).toString();\n\t\tconst endpoint = 'files?' + queryString;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetFileDownloadUrl(key: string): Promise<Model.DownloadedFile> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to download.\");\n\n\t\tconst endpoint = 'files/download?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tdeleteFile(key: string): Promise<void> {\n\n\t\tif (!key) throw new Error(\"Please specify the key of the file to delete.\");\n\n\t\tconst endpoint = 'files?key=' + key;\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'DELETE', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\t// Authorization\n\n\tconnect(): Promise<void> {\n\t\tconst mdh = this;\n\t\tlet refreshDelegatedAccessToken = function () {\n\t\t\tmdh.token = null;\n\n\t\t\tmdh.refreshTokenPromise = new Promise(function (resolve, reject) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (tokenResponse) {\n\t\t\t\t\tif (tokenResponse.success) {\n\t\t\t\t\t\tmdh.tokenExpires = Date.now() + (tokenResponse.data.expires_in * 1000);\n\t\t\t\t\t\tmdh.token = tokenResponse.data;\n\t\t\t\t\t\tmdh.baseUrl = tokenResponse.baseUrl;\n\t\t\t\t\t\tsetTimeout(refreshDelegatedAccessToken, ((tokenResponse.data.expires_in - mdh.accessTokenRenewalBufferSeconds) * 1000));\n\t\t\t\t\t\tresolve(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmdh.token = null;\n\t\t\t\t\t\treject(tokenResponse.message);\n\t\t\t\t\t}\n\t\t\t\t\tmdh.messageHandlers[messageID] = null;\n\t\t\t\t\tmdh.refreshTokenPromise = null;\n\t\t\t\t};\n\n\t\t\t\twindow.webkit.messageHandlers.GetDelegatedAccessToken.postMessage({ messageID: messageID });\n\t\t\t});\n\t\t};\n\n\t\tif (this.token && Date.now() < this.tokenExpires) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\tif (this.isStandaloneMode() && !this.isEmbeddedMode()) {\n\t\t\tlet error = this.token ? \"access token is expired or invalid\" : \"access token must be explicitly provided using the setParticipantAccess method\";\n\t\t\tconsole.log(error);\n\t\t\treturn Promise.reject(error);\n\t\t}\n\n\t\tif (!this.refreshTokenPromise) {\n\t\t\trefreshDelegatedAccessToken();\n\t\t}\n\n\t\t// Re-use promise if refresh already in progress\n\t\treturn this.refreshTokenPromise;\n\t}\n\n\tsetParticipantAccessToken(token: Model.Token, baseUrl?: string): void {\n\t\tthis.enableStandaloneMode();\n\t\tthis.token = token;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tthis.tokenExpires = Date.now() + (this.token.expires_in * 1000);\n\t\tconst mdh = this;\n\t\tsetTimeout(function () {\n\t\t\tmdh.triggerEvent({ type: \"tokenWillExpire\" });\n\t\t}, ((this.token.expires_in - this.accessTokenRenewalBufferSeconds) * 1000));\n\t}\n\n\t// Miscellaneous\n\n\tisStandaloneMode() {\n\t\treturn this.standaloneMode;\n\t}\n\n\tisEmbeddedMode() {\n\t\treturn this.embeddedMode;\n\t}\n\n\tenableStandaloneMode(embeddedMode: boolean = false, baseUrl?: string) {\n\t\tthis.standaloneMode = true;\n\t\tthis.embeddedMode = embeddedMode;\n\t\tif (baseUrl) {\n\t\t\tthis.baseUrl = baseUrl;\n\t\t}\n\t\tif (window.webkit) {\n\t\t\twindow.webkit.messageHandlers = embeddedMode ? {\n\t\t\t\tGetDelegatedAccessToken: window.webkit.messageHandlers.GetDelegatedAccessToken,\n\t\t\t\tOpenExternalLink: window.webkit.messageHandlers.OpenExternalLink,\n\t\t\t\tOpenEmbeddedLink: window.webkit.messageHandlers.OpenEmbeddedLink,\n\t\t\t\tOpenExternalApplication: window.webkit.messageHandlers.OpenExternalApplication,\n\t\t\t\tPopNavigation: window.webkit.messageHandlers.PopNavigation,\n\t\t\t\tDismiss: window.webkit.messageHandlers.Dismiss,\n\t\t\t} : {};\n\t\t}\n\t}\n\n\tsetStatusBarStyle(style: Model.StatusBarStyle): void {\n\t\tif (window.webkit.messageHandlers.SetStatusBarStyle) {\n\t\t\twindow.webkit.messageHandlers.SetStatusBarStyle.postMessage({ style: style });\n\t\t}\n\t}\n\n\tgetDeviceInfo(): Promise<Model.DeviceInfo> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.DeviceInfo>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetDeviceInfo) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (deviceInfoResponse) {\n\t\t\t\t\tresolve(deviceInfoResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetDeviceInfo.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetSupportedLanguages(languages: string[]) {\n\t\tthis.supportedLanguages.length = 0;\n\t\tfor (let i = 0; i < languages.length; i++) {\n\t\t\tthis.supportedLanguages.push(languages[i].replace(\"_\", \"-\"));\n\t\t}\n\t}\n\n\tgetStepConfiguration(): Promise<Model.StepConfiguration> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.StepConfiguration>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetStepConfiguration) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (stepConfigurationResponse) {\n\t\t\t\t\tresolve(stepConfigurationResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetStepConfiguration.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tgetSurveyContext(): Promise<Model.SurveyContext> {\n\t\tlet mdh = this;\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t}\n\t\t\tmdh.getDeviceInfo().then(function (deviceInfo) {\n\t\t\t\tif (deviceInfo.platform !== \"Web\") {\n\t\t\t\t\tresolve({ surveyMode: \"Survey\" });\n\t\t\t\t}\n\t\t\t\telse if (window.webkit.messageHandlers.GetSurveyContext) {\n\t\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\t\tmdh.messageHandlers[messageID] = function (surveyContextResponse) {\n\t\t\t\t\t\tresolve(surveyContextResponse.data);\n\t\t\t\t\t};\n\t\t\t\t\twindow.webkit.messageHandlers.GetSurveyContext.postMessage({ messageID: messageID });\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treject();\n\t\t\t\t}\n\t\t\t}).catch(function (error) {\n\t\t\t\treject();\n\t\t\t});\n\t\t});\n\t}\n\n\tgetCurrentSurveyAnswers(): Promise<Model.CurrentSurveyAnswer[]> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.CurrentSurveyAnswer[]>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.GetCurrentSurveyAnswers) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (currentSurveyAnswersResponse) {\n\t\t\t\t\tresolve(currentSurveyAnswersResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.GetCurrentSurveyAnswers.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tsetCurrentLanguage(language: string) {\n\t\tif (language) {\n\t\t\tlet supportedLanguage = this.getSupportedLanguage(language);\n\t\t\tif (supportedLanguage) {\n\t\t\t\tthis.language = supportedLanguage;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${language} not supported`);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.language = language;\n\t\t}\n\t}\n\n\tgetCurrentLanguage(): string {\n\t\tlet searchParams = new URLSearchParams(window.location.search);\n\t\tlet lang;\n\t\tif (searchParams.has(\"lang\")) {\n\t\t\tlang = this.getSupportedLanguage(searchParams.get(\"lang\"));\n\t\t\tif (lang) {\n\t\t\t\treturn lang;\n\t\t\t} else {\n\t\t\t\tconsole.warn(`language ${searchParams.get(\"lang\")} not supported`);\n\t\t\t}\n\t\t}\n\t\treturn this.language || navigator.language;\n\t}\n\n\tshowGoogleFitSettings(): void {\n\t\tif (window.webkit.messageHandlers.ShowGoogleFitSettings) {\n\t\t\twindow.webkit.messageHandlers.ShowGoogleFitSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectSettings(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectSettings) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectSettings.postMessage({});\n\t\t}\n\t}\n\n\tshowHealthConnectPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectStatus(): Promise<Model.HealthConnectStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\tshowHealthConnectPhrPrompt(): void {\n\t\tif (window.webkit.messageHandlers.HealthConnectPhrPrompt) {\n\t\t\twindow.webkit.messageHandlers.HealthConnectPhrPrompt.postMessage({});\n\t\t}\n\t}\n\n\tgetHealthConnectPhrStatus(): Promise<Model.HealthConnectPhrStatus> {\n\t\tlet mdh = this;\n\t\treturn new Promise<Model.HealthConnectPhrStatus>(function (resolve, reject) {\n\t\t\tif (mdh.isStandaloneMode()) {\n\t\t\t\tresolve(null);\n\t\t\t} else if (window.webkit.messageHandlers.HealthConnectPhrStatus) {\n\t\t\t\tlet messageID = mdh.nextMessageID();\n\t\t\t\tmdh.messageHandlers[messageID] = function (statusResponse) {\n\t\t\t\t\tresolve(statusResponse.data);\n\t\t\t\t};\n\t\t\t\twindow.webkit.messageHandlers.HealthConnectPhrStatus.postMessage({ messageID: messageID });\n\t\t\t} else {\n\t\t\t\treject();\n\t\t\t}\n\t\t});\n\t}\n\n\trequestReview(cooldownDays?: number): void {\n\t\tif (window.webkit.messageHandlers.RequestReview) {\n\t\t\twindow.webkit.messageHandlers.RequestReview.postMessage({ cooldownDays: cooldownDays });\n\t\t}\n\t}\n\n\ttrackCustomEvent(event: Model.CustomEventInfo): Promise<void> {\n\t\tconst endpoint = 'customevents';\n\t\tconst mdh = this;\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'POST', event);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function () {\n\t\t\t\treturn;\n\t\t\t});\n\t}\n\n\tgetDataCollectionSettings(): Promise<Model.DataCollectionSettings> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'datacollectionsettings';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tgetDataAvailability(): Promise<Model.DataAvailability> {\n\t\tconst mdh = this;\n\t\tconst endpoint = 'dataavailability';\n\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, 'GET', null);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn response.json();\n\t\t\t});\n\t}\n\n\tinvokeCustomApi(customApi: string, method: string, queryParameters: string | string[][] | Record<string, string> | URLSearchParams | null | undefined, jsonResponse: boolean): Promise<any> {\n\t\tif (customApi.includes('?')) {\n\t\t\tthrow new Error(\"Cannot include query parameters directly in the \\\"customApi\\\" string. Provide as an argument for \\\"queryParameters\\\" instead.\");\n\t\t}\n\n\t\tlet endpoint = 'custom/' + customApi;\n\t\tmethod = method.toUpperCase();\n\t\tif (queryParameters !== null && queryParameters !== undefined && (method === 'GET' || method === 'DELETE')) {\n\t\t\tlet parameterString = new URLSearchParams(queryParameters).toString();\n\t\t\tendpoint += \"?\" + parameterString;\n\t\t\tqueryParameters = null;\n\t\t}\n\n\t\tconst mdh = this;\n\t\treturn this\n\t\t\t.connect()\n\t\t\t.then(function () {\n\t\t\t\treturn mdh.makeRequest(endpoint, method, queryParameters);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn MyDataHelps.validateResponse(response);\n\t\t\t})\n\t\t\t.then(function (response) {\n\t\t\t\treturn jsonResponse ? response.json() : undefined;\n\t\t\t});\n\t}\n\n\tconstructor() {\n\t\tif (this.handleConnectExternalAccountResponse()) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet mdh = this;\n\t\tlet applicationHost = getParentOrigin();\n\t\tlet supportedActions;\n\n\t\tfunction getParentOrigin(): string {\n\t\t\tlet ancestorOrigins = document.location.ancestorOrigins;\n\t\t\tif (ancestorOrigins && ancestorOrigins[0]) {\n\t\t\t\treturn ancestorOrigins[0];\n\t\t\t}\n\n\t\t\treturn '*';\n\t\t}\n\n\t\tfunction acceptableOrigin(origin) {\n\t\t\tif (origin === '*') return true;\n\n\t\t\tlet sourceURL = new URL(origin);\n\t\t\tfor (let k = 0; k < mdh.acceptableParentDomains.length; k++) {\n\t\t\t\tif (sourceURL.hostname === mdh.acceptableParentDomains[k] || sourceURL.hostname.endsWith(\".\" + mdh.acceptableParentDomains[k])) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction validateWindowMessageOrigin(message) {\n\t\t\tif (mdh.isStandaloneMode() && message.origin === window.location.origin) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tif (applicationHost === \"*\") {\n\t\t\t\treturn acceptableOrigin(message.origin);\n\t\t\t}\n\n\t\t\treturn message.origin === applicationHost;\n\t\t}\n\n\t\tfunction addActions(actions) {\n\t\t\tfor (let action in actions) {\n\t\t\t\tif (!window.webkit.messageHandlers[action]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\twindow.webkit.messageHandlers[action] = { postMessage: actions[action] };\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.log(\"Unable to add missing actions on this platform: \" + error);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction receiveWindowMessage(message) {\n\t\t\tif (!validateWindowMessageOrigin(message)) {\n\t\t\t\t// todo: this can generate tons of console errors when hosting some apps within webappstep (youtube content, for example )\n\t\t\t\tconsole.error(\"message.origin '\" + message.origin + \"' is not allowed.\");\n\t\t\t\tthrow \"message.origin '\" + message.origin + \"' is not allowed.\";\n\t\t\t}\n\n\t\t\tif (message.data.messageID) {\n\t\t\t\tmdh.setActionResult(message.data);\n\t\t\t} else {\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}\n\n\t\tfunction windowHasAnyActions() {\n\t\t\tfor (let action in supportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[action]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let action in mdh.unsupportedActions) {\n\t\t\t\tif (window.webkit.messageHandlers[mdh.unsupportedActions[action]]) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!acceptableOrigin(applicationHost)) {\n\t\t\tconsole.log(\"Detected unsupported parent origin domain.\");\n\t\t}\n\n\t\tif (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.ResearchKit) {\n\t\t\t// Presence of ResearchKit handler indicates the SDK is being used from within a WebViewStep. For pre-SDK backwards compatiblity,\n\t\t\t// WebViewStep setup registers the following handlers: GetDeviceInfo, DeleteProviderAccount, ConnectExternalAccount\n\t\t\t// ShowParticipantWebVisualizationPDF, ResearchKit\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenExternalUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenEmbeddedUrl',\n\t\t\t\t\t\turl: data\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetSurveyContext\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetSurveyContext',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost);\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t} else {\n\t\t\tsupportedActions = {\n\t\t\t\t\"GetDelegatedAccessToken\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetDelegatedAccessToken',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetDeviceInfo\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'GetDeviceInfo', messageID: data.messageID }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"StartParticipantSurvey\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'StartParticipantSurvey',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tsurveyName: data.surveyName\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenExternalUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenEmbeddedLink\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'OpenEmbeddedUrl', url: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"OpenExternalApplication\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'OpenApplication',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"Dismiss\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Dismiss' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"PopNavigation\": function () {\n\t\t\t\t\twindow.parent.postMessage({ name: 'Back' }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowTab\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowTab', tabKey: data }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantDashboard\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantDashboard',\n\t\t\t\t\t\tdashboardKey: data.dashboardKey,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualization\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualization',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowParticipantWebVisualizationPDF\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ShowParticipantWebVisualizationPDF',\n\t\t\t\t\t\tvisualizationKey: data.visualizationKey,\n\t\t\t\t\t\tparameters: data.parameters,\n\t\t\t\t\t\tmodal: data.modal,\n\t\t\t\t\t\tlandscape: data.landscape,\n\t\t\t\t\t\thtmlViewerZoom: data.htmlViewerZoom\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"DeleteProviderAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'DeleteProviderAccount',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\taccountID: data.accountID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ConnectExternalAccount\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'ConnectExternalAccount',\n\t\t\t\t\t\texternalAccountProviderID: data.externalAccountProviderID,\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\topenNewWindow: data.openNewWindow,\n\t\t\t\t\t\twidth: data.width,\n\t\t\t\t\t\theight: data.height\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"ShowProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'ShowProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"JoinProject\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({ name: 'JoinProject', code: data.code }, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetCurrentSurveyAnswers\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetCurrentSurveyAnswers',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"GetStepConfiguration\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'GetStepConfiguration',\n\t\t\t\t\t\tmessageID: data.messageID\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t},\n\t\t\t\t\"CompleteStep\": function (data) {\n\t\t\t\t\twindow.parent.postMessage({\n\t\t\t\t\t\tname: 'CompleteStep',\n\t\t\t\t\t\tmessageID: data.messageID,\n\t\t\t\t\t\tanswer: data.answer\n\t\t\t\t\t}, applicationHost)\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tif (!window.webkit || !window.webkit.messageHandlers || !windowHasAnyActions()) {\n\t\t\twindow.webkit = {\n\t\t\t\tmessageHandlers: {}\n\t\t\t};\n\t\t}\n\n\t\taddActions(supportedActions);\n\n\t\twindow.addEventListener(\"message\", receiveWindowMessage, false);\n\n\t\tif (this.hasEmbeddedModeUrlParameter()) {\n\t\t\tmdh.enableStandaloneMode(true);\n\t\t}\n\t}\n\n\tprivate readonly acceptableParentDomains = [\n\t\t'localhost',\n\t\t'careevolution.com',\n\t\t'internal',\n\t\t'b3-deploys.com',\n\t\t'mydatahelps.org',\n\t\t'platform.joinallofus.org',\n\t\t'careevolution.dev',\n\t\t'ce.dev',\n\t\t'mydatahelps.dev'\n\t];\n\n\tprivate readonly accessTokenRenewalBufferSeconds = 120;\n\tprivate readonly unsupportedActions = [\"SetHeight\", \"ResearchKit\"];\n\tprivate readonly supportedEvents = [\"surveyDidFinish\", \"applicationDidBecomeVisible\", \"externalAccountSyncComplete\", \"tokenWillExpire\", \"healthConnectSyncComplete\", \"healthConnectPhrSyncComplete\"];\n\tprivate readonly supportedLanguages = [];\n\n\tprivate currentMessageID = 1;\n\tprivate messageHandlers = [];\n\tprivate registeredEventHandlers = {};\n\tprivate refreshTokenPromise = null;\n\tprivate standaloneMode = false;\n\tprivate embeddedMode = false;\n\n\tprivate nextMessageID() {\n\t\treturn this.currentMessageID++;\n\t}\n\n\tprivate makeUrl(endpoint, apiVersion) {\n\t\tif (!this.baseUrl) {\n\t\t\tconsole.error(\"Cannot use makeUrl without MyDataHelps.baseUrl.\");\n\t\t\tthrow \"Cannot use makeUrl without MyDataHelps.baseUrl.\";\n\t\t}\n\n\t\treturn this.baseUrl + 'api/' + apiVersion + '/delegated/' + endpoint;\n\t}\n\n\tprivate makeRequest(endpoint, method, body, apiVersion = \"v1\") {\n\t\tif (!this.token || !this.token.access_token) {\n\t\t\tthrow \"No access_token available for request authorization.\";\n\t\t}\n\n\t\tlet url = this.makeUrl(endpoint, apiVersion);\n\n\t\tlet headers = new Headers();\n\t\theaders.append('Authorization', 'Bearer ' + this.token.access_token);\n\t\theaders.append('Accept', 'application/json, text/javascript, */*; q=0.01');\n\t\theaders.append('Accept-Language', this.getCurrentLanguage());\n\t\tif (!!body) {\n\t\t\theaders.append('Content-Type', 'application/json');\n\t\t}\n\n\t\tlet init: any = {\n\t\t\tmethod: method,\n\t\t\theaders: headers\n\t\t};\n\t\tif (!!body) {\n\t\t\tinit.body = JSON.stringify(body);\n\t\t}\n\n\t\treturn fetch(url, init);\n\t}\n\n\tprivate getSupportedLanguage(language: string): string {\n\t\tlanguage = language.replace(\"_\", \"-\");\n\t\tif (this.supportedLanguages.length === 0) {\n\t\t\treturn language;\n\t\t} else {\n\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\treturn language;\n\t\t\t} else if (language.indexOf(\"-\") > 0) {\n\t\t\t\tlanguage = language.substring(0, language.indexOf(\"-\"));\n\t\t\t\tif (this.supportedLanguages.find((l) => l === language)) {\n\t\t\t\t\treturn language;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static validateResponse(response) {\n\t\tif (!response.ok) {\n\t\t\tthrow response.statusText;\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprivate static escapeParam(param) {\n\t\treturn String(param)\n\t\t\t.replaceAll(\"\\\\\", \"\\\\\\\\\")\n\t\t\t.replaceAll(\",\", \"\\\\,\");\n\t}\n\n\tprivate static reduceArrayAndEscape(param) {\n\t\tif (Array.isArray(param)) {\n\t\t\tlet escapedParams = param.map(function (elem) {\n\t\t\t\treturn MyDataHelps.escapeParam(elem);\n\t\t\t});\n\t\t\treturn escapedParams.join(\",\");\n\t\t}\n\n\t\treturn this.escapeParam(param);\n\t}\n\n\tprivate static convertDateToIsoString(date) {\n\t\tlet paramAsDate = new Date(date);\n\t\tif (isNaN(paramAsDate.getTime())) {\n\t\t\tthrow \"Cannot interpret parameter as Date\";\n\t\t}\n\n\t\treturn paramAsDate.toISOString();\n\t}\n\n\tprivate static flattenPropertyShallow(params, property) {\n\t\tif (params[property] === undefined || params[property] === null) return;\n\n\t\tfor (var key in params[property]) {\n\t\t\tif (params[property].hasOwnProperty(key)) {\n\t\t\t\tparams[`${property}.${key}`] = MyDataHelps.escapeParam(params[property][key]);\n\t\t\t}\n\t\t}\n\n\t\tdelete params[property];\n\t}\n\n\tprivate startEmbeddedSurveyInternal(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\treturn new Promise(function (resolve, reject) {\n\t\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\t\treject(\"Survey already in progress\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\t\tif (message.source !== frame) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t\t} else if (message.data.name === 'SurveyFinished') {\n\t\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\t\tresolve(message.data);\n\t\t\t\t}\n\t\t\t}, true);\n\n\t\t\tlet surveyModal = document.createElement('div');\n\t\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\t\tsurveyModal.id = mdhSurveyModalId;\n\t\t\tsurveyModal.innerHTML = \"<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='\" + surveyUrl + \"'></iframe></div>\";\n\t\t\tdocument.body.append(surveyModal);\n\t\t\tdocument.body.className += ' no-scroll';\n\t\t});\n\t}\n\n\tprivate startDelegatedSurvey(surveyUrl) {\n\t\tlet mdhSurveyModalId = 'mydatahelps-survey-modal';\n\t\tlet mdh = this;\n\n\t\tif (document.getElementById(mdhSurveyModalId)) {\n\t\t\treturn;\n\t\t}\n\n\t\twindow.addEventListener(\"message\", function listener(message) {\n\t\t\tif (message.origin !== new URL(mdh.baseUrl).origin) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet frame = (document.getElementById('mydatahelps-survey-frame') as HTMLFrameElement).contentWindow;\n\t\t\tif (message.source !== frame) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (message.data.name === 'GetDelegatedAccessToken') {\n\t\t\t\tmdh.getParticipantInfo().then((participant) => {\n\t\t\t\t\tframe.postMessage({ name: \"DelegatedAccessTokenResponse\", accessToken: mdh.token, baseUrl: mdh.baseUrl, participantID: participant.participantID }, '*');\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyWindowInitialized') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).className += \" loaded\";\n\t\t\t}\n\t\t\telse if (message.data.name === 'SurveyFinished') {\n\t\t\t\tdocument.getElementById(mdhSurveyModalId).remove();\n\t\t\t\tdocument.body.className = document.body.className.replace(\"no-scroll\", \"\");\n\t\t\t\twindow.removeEventListener(\"message\", listener, true);\n\t\t\t\tmessage.data.type = 'surveyDidFinish';\n\t\t\t\tmdh.triggerEvent(message.data);\n\t\t\t}\n\t\t}, true);\n\n\t\tlet surveyModal = document.createElement('div');\n\t\tsurveyModal.className = 'mydatahelps-survey-modal';\n\t\tsurveyModal.id = mdhSurveyModalId;\n\t\tsurveyModal.innerHTML = `<div class='mydatahelps-survey'><div class='loader'>Loading...</div><iframe id='mydatahelps-survey-frame' allow='camera' sandbox='allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts' src='${surveyUrl}&lang=${mdh.getCurrentLanguage()}'></iframe></div>`;\n\t\tdocument.body.append(surveyModal);\n\t\tdocument.body.className += ' no-scroll';\n\t}\n\n\tprivate handleConnectExternalAccountResponse() {\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (window.opener && params.get('connectExternalAccount') && params.get('messageID') && params.get('success')) {\n\t\t\twindow.opener.postMessage({\n\t\t\t\tname: 'ConnectExternalAccountResponse',\n\t\t\t\tmessageID: parseInt(params.get('messageID')),\n\t\t\t\tsuccess: params.get('success') === 'true'\n\t\t\t}, window.location.origin);\n\t\t\twindow.close();\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate hasEmbeddedModeUrlParameter() {\n\t\tconst embeddedModeKey = '_e';\n\t\tconst params = new URLSearchParams(window.location.search);\n\t\tif (params.has(embeddedModeKey) && params.get(embeddedModeKey) !== 'false') {\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n//iOS/Android directly invoke window.MyDataHelps and window.RKStudioClient\n//so it's necessary to explicitly ensure they are present on the window\nconst mdh = new MyDataHelps();\n\nwindow.MyDataHelps = mdh;\n\n// For backwards compatibility\nwindow.RKStudioClient = {};\nwindow.RKStudioClient.setActionResult = function (data) {\n\twindow.MyDataHelps.setActionResult(data);\n};\n\nexport default mdh;\nexport * from './types';\n"],"names":["MyDataHelps","startSurvey","surveyName","this","isStandaloneMode","startDelegatedSurvey","baseUrl","encodeURIComponent","window","webkit","messageHandlers","StartParticipantSurvey","messageID","nextMessageID","postMessage","completeStep","answer","JSON","stringify","ResearchKit","CompleteStep","querySurveyAnswers","queryParameters","Object","assign","hasOwnProperty","reduceArrayAndEscape","stepIdentifier","resultIdentifier","before","convertDateToIsoString","after","endpoint","URLSearchParams","toString","mdh","connect","then","makeRequest","response","validateResponse","json","querySurveyResults","event","insertedBefore","insertedAfter","deleteSurveyResult","resultID","querySurveyTasks","status","queryInboxItems","target","source","key","keys","value","undefined","assignDefined","type","getInboxItem","id","updateInboxItem","update","startEmbeddedSurvey","linkIdentifier","language","getCurrentLanguage","surveyUrl","startEmbeddedSurveyInternal","openExternalUrl","url","OpenExternalLink","openEmbeddedUrl","OpenEmbeddedLink","showTab","tabKey","ShowTab","openApplication","options","OpenExternalApplication","modal","dismiss","Dismiss","back","PopNavigation","showDashboard","dashboardKey","ShowParticipantDashboard","title","showWebVisualization","visualizationKey","parameters","ShowParticipantWebVisualization","showWebVisualizationPdf","ShowParticipantWebVisualizationPDF","landscape","htmlViewerZoom","showProject","projectCode","ShowProject","code","joinProject","JoinProject","on","eventName","callback","supportedEvents","includes","Error","registeredEventHandlers","push","off","eventHandlerIndex","indexOf","splice","triggerEvent","forEach","handler","setActionResult","data","prototype","call","console","error","getParticipantInfo","persistParticipantInfo","demographics","customFields","async","ok","message","catch","log","getProjectInfo","getDeviceDataPoint","deleteDeviceDataPoint","queryDeviceData","observedBefore","observedAfter","persistDeviceData","deviceDataPoints","queryDeviceDataV2","modifiedBefore","modifiedAfter","flattenPropertyShallow","queryDeviceDataV2Aggregate","aggregateFunctions","queryDeviceDataV2DailySleep","getDeviceDataV2AllDataTypes","enabled","getExternalAccountProviders","search","category","pageSize","pageNumber","searchParameters","connectExternalAccount","externalAccountProviderID","Promise","resolve","reject","connectProviderAccountResponse","success","errorMessage","standaloneMode","standaloneModeFinalRedirectPath","location","href","providerAuthWindow","openNewWindow","split","windowFeatures","width","height","w","h","outerHeight","screenY","outerWidth","screenX","open","queryString","finalRedirectPath","text","redirectUrl","replace","top","ConnectExternalAccount","getExternalAccounts","refreshExternalAccount","accountID","deleteExternalAccount","DeleteProviderAccount","deleteProviderAccountResponse","queryNotifications","sentBefore","sentAfter","queryFitbitDailySummaries","startDate","endDate","queryFitbitSleepLogs","queryAppleHealthActivitySummaries","queryAppleHealthWorkouts","uploadFile","file","fileName","size","name","fetch","preSignedUrl","method","body","headers","queryFiles","getFileDownloadUrl","deleteFile","refreshDelegatedAccessToken","token","refreshTokenPromise","tokenResponse","tokenExpires","Date","now","expires_in","setTimeout","accessTokenRenewalBufferSeconds","GetDelegatedAccessToken","isEmbeddedMode","setParticipantAccessToken","enableStandaloneMode","embeddedMode","setStatusBarStyle","style","SetStatusBarStyle","getDeviceInfo","GetDeviceInfo","deviceInfoResponse","setSupportedLanguages","languages","supportedLanguages","length","i","getStepConfiguration","GetStepConfiguration","stepConfigurationResponse","getSurveyContext","deviceInfo","platform","surveyMode","GetSurveyContext","surveyContextResponse","getCurrentSurveyAnswers","GetCurrentSurveyAnswers","currentSurveyAnswersResponse","setCurrentLanguage","supportedLanguage","getSupportedLanguage","warn","lang","searchParams","has","get","navigator","showGoogleFitSettings","ShowGoogleFitSettings","showHealthConnectSettings","HealthConnectSettings","showHealthConnectPrompt","HealthConnectPrompt","getHealthConnectStatus","HealthConnectStatus","statusResponse","showHealthConnectPhrPrompt","HealthConnectPhrPrompt","getHealthConnectPhrStatus","HealthConnectPhrStatus","requestReview","cooldownDays","RequestReview","trackCustomEvent","getDataCollectionSettings","getDataAvailability","invokeCustomApi","customApi","jsonResponse","toUpperCase","parameterString","constructor","acceptableParentDomains","unsupportedActions","currentMessageID","handleConnectExternalAccountResponse","supportedActions","applicationHost","ancestorOrigins","document","getParentOrigin","acceptableOrigin","origin","sourceURL","URL","k","hostname","endsWith","parent","action","windowHasAnyActions","actions","addActions","addEventListener","validateWindowMessageOrigin","hasEmbeddedModeUrlParameter","makeUrl","apiVersion","access_token","Headers","append","init","find","l","substring","statusText","escapeParam","param","String","replaceAll","Array","isArray","map","elem","join","date","paramAsDate","isNaN","getTime","toISOString","params","property","mdhSurveyModalId","getElementById","listener","frame","contentWindow","className","remove","removeEventListener","surveyModal","createElement","innerHTML","participant","accessToken","participantID","opener","parseInt","close","RKStudioClient"],"mappings":"MAMaA,EASZ,WAAAC,CAAYC,GACX,GAAIC,KAAKC,mBACRD,KAAKE,qBAAqB,GAAGF,KAAKG,6BAA6BC,mBAAmBL,WAE9E,GAAIM,OAAOC,OAAOC,gBAAgBC,uBAAwB,CAC9D,IAAIC,EAAYT,KAAKU,gBACrBL,OAAOC,OAAOC,gBAAgBC,u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rBnD,SAASpF,KAAKoI,WAAa,YAC3B,CAEO,oCAAApD,GACP,MAAM6C,EAAS,IAAI/S,gBAAgBzB,OAAO8J,SAASf,QACnD,GAAI/I,OAAOwV,QAAUhB,EAAO3E,IAAI,2BAA6B2E,EAAO3E,IAAI,cAAgB2E,EAAO3E,IAAI,WAOlG,OANA7P,OAAOwV,OAAOlV,YAAY,CACzBiM,KAAM,iCACNnM,UAAWqV,SAASjB,EAAO3E,IAAI,cAC/BnG,QAAmC,SAA1B8K,EAAO3E,IAAI,YAClB7P,OAAO8J,SAASoI,QACnBlS,OAAO0V,SACA,CAER,CAEO,2BAAA3C,GACP,MACMyB,EAAS,IAAI/S,gBAAgBzB,OAAO8J,SAASf,QACnD,GAAIyL,EAAO5E,IAFa,OAE2C,UAAhC4E,EAAO3E,IAFlB,MAGvB,OAAO,CAER,EAKF,MAAMlO,EAAM,IAAInC,EAEhBQ,OAAOR,YAAcmC,EAGrB3B,OAAO2V,eAAiB,CAAA,EACxB3V,OAAO2V,eAAe7O,gBAAkB,SAAUC,GACjD/G,OAAOR,YAAYsH,gBAAgBC,EACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careevolution/mydatahelps-js",
3
- "version": "3.36.0",
3
+ "version": "4.0.0",
4
4
  "description": "MyDataHelps client to be used by external applications for integrations inside the MyDataHelps platform",
5
5
  "type": "module",
6
6
  "types": "MyDataHelps.d.ts",
package/types.d.ts CHANGED
@@ -174,6 +174,14 @@ export interface SurveyTask {
174
174
  dueDate?: string;
175
175
  insertedDate: string;
176
176
  modifiedDate: string;
177
+ schedule?: ScheduleMetadata;
178
+ }
179
+ export interface ScheduleMetadata {
180
+ id: Guid;
181
+ name: string;
182
+ category?: string;
183
+ interval?: number;
184
+ intervalType?: "days" | "weeks" | "months" | "years";
177
185
  }
178
186
  export interface InboxItem {
179
187
  type: InboxItemType;
@@ -390,6 +398,32 @@ export interface SurveyAnswer {
390
398
  answers: string[];
391
399
  insertedDate: string;
392
400
  }
401
+ export interface SurveyResultsQuery extends QueryParameters {
402
+ surveyID?: string;
403
+ surveyName?: string | string[];
404
+ after?: string;
405
+ before?: string;
406
+ insertedAfter?: string;
407
+ insertedBefore?: string;
408
+ event?: string;
409
+ }
410
+ export interface SurveyResultsPage {
411
+ surveyResults: SurveyResult[];
412
+ nextPageID?: Guid;
413
+ }
414
+ export interface SurveyResult {
415
+ id: Guid;
416
+ surveyID: Guid;
417
+ surveyVersion: number;
418
+ taskID?: Guid;
419
+ surveyName: string;
420
+ surveyDisplayName: string;
421
+ date: string;
422
+ insertedDate: string;
423
+ schedule: ScheduleMetadata;
424
+ event: string;
425
+ userType: string;
426
+ }
393
427
  export interface FitbitQuery {
394
428
  providerID?: number;
395
429
  pageID?: Guid;