@elliemae/ssf-host 2.7.4 → 2.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/guest.js CHANGED
@@ -130,24 +130,41 @@ class Guest {
130
130
  guestUrl: this.url
131
131
  });
132
132
  /**
133
- * initialize guest messaging
134
- */
135
- init = () => {
136
- this.#remoting.addSender({ origin: this.origin, window: this.window });
137
- if (this.openMode === import_types.OpenMode.Popup) {
138
- const handShakeInterval = setInterval(() => {
133
+ * Handshake with the guest application in the popup window
134
+ * @returns true if the guest popup window is open & connected
135
+ */
136
+ handShake = () => new Promise((resolve) => {
137
+ let handShakeCount = 0;
138
+ const handShakeRetries = 5;
139
+ const handShakeHandle = setInterval(() => {
140
+ if (handShakeCount >= handShakeRetries) {
141
+ clearInterval(handShakeHandle);
142
+ resolve(false);
143
+ } else {
139
144
  this.#remoting.send({
140
145
  targetWin: this.window,
141
146
  targetOrigin: this.origin,
142
147
  messageType: import_microfe_common.MessageType.HandShake,
143
148
  messageBody: {}
144
149
  });
145
- }, 1e3);
146
- this.#remoting.listen({
147
- messageType: import_microfe_common.MessageType.HandShakeAck,
148
- callback: () => {
149
- clearInterval(handShakeInterval);
150
- }
150
+ handShakeCount += 1;
151
+ }
152
+ }, 1e3);
153
+ this.#remoting.listen({
154
+ messageType: import_microfe_common.MessageType.HandShakeAck,
155
+ callback: () => {
156
+ clearInterval(handShakeHandle);
157
+ resolve(true);
158
+ }
159
+ });
160
+ });
161
+ /**
162
+ * initialize guest messaging
163
+ */
164
+ init = () => {
165
+ this.#remoting.addSender({ origin: this.origin, window: this.window });
166
+ if (this.openMode === import_types.OpenMode.Popup) {
167
+ this.handShake().catch(() => {
151
168
  });
152
169
  }
153
170
  };
package/dist/cjs/host.js CHANGED
@@ -270,8 +270,13 @@ class SSFHost {
270
270
  });
271
271
  }
272
272
  };
273
- #handleGuestClose = ({ sourceWin }) => {
274
- if (sourceWin?.window) this.unloadGuest(sourceWin);
273
+ #handleGuestClose = async ({ sourceWin }) => {
274
+ if (sourceWin?.window) {
275
+ const guest = this.#findGuest(sourceWin);
276
+ if (guest && !await guest.handShake()) {
277
+ this.unloadGuest(sourceWin);
278
+ }
279
+ }
275
280
  };
276
281
  // Handles object get requests from the remote automation framework
277
282
  #handleObjectGet = ({
@@ -445,6 +450,7 @@ class SSFHost {
445
450
  });
446
451
  this.#remoting.listen({
447
452
  messageType: import_microfe_common.MessageType.GuestClose,
453
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
448
454
  callback: this.#handleGuestClose
449
455
  });
450
456
  this.#remoting.listen({
@@ -478,6 +484,20 @@ class SSFHost {
478
484
  this.#guests.set(param.guestId, guest);
479
485
  return guest;
480
486
  };
487
+ /**
488
+ * find the guest object by its id, window or dom element
489
+ * @param guestIdOrWindowOrEle id, window or dom element of the guest
490
+ * @returns guest object
491
+ */
492
+ #findGuest = (guestIdOrWindowOrEle) => {
493
+ let guest = typeof guestIdOrWindowOrEle === "string" ? this.#guests.get(guestIdOrWindowOrEle) : null;
494
+ if (!guest) {
495
+ guest = Array.from(this.#guests.values()).find(
496
+ (value) => value.window === guestIdOrWindowOrEle || value.domElement === guestIdOrWindowOrEle
497
+ );
498
+ }
499
+ return guest;
500
+ };
481
501
  #monitorPopupGuests = () => {
482
502
  this.#popupGuestMonitor = setInterval(() => {
483
503
  const guestsToRemove = [];
@@ -914,20 +934,14 @@ class SSFHost {
914
934
  * @throws Error if guestId or Window reference is invalid
915
935
  */
916
936
  unloadGuest = (guestIdOrWindowOrEle) => {
917
- let guest = typeof guestIdOrWindowOrEle === "string" ? this.#guests.get(guestIdOrWindowOrEle) : null;
918
- if (!guest) {
919
- guest = Array.from(this.#guests.values()).find(
920
- (value) => value.window === guestIdOrWindowOrEle || value.domElement === guestIdOrWindowOrEle
921
- );
922
- if (!guest) {
923
- throw new Error("Invalid guestId or guestWindow reference");
924
- }
937
+ const guest = this.#findGuest(guestIdOrWindowOrEle);
938
+ if (guest) {
939
+ guest.dispose();
940
+ this.#guests.delete(guest.id);
941
+ this.#logger.audit({
942
+ message: `Guest is removed from host`,
943
+ ...guest.getInfo()
944
+ });
925
945
  }
926
- guest.dispose();
927
- this.#guests.delete(guest.id);
928
- this.#logger.audit({
929
- message: `Guest is removed from host`,
930
- ...guest.getInfo()
931
- });
932
946
  };
933
947
  }
package/dist/esm/guest.js CHANGED
@@ -107,24 +107,41 @@ class Guest {
107
107
  guestUrl: this.url
108
108
  });
