@liyalabs/liya-ai-chat-react 1.0.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 ADDED
@@ -0,0 +1,231 @@
1
+ # @liyalabs/liya-ai-chat-react
2
+
3
+ React Chat Widget & Full App Component for Liya AI Assistants.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Two Modes**: Widget (floating chatbox) & App (full chat interface)
8
+ - 💬 **Real-time Chat**: Send messages and receive AI responses
9
+ - 📁 **File Upload**: Attach files to your messages
10
+ - 🎤 **Voice Input**: Speech-to-text support
11
+ - 📜 **Session History**: Browse and continue previous conversations
12
+ - 🎯 **Customizable**: Theme, colors, position, and more
13
+ - 📱 **Responsive**: Mobile-friendly design
14
+ - 🔒 **TypeScript**: Full type support
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @liyalabs/liya-ai-chat-react
20
+ # or
21
+ yarn add @liyalabs/liya-ai-chat-react
22
+ # or
23
+ pnpm add @liyalabs/liya-ai-chat-react
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ### Widget Mode (Website Helper)
29
+
30
+ ```tsx
31
+ import React from 'react'
32
+ import { LiyaChatProvider, LiyaChatWidget } from '@liyalabs/liya-ai-chat-react'
33
+ import '@liyalabs/liya-ai-chat-react/style.css'
34
+
35
+ function App() {
36
+ return (
37
+ <LiyaChatProvider config={{
38
+ apiKey: 'liwhai_your_api_key_here',
39
+ baseUrl: 'https://app-1-ai.liyalabs.com',
40
+ assistantId: 'your-assistant-uuid',
41
+ assistantName: 'Destek Asistanı',
42
+ }}>
43
+ <div>
44
+ <h1>My Website</h1>
45
+ <LiyaChatWidget
46
+ position="bottom-right"
47
+ theme={{ primaryColor: '#6366f1' }}
48
+ welcomeMessage="Merhaba! Size nasıl yardımcı olabilirim?"
49
+ showVoice={true}
50
+ showFileUpload={true}
51
+ />
52
+ </div>
53
+ </LiyaChatProvider>
54
+ )
55
+ }
56
+ ```
57
+
58
+ ### App Mode (Full Chat Application)
59
+
60
+ ```tsx
61
+ import React from 'react'
62
+ import { LiyaChatProvider, LiyaChatApp } from '@liyalabs/liya-ai-chat-react'
63
+ import '@liyalabs/liya-ai-chat-react/style.css'
64
+
65
+ function App() {
66
+ return (
67
+ <LiyaChatProvider config={{
68
+ apiKey: 'liwhai_your_api_key_here',
69
+ baseUrl: 'https://app-1-ai.liyalabs.com',
70
+ assistantId: 'your-assistant-uuid',
71
+ assistantName: 'AI Assistant',
72
+ }}>
73
+ <div style={{ height: '100vh' }}>
74
+ <LiyaChatApp
75
+ showSidebar={true}
76
+ sidebarWidth="320px"
77
+ welcomeMessage="Merhaba! Yeni bir sohbet başlatın."
78
+ showVoice={true}
79
+ showFileUpload={true}
80
+ onSessionCreated={(session) => console.log('New session:', session)}
81
+ onMessageSent={(message) => console.log('Sent:', message)}
82
+ />
83
+ </div>
84
+ </LiyaChatProvider>
85
+ )
86
+ }
87
+ ```
88
+
89
+ ## Configuration
90
+
91
+ ### Provider Config
92
+
93
+ | Option | Type | Required | Description |
94
+ |--------|------|----------|-------------|
95
+ | `apiKey` | `string` | Yes | Your Liya API key |
96
+ | `baseUrl` | `string` | Yes | API base URL |
97
+ | `assistantId` | `string` | Yes | Assistant UUID |
98
+ | `assistantName` | `string` | No | Display name for the assistant |
99
+
100
+ ### Theme Configuration
101
+
102
+ ```typescript
103
+ interface ThemeConfig {
104
+ primaryColor?: string // Main brand color (default: #6366f1)
105
+ secondaryColor?: string // Secondary color
106
+ backgroundColor?: string // Background color
107
+ textColor?: string // Text color
108
+ fontFamily?: string // Font family
109
+ borderRadius?: string // Border radius
110
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
111
+ zIndex?: number // Z-index for widget
112
+ }
113
+ ```
114
+
115
+ ## Components
116
+
117
+ ### LiyaChatWidget
118
+
119
+ Floating chat widget for websites.
120
+
121
+ ```tsx
122
+ <LiyaChatWidget
123
+ position="bottom-right"
124
+ theme={{ primaryColor: '#6366f1' }}
125
+ welcomeMessage="Merhaba!"
126
+ placeholder="Mesajınızı yazın..."
127
+ showBranding={true}
128
+ showVoice={true}
129
+ showFileUpload={true}
130
+ onOpen={() => console.log('Widget opened')}
131
+ onClose={() => console.log('Widget closed')}
132
+ onMessageSent={(msg) => console.log('Sent:', msg)}
133
+ onMessageReceived={(msg) => console.log('Received:', msg)}
134
+ />
135
+ ```
136
+
137
+ ### LiyaChatApp
138
+
139
+ Full chat application with sidebar.
140
+
141
+ ```tsx
142
+ <LiyaChatApp
143
+ theme={{ primaryColor: '#6366f1' }}
144
+ showSidebar={true}
145
+ sidebarWidth="300px"
146
+ welcomeMessage="Yeni sohbet başlatın"
147
+ placeholder="Mesajınızı yazın..."
148
+ showVoice={true}
149
+ showFileUpload={true}
150
+ onSessionCreated={(session) => {}}
151
+ onSessionSelected={(session) => {}}
152
+ onSessionDeleted={(sessionId) => {}}
153
+ onMessageSent={(message) => {}}
154
+ onMessageReceived={(message) => {}}
155
+ />
156
+ ```
157
+
158
+ ## Hooks
159
+
160
+ Use hooks for custom implementations:
161
+
162
+ ```typescript
163
+ import { useChat, useSessions, useVoice, useFileUpload } from '@liyalabs/liya-ai-chat-react'
164
+
165
+ function CustomChat() {
166
+ const { messages, isLoading, sendMessage, loadHistory } = useChat()
167
+ const { sessions, createSession, deleteSession } = useSessions()
168
+ const { isRecording, startRecording, stopRecording } = useVoice()
169
+ const { pendingFiles, addFiles, uploadFiles } = useFileUpload()
170
+
171
+ // Build your custom UI
172
+ }
173
+ ```
174
+
175
+ ## API Functions
176
+
177
+ Direct API access:
178
+
179
+ ```typescript
180
+ import {
181
+ sendMessage,
182
+ getSessions,
183
+ createSession,
184
+ getSessionHistory,
185
+ uploadFile
186
+ } from '@liyalabs/liya-ai-chat-react'
187
+
188
+ // Send a message
189
+ const response = await sendMessage('Hello!', sessionId)
190
+
191
+ // Get sessions
192
+ const { sessions } = await getSessions()
193
+
194
+ // Create new session
195
+ const session = await createSession('New Chat')
196
+ ```
197
+
198
+ ## Styling
199
+
200
+ ### CSS Variables
201
+
202
+ ```css
203
+ :root {
204
+ --liya-primary-color: #6366f1;
205
+ --liya-primary-hover: #4f46e5;
206
+ --liya-bg-color: #ffffff;
207
+ --liya-bg-secondary: #f3f4f6;
208
+ --liya-text-color: #374151;
209
+ --liya-text-muted: #9ca3af;
210
+ --liya-border-color: #e5e7eb;
211
+ --liya-border-radius: 12px;
212
+ }
213
+ ```
214
+
215
+ ## TypeScript
216
+
217
+ Full TypeScript support:
218
+
219
+ ```typescript
220
+ import type {
221
+ LiyaChatConfig,
222
+ ThemeConfig,
223
+ Session,
224
+ Message,
225
+ FileAttachment
226
+ } from '@liyalabs/liya-ai-chat-react'
227
+ ```
228
+
229
+ ## License
230
+
231
+ MIT © Liya Labs
@@ -0,0 +1,4 @@
1
+ import { SendMessageResponse, SessionHistoryResponse } from '../types';
2
+
3
+ export declare function sendMessage(message: string, sessionId?: string, fileIds?: string[]): Promise<SendMessageResponse>;
4
+ export declare function getSessionHistory(sessionId: string, limit?: number, offset?: number): Promise<SessionHistoryResponse>;
@@ -0,0 +1,7 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { LiyaChatConfig } from '../types';
3
+
4
+ export declare function initializeClient(config: LiyaChatConfig): AxiosInstance;
5
+ export declare function getClient(): AxiosInstance;
6
+ export declare function getConfig(): LiyaChatConfig;
7
+ export declare function isInitialized(): boolean;
@@ -0,0 +1,7 @@
1
+ import { FileAttachment } from '../types';
2
+
3
+ export declare function uploadFile(sessionId: string, file: File): Promise<FileAttachment>;
4
+ export declare function formatFileSize(bytes: number): string;
5
+ export declare function isValidFileType(file: File, allowedTypes?: string[]): boolean;
6
+ export declare const DEFAULT_ALLOWED_FILE_TYPES: string[];
7
+ export declare const MAX_FILE_SIZE: number;
@@ -0,0 +1,4 @@
1
+ export { initializeClient, getClient, getConfig, isInitialized } from './client';
2
+ export { sendMessage, getSessionHistory } from './chat';
3
+ export { getSessions, createSession, getSession, deleteSession } from './sessions';
4
+ export { uploadFile, formatFileSize, isValidFileType, DEFAULT_ALLOWED_FILE_TYPES, MAX_FILE_SIZE } from './files';
@@ -0,0 +1,6 @@
1
+ import { Session, SessionListResponse } from '../types';
2
+
3
+ export declare function getSessions(limit?: number, offset?: number): Promise<SessionListResponse>;
4
+ export declare function createSession(sessionName?: string, externalSessionId?: string): Promise<Session>;
5
+ export declare function getSession(sessionId: string): Promise<Session>;
6
+ export declare function deleteSession(sessionId: string): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { ChatAppProps } from '../../types';
2
+
3
+ export declare function LiyaChatApp({ theme, showSidebar, sidebarWidth, welcomeMessage, placeholder, showVoice, voiceEnabled, showFileUpload, onSessionCreated, onSessionSelected, onSessionDeleted, onMessageSent, onMessageReceived, }: ChatAppProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { Session } from '../../types';
2
+
3
+ interface SessionSidebarProps {
4
+ sessions: Session[];
5
+ currentSessionId?: string | null;
6
+ isLoading?: boolean;
7
+ assistantName?: string;
8
+ onSelectSession: (session: Session) => void;
9
+ onCreateSession: () => void;
10
+ onDeleteSession: (sessionId: string) => void;
11
+ }
12
+ export declare function SessionSidebar({ sessions, currentSessionId, isLoading, assistantName, onSelectSession, onCreateSession, onDeleteSession, }: SessionSidebarProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,2 @@
1
+ export { LiyaChatApp } from './LiyaChatApp';
2
+ export { SessionSidebar } from './SessionSidebar';
@@ -0,0 +1,3 @@
1
+ export * from './shared';
2
+ export * from './widget';
3
+ export * from './app';
@@ -0,0 +1,4 @@
1
+ import { ChatInputProps } from '../../types';
2
+
3
+ export declare function ChatInput({ placeholder, disabled, showVoice, voiceEnabled, // false for STANDARD users - shows disabled mic icon
4
+ showFileUpload, maxLength, onSend, }: ChatInputProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { MessageBubbleProps } from '../../types';
2
+
3
+ export declare function MessageBubble({ message, showAvatar, assistantName: _assistantName, onSuggestionClick }: MessageBubbleProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { Message } from '../../types';
2
+
3
+ interface MessageListProps {
4
+ messages: Message[];
5
+ isLoading?: boolean;
6
+ assistantName?: string;
7
+ welcomeMessage?: string;
8
+ onSuggestionClick?: (suggestion: string) => void;
9
+ }
10
+ export declare function MessageList({ messages, isLoading, assistantName, welcomeMessage, onSuggestionClick }: MessageListProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,3 @@
1
+ export { MessageBubble } from './MessageBubble';
2
+ export { MessageList } from './MessageList';
3
+ export { ChatInput } from './ChatInput';
@@ -0,0 +1,3 @@
1
+ import { ChatWidgetProps } from '../../types';
2
+
3
+ export declare function LiyaChatWidget({ position, theme, welcomeMessage, placeholder, showBranding, showVoice, voiceEnabled, showFileUpload, onOpen, onClose, onMessageSent, onMessageReceived, }: ChatWidgetProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { LiyaChatWidget } from './LiyaChatWidget';
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { LiyaChatConfig, LiyaChatContextValue } from '../types';
3
+
4
+ declare const LiyaChatContext: React.Context<LiyaChatContextValue | null>;
5
+ export interface LiyaChatProviderProps {
6
+ config: LiyaChatConfig;
7
+ children: React.ReactNode;
8
+ }
9
+ export declare function LiyaChatProvider({ config, children }: LiyaChatProviderProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function useLiyaChatContext(): LiyaChatContextValue;
11
+ export { LiyaChatContext };
@@ -0,0 +1,4 @@
1
+ export { useChat } from './useChat';
2
+ export { useSessions } from './useSessions';
3
+ export { useVoice } from './useVoice';
4
+ export { useFileUpload } from './useFileUpload';
@@ -0,0 +1,14 @@
1
+ import { Message, SendMessageResponse } from '../types';
2
+
3
+ interface UseChatReturn {
4
+ messages: Message[];
5
+ isLoading: boolean;
6
+ error: string | null;
7
+ currentSessionId: string | null;
8
+ sendMessage: (content: string, fileIds?: string[]) => Promise<SendMessageResponse | null>;
9
+ loadHistory: (sessionId: string) => Promise<void>;
10
+ clearMessages: () => void;
11
+ setSessionId: (sessionId: string | null) => void;
12
+ }
13
+ export declare function useChat(): UseChatReturn;
14
+ export {};
@@ -0,0 +1,25 @@
1
+ import { FileAttachment } from '../types';
2
+
3
+ interface PendingFile {
4
+ id: string;
5
+ file: File;
6
+ progress: number;
7
+ status: 'pending' | 'uploading' | 'completed' | 'error';
8
+ error?: string;
9
+ attachment?: FileAttachment;
10
+ }
11
+ interface UseFileUploadReturn {
12
+ pendingFiles: PendingFile[];
13
+ uploadedFiles: FileAttachment[];
14
+ isUploading: boolean;
15
+ error: string | null;
16
+ addFiles: (files: FileList | File[]) => void;
17
+ uploadFiles: (sessionId: string) => Promise<FileAttachment[]>;
18
+ removePendingFile: (fileId: string) => void;
19
+ removeUploadedFile: (fileId: string) => void;
20
+ clearAll: () => void;
21
+ formatFileSize: (bytes: number) => string;
22
+ getFileIcon: (fileType: string) => string;
23
+ }
24
+ export declare function useFileUpload(allowedTypes?: string[]): UseFileUploadReturn;
25
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Session } from '../types';
2
+
3
+ interface UseSessionsReturn {
4
+ sessions: Session[];
5
+ currentSession: Session | null;
6
+ isLoading: boolean;
7
+ error: string | null;
8
+ totalSessions: number;
9
+ loadSessions: (limit?: number, offset?: number) => Promise<void>;
10
+ createSession: (sessionName?: string) => Promise<Session | null>;
11
+ deleteSession: (sessionId: string) => Promise<boolean>;
12
+ selectSession: (session: Session | null) => void;
13
+ clearSessions: () => void;
14
+ }
15
+ export declare function useSessions(): UseSessionsReturn;
16
+ export {};
@@ -0,0 +1,38 @@
1
+ interface SpeechRecognitionEvent extends Event {
2
+ results: SpeechRecognitionResultList;
3
+ resultIndex: number;
4
+ }
5
+ interface SpeechRecognitionErrorEvent extends Event {
6
+ error: string;
7
+ }
8
+ interface SpeechRecognition extends EventTarget {
9
+ continuous: boolean;
10
+ interimResults: boolean;
11
+ lang: string;
12
+ start(): void;
13
+ stop(): void;
14
+ abort(): void;
15
+ onresult: ((event: SpeechRecognitionEvent) => void) | null;
16
+ onerror: ((event: SpeechRecognitionErrorEvent) => void) | null;
17
+ onend: (() => void) | null;
18
+ onstart: (() => void) | null;
19
+ }
20
+ declare global {
21
+ interface Window {
22
+ SpeechRecognition: new () => SpeechRecognition;
23
+ webkitSpeechRecognition: new () => SpeechRecognition;
24
+ }
25
+ }
26
+ interface UseVoiceReturn {
27
+ isRecording: boolean;
28
+ transcript: string;
29
+ interimTranscript: string;
30
+ error: string | null;
31
+ isSupported: boolean;
32
+ startRecording: () => void;
33
+ stopRecording: () => string;
34
+ cancelRecording: () => void;
35
+ clearTranscript: () => void;
36
+ }
37
+ export declare function useVoice(locale?: string): UseVoiceReturn;
38
+ export {};
package/dist/index.cjs ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),w=require("react");function ot(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ht}=Object.prototype,{getPrototypeOf:Le}=Object,{iterator:be,toStringTag:at}=Symbol,xe=(e=>t=>{const s=Ht.call(t);return e[s]||(e[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),$=e=>(e=e.toLowerCase(),t=>xe(t)===e),_e=e=>t=>typeof t===e,{isArray:se}=Array,te=_e("undefined");function le(e){return e!==null&&!te(e)&&e.constructor!==null&&!te(e.constructor)&&U(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lt=$("ArrayBuffer");function $t(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lt(e.buffer),t}const qt=_e("string"),U=_e("function"),ct=_e("number"),ce=e=>e!==null&&typeof e=="object",Vt=e=>e===!0||e===!1,pe=e=>{if(xe(e)!=="object")return!1;const t=Le(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(at in e)&&!(be in e)},Wt=e=>{if(!ce(e)||le(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Jt=$("Date"),Kt=$("File"),Xt=$("Blob"),Gt=$("FileList"),Yt=e=>ce(e)&&U(e.pipe),Zt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||U(e.append)&&((t=xe(e))==="formdata"||t==="object"&&U(e.toString)&&e.toString()==="[object FormData]"))},Qt=$("URLSearchParams"),[es,ts,ss,ns]=["ReadableStream","Request","Response","Headers"].map($),rs=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ue(e,t,{allOwnKeys:s=!1}={}){if(e===null||typeof e>"u")return;let n,r;if(typeof e!="object"&&(e=[e]),se(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{if(le(e))return;const i=s?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let a;for(n=0;n<o;n++)a=i[n],t.call(null,e[a],a,e)}}function ut(e,t){if(le(e))return null;t=t.toLowerCase();const s=Object.keys(e);let n=s.length,r;for(;n-- >0;)if(r=s[n],t===r.toLowerCase())return r;return null}const G=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dt=e=>!te(e)&&e!==G;function ve(){const{caseless:e,skipUndefined:t}=dt(this)&&this||{},s={},n=(r,i)=>{const o=e&&ut(s,i)||i;pe(s[o])&&pe(r)?s[o]=ve(s[o],r):pe(r)?s[o]=ve({},r):se(r)?s[o]=r.slice():(!t||!te(r))&&(s[o]=r)};for(let r=0,i=arguments.length;r<i;r++)arguments[r]&&ue(arguments[r],n);return s}const is=(e,t,s,{allOwnKeys:n}={})=>(ue(t,(r,i)=>{s&&U(r)?Object.defineProperty(e,i,{value:ot(r,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),e),os=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),as=(e,t,s,n)=>{e.prototype=Object.create(t.prototype,n),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),s&&Object.assign(e.prototype,s)},ls=(e,t,s,n)=>{let r,i,o;const a={};if(t=t||{},e==null)return t;do{for(r=Object.getOwnPropertyNames(e),i=r.length;i-- >0;)o=r[i],(!n||n(o,e,t))&&!a[o]&&(t[o]=e[o],a[o]=!0);e=s!==!1&&Le(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},cs=(e,t,s)=>{e=String(e),(s===void 0||s>e.length)&&(s=e.length),s-=t.length;const n=e.indexOf(t,s);return n!==-1&&n===s},us=e=>{if(!e)return null;if(se(e))return e;let t=e.length;if(!ct(t))return null;const s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},ds=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Le(Uint8Array)),fs=(e,t)=>{const n=(e&&e[be]).call(e);let r;for(;(r=n.next())&&!r.done;){const i=r.value;t.call(e,i[0],i[1])}},hs=(e,t)=>{let s;const n=[];for(;(s=e.exec(t))!==null;)n.push(s);return n},ps=$("HTMLFormElement"),ms=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,n,r){return n.toUpperCase()+r}),He=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),ys=$("RegExp"),ft=(e,t)=>{const s=Object.getOwnPropertyDescriptors(e),n={};ue(s,(r,i)=>{let o;(o=t(r,i,e))!==!1&&(n[i]=o||r)}),Object.defineProperties(e,n)},gs=e=>{ft(e,(t,s)=>{if(U(e)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const n=e[s];if(U(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},ws=(e,t)=>{const s={},n=r=>{r.forEach(i=>{s[i]=!0})};return se(e)?n(e):n(String(e).split(t)),s},bs=()=>{},xs=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function _s(e){return!!(e&&U(e.append)&&e[at]==="FormData"&&e[be])}const Ss=e=>{const t=new Array(10),s=(n,r)=>{if(ce(n)){if(t.indexOf(n)>=0)return;if(le(n))return n;if(!("toJSON"in n)){t[r]=n;const i=se(n)?[]:{};return ue(n,(o,a)=>{const h=s(o,r+1);!te(h)&&(i[a]=h)}),t[r]=void 0,i}}return n};return s(e,0)},Es=$("AsyncFunction"),Rs=e=>e&&(ce(e)||U(e))&&U(e.then)&&U(e.catch),ht=((e,t)=>e?setImmediate:t?((s,n)=>(G.addEventListener("message",({source:r,data:i})=>{r===G&&i===s&&n.length&&n.shift()()},!1),r=>{n.push(r),G.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",U(G.postMessage)),Cs=typeof queueMicrotask<"u"?queueMicrotask.bind(G):typeof process<"u"&&process.nextTick||ht,js=e=>e!=null&&U(e[be]),c={isArray:se,isArrayBuffer:lt,isBuffer:le,isFormData:Zt,isArrayBufferView:$t,isString:qt,isNumber:ct,isBoolean:Vt,isObject:ce,isPlainObject:pe,isEmptyObject:Wt,isReadableStream:es,isRequest:ts,isResponse:ss,isHeaders:ns,isUndefined:te,isDate:Jt,isFile:Kt,isBlob:Xt,isRegExp:ys,isFunction:U,isStream:Yt,isURLSearchParams:Qt,isTypedArray:ds,isFileList:Gt,forEach:ue,merge:ve,extend:is,trim:rs,stripBOM:os,inherits:as,toFlatObject:ls,kindOf:xe,kindOfTest:$,endsWith:cs,toArray:us,forEachEntry:fs,matchAll:hs,isHTMLForm:ps,hasOwnProperty:He,hasOwnProp:He,reduceDescriptors:ft,freezeMethods:gs,toObjectSet:ws,toCamelCase:ms,noop:bs,toFiniteNumber:xs,findKey:ut,global:G,isContextDefined:dt,isSpecCompliantForm:_s,toJSONObject:Ss,isAsyncFn:Es,isThenable:Rs,setImmediate:ht,asap:Cs,isIterable:js};let _=class pt extends Error{static from(t,s,n,r,i,o){const a=new pt(t.message,s||t.code,n,r,i);return a.cause=t,a.name=t.name,o&&Object.assign(a,o),a}constructor(t,s,n,r,i){super(t),this.name="AxiosError",this.isAxiosError=!0,s&&(this.code=s),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:c.toJSONObject(this.config),code:this.code,status:this.status}}};_.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";_.ERR_BAD_OPTION="ERR_BAD_OPTION";_.ECONNABORTED="ECONNABORTED";_.ETIMEDOUT="ETIMEDOUT";_.ERR_NETWORK="ERR_NETWORK";_.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";_.ERR_DEPRECATED="ERR_DEPRECATED";_.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";_.ERR_BAD_REQUEST="ERR_BAD_REQUEST";_.ERR_CANCELED="ERR_CANCELED";_.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";_.ERR_INVALID_URL="ERR_INVALID_URL";const Fs=null;function Ae(e){return c.isPlainObject(e)||c.isArray(e)}function mt(e){return c.endsWith(e,"[]")?e.slice(0,-2):e}function $e(e,t,s){return e?e.concat(t).map(function(r,i){return r=mt(r),!s&&i?"["+r+"]":r}).join(s?".":""):t}function Ns(e){return c.isArray(e)&&!e.some(Ae)}const vs=c.toFlatObject(c,{},null,function(t){return/^is[A-Z]/.test(t)});function Se(e,t,s){if(!c.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,s=c.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!c.isUndefined(p[m])});const n=s.metaTokens,r=s.visitor||f,i=s.dots,o=s.indexes,h=(s.Blob||typeof Blob<"u"&&Blob)&&c.isSpecCompliantForm(t);if(!c.isFunction(r))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(c.isDate(d))return d.toISOString();if(c.isBoolean(d))return d.toString();if(!h&&c.isBlob(d))throw new _("Blob is not supported. Use a Buffer instead.");return c.isArrayBuffer(d)||c.isTypedArray(d)?h&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function f(d,m,p){let g=d;if(d&&!p&&typeof d=="object"){if(c.endsWith(m,"{}"))m=n?m:m.slice(0,-2),d=JSON.stringify(d);else if(c.isArray(d)&&Ns(d)||(c.isFileList(d)||c.endsWith(m,"[]"))&&(g=c.toArray(d)))return m=mt(m),g.forEach(function(S,E){!(c.isUndefined(S)||S===null)&&t.append(o===!0?$e([m],E,i):o===null?m:m+"[]",u(S))}),!1}return Ae(d)?!0:(t.append($e(p,m,i),u(d)),!1)}const y=[],x=Object.assign(vs,{defaultVisitor:f,convertValue:u,isVisitable:Ae});function C(d,m){if(!c.isUndefined(d)){if(y.indexOf(d)!==-1)throw Error("Circular reference detected in "+m.join("."));y.push(d),c.forEach(d,function(g,b){(!(c.isUndefined(g)||g===null)&&r.call(t,g,c.isString(b)?b.trim():b,m,x))===!0&&C(g,m?m.concat(b):[b])}),y.pop()}}if(!c.isObject(e))throw new TypeError("data must be an object");return C(e),t}function qe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function ke(e,t){this._pairs=[],e&&Se(e,this,t)}const yt=ke.prototype;yt.append=function(t,s){this._pairs.push([t,s])};yt.toString=function(t){const s=t?function(n){return t.call(this,n,qe)}:qe;return this._pairs.map(function(r){return s(r[0])+"="+s(r[1])},"").join("&")};function As(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function gt(e,t,s){if(!t)return e;const n=s&&s.encode||As,r=c.isFunction(s)?{serialize:s}:s,i=r&&r.serialize;let o;if(i?o=i(t,r):o=c.isURLSearchParams(t)?t.toString():new ke(t,r).toString(n),o){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ve{constructor(){this.handlers=[]}use(t,s,n){return this.handlers.push({fulfilled:t,rejected:s,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){c.forEach(this.handlers,function(n){n!==null&&t(n)})}}const wt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Os=typeof URLSearchParams<"u"?URLSearchParams:ke,Ts=typeof FormData<"u"?FormData:null,Ls=typeof Blob<"u"?Blob:null,ks={isBrowser:!0,classes:{URLSearchParams:Os,FormData:Ts,Blob:Ls},protocols:["http","https","file","blob","url","data"]},Pe=typeof window<"u"&&typeof document<"u",Oe=typeof navigator=="object"&&navigator||void 0,Ps=Pe&&(!Oe||["ReactNative","NativeScript","NS"].indexOf(Oe.product)<0),Bs=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Us=Pe&&window.location.href||"http://localhost",Ds=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Pe,hasStandardBrowserEnv:Ps,hasStandardBrowserWebWorkerEnv:Bs,navigator:Oe,origin:Us},Symbol.toStringTag,{value:"Module"})),P={...Ds,...ks};function zs(e,t){return Se(e,new P.classes.URLSearchParams,{visitor:function(s,n,r,i){return P.isNode&&c.isBuffer(s)?(this.append(n,s.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function Ms(e){return c.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Is(e){const t={},s=Object.keys(e);let n;const r=s.length;let i;for(n=0;n<r;n++)i=s[n],t[i]=e[i];return t}function bt(e){function t(s,n,r,i){let o=s[i++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),h=i>=s.length;return o=!o&&c.isArray(r)?r.length:o,h?(c.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!a):((!r[o]||!c.isObject(r[o]))&&(r[o]=[]),t(s,n,r[o],i)&&c.isArray(r[o])&&(r[o]=Is(r[o])),!a)}if(c.isFormData(e)&&c.isFunction(e.entries)){const s={};return c.forEachEntry(e,(n,r)=>{t(Ms(n),r,s,0)}),s}return null}function Hs(e,t,s){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(s||JSON.stringify)(e)}const de={transitional:wt,adapter:["xhr","http","fetch"],transformRequest:[function(t,s){const n=s.getContentType()||"",r=n.indexOf("application/json")>-1,i=c.isObject(t);if(i&&c.isHTMLForm(t)&&(t=new FormData(t)),c.isFormData(t))return r?JSON.stringify(bt(t)):t;if(c.isArrayBuffer(t)||c.isBuffer(t)||c.isStream(t)||c.isFile(t)||c.isBlob(t)||c.isReadableStream(t))return t;if(c.isArrayBufferView(t))return t.buffer;if(c.isURLSearchParams(t))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return zs(t,this.formSerializer).toString();if((a=c.isFileList(t))||n.indexOf("multipart/form-data")>-1){const h=this.env&&this.env.FormData;return Se(a?{"files[]":t}:t,h&&new h,this.formSerializer)}}return i||r?(s.setContentType("application/json",!1),Hs(t)):t}],transformResponse:[function(t){const s=this.transitional||de.transitional,n=s&&s.forcedJSONParsing,r=this.responseType==="json";if(c.isResponse(t)||c.isReadableStream(t))return t;if(t&&c.isString(t)&&(n&&!this.responseType||r)){const o=!(s&&s.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(a){if(o)throw a.name==="SyntaxError"?_.from(a,_.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:P.classes.FormData,Blob:P.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};c.forEach(["delete","get","head","post","put","patch"],e=>{de.headers[e]={}});const $s=c.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),qs=e=>{const t={};let s,n,r;return e&&e.split(`
2
+ `).forEach(function(o){r=o.indexOf(":"),s=o.substring(0,r).trim().toLowerCase(),n=o.substring(r+1).trim(),!(!s||t[s]&&$s[s])&&(s==="set-cookie"?t[s]?t[s].push(n):t[s]=[n]:t[s]=t[s]?t[s]+", "+n:n)}),t},We=Symbol("internals");function ae(e){return e&&String(e).trim().toLowerCase()}function me(e){return e===!1||e==null?e:c.isArray(e)?e.map(me):String(e)}function Vs(e){const t=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=s.exec(e);)t[n[1]]=n[2];return t}const Ws=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function je(e,t,s,n,r){if(c.isFunction(n))return n.call(this,t,s);if(r&&(t=s),!!c.isString(t)){if(c.isString(n))return t.indexOf(n)!==-1;if(c.isRegExp(n))return n.test(t)}}function Js(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,s,n)=>s.toUpperCase()+n)}function Ks(e,t){const s=c.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+s,{value:function(r,i,o){return this[n].call(this,t,r,i,o)},configurable:!0})})}let D=class{constructor(t){t&&this.set(t)}set(t,s,n){const r=this;function i(a,h,u){const f=ae(h);if(!f)throw new Error("header name must be a non-empty string");const y=c.findKey(r,f);(!y||r[y]===void 0||u===!0||u===void 0&&r[y]!==!1)&&(r[y||h]=me(a))}const o=(a,h)=>c.forEach(a,(u,f)=>i(u,f,h));if(c.isPlainObject(t)||t instanceof this.constructor)o(t,s);else if(c.isString(t)&&(t=t.trim())&&!Ws(t))o(qs(t),s);else if(c.isObject(t)&&c.isIterable(t)){let a={},h,u;for(const f of t){if(!c.isArray(f))throw TypeError("Object iterator must return a key-value pair");a[u=f[0]]=(h=a[u])?c.isArray(h)?[...h,f[1]]:[h,f[1]]:f[1]}o(a,s)}else t!=null&&i(s,t,n);return this}get(t,s){if(t=ae(t),t){const n=c.findKey(this,t);if(n){const r=this[n];if(!s)return r;if(s===!0)return Vs(r);if(c.isFunction(s))return s.call(this,r,n);if(c.isRegExp(s))return s.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,s){if(t=ae(t),t){const n=c.findKey(this,t);return!!(n&&this[n]!==void 0&&(!s||je(this,this[n],n,s)))}return!1}delete(t,s){const n=this;let r=!1;function i(o){if(o=ae(o),o){const a=c.findKey(n,o);a&&(!s||je(n,n[a],a,s))&&(delete n[a],r=!0)}}return c.isArray(t)?t.forEach(i):i(t),r}clear(t){const s=Object.keys(this);let n=s.length,r=!1;for(;n--;){const i=s[n];(!t||je(this,this[i],i,t,!0))&&(delete this[i],r=!0)}return r}normalize(t){const s=this,n={};return c.forEach(this,(r,i)=>{const o=c.findKey(n,i);if(o){s[o]=me(r),delete s[i];return}const a=t?Js(i):String(i).trim();a!==i&&delete s[i],s[a]=me(r),n[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const s=Object.create(null);return c.forEach(this,(n,r)=>{n!=null&&n!==!1&&(s[r]=t&&c.isArray(n)?n.join(", "):n)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,s])=>t+": "+s).join(`
3
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...s){const n=new this(t);return s.forEach(r=>n.set(r)),n}static accessor(t){const n=(this[We]=this[We]={accessors:{}}).accessors,r=this.prototype;function i(o){const a=ae(o);n[a]||(Ks(r,o),n[a]=!0)}return c.isArray(t)?t.forEach(i):i(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);c.reduceDescriptors(D.prototype,({value:e},t)=>{let s=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[s]=n}}});c.freezeMethods(D);function Fe(e,t){const s=this||de,n=t||s,r=D.from(n.headers);let i=n.data;return c.forEach(e,function(a){i=a.call(s,i,r.normalize(),t?t.status:void 0)}),r.normalize(),i}function xt(e){return!!(e&&e.__CANCEL__)}let fe=class extends _{constructor(t,s,n){super(t??"canceled",_.ERR_CANCELED,s,n),this.name="CanceledError",this.__CANCEL__=!0}};function _t(e,t,s){const n=s.config.validateStatus;!s.status||!n||n(s.status)?e(s):t(new _("Request failed with status code "+s.status,[_.ERR_BAD_REQUEST,_.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function Xs(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Gs(e,t){e=e||10;const s=new Array(e),n=new Array(e);let r=0,i=0,o;return t=t!==void 0?t:1e3,function(h){const u=Date.now(),f=n[i];o||(o=u),s[r]=h,n[r]=u;let y=i,x=0;for(;y!==r;)x+=s[y++],y=y%e;if(r=(r+1)%e,r===i&&(i=(i+1)%e),u-o<t)return;const C=f&&u-f;return C?Math.round(x*1e3/C):void 0}}function Ys(e,t){let s=0,n=1e3/t,r,i;const o=(u,f=Date.now())=>{s=f,r=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const f=Date.now(),y=f-s;y>=n?o(u,f):(r=u,i||(i=setTimeout(()=>{i=null,o(r)},n-y)))},()=>r&&o(r)]}const ge=(e,t,s=3)=>{let n=0;const r=Gs(50,250);return Ys(i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,h=o-n,u=r(h),f=o<=a;n=o;const y={loaded:o,total:a,progress:a?o/a:void 0,bytes:h,rate:u||void 0,estimated:u&&a&&f?(a-o)/u:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(y)},s)},Je=(e,t)=>{const s=e!=null;return[n=>t[0]({lengthComputable:s,total:e,loaded:n}),t[1]]},Ke=e=>(...t)=>c.asap(()=>e(...t)),Zs=P.hasStandardBrowserEnv?((e,t)=>s=>(s=new URL(s,P.origin),e.protocol===s.protocol&&e.host===s.host&&(t||e.port===s.port)))(new URL(P.origin),P.navigator&&/(msie|trident)/i.test(P.navigator.userAgent)):()=>!0,Qs=P.hasStandardBrowserEnv?{write(e,t,s,n,r,i,o){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];c.isNumber(s)&&a.push(`expires=${new Date(s).toUTCString()}`),c.isString(n)&&a.push(`path=${n}`),c.isString(r)&&a.push(`domain=${r}`),i===!0&&a.push("secure"),c.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function en(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function tn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function St(e,t,s){let n=!en(t);return e&&(n||s==!1)?tn(e,t):t}const Xe=e=>e instanceof D?{...e}:e;function Q(e,t){t=t||{};const s={};function n(u,f,y,x){return c.isPlainObject(u)&&c.isPlainObject(f)?c.merge.call({caseless:x},u,f):c.isPlainObject(f)?c.merge({},f):c.isArray(f)?f.slice():f}function r(u,f,y,x){if(c.isUndefined(f)){if(!c.isUndefined(u))return n(void 0,u,y,x)}else return n(u,f,y,x)}function i(u,f){if(!c.isUndefined(f))return n(void 0,f)}function o(u,f){if(c.isUndefined(f)){if(!c.isUndefined(u))return n(void 0,u)}else return n(void 0,f)}function a(u,f,y){if(y in t)return n(u,f);if(y in e)return n(void 0,u)}const h={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,f,y)=>r(Xe(u),Xe(f),y,!0)};return c.forEach(Object.keys({...e,...t}),function(f){const y=h[f]||r,x=y(e[f],t[f],f);c.isUndefined(x)&&y!==a||(s[f]=x)}),s}const Et=e=>{const t=Q({},e);let{data:s,withXSRFToken:n,xsrfHeaderName:r,xsrfCookieName:i,headers:o,auth:a}=t;if(t.headers=o=D.from(o),t.url=gt(St(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),c.isFormData(s)){if(P.hasStandardBrowserEnv||P.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(c.isFunction(s.getHeaders)){const h=s.getHeaders(),u=["content-type","content-length"];Object.entries(h).forEach(([f,y])=>{u.includes(f.toLowerCase())&&o.set(f,y)})}}if(P.hasStandardBrowserEnv&&(n&&c.isFunction(n)&&(n=n(t)),n||n!==!1&&Zs(t.url))){const h=r&&i&&Qs.read(i);h&&o.set(r,h)}return t},sn=typeof XMLHttpRequest<"u",nn=sn&&function(e){return new Promise(function(s,n){const r=Et(e);let i=r.data;const o=D.from(r.headers).normalize();let{responseType:a,onUploadProgress:h,onDownloadProgress:u}=r,f,y,x,C,d;function m(){C&&C(),d&&d(),r.cancelToken&&r.cancelToken.unsubscribe(f),r.signal&&r.signal.removeEventListener("abort",f)}let p=new XMLHttpRequest;p.open(r.method.toUpperCase(),r.url,!0),p.timeout=r.timeout;function g(){if(!p)return;const S=D.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),j={data:!a||a==="text"||a==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:S,config:e,request:p};_t(function(v){s(v),m()},function(v){n(v),m()},j),p=null}"onloadend"in p?p.onloadend=g:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(g)},p.onabort=function(){p&&(n(new _("Request aborted",_.ECONNABORTED,e,p)),p=null)},p.onerror=function(E){const j=E&&E.message?E.message:"Network Error",F=new _(j,_.ERR_NETWORK,e,p);F.event=E||null,n(F),p=null},p.ontimeout=function(){let E=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const j=r.transitional||wt;r.timeoutErrorMessage&&(E=r.timeoutErrorMessage),n(new _(E,j.clarifyTimeoutError?_.ETIMEDOUT:_.ECONNABORTED,e,p)),p=null},i===void 0&&o.setContentType(null),"setRequestHeader"in p&&c.forEach(o.toJSON(),function(E,j){p.setRequestHeader(j,E)}),c.isUndefined(r.withCredentials)||(p.withCredentials=!!r.withCredentials),a&&a!=="json"&&(p.responseType=r.responseType),u&&([x,d]=ge(u,!0),p.addEventListener("progress",x)),h&&p.upload&&([y,C]=ge(h),p.upload.addEventListener("progress",y),p.upload.addEventListener("loadend",C)),(r.cancelToken||r.signal)&&(f=S=>{p&&(n(!S||S.type?new fe(null,e,p):S),p.abort(),p=null)},r.cancelToken&&r.cancelToken.subscribe(f),r.signal&&(r.signal.aborted?f():r.signal.addEventListener("abort",f)));const b=Xs(r.url);if(b&&P.protocols.indexOf(b)===-1){n(new _("Unsupported protocol "+b+":",_.ERR_BAD_REQUEST,e));return}p.send(i||null)})},rn=(e,t)=>{const{length:s}=e=e?e.filter(Boolean):[];if(t||s){let n=new AbortController,r;const i=function(u){if(!r){r=!0,a();const f=u instanceof Error?u:this.reason;n.abort(f instanceof _?f:new fe(f instanceof Error?f.message:f))}};let o=t&&setTimeout(()=>{o=null,i(new _(`timeout of ${t}ms exceeded`,_.ETIMEDOUT))},t);const a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:h}=n;return h.unsubscribe=()=>c.asap(a),h}},on=function*(e,t){let s=e.byteLength;if(s<t){yield e;return}let n=0,r;for(;n<s;)r=n+t,yield e.slice(n,r),n=r},an=async function*(e,t){for await(const s of ln(e))yield*on(s,t)},ln=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:s,value:n}=await t.read();if(s)break;yield n}}finally{await t.cancel()}},Ge=(e,t,s,n)=>{const r=an(e,t);let i=0,o,a=h=>{o||(o=!0,n&&n(h))};return new ReadableStream({async pull(h){try{const{done:u,value:f}=await r.next();if(u){a(),h.close();return}let y=f.byteLength;if(s){let x=i+=y;s(x)}h.enqueue(new Uint8Array(f))}catch(u){throw a(u),u}},cancel(h){return a(h),r.return()}},{highWaterMark:2})},Ye=64*1024,{isFunction:he}=c,cn=(({Request:e,Response:t})=>({Request:e,Response:t}))(c.global),{ReadableStream:Ze,TextEncoder:Qe}=c.global,et=(e,...t)=>{try{return!!e(...t)}catch{return!1}},un=e=>{e=c.merge.call({skipUndefined:!0},cn,e);const{fetch:t,Request:s,Response:n}=e,r=t?he(t):typeof fetch=="function",i=he(s),o=he(n);if(!r)return!1;const a=r&&he(Ze),h=r&&(typeof Qe=="function"?(d=>m=>d.encode(m))(new Qe):async d=>new Uint8Array(await new s(d).arrayBuffer())),u=i&&a&&et(()=>{let d=!1;const m=new s(P.origin,{body:new Ze,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!m}),f=o&&a&&et(()=>c.isReadableStream(new n("").body)),y={stream:f&&(d=>d.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!y[d]&&(y[d]=(m,p)=>{let g=m&&m[d];if(g)return g.call(m);throw new _(`Response type '${d}' is not supported`,_.ERR_NOT_SUPPORT,p)})});const x=async d=>{if(d==null)return 0;if(c.isBlob(d))return d.size;if(c.isSpecCompliantForm(d))return(await new s(P.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(c.isArrayBufferView(d)||c.isArrayBuffer(d))return d.byteLength;if(c.isURLSearchParams(d)&&(d=d+""),c.isString(d))return(await h(d)).byteLength},C=async(d,m)=>{const p=c.toFiniteNumber(d.getContentLength());return p??x(m)};return async d=>{let{url:m,method:p,data:g,signal:b,cancelToken:S,timeout:E,onDownloadProgress:j,onUploadProgress:F,responseType:v,headers:T,withCredentials:z="same-origin",fetchOptions:k}=Et(d),B=t||fetch;v=v?(v+"").toLowerCase():"text";let M=rn([b,S&&S.toAbortSignal()],E),A=null;const R=M&&M.unsubscribe&&(()=>{M.unsubscribe()});let W;try{if(F&&u&&p!=="get"&&p!=="head"&&(W=await C(T,g))!==0){let I=new s(m,{method:"POST",body:g,duplex:"half"}),J;if(c.isFormData(g)&&(J=I.headers.get("content-type"))&&T.setContentType(J),I.body){const[N,H]=Je(W,ge(Ke(F)));g=Ge(I.body,Ye,N,H)}}c.isString(z)||(z=z?"include":"omit");const L=i&&"credentials"in s.prototype,ee={...k,signal:M,method:p.toUpperCase(),headers:T.normalize().toJSON(),body:g,duplex:"half",credentials:L?z:void 0};A=i&&new s(m,ee);let q=await(i?B(A,k):B(m,ee));const re=f&&(v==="stream"||v==="response");if(f&&(j||re&&R)){const I={};["status","statusText","headers"].forEach(ie=>{I[ie]=q[ie]});const J=c.toFiniteNumber(q.headers.get("content-length")),[N,H]=j&&Je(J,ge(Ke(j),!0))||[];q=new n(Ge(q.body,Ye,N,()=>{H&&H(),R&&R()}),I)}v=v||"text";let Ce=await y[c.findKey(y,v)||"text"](q,d);return!re&&R&&R(),await new Promise((I,J)=>{_t(I,J,{data:Ce,headers:D.from(q.headers),status:q.status,statusText:q.statusText,config:d,request:A})})}catch(L){throw R&&R(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new _("Network Error",_.ERR_NETWORK,d,A),{cause:L.cause||L}):_.from(L,L&&L.code,d,A)}}},dn=new Map,Rt=e=>{let t=e&&e.env||{};const{fetch:s,Request:n,Response:r}=t,i=[n,r,s];let o=i.length,a=o,h,u,f=dn;for(;a--;)h=i[a],u=f.get(h),u===void 0&&f.set(h,u=a?new Map:un(t)),f=u;return u};Rt();const Be={http:Fs,xhr:nn,fetch:{get:Rt}};c.forEach(Be,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const tt=e=>`- ${e}`,fn=e=>c.isFunction(e)||e===null||e===!1;function hn(e,t){e=c.isArray(e)?e:[e];const{length:s}=e;let n,r;const i={};for(let o=0;o<s;o++){n=e[o];let a;if(r=n,!fn(n)&&(r=Be[(a=String(n)).toLowerCase()],r===void 0))throw new _(`Unknown adapter '${a}'`);if(r&&(c.isFunction(r)||(r=r.get(t))))break;i[a||"#"+o]=r}if(!r){const o=Object.entries(i).map(([h,u])=>`adapter ${h} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=s?o.length>1?`since :
4
+ `+o.map(tt).join(`
5
+ `):" "+tt(o[0]):"as no adapter specified";throw new _("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return r}const Ct={getAdapter:hn,adapters:Be};function Ne(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fe(null,e)}function st(e){return Ne(e),e.headers=D.from(e.headers),e.data=Fe.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ct.getAdapter(e.adapter||de.adapter,e)(e).then(function(n){return Ne(e),n.data=Fe.call(e,e.transformResponse,n),n.headers=D.from(n.headers),n},function(n){return xt(n)||(Ne(e),n&&n.response&&(n.response.data=Fe.call(e,e.transformResponse,n.response),n.response.headers=D.from(n.response.headers))),Promise.reject(n)})}const jt="1.13.4",Ee={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ee[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const nt={};Ee.transitional=function(t,s,n){function r(i,o){return"[Axios v"+jt+"] Transitional option '"+i+"'"+o+(n?". "+n:"")}return(i,o,a)=>{if(t===!1)throw new _(r(o," has been removed"+(s?" in "+s:"")),_.ERR_DEPRECATED);return s&&!nt[o]&&(nt[o]=!0,console.warn(r(o," has been deprecated since v"+s+" and will be removed in the near future"))),t?t(i,o,a):!0}};Ee.spelling=function(t){return(s,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function pn(e,t,s){if(typeof e!="object")throw new _("options must be an object",_.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let r=n.length;for(;r-- >0;){const i=n[r],o=t[i];if(o){const a=e[i],h=a===void 0||o(a,i,e);if(h!==!0)throw new _("option "+i+" must be "+h,_.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new _("Unknown option "+i,_.ERR_BAD_OPTION)}}const ye={assertOptions:pn,validators:Ee},V=ye.validators;let Z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ve,response:new Ve}}async request(t,s){try{return await this._request(t,s)}catch(n){if(n instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
+ `+i):n.stack=i}catch{}}throw n}}_request(t,s){typeof t=="string"?(s=s||{},s.url=t):s=t||{},s=Q(this.defaults,s);const{transitional:n,paramsSerializer:r,headers:i}=s;n!==void 0&&ye.assertOptions(n,{silentJSONParsing:V.transitional(V.boolean),forcedJSONParsing:V.transitional(V.boolean),clarifyTimeoutError:V.transitional(V.boolean)},!1),r!=null&&(c.isFunction(r)?s.paramsSerializer={serialize:r}:ye.assertOptions(r,{encode:V.function,serialize:V.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),ye.assertOptions(s,{baseUrl:V.spelling("baseURL"),withXsrfToken:V.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let o=i&&c.merge(i.common,i[s.method]);i&&c.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),s.headers=D.concat(o,i);const a=[];let h=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(s)===!1||(h=h&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const u=[];this.interceptors.response.forEach(function(m){u.push(m.fulfilled,m.rejected)});let f,y=0,x;if(!h){const d=[st.bind(this),void 0];for(d.unshift(...a),d.push(...u),x=d.length,f=Promise.resolve(s);y<x;)f=f.then(d[y++],d[y++]);return f}x=a.length;let C=s;for(;y<x;){const d=a[y++],m=a[y++];try{C=d(C)}catch(p){m.call(this,p);break}}try{f=st.call(this,C)}catch(d){return Promise.reject(d)}for(y=0,x=u.length;y<x;)f=f.then(u[y++],u[y++]);return f}getUri(t){t=Q(this.defaults,t);const s=St(t.baseURL,t.url,t.allowAbsoluteUrls);return gt(s,t.params,t.paramsSerializer)}};c.forEach(["delete","get","head","options"],function(t){Z.prototype[t]=function(s,n){return this.request(Q(n||{},{method:t,url:s,data:(n||{}).data}))}});c.forEach(["post","put","patch"],function(t){function s(n){return function(i,o,a){return this.request(Q(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Z.prototype[t]=s(),Z.prototype[t+"Form"]=s(!0)});let mn=class Ft{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(i){s=i});const n=this;this.promise.then(r=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](r);n._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(a=>{n.subscribe(a),i=a}).then(r);return o.cancel=function(){n.unsubscribe(i)},o},t(function(i,o,a){n.reason||(n.reason=new fe(i,o,a),s(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const s=this._listeners.indexOf(t);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const t=new AbortController,s=n=>{t.abort(n)};return this.subscribe(s),t.signal.unsubscribe=()=>this.unsubscribe(s),t.signal}static source(){let t;return{token:new Ft(function(r){t=r}),cancel:t}}};function yn(e){return function(s){return e.apply(null,s)}}function gn(e){return c.isObject(e)&&e.isAxiosError===!0}const Te={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Te).forEach(([e,t])=>{Te[t]=e});function Nt(e){const t=new Z(e),s=ot(Z.prototype.request,t);return c.extend(s,Z.prototype,t,{allOwnKeys:!0}),c.extend(s,t,null,{allOwnKeys:!0}),s.create=function(r){return Nt(Q(e,r))},s}const O=Nt(de);O.Axios=Z;O.CanceledError=fe;O.CancelToken=mn;O.isCancel=xt;O.VERSION=jt;O.toFormData=Se;O.AxiosError=_;O.Cancel=O.CanceledError;O.all=function(t){return Promise.all(t)};O.spread=yn;O.isAxiosError=gn;O.mergeConfig=Q;O.AxiosHeaders=D;O.formToJSON=e=>bt(c.isHTMLForm(e)?new FormData(e):e);O.getAdapter=Ct.getAdapter;O.HttpStatusCode=Te;O.default=O;const{Axios:Pn,AxiosError:Bn,CanceledError:Un,isCancel:Dn,CancelToken:zn,VERSION:Mn,all:In,Cancel:Hn,isAxiosError:$n,spread:qn,toFormData:Vn,AxiosHeaders:Wn,HttpStatusCode:Jn,formToJSON:Kn,getAdapter:Xn,mergeConfig:Gn}=O;let Y=null,we=null;function vt(e){return we=e,Y=O.create({baseURL:e.baseUrl,timeout:6e4,headers:{"Content-Type":"application/json","X-API-Key":e.apiKey}}),Y.interceptors.request.use(t=>t,t=>Promise.reject(t)),Y.interceptors.response.use(t=>t,t=>{var n,r;const s=((r=(n=t.response)==null?void 0:n.data)==null?void 0:r.message)||t.message||"An error occurred";return console.error("[LiyaChat] API Error:",s),Promise.reject(new Error(s))}),Y}function X(){if(!Y)throw new Error("[LiyaChat] API client not initialized. Call initializeClient first.");return Y}function ne(){if(!we)throw new Error("[LiyaChat] Config not set. Initialize the provider first.");return we}function wn(){return Y!==null&&we!==null}async function At(e,t,s){const n=X(),r=ne(),i=s&&s.length>0?"/api/v1/external/chat/with-files/":"/api/v1/external/chat/",o={assistant_id:r.assistantId,message:e,session_id:t,file_ids:s},a=await n.post(i,o);if(a.data.status==="error")throw new Error(a.data.message||"Failed to send message");return a.data.data}async function Ot(e,t=50,s=0){const r=await X().get(`/api/v1/external/sessions/${e}/history/`,{params:{limit:t,offset:s}});if(r.data.status==="error")throw new Error(r.data.message||"Failed to get session history");return r.data.data}async function Tt(e=20,t=0){const s=X(),n=ne(),r=await s.get("/api/v1/external/sessions/",{params:{assistant_id:n.assistantId,limit:e,offset:t}});if(r.data.status==="error")throw new Error(r.data.message||"Failed to get sessions");return r.data.data}async function Lt(e,t){const s=X(),r={assistant_id:ne().assistantId,session_name:e||"Yeni Sohbet",external_session_id:t},i=await s.post("/api/v1/external/sessions/",r);if(i.data.status==="error")throw new Error(i.data.message||"Failed to create session");return i.data.data}async function bn(e){const s=await X().get(`/api/v1/external/sessions/${e}/`);if(s.data.status==="error")throw new Error(s.data.message||"Failed to get session");return s.data.data}async function kt(e){const s=await X().delete(`/api/v1/external/sessions/${e}/`);if(s.data.status==="error")throw new Error(s.data.message||"Failed to delete session")}async function Pt(e,t){const s=X(),n=new FormData;n.append("session_id",e),n.append("file",t);const r=await s.post("/api/v1/external/files/",n,{headers:{"Content-Type":"multipart/form-data"}});if(r.data.status==="error")throw new Error(r.data.message||"Failed to upload file");return r.data.data}function rt(e){if(e===0)return"0 Bytes";const t=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+s[n]}function xn(e,t){return!t||t.length===0?!0:t.some(s=>{if(s.endsWith("/*")){const n=s.replace("/*","");return e.type.startsWith(n)}return e.type===s})}const _n=["text/plain","text/csv","text/markdown","application/pdf","application/json","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","image/*"],it=50*1024*1024,Bt=w.createContext(null);function Sn({config:e,children:t}){const[s,n]=w.useState(!1);w.useEffect(()=>{e.apiKey&&e.baseUrl&&e.assistantId&&(vt(e),n(!0))},[e]);const r={config:e,isInitialized:s};return l.jsx(Bt.Provider,{value:r,children:t})}function En(){const e=w.useContext(Bt);if(!e)throw new Error("useLiyaChatContext must be used within a LiyaChatProvider");return e}function Ue(){const[e,t]=w.useState([]),[s,n]=w.useState(!1),[r,i]=w.useState(null),[o,a]=w.useState(()=>{try{return localStorage.getItem("liya_chat_session_id")}catch{return null}}),h=w.useCallback(d=>{try{localStorage.setItem("liya_chat_session_id",d)}catch{}},[]),u=w.useCallback(()=>{try{localStorage.removeItem("liya_chat_session_id")}catch{}},[]),f=w.useCallback(async(d,m)=>{if(!d.trim())return null;n(!0),i(null);const p={id:`temp-${Date.now()}`,content:d.trim(),role:"user",created_at:new Date().toISOString()};t(g=>[...g,p]);try{const g=await At(d.trim(),o||void 0,m);return g.session_id&&(a(g.session_id),h(g.session_id)),t(b=>{const E=[...b.filter(j=>j.id!==p.id)];return g.user_message?E.push(g.user_message):E.push({...p,id:`user-${Date.now()}`}),g.assistant_message?E.push(g.assistant_message):g.response&&E.push({id:g.message_id||`msg-${Date.now()}`,content:g.response,role:"assistant",created_at:new Date().toISOString(),response_time:g.response_time}),E}),g}catch(g){return i(g instanceof Error?g.message:"Failed to send message"),t(b=>b.filter(S=>S.id!==p.id)),null}finally{n(!1)}},[o,h]),y=w.useCallback(async d=>{n(!0),i(null);try{const m=await Ot(d);t(m.messages),a(d),h(d)}catch(m){i(m instanceof Error?m.message:"Failed to load history")}finally{n(!1)}},[h]),x=w.useCallback(()=>{t([]),a(null),u()},[u]),C=w.useCallback(d=>{a(d),d?h(d):u()},[h,u]);return{messages:e,isLoading:s,error:r,currentSessionId:o,sendMessage:f,loadHistory:y,clearMessages:x,setSessionId:C}}function Re(e=_n){const[t,s]=w.useState([]),[n,r]=w.useState([]),[i,o]=w.useState(!1),[a,h]=w.useState(null),u=w.useCallback(m=>{h(null);const p=Array.from(m),g=[];for(const b of p){if(b.size>it){h(`File "${b.name}" exceeds maximum size of ${rt(it)}`);continue}if(!xn(b,e)){h(`File type "${b.type}" is not allowed`);continue}g.push({id:`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,file:b,progress:0,status:"pending"})}s(b=>[...b,...g])},[e]),f=w.useCallback(async m=>{if(t.length===0)return[];o(!0),h(null);const p=[];for(const g of t)if(g.status!=="completed"){s(b=>b.map(S=>S.id===g.id?{...S,status:"uploading"}:S));try{const b=await Pt(m,g.file);p.push(b),r(S=>[...S,b]),s(S=>S.map(E=>E.id===g.id?{...E,status:"completed",progress:100,attachment:b}:E))}catch(b){s(S=>S.map(E=>E.id===g.id?{...E,status:"error",error:b instanceof Error?b.message:"Upload failed"}:E))}}return s(g=>g.filter(b=>b.status!=="completed")),o(!1),p},[t]),y=w.useCallback(m=>{s(p=>p.filter(g=>g.id!==m))},[]),x=w.useCallback(m=>{r(p=>p.filter(g=>g.id!==m))},[]),C=w.useCallback(()=>{s([]),r([]),h(null)},[]),d=w.useCallback(m=>m.startsWith("image/")?"🖼️":m.startsWith("video/")?"🎬":m.startsWith("audio/")?"🎵":m.includes("pdf")?"📄":m.includes("word")||m.includes("document")?"📝":m.includes("excel")||m.includes("spreadsheet")?"📊":m.includes("json")?"📋":m.startsWith("text/")?"📃":"📎",[]);return{pendingFiles:t,uploadedFiles:n,isUploading:i,error:a,addFiles:u,uploadFiles:f,removePendingFile:y,removeUploadedFile:x,clearAll:C,formatFileSize:rt,getFileIcon:d}}function Rn(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Cn(e){if(!e)return null;try{let t=e.trim();t.startsWith("```json")?t=t.replace(/^```json\s*/,"").replace(/\s*```$/,""):t.startsWith("```")&&(t=t.replace(/^```\s*/,"").replace(/\s*```$/,""));const s=t.match(/\{[\s\S]*\}/);s&&(t=s[0]);const n=JSON.parse(t);return n&&typeof n.response=="string"?n:null}catch{return null}}function Ut({message:e,showAvatar:t=!0,assistantName:s="Assistant",onSuggestionClick:n}){const r=e.role==="user",i=w.useMemo(()=>r?null:Cn(e.raw_response||e.content),[r,e.raw_response,e.content]),o=(i==null?void 0:i.response)||e.content,a=(i==null?void 0:i.suggestions)||[],h=u=>{n==null||n(u)};return l.jsxs("div",{className:`liya-message ${r?"liya-message--user":"liya-message--assistant"}`,children:[t&&!r&&l.jsx("div",{className:"liya-message__avatar",children:l.jsx("div",{className:"liya-avatar liya-avatar--assistant",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"})})})}),l.jsxs("div",{className:"liya-message__content",children:[l.jsx("div",{className:"liya-message__bubble",children:l.jsx("div",{className:"liya-message__text",dangerouslySetInnerHTML:{__html:o}})}),a.length>0&&l.jsx("div",{className:"liya-message__suggestions",children:a.map((u,f)=>l.jsxs("button",{className:"liya-suggestion",onClick:()=>h(u),children:[l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"14",height:"14",children:l.jsx("path",{d:"M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"})}),u]},f))}),l.jsxs("div",{className:"liya-message__meta",children:[l.jsx("span",{className:"liya-message__time",children:Rn(e.created_at)}),e.response_time&&l.jsxs("span",{className:"liya-message__response-time",children:[e.response_time.toFixed(1),"s"]})]})]}),t&&r&&l.jsx("div",{className:"liya-message__avatar",children:l.jsx("div",{className:"liya-avatar liya-avatar--user",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"})})})})]})}function De({messages:e,isLoading:t=!1,assistantName:s="Assistant",welcomeMessage:n="",onSuggestionClick:r}){const i=w.useRef(null);return w.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e,t]),l.jsxs("div",{ref:i,className:"liya-message-list",children:[e.length===0&&n&&l.jsxs("div",{className:"liya-welcome",children:[l.jsx("div",{className:"liya-welcome__icon",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"48",height:"48",children:l.jsx("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})})}),l.jsx("p",{className:"liya-welcome__text",children:n})]}),e.map(o=>l.jsx(Ut,{message:o,assistantName:s,onSuggestionClick:r},o.id)),t&&l.jsxs("div",{className:"liya-typing",children:[l.jsx("div",{className:"liya-typing__avatar",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"})})}),l.jsxs("div",{className:"liya-typing__dots",children:[l.jsx("span",{}),l.jsx("span",{}),l.jsx("span",{})]})]})]})}function Dt(e="tr-TR"){const[t,s]=w.useState(!1),[n,r]=w.useState(""),[i,o]=w.useState(""),[a,h]=w.useState(null),[u,f]=w.useState(!1),y=w.useRef(null);w.useEffect(()=>{const g=typeof window<"u"?window.SpeechRecognition||window.webkitSpeechRecognition:null;f(!!g)},[]);const x=w.useCallback(()=>{const g=window.SpeechRecognition||window.webkitSpeechRecognition;if(!g||y.current)return;const b=new g;b.continuous=!0,b.interimResults=!0,b.lang=e,b.onstart=()=>{s(!0),h(null)},b.onresult=S=>{let E="",j="";for(let F=S.resultIndex;F<S.results.length;F++){const v=S.results[F];v.isFinal?j+=v[0].transcript:E+=v[0].transcript}j&&r(F=>(F?F+" ":"")+j),o(E)},b.onerror=S=>{h({"no-speech":"No speech detected. Please try again.","audio-capture":"Microphone not available.","not-allowed":"Microphone permission denied.",network:"Network error occurred.",aborted:"Recording was cancelled."}[S.error]||"An error occurred during recording."),s(!1)},b.onend=()=>{s(!1),o("")},y.current=b},[e]),C=w.useCallback(()=>{if(!u){h("Speech recognition is not supported in this browser");return}if(x(),y.current&&!t){r(""),o(""),h(null);try{y.current.start()}catch{h("Failed to start recording")}}},[u,t,x]),d=w.useCallback(()=>(y.current&&t&&y.current.stop(),n),[t,n]),m=w.useCallback(()=>{y.current&&t&&y.current.abort(),r(""),o("")},[t]),p=w.useCallback(()=>{r(""),o("")},[]);return w.useEffect(()=>()=>{y.current&&t&&y.current.abort()},[t]),{isRecording:t,transcript:n,interimTranscript:i,error:a,isSupported:u,startRecording:C,stopRecording:d,cancelRecording:m,clearTranscript:p}}function ze({placeholder:e="Mesajınızı yazın...",disabled:t=!1,showVoice:s=!0,voiceEnabled:n=!0,showFileUpload:r=!0,maxLength:i=4e3,onSend:o}){const[a,h]=w.useState(""),u=w.useRef(null),f=w.useRef(null),{isRecording:y,transcript:x,isSupported:C,startRecording:d,stopRecording:m}=Dt(),{pendingFiles:p,uploadedFiles:g,isUploading:b,addFiles:S,removePendingFile:E,clearAll:j,formatFileSize:F,getFileIcon:v}=Re(),T=(a.trim().length>0||g.length>0)&&!t&&!b;w.useEffect(()=>{x&&h(x)},[x]);const z=()=>{if(!T)return;const R=a.trim(),W=g.length>0?g.map(L=>L.id):void 0;o(R,W),h(""),j(),B()},k=R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),z())},B=()=>{u.current&&(u.current.style.height="auto",u.current.style.height=Math.min(u.current.scrollHeight,150)+"px")},M=()=>{if(y){const R=m();R&&h(R)}else d()},A=R=>{R.target.files&&(S(R.target.files),R.target.value="")};return l.jsxs("div",{className:"liya-chat-input",children:[p.length>0&&l.jsx("div",{className:"liya-chat-input__files",children:p.map(R=>l.jsxs("div",{className:`liya-file-chip ${R.status==="error"?"liya-file-chip--error":""}`,children:[l.jsx("span",{className:"liya-file-chip__icon",children:v(R.file.type)}),l.jsx("span",{className:"liya-file-chip__name",children:R.file.name}),l.jsx("span",{className:"liya-file-chip__size",children:F(R.file.size)}),l.jsx("button",{type:"button",className:"liya-file-chip__remove",onClick:()=>E(R.id),children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"14",height:"14",children:l.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})})]},R.id))}),l.jsxs("div",{className:"liya-chat-input__wrapper",children:[r&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"liya-chat-input__btn liya-chat-input__btn--file",disabled:t,onClick:()=>{var R;return(R=f.current)==null?void 0:R.click()},title:"Dosya ekle",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z"})})}),l.jsx("input",{ref:f,type:"file",multiple:!0,className:"liya-chat-input__file-input",onChange:A})]}),l.jsx("textarea",{ref:u,value:a,placeholder:e,disabled:t,maxLength:i,className:"liya-chat-input__textarea",rows:1,onChange:R=>{h(R.target.value),B()},onKeyDown:k}),s&&C&&l.jsx("button",{type:"button",className:`liya-chat-input__btn liya-chat-input__btn--voice ${y?"liya-chat-input__btn--recording":""} ${n?"":"liya-chat-input__btn--voice-disabled"}`,disabled:t||!n,onClick:n?M:void 0,title:n?y?"Kaydı durdur":"Sesle yaz":"Sesli yazma özelliği Premium üyelik gerektirir",children:n?y?l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M6 6h12v12H6z"})}):l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"})}):l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M19 11h-1.7c0 .74-.16 1.43-.43 2.05l1.23 1.23c.56-.98.9-2.09.9-3.28zm-4.02.17c0-.06.02-.11.02-.17V5c0-1.66-1.34-3-3-3S9 3.34 9 5v.18l5.98 5.99zM4.27 3L3 4.27l6.01 6.01V11c0 1.66 1.33 3 2.99 3 .22 0 .44-.03.65-.08l1.66 1.66c-.71.33-1.5.52-2.31.52-2.76 0-5.3-2.1-5.3-5.1H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c.91-.13 1.77-.45 2.54-.9L19.73 21 21 19.73 4.27 3z"})})}),l.jsx("button",{type:"button",className:"liya-chat-input__btn liya-chat-input__btn--send",disabled:!T,onClick:z,title:"Gönder",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})})})]}),a.length>i*.8&&l.jsxs("div",{className:"liya-chat-input__count",children:[a.length," / ",i]})]})}function jn(e,t){const s=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),r=(s>>16)+n,i=(s>>8&255)+n,o=(s&255)+n;return"#"+(16777216+(r<255?r<1?0:r:255)*65536+(i<255?i<1?0:i:255)*256+(o<255?o<1?0:o:255)).toString(16).slice(1)}function Fn({position:e="bottom-right",theme:t={},welcomeMessage:s="Merhaba! Size nasıl yardımcı olabilirim?",placeholder:n="Mesajınızı yazın...",showBranding:r=!0,showVoice:i=!0,voiceEnabled:o=!0,showFileUpload:a=!0,onOpen:h,onClose:u,onMessageSent:f,onMessageReceived:y}){const[x,C]=w.useState(!1),d=ne(),{messages:m,isLoading:p,currentSessionId:g,sendMessage:b,loadHistory:S}=Ue(),{uploadFiles:E,clearAll:j}=Re(),F=d.assistantName||"Assistant",v={"--liya-primary-color":t.primaryColor||"#6366f1","--liya-primary-hover":t.primaryColor?jn(t.primaryColor,-10):"#4f46e5","--liya-secondary-color":t.secondaryColor||"#e5e7eb","--liya-bg-color":t.backgroundColor||"#ffffff","--liya-bg-secondary":"#f3f4f6","--liya-text-color":t.textColor||"#374151","--liya-text-muted":"#9ca3af","--liya-border-color":"#e5e7eb","--liya-border-radius":t.borderRadius||"16px","--liya-font-family":t.fontFamily||"system-ui, -apple-system, sans-serif","--liya-z-index":t.zIndex||9999},T=()=>{const k=!x;C(k),k?h==null||h():u==null||u()},z=async(k,B)=>{var R,W;if(!k.trim()&&(!B||B.length===0))return;let M=B;g&&B&&B.length>0&&(M=(await E(g)).map(ee=>ee.id)),f==null||f(k);const A=await b(k,M);((R=A==null?void 0:A.assistant_message)!=null&&R.content||A!=null&&A.response)&&(y==null||y(((W=A.assistant_message)==null?void 0:W.content)||A.response||"")),j()};return w.useEffect(()=>{try{const k=localStorage.getItem("liya_chat_session_id");k&&S(k)}catch{}},[]),l.jsxs("div",{className:`liya-widget liya-widget--${e}`,style:v,children:[l.jsx("button",{className:`liya-widget__toggle ${x?"liya-widget__toggle--open":""}`,onClick:T,"aria-label":x?"Sohbeti kapat":"Sohbeti aç",children:x?l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"28",height:"28",children:l.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})}):l.jsxs("svg",{viewBox:"0 0 80 92",fill:"none",width:"28",height:"28",children:[l.jsx("rect",{x:"0",y:"0",width:"80",height:"80",rx:"18",fill:"#6366F1"}),l.jsx("path",{d:"M22 80 L34 80 L28 92 Z",fill:"#6366F1"}),l.jsx("path",{d:"M36 26 V58 H56",stroke:"#FFFFFF",strokeWidth:"5",strokeLinecap:"round"}),l.jsx("circle",{cx:"36",cy:"26",r:"3",fill:"#FFFFFF"}),l.jsx("circle",{cx:"36",cy:"58",r:"3",fill:"#FFFFFF"}),l.jsx("circle",{cx:"56",cy:"58",r:"3",fill:"#FFFFFF"}),l.jsx("text",{x:"40",y:"52",fontSize:"12",fontWeight:"600",fontFamily:"system-ui, sans-serif",fill:"#FFFFFF",children:"ai"}),l.jsx("path",{d:"M58 16 L60 20 L64 22 L60 24 L58 28 L56 24 L52 22 L56 20 Z",fill:"#FFFFFF"}),l.jsx("path",{d:"M66 30 L67.5 33 L71 34.5 L67.5 36 L66 39 L64.5 36 L61 34.5 L64.5 33 Z",fill:"#FFFFFF"}),l.jsx("path",{d:"M50 18 L51.5 21 L55 22.5 L51.5 24 L50 27 L48.5 24 L45 22.5 L48.5 21 Z",fill:"#FFFFFF"})]})}),x&&l.jsxs("div",{className:"liya-widget__panel",children:[l.jsxs("div",{className:"liya-widget__header",children:[l.jsxs("div",{className:"liya-widget__header-info",children:[l.jsx("div",{className:"liya-widget__avatar",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:l.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"})})}),l.jsxs("div",{className:"liya-widget__header-text",children:[l.jsx("h3",{className:"liya-widget__title",children:F}),l.jsx("span",{className:"liya-widget__status",children:"Çevrimiçi"})]})]}),l.jsx("button",{className:"liya-widget__close",onClick:T,children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})})]}),l.jsx(De,{messages:m,isLoading:p,assistantName:F,welcomeMessage:s}),l.jsx(ze,{placeholder:n,disabled:p,showVoice:i,voiceEnabled:o,showFileUpload:a,sessionId:g,onSend:z}),r&&l.jsxs("div",{className:"liya-widget__branding",children:["Powered by ",l.jsx("a",{href:"https://liyalabs.com",target:"_blank",rel:"noopener noreferrer",children:"Liya AI"})]})]})]})}function zt(){const[e,t]=w.useState([]),[s,n]=w.useState(null),[r,i]=w.useState(!1),[o,a]=w.useState(null),[h,u]=w.useState(0),f=w.useCallback(async(m=20,p=0)=>{i(!0),a(null);try{const g=await Tt(m,p);t(g.sessions),u(g.total)}catch(g){a(g instanceof Error?g.message:"Failed to load sessions")}finally{i(!1)}},[]),y=w.useCallback(async m=>{i(!0),a(null);try{const p=await Lt(m);return t(g=>[p,...g]),n(p),p}catch(p){return a(p instanceof Error?p.message:"Failed to create session"),null}finally{i(!1)}},[]),x=w.useCallback(async m=>{i(!0),a(null);try{return await kt(m),t(p=>p.filter(g=>g.id!==m)),(s==null?void 0:s.id)===m&&n(null),!0}catch(p){return a(p instanceof Error?p.message:"Failed to delete session"),!1}finally{i(!1)}},[s]),C=w.useCallback(m=>{n(m)},[]),d=w.useCallback(()=>{t([]),n(null),u(0)},[]);return{sessions:e,currentSession:s,isLoading:r,error:o,totalSessions:h,loadSessions:f,createSession:y,deleteSession:x,selectSession:C,clearSessions:d}}function Nn(e){if(!e)return"";const t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/(1e3*60*60*24));return r===0?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):r===1?"Dün":r<7?t.toLocaleDateString([],{weekday:"short"}):t.toLocaleDateString([],{day:"numeric",month:"short"})}function vn(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function Mt({sessions:e,currentSessionId:t,isLoading:s=!1,assistantName:n="Assistant",onSelectSession:r,onCreateSession:i,onDeleteSession:o}){return l.jsxs("div",{className:"liya-sidebar",children:[l.jsxs("div",{className:"liya-sidebar__header",children:[l.jsxs("div",{className:"liya-sidebar__logo",children:[l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:l.jsx("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})}),l.jsx("span",{children:n})]}),l.jsx("button",{className:"liya-sidebar__new-btn",onClick:i,title:"Yeni sohbet",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"20",height:"20",children:l.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})})})]}),l.jsxs("div",{className:"liya-sidebar__list",children:[s&&l.jsxs("div",{className:"liya-sidebar__loading",children:[l.jsx("div",{className:"liya-sidebar__spinner"}),l.jsx("span",{children:"Yükleniyor..."})]}),!s&&e.length===0&&l.jsxs("div",{className:"liya-sidebar__empty",children:[l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"40",height:"40",children:l.jsx("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})}),l.jsx("p",{children:"Henüz sohbet yok"}),l.jsx("button",{className:"liya-sidebar__start-btn",onClick:i,children:"Yeni Sohbet Başlat"})]}),e.map(a=>l.jsxs("div",{className:`liya-sidebar__item ${a.id===t?"liya-sidebar__item--active":""}`,onClick:()=>r(a),children:[l.jsx("div",{className:"liya-sidebar__item-icon",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:l.jsx("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"})})}),l.jsxs("div",{className:"liya-sidebar__item-content",children:[l.jsx("div",{className:"liya-sidebar__item-title",children:vn(a.session_name,28)}),l.jsxs("div",{className:"liya-sidebar__item-meta",children:[l.jsxs("span",{children:[a.message_count," mesaj"]}),l.jsx("span",{children:Nn(a.last_message_at||a.created_at)})]})]}),l.jsx("button",{className:"liya-sidebar__item-delete",onClick:h=>{h.stopPropagation(),o(a.id)},title:"Sohbeti sil",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:l.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})})})]},a.id))]})]})}function An(e,t){const s=parseInt(e.replace("#",""),16),n=Math.round(2.55*t),r=(s>>16)+n,i=(s>>8&255)+n,o=(s&255)+n;return"#"+(16777216+(r<255?r<1?0:r:255)*65536+(i<255?i<1?0:i:255)*256+(o<255?o<1?0:o:255)).toString(16).slice(1)}function On({theme:e={},showSidebar:t=!0,sidebarWidth:s="300px",welcomeMessage:n="Merhaba! Size nasıl yardımcı olabilirim?",placeholder:r="Mesajınızı yazın...",showVoice:i=!0,voiceEnabled:o=!0,showFileUpload:a=!0,onSessionCreated:h,onSessionSelected:u,onSessionDeleted:f,onMessageSent:y,onMessageReceived:x}){const[C,d]=w.useState(!1),m=ne(),{messages:p,isLoading:g,currentSessionId:b,sendMessage:S,loadHistory:E,clearMessages:j,setSessionId:F}=Ue(),{sessions:v,currentSession:T,isLoading:z,loadSessions:k,createSession:B,deleteSession:M,selectSession:A}=zt(),{uploadFiles:R,clearAll:W}=Re(),L=m.assistantName||"Assistant",ee={"--liya-primary-color":e.primaryColor||"#6366f1","--liya-primary-hover":e.primaryColor?An(e.primaryColor,-10):"#4f46e5","--liya-secondary-color":e.secondaryColor||"#e5e7eb","--liya-bg-color":e.backgroundColor||"#ffffff","--liya-bg-secondary":"#f3f4f6","--liya-text-color":e.textColor||"#374151","--liya-text-muted":"#9ca3af","--liya-border-color":"#e5e7eb","--liya-border-radius":e.borderRadius||"12px","--liya-font-family":e.fontFamily||"system-ui, -apple-system, sans-serif","--liya-sidebar-width":s},q=async N=>{A(N),F(N.id),await E(N.id),d(!1),u==null||u(N)},re=async()=>{const N=await B();N&&(A(N),F(N.id),j(),d(!1),h==null||h(N))},Ce=async N=>{await M(N)&&(b===N&&(j(),F(null),A(null)),f==null||f(N))},I=async(N,H)=>{var Me,Ie;if(!N.trim()&&(!H||H.length===0))return;if(!b){const oe=await B(N.substring(0,30));oe&&(A(oe),F(oe.id),h==null||h(oe))}let ie=H;b&&H&&H.length>0&&(ie=(await R(b)).map(It=>It.id)),y==null||y(N);const K=await S(N,ie);((Me=K==null?void 0:K.assistant_message)!=null&&Me.content||K!=null&&K.response)&&(x==null||x(((Ie=K.assistant_message)==null?void 0:Ie.content)||K.response||"")),W(),k()},J=N=>{I(N)};return w.useEffect(()=>{k()},[]),l.jsxs("div",{className:"liya-app",style:ee,children:[l.jsxs("div",{className:"liya-app__mobile-header",children:[l.jsx("button",{className:"liya-app__menu-btn",onClick:()=>d(!0),children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:l.jsx("path",{d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"})})}),l.jsx("span",{className:"liya-app__mobile-title",children:(T==null?void 0:T.session_name)||L}),l.jsx("button",{className:"liya-app__new-btn",onClick:re,children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:l.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})})})]}),t&&l.jsx("aside",{className:`liya-app__sidebar ${C?"liya-app__sidebar--open":""}`,children:l.jsx(Mt,{sessions:v,currentSessionId:b,isLoading:z,assistantName:L,onSelectSession:q,onCreateSession:re,onDeleteSession:Ce})}),C&&l.jsx("div",{className:"liya-app__overlay",onClick:()=>d(!1)}),l.jsxs("main",{className:"liya-app__main",children:[l.jsx("div",{className:"liya-app__header",children:l.jsxs("div",{className:"liya-app__header-info",children:[l.jsx("div",{className:"liya-app__avatar",children:l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",width:"24",height:"24",children:l.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"})})}),l.jsxs("div",{className:"liya-app__header-text",children:[l.jsx("h2",{className:"liya-app__title",children:(T==null?void 0:T.session_name)||L}),l.jsx("span",{className:"liya-app__status",children:T?`${T.message_count} mesaj`:"Yeni sohbet başlatın"})]})]})}),l.jsx(De,{messages:p,isLoading:g,assistantName:L,welcomeMessage:n,onSuggestionClick:J}),l.jsx(ze,{placeholder:r,disabled:g,showVoice:i,voiceEnabled:o,showFileUpload:a,sessionId:b,onSend:I})]})]})}exports.ChatInput=ze;exports.LiyaChatApp=On;exports.LiyaChatProvider=Sn;exports.LiyaChatWidget=Fn;exports.MessageBubble=Ut;exports.MessageList=De;exports.SessionSidebar=Mt;exports.createSession=Lt;exports.deleteSession=kt;exports.getClient=X;exports.getConfig=ne;exports.getSession=bn;exports.getSessionHistory=Ot;exports.getSessions=Tt;exports.initializeClient=vt;exports.isInitialized=wn;exports.sendMessage=At;exports.uploadFile=Pt;exports.useChat=Ue;exports.useFileUpload=Re;exports.useLiyaChatContext=En;exports.useSessions=zt;exports.useVoice=Dt;