apexsankey 1.2.4 → 1.2.5

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.
@@ -425,6 +425,131 @@ class Export {
425
425
  this.triggerDownload(this.svgUrl(), `${this.prefix}-${(/* @__PURE__ */ new Date()).getTime()}.svg`);
426
426
  }
427
427
  }
428
+ const _LicenseManager = class _LicenseManager {
429
+ /**
430
+ * Decode license data from encoded string
431
+ * This is a simple base64 + JSON approach - you can make it more sophisticated
432
+ */
433
+ static decodeLicenseData(encodedData) {
434
+ try {
435
+ const decodedString = window.atob(encodedData);
436
+ const data = JSON.parse(decodedString);
437
+ if (!data.issueDate || !data.expiryDate || !data.plan) {
438
+ return null;
439
+ }
440
+ return {
441
+ expiryDate: data.expiryDate,
442
+ issueDate: data.issueDate,
443
+ plan: data.plan,
444
+ valid: true
445
+ };
446
+ } catch {
447
+ return null;
448
+ }
449
+ }
450
+ /**
451
+ * Generate a license key (for your internal use)
452
+ * You would use this on your server/admin panel to generate keys for customers
453
+ */
454
+ static generateLicenseKey(issueDate, expiryDate, plan = "standard") {
455
+ const licenseData = {
456
+ expiryDate,
457
+ issueDate,
458
+ plan
459
+ };
460
+ const encodedData = window.btoa(JSON.stringify(licenseData));
461
+ return `APEX-${encodedData}`;
462
+ }
463
+ /**
464
+ * Get current license validation result
465
+ */
466
+ static getLicenseStatus() {
467
+ if (!this.licenseKey) {
468
+ return { expired: false, valid: false };
469
+ }
470
+ if (!this.validationResult) {
471
+ this.validationResult = this.validateLicense(this.licenseKey);
472
+ }
473
+ return this.validationResult;
474
+ }
475
+ /**
476
+ * Check if current license is valid
477
+ */
478
+ static isLicenseValid() {
479
+ if (!this.licenseKey) {
480
+ return false;
481
+ }
482
+ if (!this.validationResult) {
483
+ this.validationResult = this.validateLicense(this.licenseKey);
484
+ }
485
+ return this.validationResult.valid;
486
+ }
487
+ /**
488
+ * Set the global license key
489
+ */
490
+ static setLicense(key) {
491
+ this.licenseKey = key;
492
+ this.validationResult = this.validateLicense(key);
493
+ if (!this.validationResult.valid) {
494
+ console.error(`[Apex] ${this.validationResult.message}`);
495
+ }
496
+ }
497
+ /**
498
+ * Validate license key format and content
499
+ */
500
+ static validateLicense(key) {
501
+ try {
502
+ if (!key.startsWith("APEX-")) {
503
+ return {
504
+ expired: false,
505
+ message: 'Invalid license key format. License key must start with "APEX-".',
506
+ valid: false
507
+ };
508
+ }
509
+ const parts = key.split("-");
510
+ if (parts.length !== 2) {
511
+ return {
512
+ expired: false,
513
+ message: "Invalid license key format. Expected format: APEX-{encoded-data}.",
514
+ valid: false
515
+ };
516
+ }
517
+ const encodedData = parts[1];
518
+ const licenseData = this.decodeLicenseData(encodedData);
519
+ if (!licenseData) {
520
+ return {
521
+ expired: false,
522
+ message: "Invalid license key. Unable to decode license data.",
523
+ valid: false
524
+ };
525
+ }
526
+ const now = /* @__PURE__ */ new Date();
527
+ const expiryDate = new Date(licenseData.expiryDate);
528
+ if (expiryDate < now) {
529
+ return {
530
+ data: licenseData,
531
+ expired: true,
532
+ message: `License expired on ${licenseData.expiryDate}. Please renew your license.`,
533
+ valid: false
534
+ };
535
+ }
536
+ return {
537
+ data: licenseData,
538
+ expired: false,
539
+ valid: true
540
+ };
541
+ } catch {
542
+ return {
543
+ expired: false,
544
+ message: "Invalid license key format or corrupted data.",
545
+ valid: false
546
+ };
547
+ }
548
+ }
549
+ };
550
+ _LicenseManager.licenseKey = null;
551
+ _LicenseManager.validationResult = null;
552
+ let LicenseManager = _LicenseManager;
428
553
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
429
554
  function getDefaultExportFromCjs(x) {
430
555
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -6069,6 +6194,52 @@ class Toolbar {
6069
6194
  (_a = this.element) == null ? void 0 : _a.append(container);
6070
6195
  }
6071
6196
  }