109
109
  /**
110
- * initialize guest messaging
111
- */
112
- init = () => {
113
- this.#remoting.addSender({ origin: this.origin, window: this.window });
114
- if (this.openMode === OpenMode.Popup) {
115
- const handShakeInterval = setInterval(() => {
110
+ * Handshake with the guest application in the popup window
111
+ * @returns true if the guest popup window is open & connected
112
+ */
113
+ handShake = () => new Promise((resolve) => {
114
+ let handShakeCount = 0;
115
+ const handShakeRetries = 5;
116
+ const handShakeHandle = setInterval(() => {
117
+ if (handShakeCount >= handShakeRetries) {
118
+ clearInterval(handShakeHandle);
119
+ resolve(false);
120
+ } else {
116
121
  this.#remoting.send({
117
122
  targetWin: this.window,
118
123
  targetOrigin: this.origin,
119
124
  messageType: MessageType.HandShake,
120
125
  messageBody: {}
121
126
  });
122
- }, 1e3);
123
- this.#remoting.listen({
124
- messageType: MessageType.HandShakeAck,
125
- callback: () => {
126
- clearInterval(handShakeInterval);
127
- }
127
+ handShakeCount += 1;
128
+ }
129
+ }, 1e3);
130
+ this.#remoting.listen({
131
+ messageType: MessageType.HandShakeAck,
132
+ callback: () => {
133
+ clearInterval(handShakeHandle);
134
+ resolve(true);
135
+ }
136
+ });
137
+ });
138
+ /**
139
+ * initialize guest messaging
140
+ */
141
+ init = () => {
142
+ this.#remoting.addSender({ origin: this.origin, window: this.window });
143
+ if (this.openMode === OpenMode.Popup) {
144
+ this.handShake().catch(() => {
128
145
  });
129
146
  }
130
147
  };
package/dist/esm/host.js CHANGED
@@ -257,8 +257,13 @@ class SSFHost {
257
257
  });
258
258
  }
259
259
  };
260
- #handleGuestClose = ({ sourceWin }) => {
261
- if (sourceWin?.window) this.unloadGuest(sourceWin);
260
+ #handleGuestClose = async ({ sourceWin }) => {
261
+ if (sourceWin?.window) {
262
+ const guest = this.#findGuest(sourceWin);
263
+ if (guest && !await guest.handShake()) {
264
+ this.unloadGuest(sourceWin);
265
+ }
266
+ }
262
267
  };
263
268
  // Handles object get requests from the remote automation framework
264
269
  #handleObjectGet = ({
@@ -432,6 +437,7 @@ class SSFHost {
432
437
  });
433
438
  this.#remoting.listen({
434
439
  messageType: MessageType.GuestClose,
440
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
435
441
  callback: this.#handleGuestClose
436
442
  });
437
443
  this.#remoting.listen({
@@ -465,6 +471,20 @@ class SSFHost {
465
471
  this.#guests.set(param.guestId, guest);
466
472
  return guest;
467
473
  };
474
+ /**
475
+ * find the guest object by its id, window or dom element
476
+ * @param guestIdOrWindowOrEle id, window or dom element of the guest
477
+ * @returns guest object
478
+ */
479
+ #findGuest = (guestIdOrWindowOrEle) => {
480
+ let guest = typeof guestIdOrWindowOrEle === "string" ? this.#guests.get(guestIdOrWindowOrEle) : null;
481
+ if (!guest) {
482
+ guest = Array.from(this.#guests.values()).find(
483
+ (value) => value.window === guestIdOrWindowOrEle || value.domElement === guestIdOrWindowOrEle
484
+ );
485
+ }
486
+ return guest;
487
+ };
468
488
  #monitorPopupGuests = () => {
469
489
  this.#popupGuestMonitor = setInterval(() => {
470
490
  const guestsToRemove = [];
@@ -901,21 +921,15 @@ class SSFHost {
901
921
  * @throws Error if guestId or Window reference is invalid
902
922
  */
903
923
  unloadGuest = (guestIdOrWindowOrEle) => {
904
- let guest = typeof guestIdOrWindowOrEle === "string" ? this.#guests.get(guestIdOrWindowOrEle) : null;
905
- if (!guest) {
906
- guest = Array.from(this.#guests.values()).find(
907
- (value) => value.window === guestIdOrWindowOrEle || value.domElement === guestIdOrWindowOrEle
908
- );
909
- if (!guest) {
910
- throw new Error("Invalid guestId or guestWindow reference");
911
- }
924
+ const guest = this.#findGuest(guestIdOrWindowOrEle);
925
+ if (guest) {
926
+ guest.dispose();
927
+ this.#guests.delete(guest.id);
928
+ this.#logger.audit({
929
+ message: `Guest is removed from host`,
930
+ ...guest.getInfo()
931
+ });
912
932
  }
913
- guest.dispose();
914
- this.#guests.delete(guest.id);
915
- this.#logger.audit({
916
- message: `Guest is removed from host`,
917
- ...guest.getInfo()
918
- });
919
933
  };
920
934
  }
