@logosphere-ui/core 0.0.0-alpha.7 → 0.0.0-alpha.9
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/dist/badge-CHWTCGQG.js +72 -0
- package/dist/badge-DVvdodRb.cjs +13 -0
- package/dist/badge.cjs +1 -0
- package/dist/badge.js +4 -0
- package/dist/breadcrumb-BB61Xt0s.js +41 -0
- package/dist/breadcrumb-Cop-B1J7.cjs +12 -0
- package/dist/breadcrumb.cjs +1 -0
- package/dist/breadcrumb.js +4 -0
- package/dist/button-BqOMevro.js +58 -0
- package/dist/button-CDRccsk9.cjs +10 -0
- package/dist/button.cjs +1 -0
- package/dist/button.js +4 -0
- package/dist/card-CNoTUaJC.js +98 -0
- package/dist/card-KiNHfEi2.cjs +43 -0
- package/dist/card.cjs +1 -0
- package/dist/card.js +4 -0
- package/dist/chatbot-BNGCxSf9.js +485 -0
- package/dist/chatbot-P32-Xv7e.cjs +160 -0
- package/dist/chatbot.cjs +1 -0
- package/dist/chatbot.js +4 -0
- package/dist/checkbox-CdDTRdKV.cjs +37 -0
- package/dist/checkbox-g6kl2jGR.js +119 -0
- package/dist/checkbox.cjs +1 -0
- package/dist/checkbox.js +4 -0
- package/dist/combobox-CeK7yW2F.cjs +99 -0
- package/dist/combobox-DTUSFw9V.js +270 -0
- package/dist/combobox.cjs +1 -0
- package/dist/combobox.js +4 -0
- package/dist/datepicker-BQOVo1Pr.cjs +115 -0
- package/dist/datepicker-ChdQsc_l.js +751 -0
- package/dist/datepicker.cjs +1 -0
- package/dist/datepicker.js +4 -0
- package/dist/download-manager-BSIMTGaK.cjs +97 -0
- package/dist/download-manager-a541AYhr.js +381 -0
- package/dist/download-manager.cjs +1 -0
- package/dist/download-manager.js +4 -0
- package/dist/formfield-BOgRugzm.js +118 -0
- package/dist/formfield-D_7NFFoe.cjs +27 -0
- package/dist/formfield.cjs +1 -0
- package/dist/formfield.js +4 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +32 -3207
- package/dist/index.umd.js +106 -85
- package/dist/input-CoY1ZcPF.cjs +46 -0
- package/dist/input-CxBP0i-3.js +194 -0
- package/dist/input.cjs +1 -0
- package/dist/input.js +4 -0
- package/dist/modal-CnwRIdd8.js +110 -0
- package/dist/modal-DQ8VFL-P.cjs +39 -0
- package/dist/modal.cjs +1 -0
- package/dist/modal.js +4 -0
- package/dist/popover-C2p5Pmts.cjs +30 -0
- package/dist/popover-CaVOXo_k.js +140 -0
- package/dist/popover.cjs +1 -0
- package/dist/popover.js +4 -0
- package/dist/switch-CG4SSjTg.js +64 -0
- package/dist/switch-Rnnn10bn.cjs +17 -0
- package/dist/switch.cjs +1 -0
- package/dist/switch.js +4 -0
- package/dist/tab-BYU_XEhp.js +176 -0
- package/dist/tab-DcjAlXzU.cjs +40 -0
- package/dist/tab.cjs +1 -0
- package/dist/tab.js +4 -0
- package/dist/text-area-Dw4CUBcz.js +206 -0
- package/dist/text-area-eT-oCnqZ.cjs +44 -0
- package/dist/textarea.cjs +1 -0
- package/dist/textarea.js +4 -0
- package/dist/ui-icon-CVEyvL5D.cjs +22 -0
- package/dist/ui-icon-ltkJROhR.js +51 -0
- package/package.json +31 -20
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { unsafeCSS as f, css as v, LitElement as _, html as a } from "lit";
|
|
2
|
+
import { property as d, state as c, query as b, customElement as y } from "lit/decorators.js";
|
|
3
|
+
import { unsafeHTML as w } from "lit/directives/unsafe-html.js";
|
|
4
|
+
import "./combobox-DTUSFw9V.js";
|
|
5
|
+
import "./button-BqOMevro.js";
|
|
6
|
+
import "./input-CxBP0i-3.js";
|
|
7
|
+
import "./ui-icon-ltkJROhR.js";
|
|
8
|
+
const x = ":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;inset:0;background-color:#0003;z-index:var(--z-index-modal-backdrop)}.chatbot__launcher{position:fixed;z-index:var(--z-index-modal);display:flex;align-items:center;gap:var(--spacing-4);padding-left:var(--spacing-4);padding-right:var(--spacing-4);height:66px;color:#fff;border-radius:var(--radius-xl);cursor:pointer;box-shadow:var(--shadow-base);background-color:var(--color-body-bg);overflow:hidden;transition:box-shadow var(--transition-speed-fast) var(--transition-timing)}.chatbot__launcher:hover{box-shadow:var(--shadow-md)}.chatbot__launcher--draggable{cursor:move}.chatbot__launcher--hidden{visibility:hidden;width:72px;height:66px;justify-content:center;padding:0}.chatbot__launcher-icon{width:40px;height:34px;flex-shrink:0}.chatbot__launcher-text{display:flex;flex-direction:column}.chatbot__launcher-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;white-space:nowrap;color:var(--color-body-text)}.chatbot__launcher-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;white-space:nowrap;color:var(--color-tertiary)}.chatbot__window{position:fixed;z-index:var(--z-index-modal);display:flex;flex-direction:column;box-shadow:var(--shadow-xl);border-radius:var(--radius-md);overflow:hidden;background-color:var(--color-body-bg)}.chatbot__window--hidden{display:none}.chatbot__window--fullscreen{inset:80px 50px;width:auto;height:auto}.chatbot__resize-top{position:absolute;top:0;left:0;right:0;height:8px;cursor:ns-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-top:hover{background-color:#0000000d}.chatbot__resize-side{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-side:hover{background-color:#0000000d}.chatbot__resize-side--left{left:0}.chatbot__resize-side--right{right:0}.chatbot__resize-corner{position:absolute;top:0;width:16px;height:16px;z-index:50;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__resize-corner:hover{background-color:#0000001a}.chatbot__resize-corner--nwse{left:0;cursor:nwse-resize}.chatbot__resize-corner--nesw{right:0;cursor:nesw-resize}.chatbot__header{height:74px;display:flex;align-items:center;justify-content:space-between;padding-left:var(--spacing-5);padding-right:var(--spacing-4);gap:var(--spacing-4);flex-shrink:0;background-color:var(--color-body-bg);border-bottom:1px solid var(--color-border)}.chatbot__header-info{display:flex;align-items:center;gap:var(--spacing-4)}.chatbot__header-logo{width:50px;height:41px}.chatbot__header-title{font-weight:var(--font-weight-semibold);font-size:var(--font-size-xl);margin:0;line-height:24px;color:var(--color-body-text)}.chatbot__header-subtitle{font-weight:var(--font-weight-semibold);font-size:var(--font-size-sm);margin:0;line-height:20px;color:var(--color-tertiary)}.chatbot__header-actions{display:flex;align-items:center;gap:var(--spacing-2)}.chatbot__body{flex:1;display:flex;flex-direction:column;background-color:var(--color-body-bg);position:relative;overflow:hidden}.chatbot__product{padding:var(--spacing-3);padding-bottom:0;flex-shrink:0;margin:0 var(--spacing-3)}.chatbot__messages{flex:1;display:flex;flex-direction:column;gap:var(--spacing-3);margin-top:var(--spacing-4);padding:var(--spacing-4);overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none}.chatbot__messages::-webkit-scrollbar{display:none}.chatbot__message{display:flex}.chatbot__message--user{justify-content:flex-end}.chatbot__message--assistant,.chatbot__message--system{justify-content:flex-start}.chatbot__bubble{position:relative;color:var(--color-body-text);max-width:85%;border-radius:var(--radius-md);padding:var(--spacing-4);font-size:var(--font-size-sm);line-height:20px;font-weight:var(--font-weight-medium)}.chatbot__bubble--user{background-color:var(--color-primary);color:#fff;border-bottom-right-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.chatbot__bubble--user a{color:#ffffffe6}.chatbot__bubble--assistant,.chatbot__bubble--system{background-color:var(--color-tertiary-bg);border-bottom-left-radius:0;border-top-right-radius:var(--radius-xl);border-top-left-radius:var(--radius-xl);border-bottom-right-radius:var(--radius-xl)}.chatbot__message-content p{margin:0}.chatbot__message-content ol{list-style-type:decimal;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content ul{list-style-type:disc;margin:0;padding-left:var(--spacing-5)}.chatbot__message-content li{padding-left:var(--spacing-1)}.chatbot__message-content a{color:var(--color-primary);text-decoration:underline;transition:color var(--transition-speed-fast) var(--transition-timing)}.chatbot__message-content a:hover{color:var(--color-primary-hover)}.chatbot__feedback{display:flex;align-items:center;gap:var(--spacing-2);padding-top:var(--spacing-2)}.chatbot__typing-wrapper{display:flex;justify-content:flex-start}.chatbot__typing{background-color:var(--color-tertiary-bg);padding:var(--spacing-3);border-radius:var(--radius-xl);border-bottom-left-radius:0;display:inline-flex;align-items:center;gap:2px}.chatbot__typing-dot{display:inline-block;width:6px;height:6px;background-color:var(--color-gray-300);border-radius:var(--radius-full);animation:chatbot-typing 1.4s infinite ease-in-out both;margin:0 2px}.chatbot__typing-dot:nth-child(1){animation-delay:-.32s}.chatbot__typing-dot:nth-child(2){animation-delay:-.16s}@keyframes chatbot-typing{0%,80%,to{transform:scale(0)}40%{transform:scale(1)}}.chatbot__input-area{padding:var(--spacing-4);padding-top:var(--spacing-2);padding-bottom:var(--spacing-1);background-color:var(--color-body-bg)}.chatbot__input-wrapper{position:relative;display:flex;align-items:center;gap:var(--spacing-2);background-color:var(--color-tertiary-bg);border-radius:var(--radius-md);padding:var(--spacing-2);border:1px solid transparent;transition:background-color var(--transition-speed-fast) var(--transition-timing),border-color var(--transition-speed-fast) var(--transition-timing)}.chatbot__input-wrapper:focus-within{background-color:var(--color-body-bg);border-color:var(--color-border)}.chatbot__input{flex:1;background:transparent;border:none;outline:none;font-family:var(--font-family-base);font-size:var(--font-size-sm);color:var(--color-body-text)}.chatbot__input::placeholder{color:var(--color-tertiary)}.chatbot__input:disabled{opacity:.5;cursor:not-allowed}.chatbot__footer{display:flex;align-items:center;justify-content:center;padding-bottom:var(--spacing-2)}.chatbot__footer-text{margin:0;padding:0;color:var(--color-secondary);font-size:var(--font-size-xs);font-family:var(--font-family-base)}";
|
|
9
|
+
var z = Object.defineProperty, C = Object.getOwnPropertyDescriptor, s = (t, e, n, i) => {
|
|
10
|
+
for (var r = i > 1 ? void 0 : i ? C(e, n) : e, l = t.length - 1, h; l >= 0; l--)
|
|
11
|
+
(h = t[l]) && (r = (i ? h(e, n, r) : h(r)) || r);
|
|
12
|
+
return i && r && z(e, n, r), r;
|
|
13
|
+
};
|
|
14
|
+
let o = class extends _ {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments), this.returnUri = "", this.questionPrompt = "", this.minimizedIconOnly = !1, this.draggable = !1, this.resizable = !1, this.products = [], this.openInitially = !1, this.showFeedbackButtons = !1, this.open = !1, this.fullscreen = !1, this.messages = [], this.isLoading = !1, this.inputText = "", this.selectedProductId = "", this.windowWidth = 440, this.windowHeight = Math.min(700, window.innerHeight - 40), this.position = { right: 20, bottom: 20 }, this.isDragging = !1, this.screenWidth = window.innerWidth, this.dragStartPos = { x: 0, y: 0 }, this.initialPosition = { right: 0, bottom: 0 }, this.isResizing = !1, this.resizeDirection = "horizontal", this.resizeStartWidth = 0, this.resizeStartHeight = 0, this.onWindowResize = () => {
|
|
17
|
+
this.screenWidth = window.innerWidth;
|
|
18
|
+
const t = window.innerHeight - 40;
|
|
19
|
+
this.windowHeight > t && (this.windowHeight = t);
|
|
20
|
+
}, this.onToggle = () => {
|
|
21
|
+
this.open = !this.open, this.scrollToBottom();
|
|
22
|
+
}, this.onClose = () => {
|
|
23
|
+
this.open = !1, this.fullscreen = !1;
|
|
24
|
+
}, this.onToggleFullscreen = () => {
|
|
25
|
+
this.fullscreen = !this.fullscreen;
|
|
26
|
+
}, this.onMouseMove = (t) => {
|
|
27
|
+
if (this.isDragging) {
|
|
28
|
+
const e = this.dragStartPos.x - t.clientX, n = this.dragStartPos.y - t.clientY, r = this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(), l = r?.width || 72, h = r?.height || 66;
|
|
29
|
+
this.position = {
|
|
30
|
+
right: Math.max(0, Math.min(window.innerWidth - l, this.initialPosition.right + e)),
|
|
31
|
+
bottom: Math.max(0, Math.min(window.innerHeight - h, this.initialPosition.bottom + n))
|
|
32
|
+
};
|
|
33
|
+
} else if (this.isResizing) {
|
|
34
|
+
const e = this.dragStartPos.x - t.clientX, n = this.dragStartPos.y - t.clientY;
|
|
35
|
+
if (this.resizeDirection === "horizontal" || this.resizeDirection === "both") {
|
|
36
|
+
const i = this.position.right < this.screenWidth / 2;
|
|
37
|
+
this.windowWidth = Math.max(300, this.resizeStartWidth + (i ? e : -e));
|
|
38
|
+
}
|
|
39
|
+
(this.resizeDirection === "vertical" || this.resizeDirection === "both") && (this.windowHeight = Math.max(400, this.resizeStartHeight + n));
|
|
40
|
+
}
|
|
41
|
+
}, this.onMouseUp = (t) => {
|
|
42
|
+
this.isDragging ? (this.isDragging = !1, window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("mouseup", this.onMouseUp), Math.hypot(t.clientX - this.dragStartPos.x, t.clientY - this.dragStartPos.y) < 5 && this.onToggle()) : this.isResizing && (this.isResizing = !1, window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("mouseup", this.onMouseUp));
|
|
43
|
+
}, this.handleKeyDown = (t) => {
|
|
44
|
+
t.key === "Enter" && !t.shiftKey && (t.preventDefault(), this.sendMessage());
|
|
45
|
+
}, this.onInput = (t) => {
|
|
46
|
+
const e = t.target;
|
|
47
|
+
this.inputText = e ? e.value : t.detail;
|
|
48
|
+
}, this.onCopyMessage = (t) => {
|
|
49
|
+
navigator.clipboard.writeText(t);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
super.connectedCallback(), window.addEventListener("resize", this.onWindowResize);
|
|
54
|
+
}
|
|
55
|
+
disconnectedCallback() {
|
|
56
|
+
super.disconnectedCallback(), window.removeEventListener("resize", this.onWindowResize), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("mouseup", this.onMouseUp);
|
|
57
|
+
}
|
|
58
|
+
async firstUpdated() {
|
|
59
|
+
this.products.length === 1 && (this.selectedProductId = this.products[0].id), this.open = this.openInitially, this.open && await this.initConversation();
|
|
60
|
+
}
|
|
61
|
+
updated(t) {
|
|
62
|
+
t.has("products") && this.handleProductUpdate(), t.has("messages") && this.scrollToBottom(), t.has("open") && this.open && !this.conversationId && this.initConversation();
|
|
63
|
+
}
|
|
64
|
+
// ==================== PRODUCT ====================
|
|
65
|
+
handleProductUpdate() {
|
|
66
|
+
if (!this.products.length) return;
|
|
67
|
+
const t = this.products.some((e) => e.id === this.selectedProductId);
|
|
68
|
+
this.products.length === 1 && (this.selectedProductId = this.products[0].id), t || (this.messages = [], this.conversationId = void 0, this.open && this.initConversation()), requestAnimationFrame(() => this.updateComboboxItems());
|
|
69
|
+
}
|
|
70
|
+
updateComboboxItems() {
|
|
71
|
+
const t = this.productEl;
|
|
72
|
+
if (!t || this.products?.length <= 1) return;
|
|
73
|
+
const e = this.products.map((i) => ({ value: i.id, label: i.name }));
|
|
74
|
+
t.items = e;
|
|
75
|
+
const n = t.selectedItems?.() || [];
|
|
76
|
+
if (n.length > 0) {
|
|
77
|
+
const i = n[0]?.value;
|
|
78
|
+
!this.products.some((l) => l.id === i) && t.setSelected && t.setSelected([]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async onProductChange(t) {
|
|
82
|
+
const e = t.detail?.selected?.[0]?.value;
|
|
83
|
+
e && e !== this.selectedProductId && (this.selectedProductId = e);
|
|
84
|
+
}
|
|
85
|
+
// ==================== DRAG ====================
|
|
86
|
+
onMouseDown(t) {
|
|
87
|
+
this.draggable && (t.preventDefault(), this.isDragging = !0, this.dragStartPos = { x: t.clientX, y: t.clientY }, this.initialPosition = { ...this.position }, window.addEventListener("mousemove", this.onMouseMove), window.addEventListener("mouseup", this.onMouseUp));
|
|
88
|
+
}
|
|
89
|
+
startResize(t, e) {
|
|
90
|
+
this.resizable && (t.preventDefault(), t.stopPropagation(), this.isResizing = !0, this.resizeDirection = e, this.dragStartPos = { x: t.clientX, y: t.clientY }, this.resizeStartWidth = this.windowWidth, this.resizeStartHeight = this.windowHeight, window.addEventListener("mousemove", this.onMouseMove), window.addEventListener("mouseup", this.onMouseUp));
|
|
91
|
+
}
|
|
92
|
+
// ==================== CHAT API ====================
|
|
93
|
+
async ensureToken(t = !1) {
|
|
94
|
+
const e = "logosphere_chatbot_token";
|
|
95
|
+
if (t && (this.assertionToken = void 0, localStorage.removeItem(e)), !t) {
|
|
96
|
+
const r = localStorage.getItem(e);
|
|
97
|
+
if (r) {
|
|
98
|
+
this.assertionToken = r;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const i = await (await fetch(`${this.returnUri}/api/chat/start`)).json();
|
|
103
|
+
if (!i.Success || !i.Data?.Token) throw new Error("Token alınamadı");
|
|
104
|
+
this.assertionToken = i.Data.Token, localStorage.setItem(e, this.assertionToken);
|
|
105
|
+
}
|
|
106
|
+
async postChat(t) {
|
|
107
|
+
await this.ensureToken();
|
|
108
|
+
const e = `${this.returnUri}/api/chat/completions`, n = () => fetch(e, {
|
|
109
|
+
method: "POST",
|
|
110
|
+
headers: {
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
client_assertion: this.assertionToken,
|
|
113
|
+
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
|
|
114
|
+
},
|
|
115
|
+
body: JSON.stringify(t)
|
|
116
|
+
});
|
|
117
|
+
let i = await n();
|
|
118
|
+
if (i.status === 401 && (await this.ensureToken(!0), i = await n()), !i.ok) throw new Error(`HTTP ${i.status}`);
|
|
119
|
+
return i.json();
|
|
120
|
+
}
|
|
121
|
+
async initConversation() {
|
|
122
|
+
if (!this.isLoading) {
|
|
123
|
+
this.isLoading = !0;
|
|
124
|
+
try {
|
|
125
|
+
await this.ensureToken();
|
|
126
|
+
const t = await this.postChat({
|
|
127
|
+
ChatCompletionType: "NewConversation",
|
|
128
|
+
Context: this.selectedProductId,
|
|
129
|
+
QuestionPrompt: this.questionPrompt
|
|
130
|
+
});
|
|
131
|
+
this.conversationId = t.Data.ConversationId;
|
|
132
|
+
const e = t.Data.Choices?.[0]?.Message?.Content;
|
|
133
|
+
e && this.addMessage(e, "assistant");
|
|
134
|
+
} catch {
|
|
135
|
+
this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.", "system");
|
|
136
|
+
} finally {
|
|
137
|
+
this.isLoading = !1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async sendMessage() {
|
|
142
|
+
const t = this.inputText.trim();
|
|
143
|
+
if (!(!t || !this.conversationId || this.isLoading)) {
|
|
144
|
+
if (!this.selectedProductId) {
|
|
145
|
+
this.addMessage("Lütfen önce bir ürün seçiniz.", "system");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.addMessage(t, "user"), this.inputText = "", this.isLoading = !0;
|
|
149
|
+
try {
|
|
150
|
+
const n = (await this.postChat({
|
|
151
|
+
ChatCompletionType: "ConversationUpdate",
|
|
152
|
+
Content: t,
|
|
153
|
+
Context: this.selectedProductId,
|
|
154
|
+
ConversationId: this.conversationId,
|
|
155
|
+
QuestionPrompt: this.questionPrompt
|
|
156
|
+
})).Data?.Choices?.[0]?.Message?.Content;
|
|
157
|
+
this.addMessage(n || "Cevap alınamadı.", "assistant");
|
|
158
|
+
} catch {
|
|
159
|
+
this.addMessage("Bağlantı hatası.", "system");
|
|
160
|
+
} finally {
|
|
161
|
+
this.isLoading = !1;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
addMessage(t, e) {
|
|
166
|
+
this.messages = [...this.messages, { content: t, role: e, timestamp: Date.now() }];
|
|
167
|
+
}
|
|
168
|
+
scrollToBottom() {
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
this.chatContainer && (this.chatContainer.scrollTop = this.chatContainer.scrollHeight);
|
|
171
|
+
}, 0);
|
|
172
|
+
}
|
|
173
|
+
// ==================== CONTENT FORMATTER ====================
|
|
174
|
+
formatContent(t) {
|
|
175
|
+
if (!t) return "";
|
|
176
|
+
const n = t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").split(`
|
|
177
|
+
`);
|
|
178
|
+
let i = "", r = !1, l = "";
|
|
179
|
+
for (const h of n) {
|
|
180
|
+
const m = h.trim() === "", p = h.match(/^\s*\d+\.\s+(.*)/), g = h.match(/^\s*[-*]\s+(.*)/);
|
|
181
|
+
if (p || g) {
|
|
182
|
+
const u = p ? "ol" : "ul";
|
|
183
|
+
(!r || l !== u) && (r && (i += `</${l}>`), i += `<${u}>`, r = !0, l = u), i += `<li>${p ? p[1] : g[1]}</li>`;
|
|
184
|
+
} else
|
|
185
|
+
m ? r || (i += "<br>") : (r && (i += `</${l}>`, r = !1, l = ""), i += `<p>${h}</p>`);
|
|
186
|
+
}
|
|
187
|
+
return r && (i += `</${l}>`), i.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>").replace(/\*(.*?)\*/g, "<em>$1</em>").replace(
|
|
188
|
+
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
189
|
+
'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
// ==================== RENDER ====================
|
|
193
|
+
render() {
|
|
194
|
+
const t = this.position.right < this.screenWidth / 2;
|
|
195
|
+
return a`
|
|
196
|
+
<div class="chatbot">
|
|
197
|
+
${this.renderOverlay()}
|
|
198
|
+
${this.renderLauncher()}
|
|
199
|
+
${this.renderWindow(t)}
|
|
200
|
+
</div>
|
|
201
|
+
`;
|
|
202
|
+
}
|
|
203
|
+
renderOverlay() {
|
|
204
|
+
return this.open || this.fullscreen ? a`<div class="chatbot__overlay" @click=${this.onToggle}></div>` : "";
|
|
205
|
+
}
|
|
206
|
+
renderLauncher() {
|
|
207
|
+
const t = [
|
|
208
|
+
"chatbot__launcher",
|
|
209
|
+
this.draggable ? "chatbot__launcher--draggable" : "",
|
|
210
|
+
this.open ? "chatbot__launcher--hidden" : ""
|
|
211
|
+
].filter(Boolean).join(" ");
|
|
212
|
+
return a`
|
|
213
|
+
<div
|
|
214
|
+
class="${t}"
|
|
215
|
+
style="right: ${this.position.right}px; bottom: ${this.position.bottom}px;"
|
|
216
|
+
@mousedown=${this.onMouseDown}
|
|
217
|
+
@click=${this.draggable ? null : this.onToggle}
|
|
218
|
+
aria-expanded=${this.open ? "true" : "false"}
|
|
219
|
+
>
|
|
220
|
+
<img class="chatbot__launcher-icon" src="${o.ICONS.launcher}" alt="chatbot" />
|
|
221
|
+
${!this.open && !this.minimizedIconOnly ? a`
|
|
222
|
+
<div class="chatbot__launcher-text">
|
|
223
|
+
<p class="chatbot__launcher-title">Logo</p>
|
|
224
|
+
<p class="chatbot__launcher-subtitle">Dijital Danışman</p>
|
|
225
|
+
</div>
|
|
226
|
+
` : ""}
|
|
227
|
+
</div>
|
|
228
|
+
`;
|
|
229
|
+
}
|
|
230
|
+
renderWindow(t) {
|
|
231
|
+
const e = [
|
|
232
|
+
"chatbot__window",
|
|
233
|
+
this.open ? "" : "chatbot__window--hidden",
|
|
234
|
+
this.fullscreen ? "chatbot__window--fullscreen" : ""
|
|
235
|
+
].filter(Boolean).join(" "), n = this.fullscreen ? "" : `bottom: 20px; height: ${this.windowHeight}px; width: ${this.windowWidth}px; ${t ? "right: 20px;" : "left: 20px;"}`;
|
|
236
|
+
return a`
|
|
237
|
+
<div class="${e}" style="${n}">
|
|
238
|
+
${this.renderResizeHandles(t)}
|
|
239
|
+
${this.renderHeader()}
|
|
240
|
+
<div class="chatbot__body">
|
|
241
|
+
${this.renderProductSelector()}
|
|
242
|
+
${this.renderChatArea()}
|
|
243
|
+
${this.renderInputArea()}
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
`;
|
|
247
|
+
}
|
|
248
|
+
renderResizeHandles(t) {
|
|
249
|
+
return this.fullscreen || !this.resizable ? "" : a`
|
|
250
|
+
<div class="chatbot__resize-top"
|
|
251
|
+
@mousedown=${(e) => this.startResize(e, "vertical")}></div>
|
|
252
|
+
<div class="chatbot__resize-side ${t ? "chatbot__resize-side--left" : "chatbot__resize-side--right"}"
|
|
253
|
+
@mousedown=${(e) => this.startResize(e, "horizontal")}></div>
|
|
254
|
+
<div class="chatbot__resize-corner ${t ? "chatbot__resize-corner--nwse" : "chatbot__resize-corner--nesw"}"
|
|
255
|
+
@mousedown=${(e) => this.startResize(e, "both")}></div>
|
|
256
|
+
`;
|
|
257
|
+
}
|
|
258
|
+
renderHeader() {
|
|
259
|
+
return a`
|
|
260
|
+
<div class="chatbot__header">
|
|
261
|
+
<div class="chatbot__header-info">
|
|
262
|
+
<img class="chatbot__header-logo" alt="logo" src="${o.ICONS.launcher}" />
|
|
263
|
+
<div>
|
|
264
|
+
<p class="chatbot__header-title">Logo</p>
|
|
265
|
+
<p class="chatbot__header-subtitle">Dijital Danışman</p>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
<div class="chatbot__header-actions">
|
|
269
|
+
<logosphere-button
|
|
270
|
+
iconOnly="true"
|
|
271
|
+
size="sm"
|
|
272
|
+
variant="text"
|
|
273
|
+
theme="--color-light-rgb"
|
|
274
|
+
title=${this.fullscreen ? "Küçült" : "Tam Ekran"}
|
|
275
|
+
@click=${this.onToggleFullscreen}
|
|
276
|
+
>
|
|
277
|
+
<ui-icon name="${this.fullscreen ? "uil-compress-alt" : "uil-expand-alt"}" size="16"></ui-icon>
|
|
278
|
+
</logosphere-button>
|
|
279
|
+
<logosphere-button
|
|
280
|
+
iconOnly="true"
|
|
281
|
+
size="sm"
|
|
282
|
+
variant="text"
|
|
283
|
+
theme="--color-light"
|
|
284
|
+
title="Kapat"
|
|
285
|
+
@click=${this.onClose}
|
|
286
|
+
>
|
|
287
|
+
<ui-icon name="uil-times" size="16"></ui-icon>
|
|
288
|
+
</logosphere-button>
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
`;
|
|
292
|
+
}
|
|
293
|
+
renderProductSelector() {
|
|
294
|
+
return a`
|
|
295
|
+
<div class="chatbot__product">
|
|
296
|
+
${this.products.length > 1 ? a`
|
|
297
|
+
<logosphere-combobox
|
|
298
|
+
id="product"
|
|
299
|
+
.items=${this.products.map((t) => ({ value: t.id, label: t.name }))}
|
|
300
|
+
optionValue="value"
|
|
301
|
+
optionLabel="label"
|
|
302
|
+
placeholder="Ürün seçiniz"
|
|
303
|
+
@selected=${this.onProductChange}
|
|
304
|
+
></logosphere-combobox>
|
|
305
|
+
` : a`
|
|
306
|
+
<logosphere-input
|
|
307
|
+
id="product"
|
|
308
|
+
placeholder="Ürün seçiniz"
|
|
309
|
+
.value=${this.products.length === 1 ? this.products[0].name : ""}
|
|
310
|
+
readOnly="true"
|
|
311
|
+
></logosphere-input>
|
|
312
|
+
`}
|
|
313
|
+
</div>
|
|
314
|
+
`;
|
|
315
|
+
}
|
|
316
|
+
renderChatArea() {
|
|
317
|
+
return a`
|
|
318
|
+
<div id="chat-container" class="chatbot__messages">
|
|
319
|
+
${this.messages.map((t) => this.renderMessage(t))}
|
|
320
|
+
${this.isLoading ? this.renderTypingIndicator() : ""}
|
|
321
|
+
</div>
|
|
322
|
+
`;
|
|
323
|
+
}
|
|
324
|
+
renderMessage(t) {
|
|
325
|
+
const e = [
|
|
326
|
+
"chatbot__bubble",
|
|
327
|
+
`chatbot__bubble--${t.role}`
|
|
328
|
+
].join(" ");
|
|
329
|
+
return a`
|
|
330
|
+
<div class="chatbot__message chatbot__message--${t.role}">
|
|
331
|
+
<div class="${e}">
|
|
332
|
+
<div class="chatbot__message-content">
|
|
333
|
+
${w(this.formatContent(t.content))}
|
|
334
|
+
</div>
|
|
335
|
+
${this.showFeedbackButtons && t.role === "assistant" ? this.renderFeedbackButtons(t) : ""}
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
`;
|
|
339
|
+
}
|
|
340
|
+
renderFeedbackButtons(t) {
|
|
341
|
+
return a`
|
|
342
|
+
<div class="chatbot__feedback">
|
|
343
|
+
<logosphere-button
|
|
344
|
+
@click=${() => this.onCopyMessage(t.content)}
|
|
345
|
+
title="Kopyala"
|
|
346
|
+
iconOnly="true"
|
|
347
|
+
size="sm"
|
|
348
|
+
theme="--color-light-rgb"
|
|
349
|
+
>
|
|
350
|
+
<ui-icon name="uil-copy" size="14"></ui-icon>
|
|
351
|
+
</logosphere-button>
|
|
352
|
+
<logosphere-button title="Like" iconOnly="true" size="sm" theme="--color-light-rgb">
|
|
353
|
+
<ui-icon name="uil-thumbs-up" size="14"></ui-icon>
|
|
354
|
+
</logosphere-button>
|
|
355
|
+
<logosphere-button title="Dislike" iconOnly="true" size="sm" theme="--color-light-rgb">
|
|
356
|
+
<ui-icon name="uil-thumbs-down" size="14"></ui-icon>
|
|
357
|
+
</logosphere-button>
|
|
358
|
+
</div>
|
|
359
|
+
`;
|
|
360
|
+
}
|
|
361
|
+
renderTypingIndicator() {
|
|
362
|
+
return a`
|
|
363
|
+
<div class="chatbot__typing-wrapper">
|
|
364
|
+
<div class="chatbot__typing">
|
|
365
|
+
<span class="chatbot__typing-dot"></span>
|
|
366
|
+
<span class="chatbot__typing-dot"></span>
|
|
367
|
+
<span class="chatbot__typing-dot"></span>
|
|
368
|
+
</div>
|
|
369
|
+
</div>
|
|
370
|
+
`;
|
|
371
|
+
}
|
|
372
|
+
renderInputArea() {
|
|
373
|
+
return a`
|
|
374
|
+
<div class="chatbot__input-area">
|
|
375
|
+
<div class="chatbot__input-wrapper">
|
|
376
|
+
<input
|
|
377
|
+
class="chatbot__input"
|
|
378
|
+
placeholder=${this.selectedProductId ? "Bir şeyler yazın..." : "Lütfen ürün seçiniz..."}
|
|
379
|
+
.value=${this.inputText}
|
|
380
|
+
@input=${this.onInput}
|
|
381
|
+
@keydown=${this.handleKeyDown}
|
|
382
|
+
?disabled=${!this.selectedProductId}
|
|
383
|
+
/>
|
|
384
|
+
<logosphere-button
|
|
385
|
+
iconOnly="true"
|
|
386
|
+
size="lg"
|
|
387
|
+
variant="text"
|
|
388
|
+
theme="--color-light"
|
|
389
|
+
title="Gönder"
|
|
390
|
+
@click=${this.sendMessage}
|
|
391
|
+
?disabled=${!this.selectedProductId || !this.inputText.trim()}
|
|
392
|
+
>
|
|
393
|
+
<ui-icon name="uil-arrow-circle-right" size="20"></ui-icon>
|
|
394
|
+
</logosphere-button>
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
<div class="chatbot__footer">
|
|
398
|
+
<p class="chatbot__footer-text">İçerik Yapay Zeka ile Üretilmiştir</p>
|
|
399
|
+
</div>
|
|
400
|
+
`;
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
o.styles = [v`${f(x)}`];
|
|
404
|
+
o.ICONS = {
|
|
405
|
+
launcher: "data:image/svg+xml,%3Csvg%20width%3D%2251%22%20height%3D%2242%22%20viewBox%3D%220%200%2051%2042%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M38.457%200C40.0338%200%2041.542%200.293293%2042.9302%200.8283L49.15%206.07675C50.2611%207.93912%2050.8994%2010.1162%2050.8994%2012.4424V23.084C50.8994%2024.4858%2050.6676%2025.8334%2050.2402%2027.0907L43.1534%2034.6096C41.7043%2035.2006%2040.1187%2035.5264%2038.457%2035.5264H30.7605L38.5805%2027.2296C40.814%2027.1643%2042.6045%2025.3332%2042.6045%2023.084V12.4424C42.6045%2010.1518%2040.7476%208.29492%2038.457%208.29492H12.4424C10.1518%208.29492%208.29492%2010.1518%208.29492%2012.4424V23.084C8.29492%2025.3746%2010.1518%2027.2314%2012.4424%2027.2314H33.5078L20.4487%2041.0866C17.7992%2042.5379%2014.3381%2040.2741%2014.7842%2036.7803C14.8402%2036.3421%2014.9629%2035.9194%2015.1416%2035.5264H12.4424C10.9217%2035.5264%209.46472%2035.2536%208.11774%2034.7542L0.610679%2026.945C0.214298%2025.7295%200%2024.4318%200%2023.084V12.4424C0%2010.8011%200.317794%209.23402%200.895207%207.79935L7.12424%201.19058C8.73679%200.427072%2010.5397%200%2012.4424%200H38.457ZM23.1357%2017.7881C23.1357%2015.4815%2021.2656%2013.6113%2018.959%2013.6113C16.6525%2013.6114%2014.7822%2015.4815%2014.7822%2017.7881C14.7824%2020.0945%2016.6526%2021.9638%2018.959%2021.9639C21.2655%2021.9639%2023.1356%2020.0945%2023.1357%2017.7881ZM36.2344%2017.7881C36.2344%2015.4815%2034.3642%2013.6113%2032.0576%2013.6113C29.7511%2013.6114%2027.8809%2015.4815%2027.8809%2017.7881C27.881%2020.0945%2029.7512%2021.9638%2032.0576%2021.9639C34.3641%2021.9639%2036.2342%2020.0945%2036.2344%2017.7881Z%22%20fill%3D%22url(%23paint0_linear_97_4585)%22%2F%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22paint0_linear_97_4585%22%20x1%3D%2231.662%22%20y1%3D%224.88016%22%20x2%3D%2214.4119%22%20y2%3D%2237.9167%22%20gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop%20stop-color%3D%22%23F22727%22%2F%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23CA0D0D%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E"
|
|
406
|
+
};
|
|
407
|
+
s([
|
|
408
|
+
d({ type: String, attribute: "return-uri" })
|
|
409
|
+
], o.prototype, "returnUri", 2);
|
|
410
|
+
s([
|
|
411
|
+
d({ type: String, attribute: "question-prompt" })
|
|
412
|
+
], o.prototype, "questionPrompt", 2);
|
|
413
|
+
s([
|
|
414
|
+
d({ type: Boolean, attribute: "minimized-icon-only" })
|
|
415
|
+
], o.prototype, "minimizedIconOnly", 2);
|
|
416
|
+
s([
|
|
417
|
+
d({ type: Boolean, attribute: "draggable" })
|
|
418
|
+
], o.prototype, "draggable", 2);
|
|
419
|
+
s([
|
|
420
|
+
d({ type: Boolean, attribute: "resizable" })
|
|
421
|
+
], o.prototype, "resizable", 2);
|
|
422
|
+
s([
|
|
423
|
+
d({
|
|
424
|
+
type: Array,
|
|
425
|
+
hasChanged: (t, e) => t === e ? !1 : !e || !t || t.length !== e.length ? !0 : JSON.stringify(t) !== JSON.stringify(e)
|
|
426
|
+
}),
|
|
427
|
+
d({ type: Array })
|
|
428
|
+
], o.prototype, "products", 2);
|
|
429
|
+
s([
|
|
430
|
+
d({ type: Boolean, attribute: "open-initially" })
|
|
431
|
+
], o.prototype, "openInitially", 2);
|
|
432
|
+
s([
|
|
433
|
+
d({ type: Boolean, attribute: "show-feedback-buttons" })
|
|
434
|
+
], o.prototype, "showFeedbackButtons", 2);
|
|
435
|
+
s([
|
|
436
|
+
c()
|
|
437
|
+
], o.prototype, "open", 2);
|
|
438
|
+
s([
|
|
439
|
+
c()
|
|
440
|
+
], o.prototype, "fullscreen", 2);
|
|
441
|
+
s([
|
|
442
|
+
c()
|
|
443
|
+
], o.prototype, "messages", 2);
|
|
444
|
+
s([
|
|
445
|
+
c()
|
|
446
|
+
], o.prototype, "conversationId", 2);
|
|
447
|
+
s([
|
|
448
|
+
c()
|
|
449
|
+
], o.prototype, "assertionToken", 2);
|
|
450
|
+
s([
|
|
451
|
+
c()
|
|
452
|
+
], o.prototype, "isLoading", 2);
|
|
453
|
+
s([
|
|
454
|
+
c()
|
|
455
|
+
], o.prototype, "inputText", 2);
|
|
456
|
+
s([
|
|
457
|
+
c()
|
|
458
|
+
], o.prototype, "selectedProductId", 2);
|
|
459
|
+
s([
|
|
460
|
+
c()
|
|
461
|
+
], o.prototype, "windowWidth", 2);
|
|
462
|
+
s([
|
|
463
|
+
c()
|
|
464
|
+
], o.prototype, "windowHeight", 2);
|
|
465
|
+
s([
|
|
466
|
+
c()
|
|
467
|
+
], o.prototype, "position", 2);
|
|
468
|
+
s([
|
|
469
|
+
c()
|
|
470
|
+
], o.prototype, "isDragging", 2);
|
|
471
|
+
s([
|
|
472
|
+
c()
|
|
473
|
+
], o.prototype, "screenWidth", 2);
|
|
474
|
+
s([
|
|
475
|
+
b("#chat-container")
|
|
476
|
+
], o.prototype, "chatContainer", 2);
|
|
477
|
+
s([
|
|
478
|
+
b("#product")
|
|
479
|
+
], o.prototype, "productEl", 2);
|
|
480
|
+
o = s([
|
|
481
|
+
y("logosphere-chatbot")
|
|
482
|
+
], o);
|
|
483
|
+
export {
|
|
484
|
+
o as L
|
|
485
|
+
};
|