6197
+ const _Watermark = class _Watermark {
6198
+ /**
6199
+ * Add watermark to a container element
6200
+ */
6201
+ static add(container) {
6202
+ this.remove(container);
6203
+ const watermark = document.createElement("div");
6204
+ watermark.className = this.WATERMARK_CLASS;
6205
+ watermark.textContent = this.WATERMARK_TEXT;
6206
+ Object.assign(watermark.style, {
6207
+ bottom: "5px",
6208
+ color: "#666",
6209
+ fontFamily: "Arial, sans-serif",
6210
+ fontSize: "14px",
6211
+ msUserSelect: "none",
6212
+ pointerEvents: "none",
6213
+ position: "absolute",
6214
+ right: "5px",
6215
+ userSelect: "none",
6216
+ webkitUserSelect: "none",
6217
+ zIndex: "1000"
6218
+ });
6219
+ if (getComputedStyle(container).position === "static") {
6220
+ container.style.position = "relative";
6221
+ }
6222
+ container.appendChild(watermark);
6223
+ }
6224
+ /**
6225
+ * Check if watermark exists in container
6226
+ */
6227
+ static exists(container) {
6228
+ return !!container.querySelector(`.${this.WATERMARK_CLASS}`);
6229
+ }
6230
+ /**
6231
+ * Remove watermark from a container element
6232
+ */
6233
+ static remove(container) {
6234
+ const existingWatermark = container.querySelector(`.${this.WATERMARK_CLASS}`);
6235
+ if (existingWatermark) {
6236
+ existingWatermark.remove();
6237
+ }
6238
+ }
6239
+ };
6240
+ _Watermark.WATERMARK_CLASS = "apexgantt-watermark";
6241
+ _Watermark.WATERMARK_TEXT = "Powered by apexcharts.com";
6242
+ let Watermark = _Watermark;
6072
6243
  function linkDirection(G2, link) {
6073
6244
  if (link.w === null)
6074
6245
  return 0;
@@ -12752,6 +12923,25 @@ class ApexSankey {
12752
12923
  this.element.style.width = `${calculatedWidth}${isPercentValues ? "%" : "px"}`;
12753
12924
  this.element.style.height = `${calculatedHeight}${isPercentValues ? "%" : "px"}`;
12754
12925
  this.element.style.position = "relative";
12926
+ this.handleWatermark();
12927
+ }
12928
+ // Static method to set global license
12929
+ static setLicense(key) {
12930
+ LicenseManager.setLicense(key);
12931
+ }
12932
+ /**
12933
+ * Handle watermark display based on license validation
12934
+ */
12935
+ handleWatermark() {
12936
+ const container = this.element;
12937
+ if (!container) {
12938
+ return;
12939
+ }
12940
+ if (LicenseManager.isLicenseValid()) {
12941
+ Watermark.remove(container);
12942
+ } else {
12943
+ Watermark.add(container);
12944
+ }
12755
12945
  }
12756
12946
  render(data) {
12757
12947
  if (!this.element) {
@@ -12769,6 +12959,10 @@ class ApexSankey {
12769
12959
  return this.graph;
12770
12960
  }
12771
12961
  }
12962
+ if (typeof window !== "undefined") {
12963
+ window.ApexSankey = ApexSankey;
12964
+ }
12772
12965
  export {
12966
+ ApexSankey,
12773
12967
  ApexSankey as default
12774
12968
  };