@hellotext/hellotext 2.5.7 → 2.5.8

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 (102) hide show
  1. package/README.md +0 -25
  2. package/dist/hellotext.js +1 -1
  3. package/index.d.ts +0 -6
  4. package/lib/api/acks.cjs +17 -31
  5. package/lib/api/acks.js +17 -42
  6. package/lib/api/businesses.cjs +14 -28
  7. package/lib/api/businesses.js +13 -36
  8. package/lib/api/events.cjs +26 -40
  9. package/lib/api/events.js +28 -52
  10. package/lib/api/forms.cjs +24 -40
  11. package/lib/api/forms.js +24 -57
  12. package/lib/api/identifications.cjs +15 -29
  13. package/lib/api/identifications.js +15 -40
  14. package/lib/api/index.cjs +25 -51
  15. package/lib/api/index.js +27 -54
  16. package/lib/api/push/identities.cjs +30 -46
  17. package/lib/api/push/identities.js +30 -63
  18. package/lib/api/response.cjs +30 -52
  19. package/lib/api/response.js +31 -60
  20. package/lib/api/submissions.cjs +18 -34
  21. package/lib/api/submissions.js +18 -48
  22. package/lib/api/webchat/messages.cjs +44 -64
  23. package/lib/api/webchat/messages.js +44 -80
  24. package/lib/api/webchats.cjs +37 -56
  25. package/lib/api/webchats.js +37 -65
  26. package/lib/api/whatsapp_widgets.cjs +49 -72
  27. package/lib/api/whatsapp_widgets.js +48 -91
  28. package/lib/builders/input_builder.cjs +36 -48
  29. package/lib/builders/input_builder.js +36 -48
  30. package/lib/builders/logo_builder.cjs +10 -29
  31. package/lib/builders/logo_builder.js +20 -28
  32. package/lib/channels/application_channel.cjs +136 -178
  33. package/lib/channels/application_channel.js +137 -180
  34. package/lib/channels/webchat_channel.cjs +125 -170
  35. package/lib/channels/webchat_channel.js +125 -170
  36. package/lib/controllers/form_controller.cjs +82 -121
  37. package/lib/controllers/form_controller.js +82 -130
  38. package/lib/controllers/message_controller.cjs +211 -282
  39. package/lib/controllers/message_controller.js +209 -284
  40. package/lib/controllers/mixins/usePopover.cjs +3 -6
  41. package/lib/controllers/mixins/usePopover.js +17 -22
  42. package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
  43. package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
  44. package/lib/controllers/webchat/useBehaviour.js +5 -5
  45. package/lib/controllers/webchat/useOpeningSequence.js +6 -6
  46. package/lib/controllers/webchat/useTeaser.js +9 -9
  47. package/lib/controllers/webchat_controller.cjs +916 -1088
  48. package/lib/controllers/webchat_controller.js +926 -1152
  49. package/lib/core/configuration/forms.cjs +21 -35
  50. package/lib/core/configuration/forms.js +20 -35
  51. package/lib/core/configuration/locale.cjs +36 -71
  52. package/lib/core/configuration/locale.js +36 -70
  53. package/lib/core/configuration/push.cjs +9 -21
  54. package/lib/core/configuration/push.js +8 -20
  55. package/lib/core/configuration/webchat.cjs +142 -182
  56. package/lib/core/configuration/webchat.js +145 -189
  57. package/lib/core/configuration/whatsapp.cjs +76 -102
  58. package/lib/core/configuration/whatsapp.js +76 -105
  59. package/lib/core/configuration.cjs +60 -78
  60. package/lib/core/configuration.js +59 -78
  61. package/lib/core/event.cjs +36 -59
  62. package/lib/core/event.js +35 -61
  63. package/lib/core/sanitize_html.js +4 -4
  64. package/lib/errors/invalid_event.cjs +5 -26
  65. package/lib/errors/invalid_event.js +5 -26
  66. package/lib/errors/not_initialized_error.cjs +5 -26
  67. package/lib/errors/not_initialized_error.js +5 -26
  68. package/lib/hellotext.cjs +185 -223
  69. package/lib/hellotext.js +188 -247
  70. package/lib/index.js +1 -1
  71. package/lib/models/business.cjs +114 -152
  72. package/lib/models/business.js +117 -162
  73. package/lib/models/cookies.cjs +34 -51
  74. package/lib/models/cookies.js +34 -51
  75. package/lib/models/fingerprint.cjs +8 -23
  76. package/lib/models/fingerprint.js +25 -58
  77. package/lib/models/form.cjs +106 -142
  78. package/lib/models/form.js +105 -153
  79. package/lib/models/form_collection.cjs +63 -101
  80. package/lib/models/form_collection.js +61 -107
  81. package/lib/models/page.cjs +106 -129
  82. package/lib/models/page.js +106 -131
  83. package/lib/models/push.cjs +278 -322
  84. package/lib/models/push.js +284 -357
  85. package/lib/models/query.cjs +21 -41
  86. package/lib/models/query.js +21 -41
  87. package/lib/models/session.cjs +33 -65
  88. package/lib/models/session.js +30 -63
  89. package/lib/models/user.cjs +29 -51
  90. package/lib/models/user.js +29 -51
  91. package/lib/models/utm.cjs +15 -27
  92. package/lib/models/utm.js +17 -32
  93. package/lib/models/webchat.cjs +52 -76
  94. package/lib/models/webchat.js +52 -90
  95. package/lib/models/whatsapp_widget.cjs +41 -59
  96. package/lib/models/whatsapp_widget.js +41 -73
  97. package/lib/vanilla.cjs +4 -7
  98. package/lib/vanilla.js +2 -1
  99. package/package.json +1 -9
  100. package/src/index.bundle.js +0 -1
  101. package/src/vanilla.js +2 -1
  102. package/styles/index.css +0 -30