921
935
  export {
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Host</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://qa.assets.rd.elliemae.io/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.40d624577eb78b3aeb0c.js"></script></head><body><header class="bg-indigo-300 h-10 flex place-items-center"><div class="px-2">ICE Mortgage Product</div></header><main class="mx-auto max-w-7xl px-2 sm:px-6 lg:px-8"><div class="min-w-0 flex-1 mt-4"><h1 class="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight">Loan Application</h1></div><div id="successFeedback" class="hidden rounded-md bg-green-50 p-4"><div class="flex"><div class="flex-shrink-0"><svg class="h-5 w-5 text-green-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"/></svg></div><div class="ml-3"><p class="text-sm font-medium text-green-800">Loan Saved Successfully</p></div></div></div><div id="errorFeedback" class="hidden rounded-md bg-red-50 p-4"><div class="flex"><div class="flex-shrink-0"><svg class="h-5 w-5 text-red-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd"/></svg></div><div class="ml-3"><h3 class="text-sm font-medium text-red-800">Credit Score is not meeting the requirement</h3></div></div></div><div class="mt-2 sm:grid sm:grid-cols-2 sm:gap-2"><form class="px-2 py-2 space-y-8 divide-y divide-gray-200 bg-gray-50"><div class="space-y-8 divide-y divide-gray-200 sm:space-y-5"><div class="space-y-6 sm:space-y-5"><div><h3 class="text-lg font-medium leading-6 text-gray-900">Personal Information</h3></div><div class="space-y-6 sm:space-y-5"><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="firstName" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">First name</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input name="firstName" id="firstName" autocomplete="given-name" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="John" placeholder="John"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="lastName" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Last name</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input name="lastName" id="lastName" autocomplete="family-name" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="Doe" placeholder="Doe"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="ssn" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">SSN</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="ssn" id="ssn" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="123456789" placeholder="123456789"/></div></div></div><div><h3 class="text-lg font-medium leading-6 text-gray-900">Loan Information</h3></div><div class="space-y-6 sm:space-y-5"><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="amount" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Amount</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="amount" id="amount" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="500000" placeholder="500000"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="Term" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Term (years)</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="term" id="term" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="30" placeholder="30"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="downPayment" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Down Payment</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="downPayment" id="downPayment" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="50000" placeholder="50000"/></div></div><div><h3 class="text-lg font-medium leading-6 text-gray-900">Order Services</h3></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><div class="mt-1 sm:mt-0"><button id="title" type="button" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed focus:ring-offset-2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6"><path fill-rule="evenodd" d="M7.502 6h7.128A3.375 3.375 0 0118 9.375v9.375a3 3 0 003-3V6.108c0-1.505-1.125-2.811-2.664-2.94a48.972 48.972 0 00-.673-.05A3 3 0 0015 1.5h-1.5a3 3 0 00-2.663 1.618c-.225.015-.45.032-.673.05C8.662 3.295 7.554 4.542 7.502 6zM13.5 3A1.5 1.5 0 0012 4.5h4.5A1.5 1.5 0 0015 3h-1.5z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M3 9.375C3 8.339 3.84 7.5 4.875 7.5h9.75c1.036 0 1.875.84 1.875 1.875v11.25c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 013 20.625V9.375zM6 12a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V12zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75zM6 15a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V15zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75zM6 18a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V18zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75z" clip-rule="evenodd"/></svg> Title</button></div><div class="mt-1 sm:mt-0"><button id="credit" type="button" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed focus:ring-offset-2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6"><path fill-rule="evenodd" d="M2.25 13.5a8.25 8.25 0 018.25-8.25.75.75 0 01.75.75v6.75H18a.75.75 0 01.75.75 8.25 8.25 0 01-16.5 0z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M12.75 3a.75.75 0 01.75-.75 8.25 8.25 0 018.25 8.25.75.75 0 01-.75.75h-7.5a.75.75 0 01-.75-.75V3z" clip-rule="evenodd"/></svg> Credit Score</button></div></div></div></div></div><div class="flex flex-col"><button id="saveLoan" type="button" class="rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">Save</button></div></form><div id="aside-container" class="flex flex-col gap-4 items-start mt-4 border-2 p-2 rounded-lg border-dashed border-cyan-300 sm:mt-0"></div></div><div id="bottom-container" class="flex flex-col gap-4 items-start mt-4 p-2 sm:mt-0"></div></main><script src="./init.js" type="module"></script></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Host</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://qa.assets.rd.elliemae.io/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.7cccf3d0afe21a4dcebe.js"></script></head><body><header class="bg-indigo-300 h-10 flex place-items-center"><div class="px-2">ICE Mortgage Product</div></header><main class="mx-auto max-w-7xl px-2 sm:px-6 lg:px-8"><div class="min-w-0 flex-1 mt-4"><h1 class="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight">Loan Application</h1></div><div id="successFeedback" class="hidden rounded-md bg-green-50 p-4"><div class="flex"><div class="flex-shrink-0"><svg class="h-5 w-5 text-green-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"/></svg></div><div class="ml-3"><p class="text-sm font-medium text-green-800">Loan Saved Successfully</p></div></div></div><div id="errorFeedback" class="hidden rounded-md bg-red-50 p-4"><div class="flex"><div class="flex-shrink-0"><svg class="h-5 w-5 text-red-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z" clip-rule="evenodd"/></svg></div><div class="ml-3"><h3 class="text-sm font-medium text-red-800">Credit Score is not meeting the requirement</h3></div></div></div><div class="mt-2 sm:grid sm:grid-cols-2 sm:gap-2"><form class="px-2 py-2 space-y-8 divide-y divide-gray-200 bg-gray-50"><div class="space-y-8 divide-y divide-gray-200 sm:space-y-5"><div class="space-y-6 sm:space-y-5"><div><h3 class="text-lg font-medium leading-6 text-gray-900">Personal Information</h3></div><div class="space-y-6 sm:space-y-5"><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="firstName" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">First name</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input name="firstName" id="firstName" autocomplete="given-name" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="John" placeholder="John"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="lastName" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Last name</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input name="lastName" id="lastName" autocomplete="family-name" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="Doe" placeholder="Doe"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="ssn" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">SSN</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="ssn" id="ssn" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="123456789" placeholder="123456789"/></div></div></div><div><h3 class="text-lg font-medium leading-6 text-gray-900">Loan Information</h3></div><div class="space-y-6 sm:space-y-5"><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="amount" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Amount</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="amount" id="amount" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="500000" placeholder="500000"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="Term" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Term (years)</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="term" id="term" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="30" placeholder="30"/></div></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><label for="downPayment" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">Down Payment</label><div class="mt-1 sm:col-span-2 sm:mt-0"><input type="number" name="downPayment" id="downPayment" class="block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:max-w-xs sm:text-sm" value="50000" placeholder="50000"/></div></div><div><h3 class="text-lg font-medium leading-6 text-gray-900">Order Services</h3></div><div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:border-gray-200"><div class="mt-1 sm:mt-0"><button id="title" type="button" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed focus:ring-offset-2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6"><path fill-rule="evenodd" d="M7.502 6h7.128A3.375 3.375 0 0118 9.375v9.375a3 3 0 003-3V6.108c0-1.505-1.125-2.811-2.664-2.94a48.972 48.972 0 00-.673-.05A3 3 0 0015 1.5h-1.5a3 3 0 00-2.663 1.618c-.225.015-.45.032-.673.05C8.662 3.295 7.554 4.542 7.502 6zM13.5 3A1.5 1.5 0 0012 4.5h4.5A1.5 1.5 0 0015 3h-1.5z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M3 9.375C3 8.339 3.84 7.5 4.875 7.5h9.75c1.036 0 1.875.84 1.875 1.875v11.25c0 1.035-.84 1.875-1.875 1.875h-9.75A1.875 1.875 0 013 20.625V9.375zM6 12a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V12zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75zM6 15a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V15zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75zM6 18a.75.75 0 01.75-.75h.008a.75.75 0 01.75.75v.008a.75.75 0 01-.75.75H6.75a.75.75 0 01-.75-.75V18zm2.25 0a.75.75 0 01.75-.75h3.75a.75.75 0 010 1.5H9a.75.75 0 01-.75-.75z" clip-rule="evenodd"/></svg> Title</button></div><div class="mt-1 sm:mt-0"><button id="credit" type="button" class="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed focus:ring-offset-2"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6"><path fill-rule="evenodd" d="M2.25 13.5a8.25 8.25 0 018.25-8.25.75.75 0 01.75.75v6.75H18a.75.75 0 01.75.75 8.25 8.25 0 01-16.5 0z" clip-rule="evenodd"/><path fill-rule="evenodd" d="M12.75 3a.75.75 0 01.75-.75 8.25 8.25 0 018.25 8.25.75.75 0 01-.75.75h-7.5a.75.75 0 01-.75-.75V3z" clip-rule="evenodd"/></svg> Credit Score</button></div></div></div></div></div><div class="flex flex-col"><button id="saveLoan" type="button" class="rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">Save</button></div></form><div id="aside-container" class="flex flex-col gap-4 items-start mt-4 border-2 p-2 rounded-lg border-dashed border-cyan-300 sm:mt-0"></div></div><div id="bottom-container" class="flex flex-col gap-4 items-start mt-4 p-2 sm:mt-0"></div></main><script src="./init.js" type="module"></script></body></html>
@@ -0,0 +1,3 @@
1
+ (function(y,m){typeof exports=="object"&&typeof module=="object"?module.exports=m():typeof define=="function"&&define.amd?define([],m):typeof exports=="object"?exports.ice=m():(y.ice=y.ice||{},y.ice.host=m())})(globalThis,()=>(()=>{"use strict";var b={};b.d=(n,e)=>{for(var t in e)b.o(e,t)&&!b.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},b.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),b.r=n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var y={};b.r(y),b.d(y,{Event:()=>m,Guest:()=>P,IFrameSandboxValues:()=>v,OpenMode:()=>f,SSFHost:()=>Y,ScriptingObject:()=>I});class m{scriptingObject;name;objectId;requiresFeedback;id;constructor(e){const{name:t,requiresFeedback:i=!1,so:s}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object is required");this.scriptingObject=s,this.objectId=s.id,this.name=t,this.id=`${this.objectId}.${this.name}`.toLowerCase(),this.requiresFeedback=i}}class C{static[Symbol.hasInstance](e){return e.getType?.()==="ProxyEvent"}objectId;name;id;getType(){return"ProxyEvent"}constructor(e){const{name:t,objectId:i}=e;this.objectId=i,this.name=t,this.id=`${this.objectId}.${this.name}`.toLowerCase()}}const _=n=>n instanceof m,Q=(n,e)=>`${n.toLowerCase()}.${e.toLowerCase()}`,x="function",L=(n,e)=>typeof n===x&&!!e&&!e.startsWith("_");class I{#t;#e="Object";constructor(e,t){this.#t=e,this.#e=t||this.#e}get id(){return this.#t}get objectType(){return this.#e}_toJSON=()=>{const e=[],t=[];return Object.keys(this).forEach(i=>{const s=this[i];_(s)?t.push(i):L(s,i)&&e.push(i)}),{objectId:this.#t,objectType:this.#e,functions:e,events:t}};_dispose=()=>{};dispose=()=>{}}var p=(n=>(n.GuestReady="guest:ready",n.GuestClose="guest:close",n.GuestReadyComplete="guest:readyComplete",n.GuestResize="guest:resize",n.GuestFocus="guest:focus",n.HandShake="handshake",n.HandShakeAck="handshake:ack",n.ObjectInvoke="object:invoke",n.ObjectGet="object:get",n.ObjectEvent="object:event",n.HostConfig="host:config",n))(p||{}),f=(n=>(n.Popup="popup",n.Embed="embed",n))(f||{}),v=(n=>(n.AllowDownloadsWithoutUserActivation="allow-downloads-without-user-activation",n.AllowDownloads="allow-downloads",n.AllowForms="allow-forms",n.AllowModals="allow-modals",n.AllowOrientationLock="allow-orientation-lock",n.AllowPointerLock="allow-pointer-lock",n.AllowPopups="allow-popups",n.AllowPopupsToEscapeSandbox="allow-popups-to-escape-sandbox",n.AllowPresentation="allow-presentation",n.AllowSameOrigin="allow-same-origin",n.AllowScripts="allow-scripts",n.AllowStorageAccessByUserActivation="allow-storage-access-by-user-activation",n.AllowTopNavigation="allow-top-navigation",n.AllowTopNavigationByUserActivation="allow-top-navigation-by-user-activation",n))(v||{});const z=n=>{if(n==="about:blank")return"*";try{const{origin:e}=new URL(n);return e==="null"||!e?n:e}catch{const{origin:t}=new URL(n,document.baseURI);return t}},$=(n,e=[])=>{const t=e||[];return n&&n.forEach?n.forEach(i=>{$(i,t)}):typeof n<"u"&&t.push(n),t},Z=n=>typeof n?._toJSON=="function";function k(n){return typeof n=="function"}const N=n=>n?.constructor?.name==="Proxy",V=n=>n?.id??n;class P{id;title;url;searchParams;domElement;window;openMode;origin;initialized=!1;ready=!1;capabilities;#t;#e;constructor(e){const{guestId:t,domElement:i=null,title:s,url:o,window:r,searchParams:c={},openMode:a=f.Embed,remoting:d,analyticsObj:l}=e;this.id=t,this.title=s,this.url=o,this.origin=z(o),this.searchParams=c,this.domElement=i,this.window=r,this.openMode=a,this.capabilities={},this.#e=l,this.#t=d}dispose=()=>{if(this.#t.removeSender({origin:this.origin,window:this.window}),this.openMode===f.Popup&&!this.window.closed)try{this.window.document,this.window.close()}catch{}else this.domElement?.remove?.()};getInfo=()=>({guestId:this.id,guestTitle:this.title,guestUrl:this.url});handShake=()=>new Promise(e=>{let t=0;const i=5,s=setInterval(()=>{t>=i?(clearInterval(s),e(!1)):(this.#t.send({targetWin:this.window,targetOrigin:this.origin,messageType:p.HandShake,messageBody:{}}),t+=1)},1e3);this.#t.listen({messageType:p.HandShakeAck,callback:()=>{clearInterval(s),e(!0)}})});init=()=>{this.#t.addSender({origin:this.origin,window:this.window}),this.openMode===f.Popup&&this.handShake().catch(()=>{})};dispatchEvent=(e,t)=>(this.#e.startTiming(`ScriptingObject.Event.${e.object.objectId}.${e.eventName}`,{appId:this.id,appUrl:this.url}).catch(()=>{}),this.#t.invoke({targetWin:this.window,targetOrigin:this.origin,messageType:p.ObjectEvent,messageBody:e,responseTimeoutMs:t}).finally(()=>{this.#e.endTiming(`ScriptingObject.Event.${e.object.objectId}.${e.eventName}`,{appId:this.id,appUrl:this.url}).catch(()=>{})}));send=e=>{this.#t.send({targetWin:this.window,targetOrigin:this.origin,...e})}}const G={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let S;const D=new Uint8Array(16);function B(){if(!S&&(S=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!S))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return S(D)}const h=[];for(let n=0;n<256;++n)h.push((n+256).toString(16).slice(1));function A(n,e=0){return h[n[e+0]]+h[n[e+1]]+h[n[e+2]]+h[n[e+3]]+"-"+h[n[e+4]]+h[n[e+5]]+"-"+h[n[e+6]]+h[n[e+7]]+"-"+h[n[e+8]]+h[n[e+9]]+"-"+h[n[e+10]]+h[n[e+11]]+h[n[e+12]]+h[n[e+13]]+h[n[e+14]]+h[n[e+15]]}function te(n,e=0){const t=A(n,e);if(!validate(t))throw TypeError("Stringified UUID is invalid");return t}const ie=null;function F(n,e,t){if(G.randomUUID&&!e&&!n)return G.randomUUID();n=n||{};const i=n.random||(n.rng||B)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let s=0;s<16;++s)e[t+s]=i[s];return e}return A(i)}const T=F,R="elli:remoting",q="elli:remoting:response",U="elli:remoting:exception",O=({messageType:n,messageBody:e,onewayMsg:t=!1})=>({requestId:t?null:T(),source:R,type:n,body:e}),se=n=>{const{targetWin:e,targetOrigin:t,messageType:i,messageBody:s}=n,o=O({messageType:i,messageBody:s});e.postMessage(o,t)};class H{#t;#e;#i=new Map;#n=new Map;#s=null;#o=new Map;constructor(e,t){if(!e)throw new Error("logger is required");if(!t)throw new Error("correlationId is required");this.#t=t,this.#e=e}#a=()=>{const e=Date.now(),t=[];this.#n.forEach((i,s)=>{const{requestId:o,cancelTime:r}=i;this.#e.debug(`Checking response timeout for requestId: ${o}) @ ${r??""}`),i.cancelTime&&i.cancelTime<e&&(this.#e.debug(`Detected response timeout for requestId: ${o}...`),t.push(s),i.resolve(),this.#e.debug(`Aborted waiting for response to requestid: ${o})`))}),t.forEach(i=>{this.#e.debug(`removing invocations with requestId ${i} from cache since response time has expired`),this.#n.delete(i)}),this.#n.size===0&&(this.#e.debug("stopping response monitor"),this.#g())};#u=()=>{this.#s===null&&(this.#e.debug("Staring response timeout evaluator"),this.#s=window.setInterval(this.#a,200))};#g=()=>{this.#s!==null&&(window.clearInterval(this.#s),this.#s=null,this.#e.debug("Stopped response timeout evaluator"))};#c=e=>{const t=this.#n.get(e);return this.#e.debug(`serving requestId: ${e}`),this.#n.delete(e),t};#d=e=>{const{requestId:t}=e;this.#e.debug(`Response received for invocation requestId: ${t}`);const i=this.#c(t);return i?(i.resolve(e.body),!0):(this.#e.warn(`Received response to stale/invalid request with requestId: ${t}`),!1)};#h=e=>{this.#e.debug(`Exception received for invocation (requestId = ${e.requestId})`);const t=this.#c(e.requestId);return t?(t.reject(new Error(e.body)),!0):(this.#e.warn(`Received exception for stale/invalid request (requestId = ${e.requestId})`),!1)};#r=({sourceWin:e,sourceOrigin:t,message:i})=>{this.#e.debug(`Received message of type "${i.type}"`);const s=this.#i.get(i.type);return s?(s.forEach(o=>{this.#e.debug(`Invoking message handler ${o.name}`),o({sourceWin:e,sourceOrigin:t,requestId:i.requestId,type:i.type,body:i.body})}),!0):!1};#l=e=>{if(this.#e.debug(`Remoting: Received message ${JSON.stringify(e.data)}`),this.#o.size===0||!e.source)return!1;const t=this.#o.get(e.source);return!t||e?.data?.source!==R?!1:(e.data.type===q?this.#d(e.data):e.data.type===U?this.#h(e.data):this.#r({sourceWin:e.source,sourceOrigin:t,message:e.data}),!0)};addSender=e=>{const{origin:t,window:i}=e;if(!t)throw new Error("origin is required");if(!i)throw new Error("window is required");this.#o.set(i,t)};initialize=e=>{e.removeEventListener("message",this.#l),e.addEventListener("message",this.#l),this.#e.debug(`initialized remoting id: ${this.#t}`)};close=()=>{window.removeEventListener("message",this.#l),this.#e.debug(`closed remoting id: ${this.#t}`)};invoke=e=>{const{targetWin:t,targetOrigin:i,messageType:s,messageBody:o,responseTimeoutMs:r}=e;return new Promise((c,a)=>{const d=O({messageType:s,messageBody:o});this.#n.set(d.requestId,{requestId:d.requestId,resolve:c,reject:a,cancelTime:r?Date.now()+Number.parseInt(r,10):null}),t.postMessage(d,i);const{requestId:l}=d;this.#e.debug(`Posted invocation message of type ${s} requestId: ${l||""}`),r&&(this.#e.debug(`starting response monitor for requestId: ${l||""} for ${r} ms`),this.#u())})};listen=e=>{const{messageType:t,callback:i}=e,s=this.#i.get(t)||[];s.push(i),this.#i.set(t,s)};send=e=>{const{targetWin:t,targetOrigin:i,messageType:s,messageBody:o}=e,r=O({messageType:s,messageBody:o,onewayMsg:!0});t.postMessage(r,i),this.#e.debug(`Posted one-way message of type "${s}"`)};removeSender=e=>{const{window:t}=e;t&&this.#o.delete(t)};respond=e=>{const{targetWin:t,targetOrigin:i,requestId:s,response:o}=e,r=O({messageType:q,messageBody:o});r.requestId=s,t.postMessage(r,i),this.#e.debug(`Response sent to caller for invocation requestId: ${s}`)};raiseException=e=>{const{targetWin:t,targetOrigin:i,requestId:s,ex:o}=e,r=O({messageType:U,messageBody:o});r.requestId=s,t.postMessage(r,i),this.#e.debug(`Exception sent to caller for invocation. requestId: ${s}`)}}const M="module";var W=(n=>(n.USER="USER",n.PARTNER="PARTNER",n))(W||{});class J{#t=new Map;#e=new Map;#i=e=>{const{so:t,guestId:i}=e,s=t.id.toLowerCase(),o=this.#e.get(i);if(!o)this.#e.set(i,new Map([[s,e]]));else{if(o.has(s))throw new Error(`Scripting Object ${t.id} already exists for guest ${i}`);o.set(s,e)}};#n=({so:e})=>{e._dispose&&typeof e._dispose=="function"&&e._dispose()};#s=({objectId:e,guestId:t})=>{if(e===M&&!t)for(const[,s]of this.#e){const o=s.get(e);if(o)return o}const i=t?this.#e.get(t):null;return i?i.get(e)??null:null};#o=({objectId:e,guestId:t}={})=>{if(t){if(!e){const s=this.#e.get(t);s&&s.forEach(this.#n),this.#e.delete(t);return}const i=this.#e.get(t);if(i){const s=i.get(e);s&&this.#n(s),i.delete(e)}}else e&&this.#e.forEach(i=>{const s=i.get(e);s&&this.#n(s),i.delete(e)})};#a=({so:e,guest:t})=>new Proxy(e,{get(i,s,o){const r=i[s];return r instanceof Function&&s!=="constructor"?function(...c){const a=this;return Object.defineProperty(r,"callContext",{value:t,enumerable:!1,writable:!0}),r.apply(a===o?i:a,c)}:r}});addScriptingObject=(e,t)=>{const{guestId:i}=t||{};if(!e?.id||!e?._toJSON)throw new Error("Object is not derived from ScriptingObject");const s=e.id.toLowerCase();if(s.trim().toLowerCase()===M&&!i)throw new Error("Guest id is required to add Module scripting object");if(i){this.#i({so:e,...t,guestId:i});return}if(this.#t.has(s))throw new Error(`Scripting Object ${e.id} already exists`);this.#t.set(s,{so:e,...t})};getObject=(e,t)=>{const i=e.trim().toLowerCase();let s=this.#s({objectId:i,guestId:t?.id});s=s??this.#t.get(i)??null;const{so:o}=s||{};if(!o)return null;if(!t)return o;const r=this.#a({so:o,guest:t});return Object.defineProperty(r,"target",{value:o,enumerable:!1,configurable:!1,writable:!0}),r};removeScriptingObject=(e,t)=>{const i=e.toLowerCase();if(t)this.#o({objectId:i,guestId:t});else{this.#o({objectId:i});const s=this.#t.get(i);s&&this.#n(s),this.#t.delete(i)}};removeAllScriptingObjects=e=>{e?this.#o({guestId:e}):(this.#t.forEach(this.#n),this.#t.clear())}}const X=[v.AllowScripts,v.AllowPopups,v.AllowModals,v.AllowForms,v.AllowDownloads,v.AllowSameOrigin].join(" ");class Y{hostId;#t;#e;#i;#n;#s=new Map;#o;#a=null;#u=null;constructor(e,t){if(this.hostId=e,!t?.logger)throw new Error("Logger is required");if(!t?.analyticsObj)throw new Error("Analytics object is required");if(this.#i=t.logger,this.#n=t.analyticsObj,this.#e=T(),this.#t=new H(this.#i,this.#e),t?.readyStateCallback&&typeof t?.readyStateCallback!="function")throw new Error("readyStateCallback must be a function");this.#a=t?.readyStateCallback||null,this.#o=new J,this.#t.initialize(window),this.#P(),this.#A(),this.#i.debug(`host is initialized. hostId: ${this.hostId}, correlationId: ${this.#e}`)}#g=(e,t)=>{const i={event:e,...t};this.#n.sendBAEvent(i).catch(()=>{})};#c=(e,t)=>{this.#n.startTiming(e,t).catch(()=>{})};#d=(e,t)=>{this.#n.endTiming(e,t).catch(()=>{})};#h=()=>{for(const e of this.#s.values())e.openMode===f.Popup&&this.unloadGuest(e.id)};#r=e=>Array.from(this.#s.values()).find(t=>t.window===e);#l=e=>{for(const t of this.#s.values())if(t.url===e)return t;return null};#v=e=>typeof e?._toJSON=="function";#p=e=>this.#v(e)?{type:"object",object:e._toJSON()}:{type:"value",value:e};#y=e=>typeof e=="string"?e:e instanceof Error?e.message:"An unexpected error occurred in the host application";#f=e=>{e.ready&&this.#t.send({targetWin:e.window,targetOrigin:e.origin,messageType:p.HostConfig,messageBody:{logLevel:this.#i.getLogLevel(),...e.getInfo()}})};#E=({guest:e,obj:t,functionName:i,functionParams:s})=>{const o=t[i];return k(o)?(this.#i.debug(`Invoking host implementation of ${t.id}.${String(i)}()`),new Promise(r=>{Object.prototype.hasOwnProperty.call(o,"callContext")||Object.defineProperty(o,"callContext",{value:{guest:e},enumerable:!0}),r(o(...s))})):(this.#i.warn(`Attempt to call invalid function on object type ${t.objectType}: ${String(i)}`),Promise.reject(new Error(`Method '${i}' not found in Scripting Object '${t.id}'`)))};#w=({sourceWin:e,sourceOrigin:t,requestId:i})=>{const s=this.#r(e);if(!s){this.#i.warn(`Received ready event for unknown guest. requestId: ${i}`);return}if(!s.initialized){this.#i.warn("Guest must be initialized before it is marked as ready"),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:"Guest must be initialized before it is marked as ready"});return}if(!s.ready){s.ready=!0;const o=s.getInfo();this.#d("SSF.Guest.Load",{appId:o.guestId,appUrl:o.guestUrl}),this.#f(s),this.#a?.(s),this.#i.audit({message:"Guest is ready",...o})}};#j=({sourceWin:e,sourceOrigin:t,requestId:i,body:s})=>{const o=this.#r(e);if(!o){this.#i.warn(`Received ready event for unknown guest. requestid = ${i}`);return}o.initialized||(o.initialized=!0,o.capabilities=s||{},this.#i.audit({message:"Guest is initialized",...o.getInfo()})),(!s||!s.onReady)&&this.#w({sourceWin:e,sourceOrigin:t,requestId:i,type:"",body:null})};#O=async({sourceWin:e})=>{if(e?.window){const t=this.#m(e);t&&!await t.handShake()&&this.unloadGuest(e)}};#S=({sourceWin:e,sourceOrigin:t,requestId:i,body:s})=>{const{objectId:o}=s;this.#i.debug(`Processing getObject request for object ${o}. requestId = ${i}`);const r=this.#r(e);if(!r)return this.#i.warn("Rejected object request from unknown guest window"),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:"Specified window is not a known guest"}),!1;const c=this.getScriptingObject(o,{guest:r});return c?(this.#t.respond({targetWin:e,targetOrigin:t,requestId:i,response:this.#p(c)}),this.#i.audit({message:"Scripting Object returned",requestId:i,scriptingObject:o,...r.getInfo()}),!0):(this.#i.warn(`unknown or unauthorized object ${o} from guest ${r.id}`),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:`The requested object (${o}) is not available`}),!1)};#I=({sourceWin:e,requestId:t,body:i})=>{const s=this.#r(e);if(!s){this.#i.warn(`Received resize event from unknown guest. requestid = ${t}`);return}s.domElement&&(s.domElement.style.height=`${i.height}px`),this.#i.debug(`Guest ${s.id} resized to ${i.width}x${i.height}`)};#$=({sourceWin:e,sourceOrigin:t,requestId:i,body:s})=>{const{objectId:o}=s,r=this.#r(e);if(!r)return this.#i.warn("Rejected method invocation request from unknown guest window"),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:"Specified window is not a known guest"}),!1;this.#i.debug(`Function ${o}.${String(s.functionName)}() called from guest "${r.id}" (requestId = ${i})`);const c=this.getScriptingObject(o);if(!c)return this.#i.warn(`Invocation of unknown or unauthorized object ${o} from guest ${r.id}`),this.#t.raiseException({targetWin:e,targetOrigin:t,requestId:i,ex:`The requested object (${o}) is not available`}),!1;const a=r.getInfo();return this.#c(`ScriptingObject.API.${o}.${s.functionName}`,{appId:a.guestId,appUrl:a.guestUrl}),this.#E({guest:r,obj:c,functionName:s.functionName,functionParams:s.functionParams}).then(d=>{this.#t.respond({targetWin:e,targetOrigin:t,requestId:i,response:this.#p(d)}),this.#i.audit({message:"Value returned for Scripting Object method call",requestId:i,scriptingObject:o,scriptingMethod:s.functionName,...a})}).catch(d=>{this.#t.raiseException({targetWin:e,targetOrigin:r.origin,requestId:i,ex:this.#y(d)}),this.#i.audit({message:"Exception thrown for Scripting Object method call",requestId:i,scriptingObject:o,scriptingMethod:s.functionName,...a})}).finally(()=>{this.#d(`ScriptingObject.API.${o}.${s.functionName}`,{appId:a.guestId,appUrl:a.guestUrl})}),!0};#k=()=>{this.#t.listen({messageType:p.GuestResize,callback:this.#I})};#P=()=>{this.#t.listen({messageType:p.GuestReady,callback:this.#j}),this.#t.listen({messageType:p.GuestReadyComplete,callback:this.#w}),this.#t.listen({messageType:p.GuestClose,callback:this.#O}),this.#t.listen({messageType:p.ObjectGet,callback:this.#S}),this.#t.listen({messageType:p.ObjectInvoke,callback:this.#$}),window.addEventListener("visibilitychange",this.#h)};#G=e=>e instanceof C||typeof e?.subscribe=="function";#b=e=>{const t=new P({...e,remoting:this.#t,analyticsObj:this.#n});return t.init(),this.#s.set(e.guestId,t),t};#m=e=>{let t=typeof e=="string"?this.#s.get(e):null;return t||(t=Array.from(this.#s.values()).find(i=>i.window===e||i.domElement===e)),t};#A=()=>{this.#u=setInterval(()=>{const e=[];this.#s.forEach(t=>{t.openMode===f.Popup&&t.window.closed&&e.push(t)}),e.forEach(t=>{this.unloadGuest(t.id)})},1e3)};#T=e=>{const{url:t,title:i,popupWindowFeatures:s={},searchParams:o,guestId:r}=e,{width:c=800,height:a=600,top:d=100,left:l=100}=s;let u=this.#l(t);if(u)u.window.closed||u.send({messageType:p.GuestFocus,messageBody:{}});else{const E=[{key:"width",value:c},{key:"height",value:a},{key:"top",value:d},{key:"left",value:l}].reduce((g,j,K)=>(K>0&&j.value&&(g+=","),j.value?`${g}${j.key}=${j.value}`:g),""),w=window.open(t,i,`popup, ${E}`);if(!w)throw new Error("Failed to open guest application in popup window");w.opener=null,u=this.#b({guestId:r,window:w,title:i,url:t,searchParams:o,openMode:f.Popup})}return u};#R=e=>{const{url:t,title:i,targetElement:s,searchParams:o,guestId:r,options:c={}}=e,a=s.ownerDocument??document,{fitToContent:d=!1,disableSandbox:l=!1,sandboxValues:u=[],style:E=""}=c;if(!i)throw new Error("title is required");d&&this.#k();const w=a.createElement("iframe");w.setAttribute("id",r),w.addEventListener("load",()=>{this.#i.debug(`frame loaded for guest with id '${r}'`)}),w.setAttribute("style",`min-width: 100%; height: 100%; border: 0px; ${E}`),l||w.setAttribute("sandbox",`${X} ${u.join(" ")}`),w.setAttribute("title",i),w.setAttribute("src",t),s.appendChild(w);const g=a.getElementById(r);return this.#b({guestId:r,domElement:g,window:g.contentWindow,title:i,url:t,searchParams:o,openMode:f.Embed})};#q=(e,t)=>{let i="";return Object.keys(t).forEach(s=>{i+=`${(i.length?"&":"")+encodeURIComponent(s)}=${encodeURIComponent(t[s])}`}),e+(i?(e.indexOf("?")>=0?"&":"?")+i:"")};addScriptingObject=(e,t)=>{this.#o.addScriptingObject(e,t)};cloneScriptingObject=(e,t)=>{if(!e)throw new Error("proxy is required");if(!t)throw new Error("guest is required");const i=new I(e.id,e.objectType);let s=[];return Object.keys(e).forEach(o=>{const r=e[o];if(this.#G(r)){let c;if(r?.subscribe!=="function"?c=new m({name:r.name||o,requiresFeedback:!1,so:i}):c=new automation.Event,Object.defineProperty(i,o,{value:c,enumerable:!0}),t.subscribe){const a=({eventParams:l,eventOptions:u})=>this.dispatchEvent({event:c,eventParams:l,eventOptions:u}),d=t.subscribe({eventId:r.id,callback:a});s.push(()=>{t.unsubscribe({eventId:r.id,token:d})})}else{const a=r.subscribe?.((d,l,u)=>this.dispatchEvent({event:c,eventParams:l,eventOptions:u}));s.push(()=>{r.unsubscribe?.(a)})}}else if(k(r)&&(Object.defineProperty(i,o,{value:async(...c)=>{const a=await r(...c);return N(a)?this.cloneScriptingObject(a,t):a},enumerable:!0}),o==="dispose")){const c=i.dispose;Object.defineProperty(i,o,{value:()=>(i._dispose(),c.apply(i)),enumerable:!0})}}),i._dispose=()=>{s.forEach(o=>{o?.()}),s=[]},i};close=()=>{clearInterval(this.#u),this.#t.close(),window.removeEventListener("visibilitychange",this.#h),this.#i.debug(`host is closed. hostId: ${this.hostId}, correlationId: ${this.#e}`)};dispatchEvent=async e=>{const{event:{id:t,name:i,scriptingObject:s},eventParams:o,eventOptions:r={}}=e,{eventHandler:c=null,timeout:a=null,window:d=null}=r,l={object:s._toJSON(),eventName:i,eventParams:o,eventHandler:c,eventOptions:{allowsFeedback:!1}};a&&!Number.isNaN(a)&&(l.eventOptions={allowsFeedback:!0,timeout:Number(a)});const u=[];let E=!1;return this.#s.forEach(g=>{const j=g.getInfo();(!d||d===g.window)&&(a&&g?.capabilities?.eventFeedback?(u.push(g.dispatchEvent(l,a)),E||(this.#c(`ScriptingObject.Event.${s.id}.${i}`,{appId:this.hostId,appUrl:window.location.href}),E=!0),this.#i.audit({message:"Event dispatched and awaiting feedback",scriptingEventId:t,...j})):(g.send({messageType:p.ObjectEvent,messageBody:l}),this.#i.audit({message:"Event dispatched",scriptingEventId:t,...j})))}),await Promise.all(u).then(g=>(this.#i.audit({message:"Event feedback received",scriptingEventId:t}),$(g))).catch(g=>{throw this.#i.error({message:"Error processing event",eventId:t,exception:g}),g}).finally(()=>{E&&this.#d(`ScriptingObject.Event.${s.id}.${i}`,{appId:this.hostId,appUrl:window.location.href})})};getGuests=()=>{const e=[];return this.#s.forEach(t=>{e.push(t)}),e};getScriptingObject=(e,t)=>this.#o.getObject(e,t?.guest);loadGuest=e=>{const{id:t,url:i,targetElement:s,title:o,searchParams:r={},options:c={}}=e;if(!t)throw new Error("id for guest application is required");const{openMode:a=f.Embed,popupWindowFeatures:d={}}=c,l=this.#q(i,r);let u=null;if(this.#c("SSF.Guest.Load",{appId:t,appUrl:l}),a===f.Popup)u=this.#T({guestId:t,url:l,title:o,searchParams:r,popupWindowFeatures:d});else if(a===f.Embed)u=this.#R({guestId:t,url:l,title:o,targetElement:s,searchParams:r,options:c});else throw new Error(`Invalid openMode: ${a}`);return this.#i.audit({message:"Guest loaded",...u.getInfo()}),u};loadGuests=e=>{const{id:t,url:i,targetElement:s,title:o,searchParamsList:r=[],options:c={}}=e;r.forEach((a,d)=>{this.loadGuest({id:`${t}-${d}`,url:i,title:o,targetElement:s,searchParams:a,options:c})},this)};removeAllScriptingObjects=e=>{this.#o.removeAllScriptingObjects(e)};removeScriptingObject=(e,t)=>{this.#o.removeScriptingObject(e,t)};setLogLevel=e=>{this.#i.setLogLevel(e),this.#s.forEach(this.#f),this.#i.debug("Dispatched config events to all guests")};unloadGuest=e=>{const t=this.#m(e);t&&(t.dispose(),this.#s.delete(t.id),this.#i.audit({message:"Guest is removed from host",...t.getInfo()}))}}return y})());
2
+
3
+ //# sourceMappingURL=emuiSsfHost.7cccf3d0afe21a4dcebe.js.map