@kilichat/vue 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +91 -2
- package/dist/KiliChat.vue.d.ts +4 -0
- package/dist/KiliChatBootstrap.vue.d.ts +3 -0
- package/dist/components/ui/Button.vue.d.ts +20 -0
- package/dist/components/ui/Textarea.vue.d.ts +12 -0
- package/dist/components/ui/button.d.ts +19 -0
- package/dist/components/ui/slot.d.ts +9 -0
- package/dist/components/widget/ChatHome.vue.d.ts +13 -0
- package/dist/components/widget/ChatThread.vue.d.ts +21 -0
- package/dist/components/widget/ChatWidget.vue.d.ts +3 -0
- package/dist/components/widget/InitialsAvatar.vue.d.ts +13 -0
- package/dist/composables/use-mobile.d.ts +2 -0
- package/dist/context/AppStateProvider.vue.d.ts +15 -0
- package/dist/context/SocketProvider.vue.d.ts +15 -0
- package/dist/context/socket.d.ts +5 -0
- package/dist/context/state.d.ts +22 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +790 -0
- package/dist/index.js.map +1 -0
- package/dist/kili-chat.d.ts +4 -0
- package/dist/lib/config.d.ts +21 -0
- package/dist/lib/http.d.ts +2 -0
- package/dist/lib/socket-events.d.ts +29 -0
- package/dist/lib/storage-keys.d.ts +9 -0
- package/dist/lib/types.d.ts +67 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/widget-data.d.ts +35 -0
- package/dist/lib/widget-format.d.ts +3 -0
- package/dist/services/chat.service.d.ts +8 -0
- package/dist/services/core.service.d.ts +6 -0
- package/dist/styles.css +2 -0
- package/package.json +75 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kili
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kilichat/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 SDK for the Kili customer support chat widget. Add it to your app so your
|
|
4
|
+
users can chat with your support team.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @kilichat/vue
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`vue` v3.3 or later is a peer dependency.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Render `KiliChat` and import the stylesheet once:
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { KiliChat } from "@kilichat/vue";
|
|
21
|
+
import "@kilichat/vue/styles.css";
|
|
22
|
+
|
|
23
|
+
const config = {
|
|
24
|
+
apiBaseUrl: "https://api.example.com",
|
|
25
|
+
apiKey: "<your api key>",
|
|
26
|
+
apiSecret: "<your api secret>",
|
|
27
|
+
};
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<KiliChat :config="config" />
|
|
32
|
+
</template>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
On mount, `KiliChat` creates or restores the customer for this browser, signs
|
|
36
|
+
them in, loads their conversations and opens a realtime connection. The widget
|
|
37
|
+
fills the full viewport height, so give it its own page or wrap it in a
|
|
38
|
+
container you size yourself.
|
|
39
|
+
|
|
40
|
+
The widget uses `localStorage`, `sessionStorage` and `window`, so it must render
|
|
41
|
+
on the client. In Nuxt, wrap it in `<ClientOnly>`.
|
|
42
|
+
|
|
43
|
+
### Config
|
|
44
|
+
|
|
45
|
+
| Option | Required | Description |
|
|
46
|
+
| --------------- | -------- | ---------------------------------------------------------- |
|
|
47
|
+
| `apiBaseUrl` | yes | Base URL of the Kili API. |
|
|
48
|
+
| `socketBaseUrl` | no | Base URL of the realtime server. Defaults to `apiBaseUrl`. |
|
|
49
|
+
| `apiKey` | yes | Your organisation's API key. |
|
|
50
|
+
| `apiSecret` | yes | Your organisation's API secret. |
|
|
51
|
+
|
|
52
|
+
## Styling
|
|
53
|
+
|
|
54
|
+
`@kilichat/vue/styles.css` holds the widget's styles and its Space Grotesk and
|
|
55
|
+
DM Sans fonts, which load from Google Fonts. Every rule is scoped to the
|
|
56
|
+
widget's root element (`.kili-root`), so the stylesheet does not change the rest
|
|
57
|
+
of your page.
|
|
58
|
+
|
|
59
|
+
For the dark theme, add a `dark` class to the widget's root or to any ancestor,
|
|
60
|
+
such as `<html>`.
|
|
61
|
+
|
|
62
|
+
## Building your own layout
|
|
63
|
+
|
|
64
|
+
`KiliChat` is the simplest option. To compose the widget yourself, call
|
|
65
|
+
`configureKili(config)` first and use any of these exports:
|
|
66
|
+
|
|
67
|
+
- `AppStateProvider` (component), `provideAppState()` / `createAppState()`, and `useApp()`
|
|
68
|
+
- `ChatWidget`, `ChatHome`, `ChatThread`, `InitialsAvatar`, `Button`, `Textarea`
|
|
69
|
+
- `SocketProvider` (component) and `useSocket()`
|
|
70
|
+
- `chatService` and `coreService`
|
|
71
|
+
- the `SocketEvent` constants and the `Chat`, `Message` and `Customer` types
|
|
72
|
+
|
|
73
|
+
`ChatWidget`, `ChatThread` and any component that calls `useApp()` must be
|
|
74
|
+
rendered inside `AppStateProvider`, or inside a component that called
|
|
75
|
+
`provideAppState()`.
|
|
76
|
+
|
|
77
|
+
`ChatWidget` adds the `kili-root` class itself. If you render the smaller
|
|
78
|
+
components without it, put them inside an element with `class="kili-root"` so
|
|
79
|
+
the styles apply.
|
|
80
|
+
|
|
81
|
+
### Component events
|
|
82
|
+
|
|
83
|
+
| Component | Props and events |
|
|
84
|
+
| ------------ | ----------------------------------------------------------------------- |
|
|
85
|
+
| `ChatHome` | `@open`, `@start-new` |
|
|
86
|
+
| `ChatThread` | `v-model:draft`, `@send`, `@back`, `@textfield-focus`, `@textfield-blur` |
|
|
87
|
+
| `Textarea` | `v-model` |
|
|
88
|
+
| `Button` | `as-child` renders the button's styles onto its child element |
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { KiliChatProps } from './kili-chat';
|
|
2
|
+
declare const __VLS_export: import('vue').DefineComponent<KiliChatProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<KiliChatProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonProps } from './button';
|
|
2
|
+
declare const __VLS_template: () => {
|
|
3
|
+
__VLS_Slots: {
|
|
4
|
+
default?: (props: {}) => any;
|
|
5
|
+
} & {
|
|
6
|
+
default?: (props: {}) => any;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
10
|
+
declare const __VLS_base: import('vue').DefineComponent<ButtonProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ButtonProps> & Readonly<{}>, {
|
|
11
|
+
asChild: boolean;
|
|
12
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'vue';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
modelValue?: string;
|
|
4
|
+
class?: HTMLAttributes["class"];
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
7
|
+
"update:modelValue": (value: string) => any;
|
|
8
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
"onUpdate:modelValue"?: (value: string) => any;
|
|
10
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { HTMLAttributes } from 'vue';
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
|
+
type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
8
|
+
/**
|
|
9
|
+
* Button props. Any other attribute or listener (type, disabled, aria-label,
|
|
10
|
+
* onClick, ...) falls through to the rendered element.
|
|
11
|
+
*/
|
|
12
|
+
export interface ButtonProps {
|
|
13
|
+
variant?: ButtonVariants["variant"];
|
|
14
|
+
size?: ButtonVariants["size"];
|
|
15
|
+
/** Render the single slot child instead of a <button>, merging the classes onto it. */
|
|
16
|
+
asChild?: boolean;
|
|
17
|
+
class?: HTMLAttributes["class"];
|
|
18
|
+
}
|
|
19
|
+
export { buttonVariants };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Vue equivalent of @radix-ui/react-slot: renders its single child and merges
|
|
4
|
+
* its own attributes (class, listeners, aria-*) onto it. Used by Button's
|
|
5
|
+
* `asChild` prop.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Slot: import('vue').DefineComponent<{}, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}> | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Chat } from '../../lib/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
chats: Chat[];
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
6
|
+
open: (chat: Chat) => any;
|
|
7
|
+
startNew: () => any;
|
|
8
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
onOpen?: (chat: Chat) => any;
|
|
10
|
+
onStartNew?: () => any;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Chat } from '../../lib/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
chat: Chat;
|
|
4
|
+
draft: string;
|
|
5
|
+
typing: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
8
|
+
"update:draft": (value: string) => any;
|
|
9
|
+
send: () => any;
|
|
10
|
+
back: () => any;
|
|
11
|
+
textfieldFocus: () => any;
|
|
12
|
+
textfieldBlur: () => any;
|
|
13
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
14
|
+
"onUpdate:draft"?: (value: string) => any;
|
|
15
|
+
onSend?: () => any;
|
|
16
|
+
onBack?: () => any;
|
|
17
|
+
onTextfieldFocus?: () => any;
|
|
18
|
+
onTextfieldBlur?: () => any;
|
|
19
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
declare const _default: typeof __VLS_export;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'vue';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
initials: string;
|
|
4
|
+
size?: "sm" | "md" | "lg";
|
|
5
|
+
tone?: "brand" | "muted" | "sage";
|
|
6
|
+
class?: HTMLAttributes["class"];
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
9
|
+
size: "sm" | "md" | "lg";
|
|
10
|
+
tone: "brand" | "muted" | "sage";
|
|
11
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const __VLS_template: () => {
|
|
2
|
+
__VLS_Slots: {
|
|
3
|
+
default?: (props: {}) => any;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
7
|
+
declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const __VLS_template: () => {
|
|
2
|
+
__VLS_Slots: {
|
|
3
|
+
default?: (props: {}) => any;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
7
|
+
declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Socket } from 'socket.io-client';
|
|
2
|
+
import { InjectionKey, ShallowRef } from 'vue';
|
|
3
|
+
export declare const SocketContext: InjectionKey<ShallowRef<Socket | null>>;
|
|
4
|
+
/** Returns the socket provided by SocketProvider (null until it connects). */
|
|
5
|
+
export declare function useSocket(): ShallowRef<Socket | null> | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Chat, Message } from '../lib/types';
|
|
2
|
+
import { InjectionKey } from 'vue';
|
|
3
|
+
export type AppState = {
|
|
4
|
+
accessToken: string | null;
|
|
5
|
+
setAccessToken: (at: string) => void;
|
|
6
|
+
chats: Chat[];
|
|
7
|
+
setChats: (chats: Chat[]) => void;
|
|
8
|
+
updateChat: (chat: Chat) => void;
|
|
9
|
+
messages: Message[];
|
|
10
|
+
setMessages: (msgs: Message[]) => void;
|
|
11
|
+
appendMessage: (msg: Message) => void;
|
|
12
|
+
refreshToken: string | null;
|
|
13
|
+
setRefreshToken: (rt: string) => void;
|
|
14
|
+
user: any | null;
|
|
15
|
+
setUser: (usr: object) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare const AppStateContext: InjectionKey<AppState>;
|
|
18
|
+
/** Creates the reactive app state. AppStateProvider calls this and provides it. */
|
|
19
|
+
export declare function createAppState(): AppState;
|
|
20
|
+
/** Creates the app state and provides it to every descendant component. */
|
|
21
|
+
export declare function provideAppState(): AppState;
|
|
22
|
+
export declare const useApp: () => AppState;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("vue"),l=require("@lucide/vue"),u=require("clsx"),d=require("tailwind-merge"),f=require("class-variance-authority"),p=require("axios");p=s(p,1);let m=require("socket.io-client"),h=require("@scaleway/random-name");h=s(h,1);var g={AccessTokenExp:`atexp`,JwtAccessToken:`at`,JwtRefreshToken:`rt`,User:`u`},_={ActiveChat:`ac`},v=Symbol(`KiliAppState`);function y(){let e=(0,c.reactive)({accessToken:null,chats:[],messages:[],refreshToken:null,user:null,appendMessage(t){let n=e.messages.filter(e=>String(e.id)!==String(t.id));e.messages=[...n,t]},setAccessToken(t){localStorage.setItem(g.JwtAccessToken,t),e.accessToken=t},updateChat(t){e.chats=e.chats.map(e=>String(e.id)===String(t.id)?t:e)},setChats(t){e.chats=t},setMessages(t){e.messages=t},setRefreshToken(t){localStorage.setItem(g.JwtRefreshToken,t),e.refreshToken=t},setUser(t){localStorage.setItem(g.User,JSON.stringify(t)),e.user=t}});return e}function b(){let e=y();return(0,c.provide)(v,e),e}var x=()=>{let e=(0,c.inject)(v,null);if(!e)throw Error(`useApp can only be called from inside AppStateProvider`);return e},S=(0,c.defineComponent)({__name:`AppStateProvider`,setup(e){return b(),(e,t)=>(0,c.renderSlot)(e.$slots,`default`)}});function C(...e){return(0,d.twMerge)((0,u.clsx)(e))}function w(e){if(!e)return`CS`;let[t,n]=e.split(` `),r=t?.substring(0,1)??``,i=n?.substring(0,1)??``;return r===``&&i===``?`CS`:`${r.toUpperCase()}${i.toUpperCase()}`}function T(e,t){let n=e?.substring(0,1)??``,r=t?.substring(0,1)??``;return n===``&&r===``?`CS`:`${n.toUpperCase()}${r.toUpperCase()}`}var E=(0,c.defineComponent)({name:`InitialsAvatar`,__name:`InitialsAvatar`,props:{initials:{},size:{default:`md`},tone:{default:`brand`},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>((0,c.openBlock)(),(0,c.createElementBlock)(`span`,{class:(0,c.normalizeClass)((0,c.unref)(C)(`inline-flex shrink-0 items-center justify-center rounded-full font-heading font-semibold tracking-tight`,t.size===`sm`&&`size-7 text-[11px]`,t.size===`md`&&`size-9 text-xs`,t.size===`lg`&&`size-12 text-sm`,t.tone===`brand`&&`bg-primary/15 text-primary`,t.tone===`sage`&&`bg-sage/20 text-forest`,t.tone===`muted`&&`bg-muted text-muted-foreground`,t.class))},(0,c.toDisplayString)(t.initials),3))}}),D=(0,f.cva)(`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{default:`bg-primary text-primary-foreground shadow hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90`,outline:`border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2`,sm:`h-8 rounded-md px-3 text-xs`,lg:`h-10 rounded-md px-8`,icon:`h-9 w-9`}},defaultVariants:{variant:`default`,size:`default`}});function O(e){for(let t of e)if(t.type!==c.Comment){if(t.type===c.Fragment&&Array.isArray(t.children)){let e=O(t.children);if(e)return e}else return t}return null}var k=(0,c.defineComponent)({name:`Slot`,inheritAttrs:!1,setup(e,{slots:t,attrs:n}){return()=>{let e=O(t.default?.()??[]);return e?(0,c.cloneVNode)(e,n,!0):null}}}),A=(0,c.defineComponent)({name:`Button`,__name:`Button`,props:{variant:{},size:{},asChild:{type:Boolean,default:!1},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=(0,c.computed)(()=>C(D({variant:t.variant,size:t.size,className:t.class})));return(e,r)=>t.asChild?((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(k),{key:0,class:(0,c.normalizeClass)(n.value)},{default:(0,c.withCtx)(()=>[(0,c.renderSlot)(e.$slots,`default`)]),_:3},8,[`class`])):((0,c.openBlock)(),(0,c.createElementBlock)(`button`,{key:1,class:(0,c.normalizeClass)(n.value)},[(0,c.renderSlot)(e.$slots,`default`)],2))}}),j={name:`Kili`,greeting:`Hi there`,subline:`Ask us anything, or share your feedback. We usually reply in a few minutes.`,replyTime:`Typically replies in a few minutes`},ee={name:`You`,initials:`YO`},M=[{id:`a-mara`,name:`Mara Okafor`,initials:`MO`,role:`Customer Support`},{id:`a-devon`,name:`Devon Reyes`,initials:`DR`,role:`Billing Specialist`},{id:`a-bot`,name:`Kili Team`,initials:`KT`,role:`Support Team`}],N=e=>new Date(Date.now()-e*36e5).toISOString(),P=(e,t=0)=>new Date(Date.now()-e*864e5-t*36e5).toISOString(),te=[{id:`c-1`,subject:`Trouble syncing my orders`,agentId:`a-mara`,messages:[{id:`m-1`,kind:`customer`,body:`Hey — my orders stopped syncing this morning. Nothing new has come through since about 8am.`,at:N(5)},{id:`m-2`,kind:`agent`,authorId:`a-mara`,body:`Thanks for flagging that! I can see the sync queue backed up on our side. I've re-queued your account now.`,at:N(4.6)},{id:`m-3`,kind:`customer`,body:`Great, I can see a few coming in now. How long until it catches up fully?`,at:N(4.2)},{id:`m-4`,kind:`agent`,authorId:`a-mara`,body:`Should be fully caught up within the hour. I'll keep an eye on it and let you know if anything stalls again.`,at:N(4)}]},{id:`c-2`,subject:`Invoice for August`,agentId:`a-devon`,messages:[{id:`m-5`,kind:`customer`,body:`Could you resend the August invoice? I can't find it in my inbox.`,at:P(3,2)},{id:`m-6`,kind:`agent`,authorId:`a-devon`,body:`Just sent it over to the billing email on file. Let me know if it doesn't land in the next few minutes.`,at:P(3,1)},{id:`m-7`,kind:`customer`,body:`Got it, thank you!`,at:P(3)}],closed:!0}],F=[`Thanks for reaching out! Let me take a look at that for you.`,`Good question — I'm checking with the team and will come right back to you.`,`I've made a note of this on your account. Anything else I can help with?`,`That should be sorted now. Give it a refresh and let me know how it looks.`],I=0;function ne(){let e=F[I%F.length];return I+=1,e}function re(e){return M.find(t=>t.id===e)??M[2]}function L(e){return e?new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`}):new Date().toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function R(e){if(!e)return new Date().toLocaleDateString([],{weekday:`long`,month:`short`,day:`numeric`});let t=new Date(e),n=new Date,r=new Date(Date.now()-864e5),i=(e,t)=>e.toDateString()===t.toDateString();return i(t,n)?`Today`:i(t,r)?`Yesterday`:t.toLocaleDateString([],{weekday:`long`,month:`short`,day:`numeric`})}function z(e){let t=Date.now()-new Date(e).getTime(),n=Math.round(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.round(n/60);if(r<24)return`${r}h ago`;let i=Math.round(r/24);return i<7?`${i}d ago`:new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`})}var ie={class:`flex min-h-0 flex-1 flex-col`},ae={class:`bg-brand-gradient px-6 pt-10 pb-12 text-primary-foreground sm:px-10 sm:pt-14`},oe={class:`mx-auto w-full max-w-2xl`},se={class:`font-heading text-sm font-semibold tracking-wide opacity-90`},ce={class:`mt-4 font-heading text-3xl font-semibold sm:text-4xl`},le={class:`mt-2 max-w-md text-sm opacity-90 sm:text-base`},ue={class:`min-h-0 flex-1 overflow-y-auto scrollbar-thin px-4 pt-6 pb-10 sm:px-10`},de={class:`mx-auto w-full max-w-2xl space-y-3`},fe={class:`grid size-10 shrink-0 place-items-center rounded-full bg-primary/15 text-primary`},pe={class:`min-w-0 flex-1`},me={class:`block text-xs text-muted-foreground`},he={class:`space-y-2`},ge=[`onClick`],_e={class:`min-w-0 flex-1`},ve={class:`flex items-center justify-between gap-2`},ye={class:`truncate font-heading text-sm font-semibold`},be={class:`shrink-0 text-[11px] text-muted-foreground`},xe={class:`mt-0.5 block truncate text-xs text-muted-foreground`},Se={key:0,class:`mt-2 inline-flex rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground`},Ce={class:`pt-6 text-center`},B=(0,c.defineComponent)({name:`ChatHome`,__name:`ChatHome`,props:{chats:{}},emits:[`open`,`startNew`],setup(e,{emit:t}){let n=t;function r(e){return e.title??e.summary??e.lastMessagePreview?.substring(0,30)??`Open conversation`}function i(e){let t=e.lastMessagePreview;return t?`${e.lastMessageSenderAccountType===`staff`?e.assignedStaffFullName?.split(` `)[0]??`CS`:`You`}: ${t}`:`No messages yet`}return(t,a)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,ie,[(0,c.createElementVNode)(`header`,ae,[(0,c.createElementVNode)(`div`,oe,[(0,c.createElementVNode)(`p`,se,(0,c.toDisplayString)((0,c.unref)(j).name),1),(0,c.createElementVNode)(`h1`,ce,(0,c.toDisplayString)((0,c.unref)(j).greeting),1),(0,c.createElementVNode)(`p`,le,(0,c.toDisplayString)((0,c.unref)(j).subline),1)])]),(0,c.createElementVNode)(`div`,ue,[(0,c.createElementVNode)(`div`,de,[(0,c.createElementVNode)(`button`,{type:`button`,class:`flex w-full items-center gap-3 rounded-2xl border border-border bg-card p-4 text-left shadow-soft transition-colors hover:bg-accent/40`,onClick:a[0]||=e=>n(`startNew`)},[(0,c.createElementVNode)(`span`,fe,[(0,c.createVNode)((0,c.unref)(l.MessageSquarePlus),{class:`size-5`})]),(0,c.createElementVNode)(`span`,pe,[a[1]||=(0,c.createElementVNode)(`span`,{class:`block font-heading text-sm font-semibold`},`Start a conversation`,-1),(0,c.createElementVNode)(`span`,me,(0,c.toDisplayString)((0,c.unref)(j).replyTime),1)]),(0,c.createVNode)((0,c.unref)(l.ChevronRight),{class:`size-4 shrink-0 text-muted-foreground`})]),e.chats.length>0?((0,c.openBlock)(),(0,c.createElementBlock)(c.Fragment,{key:0},[a[2]||=(0,c.createElementVNode)(`p`,{class:`px-1 pt-4 text-xs font-medium tracking-wide text-muted-foreground uppercase`},` Your conversations `,-1),(0,c.createElementVNode)(`ul`,he,[((0,c.openBlock)(!0),(0,c.createElementBlock)(c.Fragment,null,(0,c.renderList)(e.chats,e=>((0,c.openBlock)(),(0,c.createElementBlock)(`li`,{key:e.id},[(0,c.createElementVNode)(`button`,{type:`button`,class:`flex w-full items-start gap-3 rounded-2xl border border-border bg-card p-4 text-left transition-colors hover:bg-accent/40`,onClick:t=>n(`open`,e)},[(0,c.createVNode)(E,{initials:(0,c.unref)(w)(e.assignedStaffFullName??``),size:`md`,tone:`sage`},null,8,[`initials`]),(0,c.createElementVNode)(`span`,_e,[(0,c.createElementVNode)(`span`,ve,[(0,c.createElementVNode)(`span`,ye,(0,c.toDisplayString)(r(e)),1),(0,c.createElementVNode)(`span`,be,(0,c.toDisplayString)(e.lastMessagePreview?(0,c.unref)(z)(e.lastMessageSentAt??e.updatedAt):``),1)]),(0,c.createElementVNode)(`span`,xe,(0,c.toDisplayString)(i(e)),1),e.closedAt?((0,c.openBlock)(),(0,c.createElementBlock)(`span`,Se,` Closed `)):(0,c.createCommentVNode)(``,!0)])],8,ge)]))),128))])],64)):(0,c.createCommentVNode)(``,!0),(0,c.createElementVNode)(`div`,Ce,[(0,c.createVNode)(A,{variant:`ghost`,size:`sm`,class:`text-xs text-muted-foreground`,onClick:()=>{}},{default:(0,c.withCtx)(()=>[...a[3]||=[(0,c.createTextVNode)(` Can't find what you need? Message us `,-1)]]),_:1})])])])]))}}),we=[`value`],V=(0,c.defineComponent)({name:`Textarea`,__name:`Textarea`,props:{modelValue:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t;return(e,t)=>((0,c.openBlock)(),(0,c.createElementBlock)(`textarea`,{class:(0,c.normalizeClass)((0,c.unref)(C)(`flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,n.class)),value:n.modelValue,onInput:t[0]||=e=>r(`update:modelValue`,e.target.value)},null,42,we))}}),H=null;function U(e){H=e}function W(){if(!H)throw Error(`Kili SDK is not configured. Render <KiliChat :config="..." /> or call configureKili() first.`);return H}function G(){let e=W();return e.socketBaseUrl??e.apiBaseUrl}var K=p.default.create();K.interceptors.request.use(e=>{let t=W();e.baseURL=t.apiBaseUrl,e.headers[`Api-Key`]=t.apiKey,e.headers[`Api-Secret`]=t.apiSecret;let n=localStorage.getItem(g.JwtAccessToken);return n&&(e.headers.Authorization=`Bearer ${n}`),e});var q={async getAllChats(e){return(await K.get(`/chats?customerId=${e}`)).data.data},async getChatMessages(e){return(await K.get(`/chats/${e}/messages`)).data.data},async startChat(){return(await K.post(`/chats`,{initiationChannel:`web_widget`})).data.data},async sendMessage(){},async markMessageAsRead(){}},Te={class:`flex min-h-0 flex-1 flex-col bg-surface`},Ee={class:`border-b border-border bg-card px-4 py-3 sm:px-6`},De={class:`mx-auto flex w-full max-w-2xl items-center gap-3`},Oe={class:`min-w-0 flex-1`},ke={class:`truncate font-heading text-sm font-semibold`},Ae={class:`truncate text-xs text-muted-foreground`},je={class:`min-h-0 flex-1 overflow-y-auto scrollbar-thin px-4 py-6 sm:px-6`},Me={class:`mx-auto w-full max-w-2xl space-y-4`},Ne={key:0,class:`rounded-2xl border border-dashed border-border bg-card/60 p-6 text-center`},Pe={class:`mt-3 font-heading text-sm font-semibold`},Fe={key:0,class:`flex items-center gap-3`},Ie={class:`text-[11px] text-muted-foreground`},Le={key:1,class:`flex max-w-[80%] items-end gap-2`},Re={class:`rounded-2xl rounded-bl-sm border border-border bg-card px-4 py-2.5`},ze={class:`text-sm whitespace-pre-wrap`},Be={class:`mt-1 text-[11px] text-muted-foreground`},Ve={key:2,class:`ml-auto flex max-w-[80%] flex-row-reverse items-end gap-2`},He={class:`rounded-2xl rounded-br-sm bg-primary px-4 py-2.5 text-primary-foreground`},Ue={class:`text-sm whitespace-pre-wrap`},We={class:`mt-1 text-[11px] opacity-80`},Ge={key:1,class:`flex max-w-[80%] items-end gap-2`},Ke={class:`flex items-center gap-1 rounded-2xl rounded-bl-sm border border-border bg-card px-4 py-3`},qe={class:`border-t border-border bg-card px-4 py-3 sm:px-6`},Je={class:`mx-auto w-full max-w-2xl`},Ye={class:`flex items-end gap-2`},Xe={class:`mt-2 flex items-center gap-2 text-muted-foreground`},J=(0,c.defineComponent)({name:`ChatThread`,__name:`ChatThread`,props:{chat:{},draft:{},typing:{type:Boolean}},emits:[`update:draft`,`send`,`back`,`textfieldFocus`,`textfieldBlur`],setup(e,{emit:t}){let n=e,r=t,i=(0,c.ref)(null),a=x(),o=(0,c.computed)(()=>w(n.chat.assignedStaffFullName)),s=(0,c.computed)(()=>w(n.chat.customerFullName)),u=(0,c.computed)(()=>n.chat.assignedStaffFullName?.split(` `)[0]),d=async()=>{let e=await q.getChatMessages(n.chat.id);a.setMessages(e.data)},f=()=>{i.value?.scrollIntoView({behavior:`smooth`,block:`end`})};(0,c.watch)(()=>[a.messages.length,n.typing],f,{flush:`post`}),(0,c.onMounted)(()=>{f(),d()});function p(e){let t=a.messages[e],n=a.messages[e-1];return!n||R(n.sentAt)!==R(t?.sentAt)}let m=()=>crypto.randomUUID();function h(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),r(`send`))}let g=[`0ms`,`150ms`,`300ms`];return(e,t)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,Te,[(0,c.createElementVNode)(`header`,Ee,[(0,c.createElementVNode)(`div`,De,[(0,c.createVNode)(A,{variant:`ghost`,size:`icon`,class:`size-8 shrink-0`,"aria-label":`Back`,onClick:t[0]||=e=>r(`back`)},{default:(0,c.withCtx)(()=>[(0,c.createVNode)((0,c.unref)(l.ArrowLeft),{class:`size-4`})]),_:1}),(0,c.createVNode)(E,{initials:o.value,size:`md`,tone:`sage`},null,8,[`initials`]),(0,c.createElementVNode)(`div`,Oe,[(0,c.createElementVNode)(`p`,ke,(0,c.toDisplayString)(n.chat.assignedStaffFullName),1),(0,c.createElementVNode)(`p`,Ae,(0,c.toDisplayString)(n.typing?`${u.value} is typing…`:(0,c.unref)(j).replyTime),1)])])]),(0,c.createElementVNode)(`div`,je,[(0,c.createElementVNode)(`div`,Me,[(0,c.unref)(a).messages.length?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,Ne,[(0,c.createVNode)(E,{initials:(0,c.unref)(w)(n.chat.assignedStaffFullName),size:`lg`,tone:`sage`,class:`mx-auto`},null,8,[`initials`]),(0,c.createElementVNode)(`p`,Pe,`Say hello to `+(0,c.toDisplayString)(u.value),1),t[5]||=(0,c.createElementVNode)(`p`,{class:`mt-1 text-xs text-muted-foreground`},` Describe what you need help with and we'll take it from there. `,-1)])):(0,c.createCommentVNode)(``,!0),((0,c.openBlock)(!0),(0,c.createElementBlock)(c.Fragment,null,(0,c.renderList)((0,c.unref)(a).messages,(e,n)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,{key:m(),class:`space-y-4`},[p(n)?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,Fe,[t[6]||=(0,c.createElementVNode)(`span`,{class:`h-px flex-1 bg-border`},null,-1),(0,c.createElementVNode)(`span`,Ie,(0,c.toDisplayString)((0,c.unref)(R)(e.sentAt)),1),t[7]||=(0,c.createElementVNode)(`span`,{class:`h-px flex-1 bg-border`},null,-1)])):(0,c.createCommentVNode)(``,!0),e.senderAccountType===`staff`?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,Le,[(0,c.createVNode)(E,{initials:(0,c.unref)(T)(e.senderFirstName,e.senderLastName),size:`sm`,tone:`sage`},null,8,[`initials`]),(0,c.createElementVNode)(`div`,Re,[(0,c.createElementVNode)(`p`,ze,(0,c.toDisplayString)(e.content),1),(0,c.createElementVNode)(`p`,Be,(0,c.toDisplayString)(e.senderFirstName)+` · `+(0,c.toDisplayString)((0,c.unref)(L)(e.sentAt)),1)])])):((0,c.openBlock)(),(0,c.createElementBlock)(`div`,Ve,[(0,c.createVNode)(E,{initials:s.value,size:`sm`,tone:`muted`},null,8,[`initials`]),(0,c.createElementVNode)(`div`,He,[(0,c.createElementVNode)(`p`,Ue,(0,c.toDisplayString)(e.content),1),(0,c.createElementVNode)(`p`,We,(0,c.toDisplayString)((0,c.unref)(L)(e.sentAt))+` · Sent`,1)])]))]))),128)),n.typing?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,Ge,[(0,c.createVNode)(E,{initials:o.value,size:`sm`,tone:`sage`},null,8,[`initials`]),(0,c.createElementVNode)(`div`,Ke,[((0,c.openBlock)(),(0,c.createElementBlock)(c.Fragment,null,(0,c.renderList)(g,e=>(0,c.createElementVNode)(`span`,{key:e,class:`size-1.5 animate-bounce rounded-full bg-muted-foreground/60`,style:(0,c.normalizeStyle)({animationDelay:e})},null,4)),64))])])):(0,c.createCommentVNode)(``,!0),(0,c.createElementVNode)(`div`,{ref_key:`bottomRef`,ref:i},null,512)])]),(0,c.createElementVNode)(`div`,qe,[(0,c.createElementVNode)(`div`,Je,[(0,c.createElementVNode)(`div`,Ye,[(0,c.createVNode)(V,{"model-value":n.draft,placeholder:`Write a message…`,"aria-label":`Write a message`,class:`max-h-40 min-h-[44px] flex-1 resize-none bg-background text-sm`,"onUpdate:modelValue":t[1]||=e=>r(`update:draft`,e),onKeydown:h,onFocus:t[2]||=e=>r(`textfieldFocus`),onBlur:t[3]||=e=>r(`textfieldBlur`)},null,8,[`model-value`]),(0,c.createVNode)(A,{size:`icon`,class:`size-10 shrink-0`,disabled:!n.draft.trim(),"aria-label":`Send`,onClick:t[4]||=e=>r(`send`)},{default:(0,c.withCtx)(()=>[(0,c.createVNode)((0,c.unref)(l.Send),{class:`size-4`})]),_:1},8,[`disabled`])]),(0,c.createElementVNode)(`div`,Xe,[(0,c.createVNode)((0,c.unref)(l.Paperclip),{class:`size-4`,"aria-hidden":`true`}),(0,c.createVNode)((0,c.unref)(l.Smile),{class:`size-4`,"aria-hidden":`true`}),t[8]||=(0,c.createElementVNode)(`span`,{class:`ml-auto text-[11px]`},`Enter to send · Shift + Enter for a new line`,-1)])])])]))}}),Y=Object.freeze({Connection:`connection`,Disconnect:`disconnect`,Error:`error`,AssignChat:`assign_chat`,ChatAction:`chat_action`,ChatAssigned:`chat_assigned`,ChatDeassigned:`chat_deassigned`,ChatStarted:`chat_started`,ChatUpdated:`chat_updated`,ChatWindowClosed:`chat_window_closed`,ChatWindowOpened:`chat_window_opened`,CloseChat:`close_chat`,InternalNote:`internal_note`,JoinAllUnclosedChatRooms:`join_all_unclosed_chat_rooms`,JoinChatRoom:`join_chat_room`,JoinedChatRoom:`joined_chat_room`,LeaveRoom:`leave_room`,MarkMsgAsRead:`mark_msg_as_read`,Message:`message`,MessageDelivered:`message_delivered`,NewMention:`new_mention`,PrioritizeChat:`prioritize_chat`,RefetchChats:`refetch_chats`,ReopenChat:`reopen_chat`,RefetchChatCounts:`refetch_chat_counts`,SnoozeChat:`snooze_chat`,StartChat:`start_chat`}),Ze={key:0,class:`kili-root flex h-dvh w-full flex-col overflow-hidden bg-background`},X=(0,c.defineComponent)({name:`ChatWidget`,__name:`ChatWidget`,setup(e){let t=(0,c.ref)(``),n=(0,c.ref)(!1),r=[],i=x(),a=(0,c.ref)(null),o={current:null},s=e=>{let t=sessionStorage.getItem(_.ActiveChat);if(!t)return;let n=JSON.parse(t);e.chatId==n.id&&i?.appendMessage(e)},l=e=>{switch(e.action){case`typing.started`:n.value=!0;break;case`typing.stopped`:n.value=!1}},u=async e=>{let t=JSON.parse(localStorage.getItem(g.User));if(e.customerId!=t.id){console.log(`chat created by a different cstomer`);return}o.current?.emit(Y.JoinChatRoom,e.id);let n=await q.getAllChats(t.id);i?.setChats(n.data),f(e)},d=e=>{let t=sessionStorage.getItem(_.ActiveChat);if(!t)return;let n=JSON.parse(t);n&&n.id===e.id&&(a.value=e)},f=e=>{a.value=e,e?sessionStorage.setItem(_.ActiveChat,JSON.stringify(e)):sessionStorage.removeItem(_.ActiveChat)};(0,c.onBeforeUnmount)(()=>{r.forEach(clearTimeout)}),(0,c.watch)(()=>[i.user,i.accessToken],()=>{if(!i||!i.user||!i.accessToken||o.current)return;let e=(0,m.io)(G(),{extraHeaders:{"Api-Key":W().apiKey,"Api-Secret":W().apiSecret,Authorization:`Bearer ${i.accessToken}`}});e.on(`connect`,()=>{console.log(`socket connected`),e.emit(Y.JoinAllUnclosedChatRooms),e.on(Y.ChatAction,l),e.on(Y.ChatStarted,u),e.on(Y.ChatUpdated,d),e.on(Y.MessageDelivered,s)}),e.on(Y.Disconnect,()=>{console.log(`socket disconnected`)}),e.on(Y.Error,t=>{console.log(e.id,`has an error`,t)}),o.current=e},{immediate:!0});let p=()=>{if(!a.value)return;let e=i?.user??JSON.parse(localStorage.getItem(g.User)),n={chatId:Number(a.value.id),content:t.value.trim(),senderEmail:e.email,senderId:e.id,sentAt:new Date().toISOString(),senderAccountType:`CUSTOMER`,senderFirstName:e.firstName,senderLastName:e.lastName,type:`TEXT`};o.current.emit(Y.ChatAction,{action:`typing.stopped`,chatId:a.value.id}),o.current.emit(Y.Message,n),t.value=``},h=()=>{o?.current?.emit(Y.StartChat,{initiationChannel:`web_widget`}),t.value=``},v=()=>{f(null),n.value=!1},y=()=>{o.current?.emit(Y.ChatAction,{action:`typing.stopped`,chatId:a.value?.id})},b=()=>{o.current?.emit(Y.ChatAction,{action:`typing.started`,chatId:a.value?.id})},S=e=>{f(e),t.value=``};return(e,r)=>(0,c.unref)(i)?((0,c.openBlock)(),(0,c.createElementBlock)(`div`,Ze,[a.value?((0,c.openBlock)(),(0,c.createBlock)(J,{key:0,draft:t.value,"onUpdate:draft":r[0]||=e=>t.value=e,chat:a.value,typing:n.value,onSend:p,onBack:v,onTextfieldBlur:y,onTextfieldFocus:b},null,8,[`draft`,`chat`,`typing`])):((0,c.openBlock)(),(0,c.createBlock)(B,{key:1,chats:(0,c.unref)(i).chats,onOpen:S,onStartNew:h},null,8,[`chats`]))])):(0,c.createCommentVNode)(``,!0)}}),Z={async createCustomer(){let e=localStorage.getItem(g.User);if(e)return JSON.parse(e);let[t,n]=(0,h.default)(``,` `).split(` `),r=await K.post(`/customers`,{city:`Denver`,country:`united states`,device:`iPhone 17 pro`,email:`${t}.${n}@kili.africa`,firstName:t,id:crypto.randomUUID(),lastName:n,phoneCountryCode:`1`,phoneNumberSuffix:`1234567`,state:`Colorado`});return console.dir({createdCustomer:r.data},{depth:null}),localStorage.setItem(g.User,JSON.stringify(r.data.data)),r.data.data},async registerCustomer(){let e=localStorage.getItem(g.User),t=JSON.parse(e),n=await K.put(`/customers`,{id:t.userId,email:t.email});return localStorage.setItem(g.JwtAccessToken,n.data.data.accessToken),localStorage.setItem(g.AccessTokenExp,n.data.data.expiresAt),n.data.data},async setCustomerHmac(){let e=localStorage.getItem(g.User),t=JSON.parse(e),n=crypto.randomUUID();await K.patch(`/customers/${t.userId}/hmac`,{hmac:n})}},Qe=(0,c.defineComponent)({name:`KiliChatBootstrap`,__name:`KiliChatBootstrap`,setup(e){let t=x(),n=async()=>{let e=await Z.createCustomer();await Z.setCustomerHmac();let n=await Z.registerCustomer();t?.setUser(e),t?.setAccessToken(n.accessToken);let r=await q.getAllChats(e.id);t?.setChats(r.data)};return(0,c.onMounted)(()=>{n()}),(e,t)=>((0,c.openBlock)(),(0,c.createBlock)(X))}}),$e=(0,c.defineComponent)({name:`KiliChat`,__name:`KiliChat`,props:{config:{}},setup(e){let t=e;return U(t.config),(0,c.watch)(()=>t.config,e=>U(e),{deep:!0}),(e,t)=>((0,c.openBlock)(),(0,c.createBlock)(S,null,{default:(0,c.withCtx)(()=>[(0,c.createVNode)(Qe)]),_:1}))}}),Q=Symbol(`KiliSocket`);function et(){return(0,c.inject)(Q,null)}var tt=(0,c.defineComponent)({__name:`SocketProvider`,setup(e){let t=(0,c.shallowRef)(null),n=(0,c.inject)(v,null);return(0,c.watch)(()=>[n?.user,n?.accessToken],()=>{if(!n||!n.user||!n.accessToken||t.value)return;let e=(0,m.io)(G(),{extraHeaders:{"Api-Key":W().apiKey,"Api-Secret":W().apiSecret,Authorization:`Bearer ${n.accessToken}`}});e.on(`connect`,()=>{console.log(e.id,`connected to the socket`),e.emit(Y.JoinAllUnclosedChatRooms),e.on(Y.JoinedChatRoom,e=>console.log(`joined chat room`,e))}),e.on(Y.Disconnect,()=>{console.log(e.id,`has disconnected from the socket`)}),e.on(Y.Error,t=>{console.log(e.id,`has an error`,t)}),t.value=e},{immediate:!0}),(0,c.provide)(Q,t),(e,t)=>(0,c.renderSlot)(e.$slots,`default`)}}),$=768;function nt(){let e=(0,c.ref)(void 0),t=null,n=()=>{e.value=window.innerWidth<$};return(0,c.onMounted)(()=>{t=window.matchMedia(`(max-width: 767px)`),t.addEventListener(`change`,n),e.value=window.innerWidth<$}),(0,c.onBeforeUnmount)(()=>t?.removeEventListener(`change`,n)),(0,c.computed)(()=>!!e.value)}exports.AppStateContext=v,exports.AppStateProvider=S,exports.Button=A,exports.ChatHome=B,exports.ChatThread=J,exports.ChatWidget=X,exports.InitialsAvatar=E,exports.KiliChat=$e,exports.LocalStorageKeys=g,exports.SessionStorageKeys=_,exports.Slot=k,exports.SocketContext=Q,exports.SocketEvent=Y,exports.SocketProvider=tt,exports.Textarea=V,exports.agentById=re,exports.agents=M,exports.brand=j,exports.buttonVariants=D,exports.chatService=q,exports.clockTime=L,exports.cn=C,exports.configureKili=U,exports.coreService=Z,exports.createAppState=y,exports.customer=ee,exports.dayLabel=R,exports.getInitialsFromFullName=w,exports.getInitialsFromNames=T,exports.getKiliConfig=W,exports.http=K,exports.nextCannedReply=ne,exports.provideAppState=b,exports.relativeTime=z,exports.seedConversations=te,exports.useApp=x,exports.useIsMobile=nt,exports.useSocket=et;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["reactive","inject","_renderSlot","twMerge","_openBlock","_createElementBlock","_normalizeClass","_unref","_toDisplayString","cva","Comment","Fragment","defineComponent","cloneVNode","computed","_openBlock","_createBlock","_unref","_normalizeClass","_withCtx","_renderSlot","_createElementBlock","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_unref","_createVNode","MessageSquarePlus","ChevronRight","_Fragment","_renderList","InitialsAvatar","Button","_withCtx","_createTextVNode","_openBlock","_createElementBlock","_normalizeClass","_unref","_hoisted_1","ref","computed","_openBlock","_createElementBlock","_createElementVNode","_createVNode","Button","_withCtx","_unref","ArrowLeft","InitialsAvatar","_toDisplayString","_Fragment","_renderList","_normalizeStyle","Textarea","Send","Paperclip","Smile","ref","io","_unref","_openBlock","_createElementBlock","_createBlock","ChatThread","ChatHome","randomName","_openBlock","_createBlock","ChatWidget","_openBlock","_createBlock","AppStateProvider","_withCtx","_createVNode","KiliChatBootstrap","inject","shallowRef","inject","io","_renderSlot","ref","computed","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__copyProps","from","keys","i","n","key","to","except","k","desc","__toESM","mod","isNodeMode","target","vue","_lucide_vue","clsx","tailwind_merge","class_variance_authority","axios","socket_io_client","_scaleway_random_name","LocalStorageKeys","SessionStorageKeys","AppStateContext","createAppState","state","dedup","p","msg","at","chat","chats","msgs","rt","usr","provideAppState","useApp","ctx","AppStateProvider_default","_ctx","cn","inputs","getInitialsFromFullName","fullname","fname","lname","firstInitial","lastInitial","getInitialsFromNames","InitialsAvatar_default","props","__props","buttonVariants","firstRenderable","node","nodes","inner","Slot","child","slots","\"default\"","attrs","Button_default","classes","brand","customer","agents","hoursAgo","h","daysAgo","d","seedConversations","cannedReplies","replyIndex","nextCannedReply","reply","agentById","a","id","clockTime","iso","dayLabel","date","today","yesterday","sameDay","b","relativeTime","diff","minutes","hours","days","_hoisted_1$3","_hoisted_2$1","_hoisted_3$1","_hoisted_4$1","_hoisted_5$1","_hoisted_6$1","_hoisted_7$1","_hoisted_8$1","_hoisted_9$1","_hoisted_10$1","_hoisted_11$1","_hoisted_12$1","_hoisted_13$1","_hoisted_14$1","_hoisted_15$1","_hoisted_16$1","_hoisted_17$1","_hoisted_18$1","_hoisted_19$1","_hoisted_20$1","ChatHome_default","__emit","emit","chatTitle","chatPreview","last","_cache","_hoisted_1$2","Textarea_default","$event","currentConfig","configureKili","config","getKiliConfig","getSocketBaseUrl","http","token","\"Authorization\"","req","chatService","userId","chatId","_hoisted_1$1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_23","_hoisted_24","_hoisted_25","_hoisted_26","ChatThread_default","bottomRef","agentInitials","customerInitials","agentFirstName","loadChatHistory","messages","scrollToBottom","showDay","m","prev","randomKey","onKeydown","dotDelays","delay","SocketEvent","_hoisted_1","ChatWidget_default","draft","typing","timers","activeChat","socketRef","appendMessage","chatJson","handleChatAction","action","handleChatStarted","user","persistActiveChat","updateChat","acJson","ac","c","socket","err","sendMessage","startChat","onBack","onTextFieldBlur","onTextfieldFocus","onOpen","coreService","res","data","hmac","KiliChatBootstrap_default","onMount","auth","KiliChat_default","SocketContext","useSocket","SocketProvider_default","socketClient","roomId","MOBILE_BREAKPOINT","useIsMobile","isMobile","mql","onChange"],"sources":["../src/lib/storage-keys.ts","../src/context/state.ts","../src/context/AppStateProvider.vue","../src/lib/utils.ts","../src/components/widget/InitialsAvatar.vue","../src/components/ui/button.ts","../src/components/ui/slot.ts","../src/components/ui/Button.vue","../src/lib/widget-data.ts","../src/lib/widget-format.ts","../src/components/widget/ChatHome.vue","../src/components/ui/Textarea.vue","../src/lib/config.ts","../src/lib/http.ts","../src/services/chat.service.ts","../src/components/widget/ChatThread.vue","../src/lib/socket-events.ts","../src/components/widget/ChatWidget.vue","../src/services/core.service.ts","../src/KiliChatBootstrap.vue","../src/KiliChat.vue","../src/context/socket.ts","../src/context/SocketProvider.vue","../src/composables/use-mobile.ts"],"sourcesContent":["export const LocalStorageKeys = {\n AccessTokenExp: 'atexp',\n JwtAccessToken: 'at',\n JwtRefreshToken: 'rt',\n User: 'u',\n}\n\nexport const SessionStorageKeys = {\n ActiveChat: 'ac',\n}","import { LocalStorageKeys } from '@/lib/storage-keys';\nimport { Chat, Message } from '@/lib/types';\nimport { inject, provide, reactive, type InjectionKey } from 'vue';\n\nexport type AppState = {\n accessToken: string | null;\n setAccessToken: (at: string) => void;\n chats: Chat[];\n setChats: (chats: Chat[]) => void;\n updateChat: (chat: Chat) => void;\n messages: Message[];\n setMessages: (msgs: Message[]) => void;\n appendMessage: (msg: Message) => void;\n refreshToken: string | null;\n setRefreshToken: (rt: string) => void;\n user: any | null;\n setUser: (usr: object) => void;\n}\n\nexport const AppStateContext: InjectionKey<AppState> = Symbol('KiliAppState');\n\n/** Creates the reactive app state. AppStateProvider calls this and provides it. */\nexport function createAppState(): AppState {\n const state: AppState = reactive({\n accessToken: null as string | null,\n chats: [] as Chat[],\n messages: [] as Message[],\n refreshToken: null as string | null,\n user: null as object | null,\n\n appendMessage(msg: Message) {\n const dedup = state.messages.filter(p => String(p.id) !== String(msg.id));\n state.messages = [...dedup, msg];\n },\n\n setAccessToken(at: string) {\n localStorage.setItem(LocalStorageKeys.JwtAccessToken, at);\n state.accessToken = at;\n },\n\n updateChat(chat: Chat) {\n state.chats = state.chats.map(p => String(p.id) === String(chat.id) ? chat : p);\n },\n\n setChats(chats: Chat[]) {\n state.chats = chats;\n },\n\n setMessages(msgs: Message[]) {\n state.messages = msgs;\n },\n\n setRefreshToken(rt: string) {\n localStorage.setItem(LocalStorageKeys.JwtRefreshToken, rt);\n state.refreshToken = rt;\n },\n\n setUser(usr: object) {\n localStorage.setItem(LocalStorageKeys.User, JSON.stringify(usr));\n state.user = usr;\n },\n });\n\n return state;\n}\n\n/** Creates the app state and provides it to every descendant component. */\nexport function provideAppState(): AppState {\n const state = createAppState();\n provide(AppStateContext, state);\n return state;\n}\n\nexport const useApp = (): AppState => {\n const ctx = inject(AppStateContext, null);\n if (!ctx) throw new Error('useApp can only be called from inside AppStateProvider');\n return ctx;\n}\n","<script setup lang=\"ts\">\nimport { provideAppState } from './state';\n\nprovideAppState();\n</script>\n\n<template>\n <slot />\n</template>\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n\nexport function getInitialsFromFullName(fullname?: string): string {\n if (!fullname) return 'CS';\n const [fname, lname] = fullname.split(' ');\n const firstInitial = fname?.substring(0,1) ?? '';\n const lastInitial = lname?.substring(0,1) ?? '';\n if (firstInitial === '' && lastInitial === '') return 'CS';\n return `${firstInitial.toUpperCase()}${lastInitial.toUpperCase()}`;\n}\n\nexport function getInitialsFromNames(fname?: string, lname?: string): string {\n const firstInitial = fname?.substring(0,1) ?? '';\n const lastInitial = lname?.substring(0,1) ?? '';\n if (firstInitial === '' && lastInitial === '') return 'CS';\n return `${firstInitial.toUpperCase()}${lastInitial.toUpperCase()}`;\n}","<script setup lang=\"ts\">\nimport type { HTMLAttributes } from \"vue\";\nimport { cn } from \"@/lib/utils\";\n\ndefineOptions({ name: \"InitialsAvatar\" });\n\nconst props = withDefaults(\n defineProps<{\n initials: string;\n size?: \"sm\" | \"md\" | \"lg\";\n tone?: \"brand\" | \"muted\" | \"sage\";\n class?: HTMLAttributes[\"class\"];\n }>(),\n { size: \"md\", tone: \"brand\" },\n);\n</script>\n\n<template>\n <span\n :class=\"\n cn(\n 'inline-flex shrink-0 items-center justify-center rounded-full font-heading font-semibold tracking-tight',\n props.size === 'sm' && 'size-7 text-[11px]',\n props.size === 'md' && 'size-9 text-xs',\n props.size === 'lg' && 'size-12 text-sm',\n props.tone === 'brand' && 'bg-primary/15 text-primary',\n props.tone === 'sage' && 'bg-sage/20 text-forest',\n props.tone === 'muted' && 'bg-muted text-muted-foreground',\n props.class,\n )\n \"\n >\n {{ props.initials }}\n </span>\n</template>\n","import { cva, type VariantProps } from \"class-variance-authority\";\nimport type { HTMLAttributes } from \"vue\";\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground shadow hover:bg-primary/90\",\n destructive: \"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90\",\n outline:\n \"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground\",\n secondary: \"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-9 px-4 py-2\",\n sm: \"h-8 rounded-md px-3 text-xs\",\n lg: \"h-10 rounded-md px-8\",\n icon: \"h-9 w-9\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n\ntype ButtonVariants = VariantProps<typeof buttonVariants>;\n\n/**\n * Button props. Any other attribute or listener (type, disabled, aria-label,\n * onClick, ...) falls through to the rendered element.\n */\nexport interface ButtonProps {\n variant?: ButtonVariants[\"variant\"];\n size?: ButtonVariants[\"size\"];\n /** Render the single slot child instead of a <button>, merging the classes onto it. */\n asChild?: boolean;\n class?: HTMLAttributes[\"class\"];\n}\n\nexport { buttonVariants };\n","import { cloneVNode, Comment, defineComponent, Fragment, type VNode } from \"vue\";\n\nfunction firstRenderable(nodes: VNode[]): VNode | null {\n for (const node of nodes) {\n if (node.type === Comment) continue;\n if (node.type === Fragment && Array.isArray(node.children)) {\n const inner = firstRenderable(node.children as VNode[]);\n if (inner) return inner;\n continue;\n }\n return node;\n }\n return null;\n}\n\n/**\n * Vue equivalent of @radix-ui/react-slot: renders its single child and merges\n * its own attributes (class, listeners, aria-*) onto it. Used by Button's\n * `asChild` prop.\n */\nexport const Slot = defineComponent({\n name: \"Slot\",\n inheritAttrs: false,\n setup(_, { slots, attrs }) {\n return () => {\n const child = firstRenderable(slots[\"default\"]?.() ?? []);\n if (!child) return null;\n return cloneVNode(child, attrs, true);\n };\n },\n});\n","<script setup lang=\"ts\">\nimport { computed } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { buttonVariants, type ButtonProps } from \"./button\";\nimport { Slot } from \"./slot\";\n\ndefineOptions({ name: \"Button\" });\n\nconst props = withDefaults(defineProps<ButtonProps>(), { asChild: false });\n\nconst classes = computed(() =>\n cn(buttonVariants({ variant: props.variant, size: props.size, className: props.class })),\n);\n</script>\n\n<template>\n <!-- Not <component :is=\"'button'\">: Vue would resolve that string to this\n component itself (self-name \"Button\") and recurse forever. -->\n <Slot v-if=\"props.asChild\" :class=\"classes\">\n <slot />\n </Slot>\n <button v-else :class=\"classes\">\n <slot />\n </button>\n</template>\n","export type MessageKind = \"customer\" | \"agent\";\n\nexport type WidgetMessage = {\n id: string;\n kind: MessageKind;\n body: string;\n at: string; // ISO timestamp\n authorId?: string;\n};\n\nexport type Agent = {\n id: string;\n name: string;\n initials: string;\n role: string;\n};\n\nexport type WidgetConversation = {\n id: string;\n subject: string;\n agentId: string;\n messages: WidgetMessage[];\n closed?: boolean;\n};\n\nexport const brand = {\n name: \"Kili\",\n greeting: \"Hi there\",\n subline: \"Ask us anything, or share your feedback. We usually reply in a few minutes.\",\n replyTime: \"Typically replies in a few minutes\",\n};\n\nexport const customer = {\n name: \"You\",\n initials: \"YO\",\n};\n\nexport const agents: Agent[] = [\n { id: \"a-mara\", name: \"Mara Okafor\", initials: \"MO\", role: \"Customer Support\" },\n { id: \"a-devon\", name: \"Devon Reyes\", initials: \"DR\", role: \"Billing Specialist\" },\n { id: \"a-bot\", name: \"Kili Team\", initials: \"KT\", role: \"Support Team\" },\n];\n\nconst hoursAgo = (h: number) => new Date(Date.now() - h * 3600_000).toISOString();\nconst daysAgo = (d: number, h = 0) => new Date(Date.now() - d * 86_400_000 - h * 3600_000).toISOString();\n\nexport const seedConversations: WidgetConversation[] = [\n {\n id: \"c-1\",\n subject: \"Trouble syncing my orders\",\n agentId: \"a-mara\",\n messages: [\n {\n id: \"m-1\",\n kind: \"customer\",\n body: \"Hey — my orders stopped syncing this morning. Nothing new has come through since about 8am.\",\n at: hoursAgo(5),\n },\n {\n id: \"m-2\",\n kind: \"agent\",\n authorId: \"a-mara\",\n body: \"Thanks for flagging that! I can see the sync queue backed up on our side. I've re-queued your account now.\",\n at: hoursAgo(4.6),\n },\n {\n id: \"m-3\",\n kind: \"customer\",\n body: \"Great, I can see a few coming in now. How long until it catches up fully?\",\n at: hoursAgo(4.2),\n },\n {\n id: \"m-4\",\n kind: \"agent\",\n authorId: \"a-mara\",\n body: \"Should be fully caught up within the hour. I'll keep an eye on it and let you know if anything stalls again.\",\n at: hoursAgo(4),\n },\n ],\n },\n {\n id: \"c-2\",\n subject: \"Invoice for August\",\n agentId: \"a-devon\",\n messages: [\n {\n id: \"m-5\",\n kind: \"customer\",\n body: \"Could you resend the August invoice? I can't find it in my inbox.\",\n at: daysAgo(3, 2),\n },\n {\n id: \"m-6\",\n kind: \"agent\",\n authorId: \"a-devon\",\n body: \"Just sent it over to the billing email on file. Let me know if it doesn't land in the next few minutes.\",\n at: daysAgo(3, 1),\n },\n {\n id: \"m-7\",\n kind: \"customer\",\n body: \"Got it, thank you!\",\n at: daysAgo(3),\n },\n ],\n closed: true,\n },\n];\n\nconst cannedReplies = [\n \"Thanks for reaching out! Let me take a look at that for you.\",\n \"Good question — I'm checking with the team and will come right back to you.\",\n \"I've made a note of this on your account. Anything else I can help with?\",\n \"That should be sorted now. Give it a refresh and let me know how it looks.\",\n];\n\nlet replyIndex = 0;\nexport function nextCannedReply(): string {\n const reply = cannedReplies[replyIndex % cannedReplies.length] as string;\n replyIndex += 1;\n return reply;\n}\n\nexport function agentById(id: string): Agent {\n return agents.find((a) => a.id === id) ?? (agents[2] as Agent);\n}\n","export function clockTime(iso?: string) {\n if (!iso) return new Date().toLocaleTimeString([], { hour: \"numeric\", minute: \"2-digit\" });\n return new Date(iso).toLocaleTimeString([], { hour: \"numeric\", minute: \"2-digit\" });\n}\n\nexport function dayLabel(iso?: string) {\n if (!iso) return (new Date().toLocaleDateString([], { weekday: \"long\", month: \"short\", day: \"numeric\" }));\n const date = new Date(iso);\n const today = new Date();\n const yesterday = new Date(Date.now() - 86_400_000);\n const sameDay = (a: Date, b: Date) => a.toDateString() === b.toDateString();\n if (sameDay(date, today)) return \"Today\";\n if (sameDay(date, yesterday)) return \"Yesterday\";\n return date.toLocaleDateString([], { weekday: \"long\", month: \"short\", day: \"numeric\" });\n}\n\nexport function relativeTime(iso: string) {\n const diff = Date.now() - new Date(iso).getTime();\n const minutes = Math.round(diff / 60_000);\n if (minutes < 1) return \"just now\";\n if (minutes < 60) return `${minutes}m ago`;\n const hours = Math.round(minutes / 60);\n if (hours < 24) return `${hours}h ago`;\n const days = Math.round(hours / 24);\n if (days < 7) return `${days}d ago`;\n return new Date(iso).toLocaleDateString([], { month: \"short\", day: \"numeric\" });\n}\n","<script setup lang=\"ts\">\nimport { ChevronRight, MessageSquarePlus } from \"@lucide/vue\";\nimport InitialsAvatar from \"@/components/widget/InitialsAvatar.vue\";\nimport Button from \"@/components/ui/Button.vue\";\nimport { brand } from \"@/lib/widget-data\";\nimport { relativeTime } from \"@/lib/widget-format\";\nimport { Chat } from \"@/lib/types\";\nimport { getInitialsFromFullName } from \"@/lib/utils\";\n\ndefineOptions({ name: \"ChatHome\" });\n\ndefineProps<{\n chats: Chat[];\n}>();\n\nconst emit = defineEmits<{\n open: [chat: Chat];\n startNew: [];\n}>();\n\nfunction chatTitle(chat: Chat) {\n return chat.title ?? chat.summary ?? chat.lastMessagePreview?.substring(0, 30) ?? 'Open conversation';\n}\n\nfunction chatPreview(chat: Chat) {\n // const agent = agentById(conversation.assignedStaffId);\n const last = chat.lastMessagePreview;\n return last\n ? `${chat.lastMessageSenderAccountType === \"staff\" ? (chat.assignedStaffFullName?.split(\" \")[0] ?? 'CS') : \"You\"}: ${last}`\n : \"No messages yet\";\n}\n</script>\n\n<template>\n <div class=\"flex min-h-0 flex-1 flex-col\">\n <header class=\"bg-brand-gradient px-6 pt-10 pb-12 text-primary-foreground sm:px-10 sm:pt-14\">\n <div class=\"mx-auto w-full max-w-2xl\">\n <p class=\"font-heading text-sm font-semibold tracking-wide opacity-90\">{{ brand.name }}</p>\n <h1 class=\"mt-4 font-heading text-3xl font-semibold sm:text-4xl\">{{ brand.greeting }}</h1>\n <p class=\"mt-2 max-w-md text-sm opacity-90 sm:text-base\">{{ brand.subline }}</p>\n </div>\n </header>\n\n <div class=\"min-h-0 flex-1 overflow-y-auto scrollbar-thin px-4 pt-6 pb-10 sm:px-10\">\n <div class=\"mx-auto w-full max-w-2xl space-y-3\">\n <button\n type=\"button\"\n class=\"flex w-full items-center gap-3 rounded-2xl border border-border bg-card p-4 text-left shadow-soft transition-colors hover:bg-accent/40\"\n @click=\"emit('startNew')\"\n >\n <span class=\"grid size-10 shrink-0 place-items-center rounded-full bg-primary/15 text-primary\">\n <MessageSquarePlus class=\"size-5\" />\n </span>\n <span class=\"min-w-0 flex-1\">\n <span class=\"block font-heading text-sm font-semibold\">Start a conversation</span>\n <span class=\"block text-xs text-muted-foreground\">{{ brand.replyTime }}</span>\n </span>\n <ChevronRight class=\"size-4 shrink-0 text-muted-foreground\" />\n </button>\n\n <template v-if=\"chats.length > 0\">\n <p class=\"px-1 pt-4 text-xs font-medium tracking-wide text-muted-foreground uppercase\">\n Your conversations\n </p>\n <ul class=\"space-y-2\">\n <li v-for=\"chat in chats\" :key=\"chat.id\">\n <button\n type=\"button\"\n class=\"flex w-full items-start gap-3 rounded-2xl border border-border bg-card p-4 text-left transition-colors hover:bg-accent/40\"\n @click=\"emit('open', chat)\"\n >\n <InitialsAvatar :initials=\"getInitialsFromFullName(chat.assignedStaffFullName ?? '')\" size=\"md\" tone=\"sage\" />\n <span class=\"min-w-0 flex-1\">\n <span class=\"flex items-center justify-between gap-2\">\n <span class=\"truncate font-heading text-sm font-semibold\">\n {{ chatTitle(chat) }}\n </span>\n <span class=\"shrink-0 text-[11px] text-muted-foreground\">\n {{ chat.lastMessagePreview ? relativeTime(chat.lastMessageSentAt ?? chat.updatedAt) : \"\" }}\n </span>\n </span>\n <span class=\"mt-0.5 block truncate text-xs text-muted-foreground\">\n {{ chatPreview(chat) }}\n </span>\n <span\n v-if=\"chat.closedAt\"\n class=\"mt-2 inline-flex rounded-full bg-muted px-2 py-0.5 text-[11px] text-muted-foreground\"\n >\n Closed\n </span>\n </span>\n </button>\n </li>\n </ul>\n </template>\n\n <div class=\"pt-6 text-center\">\n <!-- onClick was a no-op in the original (onStartNew commented out) -->\n <Button variant=\"ghost\" size=\"sm\" class=\"text-xs text-muted-foreground\" @click=\"() => {}\">\n Can't find what you need? Message us\n </Button>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { HTMLAttributes } from \"vue\";\nimport { cn } from \"@/lib/utils\";\n\ndefineOptions({ name: \"Textarea\" });\n\n// Other attributes and listeners (placeholder, aria-label, onKeydown, onFocus,\n// onBlur, ...) fall through to the <textarea>.\nconst props = defineProps<{\n modelValue?: string;\n class?: HTMLAttributes[\"class\"];\n}>();\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n}>();\n</script>\n\n<template>\n <textarea\n :class=\"\n cn(\n 'flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n props.class,\n )\n \"\n :value=\"props.modelValue\"\n @input=\"emit('update:modelValue', ($event.target as HTMLTextAreaElement).value)\"\n />\n</template>\n","/**\n * Runtime configuration for the SDK.\n *\n * In the original web app these values came from VITE_* environment variables\n * (VITE_API_BASE_URL, VITE_SOCKET_BASE_URL, VITE_API_KEY, VITE_API_SECRET).\n * As a library they are supplied by the host app, either through the\n * <KiliChat :config=\"...\" /> prop or by calling configureKili() directly.\n */\nexport type KiliConfig = {\n /** Base URL of the Kili REST API, e.g. \"https://api.kili.africa\" */\n apiBaseUrl: string;\n /** Base URL of the Kili socket server. Defaults to apiBaseUrl. */\n socketBaseUrl?: string;\n /** Organisation API key */\n apiKey: string;\n /** Organisation API secret */\n apiSecret: string;\n};\n\nlet currentConfig: KiliConfig | null = null;\n\nexport function configureKili(config: KiliConfig) {\n currentConfig = config;\n}\n\nexport function getKiliConfig(): KiliConfig {\n if (!currentConfig) {\n throw new Error(\n \"Kili SDK is not configured. Render <KiliChat :config=\\\"...\\\" /> or call configureKili() first.\",\n );\n }\n return currentConfig;\n}\n\nexport function getSocketBaseUrl(): string {\n const config = getKiliConfig();\n return config.socketBaseUrl ?? config.apiBaseUrl;\n}\n\n","import axios from 'axios';\nimport { LocalStorageKeys } from './storage-keys';\nimport { getKiliConfig } from './config';\n\nconst http = axios.create();\n\nhttp.interceptors.request.use((req) => {\n const config = getKiliConfig();\n req.baseURL = config.apiBaseUrl;\n req.headers['Api-Key'] = config.apiKey;\n req.headers['Api-Secret'] = config.apiSecret;\n\n const token = localStorage.getItem(LocalStorageKeys.JwtAccessToken);\n if (token) req.headers['Authorization'] = `Bearer ${token}`;\n return req;\n});\n\nexport default http;\n","import http from '@/lib/http';\n\nconst chatService = {\n async getAllChats(userId: number) {\n const res = await http.get(`/chats?customerId=${userId}`);\n return res.data.data;\n },\n\n async getChatMessages(chatId: number) {\n const res = await http.get(`/chats/${chatId}/messages`);\n return res.data.data;\n },\n\n async startChat() {\n const res = await http.post('/chats', { initiationChannel: 'web_widget' });\n return res.data.data;\n },\n\n async sendMessage() {},\n\n async markMessageAsRead() {}\n}\n\nexport default chatService;","<script setup lang=\"ts\">\nimport { computed, onMounted, ref, watch } from \"vue\";\nimport { ArrowLeft, Paperclip, Send, Smile } from \"@lucide/vue\";\n\nimport InitialsAvatar from \"@/components/widget/InitialsAvatar.vue\";\nimport Button from \"@/components/ui/Button.vue\";\nimport Textarea from \"@/components/ui/Textarea.vue\";\nimport { brand } from \"@/lib/widget-data\";\nimport { clockTime, dayLabel } from \"@/lib/widget-format\";\nimport { Chat } from \"@/lib/types\";\nimport { useApp } from \"@/context/state\";\nimport { getInitialsFromFullName, getInitialsFromNames } from \"@/lib/utils\";\nimport chatService from \"@/services/chat.service\";\n\ndefineOptions({ name: \"ChatThread\" });\n\nconst props = defineProps<{\n chat: Chat;\n draft: string;\n typing: boolean;\n}>();\n\nconst emit = defineEmits<{\n \"update:draft\": [value: string];\n send: [];\n back: [];\n textfieldFocus: [];\n textfieldBlur: [];\n}>();\n\nconst bottomRef = ref<HTMLDivElement | null>(null);\nconst state = useApp();\n\nconst agentInitials = computed(() => getInitialsFromFullName(props.chat.assignedStaffFullName));\nconst customerInitials = computed(() => getInitialsFromFullName(props.chat.customerFullName));\nconst agentFirstName = computed(() => props.chat.assignedStaffFullName?.split(\" \")[0]);\n\nconst loadChatHistory = async () => {\n const messages = await chatService.getChatMessages(props.chat.id);\n state.setMessages(messages.data);\n}\n\nconst scrollToBottom = () => {\n bottomRef.value?.scrollIntoView({ behavior: \"smooth\", block: \"end\" });\n};\n\nwatch(() => [state.messages.length, props.typing], scrollToBottom, { flush: \"post\" });\n\nonMounted(() => {\n scrollToBottom();\n loadChatHistory();\n});\n\nfunction showDay(i: number) {\n const m = state.messages[i];\n const prev = state.messages[i - 1];\n return !prev || dayLabel(prev.sentAt) !== dayLabel(m?.sentAt);\n}\n\n// The original keyed every message row with a fresh UUID on each render.\nconst randomKey = () => crypto.randomUUID();\n\nfunction onKeydown(e: KeyboardEvent) {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n emit(\"send\");\n }\n}\n\nconst dotDelays = [\"0ms\", \"150ms\", \"300ms\"];\n</script>\n\n<template>\n <div class=\"flex min-h-0 flex-1 flex-col bg-surface\">\n <header class=\"border-b border-border bg-card px-4 py-3 sm:px-6\">\n <div class=\"mx-auto flex w-full max-w-2xl items-center gap-3\">\n <Button variant=\"ghost\" size=\"icon\" class=\"size-8 shrink-0\" aria-label=\"Back\" @click=\"emit('back')\">\n <ArrowLeft class=\"size-4\" />\n </Button>\n <InitialsAvatar :initials=\"agentInitials\" size=\"md\" tone=\"sage\" />\n <div class=\"min-w-0 flex-1\">\n <p class=\"truncate font-heading text-sm font-semibold\">{{ props.chat.assignedStaffFullName }}</p>\n <p class=\"truncate text-xs text-muted-foreground\">\n {{ props.typing ? `${agentFirstName} is typing…` : brand.replyTime }}\n </p>\n </div>\n </div>\n </header>\n\n <div class=\"min-h-0 flex-1 overflow-y-auto scrollbar-thin px-4 py-6 sm:px-6\">\n <div class=\"mx-auto w-full max-w-2xl space-y-4\">\n <div\n v-if=\"!!state.messages.length\"\n class=\"rounded-2xl border border-dashed border-border bg-card/60 p-6 text-center\"\n >\n <InitialsAvatar\n :initials=\"getInitialsFromFullName(props.chat.assignedStaffFullName)\"\n size=\"lg\"\n tone=\"sage\"\n class=\"mx-auto\"\n />\n <p class=\"mt-3 font-heading text-sm font-semibold\">Say hello to {{ agentFirstName }}</p>\n <p class=\"mt-1 text-xs text-muted-foreground\">\n Describe what you need help with and we'll take it from there.\n </p>\n </div>\n\n <div v-for=\"(m, i) in state.messages\" :key=\"randomKey()\" class=\"space-y-4\">\n <div v-if=\"showDay(i)\" class=\"flex items-center gap-3\">\n <span class=\"h-px flex-1 bg-border\" />\n <span class=\"text-[11px] text-muted-foreground\">{{ dayLabel(m.sentAt) }}</span>\n <span class=\"h-px flex-1 bg-border\" />\n </div>\n\n <div v-if=\"m.senderAccountType === 'staff'\" class=\"flex max-w-[80%] items-end gap-2\">\n <InitialsAvatar :initials=\"getInitialsFromNames(m.senderFirstName, m.senderLastName)\" size=\"sm\" tone=\"sage\" />\n <div class=\"rounded-2xl rounded-bl-sm border border-border bg-card px-4 py-2.5\">\n <p class=\"text-sm whitespace-pre-wrap\">{{ m.content }}</p>\n <p class=\"mt-1 text-[11px] text-muted-foreground\">\n {{ m.senderFirstName }} · {{ clockTime(m.sentAt) }}\n </p>\n </div>\n </div>\n <div v-else class=\"ml-auto flex max-w-[80%] flex-row-reverse items-end gap-2\">\n <InitialsAvatar :initials=\"customerInitials\" size=\"sm\" tone=\"muted\" />\n <div class=\"rounded-2xl rounded-br-sm bg-primary px-4 py-2.5 text-primary-foreground\">\n <p class=\"text-sm whitespace-pre-wrap\">{{ m.content }}</p>\n <p class=\"mt-1 text-[11px] opacity-80\">{{ clockTime(m.sentAt) }} · Sent</p>\n </div>\n </div>\n </div>\n\n <div v-if=\"props.typing\" class=\"flex max-w-[80%] items-end gap-2\">\n <InitialsAvatar :initials=\"agentInitials\" size=\"sm\" tone=\"sage\" />\n <div class=\"flex items-center gap-1 rounded-2xl rounded-bl-sm border border-border bg-card px-4 py-3\">\n <span\n v-for=\"delay in dotDelays\"\n :key=\"delay\"\n class=\"size-1.5 animate-bounce rounded-full bg-muted-foreground/60\"\n :style=\"{ animationDelay: delay }\"\n />\n </div>\n </div>\n\n <div ref=\"bottomRef\" />\n </div>\n </div>\n\n <div class=\"border-t border-border bg-card px-4 py-3 sm:px-6\">\n <div class=\"mx-auto w-full max-w-2xl\">\n <div class=\"flex items-end gap-2\">\n <Textarea\n :model-value=\"props.draft\"\n placeholder=\"Write a message…\"\n aria-label=\"Write a message\"\n class=\"max-h-40 min-h-[44px] flex-1 resize-none bg-background text-sm\"\n @update:model-value=\"emit('update:draft', $event)\"\n @keydown=\"onKeydown\"\n @focus=\"emit('textfieldFocus')\"\n @blur=\"emit('textfieldBlur')\"\n />\n <Button\n size=\"icon\"\n class=\"size-10 shrink-0\"\n :disabled=\"!props.draft.trim()\"\n aria-label=\"Send\"\n @click=\"emit('send')\"\n >\n <Send class=\"size-4\" />\n </Button>\n </div>\n <div class=\"mt-2 flex items-center gap-2 text-muted-foreground\">\n <Paperclip class=\"size-4\" aria-hidden=\"true\" />\n <Smile class=\"size-4\" aria-hidden=\"true\" />\n <span class=\"ml-auto text-[11px]\">Enter to send · Shift + Enter for a new line</span>\n </div>\n </div>\n </div>\n </div>\n</template>\n","export const SocketEvent = Object.freeze({\n Connection: 'connection',\n Disconnect: 'disconnect',\n Error: 'error',\n\n AssignChat: 'assign_chat',\n ChatAction: 'chat_action',\n ChatAssigned: 'chat_assigned',\n ChatDeassigned: 'chat_deassigned',\n ChatStarted: 'chat_started',\n ChatUpdated: 'chat_updated',\n ChatWindowClosed: 'chat_window_closed',\n ChatWindowOpened: 'chat_window_opened',\n CloseChat: 'close_chat',\n InternalNote: 'internal_note',\n JoinAllUnclosedChatRooms: 'join_all_unclosed_chat_rooms',\n JoinChatRoom: 'join_chat_room',\n JoinedChatRoom: 'joined_chat_room',\n LeaveRoom: 'leave_room',\n MarkMsgAsRead: 'mark_msg_as_read',\n Message: 'message',\n MessageDelivered: 'message_delivered',\n NewMention: 'new_mention',\n PrioritizeChat: 'prioritize_chat',\n RefetchChats: 'refetch_chats',\n ReopenChat: 'reopen_chat',\n RefetchChatCounts: 'refetch_chat_counts',\n SnoozeChat: 'snooze_chat',\n StartChat: 'start_chat',\n});","<script setup lang=\"ts\">\nimport { onBeforeUnmount, ref, watch } from \"vue\";\nimport ChatHome from \"@/components/widget/ChatHome.vue\";\nimport ChatThread from \"@/components/widget/ChatThread.vue\";\nimport chatService from \"@/services/chat.service\";\nimport { SocketEvent } from \"@/lib/socket-events\";\nimport { getKiliConfig, getSocketBaseUrl } from \"@/lib/config\";\nimport { LocalStorageKeys, SessionStorageKeys } from \"@/lib/storage-keys\";\nimport { Chat, ChatAction, Customer, Message } from \"@/lib/types\";\nimport { Socket, io } from \"socket.io-client\";\nimport { useApp } from \"@/context/state\";\n\ndefineOptions({ name: \"ChatWidget\" });\n\nconst draft = ref(\"\");\nconst typing = ref(false);\nconst timers: ReturnType<typeof setTimeout>[] = [];\nconst state = useApp();\nconst activeChat = ref<Chat | null>(null);\n// Plain (non-reactive) holder, like React's useRef.\nconst socketRef: { current: Socket | null } = { current: null };\n\nconst appendMessage = (msg: Message) => {\n const chatJson = sessionStorage.getItem(SessionStorageKeys.ActiveChat);\n if (!chatJson) return;\n const chat = JSON.parse(chatJson);\n if (msg.chatId == chat.id) {\n state?.appendMessage(msg);\n }\n};\n\nconst handleChatAction = (action: { action: ChatAction, chatId: number }) => {\n switch (action.action) {\n case 'typing.started':\n typing.value = true;\n break;\n case 'typing.stopped':\n typing.value = false;\n break;\n case 'uploading_file.started':\n case 'uploading_file.stopped':\n default:\n break;\n }\n}\n\nconst handleChatStarted = async (chat: Chat) => {\n const user = JSON.parse(localStorage.getItem(LocalStorageKeys.User)!);\n if (chat.customerId != user.id) {\n console.log('chat created by a different cstomer');\n return;\n }\n\n socketRef.current?.emit(SocketEvent.JoinChatRoom, chat.id);\n\n const chats = await chatService.getAllChats(user.id);\n state?.setChats(chats.data);\n\n persistActiveChat(chat);\n}\n\nconst updateChat = (chat: Chat) => {\n const acJson = sessionStorage.getItem(SessionStorageKeys.ActiveChat);\n if (!acJson) return;\n const ac: Chat = JSON.parse(acJson);\n if (ac && ac.id === chat.id) {\n activeChat.value = chat;\n }\n}\n\nconst persistActiveChat = (c: Chat | null) => {\n activeChat.value = c;\n if (!c) {\n sessionStorage.removeItem(SessionStorageKeys.ActiveChat);\n } else {\n sessionStorage.setItem(SessionStorageKeys.ActiveChat, JSON.stringify(c));\n }\n}\n\nonBeforeUnmount(() => {\n timers.forEach(clearTimeout);\n});\n\nwatch(\n () => [state.user, state.accessToken],\n () => {\n if (!state || !state.user || !state.accessToken) return;\n if (socketRef.current) return;\n const socket = io(getSocketBaseUrl(), {\n extraHeaders: {\n 'Api-Key': getKiliConfig().apiKey,\n 'Api-Secret': getKiliConfig().apiSecret,\n 'Authorization': `Bearer ${state.accessToken}`\n },\n });\n\n socket.on('connect', () => {\n console.log('socket connected');\n socket.emit(SocketEvent.JoinAllUnclosedChatRooms);\n socket.on(SocketEvent.ChatAction, handleChatAction);\n socket.on(SocketEvent.ChatStarted, handleChatStarted);\n socket.on(SocketEvent.ChatUpdated, updateChat);\n socket.on(SocketEvent.MessageDelivered, appendMessage);\n });\n socket.on(SocketEvent.Disconnect, () => {\n console.log('socket disconnected');\n });\n socket.on(SocketEvent.Error, (err) => {\n console.log(socket.id, 'has an error', err);\n });\n socketRef.current = socket;\n },\n { immediate: true },\n);\n\nconst sendMessage = () => {\n if (!activeChat.value) return;\n const user: Customer = state?.user ?? JSON.parse(localStorage.getItem(LocalStorageKeys.User)!);\n const msg: Partial<Message> = {\n chatId: Number(activeChat.value.id),\n content: draft.value.trim(),\n senderEmail: user.email!,\n senderId: user.id,\n sentAt: new Date().toISOString(),\n senderAccountType: 'CUSTOMER',\n senderFirstName: user.firstName!,\n senderLastName: user.lastName!,\n type: 'TEXT',\n };\n socketRef.current!.emit(SocketEvent.ChatAction, {\n action: 'typing.stopped',\n chatId: activeChat.value.id,\n });\n socketRef.current!.emit(SocketEvent.Message, msg);\n draft.value = '';\n};\n\nconst startChatOld = async () => {\n const chat = await chatService.startChat();\n socketRef.current?.emit(SocketEvent.JoinChatRoom, { chatId: chat.id });\n\n const user = JSON.parse(localStorage.getItem(LocalStorageKeys.User)!);\n const chats = await chatService.getAllChats(user.id);\n state?.setChats(chats.data);\n\n persistActiveChat(chat);\n draft.value = \"\";\n};\n\nconst startChat = () => {\n socketRef?.current?.emit(SocketEvent.StartChat, { initiationChannel: 'web_widget' });\n draft.value = \"\";\n};\n\nconst onBack = () => {\n persistActiveChat(null);\n typing.value = false;\n};\n\nconst onTextFieldBlur = () => {\n socketRef.current?.emit(SocketEvent.ChatAction, {\n action: 'typing.stopped',\n chatId: activeChat.value?.id,\n });\n};\n\nconst onTextfieldFocus = () => {\n socketRef.current?.emit(SocketEvent.ChatAction, {\n action: 'typing.started',\n chatId: activeChat.value?.id,\n });\n};\n\nconst onOpen = (c: Chat) => {\n persistActiveChat(c);\n draft.value = \"\";\n};\n</script>\n\n<template>\n <div v-if=\"state\" class=\"kili-root flex h-dvh w-full flex-col overflow-hidden bg-background\">\n <ChatThread\n v-if=\"activeChat\"\n v-model:draft=\"draft\"\n :chat=\"activeChat\"\n :typing=\"typing\"\n @send=\"sendMessage\"\n @back=\"onBack\"\n @textfield-blur=\"onTextFieldBlur\"\n @textfield-focus=\"onTextfieldFocus\"\n />\n <ChatHome v-else :chats=\"state.chats\" @open=\"onOpen\" @start-new=\"startChat\" />\n </div>\n</template>\n","import { LocalStorageKeys } from '@/lib/storage-keys';\nimport randomName from '@scaleway/random-name';\nimport http from '@/lib/http';\n\nconst coreService = {\n async createCustomer() {\n let user = localStorage.getItem(LocalStorageKeys.User);\n if (user) return JSON.parse(user);\n\n const [fname, lname] = randomName('', ' ').split(' ');\n const res = await http.post('/customers', {\n city: 'Denver',\n country: 'united states',\n device: 'iPhone 17 pro',\n email: `${fname}.${lname}@kili.africa`,\n firstName: fname,\n id: crypto.randomUUID(),\n lastName: lname,\n phoneCountryCode: '1',\n phoneNumberSuffix: '1234567',\n state: 'Colorado',\n });\n console.dir({ createdCustomer: res.data }, { depth: null });\n localStorage.setItem(LocalStorageKeys.User, JSON.stringify(res.data.data));\n return res.data.data;\n },\n\n async registerCustomer() {\n const data = localStorage.getItem(LocalStorageKeys.User);\n const user = JSON.parse(data!);\n const res = await http.put('/customers', {\n id: user.userId,\n email: user.email,\n });\n localStorage.setItem(LocalStorageKeys.JwtAccessToken, res.data.data.accessToken)\n localStorage.setItem(LocalStorageKeys.AccessTokenExp, res.data.data.expiresAt );\n return res.data.data;\n },\n\n async setCustomerHmac() {\n /**\n * check if there is a user\n * if no user, create user and save\n * get existing user\n * use the user id to set hmac\n */\n const data = localStorage.getItem(LocalStorageKeys.User);\n const user = JSON.parse(data!);\n const hmac = crypto.randomUUID();\n await http.patch(`/customers/${user.userId}/hmac`, { hmac });\n },\n}\n\nexport default coreService;","<script setup lang=\"ts\">\nimport { onMounted } from \"vue\";\nimport ChatWidget from \"@/components/widget/ChatWidget.vue\";\nimport coreService from \"@/services/core.service\";\nimport chatService from \"@/services/chat.service\";\nimport { useApp } from \"@/context/state\";\n\ndefineOptions({ name: \"KiliChatBootstrap\" });\n\nconst state = useApp();\n\nconst onMount = async () => {\n const customer = await coreService.createCustomer();\n await coreService.setCustomerHmac();\n const auth = await coreService.registerCustomer();\n\n state?.setUser(customer);\n state?.setAccessToken(auth.accessToken);\n\n const chats = await chatService.getAllChats(customer.id);\n state?.setChats(chats.data);\n}\n\nonMounted(() => {\n onMount();\n});\n</script>\n\n<template>\n <ChatWidget />\n</template>\n","<script setup lang=\"ts\">\nimport { watch } from \"vue\";\nimport AppStateProvider from \"@/context/AppStateProvider.vue\";\nimport KiliChatBootstrap from \"./KiliChatBootstrap.vue\";\nimport { configureKili } from \"@/lib/config\";\nimport type { KiliChatProps } from \"./kili-chat\";\n\n/**\n * Drop-in Kili support chat. This is the library equivalent of the\n * kili-customer-fe \"/\" route: it wraps the widget in the app state provider\n * and bootstraps the customer session on mount.\n */\ndefineOptions({ name: \"KiliChat\" });\n\nconst props = defineProps<KiliChatProps>();\n\n// Configure synchronously during setup so the config is in place before any\n// child runs (e.g. the socket connection in ChatWidget), and again whenever\n// the host app passes a new config.\nconfigureKili(props.config);\nwatch(() => props.config, (config) => configureKili(config), { deep: true });\n</script>\n\n<template>\n <AppStateProvider>\n <KiliChatBootstrap />\n </AppStateProvider>\n</template>\n","import type { Socket } from 'socket.io-client';\nimport { inject, type InjectionKey, type ShallowRef } from 'vue';\n\nexport const SocketContext: InjectionKey<ShallowRef<Socket | null>> = Symbol('KiliSocket');\n\n/** Returns the socket provided by SocketProvider (null until it connects). */\nexport function useSocket(): ShallowRef<Socket | null> | null {\n return inject(SocketContext, null);\n}\n","<script setup lang=\"ts\">\nimport { io, Socket } from 'socket.io-client';\nimport { inject, provide, shallowRef, watch } from 'vue';\nimport { AppStateContext } from './state';\nimport { SocketContext } from './socket';\nimport { SocketEvent } from '@/lib/socket-events';\nimport { getKiliConfig, getSocketBaseUrl } from '@/lib/config';\n\nconst socket = shallowRef<Socket | null>(null);\nconst state = inject(AppStateContext, null);\n\nwatch(\n () => [state?.user, state?.accessToken],\n () => {\n if (!state || !state.user || !state.accessToken) return;\n if (socket.value) return;\n const socketClient = io(getSocketBaseUrl(), {\n extraHeaders: {\n 'Api-Key': getKiliConfig().apiKey,\n 'Api-Secret': getKiliConfig().apiSecret,\n 'Authorization': `Bearer ${state.accessToken}`\n },\n });\n\n socketClient.on('connect', () => {\n console.log(socketClient.id, 'connected to the socket');\n socketClient.emit(SocketEvent.JoinAllUnclosedChatRooms);\n socketClient.on(SocketEvent.JoinedChatRoom, (roomId) => console.log('joined chat room', roomId));\n });\n socketClient.on(SocketEvent.Disconnect, () => {\n console.log(socketClient.id, 'has disconnected from the socket');\n });\n socketClient.on(SocketEvent.Error, (err) => {\n console.log(socketClient.id, 'has an error', err);\n });\n socket.value = socketClient;\n },\n { immediate: true },\n);\n\nprovide(SocketContext, socket);\n</script>\n\n<template>\n <slot />\n</template>\n","import { computed, onBeforeUnmount, onMounted, ref, type ComputedRef } from \"vue\";\n\nconst MOBILE_BREAKPOINT = 768;\n\nexport function useIsMobile(): ComputedRef<boolean> {\n const isMobile = ref<boolean | undefined>(undefined);\n let mql: MediaQueryList | null = null;\n\n const onChange = () => {\n isMobile.value = window.innerWidth < MOBILE_BREAKPOINT;\n };\n\n onMounted(() => {\n mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);\n mql.addEventListener(\"change\", onChange);\n isMobile.value = window.innerWidth < MOBILE_BREAKPOINT;\n });\n\n onBeforeUnmount(() => mql?.removeEventListener(\"change\", onChange));\n\n return computed(() => !!isMobile.value);\n}\n"],"mappings":"A,myBAAA,IAAaoI,EAAmB,CAC9B,eAAgB,QAChB,eAAgB,KAChB,gBAAiB,KACjB,KAAM,GACR,EAEaC,EAAqB,CAChC,WAAY,IACd,ECUaC,EAA0C,OAAO,cAAc,EAG5E,SAAgBC,GAA2B,CACzC,IAAMC,GAAA,EAAkBxI,EAAAA,SAAAA,CAAS,CAC/B,YAAa,KACb,MAAO,CAAC,EACR,SAAU,CAAC,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CAClD,IAAMC,GAAA,EAAWlO,EAAAA,IAAAA,CAAyB,IAAA,EAAS,EAC/CmO,EAA6B,KAE3BC,MAAiB,CACrB,EAAS,MAAQ,OAAO,WAAaJ,CACvC,EAUA,OARA,EAAA1M,EAAA,UAAA,KAAgB,CACd,EAAM,OAAO,WAAW,oBAAyC,EACjE6M,EAAI,iBAAiB,SAAUC,CAAQ,EACvC,EAAS,MAAQ,OAAO,WAAaJ,CACvC,CAAC,GAED,EAAA1M,EAAA,gBAAA,KAAsB6M,GAAK,oBAAoB,SAAUC,CAAQ,CAAC,GAElE,EAAOnO,EAAAA,SAAAA,KAAe,CAAC,CAACiO,EAAS,KAAK,CACxC,C"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { default as KiliChat } from './KiliChat.vue';
|
|
2
|
+
export type { KiliChatProps } from './kili-chat';
|
|
3
|
+
export { configureKili, getKiliConfig, type KiliConfig } from './lib/config';
|
|
4
|
+
export { default as ChatWidget } from './components/widget/ChatWidget.vue';
|
|
5
|
+
export { default as ChatHome } from './components/widget/ChatHome.vue';
|
|
6
|
+
export { default as ChatThread } from './components/widget/ChatThread.vue';
|
|
7
|
+
export { default as InitialsAvatar } from './components/widget/InitialsAvatar.vue';
|
|
8
|
+
export { default as Button } from './components/ui/Button.vue';
|
|
9
|
+
export { buttonVariants, type ButtonProps } from './components/ui/button';
|
|
10
|
+
export { Slot } from './components/ui/slot';
|
|
11
|
+
export { default as Textarea } from './components/ui/Textarea.vue';
|
|
12
|
+
export { default as AppStateProvider } from './context/AppStateProvider.vue';
|
|
13
|
+
export { AppStateContext, createAppState, provideAppState, useApp, type AppState } from './context/state';
|
|
14
|
+
export { default as SocketProvider } from './context/SocketProvider.vue';
|
|
15
|
+
export { SocketContext, useSocket } from './context/socket';
|
|
16
|
+
export { useIsMobile } from './composables/use-mobile';
|
|
17
|
+
export { default as chatService } from './services/chat.service';
|
|
18
|
+
export { default as coreService } from './services/core.service';
|
|
19
|
+
export { default as http } from './lib/http';
|
|
20
|
+
export { SocketEvent } from './lib/socket-events';
|
|
21
|
+
export { LocalStorageKeys, SessionStorageKeys } from './lib/storage-keys';
|
|
22
|
+
export { cn, getInitialsFromFullName, getInitialsFromNames } from './lib/utils';
|
|
23
|
+
export { clockTime, dayLabel, relativeTime } from './lib/widget-format';
|
|
24
|
+
export * from './lib/widget-data';
|
|
25
|
+
export type { Chat, ChatAction, Customer, Message } from './lib/types';
|