@logosphere-ui/core 0.0.0-alpha.21 → 0.0.0-alpha.23

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.
@@ -1,15 +1,15 @@
1
1
  import { unsafeCSS as x, css as z, LitElement as C, html as a } from "lit";
2
- import { property as d, state as l, query as y, customElement as k } from "lit/decorators.js";
2
+ import { property as h, state as l, query as y, customElement as k } from "lit/decorators.js";
3
3
  import { unsafeHTML as $ } from "lit/directives/unsafe-html.js";
4
4
  import "./combobox-LBU6VHLi.js";
5
5
  import "./button-BqOMevro.js";
6
6
  import "./input-jmbvgWEq.js";
7
7
  import "./ui-icon-Bys4HYSQ.js";
8
8
  const D = ":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>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.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)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";
9
- var M = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (t, e, n, i) => {
10
- for (var o = i > 1 ? void 0 : i ? I(e, n) : e, c = t.length - 1, h; c >= 0; c--)
11
- (h = t[c]) && (o = (i ? h(e, n, o) : h(o)) || o);
12
- return i && o && M(e, n, o), o;
9
+ var I = Object.defineProperty, M = Object.getOwnPropertyDescriptor, r = (t, e, n, i) => {
10
+ for (var o = i > 1 ? void 0 : i ? M(e, n) : e, c = t.length - 1, d; c >= 0; c--)
11
+ (d = t[c]) && (o = (i ? d(e, n, o) : d(o)) || o);
12
+ return i && o && I(e, n, o), o;
13
13
  };
14
14
  let s = class extends C {
15
15
  constructor() {
@@ -25,10 +25,10 @@ let s = class extends C {
25
25
  this.fullscreen = !this.fullscreen;
26
26
  }, this.onMouseMove = (t) => {
27
27
  if (this.isDragging) {
28
- const e = this.dragStartPos.x - t.clientX, n = this.dragStartPos.y - t.clientY, o = this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(), c = o?.width || 72, h = o?.height || 66;
28
+ const e = this.dragStartPos.x - t.clientX, n = this.dragStartPos.y - t.clientY, o = this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(), c = o?.width || 72, d = o?.height || 66;
29
29
  this.position = {
30
30
  right: Math.max(0, Math.min(window.innerWidth - c, this.initialPosition.right + e)),
31
- bottom: Math.max(0, Math.min(window.innerHeight - h, this.initialPosition.bottom + n))
31
+ bottom: Math.max(0, Math.min(window.innerHeight - d, this.initialPosition.bottom + n))
32
32
  };
33
33
  } else if (this.isResizing) {
34
34
  const e = this.dragStartPos.x - t.clientX, n = this.dragStartPos.y - t.clientY;
@@ -69,21 +69,16 @@ let s = class extends C {
69
69
  }
70
70
  handleProductUpdate() {
71
71
  if (!this.products.length) return;
72
- const t = this._resolveInitialProduct();
73
- this.products.some((n) => n.id === this.selectedProductId) || (this.selectedProductId = t, this.messages = [], this.conversationId = void 0, this.open && this.initConversation()), requestAnimationFrame(() => this.updateComboboxItems());
72
+ const t = this.products.find((n) => n.selected), e = this.products.some((n) => n.id === this.selectedProductId);
73
+ t && t.id !== this.selectedProductId ? (this.selectedProductId = t.id, this.messages = [], this.conversationId = void 0, this.open && this.initConversation()) : e || (this.selectedProductId = this._resolveInitialProduct(), this.messages = [], this.conversationId = void 0, this.open && this.initConversation()), requestAnimationFrame(() => this.updateComboboxItems());
74
74
  }
75
75
  updateComboboxItems() {
76
76
  const t = this.productEl;
77
77
  if (!t || this.products?.length <= 1) return;
78
78
  const e = this.products.map((i) => ({ value: i.id, label: i.name }));
79
- t.items = e;
80
- const n = t.selectedItems?.() || [];
81
- if (n.length === 0 && this.selectedProductId) {
79
+ if (t.items = e, (t.selectedItems?.() || [])[0]?.value !== this.selectedProductId) {
82
80
  const i = e.find((o) => o.value === this.selectedProductId);
83
- i && t.setSelected && t.setSelected([i]);
84
- } else if (n.length > 0) {
85
- const i = n[0]?.value;
86
- !this.products.some((c) => c.id === i) && t.setSelected && t.setSelected([]);
81
+ t.setSelected && t.setSelected(i ? [i] : []);
87
82
  }
88
83
  }
89
84
  async onProductChange(t) {
@@ -186,11 +181,11 @@ let s = class extends C {
186
181
  let i = "";
187
182
  const o = [];
188
183
  let c = !1;
189
- const h = () => {
184
+ const d = () => {
190
185
  c && (i += "</li>", c = !1);
191
186
  }, v = (u) => {
192
187
  for (; o.length > 0 && o[o.length - 1].indent >= u; )
193
- h(), i += `</${o.pop().type}>`, o.length > 0 && (c = !0);
188
+ d(), i += `</${o.pop().type}>`, o.length > 0 && (c = !0);
194
189
  }, m = () => v(-1);
195
190
  for (const u of n) {
196
191
  const g = u.match(/^(\s*)\d+\.\s+(.*)/), f = u.match(/^(\s*)[-*]\s+(.*)/);
@@ -200,7 +195,7 @@ let s = class extends C {
200
195
  i += `<${b}>`, o.push({ type: b, indent: p });
201
196
  else {
202
197
  const _ = o[o.length - 1];
203
- p > _.indent ? (i += `<${b}>`, o.push({ type: b, indent: p })) : p === _.indent ? h() : (v(p + 1), o.length > 0 && o[o.length - 1].indent === p ? h() : (m(), i += `<${b}>`, o.push({ type: b, indent: p })));
198
+ p > _.indent ? (i += `<${b}>`, o.push({ type: b, indent: p })) : p === _.indent ? d() : (v(p + 1), o.length > 0 && o[o.length - 1].indent === p ? d() : (m(), i += `<${b}>`, o.push({ type: b, indent: p })));
204
199
  }
205
200
  i += `<li>${w}`, c = !0;
206
201
  } else u.trim() === "" ? o.length === 0 && (i += "<br>") : (m(), i += `<p>${u}</p>`);
@@ -427,32 +422,32 @@ s.ICONS = {
427
422
  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"
428
423
  };
429
424
  r([
430
- d({ type: String, attribute: "return-uri" })
425
+ h({ type: String, attribute: "return-uri" })
431
426
  ], s.prototype, "returnUri", 2);
432
427
  r([
433
- d({ type: String, attribute: "question-prompt" })
428
+ h({ type: String, attribute: "question-prompt" })
434
429
  ], s.prototype, "questionPrompt", 2);
435
430
  r([
436
- d({ type: Boolean, attribute: "minimized-icon-only" })
431
+ h({ type: Boolean, attribute: "minimized-icon-only" })
437
432
  ], s.prototype, "minimizedIconOnly", 2);
438
433
  r([
439
- d({ type: Boolean, attribute: "draggable" })
434
+ h({ type: Boolean, attribute: "draggable" })
440
435
  ], s.prototype, "draggable", 2);
441
436
  r([
442
- d({ type: Boolean, attribute: "resizable" })
437
+ h({ type: Boolean, attribute: "resizable" })
443
438
  ], s.prototype, "resizable", 2);
444
439
  r([
445
- d({
440
+ h({
446
441
  type: Array,
447
442
  hasChanged: (t, e) => t === e ? !1 : !e || !t || t.length !== e.length ? !0 : JSON.stringify(t) !== JSON.stringify(e)
448
443
  }),
449
- d({ type: Array })
444
+ h({ type: Array })
450
445
  ], s.prototype, "products", 2);
451
446
  r([
452
- d({ type: Boolean, attribute: "open-initially" })
447
+ h({ type: Boolean, attribute: "open-initially" })
453
448
  ], s.prototype, "openInitially", 2);
454
449
  r([
455
- d({ type: Boolean, attribute: "show-feedback-buttons" })
450
+ h({ type: Boolean, attribute: "show-feedback-buttons" })
456
451
  ], s.prototype, "showFeedbackButtons", 2);
457
452
  r([
458
453
  l()
@@ -1,5 +1,5 @@
1
- "use strict";const n=require("lit"),s=require("lit/decorators.js"),y=require("lit/directives/unsafe-html.js");require("./combobox-C6zoQopK.cjs");require("./button-CDRccsk9.cjs");require("./input-JpAWN-M1.cjs");require("./ui-icon-DWh1MhBa.cjs");const w=":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>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.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)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";var x=Object.defineProperty,C=Object.getOwnPropertyDescriptor,a=(l,t,e,r)=>{for(var o=r>1?void 0:r?C(t,e):t,i=l.length-1,h;i>=0;i--)(h=l[i])&&(o=(r?h(t,e,o):h(o))||o);return r&&o&&x(t,e,o),o};exports.LogosphereChatBot=class extends n.LitElement{constructor(){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=()=>{this.screenWidth=window.innerWidth;const t=window.innerHeight-40;this.windowHeight>t&&(this.windowHeight=t)},this.onToggle=()=>{this.open=!this.open,this.scrollToBottom()},this.onClose=()=>{this.open=!1,this.fullscreen=!1},this.onToggleFullscreen=()=>{this.fullscreen=!this.fullscreen},this.onMouseMove=t=>{if(this.isDragging){const e=this.dragStartPos.x-t.clientX,r=this.dragStartPos.y-t.clientY,i=this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(),h=i?.width||72,u=i?.height||66;this.position={right:Math.max(0,Math.min(window.innerWidth-h,this.initialPosition.right+e)),bottom:Math.max(0,Math.min(window.innerHeight-u,this.initialPosition.bottom+r))}}else if(this.isResizing){const e=this.dragStartPos.x-t.clientX,r=this.dragStartPos.y-t.clientY;if(this.resizeDirection==="horizontal"||this.resizeDirection==="both"){const o=this.position.right<this.screenWidth/2;this.windowWidth=Math.max(300,this.resizeStartWidth+(o?e:-e))}(this.resizeDirection==="vertical"||this.resizeDirection==="both")&&(this.windowHeight=Math.max(400,this.resizeStartHeight+r))}},this.onMouseUp=t=>{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))},this.handleKeyDown=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendMessage())},this.onInput=t=>{const e=t.target;this.inputText=e?e.value:t.detail},this.onCopyMessage=t=>{navigator.clipboard.writeText(t)}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onWindowResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}async firstUpdated(){this.selectedProductId=this._resolveInitialProduct(),this.open=this.openInitially,this.open&&await this.initConversation()}updated(t){t.has("products")&&this.handleProductUpdate(),t.has("messages")&&this.scrollToBottom(),t.has("open")&&this.open&&!this.conversationId&&this.initConversation()}_resolveInitialProduct(){if(!this.products.length)return"";const t=this.products.find(e=>e.selected);return t?t.id:this.products.length===1?this.products[0].id:""}handleProductUpdate(){if(!this.products.length)return;const t=this._resolveInitialProduct();this.products.some(r=>r.id===this.selectedProductId)||(this.selectedProductId=t,this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()),requestAnimationFrame(()=>this.updateComboboxItems())}updateComboboxItems(){const t=this.productEl;if(!t||this.products?.length<=1)return;const e=this.products.map(o=>({value:o.id,label:o.name}));t.items=e;const r=t.selectedItems?.()||[];if(r.length===0&&this.selectedProductId){const o=e.find(i=>i.value===this.selectedProductId);o&&t.setSelected&&t.setSelected([o])}else if(r.length>0){const o=r[0]?.value;!this.products.some(h=>h.id===o)&&t.setSelected&&t.setSelected([])}}async onProductChange(t){const e=t.detail?.selected?.[0]?.value;e&&e!==this.selectedProductId&&(this.selectedProductId=e)}onMouseDown(t){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))}startResize(t,e){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))}async ensureToken(t=!1){const e="logosphere_chatbot_token";if(t&&(this.assertionToken=void 0,localStorage.removeItem(e)),!t){const i=localStorage.getItem(e);if(i){this.assertionToken=i;return}}const o=await(await fetch(`${this.returnUri}/api/chat/start`)).json();if(!o.Success||!o.Data?.Token)throw new Error("Token alınamadı");this.assertionToken=o.Data.Token,localStorage.setItem(e,this.assertionToken)}async postChat(t){await this.ensureToken();const e=`${this.returnUri}/api/chat/completions`,r=()=>fetch(e,{method:"POST",headers:{"Content-Type":"application/json",client_assertion:this.assertionToken,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},body:JSON.stringify(t)});let o=await r();if(o.status===401&&(await this.ensureToken(!0),o=await r()),!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async initConversation(){if(!this.isLoading){this.isLoading=!0;try{await this.ensureToken();const t=await this.postChat({ChatCompletionType:"NewConversation",Context:this.selectedProductId,QuestionPrompt:this.questionPrompt});this.conversationId=t.Data.ConversationId;const e=t.Data.Choices?.[0]?.Message?.Content;e&&this.addMessage(e,"assistant")}catch{this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.","system")}finally{this.isLoading=!1}}}async sendMessage(){const t=this.inputText.trim();if(!(!t||!this.conversationId||this.isLoading)){if(!this.selectedProductId){this.addMessage("Lütfen önce bir ürün seçiniz.","system");return}this.addMessage(t,"user"),this.inputText="",this.isLoading=!0;try{const r=(await this.postChat({ChatCompletionType:"ConversationUpdate",Content:t,Context:this.selectedProductId,ConversationId:this.conversationId,QuestionPrompt:this.questionPrompt})).Data?.Choices?.[0]?.Message?.Content;this.addMessage(r||"Cevap alınamadı.","assistant")}catch{this.addMessage("Bağlantı hatası.","system")}finally{this.isLoading=!1}}}addMessage(t,e){this.messages=[...this.messages,{content:t,role:e,timestamp:Date.now()}]}scrollToBottom(){setTimeout(()=>{this.chatContainer&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)},0)}formatContent(t){if(!t)return"";const r=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").split(`
2
- `);let o="";const i=[];let h=!1;const u=()=>{h&&(o+="</li>",h=!1)},f=d=>{for(;i.length>0&&i[i.length-1].indent>=d;)u(),o+=`</${i.pop().type}>`,i.length>0&&(h=!0)},b=()=>f(-1);for(const d of r){const p=d.match(/^(\s*)\d+\.\s+(.*)/),m=d.match(/^(\s*)[-*]\s+(.*)/);if(p||m){const c=(p?p[1]:m[1]).length,g=p?"ol":"ul",_=p?p[2]:m[2];if(i.length===0)o+=`<${g}>`,i.push({type:g,indent:c});else{const v=i[i.length-1];c>v.indent?(o+=`<${g}>`,i.push({type:g,indent:c})):c===v.indent?u():(f(c+1),i.length>0&&i[i.length-1].indent===c?u():(b(),o+=`<${g}>`,i.push({type:g,indent:c})))}o+=`<li>${_}`,h=!0}else d.trim()===""?i.length===0&&(o+="<br>"):(b(),o+=`<p>${d}</p>`)}return b(),o.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>')}render(){const t=this.position.right<this.screenWidth/2;return n.html`
1
+ "use strict";const n=require("lit"),s=require("lit/decorators.js"),y=require("lit/directives/unsafe-html.js");require("./combobox-C6zoQopK.cjs");require("./button-CDRccsk9.cjs");require("./input-JpAWN-M1.cjs");require("./ui-icon-DWh1MhBa.cjs");const w=":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>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.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)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";var x=Object.defineProperty,C=Object.getOwnPropertyDescriptor,r=(l,t,e,a)=>{for(var o=a>1?void 0:a?C(t,e):t,i=l.length-1,h;i>=0;i--)(h=l[i])&&(o=(a?h(t,e,o):h(o))||o);return a&&o&&x(t,e,o),o};exports.LogosphereChatBot=class extends n.LitElement{constructor(){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=()=>{this.screenWidth=window.innerWidth;const t=window.innerHeight-40;this.windowHeight>t&&(this.windowHeight=t)},this.onToggle=()=>{this.open=!this.open,this.scrollToBottom()},this.onClose=()=>{this.open=!1,this.fullscreen=!1},this.onToggleFullscreen=()=>{this.fullscreen=!this.fullscreen},this.onMouseMove=t=>{if(this.isDragging){const e=this.dragStartPos.x-t.clientX,a=this.dragStartPos.y-t.clientY,i=this.shadowRoot?.querySelector(".chatbot__launcher")?.getBoundingClientRect(),h=i?.width||72,g=i?.height||66;this.position={right:Math.max(0,Math.min(window.innerWidth-h,this.initialPosition.right+e)),bottom:Math.max(0,Math.min(window.innerHeight-g,this.initialPosition.bottom+a))}}else if(this.isResizing){const e=this.dragStartPos.x-t.clientX,a=this.dragStartPos.y-t.clientY;if(this.resizeDirection==="horizontal"||this.resizeDirection==="both"){const o=this.position.right<this.screenWidth/2;this.windowWidth=Math.max(300,this.resizeStartWidth+(o?e:-e))}(this.resizeDirection==="vertical"||this.resizeDirection==="both")&&(this.windowHeight=Math.max(400,this.resizeStartHeight+a))}},this.onMouseUp=t=>{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))},this.handleKeyDown=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendMessage())},this.onInput=t=>{const e=t.target;this.inputText=e?e.value:t.detail},this.onCopyMessage=t=>{navigator.clipboard.writeText(t)}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onWindowResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}async firstUpdated(){this.selectedProductId=this._resolveInitialProduct(),this.open=this.openInitially,this.open&&await this.initConversation()}updated(t){t.has("products")&&this.handleProductUpdate(),t.has("messages")&&this.scrollToBottom(),t.has("open")&&this.open&&!this.conversationId&&this.initConversation()}_resolveInitialProduct(){if(!this.products.length)return"";const t=this.products.find(e=>e.selected);return t?t.id:this.products.length===1?this.products[0].id:""}handleProductUpdate(){if(!this.products.length)return;const t=this.products.find(a=>a.selected),e=this.products.some(a=>a.id===this.selectedProductId);t&&t.id!==this.selectedProductId?(this.selectedProductId=t.id,this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()):e||(this.selectedProductId=this._resolveInitialProduct(),this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()),requestAnimationFrame(()=>this.updateComboboxItems())}updateComboboxItems(){const t=this.productEl;if(!t||this.products?.length<=1)return;const e=this.products.map(o=>({value:o.id,label:o.name}));if(t.items=e,(t.selectedItems?.()||[])[0]?.value!==this.selectedProductId){const o=e.find(i=>i.value===this.selectedProductId);t.setSelected&&t.setSelected(o?[o]:[])}}async onProductChange(t){const e=t.detail?.selected?.[0]?.value;e&&e!==this.selectedProductId&&(this.selectedProductId=e)}onMouseDown(t){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))}startResize(t,e){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))}async ensureToken(t=!1){const e="logosphere_chatbot_token";if(t&&(this.assertionToken=void 0,localStorage.removeItem(e)),!t){const i=localStorage.getItem(e);if(i){this.assertionToken=i;return}}const o=await(await fetch(`${this.returnUri}/api/chat/start`)).json();if(!o.Success||!o.Data?.Token)throw new Error("Token alınamadı");this.assertionToken=o.Data.Token,localStorage.setItem(e,this.assertionToken)}async postChat(t){await this.ensureToken();const e=`${this.returnUri}/api/chat/completions`,a=()=>fetch(e,{method:"POST",headers:{"Content-Type":"application/json",client_assertion:this.assertionToken,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},body:JSON.stringify(t)});let o=await a();if(o.status===401&&(await this.ensureToken(!0),o=await a()),!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async initConversation(){if(!this.isLoading){this.isLoading=!0;try{await this.ensureToken();const t=await this.postChat({ChatCompletionType:"NewConversation",Context:this.selectedProductId,QuestionPrompt:this.questionPrompt});this.conversationId=t.Data.ConversationId;const e=t.Data.Choices?.[0]?.Message?.Content;e&&this.addMessage(e,"assistant")}catch{this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.","system")}finally{this.isLoading=!1}}}async sendMessage(){const t=this.inputText.trim();if(!(!t||!this.conversationId||this.isLoading)){if(!this.selectedProductId){this.addMessage("Lütfen önce bir ürün seçiniz.","system");return}this.addMessage(t,"user"),this.inputText="",this.isLoading=!0;try{const a=(await this.postChat({ChatCompletionType:"ConversationUpdate",Content:t,Context:this.selectedProductId,ConversationId:this.conversationId,QuestionPrompt:this.questionPrompt})).Data?.Choices?.[0]?.Message?.Content;this.addMessage(a||"Cevap alınamadı.","assistant")}catch{this.addMessage("Bağlantı hatası.","system")}finally{this.isLoading=!1}}}addMessage(t,e){this.messages=[...this.messages,{content:t,role:e,timestamp:Date.now()}]}scrollToBottom(){setTimeout(()=>{this.chatContainer&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)},0)}formatContent(t){if(!t)return"";const a=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").split(`
2
+ `);let o="";const i=[];let h=!1;const g=()=>{h&&(o+="</li>",h=!1)},f=d=>{for(;i.length>0&&i[i.length-1].indent>=d;)g(),o+=`</${i.pop().type}>`,i.length>0&&(h=!0)},b=()=>f(-1);for(const d of a){const p=d.match(/^(\s*)\d+\.\s+(.*)/),m=d.match(/^(\s*)[-*]\s+(.*)/);if(p||m){const c=(p?p[1]:m[1]).length,u=p?"ol":"ul",_=p?p[2]:m[2];if(i.length===0)o+=`<${u}>`,i.push({type:u,indent:c});else{const v=i[i.length-1];c>v.indent?(o+=`<${u}>`,i.push({type:u,indent:c})):c===v.indent?g():(f(c+1),i.length>0&&i[i.length-1].indent===c?g():(b(),o+=`<${u}>`,i.push({type:u,indent:c})))}o+=`<li>${_}`,h=!0}else d.trim()===""?i.length===0&&(o+="<br>"):(b(),o+=`<p>${d}</p>`)}return b(),o.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>')}render(){const t=this.position.right<this.screenWidth/2;return n.html`
3
3
  <div class="chatbot">
4
4
  ${this.renderOverlay()}
5
5
  ${this.renderLauncher()}
@@ -21,8 +21,8 @@
21
21
  </div>
22
22
  `:""}
23
23
  </div>
24
- `}renderWindow(t){const e=["chatbot__window",this.open?"":"chatbot__window--hidden",this.fullscreen?"chatbot__window--fullscreen":""].filter(Boolean).join(" "),r=this.fullscreen?"":`bottom: 20px; height: ${this.windowHeight}px; width: ${this.windowWidth}px; ${t?"right: 20px;":"left: 20px;"}`;return n.html`
25
- <div class="${e}" style="${r}">
24
+ `}renderWindow(t){const e=["chatbot__window",this.open?"":"chatbot__window--hidden",this.fullscreen?"chatbot__window--fullscreen":""].filter(Boolean).join(" "),a=this.fullscreen?"":`bottom: 20px; height: ${this.windowHeight}px; width: ${this.windowWidth}px; ${t?"right: 20px;":"left: 20px;"}`;return n.html`
25
+ <div class="${e}" style="${a}">
26
26
  ${this.renderResizeHandles(t)}
27
27
  ${this.renderHeader()}
28
28
  <div class="chatbot__body">
@@ -158,4 +158,4 @@
158
158
  <div class="chatbot__footer">
159
159
  <p class="chatbot__footer-text">İçerik Yapay Zeka ile Üretilmiştir</p>
160
160
  </div>
161
- `}};exports.LogosphereChatBot.styles=[n.css`${n.unsafeCSS(w)}`];exports.LogosphereChatBot.ICONS={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"};a([s.property({type:String,attribute:"return-uri"})],exports.LogosphereChatBot.prototype,"returnUri",2);a([s.property({type:String,attribute:"question-prompt"})],exports.LogosphereChatBot.prototype,"questionPrompt",2);a([s.property({type:Boolean,attribute:"minimized-icon-only"})],exports.LogosphereChatBot.prototype,"minimizedIconOnly",2);a([s.property({type:Boolean,attribute:"draggable"})],exports.LogosphereChatBot.prototype,"draggable",2);a([s.property({type:Boolean,attribute:"resizable"})],exports.LogosphereChatBot.prototype,"resizable",2);a([s.property({type:Array,hasChanged:(l,t)=>l===t?!1:!t||!l||l.length!==t.length?!0:JSON.stringify(l)!==JSON.stringify(t)}),s.property({type:Array})],exports.LogosphereChatBot.prototype,"products",2);a([s.property({type:Boolean,attribute:"open-initially"})],exports.LogosphereChatBot.prototype,"openInitially",2);a([s.property({type:Boolean,attribute:"show-feedback-buttons"})],exports.LogosphereChatBot.prototype,"showFeedbackButtons",2);a([s.state()],exports.LogosphereChatBot.prototype,"open",2);a([s.state()],exports.LogosphereChatBot.prototype,"fullscreen",2);a([s.state()],exports.LogosphereChatBot.prototype,"messages",2);a([s.state()],exports.LogosphereChatBot.prototype,"conversationId",2);a([s.state()],exports.LogosphereChatBot.prototype,"assertionToken",2);a([s.state()],exports.LogosphereChatBot.prototype,"isLoading",2);a([s.state()],exports.LogosphereChatBot.prototype,"inputText",2);a([s.state()],exports.LogosphereChatBot.prototype,"selectedProductId",2);a([s.state()],exports.LogosphereChatBot.prototype,"windowWidth",2);a([s.state()],exports.LogosphereChatBot.prototype,"windowHeight",2);a([s.state()],exports.LogosphereChatBot.prototype,"position",2);a([s.state()],exports.LogosphereChatBot.prototype,"isDragging",2);a([s.state()],exports.LogosphereChatBot.prototype,"screenWidth",2);a([s.query("#chat-container")],exports.LogosphereChatBot.prototype,"chatContainer",2);a([s.query("#product")],exports.LogosphereChatBot.prototype,"productEl",2);exports.LogosphereChatBot=a([s.customElement("logosphere-chatbot")],exports.LogosphereChatBot);
161
+ `}};exports.LogosphereChatBot.styles=[n.css`${n.unsafeCSS(w)}`];exports.LogosphereChatBot.ICONS={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"};r([s.property({type:String,attribute:"return-uri"})],exports.LogosphereChatBot.prototype,"returnUri",2);r([s.property({type:String,attribute:"question-prompt"})],exports.LogosphereChatBot.prototype,"questionPrompt",2);r([s.property({type:Boolean,attribute:"minimized-icon-only"})],exports.LogosphereChatBot.prototype,"minimizedIconOnly",2);r([s.property({type:Boolean,attribute:"draggable"})],exports.LogosphereChatBot.prototype,"draggable",2);r([s.property({type:Boolean,attribute:"resizable"})],exports.LogosphereChatBot.prototype,"resizable",2);r([s.property({type:Array,hasChanged:(l,t)=>l===t?!1:!t||!l||l.length!==t.length?!0:JSON.stringify(l)!==JSON.stringify(t)}),s.property({type:Array})],exports.LogosphereChatBot.prototype,"products",2);r([s.property({type:Boolean,attribute:"open-initially"})],exports.LogosphereChatBot.prototype,"openInitially",2);r([s.property({type:Boolean,attribute:"show-feedback-buttons"})],exports.LogosphereChatBot.prototype,"showFeedbackButtons",2);r([s.state()],exports.LogosphereChatBot.prototype,"open",2);r([s.state()],exports.LogosphereChatBot.prototype,"fullscreen",2);r([s.state()],exports.LogosphereChatBot.prototype,"messages",2);r([s.state()],exports.LogosphereChatBot.prototype,"conversationId",2);r([s.state()],exports.LogosphereChatBot.prototype,"assertionToken",2);r([s.state()],exports.LogosphereChatBot.prototype,"isLoading",2);r([s.state()],exports.LogosphereChatBot.prototype,"inputText",2);r([s.state()],exports.LogosphereChatBot.prototype,"selectedProductId",2);r([s.state()],exports.LogosphereChatBot.prototype,"windowWidth",2);r([s.state()],exports.LogosphereChatBot.prototype,"windowHeight",2);r([s.state()],exports.LogosphereChatBot.prototype,"position",2);r([s.state()],exports.LogosphereChatBot.prototype,"isDragging",2);r([s.state()],exports.LogosphereChatBot.prototype,"screenWidth",2);r([s.query("#chat-container")],exports.LogosphereChatBot.prototype,"chatContainer",2);r([s.query("#product")],exports.LogosphereChatBot.prototype,"productEl",2);exports.LogosphereChatBot=r([s.customElement("logosphere-chatbot")],exports.LogosphereChatBot);
package/dist/chatbot.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chatbot-B_3w7h4T.cjs");Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>e.LogosphereChatBot});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chatbot-CweQSDtr.cjs");Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>e.LogosphereChatBot});
package/dist/chatbot.js CHANGED
@@ -1,4 +1,4 @@
1
- import { L as r } from "./chatbot-uGYcx6Nn.js";
1
+ import { L as r } from "./chatbot-B1Yb35Rp.js";
2
2
  export {
3
3
  r as LogosphereChatBot
4
4
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./button-CDRccsk9.cjs"),t=require("./badge-7IIatiRv.cjs"),o=require("./checkbox-CdDTRdKV.cjs"),n=require("./formfield-BFOIEicR.cjs"),u=require("./switch-Rnnn10bn.cjs"),a=require("./breadcrumb-Cop-B1J7.cjs"),b=require("./card-KiNHfEi2.cjs"),c=require("./input-JpAWN-M1.cjs"),i=require("./popover-C2p5Pmts.cjs"),d=require("./text-area-CZDdxbrN.cjs"),p=require("./chatbot-B_3w7h4T.cjs"),g=require("./calendar-LMn1ZF3N.cjs"),l=require("./combobox-C6zoQopK.cjs"),m=require("./datepicker-CwDDA6np.cjs"),s=require("./drawer-BvcPd5nz.cjs"),f=require("./download-manager-BSIMTGaK.cjs"),e=require("./leftmenu-DBcncBN8.cjs"),P=require("./modal-DU1sszVn.cjs"),y=require("./tab-DcjAlXzU.cjs"),j=require("./tree-menu-B1iwfHyd.cjs");Object.defineProperty(exports,"Button",{enumerable:!0,get:()=>r.Button});Object.defineProperty(exports,"LogosphereBadge",{enumerable:!0,get:()=>t.LogosphereBadge});Object.defineProperty(exports,"Checkbox",{enumerable:!0,get:()=>o.Checkbox});Object.defineProperty(exports,"FormField",{enumerable:!0,get:()=>n.FormField});Object.defineProperty(exports,"Switch",{enumerable:!0,get:()=>u.Switch});Object.defineProperty(exports,"Breadcrumb",{enumerable:!0,get:()=>a.Breadcrumb});Object.defineProperty(exports,"Card",{enumerable:!0,get:()=>b.Card});Object.defineProperty(exports,"LogosphereInput",{enumerable:!0,get:()=>c.LogosphereInput});Object.defineProperty(exports,"Popover",{enumerable:!0,get:()=>i.Popover});Object.defineProperty(exports,"TextArea",{enumerable:!0,get:()=>d.TextArea});Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>p.LogosphereChatBot});Object.defineProperty(exports,"LogosphereCalendar",{enumerable:!0,get:()=>g.LogosphereCalendar});Object.defineProperty(exports,"Combobox",{enumerable:!0,get:()=>l.Combobox});Object.defineProperty(exports,"LogosphereDatePicker",{enumerable:!0,get:()=>m.LogosphereDatePicker});Object.defineProperty(exports,"Drawer",{enumerable:!0,get:()=>s.Drawer});Object.defineProperty(exports,"DownloadManager",{enumerable:!0,get:()=>f.DownloadManager});Object.defineProperty(exports,"LeftMenu",{enumerable:!0,get:()=>e.LeftMenu});Object.defineProperty(exports,"LeftMenuItemElement",{enumerable:!0,get:()=>e.LeftMenuItemElement});Object.defineProperty(exports,"Modal",{enumerable:!0,get:()=>P.Modal});Object.defineProperty(exports,"LogosphereTab",{enumerable:!0,get:()=>y.LogosphereTab});Object.defineProperty(exports,"TreeMenu",{enumerable:!0,get:()=>j.TreeMenu});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./button-CDRccsk9.cjs"),t=require("./badge-7IIatiRv.cjs"),o=require("./checkbox-CdDTRdKV.cjs"),n=require("./formfield-BFOIEicR.cjs"),u=require("./switch-Rnnn10bn.cjs"),a=require("./breadcrumb-Cop-B1J7.cjs"),b=require("./card-KiNHfEi2.cjs"),c=require("./input-JpAWN-M1.cjs"),i=require("./popover-C2p5Pmts.cjs"),d=require("./text-area-CZDdxbrN.cjs"),p=require("./chatbot-CweQSDtr.cjs"),g=require("./calendar-LMn1ZF3N.cjs"),l=require("./combobox-C6zoQopK.cjs"),m=require("./datepicker-CwDDA6np.cjs"),s=require("./drawer-BvcPd5nz.cjs"),f=require("./download-manager-BSIMTGaK.cjs"),e=require("./leftmenu-DBcncBN8.cjs"),P=require("./modal-DU1sszVn.cjs"),y=require("./tab-DcjAlXzU.cjs"),j=require("./tree-menu-B1iwfHyd.cjs");Object.defineProperty(exports,"Button",{enumerable:!0,get:()=>r.Button});Object.defineProperty(exports,"LogosphereBadge",{enumerable:!0,get:()=>t.LogosphereBadge});Object.defineProperty(exports,"Checkbox",{enumerable:!0,get:()=>o.Checkbox});Object.defineProperty(exports,"FormField",{enumerable:!0,get:()=>n.FormField});Object.defineProperty(exports,"Switch",{enumerable:!0,get:()=>u.Switch});Object.defineProperty(exports,"Breadcrumb",{enumerable:!0,get:()=>a.Breadcrumb});Object.defineProperty(exports,"Card",{enumerable:!0,get:()=>b.Card});Object.defineProperty(exports,"LogosphereInput",{enumerable:!0,get:()=>c.LogosphereInput});Object.defineProperty(exports,"Popover",{enumerable:!0,get:()=>i.Popover});Object.defineProperty(exports,"TextArea",{enumerable:!0,get:()=>d.TextArea});Object.defineProperty(exports,"LogosphereChatBot",{enumerable:!0,get:()=>p.LogosphereChatBot});Object.defineProperty(exports,"LogosphereCalendar",{enumerable:!0,get:()=>g.LogosphereCalendar});Object.defineProperty(exports,"Combobox",{enumerable:!0,get:()=>l.Combobox});Object.defineProperty(exports,"LogosphereDatePicker",{enumerable:!0,get:()=>m.LogosphereDatePicker});Object.defineProperty(exports,"Drawer",{enumerable:!0,get:()=>s.Drawer});Object.defineProperty(exports,"DownloadManager",{enumerable:!0,get:()=>f.DownloadManager});Object.defineProperty(exports,"LeftMenu",{enumerable:!0,get:()=>e.LeftMenu});Object.defineProperty(exports,"LeftMenuItemElement",{enumerable:!0,get:()=>e.LeftMenuItemElement});Object.defineProperty(exports,"Modal",{enumerable:!0,get:()=>P.Modal});Object.defineProperty(exports,"LogosphereTab",{enumerable:!0,get:()=>y.LogosphereTab});Object.defineProperty(exports,"TreeMenu",{enumerable:!0,get:()=>j.TreeMenu});
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { C } from "./card-CNoTUaJC.js";
8
8
  import { L as u } from "./input-jmbvgWEq.js";
9
9
  import { P as M } from "./popover-CaVOXo_k.js";
10
10
  import { T as l } from "./text-area-Dec_k4rs.js";
11
- import { L as T } from "./chatbot-uGYcx6Nn.js";
11
+ import { L as T } from "./chatbot-B1Yb35Rp.js";
12
12
  import { L as i } from "./calendar-WZ_GQvnn.js";
13
13
  import { C as F } from "./combobox-LBU6VHLi.js";
14
14
  import { L as k } from "./datepicker-SwKsdw3S.js";
package/dist/index.umd.js CHANGED
@@ -423,7 +423,7 @@
423
423
  </div>
424
424
  `}},n.Combobox.styles=[N`
425
425
  ${F(As)}
426
- `],R([c({type:String})],n.Combobox.prototype,"label",2),R([c({type:String})],n.Combobox.prototype,"helper",2),R([c({type:String})],n.Combobox.prototype,"error",2),R([c({type:String})],n.Combobox.prototype,"placeholder",2),R([c({type:Boolean})],n.Combobox.prototype,"required",2),R([c({type:Boolean})],n.Combobox.prototype,"disabled",2),R([c({type:Boolean})],n.Combobox.prototype,"readOnly",2),R([c({type:String})],n.Combobox.prototype,"variant",2),R([c({type:Boolean})],n.Combobox.prototype,"multiple",2),R([c({type:Boolean})],n.Combobox.prototype,"filterable",2),R([c({type:String})],n.Combobox.prototype,"optionLabel",2),R([c({type:String})],n.Combobox.prototype,"optionValue",2),R([c({type:String})],n.Combobox.prototype,"emptyMessage",2),R([c({type:Array})],n.Combobox.prototype,"items",2),R([c({type:String})],n.Combobox.prototype,"size",2),R([$()],n.Combobox.prototype,"selected",2),R([$()],n.Combobox.prototype,"inputValue",2),R([$()],n.Combobox.prototype,"isOpen",2),R([$()],n.Combobox.prototype,"focusedIndex",2),R([J(".combobox__wrapper")],n.Combobox.prototype,"_referenceElement",2),R([J("logosphere-formfield")],n.Combobox.prototype,"_formFieldElement",2),R([J("[data-combobox-popper]")],n.Combobox.prototype,"_dropdownElement",2),n.Combobox=R([U("logosphere-combobox")],n.Combobox);const Ps=":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;top:0;right:0;bottom:0;left: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{left:50px;right:50px;top:80px;bottom:80px;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>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.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)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";var Ls=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,I=(i,e,t,r)=>{for(var o=r>1?void 0:r?Ts(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=(r?a(e,t,o):a(o))||o);return r&&o&&Ls(e,t,o),o};n.LogosphereChatBot=class extends T{constructor(){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=()=>{this.screenWidth=window.innerWidth;const e=window.innerHeight-40;this.windowHeight>e&&(this.windowHeight=e)},this.onToggle=()=>{this.open=!this.open,this.scrollToBottom()},this.onClose=()=>{this.open=!1,this.fullscreen=!1},this.onToggleFullscreen=()=>{this.fullscreen=!this.fullscreen},this.onMouseMove=e=>{var t;if(this.isDragging){const r=this.dragStartPos.x-e.clientX,o=this.dragStartPos.y-e.clientY,s=(t=this.shadowRoot)==null?void 0:t.querySelector(".chatbot__launcher"),a=s==null?void 0:s.getBoundingClientRect(),l=(a==null?void 0:a.width)||72,d=(a==null?void 0:a.height)||66;this.position={right:Math.max(0,Math.min(window.innerWidth-l,this.initialPosition.right+r)),bottom:Math.max(0,Math.min(window.innerHeight-d,this.initialPosition.bottom+o))}}else if(this.isResizing){const r=this.dragStartPos.x-e.clientX,o=this.dragStartPos.y-e.clientY;if(this.resizeDirection==="horizontal"||this.resizeDirection==="both"){const s=this.position.right<this.screenWidth/2;this.windowWidth=Math.max(300,this.resizeStartWidth+(s?r:-r))}(this.resizeDirection==="vertical"||this.resizeDirection==="both")&&(this.windowHeight=Math.max(400,this.resizeStartHeight+o))}},this.onMouseUp=e=>{this.isDragging?(this.isDragging=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),Math.hypot(e.clientX-this.dragStartPos.x,e.clientY-this.dragStartPos.y)<5&&this.onToggle()):this.isResizing&&(this.isResizing=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp))},this.handleKeyDown=e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.sendMessage())},this.onInput=e=>{const t=e.target;this.inputText=t?t.value:e.detail},this.onCopyMessage=e=>{navigator.clipboard.writeText(e)}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onWindowResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}async firstUpdated(){this.selectedProductId=this._resolveInitialProduct(),this.open=this.openInitially,this.open&&await this.initConversation()}updated(e){e.has("products")&&this.handleProductUpdate(),e.has("messages")&&this.scrollToBottom(),e.has("open")&&this.open&&!this.conversationId&&this.initConversation()}_resolveInitialProduct(){if(!this.products.length)return"";const e=this.products.find(t=>t.selected);return e?e.id:this.products.length===1?this.products[0].id:""}handleProductUpdate(){if(!this.products.length)return;const e=this._resolveInitialProduct();this.products.some(r=>r.id===this.selectedProductId)||(this.selectedProductId=e,this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()),requestAnimationFrame(()=>this.updateComboboxItems())}updateComboboxItems(){var o,s,a;const e=this.productEl;if(!e||((o=this.products)==null?void 0:o.length)<=1)return;const t=this.products.map(l=>({value:l.id,label:l.name}));e.items=t;const r=((s=e.selectedItems)==null?void 0:s.call(e))||[];if(r.length===0&&this.selectedProductId){const l=t.find(d=>d.value===this.selectedProductId);l&&e.setSelected&&e.setSelected([l])}else if(r.length>0){const l=(a=r[0])==null?void 0:a.value;!this.products.some(p=>p.id===l)&&e.setSelected&&e.setSelected([])}}async onProductChange(e){var r,o,s;const t=(s=(o=(r=e.detail)==null?void 0:r.selected)==null?void 0:o[0])==null?void 0:s.value;t&&t!==this.selectedProductId&&(this.selectedProductId=t)}onMouseDown(e){this.draggable&&(e.preventDefault(),this.isDragging=!0,this.dragStartPos={x:e.clientX,y:e.clientY},this.initialPosition=$t({},this.position),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}startResize(e,t){this.resizable&&(e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.resizeDirection=t,this.dragStartPos={x:e.clientX,y:e.clientY},this.resizeStartWidth=this.windowWidth,this.resizeStartHeight=this.windowHeight,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}async ensureToken(e=!1){var s;const t="logosphere_chatbot_token";if(e&&(this.assertionToken=void 0,localStorage.removeItem(t)),!e){const a=localStorage.getItem(t);if(a){this.assertionToken=a;return}}const o=await(await fetch(`${this.returnUri}/api/chat/start`)).json();if(!o.Success||!((s=o.Data)!=null&&s.Token))throw new Error("Token alınamadı");this.assertionToken=o.Data.Token,localStorage.setItem(t,this.assertionToken)}async postChat(e){await this.ensureToken();const t=`${this.returnUri}/api/chat/completions`,r=()=>fetch(t,{method:"POST",headers:{"Content-Type":"application/json",client_assertion:this.assertionToken,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},body:JSON.stringify(e)});let o=await r();if(o.status===401&&(await this.ensureToken(!0),o=await r()),!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async initConversation(){var e,t,r;if(!this.isLoading){this.isLoading=!0;try{await this.ensureToken();const o=await this.postChat({ChatCompletionType:"NewConversation",Context:this.selectedProductId,QuestionPrompt:this.questionPrompt});this.conversationId=o.Data.ConversationId;const s=(r=(t=(e=o.Data.Choices)==null?void 0:e[0])==null?void 0:t.Message)==null?void 0:r.Content;s&&this.addMessage(s,"assistant")}catch(o){this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.","system")}finally{this.isLoading=!1}}}async sendMessage(){var t,r,o,s;const e=this.inputText.trim();if(!(!e||!this.conversationId||this.isLoading)){if(!this.selectedProductId){this.addMessage("Lütfen önce bir ürün seçiniz.","system");return}this.addMessage(e,"user"),this.inputText="",this.isLoading=!0;try{const l=(s=(o=(r=(t=(await this.postChat({ChatCompletionType:"ConversationUpdate",Content:e,Context:this.selectedProductId,ConversationId:this.conversationId,QuestionPrompt:this.questionPrompt})).Data)==null?void 0:t.Choices)==null?void 0:r[0])==null?void 0:o.Message)==null?void 0:s.Content;this.addMessage(l||"Cevap alınamadı.","assistant")}catch(a){this.addMessage("Bağlantı hatası.","system")}finally{this.isLoading=!1}}}addMessage(e,t){this.messages=[...this.messages,{content:e,role:t,timestamp:Date.now()}]}scrollToBottom(){setTimeout(()=>{this.chatContainer&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)},0)}formatContent(e){if(!e)return"";const r=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").split(`
426
+ `],R([c({type:String})],n.Combobox.prototype,"label",2),R([c({type:String})],n.Combobox.prototype,"helper",2),R([c({type:String})],n.Combobox.prototype,"error",2),R([c({type:String})],n.Combobox.prototype,"placeholder",2),R([c({type:Boolean})],n.Combobox.prototype,"required",2),R([c({type:Boolean})],n.Combobox.prototype,"disabled",2),R([c({type:Boolean})],n.Combobox.prototype,"readOnly",2),R([c({type:String})],n.Combobox.prototype,"variant",2),R([c({type:Boolean})],n.Combobox.prototype,"multiple",2),R([c({type:Boolean})],n.Combobox.prototype,"filterable",2),R([c({type:String})],n.Combobox.prototype,"optionLabel",2),R([c({type:String})],n.Combobox.prototype,"optionValue",2),R([c({type:String})],n.Combobox.prototype,"emptyMessage",2),R([c({type:Array})],n.Combobox.prototype,"items",2),R([c({type:String})],n.Combobox.prototype,"size",2),R([$()],n.Combobox.prototype,"selected",2),R([$()],n.Combobox.prototype,"inputValue",2),R([$()],n.Combobox.prototype,"isOpen",2),R([$()],n.Combobox.prototype,"focusedIndex",2),R([J(".combobox__wrapper")],n.Combobox.prototype,"_referenceElement",2),R([J("logosphere-formfield")],n.Combobox.prototype,"_formFieldElement",2),R([J("[data-combobox-popper]")],n.Combobox.prototype,"_dropdownElement",2),n.Combobox=R([U("logosphere-combobox")],n.Combobox);const Ps=":host{display:block;z-index:9999}.chatbot{font-family:var(--font-family-base)}.chatbot__overlay{position:fixed;top:0;right:0;bottom:0;left: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{left:50px;right:50px;top:80px;bottom:80px;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>ol,.chatbot__message-content li>ul{margin-top:var(--spacing-1);margin-bottom:var(--spacing-1)}.chatbot__message-content ol ol{list-style-type:lower-alpha}.chatbot__message-content ol ol ol{list-style-type:lower-roman}.chatbot__message-content ul ul{list-style-type:circle}.chatbot__message-content ul ul ul{list-style-type:square}.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)}.chatbot__product-selector{padding:var(--spacing-3) var(--spacing-3) 0;flex-shrink:0}.chatbot__product-input{display:block;width:100%;height:24px;padding-left:var(--spacing-1);border:1px solid var(--color-border);border-radius:var(--radius-md);background:transparent;color:var(--color-body-color);font-size:var(--font-size-md);outline:none}";var Ls=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,I=(i,e,t,r)=>{for(var o=r>1?void 0:r?Ts(e,t):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=(r?a(e,t,o):a(o))||o);return r&&o&&Ls(e,t,o),o};n.LogosphereChatBot=class extends T{constructor(){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=()=>{this.screenWidth=window.innerWidth;const e=window.innerHeight-40;this.windowHeight>e&&(this.windowHeight=e)},this.onToggle=()=>{this.open=!this.open,this.scrollToBottom()},this.onClose=()=>{this.open=!1,this.fullscreen=!1},this.onToggleFullscreen=()=>{this.fullscreen=!this.fullscreen},this.onMouseMove=e=>{var t;if(this.isDragging){const r=this.dragStartPos.x-e.clientX,o=this.dragStartPos.y-e.clientY,s=(t=this.shadowRoot)==null?void 0:t.querySelector(".chatbot__launcher"),a=s==null?void 0:s.getBoundingClientRect(),l=(a==null?void 0:a.width)||72,d=(a==null?void 0:a.height)||66;this.position={right:Math.max(0,Math.min(window.innerWidth-l,this.initialPosition.right+r)),bottom:Math.max(0,Math.min(window.innerHeight-d,this.initialPosition.bottom+o))}}else if(this.isResizing){const r=this.dragStartPos.x-e.clientX,o=this.dragStartPos.y-e.clientY;if(this.resizeDirection==="horizontal"||this.resizeDirection==="both"){const s=this.position.right<this.screenWidth/2;this.windowWidth=Math.max(300,this.resizeStartWidth+(s?r:-r))}(this.resizeDirection==="vertical"||this.resizeDirection==="both")&&(this.windowHeight=Math.max(400,this.resizeStartHeight+o))}},this.onMouseUp=e=>{this.isDragging?(this.isDragging=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),Math.hypot(e.clientX-this.dragStartPos.x,e.clientY-this.dragStartPos.y)<5&&this.onToggle()):this.isResizing&&(this.isResizing=!1,window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp))},this.handleKeyDown=e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.sendMessage())},this.onInput=e=>{const t=e.target;this.inputText=t?t.value:e.detail},this.onCopyMessage=e=>{navigator.clipboard.writeText(e)}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onWindowResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp)}async firstUpdated(){this.selectedProductId=this._resolveInitialProduct(),this.open=this.openInitially,this.open&&await this.initConversation()}updated(e){e.has("products")&&this.handleProductUpdate(),e.has("messages")&&this.scrollToBottom(),e.has("open")&&this.open&&!this.conversationId&&this.initConversation()}_resolveInitialProduct(){if(!this.products.length)return"";const e=this.products.find(t=>t.selected);return e?e.id:this.products.length===1?this.products[0].id:""}handleProductUpdate(){if(!this.products.length)return;const e=this.products.find(r=>r.selected),t=this.products.some(r=>r.id===this.selectedProductId);e&&e.id!==this.selectedProductId?(this.selectedProductId=e.id,this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()):t||(this.selectedProductId=this._resolveInitialProduct(),this.messages=[],this.conversationId=void 0,this.open&&this.initConversation()),requestAnimationFrame(()=>this.updateComboboxItems())}updateComboboxItems(){var o,s,a;const e=this.productEl;if(!e||((o=this.products)==null?void 0:o.length)<=1)return;const t=this.products.map(l=>({value:l.id,label:l.name}));if(e.items=t,((a=(((s=e.selectedItems)==null?void 0:s.call(e))||[])[0])==null?void 0:a.value)!==this.selectedProductId){const l=t.find(d=>d.value===this.selectedProductId);e.setSelected&&e.setSelected(l?[l]:[])}}async onProductChange(e){var r,o,s;const t=(s=(o=(r=e.detail)==null?void 0:r.selected)==null?void 0:o[0])==null?void 0:s.value;t&&t!==this.selectedProductId&&(this.selectedProductId=t)}onMouseDown(e){this.draggable&&(e.preventDefault(),this.isDragging=!0,this.dragStartPos={x:e.clientX,y:e.clientY},this.initialPosition=$t({},this.position),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}startResize(e,t){this.resizable&&(e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.resizeDirection=t,this.dragStartPos={x:e.clientX,y:e.clientY},this.resizeStartWidth=this.windowWidth,this.resizeStartHeight=this.windowHeight,window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("mouseup",this.onMouseUp))}async ensureToken(e=!1){var s;const t="logosphere_chatbot_token";if(e&&(this.assertionToken=void 0,localStorage.removeItem(t)),!e){const a=localStorage.getItem(t);if(a){this.assertionToken=a;return}}const o=await(await fetch(`${this.returnUri}/api/chat/start`)).json();if(!o.Success||!((s=o.Data)!=null&&s.Token))throw new Error("Token alınamadı");this.assertionToken=o.Data.Token,localStorage.setItem(t,this.assertionToken)}async postChat(e){await this.ensureToken();const t=`${this.returnUri}/api/chat/completions`,r=()=>fetch(t,{method:"POST",headers:{"Content-Type":"application/json",client_assertion:this.assertionToken,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},body:JSON.stringify(e)});let o=await r();if(o.status===401&&(await this.ensureToken(!0),o=await r()),!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async initConversation(){var e,t,r;if(!this.isLoading){this.isLoading=!0;try{await this.ensureToken();const o=await this.postChat({ChatCompletionType:"NewConversation",Context:this.selectedProductId,QuestionPrompt:this.questionPrompt});this.conversationId=o.Data.ConversationId;const s=(r=(t=(e=o.Data.Choices)==null?void 0:e[0])==null?void 0:t.Message)==null?void 0:r.Content;s&&this.addMessage(s,"assistant")}catch(o){this.addMessage("Bir hata oluştu, lütfen tekrar deneyiniz.","system")}finally{this.isLoading=!1}}}async sendMessage(){var t,r,o,s;const e=this.inputText.trim();if(!(!e||!this.conversationId||this.isLoading)){if(!this.selectedProductId){this.addMessage("Lütfen önce bir ürün seçiniz.","system");return}this.addMessage(e,"user"),this.inputText="",this.isLoading=!0;try{const l=(s=(o=(r=(t=(await this.postChat({ChatCompletionType:"ConversationUpdate",Content:e,Context:this.selectedProductId,ConversationId:this.conversationId,QuestionPrompt:this.questionPrompt})).Data)==null?void 0:t.Choices)==null?void 0:r[0])==null?void 0:o.Message)==null?void 0:s.Content;this.addMessage(l||"Cevap alınamadı.","assistant")}catch(a){this.addMessage("Bağlantı hatası.","system")}finally{this.isLoading=!1}}}addMessage(e,t){this.messages=[...this.messages,{content:e,role:t,timestamp:Date.now()}]}scrollToBottom(){setTimeout(()=>{this.chatContainer&&(this.chatContainer.scrollTop=this.chatContainer.scrollHeight)},0)}formatContent(e){if(!e)return"";const r=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").split(`
427
427
  `);let o="";const s=[];let a=!1;const l=()=>{a&&(o+="</li>",a=!1)},d=h=>{for(;s.length>0&&s[s.length-1].indent>=h;)l(),o+=`</${s.pop().type}>`,s.length>0&&(a=!0)},p=()=>d(-1);for(const h of r){const f=h.match(/^(\s*)\d+\.\s+(.*)/),b=h.match(/^(\s*)[-*]\s+(.*)/);if(f||b){const v=(f?f[1]:b[1]).length,C=f?"ol":"ul",k=f?f[2]:b[2];if(s.length===0)o+=`<${C}>`,s.push({type:C,indent:v});else{const g=s[s.length-1];v>g.indent?(o+=`<${C}>`,s.push({type:C,indent:v})):v===g.indent?l():(d(v+1),s.length>0&&s[s.length-1].indent===v?l():(p(),o+=`<${C}>`,s.push({type:C,indent:v})))}o+=`<li>${k}`,a=!0}else h.trim()===""?s.length===0&&(o+="<br>"):(p(),o+=`<p>${h}</p>`)}return p(),o.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>')}render(){const e=this.position.right<this.screenWidth/2;return u`
428
428
  <div class="chatbot">
429
429
  ${this.renderOverlay()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logosphere-ui/core",
3
- "version": "0.0.0-alpha.21",
3
+ "version": "0.0.0-alpha.23",
4
4
  "description": "A modern, framework-agnostic UI component library built with Lit and Web Components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",