@commversion/libs 0.18.2 → 0.18.4
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/.cspell.json +149 -0
- package/.editorconfig +10 -0
- package/.husky/pre-commit +27 -0
- package/.husky/prepare-commit-msg +13 -0
- package/.markdownlint.json +4 -0
- package/.oxfmtrc.json +6 -0
- package/.oxlintrc.json +34 -0
- package/.release-it.json +9 -3
- package/.vscode/extensions.json +18 -0
- package/.vscode/settings.json +12 -0
- package/README.md +20 -10
- package/dist/lc-attribution.js +1 -0
- package/dist/lc-channel-widgets.js +56 -9
- package/dist/lc-cookie-banner-update-position.js +3 -3
- package/dist/lc-device.js +1 -1
- package/dist/lc-exit-intent-debounced.js +1 -1
- package/dist/lc-exit-intent.js +1 -1
- package/dist/lc-experiment.js +1 -1
- package/dist/lc-form-abandonment.js +1 -1
- package/dist/lc-form-submission.js +1 -1
- package/dist/lc-ga-initialize-event.js +1 -1
- package/dist/lc-ga-tags.js +1 -1
- package/dist/lc-gclid.js +1 -1
- package/dist/lc-geoblocking.js +1 -1
- package/dist/lc-gtm.js +1 -1
- package/dist/lc-input-error.js +1 -1
- package/dist/lc-kill-chat-persist.js +1 -1
- package/dist/lc-kill-chat.js +1 -1
- package/dist/lc-open-on-button-click.js +1 -1
- package/dist/lc-pause-on-url.js +1 -1
- package/dist/lc-powered-by.js +1 -1
- package/dist/lc-show-by-selector.js +1 -1
- package/dist/lc-show-hide.js +1 -1
- package/dist/lc-utm-params.js +1 -1
- package/dist/lc-whatsapp-widget-combo.js +4 -4
- package/dist/lc-whatsapp-widget-only.js +8 -8
- package/dist/schedule-event.js +1 -1
- package/global.d.ts +320 -0
- package/package.json +112 -87
- package/pnpm-workspace.yaml +34 -0
- package/templates/scaffold.ts +86 -0
- package/templates/script/README.md +11 -0
- package/templates/script/package.json +4 -0
- package/templates/script/src/NAME.ts +6 -0
- package/templates/script/src/index.html +57 -0
- package/templates/script/src/main.ts +5 -0
- package/templates/script/tests/NAME.test.ts +9 -0
- package/templates/script/vite.config.ts +19 -0
- package/tsconfig.json +32 -0
- package/vitest.config.ts +18 -0
- package/.prettierignore +0 -4
- package/.prettierrc +0 -3
package/.cspell.json
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2",
|
|
3
|
+
"language": "en-GB",
|
|
4
|
+
"words": [
|
|
5
|
+
"applescript",
|
|
6
|
+
"attrib",
|
|
7
|
+
"bitfield",
|
|
8
|
+
"blazediff",
|
|
9
|
+
"boxen",
|
|
10
|
+
"bufferutil",
|
|
11
|
+
"centered",
|
|
12
|
+
"chardet",
|
|
13
|
+
"chokidar",
|
|
14
|
+
"citty",
|
|
15
|
+
"cliui",
|
|
16
|
+
"color",
|
|
17
|
+
"commversion",
|
|
18
|
+
"confbox",
|
|
19
|
+
"consola",
|
|
20
|
+
"cookieinfo",
|
|
21
|
+
"cutoff",
|
|
22
|
+
"cyclonedx",
|
|
23
|
+
"dclid",
|
|
24
|
+
"defu",
|
|
25
|
+
"degenerator",
|
|
26
|
+
"destr",
|
|
27
|
+
"direnv",
|
|
28
|
+
"domexception",
|
|
29
|
+
"dotenv",
|
|
30
|
+
"eabi",
|
|
31
|
+
"emnapi",
|
|
32
|
+
"emscripten",
|
|
33
|
+
"esbuild",
|
|
34
|
+
"escaperegexp",
|
|
35
|
+
"escodegen",
|
|
36
|
+
"esprima",
|
|
37
|
+
"estraverse",
|
|
38
|
+
"estree",
|
|
39
|
+
"esutils",
|
|
40
|
+
"eventemitter",
|
|
41
|
+
"execa",
|
|
42
|
+
"fdir",
|
|
43
|
+
"formdata",
|
|
44
|
+
"fsevents",
|
|
45
|
+
"fullwidth",
|
|
46
|
+
"gclid",
|
|
47
|
+
"geoblock",
|
|
48
|
+
"geoblocking",
|
|
49
|
+
"giget",
|
|
50
|
+
"gitmoji",
|
|
51
|
+
"gnueabihf",
|
|
52
|
+
"handoff",
|
|
53
|
+
"hashchange",
|
|
54
|
+
"hideable",
|
|
55
|
+
"hotwire",
|
|
56
|
+
"hrefs",
|
|
57
|
+
"hubspot",
|
|
58
|
+
"idempotently",
|
|
59
|
+
"isexe",
|
|
60
|
+
"isplainobject",
|
|
61
|
+
"jiti",
|
|
62
|
+
"jridgewell",
|
|
63
|
+
"jsdom",
|
|
64
|
+
"keepalive",
|
|
65
|
+
"kickoff",
|
|
66
|
+
"libc",
|
|
67
|
+
"lightningcss",
|
|
68
|
+
"listr",
|
|
69
|
+
"livechat",
|
|
70
|
+
"livechatinc",
|
|
71
|
+
"locationchange",
|
|
72
|
+
"magicast",
|
|
73
|
+
"maxage",
|
|
74
|
+
"minimatch",
|
|
75
|
+
"minimist",
|
|
76
|
+
"minipass",
|
|
77
|
+
"mrmime",
|
|
78
|
+
"msvc",
|
|
79
|
+
"musleabihf",
|
|
80
|
+
"muts",
|
|
81
|
+
"nanoid",
|
|
82
|
+
"napi",
|
|
83
|
+
"noopener",
|
|
84
|
+
"noreferrer",
|
|
85
|
+
"npmjs",
|
|
86
|
+
"nypm",
|
|
87
|
+
"obug",
|
|
88
|
+
"ohash",
|
|
89
|
+
"onetime",
|
|
90
|
+
"openharmony",
|
|
91
|
+
"oxfmt",
|
|
92
|
+
"oxlint",
|
|
93
|
+
"phun",
|
|
94
|
+
"picocolors",
|
|
95
|
+
"picomatch",
|
|
96
|
+
"pluginutils",
|
|
97
|
+
"pngjs",
|
|
98
|
+
"popstate",
|
|
99
|
+
"postback",
|
|
100
|
+
"postchat",
|
|
101
|
+
"prechat",
|
|
102
|
+
"prefilledmessage",
|
|
103
|
+
"quickjs",
|
|
104
|
+
"rawlist",
|
|
105
|
+
"readdirp",
|
|
106
|
+
"rfdc",
|
|
107
|
+
"rimraf",
|
|
108
|
+
"riscv",
|
|
109
|
+
"saslprep",
|
|
110
|
+
"sass",
|
|
111
|
+
"Segoe",
|
|
112
|
+
"siginfo",
|
|
113
|
+
"sirv",
|
|
114
|
+
"sitecore",
|
|
115
|
+
"srvc",
|
|
116
|
+
"stackback",
|
|
117
|
+
"sugarss",
|
|
118
|
+
"teardown",
|
|
119
|
+
"timezone",
|
|
120
|
+
"timezones",
|
|
121
|
+
"tinybench",
|
|
122
|
+
"tinyexec",
|
|
123
|
+
"tinyglobby",
|
|
124
|
+
"tinypool",
|
|
125
|
+
"tinyrainbow",
|
|
126
|
+
"tootallnate",
|
|
127
|
+
"totalist",
|
|
128
|
+
"tsgolint",
|
|
129
|
+
"ttclid",
|
|
130
|
+
"turbolinks",
|
|
131
|
+
"tybys",
|
|
132
|
+
"undici",
|
|
133
|
+
"uniqby",
|
|
134
|
+
"unstub",
|
|
135
|
+
"visitorid",
|
|
136
|
+
"vite",
|
|
137
|
+
"vitejs",
|
|
138
|
+
"vitest",
|
|
139
|
+
"wasi",
|
|
140
|
+
"wcwidth",
|
|
141
|
+
"webdriverio",
|
|
142
|
+
"webidl",
|
|
143
|
+
"whatwg",
|
|
144
|
+
"yargs",
|
|
145
|
+
"yoctocolors",
|
|
146
|
+
"yxxx",
|
|
147
|
+
"zstd"
|
|
148
|
+
]
|
|
149
|
+
}
|
package/.editorconfig
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# CV-496 (PR #67 review): local dependency security audit.
|
|
2
|
+
#
|
|
3
|
+
# First line of defence — catches CRITICAL vulnerabilities before code reaches
|
|
4
|
+
# CI. Uses pnpm audit against the npm advisory database.
|
|
5
|
+
#
|
|
6
|
+
# Full pipeline (mirrors gen2-monorepo-base CV2-300):
|
|
7
|
+
# 1. LOCAL: pnpm audit --audit-level=critical (this hook — blocks commit)
|
|
8
|
+
# 2. PR CI: pnpm audit --audit-level=critical (catches critical in CI)
|
|
9
|
+
# 3. PR CI: pnpm sbom generation (compliance artifact)
|
|
10
|
+
# 4. GITHUB: Dependabot (auto-fix PRs for vulnerable deps)
|
|
11
|
+
#
|
|
12
|
+
echo "Running dependency security audit..."
|
|
13
|
+
pnpm audit --audit-level=critical || {
|
|
14
|
+
echo ""
|
|
15
|
+
echo "=============================================="
|
|
16
|
+
echo " Dependency security audit found CRITICAL"
|
|
17
|
+
echo " vulnerabilities."
|
|
18
|
+
echo ""
|
|
19
|
+
echo " Run 'pnpm audit' for details."
|
|
20
|
+
echo " Run 'pnpm audit --fix' to auto-fix."
|
|
21
|
+
echo "=============================================="
|
|
22
|
+
echo ""
|
|
23
|
+
exit 1
|
|
24
|
+
}
|
|
25
|
+
echo "Dependency security audit passed."
|
|
26
|
+
|
|
27
|
+
pnpm exec lint-staged
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
if [ "$2" = "message" ]; then
|
|
4
|
+
exit 0
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //')
|
|
8
|
+
|
|
9
|
+
if echo "$BRANCH_NAME" | grep -q '^(no branch, rebasing .*)$'; then
|
|
10
|
+
exit 0
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
exec < /dev/tty && pnpm exec gitmoji --hook "$1" "$2" || true
|
package/.oxfmtrc.json
ADDED
package/.oxlintrc.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"plugins": ["eslint", "import", "jsdoc", "oxc", "promise", "typescript", "unicorn", "vitest"],
|
|
4
|
+
"categories": {
|
|
5
|
+
"correctness": "error",
|
|
6
|
+
"suspicious": "error",
|
|
7
|
+
"perf": "error"
|
|
8
|
+
},
|
|
9
|
+
"rules": {
|
|
10
|
+
"@typescript-eslint/unbound-method": ["error", { "ignoreStatic": true }],
|
|
11
|
+
"eslint/sort-imports": ["error", { "ignoreDeclarationSort": true }],
|
|
12
|
+
"eslint/no-underscore-dangle": "off",
|
|
13
|
+
"eslint/no-await-in-loop": "off",
|
|
14
|
+
"typescript/no-unsafe-type-assertion": "off",
|
|
15
|
+
"typescript/no-wrapper-object-types": "off",
|
|
16
|
+
"typescript/no-redundant-type-constituents": "off",
|
|
17
|
+
"unicorn/consistent-function-scoping": "off",
|
|
18
|
+
"unicorn/prefer-add-event-listener": "off"
|
|
19
|
+
},
|
|
20
|
+
"env": {
|
|
21
|
+
"builtin": true
|
|
22
|
+
},
|
|
23
|
+
"overrides": [
|
|
24
|
+
{
|
|
25
|
+
"files": ["**/tests/**", "**/*.test.{js,ts}"],
|
|
26
|
+
"rules": {
|
|
27
|
+
"typescript/unbound-method": "off",
|
|
28
|
+
"vitest/require-mock-type-parameters": "off",
|
|
29
|
+
"vitest/no-conditional-expect": "off",
|
|
30
|
+
"vitest/valid-title": "off"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
package/.release-it.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"recommendations": [
|
|
3
|
+
"aaron-bond.better-comments",
|
|
4
|
+
"codeandstuff.package-json-upgrade",
|
|
5
|
+
"davidanson.vscode-markdownlint",
|
|
6
|
+
"editorconfig.editorconfig",
|
|
7
|
+
"github.copilot",
|
|
8
|
+
"jock.svg",
|
|
9
|
+
"oxc.oxc-vscode",
|
|
10
|
+
"ryu1kn.partial-diff",
|
|
11
|
+
"sonarsource.sonarlint-vscode",
|
|
12
|
+
"streetsidesoftware.code-spell-checker",
|
|
13
|
+
"typescriptteam.native-preview",
|
|
14
|
+
"vitest.explorer",
|
|
15
|
+
"vscode-icons-team.vscode-icons",
|
|
16
|
+
"yzhang.markdown-all-in-one"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"oxc.fmt.configPath": ".oxfmtrc.json",
|
|
3
|
+
"oxc.typeAware": true,
|
|
4
|
+
"editor.codeActionsOnSave": {
|
|
5
|
+
"source.fixAll.oxc": "always"
|
|
6
|
+
},
|
|
7
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
8
|
+
"editor.formatOnSaveMode": "file",
|
|
9
|
+
"editor.formatOnSave": true,
|
|
10
|
+
"js/ts.experimental.useTsgo": true,
|
|
11
|
+
"typescript.native-preview.tsdk": "node_modules/@typescript/native-preview"
|
|
12
|
+
}
|
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ Configuration takes place by global `window.commversion` object, make sure to no
|
|
|
18
18
|
|
|
19
19
|
```html
|
|
20
20
|
<script>
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
window.commversion = window.commversion || {};
|
|
22
|
+
window.commversion.someProperty = true;
|
|
23
23
|
</script>
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -28,6 +28,7 @@ Configuration takes place by global `window.commversion` object, make sure to no
|
|
|
28
28
|
All scripts are available under the `scripts/` directory.
|
|
29
29
|
|
|
30
30
|
- schedule-event
|
|
31
|
+
- lc-attribution
|
|
31
32
|
- lc-open-on-button-click
|
|
32
33
|
- lc-cookie-banner-update-position
|
|
33
34
|
- lc-show-by-selector
|
|
@@ -52,6 +53,7 @@ All scripts are available under the `scripts/` directory.
|
|
|
52
53
|
- lc-whatsapp-widget-only
|
|
53
54
|
- lc-whatsapp-widget-combo
|
|
54
55
|
- lc-channel-widgets
|
|
56
|
+
<!-- scaffold:scripts -->
|
|
55
57
|
|
|
56
58
|
## Release new versions
|
|
57
59
|
|
|
@@ -59,14 +61,14 @@ All scripts are available under the `scripts/` directory.
|
|
|
59
61
|
This project uses the npm.js public registry. Before trying to do any release, make sure you are logged with npm as Commversion.
|
|
60
62
|
The quickest way to do that, is to create a `.npmrc` file in the project directly and insert the following:
|
|
61
63
|
|
|
62
|
-
```
|
|
64
|
+
```plaintext
|
|
63
65
|
//registry.npmjs.org/:_authToken=base64_encoded_npm_token
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
You can test if the above works by running:
|
|
67
69
|
|
|
68
|
-
```
|
|
69
|
-
$
|
|
70
|
+
```bash
|
|
71
|
+
$ pnpm whoami
|
|
70
72
|
commversion # this is the authenticated npm user
|
|
71
73
|
```
|
|
72
74
|
|
|
@@ -76,22 +78,30 @@ Patch releases for bug fixes.
|
|
|
76
78
|
Minor releases for new features.
|
|
77
79
|
Major releases for breaking changes.
|
|
78
80
|
|
|
79
|
-
The release is fully automated by executing `
|
|
81
|
+
The release is fully automated by executing `pnpm run release`. No need to run build scripts beforehand, this is done automatically.
|
|
80
82
|
|
|
81
83
|
## Guideline for contributing
|
|
82
84
|
|
|
85
|
+
This project uses **pnpm** via [Corepack](https://nodejs.org/api/corepack.html) — the exact pnpm version is pinned in `packageManager` in `package.json` and Corepack downloads/verifies it on first use. Enable Corepack once with:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
corepack enable
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Node `>=24` is required.
|
|
92
|
+
|
|
83
93
|
To create a new script, run the following command in a shell.
|
|
84
94
|
|
|
85
95
|
```bash
|
|
86
|
-
|
|
96
|
+
pnpm new script-name
|
|
87
97
|
```
|
|
88
98
|
|
|
89
|
-
The command above will create
|
|
99
|
+
The command above will create a new script containing the absolute minimum files. It will also amend root `README.md` and `package.json` to include required entries.
|
|
90
100
|
|
|
91
|
-
Start working on a specific script by running `
|
|
101
|
+
Start working on a specific script by running `pnpm run dev:<script-name>`.
|
|
92
102
|
|
|
93
103
|
Finally, you can run tests by running:
|
|
94
104
|
|
|
95
105
|
```bash
|
|
96
|
-
|
|
106
|
+
pnpm test
|
|
97
107
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var o=class e{constructor(e={}){r(this,`dependencies`,void 0),this.dependencies=e}provide(t){return new e(a(a({},this.dependencies),t(this.dependencies)))}},s=class e{constructor(e,t,n,i,a,o){r(this,`bus`,void 0),r(this,`pageData`,void 0),r(this,`registry`,void 0),r(this,`channelClick`,void 0),r(this,`exitIntent`,void 0),r(this,`form`,void 0),this.bus=e,this.pageData=t,this.registry=n,this.channelClick=i,this.exitIntent=a,this.form=o}static build(t){let{bus:n,pageData:r,registry:i,channelClick:a,exitIntent:o,form:s}=t;return{app:new e(n,r,i,a,o,s)}}init(){this.pageData.init(),this.registry.init(),this.channelClick.init(),this.exitIntent.init(),this.form.init(),this.bus.dispatch(`commversion:attribution-ready`,{})}destroy(){this.registry.destroy(),this.channelClick.destroy(),this.exitIntent.destroy(),this.form.destroy()}},c=class e{constructor(e){r(this,`target`,void 0),this.target=e}on(e,t){let n=e=>{e instanceof CustomEvent&&t(e.detail)};return this.target.addEventListener(e,n),()=>this.target.removeEventListener(e,n)}dispatch(e,t){this.target.dispatchEvent(new CustomEvent(e,{detail:t}))}static build(){return{bus:new e(window)}}},l=class e{constructor(e,t){r(this,`bus`,void 0),r(this,`registry`,void 0),r(this,`unsubscribe`,void 0),this.bus=e,this.registry=t}static build(t){let{bus:n,registry:r}=t;return{channelClick:new e(n,r)}}init(){this.unsubscribe=this.bus.on(`commversion:channel-clicked`,({channel:e})=>{let{sessionVariables:t}=window.LiveChatWidget.get(`customer_data`);this.registry.patchOne(e,{chat_start_url:window.location.href,chat_start_time:new Date().toISOString(),session_variables:t})})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}},u=class e{constructor(e,t,n){r(this,`registry`,void 0),r(this,`debounceMs`,void 0),r(this,`margin`,void 0),r(this,`isMouseInside`,!0),r(this,`leaveTimeout`,void 0),r(this,`onMouseEnter`,()=>{this.registry.patchAll({exit_intent:!1})}),r(this,`onMouseLeave`,()=>{this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})}),r(this,`onMouseMove`,e=>{this.checkBounds(e.clientX,e.clientY)?this.isMouseInside?(clearTimeout(this.leaveTimeout),this.leaveTimeout=void 0):(this.isMouseInside=!0,this.registry.patchAll({exit_intent:!1})):this.isMouseInside&&(this.isMouseInside=!1,this.leaveTimeout=setTimeout(()=>{this.leaveTimeout=void 0,this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})},this.debounceMs))}),this.registry=e,this.debounceMs=t,this.margin=n}init(){window.addEventListener(`mouseenter`,this.onMouseEnter),window.addEventListener(`mouseleave`,this.onMouseLeave),window.addEventListener(`mousemove`,this.onMouseMove)}static build(t){let{registry:n,config:r}=t,{exitIntentDebounceMs:i=1500,exitIntentMargin:a=10}=r;return{exitIntent:new e(n,i,a)}}destroy(){window.removeEventListener(`mouseenter`,this.onMouseEnter),window.removeEventListener(`mouseleave`,this.onMouseLeave),window.removeEventListener(`mousemove`,this.onMouseMove)}checkBounds(e,t){let n=window.innerWidth,r=window.innerHeight;return e>=this.margin&&e<=n-this.margin&&t>=this.margin&&t<=r-this.margin}isBrowsing(){try{return window.LiveChatWidget.get(`customer_data`).status===`browsing`}catch(e){return!1}}},d=class e{constructor(e,t,n,i){r(this,`registry`,void 0),r(this,`abandonmentSelector`,void 0),r(this,`abandonmentDelaySeconds`,void 0),r(this,`submissionSelector`,void 0),r(this,`formAbandonmentTimeout`,void 0),r(this,`abandonmentForms`,void 0),r(this,`submissionForms`,void 0),r(this,`inputs`,void 0),r(this,`onChange`,()=>{clearTimeout(this.formAbandonmentTimeout),this.formAbandonmentTimeout=setTimeout(()=>{this.registry.patchAll({form_abandoned:!0})},this.abandonmentDelaySeconds*1e3)}),r(this,`onAbandonmentFormSubmit`,()=>{clearTimeout(this.formAbandonmentTimeout)}),r(this,`onSubmit`,()=>{this.registry.patchAll({form_submission:!0})}),r(this,`onInvalid`,()=>{this.registry.patchAll({input_error:!0})}),this.registry=e,this.abandonmentSelector=t,this.abandonmentDelaySeconds=n,this.submissionSelector=i}static build(t){let{registry:n,config:r}=t,{formAbandonmentSelector:i=`form`,formAbandonmentDelay:a=10,formSubmissionSelector:o=`form`}=r;return{form:new e(n,i,a,o)}}init(){this.abandonmentForms=document.querySelectorAll(this.abandonmentSelector),this.submissionForms=document.querySelectorAll(this.submissionSelector),this.inputs=document.querySelectorAll(`input`);for(let e of this.abandonmentForms)e.addEventListener(`change`,this.onChange),e.addEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of this.submissionForms)e.addEventListener(`submit`,this.onSubmit);for(let e of this.inputs)e.addEventListener(`invalid`,this.onInvalid)}destroy(){var e,t,n;for(let t of(e=this.abandonmentForms)==null?[]:e)t.removeEventListener(`change`,this.onChange),t.removeEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of(t=this.submissionForms)==null?[]:t)e.removeEventListener(`submit`,this.onSubmit);for(let e of(n=this.inputs)==null?[]:n)e.removeEventListener(`invalid`,this.onInvalid)}};function f(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){f(a,r,i,o,s,`next`,e)}function s(e){f(a,r,i,o,s,`throw`,e)}o(void 0)})}}var m=class e{constructor(e){r(this,`url`,void 0),this.url=e}static build(t){let{url:n}=t;return{http:new e(n)}}post(e){var t=this;return p(function*(){let n=yield fetch(t.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`POST ${t.url} failed with ${n.status}`);return yield n.json()})()}patch(e){var t=this;return p(function*(){yield fetch(t.url,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})})()}},h;function g(e,t,n){var r;function i(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=s.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let a=(r=n==null?void 0:n.Parent)==null?Object:r;class o extends a{}Object.defineProperty(o,"name",{value:e});function s(e){var t;let r=n!=null&&n.Parent?new o:this;i(r,e),(t=r._zod).deferred!=null||(t.deferred=[]);for(let e of r._zod.deferred)e();return r}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>{var r;return n!=null&&n.Parent&&t instanceof n.Parent?!0:t==null||(r=t._zod)==null||(r=r.traits)==null?void 0:r.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var _=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(h=globalThis).__zod_globalConfig!=null||(h.__zod_globalConfig={});var v=globalThis.__zod_globalConfig;function y(e){return e&&Object.assign(v,e),v}function b(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function x(e,t){if(e==null)return{};var n,r,i=b(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var ee=[`inst`,`continue`,`input`];function te(e,t){return typeof t==`bigint`?t.toString():t}function ne(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}var S=Symbol(`evaluating`);function C(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==S)return r===void 0&&(r=S,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}var w=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ie(e,t,n){let r=new e._zod.constr(t==null?e._zod.def:t);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function T(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?a(a({},t),{},{error:()=>t.error}):t}function ae(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function E(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0}return!1}function D(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0}return!1}function O(e,t){return t.map(t=>{var n;return(n=t).path!=null||(n.path=[]),t.path.unshift(e),t})}function k(e){return typeof e==`string`?e:e==null?void 0:e.message}function A(e,t,n){var r,i,a,o,s,c,l,u,d;let f=e.message?e.message:(r=(i=(a=(o=k((s=e.inst)==null||(s=s._zod.def)==null||(c=s.error)==null?void 0:c.call(s,e)))==null?k(t==null||(l=t.error)==null?void 0:l.call(t,e)):o)==null?k((u=n.customError)==null?void 0:u.call(n,e)):a)==null?k((d=n.localeError)==null?void 0:d.call(n,e)):i)==null?`Invalid input`:r,{inst:p,continue:m,input:h}=e,g=x(e,ee);return g.path!=null||(g.path=[]),g.message=f,t!=null&&t.reportInput&&(g.input=h),g}var j=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,te,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},oe=g(`$ZodError`,j),M=g(`$ZodError`,j,{Parent:Error}),se=(e=>(t,n,r,i)=>{let o=r?a(a({},r),{},{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new _;if(s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>A(e,o,y())));throw w(t,i==null?void 0:i.callee),t}return s.value})(M),ce=(e=>function(){var t=p(function*(t,n,r,i){let o=r?a(a({},r),{},{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=yield s),s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>A(e,o,y())));throw w(t,i==null?void 0:i.callee),t}return s.value});return function(e,n,r,i){return t.apply(this,arguments)}}())(M),N=(e=>(t,n,r)=>{let i=r?a(a({},r),{},{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new _;return o.issues.length?{success:!1,error:new(e==null?oe:e)(o.issues.map(e=>A(e,i,y())))}:{success:!0,data:o.value}})(M),P=(e=>function(){var t=p(function*(t,n,r){let i=r?a(a({},r),{},{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=yield o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>A(e,i,y())))}:{success:!0,data:o.value}});return function(e,n,r){return t.apply(this,arguments)}}())(M),le=/^https?$/,F=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;`${F}`;function ue(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function I(e){let t=ue({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${F}T(?:${r})$`)}var L=e=>{var t,n;let r=e?`[\\s\\S]{${(t=e==null?void 0:e.minimum)==null?0:t},${(n=e==null?void 0:e.maximum)==null?``:n}}`:`[\\s\\S]*`;return RegExp(`^${r}$`)},R=g(`$ZodCheck`,(e,t)=>{var n;e._zod!=null||(e._zod={}),e._zod.def=t,(n=e._zod).onattach!=null||(n.onattach=[])}),z=g(`$ZodCheckStringFormat`,(e,t)=>{var n,r;R.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns!=null||(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check!=null||(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push(a(a({origin:`string`,code:`invalid_format`,format:t.format,input:n.value},t.pattern?{pattern:t.pattern.toString()}:{}),{},{inst:e,continue:!t.abort}))}):(r=e._zod).check!=null||(r.check=()=>{})}),B={major:4,minor:4,patch:3},V=g(`$ZodType`,(e,t)=>{var n,r;e!=null||(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=B;let i=[...(n=e._zod.def.checks)==null?[]:n];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0){var o;(r=e._zod).deferred!=null||(r.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse})}else{let t=(e,t,n)=>{let r=E(e),i;for(let o of t){if(o._zod.def.when){if(D(e)||!o._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&(n==null?void 0:n.async)===!1)throw new _;if(i||s instanceof Promise){var a;i=((a=i)==null?Promise.resolve():a).then(p(function*(){yield s,e.issues.length!==t&&(r||(r=E(e,t)))}))}else{if(e.issues.length===t)continue;r||(r=E(e,t))}}return i?i.then(()=>e):e},n=(n,r,a)=>{if(E(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new _;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,o)=>{if(o.skipChecks)return e._zod.parse(r,o);if(o.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},a(a({},o),{},{skipChecks:!0}));return t instanceof Promise?t.then(e=>n(e,r,o)):n(t,r,o)}let s=e._zod.parse(r,o);if(s instanceof Promise){if(o.async===!1)throw new _;return s.then(e=>t(e,i,o))}return t(s,i,o)}}C(e,`~standard`,()=>({validate:t=>{try{var n;let r=N(e,t);return r.success?{value:r.data}:{issues:(n=r.error)==null?void 0:n.issues}}catch(n){return P(e,t).then(e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}})}},vendor:`zod`,version:1}))}),H=g(`$ZodString`,(e,t)=>{var n,r,i;V.init(e,t),e._zod.pattern=(n=[...(r=e==null||(i=e._zod.bag)==null?void 0:i.patterns)==null?[]:r].pop())==null?L(e._zod.bag):n,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(e){}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),U=g(`$ZodStringFormat`,(e,t)=>{z.init(e,t),H.init(e,t)}),de=g(`$ZodURL`,(e,t)=>{U.init(e,t),e._zod.check=n=>{try{var r;let i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===le.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let a=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(`:`)?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=i;return}catch(r){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),fe=g(`$ZodISODateTime`,(e,t)=>{t.pattern!=null||(t.pattern=I(t)),U.init(e,t)}),pe=g(`$ZodNever`,(e,t)=>{V.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function W(e,t,n){e.issues.length&&t.issues.push(...O(n,e.issues)),t.value[n]=e.value}var me=g(`$ZodArray`,(e,t)=>{V.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>W(t,n,e))):W(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function G(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...O(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function he(e){let t=Object.keys(e.shape);for(let r of t){var n;if(!(!((n=e.shape)==null||(n=n[r])==null||(n=n._zod)==null||(n=n.traits)==null)&&n.has(`$ZodType`)))throw Error(`Invalid element at key "${r}": expected a Zod schema`)}let r=ae(e.shape);return a(a({},e),{},{keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)})}function ge(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>G(e,n,i,t,u,d))):G(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var _e=g(`$ZodObject`,(e,t)=>{V.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`);if(!(n!=null&&n.get)){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n=a({},e);return Object.defineProperty(t,"shape",{value:n}),n}})}let r=ne(()=>he(t));C(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]!=null||(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let i=re,o=t.catchall,s;e._zod.parse=(t,n)=>{s!=null||(s=r.value);let a=t.value;if(!i(a))return t.issues.push({expected:`object`,code:`invalid_type`,input:a,inst:e}),t;t.value={};let c=[],l=s.shape;for(let e of s.keys){let r=l[e],i=r._zod.optin===`optional`,o=r._zod.optout===`optional`,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>G(n,t,e,a,i,o))):G(s,t,e,a,i,o)}return o?ge(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}});function ve(e,t){return new e(a({type:`string`},T(t)))}function ye(e,t){return new e(a({type:`string`,format:`url`,check:`string_format`,abort:!1},T(t)))}function be(e,t){return new e(a({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null},T(t)))}function xe(e,t){return new e(a({type:`never`},T(t)))}var K=g(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);V.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>se(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>N(e,t,n),e.parseAsync=function(){var t=p(function*(t,n){return ce(e,t,n,{callee:e.parseAsync})});return function(e,n){return t.apply(this,arguments)}}(),e.safeParseAsync=function(){var t=p(function*(t,n){return P(e,t,n)});return function(e,n){return t.apply(this,arguments)}}(),e.check=(...n)=>{var r;return e.clone(a(a({},t),{},{checks:[...(r=t.checks)==null?[]:r,...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},e.with=e.check,e.clone=(t,n)=>ie(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),q=g(`ZodMiniString`,(e,t)=>{H.init(e,t),K.init(e,t)});function J(e){return ve(q,e)}var Y=g(`ZodMiniStringFormat`,(e,t)=>{U.init(e,t),q.init(e,t)}),Se=g(`ZodMiniURL`,(e,t)=>{de.init(e,t),Y.init(e,t)});function X(e){return ye(Se,e)}var Ce=g(`ZodMiniNever`,(e,t)=>{pe.init(e,t),K.init(e,t)});function we(e){return xe(Ce,e)}var Te=g(`ZodMiniArray`,(e,t)=>{me.init(e,t),K.init(e,t)});function Ee(e,t){return new Te(a({type:`array`,element:e},T(t)))}var De=g(`ZodMiniObject`,(e,t)=>{_e.init(e,t),K.init(e,t),C(e,`shape`,()=>t.shape)});function Z(e,t){return new De(a({type:`object`,shape:e,catchall:we()},T(t)))}var Oe=g(`ZodMiniISODateTime`,(e,t)=>{fe.init(e,t),Y.init(e,t)});function ke(e){return be(Oe,e)}var Ae=e=>{let t={};for(let n of e.split(/;\s*/)){if(!n)continue;let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim();if(!r)continue;let i=n.slice(e+1).trim();try{t[r]=decodeURIComponent(i)}catch(e){t[r]=i}}return t},je=Z({referrer:J(),landing_page:X(),browsing_history:Ee(Z({opened_at:ke(),url:X(),title:J()}))}),Q=`lc_browsing_history_data`,Me=`screen and (max-width: 992px) and (pointer: coarse)`,Ne=class e{constructor(e){r(this,`sessionVariables`,void 0),r(this,`data`,void 0),this.sessionVariables=e}static build(t){let{sessionVariables:n}=t;return{pageData:new e(n)}}init(){this.data=Pe(this.sessionVariables)}get(){if(this.data===void 0)throw Error(`PageDataCollector.get called before init`);return this.data}},Pe=e=>{let t=new URLSearchParams(window.location.search);return a(a(a({session_variables:e,device:window.matchMedia(Me).matches?`mobile`:`desktop`},Fe(t,e)),Ie(t)),Le())},Fe=(e,t)=>{var n,r,i;let a={};if(window.gaGlobal===void 0)return a;let o=Ae(document.cookie),s=Object.entries(o),c=(n=window.analytics)==null?void 0:n.user(),l=window.gaGlobal.vid,u=s.filter(([e])=>e.startsWith(`_ga_`)).map(e=>{var t;return(t=e[1])==null?``:t}),d=e.get(`gclid`)||((r=s.find(([e])=>e.startsWith(`_gcl_aw`)))==null?void 0:r[1])||t.gclid,f=e.get(`dclid`)||o._gcl_dc||t.dclid,p=t.fbc||o._fbc,m=t.fbp||o._fbp,h=e.get(`ttclid`)||o._ttp,g=e.get(`li_fat_id`)||o.li_fat_id,_=(c==null?void 0:c.anonymousId())||window.localStorage.getItem(`ajs_anonymous_id`),v=(c==null?void 0:c.id())||window.localStorage.getItem(`ajs_user_id`),y=(i=s.find(([e])=>e.startsWith(`bid_`)))==null?void 0:i[1];return l&&(a.ga_session=l),u.length>0&&(a.ga_session_id=u),d&&(a.gclid=d),f&&(a.dclid=f),p&&(a.fbc=p),m&&(a.fbp=m),h&&(a.ttclid=h),g&&(a.li_fat_id=g),_&&(a.segment_anonymous_id=_),v&&(a.segment_user_id=v),y&&(a.sitecore_browser_id=y),a},Ie=e=>{let t={},n=e.get(`utm_id`),r=e.get(`utm_source`),i=e.get(`utm_medium`),a=e.get(`utm_campaign`),o=e.get(`utm_term`),s=e.get(`utm_content`);return n&&(t.utm_id=n),r&&(t.utm_source=r),i&&(t.utm_medium=i),a&&(t.utm_campaign=a),o&&(t.utm_term=o),s&&(t.utm_content=s),t},Le=()=>{let e=$(),t=new Date;t.setDate(t.getDate()-30);let n=e.browsing_history.filter(e=>new Date(e.opened_at)>t),r={opened_at:new Date().toISOString(),url:window.location.href,title:document.title},i=n.length===0?{referrer:document.referrer,landing_page:r.url,browsing_history:[r]}:a(a({},e),{},{browsing_history:[...n,r].slice(-50)});return window.localStorage.setItem(Q,JSON.stringify(i)),i},$=()=>{let e=window.localStorage.getItem(Q);if(!e)return{referrer:``,landing_page:``,browsing_history:[]};try{return je.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${Q}:`,{content:e},t),{referrer:``,landing_page:``,browsing_history:[]}}},Re=class e{constructor(e,t,n,i){r(this,`bus`,void 0),r(this,`http`,void 0),r(this,`pageData`,void 0),r(this,`clientId`,void 0),r(this,`shortCodes`,{whatsapp:void 0,sms:void 0,facebook:void 0}),r(this,`unsubscribe`,void 0),this.bus=e,this.http=t,this.pageData=n,this.clientId=i}static build(t){let{bus:n,http:r,pageData:i,config:a}=t;return{registry:new e(n,r,i,a.clientId)}}init(){this.unsubscribe=this.bus.on(`commversion:channels-registered`,({channels:e})=>{for(let t of e)this.shortCodes[t]===void 0&&(this.shortCodes[t]=this.startChannel(t),this.shortCodes[t].catch(e=>console.error(e)))})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}patchAll(e){for(let t of Object.values(this.shortCodes))t==null||t.then(t=>this.http.patch(a({short_code:t},e)).catch(e=>console.error(e)),()=>{})}patchOne(e,t){var n;(n=this.shortCodes[e])==null||n.then(e=>this.http.patch(a({short_code:e},t)).catch(e=>console.error(e)),()=>{})}startChannel(e){var t=this;return p(function*(){try{let{short_code:n}=yield t.http.post(a(a({},t.pageData.get()),{},{client_id:t.clientId,channel:e,exit_intent:!1}));return t.bus.dispatch(`commversion:shortcode-resolved`,{channel:e,shortCode:n}),n}catch(n){let r=n instanceof Error?n.message:String(n);throw t.bus.dispatch(`commversion:shortcode-failed`,{channel:e,error:r}),n}})()}},ze=`https://api.cht-srvc.net/attribution`,Be=e=>{var t;let n,r=(t=e.attributionUrl)==null?ze:t;return Object.assign(({customerData:t})=>{n=new o({config:e,url:r,sessionVariables:t.sessionVariables}).provide(c.build).provide(m.build).provide(Ne.build).provide(Re.build).provide(l.build).provide(u.build).provide(d.build).provide(s.build).dependencies.app,n.init()},{destroy:()=>{n==null||n.destroy(),n=void 0}})};window.commversion=window.commversion||{};var Ve=Be(window.commversion);window.LiveChatWidget.once(`ready`,Ve)})();
|