@bitpalm/ai-agents 0.4.0 → 0.6.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.
- package/README.md +57 -193
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -2
- package/dist/index.d.ts +50 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +47 -2
- package/dist/react.d.ts +47 -2
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/widget.global.js +1 -1
- package/dist/widget.global.js.map +1 -1
- package/package.json +10 -18
package/README.md
CHANGED
|
@@ -4,235 +4,99 @@ Drop-in AI chat agent widget for any website. Works with React, Next.js, Vue, va
|
|
|
4
4
|
|
|
5
5
|
> Don't have an agent yet? [Create one for free](https://agents.bitpalm.ai/register) — takes less than 10 minutes.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 30-second install
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
### Script tag (any HTML page)
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<script
|
|
13
|
+
async
|
|
14
|
+
src="https://unpkg.com/@bitpalm/ai-agents"
|
|
15
|
+
data-slug="your-agent-slug"
|
|
16
|
+
data-token="your-embed-token"
|
|
17
|
+
></script>
|
|
11
18
|
```
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
### React / Next.js
|
|
14
21
|
|
|
15
22
|
```tsx
|
|
16
|
-
import { BitPalmAgent } from
|
|
23
|
+
import { BitPalmAgent } from "@bitpalm/ai-agents/react";
|
|
17
24
|
|
|
18
|
-
export default function
|
|
25
|
+
export default function RootLayout({ children }) {
|
|
19
26
|
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
<html>
|
|
28
|
+
<body>
|
|
29
|
+
{children}
|
|
30
|
+
<BitPalmAgent slug="your-agent-slug" token="your-embed-token" />
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
|
24
33
|
);
|
|
25
34
|
}
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## Vanilla JavaScript
|
|
37
|
+
### Vanilla JS
|
|
31
38
|
|
|
32
39
|
```js
|
|
33
|
-
import { createWidget } from
|
|
34
|
-
|
|
35
|
-
const widget = createWidget({ slug: 'your-agent-slug', token: 'your-embed-token' });
|
|
36
|
-
|
|
37
|
-
// Programmatic control
|
|
38
|
-
widget.open();
|
|
39
|
-
widget.close();
|
|
40
|
-
widget.toggle(); // open if closed, close if open
|
|
41
|
-
widget.isOpen(); // check if widget is open
|
|
42
|
-
widget.identify({
|
|
43
|
-
externalUserId: 'cust_123',
|
|
44
|
-
name: 'Max Mustermann',
|
|
45
|
-
email: 'max@example.com',
|
|
46
|
-
});
|
|
47
|
-
widget.context({
|
|
48
|
-
cart: { items: [{ name: 'Sneakers', price: 99.99 }], total: 99.99 },
|
|
49
|
-
});
|
|
50
|
-
widget.resetContext(); // clear all custom context
|
|
51
|
-
widget.send('Tell me about the Enterprise plan'); // send message as user
|
|
52
|
-
widget.on('lead_captured', (data) => console.log('Lead!', data)); // listen to events
|
|
53
|
-
widget.destroy();
|
|
54
|
-
```
|
|
40
|
+
import { createWidget } from "@bitpalm/ai-agents";
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
No build step required — add a single script tag to any HTML page:
|
|
59
|
-
|
|
60
|
-
```html
|
|
61
|
-
<script async src="https://unpkg.com/@bitpalm/ai-agents" data-slug="your-agent-slug" data-token="your-embed-token"></script>
|
|
42
|
+
const widget = createWidget({ slug: "your-agent-slug", token: "your-embed-token" });
|
|
62
43
|
```
|
|
63
44
|
|
|
64
|
-
##
|
|
45
|
+
## Light & dark theme
|
|
65
46
|
|
|
66
|
-
|
|
67
|
-
|--------|------|---------|-------------|
|
|
68
|
-
| `slug` | `string` | — | **Required.** Your agent slug from the [BitPalm dashboard](https://agents.bitpalm.ai). |
|
|
69
|
-
| `token` | `string` | — | Required for restricted/private agents. Embed token from dashboard access settings. |
|
|
70
|
-
| `locale` | `string` | auto-detected | Widget language (`"en"`, `"de"`, `"ar"`, …). Falls back to `document.documentElement.lang`. |
|
|
71
|
-
| `baseUrl` | `string` | `"https://agents.bitpalm.ai"` | Agent platform URL. Only change this for self-hosted setups. |
|
|
72
|
-
| `zIndex` | `number` | `9999` | z-index for the widget iframe and chat button. |
|
|
73
|
-
| `autoIdentify` | `boolean` | `true` | Auto-detects form submissions and sends found identity fields (email/phone/name/company) for visitor stitching. |
|
|
47
|
+
Set up dark colors for your agent in the dashboard playground. The widget then follows your website's theme on its own (`class="dark"`, `data-theme="dark"`, the page background or `color-scheme`) and switches live.
|
|
74
48
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- **Visitor Intelligence** — automatically sends page URL, title, and navigation history to the agent for context-aware responses
|
|
78
|
-
- **Returning visitor detection** — recognizes returning visitors, restores chat history, and enables session/page-count-based triggers
|
|
79
|
-
- **SPA support** — detects client-side navigation (`pushState` / `replaceState`) and keeps the widget alive across route changes
|
|
80
|
-
- **Trigger bubbles** — proactive chat bubbles configured from the dashboard, including visitor-data-driven triggers (session count, visited pages)
|
|
81
|
-
- **Scroll & exit tracking** — scroll depth and exit intent signals for smart triggers
|
|
82
|
-
- **Automatic form identity stitching** — captures common form fields on submit and links them to the current visitor profile
|
|
83
|
-
- **Custom context** — pass business data (cart, user tier, listings) to the AI for contextual, relevant answers
|
|
84
|
-
- **Privacy-friendly** — respects visitor opt-out (`_bp_optout` in localStorage); when opted out, no tracking beacons are sent and no visitor ID is stored
|
|
85
|
-
- **Light & fast** — no dependencies (React is optional), tiny bundle size
|
|
86
|
-
|
|
87
|
-
## Optional Field Hints
|
|
88
|
-
|
|
89
|
-
The widget already detects common field names automatically. For custom forms, you can add explicit markers:
|
|
90
|
-
|
|
91
|
-
- `data-bp-email`
|
|
92
|
-
- `data-bp-phone`
|
|
93
|
-
- `data-bp-name` (or `data-bp-first-name` / `data-bp-last-name`)
|
|
94
|
-
- `data-bp-company`
|
|
95
|
-
- `data-bp-field="email|phone|name|first-name|last-name|company"` (generic fallback)
|
|
96
|
-
|
|
97
|
-
Disable auto-identity for one specific form:
|
|
49
|
+
To set it yourself:
|
|
98
50
|
|
|
99
51
|
```html
|
|
100
|
-
<
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Manual Identify (Logged-in Users)
|
|
104
|
-
|
|
105
|
-
If your website has authenticated users, call `identify()` after login to attach trusted profile data to the current visitor:
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
widget.identify({
|
|
109
|
-
externalUserId: "user_42",
|
|
110
|
-
name: "Alex Example",
|
|
111
|
-
email: "alex@example.com",
|
|
112
|
-
phone: "+491701234567",
|
|
113
|
-
company: "Example GmbH",
|
|
114
|
-
});
|
|
52
|
+
<script async src="https://unpkg.com/@bitpalm/ai-agents" data-slug="your-agent-slug" data-theme="dark"></script>
|
|
115
53
|
```
|
|
116
54
|
|
|
117
|
-
Optional signed identify fields (forwarded to your BitPalm backend):
|
|
118
|
-
|
|
119
|
-
- `signature`: backend-generated HMAC signature
|
|
120
|
-
- `signedAt`: unix timestamp (seconds)
|
|
121
|
-
- `signatureVersion`: currently `"v1"`
|
|
122
|
-
|
|
123
|
-
For script-tag integrations, trigger identify via a browser event:
|
|
124
|
-
|
|
125
55
|
```js
|
|
126
|
-
|
|
127
|
-
new CustomEvent("bitpalm-identify", {
|
|
128
|
-
detail: {
|
|
129
|
-
slug: "your-agent-slug",
|
|
130
|
-
externalUserId: "user_42",
|
|
131
|
-
name: "Alex Example",
|
|
132
|
-
email: "alex@example.com",
|
|
133
|
-
},
|
|
134
|
-
})
|
|
135
|
-
);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## Custom Context (Business Data for the AI)
|
|
139
|
-
|
|
140
|
-
Pass custom data from your website to the AI chatbot so it can give contextual, business-specific answers. Context is merged — calling `context()` multiple times adds to the existing data without replacing it.
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
// Shopify / E-Commerce: pass cart data
|
|
144
|
-
widget.context({
|
|
145
|
-
cart: {
|
|
146
|
-
items: [
|
|
147
|
-
{ name: "Nike Air Max 90", size: "42", price: 149.99 },
|
|
148
|
-
{ name: "Adidas Hoodie", qty: 2, price: 59.99 },
|
|
149
|
-
],
|
|
150
|
-
total: 269.97,
|
|
151
|
-
currency: "EUR",
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// SaaS: pass user status
|
|
156
|
-
widget.context({
|
|
157
|
-
plan: "trial",
|
|
158
|
-
trialDaysLeft: 3,
|
|
159
|
-
accountId: "acc_12345",
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// Real Estate: pass current listing
|
|
163
|
-
widget.context({
|
|
164
|
-
property: { address: "Musterstr. 12, Berlin", price: 450000, rooms: 3 },
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// Merges with previous context (doesn't replace)
|
|
168
|
-
widget.context({ promoCode: "SUMMER20" });
|
|
56
|
+
widget.setTheme("dark"); // "light", "dark" or "auto"
|
|
169
57
|
```
|
|
170
58
|
|
|
171
|
-
|
|
59
|
+
## Your own chat button
|
|
172
60
|
|
|
173
|
-
|
|
61
|
+
In an app or PWA the chat can open from a button of your own, like a tab in the bottom navigation, and a proactive message can show as a dot on it:
|
|
174
62
|
|
|
175
63
|
```js
|
|
176
|
-
|
|
177
|
-
new CustomEvent("bitpalm-context", {
|
|
178
|
-
detail: {
|
|
179
|
-
slug: "your-agent-slug",
|
|
180
|
-
cart: { items: [...], total: 99.99 },
|
|
181
|
-
},
|
|
182
|
-
})
|
|
183
|
-
);
|
|
184
|
-
```
|
|
64
|
+
const widget = createWidget({ slug: "your-agent-slug", launcher: false, triggers: "events" });
|
|
185
65
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
Send a message as the user without them typing. Opens the widget automatically if closed.
|
|
191
|
-
|
|
192
|
-
```ts
|
|
193
|
-
// E.g. triggered by a "Ask about this product" button on your page
|
|
194
|
-
widget.send('Tell me more about the Enterprise plan');
|
|
195
|
-
|
|
196
|
-
// Or from a product page CTA
|
|
197
|
-
document.querySelector('#ask-bot').addEventListener('click', () => {
|
|
198
|
-
widget.send(`What can you tell me about ${productName}?`);
|
|
199
|
-
});
|
|
66
|
+
chatTab.onclick = () => widget.open(); // opens with the waiting message, if there is one
|
|
67
|
+
widget.on("trigger_shown", () => (dot.hidden = false));
|
|
68
|
+
widget.on("trigger_hidden", () => (dot.hidden = true));
|
|
200
69
|
```
|
|
201
70
|
|
|
202
|
-
|
|
71
|
+
`triggers: false` switches proactive messages off, `widget.disableTriggers()` and `enableTriggers()` do it at runtime. The widget's elements carry `data-bitpalm-launcher`, `data-bitpalm-trigger` and `data-bitpalm-chat`. In React, `<BitPalmAgent onReady={(widget) => …} />` hands you the instance.
|
|
203
72
|
|
|
204
|
-
|
|
73
|
+
## Full documentation
|
|
205
74
|
|
|
206
|
-
|
|
207
|
-
// Track leads in Google Analytics
|
|
208
|
-
widget.on('lead_captured', (data) => {
|
|
209
|
-
gtag('event', 'generate_lead', { source: 'chatbot' });
|
|
210
|
-
});
|
|
75
|
+
📚 **[agents.bitpalm.ai/docs](https://agents.bitpalm.ai/docs)**
|
|
211
76
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
77
|
+
- [Quickstart for Script Tag](https://agents.bitpalm.ai/docs/quickstart/script-tag)
|
|
78
|
+
- [Quickstart for React / Next.js](https://agents.bitpalm.ai/docs/quickstart/react)
|
|
79
|
+
- [Quickstart for Vanilla JS](https://agents.bitpalm.ai/docs/quickstart/vanilla)
|
|
80
|
+
- [Configuration options](https://agents.bitpalm.ai/docs/configuration)
|
|
81
|
+
- [Light & dark theme](https://agents.bitpalm.ai/docs/theming)
|
|
82
|
+
- [Identify logged-in users](https://agents.bitpalm.ai/docs/identify)
|
|
83
|
+
- [Custom Context (cart, listings, account data)](https://agents.bitpalm.ai/docs/context)
|
|
84
|
+
- [Events (lead capture, conversation start)](https://agents.bitpalm.ai/docs/events)
|
|
85
|
+
- [Own chat button (apps, PWAs)](https://agents.bitpalm.ai/docs/own-chat-button)
|
|
86
|
+
- [API Reference](https://agents.bitpalm.ai/docs/api-reference)
|
|
87
|
+
- [Common Errors](https://agents.bitpalm.ai/docs/common-errors)
|
|
216
88
|
|
|
217
|
-
|
|
218
|
-
widget.on('widget_opened', () => console.log('Chat opened'));
|
|
219
|
-
widget.on('widget_closed', () => console.log('Chat closed'));
|
|
220
|
-
|
|
221
|
-
// Unsubscribe
|
|
222
|
-
const unsub = widget.on('message_sent', (data) => { ... });
|
|
223
|
-
unsub(); // stop listening
|
|
224
|
-
```
|
|
89
|
+
## Features
|
|
225
90
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
| `lead_captured` | AI captures a lead via tool | `{ conversationId }` |
|
|
91
|
+
- Visitor Intelligence with intent scoring
|
|
92
|
+
- Returning visitor detection + chat history persistence
|
|
93
|
+
- SPA navigation tracking (`pushState` / `replaceState`)
|
|
94
|
+
- Trigger bubbles (session/page count, scroll depth, exit intent)
|
|
95
|
+
- Form auto-identify + signed identify for trusted data
|
|
96
|
+
- Custom context for business-aware AI responses
|
|
97
|
+
- Privacy-friendly with opt-out support
|
|
98
|
+
- Tiny bundle, no React dependency for vanilla build
|
|
235
99
|
|
|
236
100
|
## License
|
|
237
101
|
|
|
238
|
-
MIT —
|
|
102
|
+
MIT — built and operated by [BitPalm](https://agents.bitpalm.ai).
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var me=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Ge=(t,o)=>{for(var m in o)me(t,m,{get:o[m],enumerable:!0})},Ve=(t,o,m,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let p of Ye(o))!Je.call(t,p)&&p!==m&&me(t,p,{get:()=>o[p],enumerable:!(a=qe(o,p))||a.enumerable});return t};var Ke=t=>Ve(me({},"__esModule",{value:!0}),t);var lt={};Ge(lt,{createWidget:()=>Q});module.exports=Ke(lt);var Xe="https://agents.bitpalm.ai",h="_bp_",Ze=new Set(["password","file","checkbox","radio","submit","button","reset","image"]),Qe=8e3,He=4096,Ne=`${h}identify_signature`,Re=`${h}identify_fingerprint`,Fe=`${h}identify_sent_at`;function et(t){return[t.external_user_id||"",t.email||"",t.phone||"",t.name||"",t.company||"",t.signature||"",t.signed_at!=null?String(t.signed_at):"",t.signature_version||"",t.identify_source||""].join("|").toLowerCase()}function d(t,o=180){return t?t.replace(/\s+/g," ").trim().slice(0,o):""}function tt(t){return t?` ${t.toLowerCase().replace(/[_-]+/g," ").replace(/[^a-z0-9\s@.]/g," ").replace(/\s+/g," ").trim()} `:""}function W(t,o){for(let m of o)if(t.includes(m))return!0;return!1}function A(t){return/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/i.test(t)}function _(t){let o=d(t,50);if(!o)return"";let m=o.startsWith("+"),a=o.replace(/\D/g,"");return a.length<6?"":`${m?"+":""}${a.slice(0,20)}`}function De(t){let o=d(t,140).toLowerCase();return!o||!A(o)?"":o}function U(t,o){for(let m of o){let a=t.querySelector(m),p=d(a?.value);if(p)return p}return""}function nt(t){return d(t.getAttribute("data-bp-field")||t.getAttribute("data-bitpalm-field"),64).toLowerCase().replace(/[_\s]+/g,"-")}function ot(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function it(t,o){let m=[],a=(i,x=140)=>{let l=d(i,x);l&&m.push(l)};a(o.name),a(o.id),a(o.getAttribute("autocomplete")),a(o.getAttribute("placeholder")),a(o.getAttribute("aria-label")),a(o.getAttribute("data-field")),a(o.getAttribute("data-name")),a(o.getAttribute("data-label")),a(o.getAttribute("data-bp-field")),a(o.getAttribute("data-bitpalm-field"));let p=new Set,w=i=>{let x=d(i,200);!x||p.has(x)||(p.add(x),m.push(x))};for(let i of Array.from(o.labels||[]))w(i.textContent);if(o.id){let i=t.querySelector(`label[for="${ot(o.id)}"]`);w(i?.textContent)}let y=o.closest("label");w(y?.textContent);let r=o.getAttribute("aria-labelledby");if(r)for(let i of r.split(/\s+/)){if(!i)continue;let x=t.ownerDocument.getElementById(i);w(x?.textContent)}return m}function st(t){let o=d(U(t,["[data-bp-email]","[data-bitpalm-email]"]),140).toLowerCase(),m=_(U(t,["[data-bp-phone]","[data-bitpalm-phone]"])),a=d(U(t,["[data-bp-name]","[data-bitpalm-name]","[data-bp-full-name]","[data-bitpalm-full-name]"])),p=d(U(t,["[data-bp-first-name]","[data-bitpalm-first-name]"])),w=d(U(t,["[data-bp-last-name]","[data-bitpalm-last-name]"])),y=d(U(t,["[data-bp-company]","[data-bitpalm-company]"]));for(let l of Array.from(t.elements)){if(!(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement||l instanceof HTMLSelectElement)||l.disabled||l instanceof HTMLInputElement&&Ze.has(l.type.toLowerCase()))continue;let g=nt(l),u=l.hasAttribute("data-bp-email")||l.hasAttribute("data-bitpalm-email")||l.hasAttribute("data-bp-phone")||l.hasAttribute("data-bitpalm-phone")||l.hasAttribute("data-bp-name")||l.hasAttribute("data-bitpalm-name")||l.hasAttribute("data-bp-full-name")||l.hasAttribute("data-bitpalm-full-name")||l.hasAttribute("data-bp-first-name")||l.hasAttribute("data-bitpalm-first-name")||l.hasAttribute("data-bp-last-name")||l.hasAttribute("data-bitpalm-last-name")||l.hasAttribute("data-bp-company")||l.hasAttribute("data-bitpalm-company")||!!g;if(l instanceof HTMLInputElement&&l.type.toLowerCase()==="hidden"&&!u)continue;let c=d(l.value);if(!c)continue;let $=l instanceof HTMLInputElement?l.type.toLowerCase():"",S=tt(it(t,l).join(" "));if(!o&&g==="email"&&A(c)){o=c.toLowerCase();continue}if(!m&&(g==="phone"||g==="tel"||g==="mobile"||g==="whatsapp")){let I=_(c);if(I){m=I;continue}}if(!y&&g==="company"){y=d(c,160);continue}if(!p&&(g==="first-name"||g==="firstname")){p=d(c,100);continue}if(!w&&(g==="last-name"||g==="lastname"||g==="surname")){w=d(c,100);continue}if(!a&&(g==="name"||g==="full-name"||g==="fullname")){!A(c)&&!_(c)&&(a=d(c,140));continue}let j=$==="email"||W(S,[" email "," e mail "," mail "," email adresse "," mailadresse "," correo "]),O=$==="tel"||W(S,[" phone "," phone number "," mobile "," tel "," telefon "," telefonnummer "," whatsapp "," handy "," kontakt "," nummer "]),H=W(S,[" company "," company name "," firma "," firmenname "," organization "," organisation "," business "," unternehmen "," agency "," brokerage "]),N=W(S,[" first name "," firstname "," given name "," givenname "," vorname "," fname "]),R=W(S,[" last name "," lastname "," family name "," familyname "," surname "," nachname "," lname "]),z=W(S,[" full name "," fullname "," contact name "," name "])&&!j&&!O;if(!o&&j&&A(c)){o=c.toLowerCase();continue}if(!m&&O){let I=_(c);if(I){m=I;continue}}if(!y&&H){y=d(c,160);continue}if(!p&&N){p=d(c,100);continue}if(!w&&R){w=d(c,100);continue}if(!a&&z&&!A(c)&&!_(c)){a=d(c,140);continue}!o&&A(c)&&(o=c.toLowerCase())}if(a&&(A(a)||_(a))&&(a=""),y&&(A(y)||_(y))&&(y=""),a||(a=d([p,w].filter(Boolean).join(" "),140)),a&&o&&a.toLowerCase()===o.toLowerCase()&&(a=""),!!!(o||m)&&!!!(a&&y))return null;let x={...a?{name:a}:{},...o?{email:o}:{},...m?{phone:m}:{},...y?{company:y}:{}};return Object.keys(x).length>0?x:null}function at(){if(typeof document<"u"){let t=document.documentElement.lang;if(t)return t.slice(0,2).toLowerCase()}return"en"}function ue(t,o=1200){if(typeof window<"u"&&"requestIdleCallback"in window){window.requestIdleCallback(t,{timeout:o});return}setTimeout(t,Math.min(o,300))}function fe(){if(typeof window>"u")return!1;let t=typeof navigator<"u"?navigator.userAgent:"";if(/Android|iPhone|iPad|iPod|IEMobile|Windows Phone|Mobile/i.test(t))return!0;let m=window.matchMedia("(pointer: coarse)").matches,a=window.matchMedia("(hover: none)").matches,p=Math.min(window.screen?.width||window.innerWidth,window.screen?.height||window.innerHeight);return m&&a&&p<=900}function Q(t){let{slug:o,locale:m=at(),baseUrl:a=Xe,token:p,zIndex:w=9999,autoIdentify:y=!0}=t,r=document,i=r.createElement("iframe"),x=`${a}/t/${o}/widget`,l=new URLSearchParams({locale:m});p&&l.set("token",p),i.src=`${x}?${l.toString()}`,i.allow="clipboard-write; microphone",i.setAttribute("allowtransparency","true"),i.loading="lazy",i.style.cssText=`position:fixed;bottom:0;right:0;width:1px;height:1px;border:none;z-index:${w};background:transparent;color-scheme:normal;opacity:0;pointer-events:none;`;let g=new URL(i.src).origin,u=r.createElement("div");if(u.setAttribute("role","button"),u.setAttribute("aria-label","Chat"),u.style.cssText=`position:fixed;bottom:24px;right:24px;width:56px;height:56px;border-radius:50%;display:none;align-items:center;justify-content:center;cursor:pointer;z-index:${w-1};background:#00ff41;box-shadow:0 0 15px rgba(0,255,65,0.31);transition:transform .2s,opacity .3s;opacity:0;`,u.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/></svg>',u.onmouseenter=()=>{u.style.transform="scale(1.1)"},u.onmouseleave=()=>{u.style.transform="scale(1)"},u.onclick=()=>X(),r.body.appendChild(u),!r.getElementById("_bp_fade")){let e=r.createElement("style");e.id="_bp_fade",e.textContent="@keyframes _bp_fade{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}",r.head.appendChild(e)}let c=null,$=!1,S=!1,j=!1,O=!1,H=!1,N=()=>{j||(j=!0,r.body.appendChild(i))},R=!1,z=0,I={overflow:"",overscrollBehavior:""},v={overflow:"",overscrollBehavior:"",position:"",top:"",left:"",right:"",width:""},pe=()=>{if(R||!fe())return;let s=r.documentElement,n=r.body;z=window.scrollY||window.pageYOffset||0,I.overflow=s.style.overflow,I.overscrollBehavior=s.style.overscrollBehavior,v.overflow=n.style.overflow,v.overscrollBehavior=n.style.overscrollBehavior,v.position=n.style.position,v.top=n.style.top,v.left=n.style.left,v.right=n.style.right,v.width=n.style.width,s.style.overflow="hidden",s.style.overscrollBehavior="none",n.style.overflow="hidden",n.style.overscrollBehavior="none",n.style.position="fixed",n.style.top=`-${z}px`,n.style.left="0",n.style.right="0",n.style.width="100%",R=!0},F=()=>{if(!R)return;let e=r.documentElement,s=r.body;e.style.overflow=I.overflow,e.style.overscrollBehavior=I.overscrollBehavior,s.style.overflow=v.overflow,s.style.overscrollBehavior=v.overscrollBehavior,s.style.position=v.position,s.style.top=v.top,s.style.left=v.left,s.style.right=v.right,s.style.width=v.width,window.scrollTo(0,z),R=!1},ge=()=>{let e=fe();i.style.display==="none"&&(i.style.display=""),e?(i.style.width="100vw",i.style.height="100dvh",i.style.left="0",i.style.top="0",i.style.bottom="0",i.style.right="0",pe()):(i.style.width="420px",i.style.height="620px",i.style.bottom="24px",i.style.right="24px",i.style.left="",i.style.top="",F()),i.style.opacity="1",i.style.pointerEvents="auto"},C=()=>{c&&(c.remove(),c=null)},J=()=>{},ee=()=>{},D=!1,P=new Map;function te(e,s){let n=P.get(e);if(n)for(let f of n)try{f(s)}catch{}}let ye=e=>{if(e.origin===g){if(e.data?.type==="bitpalm-widget-config"){S=!1,$=!0,i.style.display==="none"&&(i.style.display=""),e.data.primaryColor&&(u.style.background=e.data.primaryColor,u.style.boxShadow=e.data.chatShadow==="none"?"none":`0 0 15px ${e.data.primaryColor}50`);let s=e.data.chatButtonIconColor||"black";if(e.data.chatButtonIconSvg){u.innerHTML="";let n=r.createElement("span");n.style.cssText=`display:flex;align-items:center;justify-content:center;width:24px;height:24px;color:${s}`;let b=new DOMParser().parseFromString(e.data.chatButtonIconSvg,"image/svg+xml").querySelector("svg");b?(b.querySelectorAll("script,foreignObject").forEach(B=>B.remove()),b.querySelectorAll("*").forEach(B=>{for(let k of[...B.attributes])(k.name.startsWith("on")||k.value&&k.value.includes("javascript:"))&&B.removeAttribute(k.name)}),b.setAttribute("width","24"),b.setAttribute("height","24"),b.style.display="block",n.appendChild(b)):n.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/></svg>',u.appendChild(n)}else{let n=u.querySelector("svg");n&&(n.style.stroke=s)}u.style.display="flex",requestAnimationFrame(()=>{u.style.opacity="1"})}if(e.data?.type==="bitpalm-widget-resize"){let s=e.data.width>0,n=D;D=s,s&&!n&&te("widget_opened"),!s&&n&&te("widget_closed");let f=fe();s?(i.style.width=f?"100vw":`${e.data.width}px`,i.style.height=f?"100dvh":`${e.data.height}px`,f?(i.style.left="0",i.style.top="0",i.style.bottom="0",i.style.right="0",pe()):F(),i.style.opacity="1",i.style.pointerEvents="auto"):(F(),i.style.width="1px",i.style.height="1px",i.style.left="",i.style.top="",i.style.opacity="0",i.style.pointerEvents="none"),u.style.display=s?"none":"flex"}if(e.data?.type==="bitpalm-trigger-show"){if(S||!$)return;C(),c=r.createElement("div"),c.style.cssText=`position:fixed;bottom:90px;right:24px;max-width:240px;background:#fff;border-radius:16px;padding:12px 32px 12px 12px;box-shadow:0 2px 20px rgba(0,0,0,0.08);cursor:pointer;z-index:${w-1};font-family:system-ui,sans-serif;animation:_bp_fade .3s;`;let s=(e.data.message||"").replace(/</g,"<");c.innerHTML=`<p style="font-size:14px;color:#1f2937;margin:0;">${s}</p><div style="position:absolute;bottom:-8px;right:20px;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid #fff;"></div>`;let n=r.createElement("button");n.style.cssText="position:absolute;top:-8px;right:-8px;width:28px;height:28px;border-radius:50%;background:#fff;border:none;box-shadow:0 1px 4px rgba(0,0,0,0.1);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:#9ca3af;",n.innerHTML="✕",n.onclick=f=>{f.stopPropagation(),C(),i.contentWindow?.postMessage({type:"bitpalm-trigger-dismiss"},"*")},c.onclick=()=>{if(C(),u.style.display="none",ge(),N(),!O){H=!0;return}i.contentWindow?.postMessage({type:"bitpalm-trigger-engaged",message:s},"*")},c.appendChild(n),r.body.appendChild(c)}e.data?.type==="bitpalm-trigger-hide"&&C(),e.data?.type==="bitpalm-request-context"&&J(),e.data?.type==="bitpalm-chat-event"&&e.data.event&&te(e.data.event,e.data.data),e.data?.type==="bitpalm-widget-blocked"&&(S=!0,$=!1,u.style.display="none",C(),F(),i.style.display="none")}};window.addEventListener("message",ye);let L=!1;try{L=localStorage.getItem(`${h}optout`)==="1"}catch{}let G=`${h}vid`,E="";if(!L){try{E=localStorage.getItem(G)||""}catch{}if(!E){let e=r.cookie.match(new RegExp(`(?:^|; )${G}=([^;]+)`));E=e?decodeURIComponent(e[1]):""}E||(E=crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,11)}`);try{localStorage.setItem(G,E)}catch{}try{r.cookie=`${G}=${encodeURIComponent(E)};path=/;max-age=31536000;SameSite=Lax`}catch{}}L||ue(()=>{try{let e=new URLSearchParams(location.search),s={};for(let T of["utm_source","utm_medium","utm_campaign","utm_term","utm_content"]){let b=e.get(T);b&&(s[T]=b)}let n=JSON.stringify({tenant_slug:o,visitor_id:E,url:location.href,referrer:r.referrer||void 0,...Object.keys(s).length>0?{utm:s}:{}}),f=`${a}/api/widget/impression`;typeof navigator.sendBeacon=="function"?navigator.sendBeacon(f,new Blob([n],{type:"application/json"})):fetch(f,{method:"POST",body:n,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}catch{}},2e3);let ne="",oe="",ie=0;try{ne=sessionStorage.getItem(Ne)||"",oe=sessionStorage.getItem(Re)||"";let e=parseInt(sessionStorage.getItem(Fe)||"0",10);Number.isFinite(e)&&e>0&&(ie=e)}catch{}let he=(e,s="")=>{if(L||!E)return;let n={},f=d(e.name,140),T=De(e.email),b=_(e.phone),B=d(e.company,160),k=d(e.external_user_id,140),ke=d(e.signature,260),le=Number(e.signed_at);if(f&&(n.name=f),T&&(n.email=T),b&&(n.phone=b),B&&(n.company=B),k&&(n.external_user_id=k),ke&&(n.signature=ke),Number.isFinite(le)&&le>0&&(n.signed_at=Math.floor(le)),(e.signature_version==="v1"||n.signature)&&(n.signature_version="v1"),(e.identify_source==="manual"||e.identify_source==="form")&&(n.identify_source=e.identify_source),!n.name&&!n.email&&!n.phone&&!n.company&&!n.external_user_id)return;let Z=et(n),ce=[s.toLowerCase(),Z].filter(Boolean).join("|"),de=Date.now();if(!(de-ie<Qe&&(ce===ne||Z===oe))){ne=ce,oe=Z,ie=de;try{sessionStorage.setItem(Ne,ce),sessionStorage.setItem(Re,Z),sessionStorage.setItem(Fe,String(de))}catch{}try{let $e=JSON.stringify({tenant_slug:o,visitor_id:E,url:location.href,referrer:r.referrer||void 0,...n}),Oe=`${a}/api/widget/identify`;typeof navigator.sendBeacon=="function"?navigator.sendBeacon(Oe,new Blob([$e],{type:"application/json"})):fetch(Oe,{method:"POST",body:$e,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}catch{}}},be=e=>{if(L||!y||!E)return;let s=e.target instanceof HTMLFormElement?e.target:e.target instanceof Element?e.target.closest("form"):null;if(!(s instanceof HTMLFormElement))return;let n=(s.getAttribute("data-bp-identify")||s.getAttribute("data-bitpalm-identify")||"").toLowerCase();if(n==="off"||n==="false"||n==="0")return;let f=st(s);if(!f)return;let T=[s.getAttribute("id")||"",s.getAttribute("name")||"",s.getAttribute("action")||""].join("|");he({...f,identify_source:"form"},T)};!L&&y&&r.addEventListener("submit",be,!0);let q=parseInt(sessionStorage.getItem(`${h}pages`)||"0")+1;sessionStorage.setItem(`${h}pages`,String(q));let M=JSON.parse(sessionStorage.getItem(`${h}hist`)||"[]");M.push(location.href),M.length>20&&(M=M.slice(-20)),sessionStorage.setItem(`${h}hist`,JSON.stringify(M));let we=Date.now(),V=parseInt(sessionStorage.getItem(`${h}site_start`)||"0");V||(V=we,sessionStorage.setItem(`${h}site_start`,String(V)));let ve=[];J=()=>{let e=!1;try{e=!!localStorage.getItem(`${h}visited`)}catch{e=!1}if(i.contentWindow?.postMessage({type:"bitpalm-parent-context",url:location.href,title:r.title,returning:e,pageCount:q,pageHistory:M,loadedAt:we,siteStart:V,locale:m,visitorId:L?"":E},"*"),!e&&!L)try{localStorage.setItem(`${h}visited`,"1")}catch{}},i.addEventListener("load",()=>{O=!0,J(),[120,450,1100].forEach(e=>{let s=setTimeout(()=>J(),e);ve.push(s)}),H&&(H=!1,ee())}),r.readyState==="loading"?r.addEventListener("DOMContentLoaded",()=>ue(N,1600),{once:!0}):ue(N,1600);let xe=history.pushState.bind(history),Ee=history.replaceState.bind(history),K=()=>{q++,sessionStorage.setItem(`${h}pages`,String(q));let e=JSON.parse(sessionStorage.getItem(`${h}hist`)||"[]");if(e.push(location.href),e.length>20&&e.splice(0,e.length-20),M=e,sessionStorage.setItem(`${h}hist`,JSON.stringify(e)),i.contentWindow?.postMessage({type:"bitpalm-page-change",url:location.href,title:r.title,pageCount:q,pageHistory:e,loadedAt:Date.now()},"*"),!L)try{let s=JSON.stringify({tenant_slug:o,visitor_id:E,url:location.href}),n=`${a}/api/widget/impression`;typeof navigator.sendBeacon=="function"?navigator.sendBeacon(n,new Blob([s],{type:"application/json"})):fetch(n,{method:"POST",body:s,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}catch{}};history.pushState=function(...e){xe(...e),K()},history.replaceState=function(...e){Ee(...e),K()},window.addEventListener("popstate",K);let Se=-1,se,Ie=()=>{clearTimeout(se),se=setTimeout(()=>{let e=Math.max(r.documentElement.scrollHeight,r.body.scrollHeight)-window.innerHeight,s=e>0?Math.round(window.scrollY/e*100):100;s!==Se&&(Se=s,i.contentWindow?.postMessage({type:"bitpalm-scroll-depth",percent:s},"*"))},500)};window.addEventListener("scroll",Ie,{passive:!0});let Le=e=>{e.clientY<=0&&i.contentWindow?.postMessage({type:"bitpalm-exit-intent"},"*")};r.addEventListener("mouseout",Le);let ae,Te=!1,re=()=>{clearTimeout(ae),!Te&&(ae=setTimeout(()=>{Te=!0,i.contentWindow?.postMessage({type:"bitpalm-inactivity"},"*")},15e3))},_e=["mousemove","keydown","scroll","touchstart"];_e.forEach(e=>r.addEventListener(e,re,{passive:!0})),re(),ee=()=>{i.contentWindow?.postMessage({type:"bitpalm-open"},"*");let e=i.src.split("#")[0];i.src=`${e}#bp-open-${Date.now()}`};let X=()=>{if(u.style.display="none",C(),ge(),N(),!O){H=!0;return}ee()},Ae=()=>{F(),i.contentWindow?.postMessage({type:"bitpalm-close"},"*")},Ce=e=>{!e||typeof e!="object"||he({external_user_id:d(e.externalUserId,140)||void 0,name:d(e.name,140)||void 0,email:De(e.email)||void 0,phone:_(e.phone)||void 0,company:d(e.company,160)||void 0,signature:d(e.signature,260)||void 0,signed_at:Number.isFinite(Number(e.signedAt))?Math.floor(Number(e.signedAt)):void 0,signature_version:e.signatureVersion==="v1"?"v1":void 0,identify_source:"manual"},"manual")},We=()=>{D?Ae():X()},Ue=()=>D,je=e=>{if(!e||typeof e!="string")return;let s=e.trim().slice(0,1e4);s&&(D||X(),setTimeout(()=>{i.contentWindow?.postMessage({type:"bitpalm-send-message",message:s},"*")},D?50:500))},Y={},Pe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;Y={...Y,...e};let s=JSON.stringify(Y);s.length>He&&console.warn(`[BitPalm] Custom context exceeds ${He} bytes (${s.length}). It may be truncated.`),i.contentWindow?.postMessage({type:"bitpalm-custom-context",data:Y},"*")},ze=()=>{Y={},i.contentWindow?.postMessage({type:"bitpalm-custom-context",data:{}},"*")},Me=e=>{let n=e.detail;if(!n||typeof n!="object")return;let f=d(n.slug,120);if(f&&f!==o)return;let{slug:T,...b}=n;Pe(b)};window.addEventListener("bitpalm-context",Me);let Be=e=>{let n=e.detail;if(!n||typeof n!="object")return;let f=d(n.slug,120);f&&f!==o||Ce(n)};return window.addEventListener("bitpalm-identify",Be),{open:X,close:Ae,toggle:We,isOpen:Ue,identify:Ce,context:Pe,resetContext:ze,send:je,on:(e,s)=>(P.has(e)||P.set(e,new Set),P.get(e).add(s),()=>P.get(e)?.delete(s)),off:(e,s)=>{P.get(e)?.delete(s)},destroy:()=>{window.removeEventListener("message",ye),window.removeEventListener("scroll",Ie),window.removeEventListener("popstate",K),r.removeEventListener("mouseout",Le),r.removeEventListener("submit",be,!0),_e.forEach(e=>r.removeEventListener(e,re)),clearTimeout(se),clearTimeout(ae),ve.forEach(e=>clearTimeout(e)),history.pushState=xe,history.replaceState=Ee,window.removeEventListener("bitpalm-identify",Be),window.removeEventListener("bitpalm-context",Me),P.clear(),F(),C(),u.remove(),i.remove()}}}function rt(t){if(t==null)return;let o=t.trim().toLowerCase();if(["1","true","yes","on"].includes(o))return!0;if(["0","false","no","off"].includes(o))return!1}if(typeof document<"u"){let t=document.currentScript;if(t?.dataset.slug){let o=()=>{Q({slug:t.dataset.slug,locale:t.dataset.locale,baseUrl:t.dataset.baseUrl,token:t.dataset.token,zIndex:t.dataset.zIndex?Number(t.dataset.zIndex):void 0,autoIdentify:rt(t.dataset.autoIdentify)})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o):o()}}0&&(module.exports={createWidget});
|
|
1
|
+
"use strict";var Se=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var _t=(t,n)=>{for(var a in n)Se(t,a,{get:n[a],enumerable:!0})},At=(t,n,a,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let d of Lt(n))!It.call(t,d)&&d!==a&&Se(t,d,{get:()=>n[d],enumerable:!(r=St(n,d))||r.enumerable});return t};var Ct=t=>At(Se({},"__esModule",{value:!0}),t);var zt={};_t(zt,{createWidget:()=>le,detectHostTheme:()=>O});module.exports=Ct(zt);function ae(t){if(t===!1)return"off";if(typeof t=="string"){let n=t.trim().toLowerCase();if(["false","off","0","no","none"].includes(n))return"off";if(n==="events")return"events"}return"bubble"}function rt(t){return t==="off"?!1:t==="events"?"events":!0}function at(t,n){let a=t.createElement("div");a.setAttribute("data-bitpalm-trigger",""),a.style.cssText=`max-width:240px;background:#fff;border-radius:16px;padding:12px 32px 12px 12px;box-shadow:0 2px 20px rgba(0,0,0,0.08);cursor:pointer;z-index:${n.zIndex-1};font-family:system-ui,sans-serif;animation:_bp_fade .3s;`,a.style.position="fixed",a.style.right="24px",a.style.bottom=`${n.bottom}px`;let r=t.createElement("p");r.style.cssText="font-size:14px;color:#1f2937;margin:0;",r.textContent=n.message;let d=t.createElement("div");d.style.cssText="position:absolute;bottom:-8px;right:20px;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid #fff;";let u=t.createElement("button");return u.type="button",u.setAttribute("aria-label","Close"),u.style.cssText="position:absolute;top:-8px;right:-8px;width:28px;height:28px;border-radius:50%;background:#fff;border:none;box-shadow:0 1px 4px rgba(0,0,0,0.1);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:#9ca3af;",u.textContent="\u2715",u.onclick=g=>{g.stopPropagation(),n.onDismiss()},a.onclick=()=>n.onEngage(),a.append(r,d,u),a}var Mt=["dark","dark-mode","dark-theme","theme-dark"],kt=["light","light-mode","light-theme","theme-light"],dt=["data-theme","data-color-scheme","data-color-mode","data-mode","data-bs-theme"],mt="(prefers-color-scheme: dark)";function R(t){return t==="light"||t==="dark"?t:"auto"}function lt(t){if(!t)return null;if(Mt.some(n=>t.classList.contains(n)))return"dark";if(kt.some(n=>t.classList.contains(n)))return"light";for(let n of dt){let a=(t.getAttribute(n)||"").toLowerCase();if(a.includes("dark"))return"dark";if(a.includes("light"))return"light"}return null}function Le(t){let n=t/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4}function ct(t,n){if(!t)return null;let a=n.getComputedStyle(t).backgroundColor.match(/rgba?\(([^)]+)\)/);if(!a)return null;let[r,d,u,g=1]=a[1].split(/[\s,/]+/).filter(Boolean).map(Number);return[r,d,u,g].some(l=>Number.isNaN(l))||g<.5?null:.2126*Le(r)+.7152*Le(d)+.0722*Le(u)<.2?"dark":"light"}function Bt(t,n){let a=n.getComputedStyle(t.documentElement).colorScheme||"",r=t.querySelector('meta[name="color-scheme"]')?.getAttribute("content")||"",d=`${a} ${r}`.toLowerCase();return d.includes("dark")?d.includes("light")?n.matchMedia?.(mt).matches?"dark":"light":"dark":null}function O(t=document,n=window){return lt(t.documentElement)??lt(t.body)??ct(t.body,n)??ct(t.documentElement,n)??Bt(t,n)??"light"}function Ie(t,n=document,a=window){let r=O(n,a),d=!1,u=()=>{d=!1;let c=O(n,a);c!==r&&(r=c,t(c))},g=()=>{d||(d=!0,typeof a.requestAnimationFrame=="function"?a.requestAnimationFrame(u):setTimeout(u,16))},T=typeof MutationObserver<"u"?new MutationObserver(g):null,l={attributes:!0,attributeFilter:["class","style",...dt]};T?.observe(n.documentElement,l),n.body&&T?.observe(n.body,l);let h=typeof a.matchMedia=="function"?a.matchMedia(mt):null;return h?.addEventListener?.("change",g),()=>{T?.disconnect(),h?.removeEventListener?.("change",g)}}var Pt="https://agents.bitpalm.ai",v="_bp_",Ht=new Set(["password","file","checkbox","radio","submit","button","reset","image"]),$t=8e3,ut=4096,ft=`${v}identify_signature`,gt=`${v}identify_fingerprint`,pt=`${v}identify_sent_at`,ht="0 4px 14px rgba(0,0,0,0.18)";function Ot(t){return[t.external_user_id||"",t.email||"",t.phone||"",t.name||"",t.company||"",t.signature||"",t.signed_at!=null?String(t.signed_at):"",t.signature_version||"",t.identify_source||""].join("|").toLowerCase()}function m(t,n=180){return t?t.replace(/\s+/g," ").trim().slice(0,n):""}function Dt(t){return t?` ${t.toLowerCase().replace(/[_-]+/g," ").replace(/[^a-z0-9\s@.]/g," ").replace(/\s+/g," ").trim()} `:""}function F(t,n){for(let a of n)if(t.includes(a))return!0;return!1}function M(t){return/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/i.test(t)}function _(t){let n=m(t,50);if(!n)return"";let a=n.startsWith("+"),r=n.replace(/\D/g,"");return r.length<6?"":`${a?"+":""}${r.slice(0,20)}`}function yt(t){let n=m(t,140).toLowerCase();return!n||!M(n)?"":n}function U(t,n){for(let a of n){let r=t.querySelector(a),d=m(r?.value);if(d)return d}return""}function Nt(t){return m(t.getAttribute("data-bp-field")||t.getAttribute("data-bitpalm-field"),64).toLowerCase().replace(/[_\s]+/g,"-")}function Wt(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function Rt(t,n){let a=[],r=(l,h=140)=>{let c=m(l,h);c&&a.push(c)};r(n.name),r(n.id),r(n.getAttribute("autocomplete")),r(n.getAttribute("placeholder")),r(n.getAttribute("aria-label")),r(n.getAttribute("data-field")),r(n.getAttribute("data-name")),r(n.getAttribute("data-label")),r(n.getAttribute("data-bp-field")),r(n.getAttribute("data-bitpalm-field"));let d=new Set,u=l=>{let h=m(l,200);!h||d.has(h)||(d.add(h),a.push(h))};for(let l of Array.from(n.labels||[]))u(l.textContent);if(n.id){let l=t.querySelector(`label[for="${Wt(n.id)}"]`);u(l?.textContent)}let g=n.closest("label");u(g?.textContent);let T=n.getAttribute("aria-labelledby");if(T)for(let l of T.split(/\s+/)){if(!l)continue;let h=t.ownerDocument.getElementById(l);u(h?.textContent)}return a}function Ft(t){let n=m(U(t,["[data-bp-email]","[data-bitpalm-email]"]),140).toLowerCase(),a=_(U(t,["[data-bp-phone]","[data-bitpalm-phone]"])),r=m(U(t,["[data-bp-name]","[data-bitpalm-name]","[data-bp-full-name]","[data-bitpalm-full-name]"])),d=m(U(t,["[data-bp-first-name]","[data-bitpalm-first-name]"])),u=m(U(t,["[data-bp-last-name]","[data-bitpalm-last-name]"])),g=m(U(t,["[data-bp-company]","[data-bitpalm-company]"]));for(let c of Array.from(t.elements)){if(!(c instanceof HTMLInputElement||c instanceof HTMLTextAreaElement||c instanceof HTMLSelectElement)||c.disabled||c instanceof HTMLInputElement&&Ht.has(c.type.toLowerCase()))continue;let y=Nt(c),z=c.hasAttribute("data-bp-email")||c.hasAttribute("data-bitpalm-email")||c.hasAttribute("data-bp-phone")||c.hasAttribute("data-bitpalm-phone")||c.hasAttribute("data-bp-name")||c.hasAttribute("data-bitpalm-name")||c.hasAttribute("data-bp-full-name")||c.hasAttribute("data-bitpalm-full-name")||c.hasAttribute("data-bp-first-name")||c.hasAttribute("data-bitpalm-first-name")||c.hasAttribute("data-bp-last-name")||c.hasAttribute("data-bitpalm-last-name")||c.hasAttribute("data-bp-company")||c.hasAttribute("data-bitpalm-company")||!!y;if(c instanceof HTMLInputElement&&c.type.toLowerCase()==="hidden"&&!z)continue;let f=m(c.value);if(!f)continue;let A=c instanceof HTMLInputElement?c.type.toLowerCase():"",s=Dt(Rt(t,c).join(" "));if(!n&&y==="email"&&M(f)){n=f.toLowerCase();continue}if(!a&&(y==="phone"||y==="tel"||y==="mobile"||y==="whatsapp")){let S=_(f);if(S){a=S;continue}}if(!g&&y==="company"){g=m(f,160);continue}if(!d&&(y==="first-name"||y==="firstname")){d=m(f,100);continue}if(!u&&(y==="last-name"||y==="lastname"||y==="surname")){u=m(f,100);continue}if(!r&&(y==="name"||y==="full-name"||y==="fullname")){!M(f)&&!_(f)&&(r=m(f,140));continue}let K=A==="email"||F(s,[" email "," e mail "," mail "," email adresse "," mailadresse "," correo "]),D=A==="tel"||F(s,[" phone "," phone number "," mobile "," tel "," telefon "," telefonnummer "," whatsapp "," handy "," kontakt "," nummer "]),ce=F(s,[" company "," company name "," firma "," firmenname "," organization "," organisation "," business "," unternehmen "," agency "," brokerage "]),p=F(s,[" first name "," firstname "," given name "," givenname "," vorname "," fname "]),k=F(s,[" last name "," lastname "," family name "," familyname "," surname "," nachname "," lname "]),j=F(s,[" full name "," fullname "," contact name "," name "])&&!K&&!D;if(!n&&K&&M(f)){n=f.toLowerCase();continue}if(!a&&D){let S=_(f);if(S){a=S;continue}}if(!g&&ce){g=m(f,160);continue}if(!d&&p){d=m(f,100);continue}if(!u&&k){u=m(f,100);continue}if(!r&&j&&!M(f)&&!_(f)){r=m(f,140);continue}!n&&M(f)&&(n=f.toLowerCase())}if(r&&(M(r)||_(r))&&(r=""),g&&(M(g)||_(g))&&(g=""),r||(r=m([d,u].filter(Boolean).join(" "),140)),r&&n&&r.toLowerCase()===n.toLowerCase()&&(r=""),!!!(n||a)&&!!!(r&&g))return null;let h={...r?{name:r}:{},...n?{email:n}:{},...a?{phone:a}:{},...g?{company:g}:{}};return Object.keys(h).length>0?h:null}function Ut(){if(typeof document<"u"){let t=document.documentElement.lang;if(t)return t.slice(0,2).toLowerCase()}return"en"}function _e(t,n=1200){if(typeof window<"u"&&"requestIdleCallback"in window){window.requestIdleCallback(t,{timeout:n});return}setTimeout(t,Math.min(n,300))}function Ae(){if(typeof window>"u")return!1;let t=typeof navigator<"u"?navigator.userAgent:"";if(/Android|iPhone|iPad|iPod|IEMobile|Windows Phone|Mobile/i.test(t))return!0;let a=window.matchMedia("(pointer: coarse)").matches,r=window.matchMedia("(hover: none)").matches,d=Math.min(window.screen?.width||window.innerWidth,window.screen?.height||window.innerHeight);return a&&r&&d<=900}function le(t){let{slug:n,locale:a=Ut(),baseUrl:r=Pt,token:d,zIndex:u=9999,autoIdentify:g=!0,launcher:T=!0}=t,l=document,h=R(t.theme),c=h==="auto"?O():h,y=null,z=ae(t.triggers),f=z,A=null,s=l.createElement("iframe");s.setAttribute("data-bitpalm-chat","");let K=`${r}/t/${n}/widget`,D=new URLSearchParams({locale:a,theme:c});d&&D.set("token",d),f==="off"&&D.set("triggers","off"),s.src=`${K}?${D.toString()}`,s.allow="clipboard-write; microphone",s.setAttribute("allowtransparency","true"),s.loading="lazy",s.style.cssText=`position:fixed;bottom:0;right:0;width:1px;height:1px;border:none;z-index:${u};background:transparent;color-scheme:normal;opacity:0;pointer-events:none;`;let ce=new URL(s.src).origin,p=l.createElement("div");if(p.setAttribute("role","button"),p.setAttribute("aria-label","Chat"),p.setAttribute("data-bitpalm-launcher",""),p.style.cssText=`position:fixed;bottom:24px;right:24px;width:56px;height:56px;border-radius:50%;display:none;align-items:center;justify-content:center;cursor:pointer;z-index:${u-1};background:#171717;box-shadow:${ht};transition:transform .2s,opacity .3s;opacity:0;`,p.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/></svg>',p.onmouseenter=()=>{p.style.transform="scale(1.05)"},p.onmouseleave=()=>{p.style.transform="scale(1)"},p.onclick=()=>J(),T&&l.body.appendChild(p),!l.getElementById("_bp_fade")){let e=l.createElement("style");e.id="_bp_fade",e.textContent="@keyframes _bp_fade{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}",l.head.appendChild(e)}let k=null,j=!1,S=!1,Ce=!1,de=!1,V=!1,X=()=>{Ce||(Ce=!0,l.body.appendChild(s))},Z=!1,me=0,Q={overflow:"",overscrollBehavior:""},E={overflow:"",overscrollBehavior:"",position:"",top:"",left:"",right:"",width:""},Me=()=>{if(Z||!Ae())return;let o=l.documentElement,i=l.body;me=window.scrollY||window.pageYOffset||0,Q.overflow=o.style.overflow,Q.overscrollBehavior=o.style.overscrollBehavior,E.overflow=i.style.overflow,E.overscrollBehavior=i.style.overscrollBehavior,E.position=i.style.position,E.top=i.style.top,E.left=i.style.left,E.right=i.style.right,E.width=i.style.width,o.style.overflow="hidden",o.style.overscrollBehavior="none",i.style.overflow="hidden",i.style.overscrollBehavior="none",i.style.position="fixed",i.style.top=`-${me}px`,i.style.left="0",i.style.right="0",i.style.width="100%",Z=!0},N=()=>{if(!Z)return;let e=l.documentElement,o=l.body;e.style.overflow=Q.overflow,e.style.overscrollBehavior=Q.overscrollBehavior,o.style.overflow=E.overflow,o.style.overscrollBehavior=E.overscrollBehavior,o.style.position=E.position,o.style.top=E.top,o.style.left=E.left,o.style.right=E.right,o.style.width=E.width,window.scrollTo(0,me),Z=!1},ke=()=>{let e=Ae();s.style.display==="none"&&(s.style.display=""),e?(s.style.width="100vw",s.style.height="100dvh",s.style.left="0",s.style.top="0",s.style.bottom="0",s.style.right="0",Me()):(s.style.width="420px",s.style.height="620px",s.style.bottom="24px",s.style.right="24px",s.style.left="",s.style.top="",N()),s.style.opacity="1",s.style.pointerEvents="auto"},C=()=>{k&&(k.remove(),k=null)},ee=()=>{A!==null&&(A=null,q("trigger_hidden"))},Be=()=>{s.contentWindow?.postMessage({type:"bitpalm-triggers",enabled:f!=="off"},"*")},te=()=>{},ue=()=>{},W=!1,B=new Map;function q(e,o){let i=B.get(e);if(i)for(let b of i)try{b(o)}catch{}}let Pe=e=>{if(e.origin===ce){if(e.data?.type==="bitpalm-widget-config"){S=!1,j=!0,s.style.display==="none"&&(s.style.display=""),e.data.primaryColor&&(p.style.background=e.data.primaryColor,p.style.boxShadow=e.data.chatShadow==="none"?"none":ht);let o=e.data.chatButtonIconColor||"black";if(e.data.chatButtonIconSvg){p.innerHTML="";let i=l.createElement("span");i.style.cssText=`display:flex;align-items:center;justify-content:center;width:24px;height:24px;color:${o}`;let w=new DOMParser().parseFromString(e.data.chatButtonIconSvg,"image/svg+xml").querySelector("svg");w?(w.querySelectorAll("script,foreignObject").forEach(H=>H.remove()),w.querySelectorAll("*").forEach(H=>{for(let $ of[...H.attributes])($.name.startsWith("on")||$.value&&$.value.includes("javascript:"))&&H.removeAttribute($.name)}),w.setAttribute("width","24"),w.setAttribute("height","24"),w.style.display="block",i.appendChild(w)):i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/></svg>',p.appendChild(i)}else{let i=p.querySelector("svg");i&&(i.style.stroke=o)}T&&(p.style.display="flex",requestAnimationFrame(()=>{p.style.opacity="1"})),Be()}if(e.data?.type==="bitpalm-widget-resize"){let o=e.data.width>0,i=W;W=o,o&&!i&&q("widget_opened"),!o&&i&&q("widget_closed");let b=Ae();o?(s.style.width=b?"100vw":`${e.data.width}px`,s.style.height=b?"100dvh":`${e.data.height}px`,b?(s.style.left="0",s.style.top="0",s.style.bottom="0",s.style.right="0",Me()):N(),s.style.opacity="1",s.style.pointerEvents="auto"):(N(),s.style.width="1px",s.style.height="1px",s.style.left="",s.style.top="",s.style.opacity="0",s.style.pointerEvents="none"),p.style.display=o||!T?"none":"flex"}if(e.data?.type==="bitpalm-trigger-show"){if(S||!j||f==="off")return;let o=typeof e.data.message=="string"?e.data.message:"";if(!o)return;if(f==="events"){A=o,q("trigger_shown",{message:o,triggerId:e.data.triggerId,triggerType:e.data.triggerType});return}C(),k=at(l,{message:o,zIndex:u,bottom:T?90:24,onDismiss:()=>{C(),s.contentWindow?.postMessage({type:"bitpalm-trigger-dismiss"},"*")},onEngage:()=>{if(C(),p.style.display="none",ke(),X(),!de){V=!0;return}s.contentWindow?.postMessage({type:"bitpalm-trigger-engaged",message:o},"*")}}),l.body.appendChild(k)}e.data?.type==="bitpalm-trigger-hide"&&(C(),ee()),e.data?.type==="bitpalm-request-context"&&te(),e.data?.type==="bitpalm-chat-event"&&e.data.event&&q(e.data.event,e.data.data),e.data?.type==="bitpalm-widget-blocked"&&(S=!0,j=!1,p.style.display="none",C(),ee(),N(),s.style.display="none")}};window.addEventListener("message",Pe);let L=!1;try{L=localStorage.getItem(`${v}optout`)==="1"}catch{}let ne=`${v}vid`,x="";if(!L){try{x=localStorage.getItem(ne)||""}catch{}if(!x){let e=l.cookie.match(new RegExp(`(?:^|; )${ne}=([^;]+)`));x=e?decodeURIComponent(e[1]):""}x||(x=crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,11)}`);try{localStorage.setItem(ne,x)}catch{}try{l.cookie=`${ne}=${encodeURIComponent(x)};path=/;max-age=31536000;SameSite=Lax`}catch{}}L||_e(()=>{try{let e=new URLSearchParams(location.search),o={};for(let I of["utm_source","utm_medium","utm_campaign","utm_term","utm_content"]){let w=e.get(I);w&&(o[I]=w)}let i=JSON.stringify({tenant_slug:n,visitor_id:x,url:location.href,referrer:l.referrer||void 0,...Object.keys(o).length>0?{utm:o}:{}}),b=`${r}/api/widget/impression`;typeof navigator.sendBeacon=="function"?navigator.sendBeacon(b,new Blob([i],{type:"application/json"})):fetch(b,{method:"POST",body:i,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}catch{}},2e3);let fe="",ge="",pe=0;try{fe=sessionStorage.getItem(ft)||"",ge=sessionStorage.getItem(gt)||"";let e=parseInt(sessionStorage.getItem(pt)||"0",10);Number.isFinite(e)&&e>0&&(pe=e)}catch{}let He=(e,o="")=>{if(L||!x)return;let i={},b=m(e.name,140),I=yt(e.email),w=_(e.phone),H=m(e.company,160),$=m(e.external_user_id,140),ot=m(e.signature,260),Ee=Number(e.signed_at);if(b&&(i.name=b),I&&(i.email=I),w&&(i.phone=w),H&&(i.company=H),$&&(i.external_user_id=$),ot&&(i.signature=ot),Number.isFinite(Ee)&&Ee>0&&(i.signed_at=Math.floor(Ee)),(e.signature_version==="v1"||i.signature)&&(i.signature_version="v1"),(e.identify_source==="manual"||e.identify_source==="form")&&(i.identify_source=e.identify_source),!i.name&&!i.email&&!i.phone&&!i.company&&!i.external_user_id)return;let re=Ot(i),Te=[o.toLowerCase(),re].filter(Boolean).join("|"),xe=Date.now();if(!(xe-pe<$t&&(Te===fe||re===ge))){fe=Te,ge=re,pe=xe;try{sessionStorage.setItem(ft,Te),sessionStorage.setItem(gt,re),sessionStorage.setItem(pt,String(xe))}catch{}try{let it=JSON.stringify({tenant_slug:n,visitor_id:x,url:location.href,referrer:l.referrer||void 0,...i}),st=`${r}/api/widget/identify`;typeof navigator.sendBeacon=="function"?navigator.sendBeacon(st,new Blob([it],{type:"application/json"})):fetch(st,{method:"POST",body:it,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}catch{}}},$e=e=>{if(L||!g||!x)return;let o=e.target instanceof HTMLFormElement?e.target:e.target instanceof Element?e.target.closest("form"):null;if(!(o instanceof HTMLFormElement))return;let i=(o.getAttribute("data-bp-identify")||o.getAttribute("data-bitpalm-identify")||"").toLowerCase();if(i==="off"||i==="false"||i==="0")return;let b=Ft(o);if(!b)return;let I=[o.getAttribute("id")||"",o.getAttribute("name")||"",o.getAttribute("action")||""].join("|");He({...b,identify_source:"form"},I)};!L&&g&&l.addEventListener("submit",$e,!0);let Y=parseInt(sessionStorage.getItem(`${v}pages`)||"0")+1;sessionStorage.setItem(`${v}pages`,String(Y));let P=JSON.parse(sessionStorage.getItem(`${v}hist`)||"[]");P.push(location.href),P.length>20&&(P=P.slice(-20)),sessionStorage.setItem(`${v}hist`,JSON.stringify(P));let Oe=Date.now(),oe=parseInt(sessionStorage.getItem(`${v}site_start`)||"0");oe||(oe=Oe,sessionStorage.setItem(`${v}site_start`,String(oe)));let De=[];te=()=>{let e=!1;try{e=!!localStorage.getItem(`${v}visited`)}catch{e=!1}if(s.contentWindow?.postMessage({type:"bitpalm-parent-context",url:location.href,title:l.title,returning:e,pageCount:Y,pageHistory:P,loadedAt:Oe,siteStart:oe,locale:a,visitorId:L?"":x},"*"),Ge(),!e&&!L)try{localStorage.setItem(`${v}visited`,"1")}catch{}},s.addEventListener("load",()=>{de=!0,te(),[120,450,1100].forEach(e=>{let o=setTimeout(()=>te(),e);De.push(o)}),V&&(V=!1,ue())}),l.readyState==="loading"?l.addEventListener("DOMContentLoaded",()=>_e(X,1600),{once:!0}):_e(X,1600);let Ne=history.pushState.bind(history),We=history.replaceState.bind(history),ie=()=>{Y++,sessionStorage.setItem(`${v}pages`,String(Y));let e=JSON.parse(sessionStorage.getItem(`${v}hist`)||"[]");if(e.push(location.href),e.length>20&&e.splice(0,e.length-20),P=e,sessionStorage.setItem(`${v}hist`,JSON.stringify(e)),s.contentWindow?.postMessage({type:"bitpalm-page-change",url:location.href,title:l.title,pageCount:Y,pageHistory:e,loadedAt:Date.now()},"*"),!L)try{let o=JSON.stringify({tenant_slug:n,visitor_id:x,url:location.href}),i=`${r}/api/widget/impression`;typeof navigator.sendBeacon=="function"?navigator.sendBeacon(i,new Blob([o],{type:"application/json"})):fetch(i,{method:"POST",body:o,headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}catch{}};history.pushState=function(...e){Ne(...e),ie()},history.replaceState=function(...e){We(...e),ie()},window.addEventListener("popstate",ie);let Re=-1,he,Fe=()=>{clearTimeout(he),he=setTimeout(()=>{let e=Math.max(l.documentElement.scrollHeight,l.body.scrollHeight)-window.innerHeight,o=e>0?Math.round(window.scrollY/e*100):100;o!==Re&&(Re=o,s.contentWindow?.postMessage({type:"bitpalm-scroll-depth",percent:o},"*"))},500)};window.addEventListener("scroll",Fe,{passive:!0});let Ue=e=>{e.clientY<=0&&s.contentWindow?.postMessage({type:"bitpalm-exit-intent"},"*")};l.addEventListener("mouseout",Ue);let ye,ze=!1,be=()=>{clearTimeout(ye),!ze&&(ye=setTimeout(()=>{ze=!0,s.contentWindow?.postMessage({type:"bitpalm-inactivity"},"*")},15e3))},je=["mousemove","keydown","scroll","touchstart"];je.forEach(e=>l.addEventListener(e,be,{passive:!0})),be(),ue=()=>{s.contentWindow?.postMessage({type:"bitpalm-open"},"*");let e=s.src.split("#")[0];s.src=`${e}#bp-open-${Date.now()}`};let J=()=>{if(p.style.display="none",C(),ke(),X(),!de){V=!0;return}if(A!==null){let e=A;ee(),s.contentWindow?.postMessage({type:"bitpalm-trigger-engaged",message:e},"*");return}ue()},qe=e=>{f=e,e==="off"&&(C(),ee()),Be()},vt=()=>qe("off"),wt=()=>qe(z==="off"?"bubble":z),ve=()=>{N(),s.contentWindow?.postMessage({type:"bitpalm-close"},"*")},Ye=e=>{!e||typeof e!="object"||He({external_user_id:m(e.externalUserId,140)||void 0,name:m(e.name,140)||void 0,email:yt(e.email)||void 0,phone:_(e.phone)||void 0,company:m(e.company,160)||void 0,signature:m(e.signature,260)||void 0,signed_at:Number.isFinite(Number(e.signedAt))?Math.floor(Number(e.signedAt)):void 0,signature_version:e.signatureVersion==="v1"?"v1":void 0,identify_source:"manual"},"manual")},Et=()=>{W?ve():J()},Tt=()=>W,Je=e=>{if(!e||typeof e!="string")return;let o=e.trim().slice(0,1e4);o&&(W||J(),setTimeout(()=>{s.contentWindow?.postMessage({type:"bitpalm-send-message",message:o},"*")},W?50:500))};function Ge(){s.contentWindow?.postMessage({type:"bitpalm-theme",theme:c},"*")}let se=e=>{e!==c&&(c=e,Ge())},Ke=e=>{h=R(e),y?.(),y=null,h==="auto"?(y=Ie(se),se(O())):se(h)};h==="auto"&&(y=Ie(se));let Ve=e=>{let o=e.detail;if(!o||typeof o!="object")return;let i=m(o.slug,120);i&&i!==n||Ke(R(o.theme))};window.addEventListener("bitpalm-theme",Ve);let G={},Xe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;G={...G,...e};let o=JSON.stringify(G);o.length>ut&&console.warn(`[BitPalm] Custom context exceeds ${ut} bytes (${o.length}). It may be truncated.`),s.contentWindow?.postMessage({type:"bitpalm-custom-context",data:G},"*")},xt=()=>{G={},s.contentWindow?.postMessage({type:"bitpalm-custom-context",data:{}},"*")},Ze=e=>{let i=e.detail;if(!i||typeof i!="object")return;let b=m(i.slug,120);if(b&&b!==n)return;let{slug:I,...w}=i;Xe(w)};window.addEventListener("bitpalm-context",Ze);let Qe=e=>{let i=e.detail;if(!i||typeof i!="object")return;let b=m(i.slug,120);b&&b!==n||Ye(i)};window.addEventListener("bitpalm-identify",Qe);let we=e=>{let o=e.detail,i=m(o?.slug,120);return!i||i===n},et=e=>{we(e)&&J()},tt=e=>{we(e)&&ve()},nt=e=>{if(!we(e))return;let o=e.detail?.message;typeof o=="string"&&Je(o)};return window.addEventListener("bitpalm-open",et),window.addEventListener("bitpalm-close",tt),window.addEventListener("bitpalm-send",nt),{open:J,close:ve,toggle:Et,isOpen:Tt,identify:Ye,context:Xe,resetContext:xt,send:Je,on:(e,o)=>(B.has(e)||B.set(e,new Set),B.get(e).add(o),()=>B.get(e)?.delete(o)),off:(e,o)=>{B.get(e)?.delete(o)},setTheme:Ke,disableTriggers:vt,enableTriggers:wt,destroy:()=>{window.removeEventListener("message",Pe),window.removeEventListener("scroll",Fe),window.removeEventListener("popstate",ie),l.removeEventListener("mouseout",Ue),l.removeEventListener("submit",$e,!0),je.forEach(e=>l.removeEventListener(e,be)),clearTimeout(he),clearTimeout(ye),De.forEach(e=>clearTimeout(e)),history.pushState=Ne,history.replaceState=We,window.removeEventListener("bitpalm-identify",Qe),window.removeEventListener("bitpalm-context",Ze),window.removeEventListener("bitpalm-theme",Ve),window.removeEventListener("bitpalm-open",et),window.removeEventListener("bitpalm-close",tt),window.removeEventListener("bitpalm-send",nt),y?.(),B.clear(),N(),C(),p.remove(),s.remove()}}}function bt(t){if(t==null)return;let n=t.trim().toLowerCase();if(["1","true","yes","on"].includes(n))return!0;if(["0","false","no","off"].includes(n))return!1}if(typeof document<"u"){let t=document.currentScript;if(t?.dataset.slug){let n=()=>{le({slug:t.dataset.slug,locale:t.dataset.locale,baseUrl:t.dataset.baseUrl,token:t.dataset.token,zIndex:t.dataset.zIndex?Number(t.dataset.zIndex):void 0,autoIdentify:bt(t.dataset.autoIdentify),theme:R(t.dataset.theme),launcher:bt(t.dataset.launcher),triggers:t.dataset.triggers===void 0?void 0:rt(ae(t.dataset.triggers))})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n):n()}}0&&(module.exports={createWidget,detectHostTheme});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|