@spteck/license-manager-react-components 1.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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/atoms/appGlobalState.d.ts +4 -0
  4. package/dist/components/RenderLabel/RenderLabel.d.ts +8 -0
  5. package/dist/components/RenderLabel/index.d.ts +2 -0
  6. package/dist/components/RenderLabel/useRenderLabelStylesStyles.d.ts +1 -0
  7. package/dist/components/customControlBar/CustomControlBar.d.ts +15 -0
  8. package/dist/components/customControlBar/index.d.ts +1 -0
  9. package/dist/components/dropDownField/DropDownField.d.ts +3 -0
  10. package/dist/components/dropDownField/IDropDownFieldProps.d.ts +15 -0
  11. package/dist/components/dropDownField/IOption.d.ts +8 -0
  12. package/dist/components/dropDownField/index.d.ts +3 -0
  13. package/dist/components/errorSVG/ErrorSVG.d.ts +2 -0
  14. package/dist/components/informationBar/InformationBar.d.ts +6 -0
  15. package/dist/components/licenseControl/LicenseControl.d.ts +10 -0
  16. package/dist/components/licenseControl/useLicenseControlStyles.d.ts +5 -0
  17. package/dist/components/licensePlaceHolder/LicensePlaceHolder.d.ts +8 -0
  18. package/dist/components/licensePlaceHolder/licensePlaceHolderStyles.d.ts +8 -0
  19. package/dist/components/licenseProvider/ILicenseProviderProps.d.ts +17 -0
  20. package/dist/components/licenseProvider/LicenseProvider.d.ts +3 -0
  21. package/dist/components/mailTo/Mailto.d.ts +12 -0
  22. package/dist/components/pricePlan/PricePlan.d.ts +9 -0
  23. package/dist/components/pricePlan/usePricePlansStyles.d.ts +12 -0
  24. package/dist/components/registerDialog/RegisterDialog.d.ts +10 -0
  25. package/dist/components/renderHeader/RenderHeader.d.ts +8 -0
  26. package/dist/components/renderHeader/index.d.ts +2 -0
  27. package/dist/components/renderHeader/useRenderHeaderStyles.d.ts +1 -0
  28. package/dist/components/showError/ShowError.d.ts +6 -0
  29. package/dist/components/trialLicense.ts/TrialLicense.d.ts +6 -0
  30. package/dist/components/trialLicense.ts/useTrialLicenseStyles.d.ts +5 -0
  31. package/dist/constants/constants.d.ts +3 -0
  32. package/dist/hooks/useUtils.d.ts +4 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +8 -0
  35. package/dist/license-manager-react-components.cjs.development.js +1433 -0
  36. package/dist/license-manager-react-components.cjs.development.js.map +1 -0
  37. package/dist/license-manager-react-components.cjs.production.min.js +2 -0
  38. package/dist/license-manager-react-components.cjs.production.min.js.map +1 -0
  39. package/dist/license-manager-react-components.esm.js +1406 -0
  40. package/dist/license-manager-react-components.esm.js.map +1 -0
  41. package/dist/loc/IStrings.d.ts +56 -0
  42. package/dist/loc/en.json +61 -0
  43. package/dist/models/EAppHostName.d.ts +7 -0
  44. package/dist/models/ETabsOptions.d.ts +5 -0
  45. package/dist/models/IGlobalState.d.ts +8 -0
  46. package/dist/zodSchemas/pricePlan.d.ts +47 -0
  47. package/package.json +79 -0