@@ -5,14 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Page = void 0;
7
7
  var _utm = require("./utm");
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
- let Page = /*#__PURE__*/function () {
14
- function Page(url = null) {
15
- _classCallCheck(this, Page);
8
+ class Page {
9
+ constructor(url = null) {
16
10
  this.utm = new _utm.UTM();
17
11
  this._url = url;
18
12
  }
@@ -21,144 +15,127 @@ let Page = /*#__PURE__*/function () {
21
15
  * Get the current page URL
22
16
  * @returns {string} The page URL
23
17
  */
24
- _createClass(Page, [{
25
- key: "url",
26
- get: function () {
27
- return this._url !== null && this._url !== undefined ? this._url : window.location.href;
28
- }
18
+ get url() {
19
+ return this._url !== null && this._url !== undefined ? this._url : window.location.href;
20
+ }
29
21
 
30
- /**
31
- * Get the current page title
32
- * @returns {string} The page title
33
- */
34
- }, {
35
- key: "title",
36
- get: function () {
37
- return document.title;
38
- }
22
+ /**
23
+ * Get the current page title
24
+ * @returns {string} The page title
25
+ */
26
+ get title() {
27
+ return document.title;
28
+ }
39
29
 
40
- /**
41
- * Get the current page path
42
- * @returns {string} The page path
43
- */
44
- }, {
45
- key: "path",
46
- get: function () {
47
- if (this._url) {
48
- try {
49
- return new URL(this._url).pathname;
50
- } catch (e) {
51
- return '/';
52
- }
30
+ /**
31
+ * Get the current page path
32
+ * @returns {string} The page path
33
+ */
34
+ get path() {
35
+ if (this._url) {
36
+ try {
37
+ return new URL(this._url).pathname;
38
+ } catch (e) {
39
+ return '/';
53
40
  }
54
- return window.location.pathname;
55
41
  }
42
+ return window.location.pathname;
43
+ }
56
44
 
57
- /**
58
- * Get current UTM parameters
59
- * @returns {Object} The UTM parameters
60
- */
61
- }, {
62
- key: "utmParams",
63
- get: function () {
64
- return this.utm.current;
65
- }
45
+ /**
46
+ * Get current UTM parameters
47
+ * @returns {Object} The UTM parameters
48
+ */
49
+ get utmParams() {
50
+ return this.utm.current;
51
+ }
66
52
 
67
- /**
68
- * Get page data for tracking
69
- * @returns {Object} Object containing page object and utm_params
70
- */
71
- }, {
72
- key: "trackingData",
73
- get: function () {
74
- return {
75
- page: {
76
- url: this.url,
77
- title: this.title,
78
- path: this.path
79
- },
80
- utm_params: this.utmParams
81
- };
82
- }
53
+ /**
54
+ * Get page data for tracking
55
+ * @returns {Object} Object containing page object and utm_params
56
+ */
57
+ get trackingData() {
58
+ return {
59
+ page: {
60
+ url: this.url,
61
+ title: this.title,
62
+ path: this.path
63
+ },
64
+ utm_params: this.utmParams
65
+ };
66
+ }
83
67
 
84
- /**
85
- * Get the current page domain (root domain for cookie sharing)
86
- * @returns {string} The root domain with leading dot, or null if no valid URL
87
- */
88
- }, {
89
- key: "domain",
90
- get: function () {
91
- try {
92
- const url = this.url;
93
- if (!url) {
94
- return null;
95
- }
96
- const hostname = new URL(url).hostname;
97
- return Page.getRootDomain(hostname);
98
- } catch (e) {
68
+ /**
69
+ * Get the current page domain (root domain for cookie sharing)
70
+ * @returns {string} The root domain with leading dot, or null if no valid URL
71
+ */
72
+ get domain() {
73
+ try {
74
+ const url = this.url;
75
+ if (!url) {
99
76
  return null;
100
77
  }
78
+ const hostname = new URL(url).hostname;
79
+ return Page.getRootDomain(hostname);
80
+ } catch (e) {
81
+ return null;
101
82
  }
83
+ }
102
84
 
103
- /**
104
- * Get the root domain from a hostname (static method, no instance needed)
105
- * @param {string} hostname - The hostname to parse
106
- * @returns {string} The root domain with leading dot, or null if invalid
107
- */
108
- }], [{
109
- key: "getRootDomain",
110
- value: function getRootDomain(hostname = null) {
111
- try {
112
- if (!hostname) {
113
- var _window$location;
114
- if (typeof window === 'undefined' || !((_window$location = window.location) !== null && _window$location !== void 0 && _window$location.hostname)) {
115
- return null;
116
- }
117
- hostname = window.location.hostname;
118
- }
119
- const parts = hostname.split('.');
120
-
121
- // Handle localhost or single-part domains
122
- if (parts.length <= 1) {
123
- return hostname;
85
+ /**
86
+ * Get the root domain from a hostname (static method, no instance needed)
87
+ * @param {string} hostname - The hostname to parse
88
+ * @returns {string} The root domain with leading dot, or null if invalid
89
+ */
90
+ static getRootDomain(hostname = null) {
91
+ try {
92
+ if (!hostname) {
93
+ if (typeof window === 'undefined' || !window.location?.hostname) {
94
+ return null;
124
95
  }
96
+ hostname = window.location.hostname;
97
+ }
98
+ const parts = hostname.split('.');
125
99
 
126
- // Handle e-commerce platform domains where store identifier must be preserved
127
- // Examples:
128
- // storename.myshopify.com -> .storename.myshopify.com
129
- // storename.vtexcommercestable.com.br -> .storename.vtexcommercestable.com.br
130
- // storename.wixsite.com -> .storename.wixsite.com
131
- const platformSuffixes = ['myshopify.com', 'vtexcommercestable.com.br', 'myvtex.com', 'wixsite.com'];
132
- for (const suffix of platformSuffixes) {
133
- const suffixParts = suffix.split('.');
134
- // Get the last N parts of the hostname (e.g., last 2 parts for 'myshopify.com')
135
- const domainTail = parts.slice(-suffixParts.length).join('.');
100
+ // Handle localhost or single-part domains
101
+ if (parts.length <= 1) {
102
+ return hostname;
103
+ }
136
104
 
137
- // Check if the tail exactly matches the platform suffix
138
- // and there are additional parts for the store identifier
139
- if (domainTail === suffix && parts.length > suffixParts.length) {
140
- // Include store identifier + platform suffix
141
- // e.g., ['secure', 'mystore', 'myshopify', 'com'] -> '.mystore.myshopify.com'
142
- return `.${parts.slice(-(suffixParts.length + 1)).join('.')}`;
143
- }
144
- }
105
+ // Handle e-commerce platform domains where store identifier must be preserved
106
+ // Examples:
107
+ // storename.myshopify.com -> .storename.myshopify.com
108
+ // storename.vtexcommercestable.com.br -> .storename.vtexcommercestable.com.br
109
+ // storename.wixsite.com -> .storename.wixsite.com
110
+ const platformSuffixes = ['myshopify.com', 'vtexcommercestable.com.br', 'myvtex.com', 'wixsite.com'];
111
+ for (const suffix of platformSuffixes) {
112
+ const suffixParts = suffix.split('.');
113
+ // Get the last N parts of the hostname (e.g., last 2 parts for 'myshopify.com')
114
+ const domainTail = parts.slice(-suffixParts.length).join('.');
145
115
 
146
- // Simple heuristic: if TLD is 2 chars and second-level is short (<=3 chars),
147
- // it's likely a multi-part TLD like .com.br, .co.uk
148
- const tld = parts[parts.length - 1];
149
- const secondLevel = parts[parts.length - 2];
150
- if (parts.length > 2 && tld.length === 2 && secondLevel.length <= 3) {
151
- // Multi-part TLD: take last 3 parts (e.g., store.com.br)
152
- return `.${parts.slice(-3).join('.')}`;
116
+ // Check if the tail exactly matches the platform suffix
117
+ // and there are additional parts for the store identifier
118
+ if (domainTail === suffix && parts.length > suffixParts.length) {
119
+ // Include store identifier + platform suffix
120
+ // e.g., ['secure', 'mystore', 'myshopify', 'com'] -> '.mystore.myshopify.com'
121
+ return `.${parts.slice(-(suffixParts.length + 1)).join('.')}`;
153
122
  }
123
+ }
154
124
 
155
- // Regular TLD: take last 2 parts (e.g., example.com)
156
- return `.${parts.slice(-2).join('.')}`;
157
- } catch (e) {
158
- return null;
125
+ // Simple heuristic: if TLD is 2 chars and second-level is short (<=3 chars),
126
+ // it's likely a multi-part TLD like .com.br, .co.uk
127
+ const tld = parts[parts.length - 1];
128
+ const secondLevel = parts[parts.length - 2];
129
+ if (parts.length > 2 && tld.length === 2 && secondLevel.length <= 3) {
130
+ // Multi-part TLD: take last 3 parts (e.g., store.com.br)
131
+ return `.${parts.slice(-3).join('.')}`;
159
132
  }
133
+
134
+ // Regular TLD: take last 2 parts (e.g., example.com)
135
+ return `.${parts.slice(-2).join('.')}`;
136
+ } catch (e) {
137
+ return null;
160
138
  }
161
- }]);
162
- return Page;
163
- }();
139
+ }
140
+ }
164
141
  exports.Page = Page;
@@ -1,13 +1,6 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
1
  import { UTM } from './utm';
7
- var Page = /*#__PURE__*/function () {
8
- function Page() {
9
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
10
- _classCallCheck(this, Page);
2
+ class Page {
3
+ constructor(url = null) {
11
4
  this.utm = new UTM();
12
5
  this._url = url;
13
6
  }
@@ -16,145 +9,127 @@ var Page = /*#__PURE__*/function () {
16
9
  * Get the current page URL
17
10
  * @returns {string} The page URL
18
11
  */
19
- _createClass(Page, [{
20
- key: "url",
21
- get: function get() {
22
- return this._url !== null && this._url !== undefined ? this._url : window.location.href;
23
- }
12
+ get url() {
13
+ return this._url !== null && this._url !== undefined ? this._url : window.location.href;
14
+ }
24
15
 
25
- /**
26
- * Get the current page title
27
- * @returns {string} The page title
28
- */
29
- }, {
30
- key: "title",
31
- get: function get() {
32
- return document.title;
33
- }
16
+ /**
17
+ * Get the current page title
18
+ * @returns {string} The page title
19
+ */
20
+ get title() {
21
+ return document.title;
22
+ }
34
23
 
35
- /**
36
- * Get the current page path
37
- * @returns {string} The page path
38
- */
39
- }, {
40
- key: "path",
41
- get: function get() {
42
- if (this._url) {
43
- try {
44
- return new URL(this._url).pathname;
45
- } catch (e) {
46
- return '/';
47
- }
24
+ /**
25
+ * Get the current page path
26
+ * @returns {string} The page path
27
+ */
28
+ get path() {
29
+ if (this._url) {
30
+ try {
31
+ return new URL(this._url).pathname;
32
+ } catch (e) {
33
+ return '/';
48
34
  }
49
- return window.location.pathname;
50
35
  }
36
+ return window.location.pathname;
37
+ }
51
38
 
52
- /**
53
- * Get current UTM parameters
54
- * @returns {Object} The UTM parameters
55
- */
56
- }, {
57
- key: "utmParams",
58
- get: function get() {
59
- return this.utm.current;
60
- }
39
+ /**
40
+ * Get current UTM parameters
41
+ * @returns {Object} The UTM parameters
42
+ */
43
+ get utmParams() {
44
+ return this.utm.current;
45
+ }
61
46
 
62
- /**
63
- * Get page data for tracking
64
- * @returns {Object} Object containing page object and utm_params
65
- */
66
- }, {
67
- key: "trackingData",
68
- get: function get() {
69
- return {
70
- page: {
71
- url: this.url,
72
- title: this.title,
73
- path: this.path
74
- },
75
- utm_params: this.utmParams
76
- };
77
- }
47
+ /**
48
+ * Get page data for tracking
49
+ * @returns {Object} Object containing page object and utm_params
50
+ */
51
+ get trackingData() {
52
+ return {
53
+ page: {
54
+ url: this.url,
55
+ title: this.title,
56
+ path: this.path
57
+ },
58
+ utm_params: this.utmParams
59
+ };
60
+ }
78
61
 
79
- /**
80
- * Get the current page domain (root domain for cookie sharing)
81
- * @returns {string} The root domain with leading dot, or null if no valid URL
82
- */
83
- }, {
84
- key: "domain",
85
- get: function get() {
86
- try {
87
- var url = this.url;
88
- if (!url) {
89
- return null;
90
- }
91
- var hostname = new URL(url).hostname;
92
- return Page.getRootDomain(hostname);
93
- } catch (e) {
62
+ /**
63
+ * Get the current page domain (root domain for cookie sharing)
64
+ * @returns {string} The root domain with leading dot, or null if no valid URL
65
+ */
66
+ get domain() {
67
+ try {
68
+ const url = this.url;
69
+ if (!url) {
94
70
  return null;
95
71
  }
72
+ const hostname = new URL(url).hostname;
73
+ return Page.getRootDomain(hostname);
74
+ } catch (e) {
75
+ return null;
96
76
  }
77
+ }
97
78
 
98
- /**
99
- * Get the root domain from a hostname (static method, no instance needed)
100
- * @param {string} hostname - The hostname to parse
101
- * @returns {string} The root domain with leading dot, or null if invalid
102
- */
103
- }], [{
104
- key: "getRootDomain",
105
- value: function getRootDomain() {
106
- var hostname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
107
- try {
108
- if (!hostname) {
109
- var _window$location;
110
- if (typeof window === 'undefined' || !((_window$location = window.location) !== null && _window$location !== void 0 && _window$location.hostname)) {
111
- return null;
112
- }
113
- hostname = window.location.hostname;
114
- }
115
- var parts = hostname.split('.');
116
-
117
- // Handle localhost or single-part domains
118
- if (parts.length <= 1) {
119
- return hostname;
79
+ /**
80
+ * Get the root domain from a hostname (static method, no instance needed)
81
+ * @param {string} hostname - The hostname to parse
82
+ * @returns {string} The root domain with leading dot, or null if invalid
83
+ */
84
+ static getRootDomain(hostname = null) {
85
+ try {
86
+ if (!hostname) {
87
+ if (typeof window === 'undefined' || !window.location?.hostname) {
88
+ return null;
120
89
  }
90
+ hostname = window.location.hostname;
91
+ }
92
+ const parts = hostname.split('.');
121
93
 
122
- // Handle e-commerce platform domains where store identifier must be preserved
123
- // Examples:
124
- // storename.myshopify.com -> .storename.myshopify.com
125
- // storename.vtexcommercestable.com.br -> .storename.vtexcommercestable.com.br
126
- // storename.wixsite.com -> .storename.wixsite.com
127
- var platformSuffixes = ['myshopify.com', 'vtexcommercestable.com.br', 'myvtex.com', 'wixsite.com'];
128
- for (var suffix of platformSuffixes) {
129
- var suffixParts = suffix.split('.');
130
- // Get the last N parts of the hostname (e.g., last 2 parts for 'myshopify.com')
131
- var domainTail = parts.slice(-suffixParts.length).join('.');
94
+ // Handle localhost or single-part domains
95
+ if (parts.length <= 1) {
96
+ return hostname;
97
+ }
132
98
 
133
- // Check if the tail exactly matches the platform suffix
134
- // and there are additional parts for the store identifier
135
- if (domainTail === suffix && parts.length > suffixParts.length) {
136
- // Include store identifier + platform suffix
137
- // e.g., ['secure', 'mystore', 'myshopify', 'com'] -> '.mystore.myshopify.com'
138
- return ".".concat(parts.slice(-(suffixParts.length + 1)).join('.'));
139
- }
140
- }
99
+ // Handle e-commerce platform domains where store identifier must be preserved
100
+ // Examples:
101
+ // storename.myshopify.com -> .storename.myshopify.com
102
+ // storename.vtexcommercestable.com.br -> .storename.vtexcommercestable.com.br
103
+ // storename.wixsite.com -> .storename.wixsite.com
104
+ const platformSuffixes = ['myshopify.com', 'vtexcommercestable.com.br', 'myvtex.com', 'wixsite.com'];
105
+ for (const suffix of platformSuffixes) {
106
+ const suffixParts = suffix.split('.');
107
+ // Get the last N parts of the hostname (e.g., last 2 parts for 'myshopify.com')
108
+ const domainTail = parts.slice(-suffixParts.length).join('.');
141
109
 
142
- // Simple heuristic: if TLD is 2 chars and second-level is short (<=3 chars),
143
- // it's likely a multi-part TLD like .com.br, .co.uk
144
- var tld = parts[parts.length - 1];
145
- var secondLevel = parts[parts.length - 2];
146
- if (parts.length > 2 && tld.length === 2 && secondLevel.length <= 3) {
147
- // Multi-part TLD: take last 3 parts (e.g., store.com.br)
148
- return ".".concat(parts.slice(-3).join('.'));
110
+ // Check if the tail exactly matches the platform suffix
111
+ // and there are additional parts for the store identifier
112
+ if (domainTail === suffix && parts.length > suffixParts.length) {
113
+ // Include store identifier + platform suffix
114
+ // e.g., ['secure', 'mystore', 'myshopify', 'com'] -> '.mystore.myshopify.com'
115
+ return `.${parts.slice(-(suffixParts.length + 1)).join('.')}`;
149
116
  }
117
+ }
150
118
 
151
- // Regular TLD: take last 2 parts (e.g., example.com)
152
- return ".".concat(parts.slice(-2).join('.'));
153
- } catch (e) {
154
- return null;
119
+ // Simple heuristic: if TLD is 2 chars and second-level is short (<=3 chars),
120
+ // it's likely a multi-part TLD like .com.br, .co.uk
121
+ const tld = parts[parts.length - 1];
122
+ const secondLevel = parts[parts.length - 2];
123
+ if (parts.length > 2 && tld.length === 2 && secondLevel.length <= 3) {
124
+ // Multi-part TLD: take last 3 parts (e.g., store.com.br)
125
+ return `.${parts.slice(-3).join('.')}`;
155
126
  }
127
+
128
+ // Regular TLD: take last 2 parts (e.g., example.com)
129
+ return `.${parts.slice(-2).join('.')}`;
130
+ } catch (e) {
131
+ return null;
156
132
  }
157
- }]);
158
- return Page;
159
- }();
133
+ }
134
+ }
160
135
  export { Page };