@@ -0,0 +1,1406 @@
1
+ import React__default, { createElement, Fragment, isValidElement, useState, useCallback, useMemo, useEffect } from 'react';
2
+ import { webLightTheme, tokens, Text, CardFooter, Button, makeStyles, shorthands, Subtitle1, Caption1, Body1Strong, Body1, Field, Input, MessageBar, FluentProvider, Dialog, DialogSurface, DialogTitle, TabList, Tab, DialogActions, MessageBarBody, MessageBarTitle, MessageBarActions, IdPrefixProvider, teamsLightTheme } from '@fluentui/react-components';
3
+ import { EStatus, useLicenseManager, useUser } from '@spteck/react-hooks-library';
4
+ import { Dismiss24Regular, Clock20Regular, Key20Regular, Apps20Regular } from '@fluentui/react-icons';
5
+ import { atom, useAtomValue, useAtom } from 'jotai';
6
+ import { css } from '@emotion/css';
7
+ import { SHA256 } from 'crypto-js';
8
+ import { Icon } from '@iconify/react';
9
+ import { z } from 'zod';
10
+ import { ErrorBoundary } from 'react-error-boundary';
11
+ import { differenceInDays } from 'date-fns';
12
+
13
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
14
+ try {
15
+ var i = n[a](c),
16
+ u = i.value;
17
+ } catch (n) {
18
+ return void e(n);
19
+ }
20
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
21
+ }
22
+ function _asyncToGenerator(n) {
23
+ return function () {
24
+ var t = this,
25
+ e = arguments;
26
+ return new Promise(function (r, o) {
27
+ var a = n.apply(t, e);
28
+ function _next(n) {
29
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
30
+ }
31
+ function _throw(n) {
32
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
33
+ }
34
+ _next(void 0);
35
+ });
36
+ };
37
+ }
38
+ function _extends() {
39
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
40
+ for (var e = 1; e < arguments.length; e++) {
41
+ var t = arguments[e];
42
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
43
+ }
44
+ return n;
45
+ }, _extends.apply(null, arguments);
46
+ }
47
+ function _regeneratorRuntime() {
48
+ _regeneratorRuntime = function () {
49
+ return e;
50
+ };
51
+ var t,
52
+ e = {},
53
+ r = Object.prototype,
54
+ n = r.hasOwnProperty,
55
+ o = Object.defineProperty || function (t, e, r) {
56
+ t[e] = r.value;
57
+ },
58
+ i = "function" == typeof Symbol ? Symbol : {},
59
+ a = i.iterator || "@@iterator",
60
+ c = i.asyncIterator || "@@asyncIterator",
61
+ u = i.toStringTag || "@@toStringTag";
62
+ function define(t, e, r) {
63
+ return Object.defineProperty(t, e, {
64
+ value: r,
65
+ enumerable: !0,
66
+ configurable: !0,
67
+ writable: !0
68
+ }), t[e];
69
+ }
70
+ try {
71
+ define({}, "");
72
+ } catch (t) {
73
+ define = function (t, e, r) {
74
+ return t[e] = r;
75
+ };
76
+ }
77
+ function wrap(t, e, r, n) {
78
+ var i = e && e.prototype instanceof Generator ? e : Generator,
79
+ a = Object.create(i.prototype),
80
+ c = new Context(n || []);
81
+ return o(a, "_invoke", {
82
+ value: makeInvokeMethod(t, r, c)
83
+ }), a;
84
+ }
85
+ function tryCatch(t, e, r) {
86
+ try {
87
+ return {
88
+ type: "normal",
89
+ arg: t.call(e, r)
90
+ };
91
+ } catch (t) {
92
+ return {
93
+ type: "throw",
94
+ arg: t
95
+ };
96
+ }
97
+ }
98
+ e.wrap = wrap;
99
+ var h = "suspendedStart",
100
+ l = "suspendedYield",
101
+ f = "executing",
102
+ s = "completed",
103
+ y = {};
104
+ function Generator() {}
105
+ function GeneratorFunction() {}
106
+ function GeneratorFunctionPrototype() {}
107
+ var p = {};
108
+ define(p, a, function () {
109
+ return this;
110
+ });
111
+ var d = Object.getPrototypeOf,
112
+ v = d && d(d(values([])));
113
+ v && v !== r && n.call(v, a) && (p = v);
114
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
115
+ function defineIteratorMethods(t) {
116
+ ["next", "throw", "return"].forEach(function (e) {
117
+ define(t, e, function (t) {
118
+ return this._invoke(e, t);
119
+ });
120
+ });
121
+ }
122
+ function AsyncIterator(t, e) {
123
+ function invoke(r, o, i, a) {
124
+ var c = tryCatch(t[r], t, o);
125
+ if ("throw" !== c.type) {
126
+ var u = c.arg,
127
+ h = u.value;
128
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
129
+ invoke("next", t, i, a);
130
+ }, function (t) {
131
+ invoke("throw", t, i, a);
132
+ }) : e.resolve(h).then(function (t) {
133
+ u.value = t, i(u);
134
+ }, function (t) {
135
+ return invoke("throw", t, i, a);
136
+ });
137
+ }
138
+ a(c.arg);
139
+ }
140
+ var r;
141
+ o(this, "_invoke", {
142
+ value: function (t, n) {
143
+ function callInvokeWithMethodAndArg() {
144
+ return new e(function (e, r) {
145
+ invoke(t, n, e, r);
146
+ });
147
+ }
148
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
149
+ }
150
+ });
151
+ }
152
+ function makeInvokeMethod(e, r, n) {
153
+ var o = h;
154
+ return function (i, a) {
155
+ if (o === f) throw Error("Generator is already running");
156
+ if (o === s) {
157
+ if ("throw" === i) throw a;
158
+ return {
159
+ value: t,
160
+ done: !0
161
+ };
162
+ }
163
+ for (n.method = i, n.arg = a;;) {
164
+ var c = n.delegate;
165
+ if (c) {
166
+ var u = maybeInvokeDelegate(c, n);
167
+ if (u) {
168
+ if (u === y) continue;
169
+ return u;
170
+ }
171
+ }
172
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
173
+ if (o === h) throw o = s, n.arg;
174
+ n.dispatchException(n.arg);
175
+ } else "return" === n.method && n.abrupt("return", n.arg);
176
+ o = f;
177
+ var p = tryCatch(e, r, n);
178
+ if ("normal" === p.type) {
179
+ if (o = n.done ? s : l, p.arg === y) continue;
180
+ return {
181
+ value: p.arg,
182
+ done: n.done
183
+ };
184
+ }
185
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
186
+ }
187
+ };
188
+ }
189
+ function maybeInvokeDelegate(e, r) {
190
+ var n = r.method,
191
+ o = e.iterator[n];
192
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
193
+ var i = tryCatch(o, e.iterator, r.arg);
194
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
195
+ var a = i.arg;
196
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
197
+ }
198
+ function pushTryEntry(t) {
199
+ var e = {
200
+ tryLoc: t[0]
201
+ };
202
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
203
+ }
204
+ function resetTryEntry(t) {
205
+ var e = t.completion || {};
206
+ e.type = "normal", delete e.arg, t.completion = e;
207
+ }
208
+ function Context(t) {
209
+ this.tryEntries = [{
210
+ tryLoc: "root"
211
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
212
+ }
213
+ function values(e) {
214
+ if (e || "" === e) {
215
+ var r = e[a];
216
+ if (r) return r.call(e);
217
+ if ("function" == typeof e.next) return e;
218
+ if (!isNaN(e.length)) {
219
+ var o = -1,
220
+ i = function next() {
221
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
222
+ return next.value = t, next.done = !0, next;
223
+ };
224
+ return i.next = i;
225
+ }
226
+ }
227
+ throw new TypeError(typeof e + " is not iterable");
228
+ }
229
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
230
+ value: GeneratorFunctionPrototype,
231
+ configurable: !0
232
+ }), o(GeneratorFunctionPrototype, "constructor", {
233
+ value: GeneratorFunction,
234
+ configurable: !0
235
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
236
+ var e = "function" == typeof t && t.constructor;
237
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
238
+ }, e.mark = function (t) {
239
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
240
+ }, e.awrap = function (t) {
241
+ return {
242
+ __await: t
243
+ };
244
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
245
+ return this;
246
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
247
+ void 0 === i && (i = Promise);
248
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
249
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
250
+ return t.done ? t.value : a.next();
251
+ });
252
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
253
+ return this;
254
+ }), define(g, "toString", function () {
255
+ return "[object Generator]";
256
+ }), e.keys = function (t) {
257
+ var e = Object(t),
258
+ r = [];
259
+ for (var n in e) r.push(n);
260
+ return r.reverse(), function next() {
261
+ for (; r.length;) {
262
+ var t = r.pop();
263
+ if (t in e) return next.value = t, next.done = !1, next;
264
+ }
265
+ return next.done = !0, next;
266
+ };
267
+ }, e.values = values, Context.prototype = {
268
+ constructor: Context,
269
+ reset: function (e) {
270
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
271
+ },
272
+ stop: function () {
273
+ this.done = !0;
274
+ var t = this.tryEntries[0].completion;
275
+ if ("throw" === t.type) throw t.arg;
276
+ return this.rval;
277
+ },
278
+ dispatchException: function (e) {
279
+ if (this.done) throw e;
280
+ var r = this;
281
+ function handle(n, o) {
282
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
283
+ }
284
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
285
+ var i = this.tryEntries[o],
286
+ a = i.completion;
287
+ if ("root" === i.tryLoc) return handle("end");
288
+ if (i.tryLoc <= this.prev) {
289
+ var c = n.call(i, "catchLoc"),
290
+ u = n.call(i, "finallyLoc");
291
+ if (c && u) {
292
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
293
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
294
+ } else if (c) {
295
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
296
+ } else {
297
+ if (!u) throw Error("try statement without catch or finally");
298
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
299
+ }
300
+ }
301
+ }
302
+ },
303
+ abrupt: function (t, e) {
304
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
305
+ var o = this.tryEntries[r];
306
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
307
+ var i = o;
308
+ break;
309
+ }
310
+ }
311
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
312
+ var a = i ? i.completion : {};
313
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
314
+ },
315
+ complete: function (t, e) {
316
+ if ("throw" === t.type) throw t.arg;
317
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
318
+ },
319
+ finish: function (t) {
320
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
321
+ var r = this.tryEntries[e];
322
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
323
+ }
324
+ },
325
+ catch: function (t) {
326
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
327
+ var r = this.tryEntries[e];
328
+ if (r.tryLoc === t) {
329
+ var n = r.completion;
330
+ if ("throw" === n.type) {
331
+ var o = n.arg;
332
+ resetTryEntry(r);
333
+ }
334
+ return o;
335
+ }
336
+ }
337
+ throw Error("illegal catch attempt");
338
+ },
339
+ delegateYield: function (e, r, n) {
340
+ return this.delegate = {
341
+ iterator: values(e),
342
+ resultName: r,
343
+ nextLoc: n
344
+ }, "next" === this.method && (this.arg = t), y;
345
+ }
346
+ }, e;
347
+ }
348
+ function _taggedTemplateLiteralLoose(e, t) {
349
+ return t || (t = e.slice(0)), e.raw = t, e;
350
+ }
351
+
352
+ var ETabsOptions;
353
+ (function (ETabsOptions) {
354
+ ETabsOptions["Trial"] = "trial";
355
+ ETabsOptions["License"] = "license";
356
+ ETabsOptions["Apps"] = "apps";
357
+ })(ETabsOptions || (ETabsOptions = {}));
358
+
359
+ var SUPPORT_EMAIL = "geral@spteck.com";
360
+ var EMAIL_BODY_TEMPLATE = "Subject: Support Request from {0} {1}\n\nDear Support Team,\n\nI am reaching out to you because I am experiencing issues with my license. Here are my details:\n\n ** Tenant ID **: {2}\n ** Application ID **: {3} - {4}\n ** User First Name **: {5}\n ** User Last Name **: {6}\n ** Email**: {7}\n\n {8}\n\nBest regards,\n{9} {10}";
361
+ var EMAIL_BODY_TEMPLATE_REQUEST_LICENSE = "Subject: Request for New License {0} {1}\n\nDear Support Team,\n\nI am just contacting you to request a license for the following product. Here are my details:\n\n ** Tenant ID **: {2}\n ** Application ID **: {3} - {4}\n ** User First Name **: {5}\n ** User Last Name **: {6}\n ** Email **: {7}\n\nBest regards,\n{8} {9}";
362
+
363
+ var Mailto = function Mailto(props) {
364
+ var to = props.to,
365
+ from = props.from,
366
+ subject = props.subject,
367
+ body = props.body,
368
+ children = props.children,
369
+ Component = props.as,
370
+ _props$componentProps = props.componentProps,
371
+ componentProps = _props$componentProps === void 0 ? {} : _props$componentProps;
372
+ // Construct the mailto link
373
+ var mailtoLink = "mailto:" + to + "?" + (from ? "from=" + encodeURIComponent(from) + "&" : "") + (subject ? "subject=" + encodeURIComponent(subject) + "&" : "") + (body ? "body=" + encodeURIComponent(body) : "");
374
+ // Ensure the correct element type is rendered
375
+ var RenderedComponent = Component || "a";
376
+ // Handle the click event
377
+ var handleClick = function handleClick(e) {
378
+ e.preventDefault();
379
+ window.open(mailtoLink, "_blank");
380
+ };
381
+ return React__default.createElement(RenderedComponent, Object.assign({
382
+ href: mailtoLink,
383
+ "aria-label": "Send an email to " + to,
384
+ onClick: handleClick
385
+ }, componentProps), children);
386
+ };
387
+
388
+ var openDialog = "Open campaign dialog";
389
+ var deleteCampaign = "Delete this campaign?";
390
+ var tenantInformation = "Tenant Information";
391
+ var licensingType = "Licensing Type";
392
+ var startDate = "Start Date";
393
+ var endDate = "End Date";
394
+ var licenseKey = "License Key";
395
+ var generate = "Generate";
396
+ var cancel = "Cancel";
397
+ var tenantId = "Tenant Id";
398
+ var tenantUrl = "Tenant Url";
399
+ var applicationId = "Application Id";
400
+ var dateError = "End date must be after start date.";
401
+ var submit = "Generate";
402
+ var placeHolderTitle = "Try or Buy Application";
403
+ var placeHolderText = "To use this application, you need to buy a license. Please click on the button below to register and buy a license, or get 'Trial' license to try the application for free.";
404
+ var placeHolderTrialButton = "Try";
405
+ var placeHolderBuyButton = "Buy";
406
+ var placeHolderRegistryButton = "Buy";
407
+ var companyName = "Company Name";
408
+ var contactFirstName = "Contact First Name";
409
+ var contactLastName = "Contact Last Name";
410
+ var contactEmail = "Contact Email";
411
+ var register = "Register";
412
+ var messageLicenseWarning = "The License {0} will expire in {1} day(s) (expires on {2});";
413
+ var trial = "Trial";
414
+ var license = "License";
415
+ var apps = "Apps";
416
+ var contactFirstNameError = "First name is required";
417
+ var contactLastNameError = "Last name is required";
418
+ var contactEmailError = "format Email is invalid";
419
+ var companyNameError = "Company name is required";
420
+ var trialLicenseTitle = "Register for a trial license";
421
+ var trialLicenseText = "To use this application, you need to register for a trial license. Please fill in the form below to get a trial license.";
422
+ var firstName = "First Name";
423
+ var firstnamePlaceholder = "Enter your first name";
424
+ var lastName = "Last Name";
425
+ var lastnamePlaceholder = "Enter your last name";
426
+ var email = "Email";
427
+ var emailPlaceholder = "Enter your email";
428
+ var company = "Company";
429
+ var companyPlaceholder = "Enter your company";
430
+ var messageStatusBlocked = "Your {0} license has been blocked. Please contact support for assistance.";
431
+ var messageStatusExpired = "Your {0} license has expired at {1}. Please renew it to continue using the application.";
432
+ var messageStatusInvalid = "Your {0} license is invalid. This could be due to incorrect information or an issue with the license itself. Please contact support to request a new license.";
433
+ var messageStatusNotFound = "No valid license was found. This could be because you haven't yet requested. Please contact our support team to request a license and gain access to all features.";
434
+ var messageStatusGenericError = "An error occurred while validating your {0} license. Please contact support for assistance";
435
+ var messageStatusValid = "Your {0} license is valid until {1}. You have full access to the application.";
436
+ var messageStatusBlockedShort = "Your {0} license has been blocked.";
437
+ var messageStatusExpiredShort = "Your {0} license has expired at {1}";
438
+ var messageStatusInvalidShort = "Your {0} license is invalid.";
439
+ var messageStatusNotFoundShort = "No valid license was found, Start a trial or request a license for full access.";
440
+ var messageStatusGenericErrorShort = "An error occurred while validating your {0} license.";
441
+ var details = "Details";
442
+ var buyLicense = "Buy License";
443
+ var requestLicense = "Request License";
444
+ var stringsLocEn = {
445
+ openDialog: openDialog,
446
+ deleteCampaign: deleteCampaign,
447
+ tenantInformation: tenantInformation,
448
+ licensingType: licensingType,
449
+ startDate: startDate,
450
+ endDate: endDate,
451
+ licenseKey: licenseKey,
452
+ generate: generate,
453
+ cancel: cancel,
454
+ tenantId: tenantId,
455
+ tenantUrl: tenantUrl,
456
+ applicationId: applicationId,
457
+ dateError: dateError,
458
+ submit: submit,
459
+ placeHolderTitle: placeHolderTitle,
460
+ placeHolderText: placeHolderText,
461
+ placeHolderTrialButton: placeHolderTrialButton,
462
+ placeHolderBuyButton: placeHolderBuyButton,
463
+ placeHolderRegistryButton: placeHolderRegistryButton,
464
+ companyName: companyName,
465
+ contactFirstName: contactFirstName,
466
+ contactLastName: contactLastName,
467
+ contactEmail: contactEmail,
468
+ register: register,
469
+ messageLicenseWarning: messageLicenseWarning,
470
+ trial: trial,
471
+ license: license,
472
+ apps: apps,
473
+ contactFirstNameError: contactFirstNameError,
474
+ contactLastNameError: contactLastNameError,
475
+ contactEmailError: contactEmailError,
476
+ companyNameError: companyNameError,
477
+ trialLicenseTitle: trialLicenseTitle,
478
+ trialLicenseText: trialLicenseText,
479
+ firstName: firstName,
480
+ firstnamePlaceholder: firstnamePlaceholder,
481
+ lastName: lastName,
482
+ lastnamePlaceholder: lastnamePlaceholder,
483
+ email: email,
484
+ emailPlaceholder: emailPlaceholder,
485
+ company: company,
486
+ companyPlaceholder: companyPlaceholder,
487
+ messageStatusBlocked: messageStatusBlocked,
488
+ messageStatusExpired: messageStatusExpired,
489
+ messageStatusInvalid: messageStatusInvalid,
490
+ messageStatusNotFound: messageStatusNotFound,
491
+ messageStatusGenericError: messageStatusGenericError,
492
+ messageStatusValid: messageStatusValid,
493
+ messageStatusBlockedShort: messageStatusBlockedShort,
494
+ messageStatusExpiredShort: messageStatusExpiredShort,
495
+ messageStatusInvalidShort: messageStatusInvalidShort,
496
+ messageStatusNotFoundShort: messageStatusNotFoundShort,
497
+ messageStatusGenericErrorShort: messageStatusGenericErrorShort,
498
+ details: details,
499
+ buyLicense: buyLicense,
500
+ requestLicense: requestLicense
501
+ };
502
+
503
+ var appGlobalStateAtom = /*#__PURE__*/atom({
504
+ theme: webLightTheme,
505
+ language: "en",
506
+ strings: stringsLocEn,
507
+ refresh: false
508
+ });
509
+
510
+ var _templateObject, _templateObject2, _templateObject3;
511
+ var useLicenseControlStyles = function useLicenseControlStyles() {
512
+ return {
513
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n row-gap: 10px;\n margin-top: 10px;\n padding: 7px;\n background-color: ", ";\n flex: 1;\n "])), tokens.colorNeutralBackground1),
514
+ title: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 10px;\n align-items: center;\n justify-content: start;\n "]))),
515
+ footer: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n justify-content: end;\n position: absolute;\n bottom: 20px;\n right: 20px;\n "])))
516
+ };
517
+ };
518
+
519
+ var useUtils = function useUtils() {
520
+ var formatString = React__default.useCallback(function (template) {
521
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
522
+ args[_key - 1] = arguments[_key];
523
+ }
524
+ return template.replace(/{(\d+)}/g, function (match, number) {
525
+ return typeof args[number] !== "undefined" ? args[number] : match;
526
+ });
527
+ }, []);
528
+ var generateSalt = React__default.useCallback(function (tenantId, appId) {
529
+ // Concatenate the inputs with a delimiter
530
+ var inputData = tenantId + ":" + appId;
531
+ // Create a SHA-256 hash
532
+ var hash = SHA256(inputData).toString();
533
+ return hash;
534
+ }, []);
535
+ return {
536
+ formatString: formatString,
537
+ generateSalt: generateSalt
538
+ };
539
+ };
540
+
541
+ var LicenseControl = function LicenseControl(_ref) {
542
+ var licenseStatus = _ref.licenseStatus,
543
+ onDismiss = _ref.onDismiss,
544
+ licenseType = _ref.licenseType,
545
+ expiryDate = _ref.expiryDate;
546
+ var styles = useLicenseControlStyles();
547
+ var formatDate = new Date(expiryDate).toLocaleDateString();
548
+ var appglobalState = useAtomValue(appGlobalStateAtom);
549
+ var tenantId = appglobalState.tenantId,
550
+ applicationId = appglobalState.applicationId,
551
+ applicationName = appglobalState.applicationName,
552
+ userInformation = appglobalState.userInformation,
553
+ strings = appglobalState.strings;
554
+ var _useUtils = useUtils(),
555
+ formatString = _useUtils.formatString;
556
+ var getMessageAndAction = React__default.useCallback(function () {
557
+ switch (licenseStatus) {
558
+ case EStatus.blocked:
559
+ return {
560
+ message: formatString(strings.messageStatusBlocked, licenseType),
561
+ actionLabel: "Contact Support"
562
+ };
563
+ case EStatus.expired:
564
+ return {
565
+ message: formatString(strings.messageStatusExpired, licenseType, formatDate),
566
+ actionLabel: "Renew License"
567
+ };
568
+ case EStatus.invalid:
569
+ return {
570
+ message: formatString(strings.messageStatusInvalid, licenseType),
571
+ actionLabel: "Request New License"
572
+ };
573
+ case EStatus.notFound:
574
+ return {
575
+ message: strings.messageStatusNotFound,
576
+ actionLabel: "Request License"
577
+ };
578
+ case EStatus.genericError:
579
+ return {
580
+ message: formatString(strings.messageStatusGenericError, ""),
581
+ actionLabel: "Contact Support"
582
+ };
583
+ case EStatus.valid:
584
+ return {
585
+ message: formatString(strings.messageStatusValid, licenseType, formatDate),
586
+ actionLabel: undefined
587
+ };
588
+ default:
589
+ return undefined;
590
+ }
591
+ }, [licenseStatus]);
592
+ var content = React__default.useMemo(function () {
593
+ return getMessageAndAction();
594
+ }, [getMessageAndAction]);
595
+ // utils.ts
596
+ var generateBodyText = React__default.useCallback(function () {
597
+ var _content;
598
+ var mail = userInformation.mail,
599
+ givenName = userInformation.givenName,
600
+ surname = userInformation.surname;
601
+ var body = EMAIL_BODY_TEMPLATE;
602
+ if (licenseStatus === EStatus.notFound) {
603
+ body = EMAIL_BODY_TEMPLATE_REQUEST_LICENSE;
604
+ content = {
605
+ actionLabel: "Request License",
606
+ message: ""
607
+ };
608
+ }
609
+ var message = formatString(body, givenName, surname, tenantId, applicationId, applicationName, givenName, surname, mail, (_content = content) == null ? void 0 : _content.message, givenName, surname);
610
+ return message;
611
+ }, [tenantId, applicationId, userInformation, content]);
612
+ if (!content) return React__default.createElement(React__default.Fragment, null);
613
+ return React__default.createElement("div", {
614
+ className: styles.container
615
+ }, React__default.createElement(Text, null, content.message), React__default.createElement(CardFooter, {
616
+ className: styles.footer
617
+ }, content.actionLabel && React__default.createElement(Mailto, {
618
+ to: SUPPORT_EMAIL,
619
+ from: userInformation == null ? void 0 : userInformation.mail,
620
+ subject: "Support request - " + applicationName,
621
+ body: generateBodyText(),
622
+ as: Button,
623
+ componentProps: {
624
+ appearance: "primary",
625
+ target: "_blank"
626
+ }
627
+ }, content.actionLabel), React__default.createElement(Button, {
628
+ appearance: "secondary",
629
+ onClick: onDismiss
630
+ }, "Close")));
631
+ };
632
+
633
+ var useRenderHeaderStyles = /*#__PURE__*/makeStyles({
634
+ closeButton: {
635
+ marginLeft: "auto",
636
+ position: "absolute",
637
+ top: "10px",
638
+ right: "10px",
639
+ zIndex: 99999
640
+ },
641
+ divider: {
642
+ width: "100%",
643
+ height: "1px",
644
+ backgroundColor: tokens.colorNeutralStroke1,
645
+ marginTop: "6px"
646
+ },
647
+ renderHeaderContent: {
648
+ display: "flex",
649
+ flexDirection: "column",
650
+ justifyContent: "flex-start",
651
+ alignItems: "stretch",
652
+ width: "100%"
653
+ },
654
+ renderHeaderHeader: /*#__PURE__*/_extends({
655
+ display: "flex",
656
+ flexDirection: "column",
657
+ justifyContent: "flex-start"
658
+ }, /*#__PURE__*/shorthands.padding("10px"), {
659
+ gap: "20px"
660
+ }),
661
+ renderHeaderFooter: /*#__PURE__*/_extends({
662
+ display: "flex",
663
+ flexDirection: "row",
664
+ justifyContent: "flex-start"
665
+ }, /*#__PURE__*/shorthands.padding("20px"), {
666
+ gap: "20px"
667
+ }),
668
+ renderHeaderBody: /*#__PURE__*/_extends({
669
+ display: "flex",
670
+ flexDirection: "column",
671
+ justifyContent: "flex-start"
672
+ }, /*#__PURE__*/shorthands.padding("20px"), {
673
+ gap: "20px"
674
+ }),
675
+ renderHeaderTitleContainer: {
676
+ display: "flex",
677
+ flexDirection: "row",
678
+ justifyContent: "flex-start",
679
+ alignItems: "center"
680
+ },
681
+ renderHeaderTitle: {
682
+ display: "-webkit-box",
683
+ "-webkit-line-clamp": "1",
684
+ "-webkit-box-orient": "vertical",
685
+ textAlign: "start",
686
+ textOverflow: "ellipsis",
687
+ wordBreak: "break-word"
688
+ },
689
+ renderHeaderDescription: {
690
+ display: "-webkit-box",
691
+ "-webkit-line-clamp": "4",
692
+ "-webkit-box-orient": "vertical",
693
+ textAlign: "start",
694
+ textOverflow: "ellipsis",
695
+ wordBreak: "break-word"
696
+ },
697
+ dialogTitleAndDescriptionContainer: {
698
+ display: "flex",
699
+ flexDirection: "column",
700
+ justifyContent: "start",
701
+ alignItems: "start",
702
+ paddingLeft: "10px",
703
+ paddingRight: "20px"
704
+ }
705
+ });
706
+
707
+ var RenderHeader = function RenderHeader(props) {
708
+ var onDismiss = props.onDismiss,
709
+ title = props.title,
710
+ description = props.description,
711
+ icon = props.icon;
712
+ var styles = useRenderHeaderStyles();
713
+ return createElement(Fragment, null, createElement("div", {
714
+ className: styles.renderHeaderContent
715
+ }, createElement("div", {
716
+ className: styles.renderHeaderHeader
717
+ }, createElement(Button, {
718
+ appearance: "subtle",
719
+ className: styles.closeButton,
720
+ onClick: function onClick(ev) {
721
+ ev.stopPropagation();
722
+ ev.preventDefault();
723
+ onDismiss(false);
724
+ },
725
+ icon: createElement(Dismiss24Regular, null)
726
+ }), createElement("div", {
727
+ className: styles.renderHeaderTitleContainer
728
+ }, isValidElement(icon) ? icon : createElement(Icon, {
729
+ icon: icon
730
+ }), createElement("div", {
731
+ className: styles.dialogTitleAndDescriptionContainer
732
+ }, isValidElement(title) ? title : createElement(Subtitle1, {
733
+ className: styles.renderHeaderTitle
734
+ }, title), isValidElement(description) ? description : createElement(Caption1, {
735
+ className: styles.renderHeaderDescription
736
+ }, description)))), createElement("div", {
737
+ className: styles.divider
738
+ })));
739
+ };
740
+
741
+ var useRenderLabelStyles = /*#__PURE__*/makeStyles({
742
+ labelContainer: /*#__PURE__*/_extends({
743
+ display: "flex",
744
+ flexDirection: "row",
745
+ justifyContent: "flex-start",
746
+ alignItems: "center"
747
+ }, /*#__PURE__*/shorthands.gap("6px")),
748
+ iconStyles: {
749
+ width: "26px"
750
+ },
751
+ item: {
752
+ paddingLeft: "15px"
753
+ }
754
+ });
755
+
756
+ var RenderLabel = function RenderLabel(props) {
757
+ var label = props.label,
758
+ icon = props.icon,
759
+ isRequired = props.isRequired;
760
+ var styles = useRenderLabelStyles();
761
+ return createElement(Fragment, null, createElement("div", {
762
+ className: styles.labelContainer
763
+ }, icon && isValidElement(icon) ? icon : createElement(Icon, {
764
+ icon: icon,
765
+ className: styles.iconStyles,
766
+ width: "20px",
767
+ height: "20px",
768
+ color: tokens.colorBrandForeground1
769
+ }), createElement(Caption1, {
770
+ style: {
771
+ color: tokens.colorBrandForeground1
772
+ }
773
+ }, label), createElement(Caption1, {
774
+ style: {
775
+ color: tokens.colorPaletteRedForeground1
776
+ }
777
+ }, isRequired ? " *" : "")));
778
+ };
779
+
780
+ var _templateObject$1, _templateObject2$1, _templateObject3$1;
781
+ var useStyles = function useStyles() {
782
+ return {
783
+ container: css(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n row-gap: 10px;\n margin-top: 10px;\n padding: 7px;\n background-color: ", ";\n "])), tokens.colorNeutralBackground1),
784
+ title: css(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 10px;\n align-items: center;\n justify-content: start;\n "]))),
785
+ cardFooter: css(_templateObject3$1 || (_templateObject3$1 = _taggedTemplateLiteralLoose(["\n align-self: flex-end;\n margin-top: 15px;\n "])))
786
+ };
787
+ };
788
+
789
+ var TrialLicense = function TrialLicense(props) {
790
+ var _React$useState = useState({}),
791
+ errors = _React$useState[0],
792
+ setErrors = _React$useState[1];
793
+ var onTrialLicenseAdded = props.onTrialLicenseAdded,
794
+ onDismiss = props.onDismiss;
795
+ var appGlobalState = useAtomValue(appGlobalStateAtom);
796
+ var userInformation = appGlobalState.userInformation,
797
+ strings = appGlobalState.strings,
798
+ tenantId = appGlobalState.tenantId,
799
+ context = appGlobalState.context;
800
+ var _useUtils = useUtils(),
801
+ generateSalt = _useUtils.generateSalt;
802
+ var _React$useState2 = useState(undefined),
803
+ error = _React$useState2[0],
804
+ setError = _React$useState2[1];
805
+ var _useLicenseManager = useLicenseManager(tenantId, context == null ? void 0 : context.manifest.id, generateSalt(tenantId, context == null ? void 0 : context.manifest.id), context),
806
+ requestTrialLicense = _useLicenseManager.requestTrialLicense;
807
+ // Define Zod schema for validation
808
+ var trialLicenseSchema = z.object({
809
+ contactFirstName: z.string().min(1, strings.contactFirstNameError),
810
+ contactLastName: z.string().min(1, strings.contactLastNameError),
811
+ contactEmail: z.string().email(strings.contactEmailError),
812
+ contactCompany: z.string().min(1, strings.contactCompanyError)
813
+ });
814
+ var _React$useState3 = useState({
815
+ contactFirstName: userInformation == null ? void 0 : userInformation.givenName,
816
+ contactLastName: userInformation == null ? void 0 : userInformation.surname,
817
+ contactEmail: userInformation == null ? void 0 : userInformation.mail,
818
+ contactCompany: ""
819
+ }),
820
+ formData = _React$useState3[0],
821
+ setFormData = _React$useState3[1];
822
+ var handleInputChange = useCallback(function (e) {
823
+ var _e$target = e.target,
824
+ name = _e$target.name,
825
+ value = _e$target.value;
826
+ setFormData(function (prev) {
827
+ var _extends2;
828
+ return _extends({}, prev, (_extends2 = {}, _extends2[name] = value, _extends2));
829
+ });
830
+ }, []);
831
+ var styles = useStyles();
832
+ var handleSubmit = useCallback(/*#__PURE__*/function () {
833
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
834
+ var validation, fieldErrors;
835
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
836
+ while (1) switch (_context.prev = _context.next) {
837
+ case 0:
838
+ e.preventDefault();
839
+ // Validate form data using Zod schema
840
+ validation = trialLicenseSchema.safeParse(formData);
841
+ if (validation.success) {
842
+ _context.next = 8;
843
+ break;
844
+ }
845
+ // Map errors for display
846
+ fieldErrors = {};
847
+ validation.error.errors.forEach(function (error) {
848
+ var fieldName = error.path[0];
849
+ fieldErrors[fieldName] = error.message;
850
+ });
851
+ setErrors(fieldErrors);
852
+ _context.next = 19;
853
+ break;
854
+ case 8:
855
+ // Clear errors and call the parent function
856
+ setErrors({});
857
+ _context.prev = 9;
858
+ _context.next = 12;
859
+ return requestTrialLicense(tenantId, context.manifest.id, formData.contactFirstName, formData.contactLastName, formData.contactEmail, formData.contactCompany);
860
+ case 12:
861
+ onTrialLicenseAdded();
862
+ _context.next = 19;
863
+ break;
864
+ case 15:
865
+ _context.prev = 15;
866
+ _context.t0 = _context["catch"](9);
867
+ console.error(_context.t0);
868
+ setError(_context.t0);
869
+ case 19:
870
+ case "end":
871
+ return _context.stop();
872
+ }
873
+ }, _callee, null, [[9, 15]]);
874
+ }));
875
+ return function (_x) {
876
+ return _ref.apply(this, arguments);
877
+ };
878
+ }(), [formData, onTrialLicenseAdded]);
879
+ return createElement("div", {
880
+ className: styles.container
881
+ }, createElement("div", null, createElement(Body1Strong, {
882
+ className: styles.title
883
+ }, strings.trialLicenseTitle), createElement(Body1, null, strings.trialLicenseText)), createElement(Fragment, null, createElement(Field, {
884
+ label: createElement(RenderLabel, {
885
+ label: strings.firstName,
886
+ isRequired: true
887
+ }),
888
+ validationState: errors.contactFirstName ? "error" : "none",
889
+ validationMessage: errors.contactFirstName || undefined
890
+ }, createElement(Input, {
891
+ name: "contactFirstName",
892
+ value: formData.contactFirstName,
893
+ onChange: handleInputChange,
894
+ placeholder: strings.firstNamePlaceholder
895
+ })), createElement(Field, {
896
+ label: createElement(RenderLabel, {
897
+ label: strings.lastName,
898
+ isRequired: true
899
+ }),
900
+ validationState: errors.contactLastName ? "error" : "none",
901
+ validationMessage: errors.contactLastName || undefined
902
+ }, createElement(Input, {
903
+ name: "contactLastName",
904
+ value: formData.contactLastName,
905
+ onChange: handleInputChange,
906
+ placeholder: strings.lastNamePlaceholder
907
+ })), createElement(Field, {
908
+ label: createElement(RenderLabel, {
909
+ label: strings.email,
910
+ isRequired: true
911
+ }),
912
+ validationState: errors.contactEmail ? "error" : "none",
913
+ validationMessage: errors.contactEmail || undefined
914
+ }, createElement(Input, {
915
+ name: "contactEmail",
916
+ value: formData.contactEmail,
917
+ onChange: handleInputChange,
918
+ placeholder: strings.emailPlaceholder
919
+ })), createElement(Field, {
920
+ label: createElement(RenderLabel, {
921
+ label: strings.company,
922
+ isRequired: true
923
+ }),
924
+ validationState: errors.contactCompany ? "error" : "none",
925
+ validationMessage: errors.contactCompany || undefined
926
+ }, createElement(Input, {
927
+ name: "contactCompany",
928
+ value: formData.contactCompany,
929
+ onChange: handleInputChange,
930
+ placeholder: strings.companyPlaceholder
931
+ })), error && createElement(MessageBar, {
932
+ style: {
933
+ marginTop: 10,
934
+ marginBottom: 10
935
+ },
936
+ intent: "error"
937
+ }, " ", error.message), createElement(CardFooter, {
938
+ className: styles.cardFooter
939
+ }, createElement(Button, {
940
+ appearance: "primary",
941
+ onClick: handleSubmit
942
+ }, strings.register), createElement(Button, {
943
+ appearance: "secondary",
944
+ onClick: onDismiss
945
+ }, strings.cancel))));
946
+ };
947
+
948
+ var RegisterDialog = function RegisterDialog(props) {
949
+ var licenseStatus = props.licenseStatus,
950
+ open = props.open,
951
+ onDismiss = props.onDismiss,
952
+ licenseType = props.licenseType,
953
+ expiryDate = props.expiryDate;
954
+ var _useAtom = useAtom(appGlobalStateAtom),
955
+ appGlobalState = _useAtom[0],
956
+ setAppGlobalState = _useAtom[1];
957
+ var theme = appGlobalState.theme,
958
+ applicationName = appGlobalState.applicationName,
959
+ applicationIcon = appGlobalState.applicationIcon,
960
+ strings = appGlobalState.strings,
961
+ _appGlobalState$showA = appGlobalState.showApps,
962
+ showApps = _appGlobalState$showA === void 0 ? false : _appGlobalState$showA;
963
+ var _React$useState = React__default.useState("trial"),
964
+ selectedValue = _React$useState[0],
965
+ setSelectedValue = _React$useState[1];
966
+ var tabs = React__default.useMemo(function () {
967
+ var defaultTabs = [{
968
+ id: "trial",
969
+ value: "trial",
970
+ label: strings.trial,
971
+ icon: React__default.createElement(Clock20Regular, null)
972
+ }, {
973
+ id: "license",
974
+ value: "license",
975
+ label: strings.license,
976
+ icon: React__default.createElement(Key20Regular, null)
977
+ }];
978
+ if (showApps) {
979
+ tabs.push({
980
+ id: "apps",
981
+ value: "apps",
982
+ label: strings.apps,
983
+ icon: React__default.createElement(Apps20Regular, null)
984
+ });
985
+ }
986
+ return defaultTabs;
987
+ }, [strings]);
988
+ var onTabSelect = React__default.useCallback(function (_event, data) {
989
+ setSelectedValue(data.value);
990
+ }, []);
991
+ React__default.useEffect(function () {
992
+ var _statusToTab;
993
+ var statusToTab = (_statusToTab = {}, _statusToTab[EStatus.notFound] = ETabsOptions.Trial, _statusToTab[EStatus.expired] = ETabsOptions.License, _statusToTab[EStatus.invalid] = ETabsOptions.License, _statusToTab[EStatus.blocked] = ETabsOptions.License, _statusToTab[EStatus.genericError] = ETabsOptions.License, _statusToTab[EStatus.valid] = ETabsOptions.License, _statusToTab);
994
+ setSelectedValue(statusToTab[licenseStatus] || ETabsOptions.Trial);
995
+ }, [licenseStatus]);
996
+ var renderPanel = React__default.useMemo(function () {
997
+ switch (selectedValue) {
998
+ case "trial":
999
+ return React__default.createElement(TrialLicense, {
1000
+ onTrialLicenseAdded: function onTrialLicenseAdded() {
1001
+ setAppGlobalState(_extends({}, appGlobalState, {
1002
+ refresh: true
1003
+ }));
1004
+ onDismiss();
1005
+ },
1006
+ onDismiss: onDismiss
1007
+ });
1008
+ case "license":
1009
+ return React__default.createElement(LicenseControl, {
1010
+ licenseStatus: licenseStatus,
1011
+ onDismiss: onDismiss,
1012
+ licenseType: licenseType,
1013
+ expiryDate: expiryDate
1014
+ });
1015
+ case "apps":
1016
+ return React__default.createElement("div", null, "Apps");
1017
+ default:
1018
+ return React__default.createElement(React__default.Fragment, null);
1019
+ }
1020
+ }, [selectedValue, licenseStatus, licenseType, expiryDate]);
1021
+ var filterTabs = React__default.useCallback(function (tab) {
1022
+ if ((licenseType == null ? void 0 : licenseType.toLocaleLowerCase()) === ETabsOptions.Trial.toLocaleLowerCase() || licenseStatus.toLocaleLowerCase() === EStatus.genericError.toLocaleLowerCase()) {
1023
+ return tab.id.toLocaleLowerCase() !== ETabsOptions.Trial.toLocaleLowerCase();
1024
+ }
1025
+ return true;
1026
+ }, [licenseType, licenseStatus]);
1027
+ return React__default.createElement(FluentProvider, {
1028
+ theme: theme
1029
+ }, React__default.createElement(Dialog, {
1030
+ open: open,
1031
+ modalType: "modal"
1032
+ }, React__default.createElement(DialogSurface, {
1033
+ style: {
1034
+ minHeight: 300
1035
+ }
1036
+ }, React__default.createElement(DialogTitle, null, React__default.createElement(RenderHeader, {
1037
+ icon: applicationIcon,
1038
+ title: applicationName,
1039
+ onDismiss: onDismiss
1040
+ })), React__default.createElement(TabList, {
1041
+ selectedValue: selectedValue,
1042
+ onTabSelect: onTabSelect,
1043
+ selectTabOnFocus: true,
1044
+ size: "medium"
1045
+ }, tabs.filter(filterTabs).map(function (tab) {
1046
+ return React__default.createElement(Tab, {
1047
+ key: tab.id,
1048
+ value: tab.value,
1049
+ icon: tab.icon
1050
+ }, tab.label);
1051
+ })), renderPanel, React__default.createElement(DialogActions, null))));
1052
+ };
1053
+
1054
+ var _templateObject$2, _templateObject2$2, _templateObject3$2, _templateObject4, _templateObject5, _templateObject6;
1055
+ var useStyles$1 = function useStyles() {
1056
+ return {
1057
+ container: css(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n row-gap: 10px;\n margin-top: 10px;\n margin-bottom: 30px;\n "]))),
1058
+ titleContainer: css(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n width: 100%;\n justify-content: center;\n align-items: center;\n gap: 10px;\n "]))),
1059
+ titleAndIcon: css(_templateObject3$2 || (_templateObject3$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 10px;\n align-items: center;\n "]))),
1060
+ informationPanel: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n padding: 20px;\n display: flex;\n flex-direction: column;\n gap: 10px;\n background-color: ", ";\n "])), tokens.colorNeutralBackground3),
1061
+ infoRow: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n display: flex;\n gap: 10px;\n justify-content: center;\n align-items: center;\n width: 100%;\n "]))),
1062
+ title: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 10px;\n align-items: center;\n "])))
1063
+ };
1064
+ };
1065
+
1066
+ var LicensePlaceHolder = function LicensePlaceHolder(props) {
1067
+ var appglobalState = useAtomValue(appGlobalStateAtom);
1068
+ var theme = appglobalState.theme,
1069
+ applicationName = appglobalState.applicationName,
1070
+ applicationIcon = appglobalState.applicationIcon,
1071
+ placeHolderText = appglobalState.placeHolderText,
1072
+ strings = appglobalState.strings;
1073
+ var styles = useStyles$1();
1074
+ var _React$useState = useState(false),
1075
+ isOpenLicenseForm = _React$useState[0],
1076
+ setIsOpenLicenseForm = _React$useState[1];
1077
+ var licenseStatus = props.licenseStatus,
1078
+ licenseType = props.licenseType,
1079
+ expiryDate = props.expiryDate;
1080
+ var _useUtils = useUtils(),
1081
+ formatString = _useUtils.formatString;
1082
+ var onDissmiss = useCallback(function () {
1083
+ setIsOpenLicenseForm(false);
1084
+ }, []);
1085
+ var formatDate = useMemo(function () {
1086
+ return new Date(expiryDate).toLocaleDateString();
1087
+ }, [expiryDate]);
1088
+ var getMessageAndAction = useCallback(function () {
1089
+ switch (licenseStatus) {
1090
+ case EStatus.blocked:
1091
+ return {
1092
+ message: formatString(strings.messageStatusBlockedShort, licenseType),
1093
+ actionLabel: strings.details
1094
+ };
1095
+ case EStatus.expired:
1096
+ return {
1097
+ message: formatString(strings.messageStatusExpiredShort, licenseType, formatDate),
1098
+ actionLabel: strings.buyLicense
1099
+ };
1100
+ case EStatus.invalid:
1101
+ return {
1102
+ message: formatString(strings.messageStatusInvalidShort, licenseType != null ? licenseType : ""),
1103
+ actionLabel: strings.details
1104
+ };
1105
+ case EStatus.notFound:
1106
+ return {
1107
+ message: formatString(strings.messageStatusNotFoundShort),
1108
+ actionLabel: strings.requestLicense
1109
+ };
1110
+ case EStatus.genericError:
1111
+ return {
1112
+ message: formatString(strings.messageStatusGenericErrorShort, licenseType != null ? licenseType : ""),
1113
+ actionLabel: strings.details
1114
+ };
1115
+ default:
1116
+ return undefined;
1117
+ }
1118
+ }, [licenseStatus]);
1119
+ var content = useMemo(function () {
1120
+ return getMessageAndAction();
1121
+ }, [getMessageAndAction]);
1122
+ return createElement(Fragment, null, createElement(FluentProvider, {
1123
+ theme: theme
1124
+ }, createElement("div", {
1125
+ className: styles.informationPanel
1126
+ }, createElement("div", {
1127
+ className: styles.infoRow
1128
+ }, createElement("div", {
1129
+ className: styles.title
1130
+ }, createElement("div", {
1131
+ className: styles.titleContainer
1132
+ }, createElement("div", {
1133
+ className: styles.titleAndIcon
1134
+ }, applicationIcon, " ", createElement(Subtitle1, null, " ", applicationName), " "), createElement(Body1, null, placeHolderText)))), createElement("div", {
1135
+ className: styles.infoRow
1136
+ }, createElement(Body1Strong, null, " ", content == null ? void 0 : content.message)), createElement("div", {
1137
+ className: styles.infoRow
1138
+ }, createElement(DialogActions, {
1139
+ style: {
1140
+ marginTop: 15
1141
+ }
1142
+ }, createElement(Button, {
1143
+ appearance: "primary",
1144
+ onClick: function onClick() {
1145
+ setIsOpenLicenseForm(true);
1146
+ }
1147
+ }, content == null ? void 0 : content.actionLabel)), isOpenLicenseForm && createElement(RegisterDialog, {
1148
+ licenseStatus: licenseStatus,
1149
+ licenseType: licenseType,
1150
+ expiryDate: expiryDate,
1151
+ open: isOpenLicenseForm,
1152
+ onDismiss: onDissmiss
1153
+ })))));
1154
+ };
1155
+
1156
+ var InformationBar = function InformationBar(props) {
1157
+ var message = props.message,
1158
+ onAction = props.onAction;
1159
+ return createElement(Fragment, null, createElement(MessageBar, {
1160
+ intent: "warning"
1161
+ }, createElement(MessageBarBody, null, createElement(MessageBarTitle, null, "License Manager"), message), createElement(MessageBarActions, null, createElement(Button, {
1162
+ onClick: onAction
1163
+ }, "Details"))));
1164
+ };
1165
+
1166
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1167
+ function ErrorIcon(props) {
1168
+ return React__default.createElement("svg", Object.assign({
1169
+ xmlns: "http://www.w3.org/2000/svg",
1170
+ width: "1em",
1171
+ height: "1em",
1172
+ viewBox: "0 0 24 24"
1173
+ }, props), React__default.createElement("g", {
1174
+ fill: "none",
1175
+ stroke: "currentColor",
1176
+ strokeWidth: 1.5
1177
+ }, React__default.createElement("path", {
1178
+ d: "M2 6.95c0-.883 0-1.324.07-1.692A4 4 0 0 1 5.257 2.07C5.626 2 6.068 2 6.95 2c.386 0 .58 0 .766.017a4 4 0 0 1 2.18.904c.144.119.28.255.554.529L11 4c.816.816 1.224 1.224 1.712 1.495a4 4 0 0 0 .848.352C14.098 6 14.675 6 15.828 6h.374c2.632 0 3.949 0 4.804.77q.119.105.224.224c.77.855.77 2.172.77 4.804V14c0 3.771 0 5.657-1.172 6.828S17.771 22 14 22h-4c-3.771 0-5.657 0-6.828-1.172S2 17.771 2 14z"
1179
+ }), React__default.createElement("path", {
1180
+ strokeLinecap: "round",
1181
+ d: "m10.5 15l3-3m0 3l-3-3"
1182
+ })));
1183
+ }
1184
+
1185
+ var styles = {
1186
+ container: /*#__PURE__*/css(/*#__PURE__*/_extends({
1187
+ display: "flex",
1188
+ flexDirection: "column",
1189
+ alignItems: "center",
1190
+ justifyContent: "center",
1191
+ height: "100%",
1192
+ textAlign: "center",
1193
+ backgroundColor: tokens.colorNeutralBackground2,
1194
+ borderRadius: tokens.borderRadiusMedium
1195
+ }, /*#__PURE__*/shorthands.padding(tokens.spacingVerticalXL, tokens.spacingHorizontalXL), {
1196
+ color: tokens.colorNeutralForeground1
1197
+ })),
1198
+ icon: /*#__PURE__*/css({
1199
+ marginTop: tokens.spacingHorizontalXL,
1200
+ fontSize: "50px",
1201
+ marginBottom: tokens.spacingHorizontalXL,
1202
+ color: tokens.colorBrandBackground
1203
+ }),
1204
+ message: /*#__PURE__*/css({
1205
+ marginBottom: tokens.spacingHorizontalXL
1206
+ })
1207
+ };
1208
+ var ShowError = function ShowError(_ref) {
1209
+ var message = _ref.message;
1210
+ return React__default.createElement("div", {
1211
+ className: styles.container
1212
+ }, React__default.createElement(Subtitle1, null, "News Feed - Application"), React__default.createElement(ErrorIcon, {
1213
+ className: styles.icon
1214
+ }), React__default.createElement(Body1Strong, {
1215
+ className: styles.message
1216
+ }, message));
1217
+ };
1218
+
1219
+ var NUMBER_DAYS_WARNING = 30;
1220
+ var LicenseProvider = function LicenseProvider(props) {
1221
+ var _props$theme = props.theme,
1222
+ theme = _props$theme === void 0 ? teamsLightTheme : _props$theme,
1223
+ context = props.context,
1224
+ children = props.children,
1225
+ tenantId = props.tenantId,
1226
+ _props$language = props.language,
1227
+ language = _props$language === void 0 ? "en" : _props$language,
1228
+ applicationId = props.applicationId;
1229
+ /* const instanceId = context?.instanceId as string;
1230
+ const tenantId = context?.pageContext.legacyPageContext.aadTenantId; */
1231
+ var _React$useState = useState(undefined),
1232
+ error = _React$useState[0],
1233
+ setError = _React$useState[1];
1234
+ var _React$useState2 = useState(true),
1235
+ isLoading = _React$useState2[0],
1236
+ setIsLoading = _React$useState2[1];
1237
+ var _React$useState3 = useState(),
1238
+ licensingResponse = _React$useState3[0],
1239
+ setLicenseResponse = _React$useState3[1];
1240
+ var _useAtom = useAtom(appGlobalStateAtom),
1241
+ appglobalState = _useAtom[0],
1242
+ setAppGlobalState = _useAtom[1];
1243
+ var _useUser = useUser(context),
1244
+ userInformation = _useUser.userInformation;
1245
+ var _React$useState4 = useState(false),
1246
+ isOpenRegisterDialog = _React$useState4[0],
1247
+ setIsOpenRegisterDialog = _React$useState4[1];
1248
+ var _useUtils = useUtils(),
1249
+ formatString = _useUtils.formatString;
1250
+ var strings = appglobalState.strings,
1251
+ refresh = appglobalState.refresh;
1252
+ var _useUtils2 = useUtils(),
1253
+ generateSalt = _useUtils2.generateSalt;
1254
+ var _ref = licensingResponse || {},
1255
+ status = _ref.status,
1256
+ licenseType = _ref.licenseType,
1257
+ expiryDate = _ref.expiryDate;
1258
+ var _useLicenseManager = useLicenseManager(tenantId, applicationId, generateSalt(tenantId, applicationId), context),
1259
+ checkAndUpdateLicensing = _useLicenseManager.checkAndUpdateLicensing;
1260
+ var styles = useMemo(function () {
1261
+ return {
1262
+ root: css({
1263
+ backgroundColor: "transparent",
1264
+ padding: 20
1265
+ })
1266
+ };
1267
+ }, []);
1268
+ useEffect(function () {
1269
+ _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1270
+ var stringsLoc, result;
1271
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1272
+ while (1) switch (_context.prev = _context.next) {
1273
+ case 0:
1274
+ _context.prev = 0;
1275
+ _context.next = 3;
1276
+ return import("./loc/" + language + ".json");
1277
+ case 3:
1278
+ stringsLoc = _context.sent;
1279
+ setAppGlobalState(function (prev) {
1280
+ return _extends({}, prev, props, {
1281
+ strings: stringsLoc,
1282
+ userInformation: userInformation
1283
+ });
1284
+ });
1285
+ _context.next = 7;
1286
+ return checkAndUpdateLicensing();
1287
+ case 7:
1288
+ result = _context.sent;
1289
+ setLicenseResponse(result);
1290
+ setIsLoading(false);
1291
+ _context.next = 16;
1292
+ break;
1293
+ case 12:
1294
+ _context.prev = 12;
1295
+ _context.t0 = _context["catch"](0);
1296
+ if (_context.t0 instanceof Error) setError(_context.t0);
1297
+ setIsLoading(false);
1298
+ case 16:
1299
+ case "end":
1300
+ return _context.stop();
1301
+ }
1302
+ }, _callee, null, [[0, 12]]);
1303
+ }))();
1304
+ }, [userInformation]);
1305
+ var fallbackRender = useCallback(function (_ref3) {
1306
+ var error = _ref3.error;
1307
+ console.error("[LicenseManager:Error: " + error.message);
1308
+ return createElement(ShowError, {
1309
+ message: error.message
1310
+ });
1311
+ }, []);
1312
+ var onMessageBarAction = useCallback(function () {
1313
+ setIsOpenRegisterDialog(true);
1314
+ }, []);
1315
+ // ipdate liecense status on refresh
1316
+ useEffect(function () {
1317
+ _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1318
+ var result;
1319
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1320
+ while (1) switch (_context2.prev = _context2.next) {
1321
+ case 0:
1322
+ _context2.prev = 0;
1323
+ setAppGlobalState(function (prev) {
1324
+ return _extends({}, prev, {
1325
+ refresh: false
1326
+ });
1327
+ });
1328
+ _context2.next = 4;
1329
+ return checkAndUpdateLicensing();
1330
+ case 4:
1331
+ result = _context2.sent;
1332
+ setLicenseResponse(result);
1333
+ setIsLoading(false);
1334
+ _context2.next = 13;
1335
+ break;
1336
+ case 9:
1337
+ _context2.prev = 9;
1338
+ _context2.t0 = _context2["catch"](0);
1339
+ if (_context2.t0 instanceof Error) setError(_context2.t0);
1340
+ setIsLoading(false);
1341
+ case 13:
1342
+ case "end":
1343
+ return _context2.stop();
1344
+ }
1345
+ }, _callee2, null, [[0, 9]]);
1346
+ }))();
1347
+ }, [refresh]);
1348
+ var onDissmiss = useCallback(function () {
1349
+ setIsOpenRegisterDialog(false);
1350
+ }, []);
1351
+ // renderMessagebar if the license is about to expire
1352
+ var renderMessagebar = useCallback(function (licenseType, expiryDate, warningDays) {
1353
+ var expirationDate = new Date(expiryDate);
1354
+ var today = new Date();
1355
+ var formatedExpiredDate = expirationDate.toLocaleDateString();
1356
+ var dayDiff = differenceInDays(expirationDate, today);
1357
+ var message = "";
1358
+ if (dayDiff <= warningDays) {
1359
+ message = formatString(strings.messageLicenseWarning, licenseType, dayDiff, formatedExpiredDate);
1360
+ return createElement(InformationBar, {
1361
+ message: message,
1362
+ onAction: onMessageBarAction
1363
+ });
1364
+ }
1365
+ return createElement(Fragment, null);
1366
+ }, [expiryDate]);
1367
+ // render the control based on the license status
1368
+ var renderContent = useCallback(function () {
1369
+ switch (status) {
1370
+ case EStatus.valid:
1371
+ return createElement(Fragment, null, renderMessagebar(licenseType, expiryDate, NUMBER_DAYS_WARNING), children);
1372
+ case EStatus.genericError:
1373
+ case EStatus.notFound:
1374
+ case EStatus.blocked:
1375
+ case EStatus.expired:
1376
+ case EStatus.invalid:
1377
+ return createElement(LicensePlaceHolder, {
1378
+ licenseStatus: status,
1379
+ licenseType: licenseType,
1380
+ expiryDate: expiryDate
1381
+ });
1382
+ }
1383
+ return createElement(Fragment, null);
1384
+ }, [licensingResponse, refresh]);
1385
+ if (isLoading) return null;
1386
+ if (error) return createElement(ShowError, {
1387
+ message: error.message
1388
+ });
1389
+ return createElement(Fragment, null, createElement(IdPrefixProvider, {
1390
+ value: "news-feed-"
1391
+ }, createElement(FluentProvider, {
1392
+ theme: theme,
1393
+ className: styles.root
1394
+ }, createElement(ErrorBoundary, {
1395
+ fallbackRender: fallbackRender
1396
+ }, renderContent(), isOpenRegisterDialog && createElement(RegisterDialog, {
1397
+ licenseStatus: status,
1398
+ licenseType: licenseType,
1399
+ expiryDate: expiryDate,
1400
+ open: isOpenRegisterDialog,
1401
+ onDismiss: onDissmiss
1402
+ })))));
1403
+ };
1404
+
1405
+ export { LicensePlaceHolder, LicenseProvider };
1406
+ //# sourceMappingURL=license-manager-react-components.esm.js.map