@nuraly/lumenui 0.5.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
40
40
  * @license
41
41
  * Copyright 2021 Google LLC
42
42
  * SPDX-License-Identifier: BSD-3-Clause
43
- */(e),o=t[n];if(o){if("string"==typeof o)return o;if("strTag"in o)return p(o.strings,e.values,o.values);{let t=_.get(o);return void 0===t&&(t=o.values,_.set(o,t)),{...o,values:t.map(t=>e.values[t])}}}}return f(e)}function S(t){window.dispatchEvent(new CustomEvent(u,{detail:t}))}let P,M,T,E,C,O="",z=new y;z.resolve();let I=0;const j=t=>(function(t){if(g)throw new Error("lit-localize can only be configured once");m=t,g=!0}((t,e)=>k(C,t,e)),O=M=t.sourceLocale,T=new Set(t.targetLocales),T.add(t.sourceLocale),E=t.loadLocale,{getLocale:R,setLocale:A}),R=()=>O,A=t=>{if(t===(P??O))return z.promise;if(!T||!E)throw new Error("Internal error");if(!T.has(t))throw new Error("Invalid locale code");I++;const e=I;P=t,z.settled&&(z=new y),S({status:"loading",loadingLocale:t});return(t===M?Promise.resolve({templates:void 0}):E(t)).then(i=>{I===e&&(O=t,P=void 0,C=i.templates,S({status:"ready",readyLocale:t}),z.resolve())},i=>{I===e&&(S({status:"error",errorLocale:t,errorMessage:i.toString()}),z.reject(i))}),z.promise};var L=t`
43
+ */(e),o=t[n];if(o){if("string"==typeof o)return o;if("strTag"in o)return p(o.strings,e.values,o.values);{let t=_.get(o);return void 0===t&&(t=o.values,_.set(o,t)),{...o,values:t.map(t=>e.values[t])}}}}return f(e)}function S(t){window.dispatchEvent(new CustomEvent(u,{detail:t}))}let P,M,T,E,C,z="",O=new y;O.resolve();let I=0;const j=t=>(function(t){if(g)throw new Error("lit-localize can only be configured once");m=t,g=!0}((t,e)=>k(C,t,e)),z=M=t.sourceLocale,T=new Set(t.targetLocales),T.add(t.sourceLocale),E=t.loadLocale,{getLocale:R,setLocale:A}),R=()=>z,A=t=>{if(t===(P??z))return O.promise;if(!T||!E)throw new Error("Internal error");if(!T.has(t))throw new Error("Invalid locale code");I++;const e=I;P=t,O.settled&&(O=new y),S({status:"loading",loadingLocale:t});return(t===M?Promise.resolve({templates:void 0}):E(t)).then(i=>{I===e&&(z=t,P=void 0,C=i.templates,S({status:"ready",readyLocale:t}),O.resolve())},i=>{I===e&&(S({status:"error",errorLocale:t,errorMessage:i.toString()}),O.reject(i))}),O.promise};var L=t`
44
44
  :host {
45
45
  display: block;
46
46
  width: 100%;
@@ -60,10 +60,10 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
60
60
  display: flex;
61
61
  width: 100%;
62
62
  height: 100%;
63
- background-color: #ffffff;
64
63
  border-radius: 8px;
65
64
  position: relative;
66
65
  border: 1px solid #e0e0e0;
66
+ box-sizing: border-box;
67
67
  }
68
68
 
69
69
  .chatbot-container {
@@ -88,13 +88,24 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
88
88
  min-width: 0;
89
89
  }
90
90
 
91
+ .chatbot-boxed-area {
92
+ display: flex;
93
+ flex-direction: column;
94
+ flex: 1;
95
+ min-height: 0;
96
+ min-width: 0;
97
+ width: 100%;
98
+ }
99
+
91
100
  .chatbot-header {
92
101
  display: flex;
93
102
  align-items: center;
94
103
  justify-content: space-between;
95
104
  gap: 0.5rem;
96
105
  padding: 0.5rem;
97
- border-bottom: 1px solid #e0e0e0;
106
+ min-height: 43px;
107
+ box-sizing: border-box;
108
+ border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
98
109
  }
99
110
 
100
111
  .chatbot-content {
@@ -106,7 +117,6 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
106
117
  }
107
118
 
108
119
  :host([boxed]) .chat-container {
109
- background-color: #ffffff;
110
120
  border: none;
111
121
  border-radius: 0;
112
122
  }
@@ -117,22 +127,15 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
117
127
 
118
128
  :host([boxed]) .chatbot-main {
119
129
  width: 100%;
120
- max-width: 768px;
121
- margin: 0 auto;
122
- background-color: #ffffff;
123
130
  border: none;
124
131
  border-radius: 0;
125
132
  box-shadow: none;
126
133
  height: 100%;
127
134
  }
128
135
 
129
- /* Boxed layout with threads: background comes from theme variable with white fallback */
130
- :host([boxed]) .chat-container--boxed.chat-container--with-threads {
131
- background-color: #ffffff;
132
- }
133
-
134
- .chat-container--boxed.chat-container--with-threads .chatbot-main {
135
- background-color: #ffffff;
136
+ :host([boxed]) .chatbot-boxed-area {
137
+ max-width: 768px;
138
+ margin: 0 auto;
136
139
  }
137
140
 
138
141
  .chat-container--boxed.chat-container--with-threads .chat-box {
@@ -148,9 +151,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
148
151
  }
149
152
 
150
153
  :host([boxed]) .chatbot-header {
151
- /* Keep header at the top */
152
154
  flex: 0 0 auto;
153
- border-bottom: none;
154
155
  }
155
156
 
156
157
  :host([boxed]) .chatbot-content:has(.empty-state) {
@@ -164,24 +165,15 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
164
165
  min-height: 0;
165
166
  }
166
167
 
167
- :host([boxed]) .chatbot-main:has(.empty-state) {
168
- /* Make main container relative for absolute positioning */
169
- position: relative;
170
- }
171
-
172
168
  :host([boxed]) .empty-state {
173
- /* Position empty state in the center - moved up */
174
- position: absolute;
175
- top: 50%;
176
- left: 50%;
177
- transform: translate(-50%, calc(-50% - 80px));
169
+ display: flex;
170
+ align-items: center;
171
+ justify-content: center;
172
+ flex-direction: column;
178
173
  width: 100%;
174
+ height: 100%;
179
175
  max-width: 768px;
180
- height: auto;
181
176
  padding: 0;
182
- display: flex;
183
- flex-direction: column;
184
- align-items: center;
185
177
  gap: 1.5rem;
186
178
  }
187
179
 
@@ -190,13 +182,9 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
190
182
  }
191
183
 
192
184
  :host([boxed]) .chatbot-content:has(.empty-state) + .input-box {
193
- /* Position input-box in the middle with empty state - moved up */
194
- position: absolute;
195
- top: 50%;
196
- left: 50%;
197
- transform: translate(-50%, calc(-50% + 40px));
198
185
  width: 100%;
199
186
  max-width: 768px;
187
+ margin: 0 auto;
200
188
  }
201
189
 
202
190
  :host([boxed]) .suggestion-container {
@@ -206,7 +194,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
206
194
  :host([boxed]) .messages {
207
195
  box-shadow: none;
208
196
  margin-bottom: 0;
209
- background-color: #ffffff;
197
+ background-color: var(--chatbot-messages-bg, transparent);
210
198
  align-items: stretch;
211
199
  width: 98%;
212
200
  padding: 8px 1.5rem;
@@ -250,7 +238,7 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
250
238
  align-items: center;
251
239
  justify-content: space-between;
252
240
  padding: 0.75rem;
253
- border-bottom: 1px solid #e0e0e0;
241
+ border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
254
242
  }
255
243
 
256
244
  .thread-sidebar__header h3 {
@@ -461,12 +449,13 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
461
449
 
462
450
  .messages {
463
451
  flex: 1;
452
+ min-height: 0;
464
453
  overflow-y: auto;
465
454
  overflow-x: hidden;
466
455
  display: flex;
467
456
  flex-direction: column;
468
457
  gap: 0;
469
- background-color: #ffffff;
458
+ background-color: var(--chatbot-messages-bg, transparent);
470
459
  padding: 8px 1rem;
471
460
  box-sizing: border-box;
472
461
  justify-content: flex-start; /* Always align messages to top */
@@ -605,16 +594,16 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
605
594
  }
606
595
 
607
596
  .message.user .message__content {
608
- background-color: #7c3aed;
609
- color: #ffffff;
597
+ background-color: var(--nuraly-color-user-bubble-bg, rgb(124, 58, 237));
598
+ color: var(--nuraly-color-user-bubble-fg, rgb(255, 255, 255));
610
599
  border-radius: var(--chatbot-radius, 8px);
611
600
  border: 0 solid transparent;
612
601
  box-shadow: none;
613
602
  }
614
603
 
615
604
  .message.bot .message__content {
616
- background-color: transparent;
617
- color: inherit;
605
+ background-color: var(--nuraly-color-bot-bubble-bg, transparent);
606
+ color: var(--nuraly-color-bot-bubble-fg, inherit);
618
607
  border-radius: 0;
619
608
  border: 0 solid transparent;
620
609
  box-shadow: none;
@@ -1659,10 +1648,10 @@ class y{constructor(){this.settled=!1,this.promise=new Promise((t,e)=>{this._res
1659
1648
  .artifact-panel {
1660
1649
  width: 400px;
1661
1650
  min-width: 300px;
1651
+ min-height: 0;
1662
1652
  flex-shrink: 0;
1663
1653
  display: flex;
1664
1654
  flex-direction: row;
1665
- background-color: #ffffff;
1666
1655
  overflow: hidden;
1667
1656
  position: relative;
1668
1657
  }
@@ -1985,14 +1974,14 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
1985
1974
  * @license
1986
1975
  * Copyright 2023 Nuraly, Laabidi Aymen
1987
1976
  * SPDX-License-Identifier: MIT
1988
- */function ht(t){return t.startsWith("image/")}function ut(t,e){const i=t.lastIndexOf(".");if(i>=0&&i<t.length-1)return t.slice(i+1).toUpperCase().slice(0,4);if(e){const t=e.indexOf("/");if(t>=0)return e.slice(t+1).toUpperCase().slice(0,4)}return"FILE"}function pt(t,n,o){var s,r,d,c,h,u,p,f;const m=null===(s=t.text)||void 0===s?void 0:s.includes("[ERROR_START]"),g={error:!!t.error||m,introduction:!!t.introduction,[t.sender]:!0};return i`
1977
+ */function ht(t){return t.startsWith("image/")}function ut(t,e){const i=t.lastIndexOf(".");if(i>=0&&i<t.length-1)return t.slice(i+1).toUpperCase().slice(0,4);if(e){const t=e.indexOf("/");if(t>=0)return e.slice(t+1).toUpperCase().slice(0,4)}return"FILE"}function pt(t,n,o){var s,r,d,c,h,u,p,f;const m=null===(s=t.text)||void 0===s?void 0:s.includes("[ERROR_START]"),g={error:!!t.error||m,introduction:!!t.introduction,[t.sender]:!0},v=t.sender;return i`
1989
1978
  <div
1990
1979
  class="message ${a(g)}"
1991
- part="message"
1980
+ part=${`message message-${v}`}
1992
1981
  data-sender="${t.sender}"
1993
1982
  data-id="${t.id}"
1994
1983
  >
1995
- <div class="message__content" part="message-content">
1984
+ <div class="message__content" part=${`message-content message-content-${v}`}>
1996
1985
  ${m?function(t){const e=t.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERROR_TITLE_END\]([\s\S]*?)\[ERROR_END\]/);if(e){const t=e[1],n=e[2];return i`
1997
1986
  <div class="message__error-container" part="message-error">
1998
1987
  ${t?i`<div class="message__error-title" part="message-error-title">${t}</div>`:""}
@@ -2062,6 +2051,7 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2062
2051
  size="small"
2063
2052
  color="#9ca3af"
2064
2053
  class="message__copy"
2054
+ part="message-copy"
2065
2055
  @click=${()=>n.onCopy(t)}
2066
2056
  @keydown=${e=>n.onCopyKeydown(e,t)}
2067
2057
  title="${o.messages.copyMessageLabel}"
@@ -2083,17 +2073,26 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2083
2073
  ${o.messages.retryButton}
2084
2074
  </nr-button>`:e}
2085
2075
  </div>
2086
- `}function ft(t,n,o,s,r){return i`
2076
+ `}function ft(t,n,o,s,r,a,l){return i`
2087
2077
  <div class="messages" part="messages">
2088
- ${0===t.length?function(t){return i`
2078
+ ${0===t.length?l?function(t){return i`
2079
+ <div class="empty-state empty-state--loading" part="empty-state thread-loading">
2080
+ <slot name="thread-loading">
2081
+ <div class="spinner" part="thread-loading-spinner"></div>
2082
+ <div class="empty-state__content" part="empty-state-content">
2083
+ ${t.messages.loadingConversationLabel}
2084
+ </div>
2085
+ </slot>
2086
+ </div>
2087
+ `}(r):function(t,e){const n=null!=e?e:t.messages.startConversationLabel;return i`
2089
2088
  <div class="empty-state" part="empty-state">
2090
2089
  <slot name="empty-state">
2091
- <div class="empty-state__content">
2092
- ${t.messages.startConversationLabel}
2090
+ <div class="empty-state__content" part="empty-state-content">
2091
+ ${n}
2093
2092
  </div>
2094
2093
  </slot>
2095
2094
  </div>
2096
- `}(r):e}
2095
+ `}(r,a):e}
2097
2096
  ${t.map(t=>pt(t,s,r))}
2098
2097
  ${n}
2099
2098
  ${o}
@@ -2137,6 +2136,7 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2137
2136
  <div
2138
2137
  slot="trigger"
2139
2138
  class="file-thumb ${t.isUploading?"file-thumb--uploading":""}"
2139
+ part="file-thumb"
2140
2140
  role="button"
2141
2141
  tabindex="0"
2142
2142
  title="${t.name}"
@@ -2145,22 +2145,24 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2145
2145
  ${r(t.mimeType)&&(t.previewUrl||t.url)?i`
2146
2146
  <img
2147
2147
  class="file-thumb__image"
2148
+ part="file-thumb-image"
2148
2149
  src="${t.previewUrl||t.url}"
2149
2150
  alt="${t.name}"
2150
2151
  />
2151
2152
  `:i`
2152
- <div class="file-thumb__ext" data-ext="${s(t.name,t.mimeType)}">
2153
- <span class="file-thumb__ext-label">${s(t.name,t.mimeType)}</span>
2153
+ <div class="file-thumb__ext" part="file-thumb-ext" data-ext="${s(t.name,t.mimeType)}">
2154
+ <span class="file-thumb__ext-label" part="file-thumb-ext-label">${s(t.name,t.mimeType)}</span>
2154
2155
  </div>
2155
2156
  `}
2156
2157
  ${t.isUploading?i`
2157
- <div class="file-thumb__spinner" aria-label="${n.input.uploadingLabel}">
2158
+ <div class="file-thumb__spinner" part="file-thumb-spinner" aria-label="${n.input.uploadingLabel}">
2158
2159
  <span class="file-thumb__spinner-ring"></span>
2159
2160
  </div>
2160
2161
  `:""}
2161
2162
  <button
2162
2163
  type="button"
2163
2164
  class="file-thumb__remove"
2165
+ part="file-thumb-remove"
2164
2166
  aria-label="${n.input.removeFileLabel}"
2165
2167
  title="${n.input.removeFileLabel}"
2166
2168
  @click=${i=>{i.stopPropagation(),e(t.id)}}
@@ -2196,8 +2198,8 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2196
2198
  `)}
2197
2199
  </div>
2198
2200
  `}function vt(t,n){return i`
2199
- <div class="action-buttons-row">
2200
- <div class="action-buttons-left">
2201
+ <div class="action-buttons-row" part="actions">
2202
+ <div class="action-buttons-left" part="actions-left">
2201
2203
  ${t.enableFileUpload?function(t,e){return i`
2202
2204
  <nr-dropdown
2203
2205
  .items=${t.fileUploadItems}
@@ -2245,11 +2247,12 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2245
2247
  `}(t,n):e}
2246
2248
  </div>
2247
2249
 
2248
- <div class="action-buttons-right">
2250
+ <div class="action-buttons-right" part="actions-right">
2249
2251
  ${t.showAudioButton&&!t.isQueryRunning?i`
2250
2252
  <!-- Speech-to-text: mic + keyboard indicator -->
2251
2253
  <button
2252
2254
  class="audio-mic-btn"
2255
+ part="audio-mic-button audio-mic-transcribe"
2253
2256
  title="${t.i18n.audio.recordSpeechLabel}"
2254
2257
  ?disabled=${t.disabled}
2255
2258
  @click=${()=>{var t;return null===(t=n.onAudioStart)||void 0===t?void 0:t.call(n,"transcribe")}}
@@ -2268,6 +2271,7 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2268
2271
  <!-- Voice message: mic + waveform indicator -->
2269
2272
  <button
2270
2273
  class="audio-mic-btn"
2274
+ part="audio-mic-button audio-mic-voice"
2271
2275
  title="${t.i18n.audio.sendVoiceMessageLabel}"
2272
2276
  ?disabled=${t.disabled}
2273
2277
  @click=${()=>{var t;return null===(t=n.onAudioStart)||void 0===t?void 0:t.call(n,"message")}}
@@ -2309,9 +2313,10 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2309
2313
  </svg>`:i`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
2310
2314
  <path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>
2311
2315
  </svg>`;return i`
2312
- <div class="audio-recording-bar">
2316
+ <div class="audio-recording-bar" part="audio-recording-bar">
2313
2317
  <button
2314
2318
  class="audio-rec-cancel"
2319
+ part="audio-cancel-button"
2315
2320
  title="${t.i18n.audio.cancelRecordingLabel}"
2316
2321
  @click=${e.onAudioCancel}
2317
2322
  aria-label="${t.i18n.audio.cancelRecordingLabel}"
@@ -2323,22 +2328,23 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2323
2328
  </svg>
2324
2329
  </button>
2325
2330
 
2326
- <div class="audio-rec-indicator">
2327
- <span class="audio-rec-dot"></span>
2328
- <div class="audio-rec-wave">
2331
+ <div class="audio-rec-indicator" part="audio-indicator">
2332
+ <span class="audio-rec-dot" part="audio-dot"></span>
2333
+ <div class="audio-rec-wave" part="audio-wave">
2329
2334
  ${o.map(t=>i`
2330
- <div class="audio-rec-bar" style=${c({height:`${Math.round(24*t)}px`})}></div>
2335
+ <div class="audio-rec-bar" part="audio-bar" style=${c({height:`${Math.round(24*t)}px`})}></div>
2331
2336
  `)}
2332
2337
  </div>
2333
- <span class="audio-rec-time">${n}</span>
2338
+ <span class="audio-rec-time" part="audio-time">${n}</span>
2334
2339
  </div>
2335
2340
 
2336
- <span class="audio-rec-mode-label">
2341
+ <span class="audio-rec-mode-label" part="audio-mode-label">
2337
2342
  ${s?t.i18n.audio.speechToTextLabel:t.i18n.audio.voiceMessageLabel}
2338
2343
  </span>
2339
2344
 
2340
2345
  <button
2341
2346
  class="audio-rec-send ${s?"audio-rec-send--transcribe":""}"
2347
+ part="audio-send-button"
2342
2348
  title="${r}"
2343
2349
  @click=${e.onAudioSend}
2344
2350
  aria-label="${r}"
@@ -2356,7 +2362,7 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2356
2362
  ${t.uploadedFiles.length>0?gt(t.uploadedFiles,n.onFileRemove,t.i18n,n.onFileClick):e}
2357
2363
 
2358
2364
  <!-- Input area -->
2359
- <div class="input-row">
2365
+ <div class="input-row" part="input-row">
2360
2366
  <div
2361
2367
  class="input-box__input"
2362
2368
  part="input"
@@ -2391,6 +2397,7 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2391
2397
  ${e.editingThreadId===t.id&&n.onRenameThread?i`
2392
2398
  <input
2393
2399
  class="thread-item__rename-input"
2400
+ part="thread-rename-input"
2394
2401
  type="text"
2395
2402
  .value=${t.title||""}
2396
2403
  @click=${t=>t.stopPropagation()}
@@ -2398,9 +2405,9 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2398
2405
  @blur=${e=>{const i=e.target.value.trim();i&&i!==t.title?n.onRenameThread(t.id,i):n.onRenameThread(t.id,t.title||"")}}
2399
2406
  />
2400
2407
  `:i`
2401
- <div class="thread-item__title">${t.title||e.i18n.threads.newChatTitle}</div>
2408
+ <div class="thread-item__title" part="thread-title">${t.title||e.i18n.threads.newChatTitle}</div>
2402
2409
  `}
2403
- <div class="thread-item__actions">
2410
+ <div class="thread-item__actions" part="thread-actions">
2404
2411
  ${n.onBookmarkThread&&t.bookmarked?i`
2405
2412
  <button
2406
2413
  class="thread-item__action-btn thread-item__bookmark--active"
@@ -2434,10 +2441,10 @@ function rt(t){if(!t)return"";const e=t instanceof Date?t:new Date(t);if(Number.
2434
2441
  `:""}
2435
2442
  </div>
2436
2443
  </div>
2437
- <div class="thread-item__preview">
2444
+ <div class="thread-item__preview" part="thread-preview">
2438
2445
  ${s}
2439
2446
  </div>
2440
- <div class="thread-item__timestamp">${rt(t.updatedAt)}</div>
2447
+ <div class="thread-item__timestamp" part="thread-timestamp">${rt(t.updatedAt)}</div>
2441
2448
  </div>
2442
2449
  `}function xt(t,n){if(!t.isOpen||!t.file)return e;const o=t.file,s=o.mimeType.startsWith("image/"),r="application/pdf"===o.mimeType||o.name.toLowerCase().endsWith(".pdf");return i`
2443
2450
  <nr-modal
@@ -2497,15 +2504,15 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2497
2504
  */function wt(t,n){var o;if(!t.isOpen||!t.artifact)return e;const s=t.artifact,r=dt(s.language);return i`
2498
2505
  <div class="artifact-panel" part="artifact-panel">
2499
2506
  <div class="artifact-panel__resize-handle" part="artifact-panel-resize-handle">
2500
- <div class="artifact-panel__resize-bar"></div>
2507
+ <div class="artifact-panel__resize-bar" part="artifact-panel-resize-bar"></div>
2501
2508
  </div>
2502
- <div class="artifact-panel__body">
2503
- <div class="artifact-panel__header">
2504
- <div class="artifact-panel__header-info">
2505
- <nr-tag size="small" class="artifact-panel__lang-badge">${r}</nr-tag>
2506
- <span class="artifact-panel__title">${s.title}</span>
2509
+ <div class="artifact-panel__body" part="artifact-panel-body">
2510
+ <div class="artifact-panel__header" part="artifact-panel-header">
2511
+ <div class="artifact-panel__header-info" part="artifact-panel-header-info">
2512
+ <nr-tag size="small" class="artifact-panel__lang-badge" part="artifact-panel-lang">${r}</nr-tag>
2513
+ <span class="artifact-panel__title" part="artifact-panel-title">${s.title}</span>
2507
2514
  </div>
2508
- <div class="artifact-panel__actions">
2515
+ <div class="artifact-panel__actions" part="artifact-panel-actions">
2509
2516
  <nr-button
2510
2517
  type="text"
2511
2518
  size="small"
@@ -2524,8 +2531,8 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2524
2531
  ></nr-button>
2525
2532
  </div>
2526
2533
  </div>
2527
- <div class="artifact-panel__content">
2528
- ${(null===(o=t.renderContent)||void 0===o?void 0:o.call(t,s))||function(t){switch(t.language){case"json":{let e;try{e=JSON.stringify(JSON.parse(t.content),null,2)}catch(i){e=t.content}return i`<pre class="artifact-panel__code"><code>${e}</code></pre>`}case"md":case"markdown":return i`<div class="artifact-panel__rendered-md">${l(ct(t.content))}</div>`;case"html":return i`<div class="artifact-panel__rendered-html">${l(t.content)}</div>`;case"text":case"txt":return i`<div class="artifact-panel__rendered-text">${t.content}</div>`;default:return i`<pre class="artifact-panel__code"><code>${t.content}</code></pre>`}}(s)}
2534
+ <div class="artifact-panel__content" part="artifact-panel-content">
2535
+ ${(null===(o=t.renderContent)||void 0===o?void 0:o.call(t,s))||function(t){switch(t.language){case"json":{let e;try{e=JSON.stringify(JSON.parse(t.content),null,2)}catch(i){e=t.content}return i`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${e}</code></pre>`}case"md":case"markdown":return i`<div class="artifact-panel__rendered-md" part="artifact-panel-md">${l(ct(t.content))}</div>`;case"html":return i`<div class="artifact-panel__rendered-html" part="artifact-panel-html">${l(t.content)}</div>`;case"text":case"txt":return i`<div class="artifact-panel__rendered-text" part="artifact-panel-text">${t.content}</div>`;default:return i`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${t.content}</code></pre>`}}(s)}
2529
2536
  </div>
2530
2537
  </div>
2531
2538
  </div>
@@ -2537,19 +2544,19 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2537
2544
  */function _t(t,n){return!1!==t.showMessages?i`
2538
2545
  <div class="chatbot-content" part="content">
2539
2546
  ${ft(t.messages,mt(t.chatStarted,t.suggestions,n.suggestion,t.i18n),t.isTyping?function(t,n,o){if(!t)return e;const s=n===V.Dots?i`
2540
- <div class="dots">
2547
+ <div class="dots" part="typing-dots">
2541
2548
  <span></span>
2542
2549
  <span></span>
2543
2550
  <span></span>
2544
2551
  </div>
2545
- `:i`<div class="spinner"></div>`;return i`
2552
+ `:i`<div class="spinner" part="typing-spinner"></div>`;return i`
2546
2553
  <div class="message bot loading" part="typing-indicator">
2547
- <div class="message__content">
2554
+ <div class="message__content" part="typing-content">
2548
2555
  ${s}
2549
- ${o?i`<span class="loading-text">${o.split("").map((t,e)=>i`<span class="loading-text__char" style="animation-delay:${.04*e}s">${" "===t?" ":t}</span>`)}</span>`:e}
2556
+ ${o?i`<span class="loading-text" part="typing-text">${o.split("").map((t,e)=>i`<span class="loading-text__char" style="animation-delay:${.04*e}s">${" "===t?" ":t}</span>`)}</span>`:e}
2550
2557
  </div>
2551
2558
  </div>
2552
- `}(t.isTyping,t.loadingIndicator||V.Spinner,t.loadingText):e,n.message,t.i18n)}
2559
+ `}(t.isTyping,t.loadingIndicator||V.Spinner,t.loadingText):e,n.message,t.i18n,t.welcomeMessage,t.isPendingThread)}
2553
2560
  <slot name="messages"></slot>
2554
2561
  </div>
2555
2562
  `:t.suggestions&&t.suggestions.length>0?i`
@@ -2566,14 +2573,14 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2566
2573
 
2567
2574
  ${t.enableThreads&&t.isThreadSidebarOpen&&t.threadSidebar&&n.threadSidebar?function(t,n){const o=t.threads.filter(t=>t.bookmarked),s=t.threads.filter(t=>!t.bookmarked);return i`
2568
2575
  <div class="thread-sidebar" part="thread-sidebar">
2569
- <div class="thread-sidebar__header">
2570
- <h3>${t.i18n.threads.conversationsTitle}</h3>
2576
+ <div class="thread-sidebar__header" part="thread-sidebar-header">
2577
+ <h3 part="thread-sidebar-title">${t.i18n.threads.conversationsTitle}</h3>
2571
2578
  </div>
2572
2579
 
2573
- <div class="thread-list">
2580
+ <div class="thread-list" part="thread-list">
2574
2581
  ${o.length>0?i`
2575
- <div class="thread-section" part="thread-section-bookmarks">
2576
- <div class="thread-section__label">
2582
+ <div class="thread-section" part="thread-section thread-section-bookmarks">
2583
+ <div class="thread-section__label" part="thread-section-label">
2577
2584
  <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
2578
2585
  ${t.i18n.threads.bookmarksLabel}
2579
2586
  </div>
@@ -2582,11 +2589,11 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2582
2589
  `:e}
2583
2590
  ${s.length>0||0===o.length?i`
2584
2591
  ${o.length>0?i`
2585
- <div class="thread-section__label">${t.i18n.threads.allConversationsLabel}</div>
2592
+ <div class="thread-section__label" part="thread-section-label">${t.i18n.threads.allConversationsLabel}</div>
2586
2593
  `:e}
2587
2594
  ${d(s,t=>t.id,e=>yt(e,t,n))}
2588
2595
  ${0===s.length&&0===o.length?i`
2589
- <p class="empty-msg">${t.i18n.threads.noConversationsLabel}</p>
2596
+ <p class="empty-msg" part="thread-empty">${t.i18n.threads.noConversationsLabel}</p>
2590
2597
  `:e}
2591
2598
  `:e}
2592
2599
  </div>
@@ -2624,11 +2631,13 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2624
2631
  </div>
2625
2632
  `:e}(t,n)}
2626
2633
 
2627
- <slot name="header"></slot>
2634
+ <div class="chatbot-boxed-area" part="boxed-area">
2635
+ <slot name="header"></slot>
2628
2636
 
2629
- ${_t(t,n)}
2637
+ ${_t(t,n)}
2630
2638
 
2631
- ${bt(t.inputBox,n.inputBox)}
2639
+ ${bt(t.inputBox,n.inputBox)}
2640
+ </div>
2632
2641
 
2633
2642
  <slot name="footer"></slot>
2634
2643
  </div>
@@ -2640,9 +2649,9 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2640
2649
  class="file-upload-area ${t.isDragging?"file-upload-area--dragging":""}"
2641
2650
  part="file-upload-area"
2642
2651
  >
2643
- <div class="file-upload-area__content">
2644
- <nr-icon name="upload" size="xlarge"></nr-icon>
2645
- <div class="file-upload-area__text">
2652
+ <div class="file-upload-area__content" part="file-upload-area-content">
2653
+ <nr-icon name="upload" size="xlarge" part="file-upload-area-icon"></nr-icon>
2654
+ <div class="file-upload-area__text" part="file-upload-area-text">
2646
2655
  ${t.label}
2647
2656
  </div>
2648
2657
  </div>
@@ -2754,7 +2763,7 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2754
2763
  * @license
2755
2764
  * Copyright 2023 Nuraly, Laabidi Aymen
2756
2765
  * SPDX-License-Identifier: MIT
2757
- */var Mt=function(t,e,i,n){for(var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r);return s>3&&r&&Object.defineProperty(e,i,r),r},Tt=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};const Et={input:{placeholder:m("Type your message..."),chatInputAriaLabel:m("Chat input"),attachButton:m("Attach"),attachFilesAriaLabel:m("Attach files"),removeFileLabel:m("Remove file"),uploadingLabel:m("Uploading"),uploadingProgress:m("Uploading…"),dropFilesHere:m("Drop files here to upload")},send:{sendButton:m("Send"),stopButton:m("Stop"),sendMessageLabel:m("Send message"),stopQueryLabel:m("Stop query")},audio:{recordSpeechLabel:m("Record speech to text"),sendVoiceMessageLabel:m("Send voice message"),cancelRecordingLabel:m("Cancel recording"),speechToTextLabel:m("Speech to text"),voiceMessageLabel:m("Voice message"),convertToTextLabel:m("Convert to text"),sendAsVoiceMessageLabel:m("Send as voice message")},modules:{moduleSelectionLabel:m("Select Modules"),moduleSearchPlaceholder:m("Search modules..."),moduleSelectAriaLabel:m("Select modules"),modulesSelectedSuffix:m("modules selected")},threads:{conversationsTitle:m("Conversations"),bookmarksLabel:m("Bookmarks"),allConversationsLabel:m("All Conversations"),noConversationsLabel:m("No conversations yet"),newChatTitle:m("New Chat"),newConversationLabel:m("New conversation"),removeBookmarkLabel:m("Remove bookmark"),bookmarkLabel:m("Bookmark"),renameLabel:m("Rename"),deleteLabel:m("Delete"),moreOptionsLabel:m("More options"),showThreadsLabel:m("Show threads"),hideThreadsLabel:m("Hide threads")},messages:{attachedFilesLabel:m("Attached files"),copyMessageLabel:m("Copy message"),retryMessageLabel:m("Retry message"),retryButton:m("Retry"),startConversationLabel:m("Start a conversation"),suggestionPrefix:m("Select suggestion: ")},urlModal:{addUrlTitle:m("Add URL"),urlLabel:m("URL"),urlPlaceholder:m("Enter URL..."),loadFromUrlLabel:m("Load file from URL"),selectedFileLabel:m("Selected file"),loadingFromUrlLabel:m("Loading file from URL..."),cancelButton:m("Cancel"),addButton:m("Add")},artifactPanel:{copyCodeLabel:m("Copy code"),closePanelLabel:m("Close panel")},loading:{agentWorkingLabel:m("Agent is working...")}};let Ct=class extends((t=>B(F(N(H(t)))))(n)){constructor(){super(...arguments),this.requiredComponents=["nr-input","nr-button","nr-icon","nr-dropdown","nr-select","nr-modal","nr-popconfirm"],this.messages=[],this.currentInput="",this.isBotTyping=!1,this.isQueryRunning=!1,this.suggestions=[],this.chatStarted=!1,this.isRTL=!1,this.size=G.Medium,this.variant=K.Default,this.loadingIndicator=V.Dots,this.loadingText=m("Agent is working..."),this.disabled=!1,this.placeholder=m("Type your message..."),this.showSendButton=!0,this.autoScroll=!0,this.showThreads=!1,this.enableThreadCreation=!1,this.threads=[],this.mode="chat",this.boxed=!1,this.enableUrlSync=!1,this.showMessages=!0,this.enableFileUpload=!1,this.uploadedFiles=[],this.actionButtons=[],this.enableModuleSelection=!1,this.modules=[],this.selectedModules=[],this.moduleSelectionLabel=m("Select Modules"),this.enableArtifacts=!1,this.showAudioButton=!1,this.focused=!1,this.isArtifactPanelOpen=!1,this.selectedArtifact=null,this.isThreadSidebarOpen=!0,this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName="",this.isFilePreviewModalOpen=!1,this.previewFile=null,this._isDragging=!1,this._dragDepth=0,this.controllerUnsubscribes=[],this._audio=new Pt(this),this._audioMode="message",this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get moduleSelectOptions(){return this.modules.map(t=>({value:t.id,label:t.name,icon:t.icon,disabled:!1===t.enabled,description:t.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var t,e,i,n;null===(t=this.shadowRoot)||void 0===t||t.addEventListener("click",t=>{var e,i;const n=null===(i=(e=t.target).closest)||void 0===i?void 0:i.call(e,"[data-artifact-id]");if(n){const t=n.dataset.artifactId;t&&this.handleArtifactClick(t)}}),null===(e=this.shadowRoot)||void 0===e||e.addEventListener("nr-thread-edit",t=>{const e=t.detail;(null==e?void 0:e.threadId)&&(this._editingThreadId=e.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".thread-item__rename-input");e&&(e.focus(),e.select())}))}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("click",t=>{var e,i;const n=null===(i=(e=t.target).closest)||void 0===i?void 0:i.call(e,"[data-selection-value]");if(n){const t=n.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("keydown",t=>{var e,i,n,o;const s=t;if("Enter"!==s.key&&" "!==s.key)return;const r=null===(i=(e=s.target).closest)||void 0===i?void 0:i.call(e,"[data-artifact-id]");if(r){s.preventDefault();const t=r.dataset.artifactId;return void(t&&this.handleArtifactClick(t))}const a=null===(o=(n=s.target).closest)||void 0===o?void 0:o.call(n,"[data-selection-value]");if(a){s.preventDefault();const t=a.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}})}disconnectedCallback(){var t;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(t=this._artifactResizeCleanup)||void 0===t||t.call(this),this._artifactResizeBound=!1}updated(t){if(super.updated(t),t.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}this.enableUrlSync&&this.handleHashChange()}if(t.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!t.has("controller")){if(t.has("messages")||t.has("suggestions")||t.has("threads"))try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}}t.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".messages");e&&(e.scrollTop=e.scrollHeight)})}setupControllerIntegration(){this.controller&&this.controllerUnsubscribes.push(this.controller.on("state:changed",this.handleControllerStateChange.bind(this)),this.controller.on("message:sent",this.handleControllerMessageSent.bind(this)),this.controller.on("message:received",this.handleControllerMessageReceived.bind(this)),this.controller.on("error",this.handleControllerError.bind(this)))}cleanupControllerIntegration(){if(this.controllerUnsubscribes.length)try{this.controllerUnsubscribes.forEach(t=>{try{t()}catch(t){}})}finally{this.controllerUnsubscribes=[]}}setupUrlSync(){this.enableUrlSync&&!this._hashChangeHandler&&(this._hashChangeHandler=this.handleHashChange.bind(this),window.addEventListener("hashchange",this._hashChangeHandler),this.handleHashChange())}teardownUrlSync(){this._hashChangeHandler&&(window.removeEventListener("hashchange",this._hashChangeHandler),this._hashChangeHandler=void 0)}handleHashChange(){const t=window.location.hash.match(/^#conversation\/(.+)$/);if(t){const e=decodeURIComponent(t[1]);e!==this.activeThreadId&&this.controller&&this.controller.switchThread(e)}}handleControllerStateChange(t){var e,i,n,o,s;if(t.messages&&(this.messages=t.messages),t.threads&&(this.threads=t.threads),t.suggestions&&t.suggestions.length>0&&(this.suggestions=t.suggestions),t.currentThreadId&&(this.activeThreadId=t.currentThreadId),this.enableUrlSync&&t.currentThreadId){const e=`#conversation/${encodeURIComponent(t.currentThreadId)}`;window.location.hash!==e&&history.replaceState(null,"",e)}if(this.chatStarted=(null===(e=t.messages)||void 0===e?void 0:e.length)>0,this.isBotTyping=t.isTyping||!1,this.statusText=t.statusText,this.isQueryRunning=t.isProcessing||!1,t.uploadedFiles&&(this.uploadedFiles=t.uploadedFiles),this.enableArtifacts){const e=null===(i=t.messages)||void 0===i?void 0:i.some(t=>{var e,i;return(null===(i=null===(e=t.metadata)||void 0===e?void 0:e.artifactIds)||void 0===i?void 0:i.length)>0});e||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(n=t.messages)||void 0===n?void 0:n.length)){const e=[...t.messages].reverse().find(t=>"bot"===t.sender),i=null===(o=null==e?void 0:e.metadata)||void 0===o?void 0:o.artifactIds;if(null==i?void 0:i.length){const t=i[i.length-1];if((null===(s=this.selectedArtifact)||void 0===s?void 0:s.id)!==t){const e=this.getArtifactPlugin(),i=null==e?void 0:e.getArtifact(t);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(t){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(t){}handleControllerError(t){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",t.error)}get resolvedI18n(){var t,e,i,n,o,s,r,a,l;const d=this.i18n;return{input:Object.assign(Object.assign({},Et.input),null!==(t=null==d?void 0:d.input)&&void 0!==t?t:{}),send:Object.assign(Object.assign({},Et.send),null!==(e=null==d?void 0:d.send)&&void 0!==e?e:{}),audio:Object.assign(Object.assign({},Et.audio),null!==(i=null==d?void 0:d.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},Et.modules),null!==(n=null==d?void 0:d.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},Et.threads),null!==(o=null==d?void 0:d.threads)&&void 0!==o?o:{}),messages:Object.assign(Object.assign({},Et.messages),null!==(s=null==d?void 0:d.messages)&&void 0!==s?s:{}),urlModal:Object.assign(Object.assign({},Et.urlModal),null!==(r=null==d?void 0:d.urlModal)&&void 0!==r?r:{}),artifactPanel:Object.assign(Object.assign({},Et.artifactPanel),null!==(a=null==d?void 0:d.artifactPanel)&&void 0!==a?a:{}),loading:Object.assign(Object.assign({},Et.loading),null!==(l=null==d?void 0:d.loading)&&void 0!==l?l:{})}}render(){var t;const e=this.resolvedI18n,n={boxed:this.boxed,showMessages:this.showMessages,messages:this.messages,isTyping:this.isBotTyping,loadingIndicator:this.loadingIndicator,loadingText:this.statusText||this.loadingText,chatStarted:this.chatStarted,suggestions:this.suggestions,inputBox:{placeholder:this.placeholder,disabled:this.disabled||this.isQueryRunning,currentInput:this.currentInput,uploadedFiles:this.uploadedFiles,isQueryRunning:this.isQueryRunning,showSendButton:this.showSendButton,enableFileUpload:this.enableFileUpload,fileUploadItems:[{id:"upload-file",label:"Upload File",icon:"upload"},{id:"upload-url",label:"Upload from URL",icon:"link"}],enableModuleSelection:this.enableModuleSelection,moduleOptions:this.moduleSelectOptions,selectedModules:this.selectedModules,moduleSelectionLabel:this.moduleSelectionLabel,renderModuleDisplay:this.renderModuleSelectedDisplay.bind(this),showAudioButton:this.showAudioButton,audioRecording:this._audio.state,audioMode:this._audioMode,i18n:e},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId,i18n:e}:void 0,enableFileUpload:this.enableFileUpload,isDragging:this._isDragging,i18n:e,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(t=this.renderArtifactContent)&&void 0!==t?t:this.getPluginArtifactRenderer(),i18n:e}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName,i18n:e}:void 0},o={message:{onRetry:this.handleRetry.bind(this),onRetryKeydown:()=>{},onCopy:this.handleCopyMessage.bind(this),onCopyKeydown:()=>{},onFileClick:this.handleFilePreview.bind(this)},suggestion:{onClick:this.handleSuggestionClick.bind(this),onKeydown:()=>{}},inputBox:{onInput:this.handleContentEditableInput.bind(this),onKeydown:this.handleKeyDown.bind(this),onFocus:this.handleInputFocus.bind(this),onBlur:this.handleInputBlur.bind(this),onSend:this.handleSendMessage.bind(this),onStop:this.handleStopQuery.bind(this),onSendKeydown:()=>{},onFileDropdownClick:this.handleFileDropdownClick.bind(this),onModuleChange:this.handleModuleSelectionChange.bind(this),onFileRemove:this.handleFileRemove.bind(this),onFileClick:this.handleFilePreview.bind(this),onAudioStart:this.handleAudioStart.bind(this),onAudioCancel:this.handleAudioCancel.bind(this),onAudioSend:this.handleAudioSend.bind(this)},threadSidebar:this.showThreads?{onCreateNew:()=>{var t;null===(t=this.controller)||void 0===t||t.createThread("New Chat")},onSelectThread:t=>{var e;this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(t)}`),null===(e=this.controller)||void 0===e||e.switchThread(t)},onDeleteThread:t=>{var e;null===(e=this.controller)||void 0===e||e.deleteThread(t)},onBookmarkThread:t=>{var e;null===(e=this.controller)||void 0===e||e.bookmarkThread(t)},onRenameThread:(t,e)=>{var i;null===(i=this.controller)||void 0===i||i.renameThread(t,e),this._editingThreadId=void 0}}:void 0,fileUploadArea:{onDragEnter:this.handleDragEnter.bind(this),onDragOver:this.handleDragOver.bind(this),onDragLeave:this.handleDragLeave.bind(this),onDrop:this.handleDrop.bind(this)},urlModal:this.isUrlModalOpen?{onClose:this.handleUrlModalClose.bind(this),onUrlInputChange:this.handleUrlInputChange.bind(this),onUrlInputKeydown:this.handleUrlInputKeydown.bind(this),onConfirm:this.handleUrlConfirm.bind(this),onAttachFile:this.handleUrlAttachFile.bind(this)}:void 0,artifactPanel:this.enableArtifacts?{onClose:this.handleArtifactPanelClose.bind(this),onCopy:this.handleArtifactCopy.bind(this)}:void 0,onToggleThreadSidebar:this.showThreads?this.toggleThreadSidebar.bind(this):void 0};return i`
2766
+ */var Mt=function(t,e,i,n){for(var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,a=t.length-1;a>=0;a--)(o=t[a])&&(r=(s<3?o(r):s>3?o(e,i,r):o(e,i))||r);return s>3&&r&&Object.defineProperty(e,i,r),r},Tt=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};const Et={input:{placeholder:m("Type your message..."),chatInputAriaLabel:m("Chat input"),attachButton:m("Attach"),attachFilesAriaLabel:m("Attach files"),removeFileLabel:m("Remove file"),uploadingLabel:m("Uploading"),uploadingProgress:m("Uploading…"),dropFilesHere:m("Drop files here to upload")},send:{sendButton:m("Send"),stopButton:m("Stop"),sendMessageLabel:m("Send message"),stopQueryLabel:m("Stop query")},audio:{recordSpeechLabel:m("Record speech to text"),sendVoiceMessageLabel:m("Send voice message"),cancelRecordingLabel:m("Cancel recording"),speechToTextLabel:m("Speech to text"),voiceMessageLabel:m("Voice message"),convertToTextLabel:m("Convert to text"),sendAsVoiceMessageLabel:m("Send as voice message")},modules:{moduleSelectionLabel:m("Select Modules"),moduleSearchPlaceholder:m("Search modules..."),moduleSelectAriaLabel:m("Select modules"),modulesSelectedSuffix:m("modules selected")},threads:{conversationsTitle:m("Conversations"),bookmarksLabel:m("Bookmarks"),allConversationsLabel:m("All Conversations"),noConversationsLabel:m("No conversations yet"),newChatTitle:m("New Chat"),newConversationLabel:m("New conversation"),removeBookmarkLabel:m("Remove bookmark"),bookmarkLabel:m("Bookmark"),renameLabel:m("Rename"),deleteLabel:m("Delete"),moreOptionsLabel:m("More options"),showThreadsLabel:m("Show threads"),hideThreadsLabel:m("Hide threads")},messages:{attachedFilesLabel:m("Attached files"),copyMessageLabel:m("Copy message"),retryMessageLabel:m("Retry message"),retryButton:m("Retry"),startConversationLabel:m("Start a conversation"),suggestionPrefix:m("Select suggestion: "),loadingConversationLabel:m("Loading conversation…")},urlModal:{addUrlTitle:m("Add URL"),urlLabel:m("URL"),urlPlaceholder:m("Enter URL..."),loadFromUrlLabel:m("Load file from URL"),selectedFileLabel:m("Selected file"),loadingFromUrlLabel:m("Loading file from URL..."),cancelButton:m("Cancel"),addButton:m("Add")},artifactPanel:{copyCodeLabel:m("Copy code"),closePanelLabel:m("Close panel")},loading:{agentWorkingLabel:m("Agent is working...")}};let Ct=class extends((t=>B(F(N(H(t)))))(n)){constructor(){super(...arguments),this.requiredComponents=["nr-input","nr-button","nr-icon","nr-dropdown","nr-select","nr-modal","nr-popconfirm"],this.messages=[],this.currentInput="",this.isBotTyping=!1,this.isQueryRunning=!1,this.suggestions=[],this.chatStarted=!1,this.isRTL=!1,this.size=G.Medium,this.variant=K.Default,this.loadingIndicator=V.Dots,this.loadingText=m("Agent is working..."),this.disabled=!1,this.placeholder=m("Type your message..."),this.showSendButton=!0,this.autoScroll=!0,this.showThreads=!1,this.enableThreadCreation=!1,this.threads=[],this.mode="chat",this.boxed=!1,this.enableUrlSync=!1,this.showMessages=!0,this.enableFileUpload=!1,this.uploadedFiles=[],this.actionButtons=[],this.enableModuleSelection=!1,this.modules=[],this.selectedModules=[],this.moduleSelectionLabel=m("Select Modules"),this.enableArtifacts=!1,this.showAudioButton=!1,this.focused=!1,this.isArtifactPanelOpen=!1,this.selectedArtifact=null,this.isThreadSidebarOpen=!0,this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName="",this.isFilePreviewModalOpen=!1,this.previewFile=null,this._isDragging=!1,this._dragDepth=0,this.controllerUnsubscribes=[],this._audio=new Pt(this),this._audioMode="message",this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get resolvedActionButtons(){var t;const e=null!==(t=this.actionButtons)&&void 0!==t?t:[];if(!this.enableFileUpload)return e;return e.some(t=>"attach"===(null==t?void 0:t.type))?e:[...e,{type:"attach",enabled:!0}]}get moduleSelectOptions(){return this.modules.map(t=>({value:t.id,label:t.name,icon:t.icon,disabled:!1===t.enabled,description:t.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var t,e,i,n;null===(t=this.shadowRoot)||void 0===t||t.addEventListener("click",t=>{var e,i;const n=null===(i=(e=t.target).closest)||void 0===i?void 0:i.call(e,"[data-artifact-id]");if(n){const t=n.dataset.artifactId;t&&this.handleArtifactClick(t)}}),null===(e=this.shadowRoot)||void 0===e||e.addEventListener("nr-thread-edit",t=>{const e=t.detail;(null==e?void 0:e.threadId)&&(this._editingThreadId=e.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".thread-item__rename-input");e&&(e.focus(),e.select())}))}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("click",t=>{var e,i;const n=null===(i=(e=t.target).closest)||void 0===i?void 0:i.call(e,"[data-selection-value]");if(n){const t=n.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("keydown",t=>{var e,i,n,o;const s=t;if("Enter"!==s.key&&" "!==s.key)return;const r=null===(i=(e=s.target).closest)||void 0===i?void 0:i.call(e,"[data-artifact-id]");if(r){s.preventDefault();const t=r.dataset.artifactId;return void(t&&this.handleArtifactClick(t))}const a=null===(o=(n=s.target).closest)||void 0===o?void 0:o.call(n,"[data-selection-value]");if(a){s.preventDefault();const t=a.dataset.selectionValue;t&&this.controller&&this.controller.sendMessage(t)}})}disconnectedCallback(){var t;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(t=this._artifactResizeCleanup)||void 0===t||t.call(this),this._artifactResizeBound=!1}updated(t){if(super.updated(t),t.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}this.enableUrlSync&&this.handleHashChange(),this.syncActiveThreadToController()}if(t.has("activeThreadId")&&this.syncActiveThreadToController(),t.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!t.has("controller")){if(t.has("messages")||t.has("suggestions")||t.has("threads"))try{const t=this.controller.getState();this.handleControllerStateChange(t)}catch(t){}}t.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".messages");e&&(e.scrollTop=e.scrollHeight)})}setupControllerIntegration(){this.controller&&this.controllerUnsubscribes.push(this.controller.on("state:changed",this.handleControllerStateChange.bind(this)),this.controller.on("message:sent",this.handleControllerMessageSent.bind(this)),this.controller.on("message:received",this.handleControllerMessageReceived.bind(this)),this.controller.on("error",this.handleControllerError.bind(this)))}cleanupControllerIntegration(){if(this.controllerUnsubscribes.length)try{this.controllerUnsubscribes.forEach(t=>{try{t()}catch(t){}})}finally{this.controllerUnsubscribes=[]}}setupUrlSync(){this.enableUrlSync&&!this._hashChangeHandler&&(this._hashChangeHandler=this.handleHashChange.bind(this),window.addEventListener("hashchange",this._hashChangeHandler),this.handleHashChange())}teardownUrlSync(){this._hashChangeHandler&&(window.removeEventListener("hashchange",this._hashChangeHandler),this._hashChangeHandler=void 0)}handleHashChange(){const t=window.location.hash.match(/^#conversation\/(.+)$/);if(t){const e=decodeURIComponent(t[1]);e!==this.activeThreadId&&this.controller&&this.controller.switchThread(e)}}syncActiveThreadToController(){var t;if(!this.controller||!this.activeThreadId)return void(this._pendingThreadId=void 0);let e;try{e=this.controller.getState()}catch(t){e=null}if((null==e?void 0:e.currentThreadId)===this.activeThreadId)return void(this._pendingThreadId=void 0);if(null===(t=null==e?void 0:e.threads)||void 0===t?void 0:t.some(t=>t.id===this.activeThreadId)){this._pendingThreadId=void 0;try{this.controller.switchThread(this.activeThreadId)}catch(t){this._pendingThreadId=this.activeThreadId}}else this._pendingThreadId=this.activeThreadId}handleControllerStateChange(t){var e,i,n,o,s,r,a;if(t.messages&&(this.messages=t.messages),t.threads&&(this.threads=t.threads),t.suggestions&&t.suggestions.length>0&&(this.suggestions=t.suggestions),t.currentThreadId&&t.currentThreadId!==this.activeThreadId&&(this.activeThreadId=t.currentThreadId),this._pendingThreadId&&(null===(e=t.threads)||void 0===e?void 0:e.some(t=>t.id===this._pendingThreadId))){const t=this._pendingThreadId;this._pendingThreadId=void 0;try{null===(i=this.controller)||void 0===i||i.switchThread(t)}catch(e){this._pendingThreadId=t}}if(this.enableUrlSync&&t.currentThreadId){const e=`#conversation/${encodeURIComponent(t.currentThreadId)}`;window.location.hash!==e&&history.replaceState(null,"",e)}if(this.chatStarted=(null===(n=t.messages)||void 0===n?void 0:n.length)>0,this.isBotTyping=t.isTyping||!1,this.statusText=t.statusText,this.isQueryRunning=t.isProcessing||!1,t.uploadedFiles&&(this.uploadedFiles=t.uploadedFiles),this.enableArtifacts){const e=null===(o=t.messages)||void 0===o?void 0:o.some(t=>{var e,i;return(null===(i=null===(e=t.metadata)||void 0===e?void 0:e.artifactIds)||void 0===i?void 0:i.length)>0});e||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(s=t.messages)||void 0===s?void 0:s.length)){const e=[...t.messages].reverse().find(t=>"bot"===t.sender),i=null===(r=null==e?void 0:e.metadata)||void 0===r?void 0:r.artifactIds;if(null==i?void 0:i.length){const t=i[i.length-1];if((null===(a=this.selectedArtifact)||void 0===a?void 0:a.id)!==t){const e=this.getArtifactPlugin(),i=null==e?void 0:e.getArtifact(t);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(t){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(t){}handleControllerError(t){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",t.error)}get resolvedI18n(){var t,e,i,n,o,s,r,a,l;const d=this.i18n;return{input:Object.assign(Object.assign({},Et.input),null!==(t=null==d?void 0:d.input)&&void 0!==t?t:{}),send:Object.assign(Object.assign({},Et.send),null!==(e=null==d?void 0:d.send)&&void 0!==e?e:{}),audio:Object.assign(Object.assign({},Et.audio),null!==(i=null==d?void 0:d.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},Et.modules),null!==(n=null==d?void 0:d.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},Et.threads),null!==(o=null==d?void 0:d.threads)&&void 0!==o?o:{}),messages:Object.assign(Object.assign({},Et.messages),null!==(s=null==d?void 0:d.messages)&&void 0!==s?s:{}),urlModal:Object.assign(Object.assign({},Et.urlModal),null!==(r=null==d?void 0:d.urlModal)&&void 0!==r?r:{}),artifactPanel:Object.assign(Object.assign({},Et.artifactPanel),null!==(a=null==d?void 0:d.artifactPanel)&&void 0!==a?a:{}),loading:Object.assign(Object.assign({},Et.loading),null!==(l=null==d?void 0:d.loading)&&void 0!==l?l:{})}}render(){var t;const e=this.resolvedI18n,n={boxed:this.boxed,showMessages:this.showMessages,welcomeMessage:this.welcomeMessage,isPendingThread:!!this._pendingThreadId,messages:this.messages,isTyping:this.isBotTyping,loadingIndicator:this.loadingIndicator,loadingText:this.statusText||this.loadingText,chatStarted:this.chatStarted,suggestions:this.suggestions,inputBox:{placeholder:this.placeholder,disabled:this.disabled||this.isQueryRunning,currentInput:this.currentInput,uploadedFiles:this.uploadedFiles,isQueryRunning:this.isQueryRunning,showSendButton:this.showSendButton,enableFileUpload:this.resolvedActionButtons.some(t=>"attach"===(null==t?void 0:t.type)&&!1!==(null==t?void 0:t.enabled)),fileUploadItems:[{id:"upload-file",label:"Upload File",icon:"upload"},{id:"upload-url",label:"Upload from URL",icon:"link"}],enableModuleSelection:this.enableModuleSelection,moduleOptions:this.moduleSelectOptions,selectedModules:this.selectedModules,moduleSelectionLabel:this.moduleSelectionLabel,renderModuleDisplay:this.renderModuleSelectedDisplay.bind(this),showAudioButton:this.showAudioButton,audioRecording:this._audio.state,audioMode:this._audioMode,i18n:e},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId,i18n:e}:void 0,enableFileUpload:this.enableFileUpload,isDragging:this._isDragging,i18n:e,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(t=this.renderArtifactContent)&&void 0!==t?t:this.getPluginArtifactRenderer(),i18n:e}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName,i18n:e}:void 0},o={message:{onRetry:this.handleRetry.bind(this),onRetryKeydown:()=>{},onCopy:this.handleCopyMessage.bind(this),onCopyKeydown:()=>{},onFileClick:this.handleFilePreview.bind(this)},suggestion:{onClick:this.handleSuggestionClick.bind(this),onKeydown:()=>{}},inputBox:{onInput:this.handleContentEditableInput.bind(this),onKeydown:this.handleKeyDown.bind(this),onFocus:this.handleInputFocus.bind(this),onBlur:this.handleInputBlur.bind(this),onSend:this.handleSendMessage.bind(this),onStop:this.handleStopQuery.bind(this),onSendKeydown:()=>{},onFileDropdownClick:this.handleFileDropdownClick.bind(this),onModuleChange:this.handleModuleSelectionChange.bind(this),onFileRemove:this.handleFileRemove.bind(this),onFileClick:this.handleFilePreview.bind(this),onAudioStart:this.handleAudioStart.bind(this),onAudioCancel:this.handleAudioCancel.bind(this),onAudioSend:this.handleAudioSend.bind(this)},threadSidebar:this.showThreads?{onCreateNew:()=>{var t;null===(t=this.controller)||void 0===t||t.createThread("New Chat")},onSelectThread:t=>{var e;t!==this.activeThreadId&&(this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(t)}`),null===(e=this.controller)||void 0===e||e.switchThread(t),this.dispatchEvent(new CustomEvent("nr-thread-change",{detail:{threadId:t},bubbles:!0,composed:!0})))},onDeleteThread:t=>{var e;null===(e=this.controller)||void 0===e||e.deleteThread(t)},onBookmarkThread:t=>{var e;null===(e=this.controller)||void 0===e||e.bookmarkThread(t)},onRenameThread:(t,e)=>{var i;null===(i=this.controller)||void 0===i||i.renameThread(t,e),this._editingThreadId=void 0}}:void 0,fileUploadArea:{onDragEnter:this.handleDragEnter.bind(this),onDragOver:this.handleDragOver.bind(this),onDragLeave:this.handleDragLeave.bind(this),onDrop:this.handleDrop.bind(this)},urlModal:this.isUrlModalOpen?{onClose:this.handleUrlModalClose.bind(this),onUrlInputChange:this.handleUrlInputChange.bind(this),onUrlInputKeydown:this.handleUrlInputKeydown.bind(this),onConfirm:this.handleUrlConfirm.bind(this),onAttachFile:this.handleUrlAttachFile.bind(this)}:void 0,artifactPanel:this.enableArtifacts?{onClose:this.handleArtifactPanelClose.bind(this),onCopy:this.handleArtifactCopy.bind(this)}:void 0,onToggleThreadSidebar:this.showThreads?this.toggleThreadSidebar.bind(this):void 0};return i`
2758
2767
  <div
2759
2768
  class="chat-container ${a({"chat-container--with-threads":this.showThreads,"chat-container--disabled":this.disabled,"chat-container--focused":this.focused,"chat-container--boxed":this.boxed})}"
2760
2769
  dir=${this.isRTL?"rtl":"ltr"}
@@ -2777,18 +2786,18 @@ function(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(102
2777
2786
  <span class="module-display-multiple">
2778
2787
  ${t} ${this.resolvedI18n.modules.modulesSelectedSuffix}
2779
2788
  </span>
2780
- `}handleContentEditableInput(t){const e=t.target.textContent||"";this.currentInput=e,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:e}})}handleInputFocus(t){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:t}})}handleInputBlur(t){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:t}})}clearInput(){var t;this.currentInput="";const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&(e.textContent="")}focusInput(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&e.focus()}handleAudioStart(t){this._audioMode=t,this._audio.start()}handleAudioCancel(){this._audio.cancel()}handleAudioSend(){return Tt(this,void 0,void 0,function*(){var t;const e=yield this._audio.stop();if(!e)return;const i=this._audioMode;null===(t=this.onAudioRecorded)||void 0===t||t.call(this,e.blob,e.mimeType,e.duration,i),this.dispatchEvent(new CustomEvent("nr-chatbot-audio-recorded",{detail:{blob:e.blob,mimeType:e.mimeType,duration:e.duration,mode:i},bubbles:!0,composed:!0}))})}handleKeyDown(t){"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.handleSendMessage())}handleSendMessage(){if(!this.currentInput.trim()||this.disabled)return;if(!this.controller)return void console.warn("nr-chatbot: No controller is attached; message will not be sent.");const t=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:t,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var t;try{null===(t=this.controller)||void 0===t||t.stop()}catch(t){console.warn("nr-chatbot: stop failed",t)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(t){t.text&&(this.currentInput=t.text,this.handleSendMessage())}handleCopyMessage(t){const e=t.text;if(!e)return;const i=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:t.id}})};navigator.clipboard?navigator.clipboard.writeText(e).then(i).catch(()=>{this.copyViaFallback(e,i)}):this.copyViaFallback(e,i)}copyViaFallback(t,e){const i=document.createElement("textarea");i.value=t,i.style.position="fixed",i.style.left="-9999px",i.style.top="-9999px",document.body.appendChild(i),i.focus(),i.select();try{document.execCommand("copy"),e()}catch(t){}i.remove()}handleSuggestionClick(t){this.currentInput=t.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:t}})}handleModuleSelectionChange(t){const e=t.detail.value;this.selectedModules=e,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:e}})}handleFileDropdownClick(t){const e=t.detail.item.id;"upload-file"===e?this.openFileDialog():"upload-url"===e&&this.openUrlModal()}openFileDialog(){const t=document.createElement("input");t.type="file",t.multiple=!0,t.accept="image/*,application/pdf,text/*,video/*,audio/*",t.addEventListener("change",t=>Tt(this,void 0,void 0,function*(){var e;const i=t.target;if(i.files&&i.files.length>0){const t=Array.from(i.files);yield null===(e=this.controller)||void 0===e?void 0:e.uploadFiles(t)}})),t.click()}openUrlModal(){this.isUrlModalOpen=!0,this.urlInput="",this.urlModalError="",this.selectedUrlFileName=""}handleUrlModalClose(){this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName=""}handleUrlInputChange(t){const e=t.target;this.urlInput=e.value,this.urlModalError=""}handleUrlInputKeydown(t){"Enter"===t.key&&(t.preventDefault(),this.handleUrlAttachFile())}handleUrlConfirm(){this.handleUrlModalClose()}handleUrlAttachFile(){return Tt(this,void 0,void 0,function*(){if(this.urlInput.trim()){this.isUrlLoading=!0,this.urlModalError="";try{const t=yield fetch(this.urlInput);if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const e=yield t.blob(),i=this.urlInput.split("/").pop()||"downloaded-file",n=new File([e],i,{type:e.type});this.selectedUrlFileName=i,this.controller&&(yield this.controller.uploadFiles([n])),this.isUrlLoading=!1,setTimeout(()=>{this.handleUrlModalClose()},1e3)}catch(t){this.isUrlLoading=!1,this.urlModalError=t instanceof Error?t.message:"Failed to load file from URL"}}else this.urlModalError="Please enter a URL"})}handleFileRemove(t){var e;null===(e=this.controller)||void 0===e||e.removeFile(t)}dragHasFiles(t){var e;const i=null===(e=t.dataTransfer)||void 0===e?void 0:e.types;if(!i)return!1;for(let t=0;t<i.length;t++)if("Files"===i[t])return!0;return!1}handleDragEnter(t){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(t)&&(t.preventDefault(),this._dragDepth++,this._isDragging=!0)}handleDragOver(t){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(t)&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="copy"))}handleDragLeave(t){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(t)&&(t.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),0===this._dragDepth&&(this._isDragging=!1))}handleDrop(t){return Tt(this,void 0,void 0,function*(){var e,i;if(!this.enableFileUpload||this.disabled)return;t.preventDefault(),this._dragDepth=0,this._isDragging=!1;const n=null===(e=t.dataTransfer)||void 0===e?void 0:e.files;n&&0!==n.length&&(yield null===(i=this.controller)||void 0===i?void 0:i.uploadFiles(Array.from(n)))})}handleFilePreview(t){this.previewFile=t,this.isFilePreviewModalOpen=!0}handleArtifactClick(t){if(!this.enableArtifacts||!this.controller)return;const e=this.getArtifactPlugin();if(!e)return;const i=e.getArtifact(t);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}handleArtifactPanelClose(){this.isArtifactPanelOpen=!1,this.selectedArtifact=null}updateArtifactPanelResize(){var t,e,i;const n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel__resize-handle"),o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".artifact-panel");if(!n||!o)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let s=!1,r=0,a=0;const l=t=>{if(!s)return;const e=t.clientX-r,i=o.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(o).minWidth,10)||300,d=Math.max(l,Math.min(a-e,n));o.style.width=`${d}px`},d=()=>{s&&(s=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",d))},c=t=>{t.preventDefault(),s=!0,r=t.clientX,a=o.getBoundingClientRect().width,n.classList.add("artifact-panel__resize-handle--active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",l),document.addEventListener("mouseup",d)};n.addEventListener("mousedown",c),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",c),d()}}handleArtifactCopy(t){const e=t.content;e&&(navigator.clipboard?navigator.clipboard.writeText(e).catch(()=>{this.copyViaFallback(e,()=>{})}):this.copyViaFallback(e,()=>{}))}getArtifactPlugin(){var t;try{const e=null===(t=this.controller)||void 0===t?void 0:t.plugins;return e&&"function"==typeof e.get?e.get("artifact"):void 0}catch(t){return}}getPluginArtifactRenderer(){var t;try{const e=null===(t=this.controller)||void 0===t?void 0:t.plugins;if(!e||"function"!=typeof e.values)return;for(const t of e.values())if("function"==typeof t.renderArtifactContent)return e=>{const n=t.renderArtifactContent(e);if(n)return i`${l(n)}`};return}catch(t){return}}handleFilePreviewModalClose(){this.isFilePreviewModalOpen=!1,this.previewFile=null}addMessage(t){var e;const i=Object.assign({id:t.id||`msg-${Date.now()}`,sender:t.sender||q.User,text:t.text||"",timestamp:t.timestamp||(new Date).toISOString()},t);return null===(e=this.controller)||void 0===e||e.addMessage(i),this.chatStarted=!0,i}clearMessages(){this.messages=[],this.chatStarted=!1}};Ct.useShadowDom=!0,Ct.styles=L,Mt([o({type:Array})],Ct.prototype,"messages",void 0),Mt([o({type:String})],Ct.prototype,"currentInput",void 0),Mt([o({type:Boolean})],Ct.prototype,"isBotTyping",void 0),Mt([o({type:Boolean})],Ct.prototype,"isQueryRunning",void 0),Mt([o({type:Array})],Ct.prototype,"suggestions",void 0),Mt([o({type:Boolean})],Ct.prototype,"chatStarted",void 0),Mt([o({type:Boolean})],Ct.prototype,"isRTL",void 0),Mt([o({type:String})],Ct.prototype,"size",void 0),Mt([o({type:String})],Ct.prototype,"variant",void 0),Mt([o({type:String})],Ct.prototype,"loadingIndicator",void 0),Mt([o({type:String})],Ct.prototype,"loadingText",void 0),Mt([o({type:Boolean})],Ct.prototype,"disabled",void 0),Mt([o({type:String})],Ct.prototype,"placeholder",void 0),Mt([o({type:Object})],Ct.prototype,"i18n",void 0),Mt([o({type:Boolean})],Ct.prototype,"showSendButton",void 0),Mt([o({type:Boolean})],Ct.prototype,"autoScroll",void 0),Mt([o({type:Boolean})],Ct.prototype,"showThreads",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableThreadCreation",void 0),Mt([o({type:Array})],Ct.prototype,"threads",void 0),Mt([o({type:String})],Ct.prototype,"activeThreadId",void 0),Mt([o({type:String})],Ct.prototype,"mode",void 0),Mt([o({type:Boolean,reflect:!0})],Ct.prototype,"boxed",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableUrlSync",void 0),Mt([o({type:Boolean})],Ct.prototype,"showMessages",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableFileUpload",void 0),Mt([o({type:Array})],Ct.prototype,"uploadedFiles",void 0),Mt([o({type:Array})],Ct.prototype,"actionButtons",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableModuleSelection",void 0),Mt([o({type:Array})],Ct.prototype,"modules",void 0),Mt([o({type:Array})],Ct.prototype,"selectedModules",void 0),Mt([o({type:String})],Ct.prototype,"moduleSelectionLabel",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableArtifacts",void 0),Mt([o({type:Boolean,attribute:"show-audio-button"})],Ct.prototype,"showAudioButton",void 0),Mt([o({type:Function})],Ct.prototype,"onAudioRecorded",void 0),Mt([o({type:Function})],Ct.prototype,"renderArtifactContent",void 0),Mt([o({type:Object})],Ct.prototype,"controller",void 0),Mt([s()],Ct.prototype,"statusText",void 0),Mt([s()],Ct.prototype,"focused",void 0),Mt([s()],Ct.prototype,"isArtifactPanelOpen",void 0),Mt([s()],Ct.prototype,"selectedArtifact",void 0),Mt([s()],Ct.prototype,"isThreadSidebarOpen",void 0),Mt([s()],Ct.prototype,"_editingThreadId",void 0),Mt([s()],Ct.prototype,"isUrlModalOpen",void 0),Mt([s()],Ct.prototype,"urlInput",void 0),Mt([s()],Ct.prototype,"urlModalError",void 0),Mt([s()],Ct.prototype,"isUrlLoading",void 0),Mt([s()],Ct.prototype,"selectedUrlFileName",void 0),Mt([s()],Ct.prototype,"isFilePreviewModalOpen",void 0),Mt([s()],Ct.prototype,"previewFile",void 0),Mt([s()],Ct.prototype,"_isDragging",void 0),Ct=Mt([(t,e)=>(t.addInitializer(b),t),r("nr-chatbot")],Ct);
2789
+ `}handleContentEditableInput(t){const e=t.target.textContent||"";this.currentInput=e,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:e}})}handleInputFocus(t){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:t}})}handleInputBlur(t){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:t}})}clearInput(){var t;this.currentInput="";const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&(e.textContent="")}focusInput(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".input-box__input");e&&e.focus()}handleAudioStart(t){this._audioMode=t,this._audio.start()}handleAudioCancel(){this._audio.cancel()}handleAudioSend(){return Tt(this,void 0,void 0,function*(){var t;const e=yield this._audio.stop();if(!e)return;const i=this._audioMode;null===(t=this.onAudioRecorded)||void 0===t||t.call(this,e.blob,e.mimeType,e.duration,i),this.dispatchEvent(new CustomEvent("nr-chatbot-audio-recorded",{detail:{blob:e.blob,mimeType:e.mimeType,duration:e.duration,mode:i},bubbles:!0,composed:!0}))})}handleKeyDown(t){"Enter"!==t.key||t.shiftKey||(t.preventDefault(),this.handleSendMessage())}handleSendMessage(){if(!this.currentInput.trim()||this.disabled)return;if(!this.controller)return void console.warn("nr-chatbot: No controller is attached; message will not be sent.");const t=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:t,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var t;try{null===(t=this.controller)||void 0===t||t.stop()}catch(t){console.warn("nr-chatbot: stop failed",t)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(t){t.text&&(this.currentInput=t.text,this.handleSendMessage())}handleCopyMessage(t){const e=t.text;if(!e)return;const i=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:t.id}})};navigator.clipboard?navigator.clipboard.writeText(e).then(i).catch(()=>{this.copyViaFallback(e,i)}):this.copyViaFallback(e,i)}copyViaFallback(t,e){const i=document.createElement("textarea");i.value=t,i.style.position="fixed",i.style.left="-9999px",i.style.top="-9999px",document.body.appendChild(i),i.focus(),i.select();try{document.execCommand("copy"),e()}catch(t){}i.remove()}handleSuggestionClick(t){this.currentInput=t.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:t}})}handleModuleSelectionChange(t){const e=t.detail.value;this.selectedModules=e,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:e}})}handleFileDropdownClick(t){const e=t.detail.item.id;"upload-file"===e?this.openFileDialog():"upload-url"===e&&this.openUrlModal()}openFileDialog(){const t=document.createElement("input");t.type="file",t.multiple=!0,t.accept="image/*,application/pdf,text/*,video/*,audio/*",t.addEventListener("change",t=>Tt(this,void 0,void 0,function*(){var e;const i=t.target;if(i.files&&i.files.length>0){const t=Array.from(i.files);yield null===(e=this.controller)||void 0===e?void 0:e.uploadFiles(t)}})),t.click()}openUrlModal(){this.isUrlModalOpen=!0,this.urlInput="",this.urlModalError="",this.selectedUrlFileName=""}handleUrlModalClose(){this.isUrlModalOpen=!1,this.urlInput="",this.urlModalError="",this.isUrlLoading=!1,this.selectedUrlFileName=""}handleUrlInputChange(t){const e=t.target;this.urlInput=e.value,this.urlModalError=""}handleUrlInputKeydown(t){"Enter"===t.key&&(t.preventDefault(),this.handleUrlAttachFile())}handleUrlConfirm(){this.handleUrlModalClose()}handleUrlAttachFile(){return Tt(this,void 0,void 0,function*(){if(this.urlInput.trim()){this.isUrlLoading=!0,this.urlModalError="";try{const t=yield fetch(this.urlInput);if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const e=yield t.blob(),i=this.urlInput.split("/").pop()||"downloaded-file",n=new File([e],i,{type:e.type});this.selectedUrlFileName=i,this.controller&&(yield this.controller.uploadFiles([n])),this.isUrlLoading=!1,setTimeout(()=>{this.handleUrlModalClose()},1e3)}catch(t){this.isUrlLoading=!1,this.urlModalError=t instanceof Error?t.message:"Failed to load file from URL"}}else this.urlModalError="Please enter a URL"})}handleFileRemove(t){var e;null===(e=this.controller)||void 0===e||e.removeFile(t)}dragHasFiles(t){var e;const i=null===(e=t.dataTransfer)||void 0===e?void 0:e.types;if(!i)return!1;for(let t=0;t<i.length;t++)if("Files"===i[t])return!0;return!1}handleDragEnter(t){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(t)&&(t.preventDefault(),this._dragDepth++,this._isDragging=!0)}handleDragOver(t){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(t)&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="copy"))}handleDragLeave(t){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(t)&&(t.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),0===this._dragDepth&&(this._isDragging=!1))}handleDrop(t){return Tt(this,void 0,void 0,function*(){var e,i;if(!this.enableFileUpload||this.disabled)return;t.preventDefault(),this._dragDepth=0,this._isDragging=!1;const n=null===(e=t.dataTransfer)||void 0===e?void 0:e.files;n&&0!==n.length&&(yield null===(i=this.controller)||void 0===i?void 0:i.uploadFiles(Array.from(n)))})}handleFilePreview(t){this.previewFile=t,this.isFilePreviewModalOpen=!0}handleArtifactClick(t){if(!this.enableArtifacts||!this.controller)return;const e=this.getArtifactPlugin();if(!e)return;const i=e.getArtifact(t);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}handleArtifactPanelClose(){this.isArtifactPanelOpen=!1,this.selectedArtifact=null}updateArtifactPanelResize(){var t,e,i;const n=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel__resize-handle"),o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".artifact-panel");if(!n||!o)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let s=!1,r=0,a=0;const l=t=>{if(!s)return;const e=t.clientX-r,i=o.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(o).minWidth,10)||300,d=Math.max(l,Math.min(a-e,n));o.style.width=`${d}px`},d=()=>{s&&(s=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",d))},c=t=>{t.preventDefault(),s=!0,r=t.clientX,a=o.getBoundingClientRect().width,n.classList.add("artifact-panel__resize-handle--active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",l),document.addEventListener("mouseup",d)};n.addEventListener("mousedown",c),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",c),d()}}handleArtifactCopy(t){const e=t.content;e&&(navigator.clipboard?navigator.clipboard.writeText(e).catch(()=>{this.copyViaFallback(e,()=>{})}):this.copyViaFallback(e,()=>{}))}getArtifactPlugin(){var t;try{const e=null===(t=this.controller)||void 0===t?void 0:t.plugins;return e&&"function"==typeof e.get?e.get("artifact"):void 0}catch(t){return}}getPluginArtifactRenderer(){var t;try{const e=null===(t=this.controller)||void 0===t?void 0:t.plugins;if(!e||"function"!=typeof e.values)return;for(const t of e.values())if("function"==typeof t.renderArtifactContent)return e=>{const n=t.renderArtifactContent(e);if(n)return i`${l(n)}`};return}catch(t){return}}handleFilePreviewModalClose(){this.isFilePreviewModalOpen=!1,this.previewFile=null}addMessage(t){var e;const i=Object.assign({id:t.id||`msg-${Date.now()}`,sender:t.sender||q.User,text:t.text||"",timestamp:t.timestamp||(new Date).toISOString()},t);return null===(e=this.controller)||void 0===e||e.addMessage(i),this.chatStarted=!0,i}clearMessages(){this.messages=[],this.chatStarted=!1}};Ct.useShadowDom=!0,Ct.styles=L,Mt([o({type:Array})],Ct.prototype,"messages",void 0),Mt([o({type:String})],Ct.prototype,"currentInput",void 0),Mt([o({type:Boolean})],Ct.prototype,"isBotTyping",void 0),Mt([o({type:Boolean})],Ct.prototype,"isQueryRunning",void 0),Mt([o({type:Array})],Ct.prototype,"suggestions",void 0),Mt([o({type:Boolean})],Ct.prototype,"chatStarted",void 0),Mt([o({type:Boolean})],Ct.prototype,"isRTL",void 0),Mt([o({type:String})],Ct.prototype,"size",void 0),Mt([o({type:String})],Ct.prototype,"variant",void 0),Mt([o({type:String})],Ct.prototype,"loadingIndicator",void 0),Mt([o({type:String})],Ct.prototype,"loadingText",void 0),Mt([o({type:Boolean})],Ct.prototype,"disabled",void 0),Mt([o({type:String})],Ct.prototype,"placeholder",void 0),Mt([o({type:Object})],Ct.prototype,"i18n",void 0),Mt([o({type:Boolean})],Ct.prototype,"showSendButton",void 0),Mt([o({type:Boolean})],Ct.prototype,"autoScroll",void 0),Mt([o({type:Boolean})],Ct.prototype,"showThreads",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableThreadCreation",void 0),Mt([o({type:Array})],Ct.prototype,"threads",void 0),Mt([o({type:String,attribute:"active-thread-id"})],Ct.prototype,"activeThreadId",void 0),Mt([o({type:String})],Ct.prototype,"mode",void 0),Mt([o({type:Boolean,reflect:!0})],Ct.prototype,"boxed",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableUrlSync",void 0),Mt([o({type:Boolean})],Ct.prototype,"showMessages",void 0),Mt([o({type:String,attribute:"welcome-message"})],Ct.prototype,"welcomeMessage",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableFileUpload",void 0),Mt([o({type:Array})],Ct.prototype,"uploadedFiles",void 0),Mt([o({type:Array})],Ct.prototype,"actionButtons",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableModuleSelection",void 0),Mt([o({type:Array})],Ct.prototype,"modules",void 0),Mt([o({type:Array})],Ct.prototype,"selectedModules",void 0),Mt([o({type:String})],Ct.prototype,"moduleSelectionLabel",void 0),Mt([o({type:Boolean})],Ct.prototype,"enableArtifacts",void 0),Mt([o({type:Boolean,attribute:"show-audio-button"})],Ct.prototype,"showAudioButton",void 0),Mt([o({type:Function})],Ct.prototype,"onAudioRecorded",void 0),Mt([o({type:Function})],Ct.prototype,"renderArtifactContent",void 0),Mt([o({type:Object})],Ct.prototype,"controller",void 0),Mt([s()],Ct.prototype,"statusText",void 0),Mt([s()],Ct.prototype,"focused",void 0),Mt([s()],Ct.prototype,"isArtifactPanelOpen",void 0),Mt([s()],Ct.prototype,"selectedArtifact",void 0),Mt([s()],Ct.prototype,"isThreadSidebarOpen",void 0),Mt([s()],Ct.prototype,"_editingThreadId",void 0),Mt([s()],Ct.prototype,"isUrlModalOpen",void 0),Mt([s()],Ct.prototype,"urlInput",void 0),Mt([s()],Ct.prototype,"urlModalError",void 0),Mt([s()],Ct.prototype,"isUrlLoading",void 0),Mt([s()],Ct.prototype,"selectedUrlFileName",void 0),Mt([s()],Ct.prototype,"isFilePreviewModalOpen",void 0),Mt([s()],Ct.prototype,"previewFile",void 0),Mt([s()],Ct.prototype,"_isDragging",void 0),Mt([s()],Ct.prototype,"_pendingThreadId",void 0),Ct=Mt([(t,e)=>(t.addInitializer(b),t),r("nr-chatbot")],Ct);
2781
2790
  /**
2782
2791
  * @license
2783
2792
  * Copyright 2023 Nuraly, Laabidi Aymen
2784
2793
  * SPDX-License-Identifier: MIT
2785
2794
  */
2786
- class Ot{constructor(){this.listeners=new Map}on(t,e){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e),()=>{var i,n;null===(i=this.listeners.get(t))||void 0===i||i.delete(e),0===(null===(n=this.listeners.get(t))||void 0===n?void 0:n.size)&&this.listeners.delete(t)}}once(t,e){const i=(...n)=>{e(...n),this.off(t,i)};this.on(t,i)}off(t,e){var i;null===(i=this.listeners.get(t))||void 0===i||i.delete(e)}emit(t,e){const i=this.listeners.get(t);i&&i.forEach(i=>{try{i(e)}catch(e){console.error(`Error in event handler for "${t}":`,e)}})}removeAllListeners(t){t?this.listeners.delete(t):this.listeners.clear()}listenerCount(t){var e;return(null===(e=this.listeners.get(t))||void 0===e?void 0:e.size)||0}eventNames(){return Array.from(this.listeners.keys())}}
2795
+ class zt{constructor(){this.listeners=new Map}on(t,e){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(e),()=>{var i,n;null===(i=this.listeners.get(t))||void 0===i||i.delete(e),0===(null===(n=this.listeners.get(t))||void 0===n?void 0:n.size)&&this.listeners.delete(t)}}once(t,e){const i=(...n)=>{e(...n),this.off(t,i)};this.on(t,i)}off(t,e){var i;null===(i=this.listeners.get(t))||void 0===i||i.delete(e)}emit(t,e){const i=this.listeners.get(t);i&&i.forEach(i=>{try{i(e)}catch(e){console.error(`Error in event handler for "${t}":`,e)}})}removeAllListeners(t){t?this.listeners.delete(t):this.listeners.clear()}listenerCount(t){var e;return(null===(e=this.listeners.get(t))||void 0===e?void 0:e.size)||0}eventNames(){return Array.from(this.listeners.keys())}}
2787
2796
  /**
2788
2797
  * @license
2789
2798
  * Copyright 2023 Nuraly, Laabidi Aymen
2790
2799
  * SPDX-License-Identifier: MIT
2791
- */class zt extends Error{constructor(t){super(t.join(", ")),this.errors=t,this.name="ValidationError"}}
2800
+ */class Ot extends Error{constructor(t){super(t.join(", ")),this.errors=t,this.name="ValidationError"}}
2792
2801
  /**
2793
2802
  * @license
2794
2803
  * Copyright 2023 Nuraly, Laabidi Aymen
@@ -2844,7 +2853,7 @@ class Ot{constructor(){this.listeners=new Map}on(t,e){return this.listeners.has(
2844
2853
  * Copyright 2023 Nuraly, Laabidi Aymen
2845
2854
  * SPDX-License-Identifier: MIT
2846
2855
  */
2847
- var Qt=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class Xt{constructor(t={}){this.plugins=new Map,this.config=t,this.ui=t.ui||{},this.eventBus=new Ot,this.pluginService=new Gt,this.plugins=this.pluginService.getPluginsMap(),t.plugins&&t.plugins.forEach(t=>this.pluginService.registerPlugin(t,this));const e=this.initializeState(t);if(this.stateHandler=new It(e,this.eventBus,this.ui,this.plugins,this.config),this.messageHandler=new jt(this.stateHandler,this.eventBus,this.plugins),this.threadHandler=new At(this.stateHandler,this.eventBus,this.ui,this.config,t.provider),this.fileHandler=new Ft(this.stateHandler,this.eventBus),this.moduleHandler=new Dt(this.stateHandler,this.eventBus),this.suggestionHandler=new Bt(this.stateHandler),this.providerService=new Ut(t.provider,this.stateHandler,this.messageHandler,this.fileHandler,this.eventBus,this.ui,this.plugins),this.validationService=new Ht(this.config),this.storageService=new qt(t.storage,this.stateHandler,this.config),t.provider){const e=t.provider;queueMicrotask(()=>{this.initializeProvider(e)})}this.setupLifecycleHooks()}initializeProvider(t){return Qt(this,void 0,void 0,function*(){try{t.isConnected()||(yield t.connect({})),yield this.autoLoadConversations(t)}catch(t){this.logError("Failed to connect provider:",t)}})}initializeState(t){const e=t.initialMessages?t.initialMessages.map(t=>this.processMessageThroughPlugins(t)):[];return{messages:e,threads:t.initialThreads||[],modules:t.enableModules?[]:void 0,selectedModules:[],uploadedFiles:[],suggestions:t.initialSuggestions||[],isTyping:!1,isProcessing:!1,currentThreadId:void 0,metadata:t.metadata||{}}}processMessageThroughPlugins(t){if(!t.text||"string"!=typeof t.text)return t;const e=Array.from(this.plugins.values()).filter(t=>Array.isArray(t.htmlTags)&&t.htmlTags.length>0);if(0===e.length)return t;let i=t.text,n=!1;for(const t of e){const e=t.htmlTags;for(const o of e){const e=o.open,s=o.close;let r=0;for(;;){const a=i.indexOf(e,r);if(-1===a)break;const l=a+e.length,d=i.indexOf(s,l);if(-1===d){r=l;continue}const c=i.substring(l,d);let h="";if("function"==typeof t.renderHtmlBlock)try{h=t.renderHtmlBlock(o.name,c)}catch(e){console.error(`[ChatbotCore] Error rendering HTML block for plugin ${t.id}:`,e)}h?(i=i.substring(0,a)+h+i.substring(d+s.length),n=!0,r=a+h.length):r=d+s.length}}}return n?Object.assign(Object.assign({},t),{text:i,metadata:Object.assign(Object.assign({},t.metadata),{renderAsHtml:!0})}):t}processRestoredMessagesForPlugins(){const t=this.stateHandler.getState();if(t.messages&&0!==t.messages.length)for(const e of t.messages)"bot"===e.sender&&this.plugins.forEach(t=>{if(t.onMessageReceived)try{t.onMessageReceived(e)}catch(t){}})}setupLifecycleHooks(){this.onBeforeInit(),this.onReady().catch(t=>{this.logError("Error during initialization:",t)})}onBeforeInit(){this.log("Initializing chatbot controller...")}onReady(){return Qt(this,void 0,void 0,function*(){this.log("Chatbot controller ready");try{const t=this.stateHandler.getState(),e=t.messages&&t.messages.length>0?t.messages[0]:void 0;e&&"bot"===e.sender&&e.introduction&&Array.isArray(e.suggestions)&&e.suggestions.length>0&&this.suggestionHandler.setSuggestions(e.suggestions)}catch(t){this.logError("Error initializing suggestions from initial messages:",t)}this.processRestoredMessagesForPlugins(),this.ui.onStateChange&&this.ui.onStateChange(this.getState()),this.emit("ready",this.stateHandler.getState())})}onDestroy(){this.log("Destroying chatbot controller..."),this.storageService.stopAutoSave(),this.pluginService.clearPlugins(),this.eventBus.removeAllListeners()}updateState(t){this.stateHandler.updateState(t)}sendMessage(t){return Qt(this,arguments,void 0,function*(t,e={}){this.log("Sending message:",t);try{const i=this.stateHandler.getState();this.config.enableThreads&&!i.currentThreadId&&(yield this.threadHandler.createThread("New Chat"));const n=yield this.beforeMessageSent(t,e);if(!e.skipValidation){const t=yield this.validationService.validateMessage(n);if(!t.isValid){const e=new zt(t.errors);throw this.handleValidationError(e),e}}const o=this.messageHandler.createUserMessage(n,e.metadata);e.files&&(o.files=e.files),this.messageHandler.addMessage(o);const s=this.stateHandler.getState();return(e.threadId||s.currentThreadId)&&this.threadHandler.updateThreadMessages(e.threadId||s.currentThreadId),yield this.afterMessageSent(o),this.providerService.processMessage(o).catch(t=>{this.logError("Error processing with provider:",t)}),o}catch(t){throw this.handleError(t),t}})}stop(){this.providerService.stopCurrentProcessing()}addMessage(t){const e=this.messageHandler.createMessage(t),i="bot"===e.sender?this.processMessageThroughPlugins(e):e;return this.messageHandler.addMessage(i),i}updateMessage(t,e){this.messageHandler.updateMessage(t,e)}deleteMessage(t){this.messageHandler.deleteMessage(t)}clearMessages(){this.updateState({messages:[]})}getMessages(){return this.stateHandler.getState().messages}uploadFiles(t){return Qt(this,void 0,void 0,function*(){if(!this.config.enableFileUpload)throw new Error("File upload is not enabled");let e=t;if(!e&&this.ui.openFileDialog&&(e=yield this.ui.openFileDialog()),!e||0===e.length)return[];const i=[];for(const t of e)try{const e=yield this.validationService.validateFile(t,{maxFileSize:this.config.maxFileSize,allowedTypes:this.config.allowedFileTypes});if(!e.isValid){this.ui.showNotification&&this.ui.showNotification(e.errors[0]||"File validation failed","error");continue}const n=yield this.fileHandler.createChatbotFile(t);this.fileHandler.addFile(n);try{const e=yield this.providerService.uploadFileToProvider(t),o=Object.assign({isUploading:!1,uploadProgress:100},e||{});this.fileHandler.updateFile(n.id,o),Object.assign(n,o),i.push(n),this.ui.showFilePreview&&this.ui.showFilePreview(n)}catch(t){throw this.fileHandler.removeFile(n.id),t}}catch(e){this.logError("Error uploading file:",e),this.ui.showNotification&&this.ui.showNotification(`Failed to upload ${t.name}`,"error")}return i})}removeFile(t){this.fileHandler.removeFile(t)}clearFiles(){this.fileHandler.clearFiles()}getUploadedFiles(){return this.stateHandler.getState().uploadedFiles}createThread(t){return Qt(this,void 0,void 0,function*(){return yield this.threadHandler.createThread(t)})}switchThread(t){this.threadHandler.switchThread(t),this.processRestoredMessagesForPlugins()}deleteThread(t){this.threadHandler.deleteThread(t)}renameThread(t,e){this.threadHandler.renameThread(t,e)}bookmarkThread(t){this.threadHandler.bookmarkThread(t)}getCurrentThread(){const t=this.stateHandler.getState();return t.threads.find(e=>e.id===t.currentThreadId)}getThreads(){return this.stateHandler.getState().threads}setModules(t){this.moduleHandler.setModules(t)}selectModules(t){this.moduleHandler.selectModules(t)}toggleModule(t){this.moduleHandler.toggleModule(t)}getSelectedModules(){return this.moduleHandler.getSelectedModules()}setSuggestions(t){this.suggestionHandler.setSuggestions(t)}clearSuggestions(){this.suggestionHandler.clearSuggestions()}beforeMessageSent(t,e){return Qt(this,void 0,void 0,function*(){let e=t;for(const t of this.plugins.values())t.beforeSend&&(e=yield t.beforeSend(e));return e})}afterMessageSent(t){return Qt(this,void 0,void 0,function*(){this.log("Message sent:",t)})}beforeProviderCall(t){return Qt(this,void 0,void 0,function*(){this.log("Calling provider for message:",t.id)})}afterProviderCall(){return Qt(this,void 0,void 0,function*(){this.log("Provider call completed")})}handleProviderError(t){return Qt(this,void 0,void 0,function*(){this.logError("Provider error:",t);const e=this.messageHandler.createMessage({sender:q.Bot,text:"Sorry, there was an error processing your request.",state:Y.Error,timestamp:(new Date).toISOString()});this.messageHandler.addMessage(e),this.ui.showNotification&&this.ui.showNotification("Failed to process message","error"),this.emit("provider:error",t),yield this.pluginService.executeHook("onError",t)})}handleValidationError(t){this.logError("Validation error:",t),this.ui.showNotification&&this.ui.showNotification(t.errors[0],"error"),this.emit("validation:error",t)}handleError(t){this.logError("Error:",t),this.emit("error",t),this.plugins.forEach(e=>{e.onError&&e.onError(t)})}registerPlugin(t){this.pluginService.registerPlugin(t,this)}unregisterPlugin(t){this.pluginService.unregisterPlugin(t)}getPlugin(t){return this.pluginService.getPlugin(t)}setProvider(t){this.providerService.setProvider(t),t.isConnected()?(this.autoLoadConversations(t).catch(t=>{this.logError("Failed to auto-load conversations:",t)}),this.emit("provider:connected",t.id)):t.connect({}).then(()=>Qt(this,void 0,void 0,function*(){yield this.autoLoadConversations(t),this.emit("provider:connected",t.id)})).catch(t=>{this.logError("Failed to connect provider:",t)})}setStorage(t){this.storageService.setStorage(t)}saveToStorage(){return Qt(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.saveState(t)})}loadFromStorage(){return Qt(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.loadState(t);const e=this.stateHandler.getState();if(e.messages&&e.messages.length>0){const t=e.messages.map(t=>this.processMessageThroughPlugins(t));this.stateHandler.updateState({messages:t}),this.processRestoredMessagesForPlugins()}})}on(t,e){return this.eventBus.on(t,e)}emit(t,e){this.eventBus.emit(t,e)}getState(){return this.stateHandler.getState()}setState(t){t.messages&&Array.isArray(t.messages)&&(t.messages=t.messages.map(t=>this.processMessageThroughPlugins(t))),t.threads&&Array.isArray(t.threads)&&(t.threads=t.threads.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}))),this.updateState(t),t.messages&&this.processRestoredMessagesForPlugins()}loadConversations(t){const e=t.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}));this.updateState({threads:e,currentThreadId:e.length>0?e[0].id:void 0,messages:e.length>0?e[0].messages:[]}),this.processRestoredMessagesForPlugins()}autoLoadConversations(t){return Qt(this,void 0,void 0,function*(){if(t&&"function"==typeof t.loadConversations)try{this.log("Auto-loading conversations from provider...");const e=yield t.loadConversations();if(Array.isArray(e)&&e.length>0){this.log(`Loaded ${e.length} conversation summaries`);const i=[];if("function"==typeof t.loadConversation)for(const n of e)try{const e=yield t.loadConversation(n.id);if(e){const t={id:e.id,title:e.title,messages:e.messages||[],createdAt:e.createdAt,updatedAt:e.updatedAt};i.push(t)}}catch(t){this.logError(`Failed to load conversation ${n.id}:`,t)}else for(const t of e){const e={id:t.id,title:t.title,messages:[],createdAt:t.createdAt,updatedAt:t.updatedAt};i.push(e)}i.length>0&&(this.log(`Successfully loaded ${i.length} conversations`),this.loadConversations(i))}else this.log("No conversations to load from provider")}catch(t){this.logError("Failed to auto-load conversations from provider:",t)}})}setUICallbacks(t){this.ui=Object.assign(Object.assign({},this.ui),t)}getConfig(){return Object.freeze(Object.assign({},this.config))}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setTyping(t){this.updateState({isTyping:t}),this.emit(t?"typing:start":"typing:end")}setStatusText(t){this.updateState({statusText:t})}clearStatusText(){this.updateState({statusText:void 0})}getContext(){const t=this.stateHandler.getState();return{messages:t.messages,currentThread:this.getCurrentThread(),selectedModules:t.selectedModules,metadata:t.metadata,uploadedFiles:t.uploadedFiles}}destroy(){this.onDestroy()}generateId(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatFileSize(t){return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(2)} KB`:`${(t/1048576).toFixed(2)} MB`}log(...t){this.config.debug&&console.log("[ChatbotCore]",...t)}logError(...t){console.error("[ChatbotCore]",...t)}}
2856
+ var Qt=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class Xt{constructor(t={}){this.plugins=new Map,this.config=t,this.ui=t.ui||{},this.eventBus=new zt,this.pluginService=new Gt,this.plugins=this.pluginService.getPluginsMap(),t.plugins&&t.plugins.forEach(t=>this.pluginService.registerPlugin(t,this));const e=this.initializeState(t);if(this.stateHandler=new It(e,this.eventBus,this.ui,this.plugins,this.config),this.messageHandler=new jt(this.stateHandler,this.eventBus,this.plugins),this.threadHandler=new At(this.stateHandler,this.eventBus,this.ui,this.config,t.provider),this.fileHandler=new Ft(this.stateHandler,this.eventBus),this.moduleHandler=new Dt(this.stateHandler,this.eventBus),this.suggestionHandler=new Bt(this.stateHandler),this.providerService=new Ut(t.provider,this.stateHandler,this.messageHandler,this.fileHandler,this.eventBus,this.ui,this.plugins),this.validationService=new Ht(this.config),this.storageService=new qt(t.storage,this.stateHandler,this.config),t.provider){const e=t.provider;queueMicrotask(()=>{this.initializeProvider(e)})}this.setupLifecycleHooks()}initializeProvider(t){return Qt(this,void 0,void 0,function*(){try{t.isConnected()||(yield t.connect({})),yield this.autoLoadConversations(t)}catch(t){this.logError("Failed to connect provider:",t)}})}initializeState(t){const e=t.initialMessages?t.initialMessages.map(t=>this.processMessageThroughPlugins(t)):[];return{messages:e,threads:t.initialThreads||[],modules:t.enableModules?[]:void 0,selectedModules:[],uploadedFiles:[],suggestions:t.initialSuggestions||[],isTyping:!1,isProcessing:!1,currentThreadId:void 0,metadata:t.metadata||{}}}processMessageThroughPlugins(t){if(!t.text||"string"!=typeof t.text)return t;const e=Array.from(this.plugins.values()).filter(t=>Array.isArray(t.htmlTags)&&t.htmlTags.length>0);if(0===e.length)return t;let i=t.text,n=!1;for(const t of e){const e=t.htmlTags;for(const o of e){const e=o.open,s=o.close;let r=0;for(;;){const a=i.indexOf(e,r);if(-1===a)break;const l=a+e.length,d=i.indexOf(s,l);if(-1===d){r=l;continue}const c=i.substring(l,d);let h="";if("function"==typeof t.renderHtmlBlock)try{h=t.renderHtmlBlock(o.name,c)}catch(e){console.error(`[ChatbotCore] Error rendering HTML block for plugin ${t.id}:`,e)}h?(i=i.substring(0,a)+h+i.substring(d+s.length),n=!0,r=a+h.length):r=d+s.length}}}return n?Object.assign(Object.assign({},t),{text:i,metadata:Object.assign(Object.assign({},t.metadata),{renderAsHtml:!0})}):t}processRestoredMessagesForPlugins(){const t=this.stateHandler.getState();if(t.messages&&0!==t.messages.length)for(const e of t.messages)"bot"===e.sender&&this.plugins.forEach(t=>{if(t.onMessageReceived)try{t.onMessageReceived(e)}catch(t){}})}setupLifecycleHooks(){this.onBeforeInit(),this.onReady().catch(t=>{this.logError("Error during initialization:",t)})}onBeforeInit(){this.log("Initializing chatbot controller...")}onReady(){return Qt(this,void 0,void 0,function*(){this.log("Chatbot controller ready");try{const t=this.stateHandler.getState(),e=t.messages&&t.messages.length>0?t.messages[0]:void 0;e&&"bot"===e.sender&&e.introduction&&Array.isArray(e.suggestions)&&e.suggestions.length>0&&this.suggestionHandler.setSuggestions(e.suggestions)}catch(t){this.logError("Error initializing suggestions from initial messages:",t)}this.processRestoredMessagesForPlugins(),this.ui.onStateChange&&this.ui.onStateChange(this.getState()),this.emit("ready",this.stateHandler.getState())})}onDestroy(){this.log("Destroying chatbot controller..."),this.storageService.stopAutoSave(),this.pluginService.clearPlugins(),this.eventBus.removeAllListeners()}updateState(t){this.stateHandler.updateState(t)}sendMessage(t){return Qt(this,arguments,void 0,function*(t,e={}){this.log("Sending message:",t);try{const i=this.stateHandler.getState();this.config.enableThreads&&!i.currentThreadId&&(yield this.threadHandler.createThread("New Chat"));const n=yield this.beforeMessageSent(t,e);if(!e.skipValidation){const t=yield this.validationService.validateMessage(n);if(!t.isValid){const e=new Ot(t.errors);throw this.handleValidationError(e),e}}const o=this.messageHandler.createUserMessage(n,e.metadata);e.files&&(o.files=e.files),this.messageHandler.addMessage(o);const s=this.stateHandler.getState();return(e.threadId||s.currentThreadId)&&this.threadHandler.updateThreadMessages(e.threadId||s.currentThreadId),yield this.afterMessageSent(o),this.providerService.processMessage(o).catch(t=>{this.logError("Error processing with provider:",t)}),o}catch(t){throw this.handleError(t),t}})}stop(){this.providerService.stopCurrentProcessing()}addMessage(t){const e=this.messageHandler.createMessage(t),i="bot"===e.sender?this.processMessageThroughPlugins(e):e;return this.messageHandler.addMessage(i),i}updateMessage(t,e){this.messageHandler.updateMessage(t,e)}deleteMessage(t){this.messageHandler.deleteMessage(t)}clearMessages(){this.updateState({messages:[]})}getMessages(){return this.stateHandler.getState().messages}uploadFiles(t){return Qt(this,void 0,void 0,function*(){if(!this.config.enableFileUpload)throw new Error("File upload is not enabled");let e=t;if(!e&&this.ui.openFileDialog&&(e=yield this.ui.openFileDialog()),!e||0===e.length)return[];const i=[];for(const t of e)try{const e=yield this.validationService.validateFile(t,{maxFileSize:this.config.maxFileSize,allowedTypes:this.config.allowedFileTypes});if(!e.isValid){this.ui.showNotification&&this.ui.showNotification(e.errors[0]||"File validation failed","error");continue}const n=yield this.fileHandler.createChatbotFile(t);this.fileHandler.addFile(n);try{const e=yield this.providerService.uploadFileToProvider(t),o=Object.assign({isUploading:!1,uploadProgress:100},e||{});this.fileHandler.updateFile(n.id,o),Object.assign(n,o),i.push(n),this.ui.showFilePreview&&this.ui.showFilePreview(n)}catch(t){throw this.fileHandler.removeFile(n.id),t}}catch(e){this.logError("Error uploading file:",e),this.ui.showNotification&&this.ui.showNotification(`Failed to upload ${t.name}`,"error")}return i})}removeFile(t){this.fileHandler.removeFile(t)}clearFiles(){this.fileHandler.clearFiles()}getUploadedFiles(){return this.stateHandler.getState().uploadedFiles}createThread(t){return Qt(this,void 0,void 0,function*(){return yield this.threadHandler.createThread(t)})}switchThread(t){this.threadHandler.switchThread(t),this.processRestoredMessagesForPlugins()}deleteThread(t){this.threadHandler.deleteThread(t)}renameThread(t,e){this.threadHandler.renameThread(t,e)}bookmarkThread(t){this.threadHandler.bookmarkThread(t)}getCurrentThread(){const t=this.stateHandler.getState();return t.threads.find(e=>e.id===t.currentThreadId)}getThreads(){return this.stateHandler.getState().threads}setModules(t){this.moduleHandler.setModules(t)}selectModules(t){this.moduleHandler.selectModules(t)}toggleModule(t){this.moduleHandler.toggleModule(t)}getSelectedModules(){return this.moduleHandler.getSelectedModules()}setSuggestions(t){this.suggestionHandler.setSuggestions(t)}clearSuggestions(){this.suggestionHandler.clearSuggestions()}beforeMessageSent(t,e){return Qt(this,void 0,void 0,function*(){let e=t;for(const t of this.plugins.values())t.beforeSend&&(e=yield t.beforeSend(e));return e})}afterMessageSent(t){return Qt(this,void 0,void 0,function*(){this.log("Message sent:",t)})}beforeProviderCall(t){return Qt(this,void 0,void 0,function*(){this.log("Calling provider for message:",t.id)})}afterProviderCall(){return Qt(this,void 0,void 0,function*(){this.log("Provider call completed")})}handleProviderError(t){return Qt(this,void 0,void 0,function*(){this.logError("Provider error:",t);const e=this.messageHandler.createMessage({sender:q.Bot,text:"Sorry, there was an error processing your request.",state:Y.Error,timestamp:(new Date).toISOString()});this.messageHandler.addMessage(e),this.ui.showNotification&&this.ui.showNotification("Failed to process message","error"),this.emit("provider:error",t),yield this.pluginService.executeHook("onError",t)})}handleValidationError(t){this.logError("Validation error:",t),this.ui.showNotification&&this.ui.showNotification(t.errors[0],"error"),this.emit("validation:error",t)}handleError(t){this.logError("Error:",t),this.emit("error",t),this.plugins.forEach(e=>{e.onError&&e.onError(t)})}registerPlugin(t){this.pluginService.registerPlugin(t,this)}unregisterPlugin(t){this.pluginService.unregisterPlugin(t)}getPlugin(t){return this.pluginService.getPlugin(t)}setProvider(t){this.providerService.setProvider(t),t.isConnected()?(this.autoLoadConversations(t).catch(t=>{this.logError("Failed to auto-load conversations:",t)}),this.emit("provider:connected",t.id)):t.connect({}).then(()=>Qt(this,void 0,void 0,function*(){yield this.autoLoadConversations(t),this.emit("provider:connected",t.id)})).catch(t=>{this.logError("Failed to connect provider:",t)})}setStorage(t){this.storageService.setStorage(t)}saveToStorage(){return Qt(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.saveState(t)})}loadFromStorage(){return Qt(this,arguments,void 0,function*(t="chatbot-state"){yield this.storageService.loadState(t);const e=this.stateHandler.getState();if(e.messages&&e.messages.length>0){const t=e.messages.map(t=>this.processMessageThroughPlugins(t));this.stateHandler.updateState({messages:t}),this.processRestoredMessagesForPlugins()}})}on(t,e){return this.eventBus.on(t,e)}emit(t,e){this.eventBus.emit(t,e)}getState(){return this.stateHandler.getState()}setState(t){t.messages&&Array.isArray(t.messages)&&(t.messages=t.messages.map(t=>this.processMessageThroughPlugins(t))),t.threads&&Array.isArray(t.threads)&&(t.threads=t.threads.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}))),this.updateState(t),t.messages&&this.processRestoredMessagesForPlugins()}loadConversations(t){const e=t.map(t=>Object.assign(Object.assign({},t),{messages:t.messages.map(t=>this.processMessageThroughPlugins(t))}));this.updateState({threads:e,currentThreadId:e.length>0?e[0].id:void 0,messages:e.length>0?e[0].messages:[]}),this.processRestoredMessagesForPlugins()}autoLoadConversations(t){return Qt(this,void 0,void 0,function*(){if(t&&"function"==typeof t.loadConversations)try{this.log("Auto-loading conversations from provider...");const e=yield t.loadConversations();if(Array.isArray(e)&&e.length>0){this.log(`Loaded ${e.length} conversation summaries`);const i=[];if("function"==typeof t.loadConversation)for(const n of e)try{const e=yield t.loadConversation(n.id);if(e){const t={id:e.id,title:e.title,messages:e.messages||[],createdAt:e.createdAt,updatedAt:e.updatedAt};i.push(t)}}catch(t){this.logError(`Failed to load conversation ${n.id}:`,t)}else for(const t of e){const e={id:t.id,title:t.title,messages:[],createdAt:t.createdAt,updatedAt:t.updatedAt};i.push(e)}i.length>0&&(this.log(`Successfully loaded ${i.length} conversations`),this.loadConversations(i))}else this.log("No conversations to load from provider")}catch(t){this.logError("Failed to auto-load conversations from provider:",t)}})}setUICallbacks(t){this.ui=Object.assign(Object.assign({},this.ui),t)}getConfig(){return Object.freeze(Object.assign({},this.config))}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setTyping(t){this.updateState({isTyping:t}),this.emit(t?"typing:start":"typing:end")}setStatusText(t){this.updateState({statusText:t})}clearStatusText(){this.updateState({statusText:void 0})}getContext(){const t=this.stateHandler.getState();return{messages:t.messages,currentThread:this.getCurrentThread(),selectedModules:t.selectedModules,metadata:t.metadata,uploadedFiles:t.uploadedFiles}}destroy(){this.onDestroy()}generateId(t){return`${t}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatFileSize(t){return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(2)} KB`:`${(t/1048576).toFixed(2)} MB`}log(...t){this.config.debug&&console.log("[ChatbotCore]",...t)}logError(...t){console.error("[ChatbotCore]",...t)}}
2848
2857
  /**
2849
2858
  * @license
2850
2859
  * Copyright 2023 Nuraly, Laabidi Aymen
@@ -2884,47 +2893,47 @@ var Qt=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){
2884
2893
  * @license
2885
2894
  * Copyright 2023 Nuraly, Laabidi Aymen
2886
2895
  * SPDX-License-Identifier: MIT
2887
- */class Oe{constructor(t){this.id="analytics",this.name="Analytics Plugin",this.version="1.0.0",this.trackEvent=t}onInit(){this.trackEvent("chatbot:initialized",{timestamp:(new Date).toISOString()}),console.log("[AnalyticsPlugin] Initialized")}onDestroy(){this.trackEvent("chatbot:destroyed",{timestamp:(new Date).toISOString()}),console.log("[AnalyticsPlugin] Destroyed")}onMessageSent(t){this.trackEvent("chatbot:message:sent",{messageId:t.id,messageLength:t.text.length,hasFiles:!!t.files&&t.files.length>0,timestamp:t.timestamp})}onMessageReceived(t){this.trackEvent("chatbot:message:received",{messageId:t.id,messageLength:t.text.length,sender:t.sender,timestamp:t.timestamp})}onError(t){this.trackEvent("chatbot:error",{error:t.message,stack:t.stack,timestamp:(new Date).toISOString()})}}
2896
+ */class ze{constructor(t){this.id="analytics",this.name="Analytics Plugin",this.version="1.0.0",this.trackEvent=t}onInit(){this.trackEvent("chatbot:initialized",{timestamp:(new Date).toISOString()}),console.log("[AnalyticsPlugin] Initialized")}onDestroy(){this.trackEvent("chatbot:destroyed",{timestamp:(new Date).toISOString()}),console.log("[AnalyticsPlugin] Destroyed")}onMessageSent(t){this.trackEvent("chatbot:message:sent",{messageId:t.id,messageLength:t.text.length,hasFiles:!!t.files&&t.files.length>0,timestamp:t.timestamp})}onMessageReceived(t){this.trackEvent("chatbot:message:received",{messageId:t.id,messageLength:t.text.length,sender:t.sender,timestamp:t.timestamp})}onError(t){this.trackEvent("chatbot:error",{error:t.message,stack:t.stack,timestamp:(new Date).toISOString()})}}
2888
2897
  /**
2889
2898
  * @license
2890
2899
  * Copyright 2023 Nuraly, Laabidi Aymen
2891
2900
  * SPDX-License-Identifier: MIT
2892
- */class ze{constructor(){this._stylesInjected=!1}getOncePerConversationStyleTag(t,e="nr-chatbot"){var i;const n=`data-plugin-styles-${this.id}`;let o=!1;try{const t=document.querySelector(e);o=!!(null===(i=null==t?void 0:t.shadowRoot)||void 0===i?void 0:i.querySelector(`style[${n}]`))}catch(t){}return this._stylesInjected||o?"":(this._stylesInjected=!0,`<style ${n}="true">${t}</style>`)}onStateChange(t){try{const e=null==t?void 0:t.currentThreadId;e!==this._lastThreadId&&(this._lastThreadId=e,this._stylesInjected=!1)}catch(t){}}}
2901
+ */class Oe{constructor(){this._stylesInjected=!1}getOncePerConversationStyleTag(t,e="nr-chatbot"){var i;const n=`data-plugin-styles-${this.id}`;let o=!1;try{const t=document.querySelector(e);o=!!(null===(i=null==t?void 0:t.shadowRoot)||void 0===i?void 0:i.querySelector(`style[${n}]`))}catch(t){}return this._stylesInjected||o?"":(this._stylesInjected=!0,`<style ${n}="true">${t}</style>`)}onStateChange(t){try{const e=null==t?void 0:t.currentThreadId;e!==this._lastThreadId&&(this._lastThreadId=e,this._stylesInjected=!1)}catch(t){}}}
2893
2902
  /**
2894
2903
  * @license
2895
2904
  * Copyright 2023 Nuraly, Laabidi Aymen
2896
2905
  * SPDX-License-Identifier: MIT
2897
- */var Ie=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class je extends ze{constructor(){super(...arguments),this.id="markdown",this.name="Markdown Plugin",this.version="2.0.0",this.htmlTags=[{name:"md",open:"[MD]",close:"[/MD]"}]}onInit(){console.log("[MarkdownPlugin] Initialized")}renderHtmlBlock(t,e){if("md"!==t)return"";const i=this.getStyles();return`${this.getOncePerConversationStyleTag(i)}${ct(e)}`}afterReceive(t){return Ie(this,void 0,void 0,function*(){return t.includes("[MD]")&&t.includes("[/MD]")?t:ct(t)})}getStyles(){return"\n .md-code { background: #f6f8fa; padding: 12px; border-radius: 6px; overflow: auto; }\n .md-inline-code { background: rgba(27,31,35,.05); padding: 0 4px; border-radius: 4px; }\n h1, h2, h3 { margin: 0.6em 0 0.4em; font-weight: 600; }\n p { margin: 0.5em 0; }\n ul { margin: 0.5em 0 0.5em 1.2em; }\n a { color: #0b5fff; text-decoration: underline; }\n "}}
2906
+ */var Ie=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class je extends Oe{constructor(){super(...arguments),this.id="markdown",this.name="Markdown Plugin",this.version="2.0.0",this.htmlTags=[{name:"md",open:"[MD]",close:"[/MD]"}]}onInit(){console.log("[MarkdownPlugin] Initialized")}renderHtmlBlock(t,e){if("md"!==t)return"";const i=this.getStyles();return`${this.getOncePerConversationStyleTag(i)}${ct(e)}`}afterReceive(t){return Ie(this,void 0,void 0,function*(){return t.includes("[MD]")&&t.includes("[/MD]")?t:ct(t)})}getStyles(){return"\n .md-code { background: #f6f8fa; padding: 12px; border-radius: 6px; overflow: auto; }\n .md-inline-code { background: rgba(27,31,35,.05); padding: 0 4px; border-radius: 4px; }\n h1, h2, h3 { margin: 0.6em 0 0.4em; font-weight: 600; }\n p { margin: 0.5em 0; }\n ul { margin: 0.5em 0 0.5em 1.2em; }\n a { color: #0b5fff; text-decoration: underline; }\n "}}
2898
2907
  /**
2899
2908
  * @license
2900
2909
  * Copyright 2023 Nuraly, Laabidi Aymen
2901
2910
  * SPDX-License-Identifier: MIT
2902
- */var Re=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class Ae extends ze{constructor(){super(...arguments),this.id="flight-card",this.name="Flight Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"flight",open:"[FLIGHT]",close:"[/FLIGHT]"}],this.cssPrefix="nr-flight-card"}renderHtmlBlockPlaceholder(t){if("flight"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`flight-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n style="min-width: 400px; max-width: 600px; margin: 16px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[FlightCardPlugin] Initialized")}afterReceive(t){return Re(this,void 0,void 0,function*(){try{const e=JSON.parse(t);if("flight"===e.type||this.isFlightData(e))return this.renderFlightCard(e)}catch(t){}const e=/\[FLIGHT\]([\s\S]*?)\[\/FLIGHT\]/g;let i,n=t;for(;null!==(i=e.exec(t));)try{const t=JSON.parse(i[1]),e=this.renderFlightCard(t);n=n.replace(i[0],e)}catch(t){console.warn("[FlightCardPlugin] Failed to parse flight data:",t)}return n})}renderHtmlBlock(t,e){if("flight"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderFlightCard(t)}catch(t){return console.warn("[FlightCardPlugin] renderHtmlBlock parse error:",t),""}}isFlightData(t){return t&&"object"==typeof t&&t.origin&&t.destination&&t.departureTime}renderFlightCard(t){const{origin:e,destination:i,departureTime:n,arrivalTime:o,departureDate:s,arrivalDate:r,terminal:a,gate:l,arrivalTerminal:d,arrivalGate:c,duration:h,flightNumber:u,airline:p,status:f,updated:m,source:g}=t;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-flight-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__route">\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(e)}</span>\n <div class="${this.cssPrefix}__flight-line">\n <svg class="${this.cssPrefix}__plane-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z" fill="currentColor"/>\n </svg>\n ${h?`<span class="${this.cssPrefix}__duration">${this.escapeHtml(h)}</span>`:""}\n </div>\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(i)}</span>\n </div>\n ${u||p?`\n <div class="${this.cssPrefix}__flight-info">\n ${p?`<span class="${this.cssPrefix}__airline">${this.escapeHtml(p)}</span>`:""}\n ${u?`<span class="${this.cssPrefix}__flight-number">${this.escapeHtml(u)}</span>`:""}\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--departure">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(e)}</span>\n <span class="${this.cssPrefix}__date">${s?this.escapeHtml(s):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure de départ prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(n)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${a?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(a)}</span>\n </div>\n `:""}\n ${l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(l)}</span>\n </div>\n `:void 0===l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n\n <div class="${this.cssPrefix}__divider"></div>\n\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--arrival">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(i)}</span>\n <span class="${this.cssPrefix}__date">${r?this.escapeHtml(r):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure d'arrivée prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(o)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${d?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(d)}</span>\n </div>\n `:""}\n ${c?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(c)}</span>\n </div>\n `:void 0===c?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n </div>\n\n ${m||g||f?`\n <div class="${this.cssPrefix}__footer">\n ${m?`<span class="${this.cssPrefix}__updated">${this.escapeHtml(m)}</span>`:""}\n ${g?`<span class="${this.cssPrefix}__source">Source : ${this.escapeHtml(g)}</span>`:""}\n ${f?`<span class="${this.cssPrefix}__status">${this.escapeHtml(f)}</span>`:""}\n </div>\n `:""}\n </div>\n `}getCityName(t){return{JED:"Djeddah",TUN:"Tunis",CDG:"Paris",LHR:"London",JFK:"New York",DXB:"Dubai",LAX:"Los Angeles",ORD:"Chicago",ATL:"Atlanta",DFW:"Dallas",DEN:"Denver",SFO:"San Francisco",SEA:"Seattle",LAS:"Las Vegas",MCO:"Orlando",MIA:"Miami",IAH:"Houston",PHX:"Phoenix",BOS:"Boston",MSP:"Minneapolis",DTW:"Detroit",FLL:"Fort Lauderdale",PHL:"Philadelphia",LGA:"New York",BWI:"Baltimore",SLC:"Salt Lake City",SAN:"San Diego",DCA:"Washington",TPA:"Tampa",PDX:"Portland",STL:"St. Louis"}[t.toUpperCase()]||t}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 24px;\n margin: 16px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 600px;\n }\n\n .${this.cssPrefix}__header {\n margin-bottom: 24px;\n }\n\n .${this.cssPrefix}__route {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 32px;\n font-weight: 700;\n color: #1a1a1a;\n letter-spacing: 0.5px;\n }\n\n .${this.cssPrefix}__flight-line {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n padding: 0 16px;\n }\n\n .${this.cssPrefix}__flight-line::before {\n content: '';\n position: absolute;\n top: 50%;\n left: 0;\n right: 0;\n height: 2px;\n background: linear-gradient(to right, #e0e0e0 0%, #e0e0e0 100%);\n z-index: 0;\n }\n\n .${this.cssPrefix}__plane-icon {\n width: 24px;\n height: 24px;\n color: #666;\n background: white;\n padding: 4px;\n position: relative;\n z-index: 1;\n transform: rotate(90deg);\n }\n\n .${this.cssPrefix}__duration {\n position: absolute;\n top: -24px;\n background: white;\n padding: 2px 8px;\n font-size: 13px;\n color: #666;\n white-space: nowrap;\n }\n\n .${this.cssPrefix}__flight-info {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 14px;\n color: #666;\n }\n\n .${this.cssPrefix}__airline {\n font-weight: 500;\n }\n\n .${this.cssPrefix}__flight-number {\n color: #999;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n gap: 24px;\n }\n\n .${this.cssPrefix}__divider {\n width: 1px;\n background: #e0e0e0;\n }\n\n .${this.cssPrefix}__section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .${this.cssPrefix}__label {\n font-size: 12px;\n color: #999;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n font-weight: 500;\n text-decoration: underline;\n }\n\n .${this.cssPrefix}__location {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__city {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__date {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__time-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 24px;\n font-weight: 700;\n color: #2d6a3e;\n }\n\n .${this.cssPrefix}__terminal-gate {\n display: flex;\n gap: 16px;\n }\n\n .${this.cssPrefix}__info-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__info-label {\n font-size: 11px;\n color: #999;\n }\n\n .${this.cssPrefix}__info-value {\n font-size: 18px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n margin-top: 16px;\n padding-top: 16px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-size: 12px;\n color: #666;\n gap: 12px;\n }\n\n .${this.cssPrefix}__updated {\n color: #999;\n }\n\n .${this.cssPrefix}__source {\n color: #666;\n }\n\n .${this.cssPrefix}__source::before {\n content: '';\n display: inline-block;\n width: 4px;\n height: 4px;\n background: #666;\n border-radius: 50%;\n margin-right: 8px;\n vertical-align: middle;\n }\n\n .${this.cssPrefix}__status {\n padding: 4px 8px;\n background: #e8f5e9;\n color: #2d6a3e;\n border-radius: 4px;\n font-weight: 500;\n }\n\n /* Share button styling */\n .${this.cssPrefix}__footer button {\n background: none;\n border: none;\n color: #666;\n cursor: pointer;\n padding: 4px;\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .${this.cssPrefix}__footer button:hover {\n color: #1a1a1a;\n }\n\n /* Responsive design */\n @media (max-width: 640px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .${this.cssPrefix}__divider {\n height: 1px;\n width: 100%;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 24px;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 20px;\n }\n\n .${this.cssPrefix}__footer {\n flex-direction: column;\n align-items: flex-start;\n }\n }\n `}}
2911
+ */var Re=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class Ae extends Oe{constructor(){super(...arguments),this.id="flight-card",this.name="Flight Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"flight",open:"[FLIGHT]",close:"[/FLIGHT]"}],this.cssPrefix="nr-flight-card"}renderHtmlBlockPlaceholder(t){if("flight"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`flight-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n style="min-width: 400px; max-width: 600px; margin: 16px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[FlightCardPlugin] Initialized")}afterReceive(t){return Re(this,void 0,void 0,function*(){try{const e=JSON.parse(t);if("flight"===e.type||this.isFlightData(e))return this.renderFlightCard(e)}catch(t){}const e=/\[FLIGHT\]([\s\S]*?)\[\/FLIGHT\]/g;let i,n=t;for(;null!==(i=e.exec(t));)try{const t=JSON.parse(i[1]),e=this.renderFlightCard(t);n=n.replace(i[0],e)}catch(t){console.warn("[FlightCardPlugin] Failed to parse flight data:",t)}return n})}renderHtmlBlock(t,e){if("flight"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderFlightCard(t)}catch(t){return console.warn("[FlightCardPlugin] renderHtmlBlock parse error:",t),""}}isFlightData(t){return t&&"object"==typeof t&&t.origin&&t.destination&&t.departureTime}renderFlightCard(t){const{origin:e,destination:i,departureTime:n,arrivalTime:o,departureDate:s,arrivalDate:r,terminal:a,gate:l,arrivalTerminal:d,arrivalGate:c,duration:h,flightNumber:u,airline:p,status:f,updated:m,source:g}=t;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-flight-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__route">\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(e)}</span>\n <div class="${this.cssPrefix}__flight-line">\n <svg class="${this.cssPrefix}__plane-icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M21 16v-2l-8-5V3.5c0-.83-.67-1.5-1.5-1.5S10 2.67 10 3.5V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5l8 2.5z" fill="currentColor"/>\n </svg>\n ${h?`<span class="${this.cssPrefix}__duration">${this.escapeHtml(h)}</span>`:""}\n </div>\n <span class="${this.cssPrefix}__airport-code">${this.escapeHtml(i)}</span>\n </div>\n ${u||p?`\n <div class="${this.cssPrefix}__flight-info">\n ${p?`<span class="${this.cssPrefix}__airline">${this.escapeHtml(p)}</span>`:""}\n ${u?`<span class="${this.cssPrefix}__flight-number">${this.escapeHtml(u)}</span>`:""}\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--departure">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(e)}</span>\n <span class="${this.cssPrefix}__date">${s?this.escapeHtml(s):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure de départ prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(n)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${a?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(a)}</span>\n </div>\n `:""}\n ${l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(l)}</span>\n </div>\n `:void 0===l?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n\n <div class="${this.cssPrefix}__divider"></div>\n\n <div class="${this.cssPrefix}__section ${this.cssPrefix}__section--arrival">\n <div class="${this.cssPrefix}__label">Infos sur l'aéroport</div>\n <div class="${this.cssPrefix}__location">\n <span class="${this.cssPrefix}__city">${this.getCityName(i)}</span>\n <span class="${this.cssPrefix}__date">${r?this.escapeHtml(r):""}</span>\n </div>\n <div class="${this.cssPrefix}__time-group">\n <div class="${this.cssPrefix}__time-label">Heure d'arrivée prévue</div>\n <div class="${this.cssPrefix}__time-value">${this.escapeHtml(o)}</div>\n </div>\n <div class="${this.cssPrefix}__terminal-gate">\n ${d?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Terminal</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(d)}</span>\n </div>\n `:""}\n ${c?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">${this.escapeHtml(c)}</span>\n </div>\n `:void 0===c?`\n <div class="${this.cssPrefix}__info-item">\n <span class="${this.cssPrefix}__info-label">Porte</span>\n <span class="${this.cssPrefix}__info-value">-</span>\n </div>\n `:""}\n </div>\n </div>\n </div>\n\n ${m||g||f?`\n <div class="${this.cssPrefix}__footer">\n ${m?`<span class="${this.cssPrefix}__updated">${this.escapeHtml(m)}</span>`:""}\n ${g?`<span class="${this.cssPrefix}__source">Source : ${this.escapeHtml(g)}</span>`:""}\n ${f?`<span class="${this.cssPrefix}__status">${this.escapeHtml(f)}</span>`:""}\n </div>\n `:""}\n </div>\n `}getCityName(t){return{JED:"Djeddah",TUN:"Tunis",CDG:"Paris",LHR:"London",JFK:"New York",DXB:"Dubai",LAX:"Los Angeles",ORD:"Chicago",ATL:"Atlanta",DFW:"Dallas",DEN:"Denver",SFO:"San Francisco",SEA:"Seattle",LAS:"Las Vegas",MCO:"Orlando",MIA:"Miami",IAH:"Houston",PHX:"Phoenix",BOS:"Boston",MSP:"Minneapolis",DTW:"Detroit",FLL:"Fort Lauderdale",PHL:"Philadelphia",LGA:"New York",BWI:"Baltimore",SLC:"Salt Lake City",SAN:"San Diego",DCA:"Washington",TPA:"Tampa",PDX:"Portland",STL:"St. Louis"}[t.toUpperCase()]||t}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 24px;\n margin: 16px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 600px;\n }\n\n .${this.cssPrefix}__header {\n margin-bottom: 24px;\n }\n\n .${this.cssPrefix}__route {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 32px;\n font-weight: 700;\n color: #1a1a1a;\n letter-spacing: 0.5px;\n }\n\n .${this.cssPrefix}__flight-line {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n padding: 0 16px;\n }\n\n .${this.cssPrefix}__flight-line::before {\n content: '';\n position: absolute;\n top: 50%;\n left: 0;\n right: 0;\n height: 2px;\n background: linear-gradient(to right, #e0e0e0 0%, #e0e0e0 100%);\n z-index: 0;\n }\n\n .${this.cssPrefix}__plane-icon {\n width: 24px;\n height: 24px;\n color: #666;\n background: white;\n padding: 4px;\n position: relative;\n z-index: 1;\n transform: rotate(90deg);\n }\n\n .${this.cssPrefix}__duration {\n position: absolute;\n top: -24px;\n background: white;\n padding: 2px 8px;\n font-size: 13px;\n color: #666;\n white-space: nowrap;\n }\n\n .${this.cssPrefix}__flight-info {\n display: flex;\n gap: 8px;\n align-items: center;\n font-size: 14px;\n color: #666;\n }\n\n .${this.cssPrefix}__airline {\n font-weight: 500;\n }\n\n .${this.cssPrefix}__flight-number {\n color: #999;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n gap: 24px;\n }\n\n .${this.cssPrefix}__divider {\n width: 1px;\n background: #e0e0e0;\n }\n\n .${this.cssPrefix}__section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .${this.cssPrefix}__label {\n font-size: 12px;\n color: #999;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n font-weight: 500;\n text-decoration: underline;\n }\n\n .${this.cssPrefix}__location {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__city {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__date {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__time-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 24px;\n font-weight: 700;\n color: #2d6a3e;\n }\n\n .${this.cssPrefix}__terminal-gate {\n display: flex;\n gap: 16px;\n }\n\n .${this.cssPrefix}__info-item {\n display: flex;\n flex-direction: column;\n gap: 4px;\n }\n\n .${this.cssPrefix}__info-label {\n font-size: 11px;\n color: #999;\n }\n\n .${this.cssPrefix}__info-value {\n font-size: 18px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n margin-top: 16px;\n padding-top: 16px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n font-size: 12px;\n color: #666;\n gap: 12px;\n }\n\n .${this.cssPrefix}__updated {\n color: #999;\n }\n\n .${this.cssPrefix}__source {\n color: #666;\n }\n\n .${this.cssPrefix}__source::before {\n content: '';\n display: inline-block;\n width: 4px;\n height: 4px;\n background: #666;\n border-radius: 50%;\n margin-right: 8px;\n vertical-align: middle;\n }\n\n .${this.cssPrefix}__status {\n padding: 4px 8px;\n background: #e8f5e9;\n color: #2d6a3e;\n border-radius: 4px;\n font-weight: 500;\n }\n\n /* Share button styling */\n .${this.cssPrefix}__footer button {\n background: none;\n border: none;\n color: #666;\n cursor: pointer;\n padding: 4px;\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .${this.cssPrefix}__footer button:hover {\n color: #1a1a1a;\n }\n\n /* Responsive design */\n @media (max-width: 640px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n gap: 16px;\n }\n\n .${this.cssPrefix}__divider {\n height: 1px;\n width: 100%;\n }\n\n .${this.cssPrefix}__airport-code {\n font-size: 24px;\n }\n\n .${this.cssPrefix}__time-value {\n font-size: 20px;\n }\n\n .${this.cssPrefix}__footer {\n flex-direction: column;\n align-items: flex-start;\n }\n }\n `}}
2903
2912
  /**
2904
2913
  * @license
2905
2914
  * Copyright 2023 Nuraly, Laabidi Aymen
2906
2915
  * SPDX-License-Identifier: MIT
2907
- */class Le extends ze{constructor(){super(...arguments),this.id="print-job-card",this.name="Print Job Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"printjob",open:"[PRINTJOB]",close:"[/PRINTJOB]"}],this.cssPrefix="nr-print-job-card"}renderHtmlBlockPlaceholder(t){if("printjob"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`printjob-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n avatar\n paragraph='{"rows":3}'\n style="min-width: 350px; max-width: 500px; margin: 8px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[PrintJobCardPlugin] Initialized")}renderHtmlBlock(t,e){if("printjob"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderPrintJobCard(t)}catch(t){return console.warn("[PrintJobCardPlugin] renderHtmlBlock parse error:",t),""}}renderPrintJobCard(t){const e=this.getStatusIcon(t.status),i=t.pagesPrinted&&t.totalPages?Math.round(t.pagesPrinted/t.totalPages*100):0;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-print-job-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__printer-icon">\n 🖨️\n </div>\n <div class="${this.cssPrefix}__header-content">\n <div class="${this.cssPrefix}__title">${this.escapeHtml(t.documentName)}</div>\n <div class="${this.cssPrefix}__subtitle">${this.escapeHtml(t.printerName)}</div>\n </div>\n <div class="${this.cssPrefix}__job-id">#${this.escapeHtml(t.jobId)}</div>\n </div>\n\n <div class="${this.cssPrefix}__status-row">\n <span class="${this.cssPrefix}__status-badge ${this.cssPrefix}__status-badge--${t.status}">\n ${e} ${this.formatStatus(t.status)}\n </span>\n ${t.priority&&"normal"!==t.priority?`\n <span class="${this.cssPrefix}__priority-badge ${this.cssPrefix}__priority-badge--${t.priority}">\n ${"high"===t.priority?"⚡":"🔽"} ${this.capitalize(t.priority)} Priority\n </span>\n `:""}\n </div>\n\n ${"printing"===t.status&&t.pagesPrinted&&t.totalPages?`\n <div class="${this.cssPrefix}__progress">\n <div class="${this.cssPrefix}__progress-bar">\n <div class="${this.cssPrefix}__progress-fill" style="width: ${i}%"></div>\n </div>\n <div class="${this.cssPrefix}__progress-text">\n ${t.pagesPrinted} / ${t.totalPages} pages (${i}%)\n </div>\n </div>\n `:""}\n\n ${"error"===t.status&&t.errorMessage?`\n <div class="${this.cssPrefix}__error-message">\n ⚠️ ${this.escapeHtml(t.errorMessage)}\n </div>\n `:""}\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Pages:</span>\n <span class="${this.cssPrefix}__detail-value">${t.totalPages}</span>\n </div>\n ${t.copies&&t.copies>1?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Copies:</span>\n <span class="${this.cssPrefix}__detail-value">${t.copies}</span>\n </div>\n `:""}\n ${t.colorMode?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Color Mode:</span>\n <span class="${this.cssPrefix}__detail-value">${this.capitalize(t.colorMode)}</span>\n </div>\n `:""}\n ${t.paperSize?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Paper Size:</span>\n <span class="${this.cssPrefix}__detail-value">${t.paperSize}</span>\n </div>\n `:""}\n ${t.userName?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">User:</span>\n <span class="${this.cssPrefix}__detail-value">${this.escapeHtml(t.userName)}</span>\n </div>\n `:""}\n ${t.estimatedTime&&"printing"===t.status?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Est. Time:</span>\n <span class="${this.cssPrefix}__detail-value">${t.estimatedTime}</span>\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__footer">\n <span class="${this.cssPrefix}__timestamp">\n 📅 Submitted: ${this.formatTimestamp(t.submittedAt)}\n </span>\n ${t.completedAt?`\n <span class="${this.cssPrefix}__timestamp">\n ✅ Completed: ${this.formatTimestamp(t.completedAt)}\n </span>\n `:""}\n </div>\n </div>\n `}getStatusColor(t){return{queued:"#ffa726",printing:"#42a5f5",completed:"#66bb6a",paused:"#ffb74d",error:"#ef5350",cancelled:"#78909c"}[t]||"#999"}getStatusIcon(t){return{queued:"⏳",printing:"🔄",completed:"✅",paused:"⏸️",error:"❌",cancelled:"🚫"}[t]||"📄"}formatStatus(t){return t.charAt(0).toUpperCase()+t.slice(1)}capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}formatTimestamp(t){try{return new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch(e){return t}}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 20px;\n margin: 12px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 500px;\n border-left: 4px solid #42a5f5;\n }\n\n .${this.cssPrefix}__header {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__printer-icon {\n font-size: 32px;\n line-height: 1;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__header-content {\n flex: 1;\n min-width: 0;\n }\n\n .${this.cssPrefix}__title {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n margin-bottom: 4px;\n word-break: break-word;\n }\n\n .${this.cssPrefix}__subtitle {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__job-id {\n font-size: 12px;\n color: #999;\n font-family: 'Monaco', 'Courier New', monospace;\n background: #f5f5f5;\n padding: 4px 8px;\n border-radius: 4px;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__status-row {\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__status-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__status-badge--queued {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--printing {\n background: #e3f2fd;\n color: #0d47a1;\n }\n\n .${this.cssPrefix}__status-badge--completed {\n background: #e8f5e9;\n color: #1b5e20;\n }\n\n .${this.cssPrefix}__status-badge--paused {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--error {\n background: #ffebee;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__status-badge--cancelled {\n background: #f5f5f5;\n color: #616161;\n }\n\n .${this.cssPrefix}__priority-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__priority-badge--high {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__priority-badge--low {\n background: #f5f5f5;\n color: #666;\n }\n\n .${this.cssPrefix}__progress {\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #42a5f5 0%, #1976d2 100%);\n transition: width 0.3s ease;\n border-radius: 4px;\n }\n\n .${this.cssPrefix}__progress-text {\n font-size: 13px;\n color: #666;\n text-align: center;\n }\n\n .${this.cssPrefix}__error-message {\n background: #ffebee;\n border-left: 3px solid #ef5350;\n padding: 12px;\n margin-bottom: 16px;\n border-radius: 4px;\n font-size: 13px;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n gap: 12px;\n margin-bottom: 16px;\n padding: 16px;\n background: #f9f9f9;\n border-radius: 8px;\n }\n\n .${this.cssPrefix}__detail-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n }\n\n .${this.cssPrefix}__detail-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__detail-value {\n font-size: 13px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n display: flex;\n flex-direction: column;\n gap: 4px;\n padding-top: 12px;\n border-top: 1px solid #e0e0e0;\n }\n\n .${this.cssPrefix}__timestamp {\n font-size: 11px;\n color: #999;\n }\n\n /* Responsive design */\n @media (max-width: 480px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n }\n\n .${this.cssPrefix}__header {\n flex-wrap: wrap;\n }\n\n .${this.cssPrefix}__job-id {\n order: -1;\n width: 100%;\n }\n }\n `}}
2916
+ */class Le extends Oe{constructor(){super(...arguments),this.id="print-job-card",this.name="Print Job Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"printjob",open:"[PRINTJOB]",close:"[/PRINTJOB]"}],this.cssPrefix="nr-print-job-card"}renderHtmlBlockPlaceholder(t){if("printjob"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`printjob-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton \n active \n avatar\n paragraph='{"rows":3}'\n style="min-width: 350px; max-width: 500px; margin: 8px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[PrintJobCardPlugin] Initialized")}renderHtmlBlock(t,e){if("printjob"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderPrintJobCard(t)}catch(t){return console.warn("[PrintJobCardPlugin] renderHtmlBlock parse error:",t),""}}renderPrintJobCard(t){const e=this.getStatusIcon(t.status),i=t.pagesPrinted&&t.totalPages?Math.round(t.pagesPrinted/t.totalPages*100):0;return`\n ${this.getOncePerConversationStyleTag(this.getStyles())}\n <div class="${this.cssPrefix}" data-nr-print-job-card="true">\n <div class="${this.cssPrefix}__header">\n <div class="${this.cssPrefix}__printer-icon">\n 🖨️\n </div>\n <div class="${this.cssPrefix}__header-content">\n <div class="${this.cssPrefix}__title">${this.escapeHtml(t.documentName)}</div>\n <div class="${this.cssPrefix}__subtitle">${this.escapeHtml(t.printerName)}</div>\n </div>\n <div class="${this.cssPrefix}__job-id">#${this.escapeHtml(t.jobId)}</div>\n </div>\n\n <div class="${this.cssPrefix}__status-row">\n <span class="${this.cssPrefix}__status-badge ${this.cssPrefix}__status-badge--${t.status}">\n ${e} ${this.formatStatus(t.status)}\n </span>\n ${t.priority&&"normal"!==t.priority?`\n <span class="${this.cssPrefix}__priority-badge ${this.cssPrefix}__priority-badge--${t.priority}">\n ${"high"===t.priority?"⚡":"🔽"} ${this.capitalize(t.priority)} Priority\n </span>\n `:""}\n </div>\n\n ${"printing"===t.status&&t.pagesPrinted&&t.totalPages?`\n <div class="${this.cssPrefix}__progress">\n <div class="${this.cssPrefix}__progress-bar">\n <div class="${this.cssPrefix}__progress-fill" style="width: ${i}%"></div>\n </div>\n <div class="${this.cssPrefix}__progress-text">\n ${t.pagesPrinted} / ${t.totalPages} pages (${i}%)\n </div>\n </div>\n `:""}\n\n ${"error"===t.status&&t.errorMessage?`\n <div class="${this.cssPrefix}__error-message">\n ⚠️ ${this.escapeHtml(t.errorMessage)}\n </div>\n `:""}\n\n <div class="${this.cssPrefix}__details">\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Pages:</span>\n <span class="${this.cssPrefix}__detail-value">${t.totalPages}</span>\n </div>\n ${t.copies&&t.copies>1?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Copies:</span>\n <span class="${this.cssPrefix}__detail-value">${t.copies}</span>\n </div>\n `:""}\n ${t.colorMode?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Color Mode:</span>\n <span class="${this.cssPrefix}__detail-value">${this.capitalize(t.colorMode)}</span>\n </div>\n `:""}\n ${t.paperSize?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Paper Size:</span>\n <span class="${this.cssPrefix}__detail-value">${t.paperSize}</span>\n </div>\n `:""}\n ${t.userName?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">User:</span>\n <span class="${this.cssPrefix}__detail-value">${this.escapeHtml(t.userName)}</span>\n </div>\n `:""}\n ${t.estimatedTime&&"printing"===t.status?`\n <div class="${this.cssPrefix}__detail-row">\n <span class="${this.cssPrefix}__detail-label">Est. Time:</span>\n <span class="${this.cssPrefix}__detail-value">${t.estimatedTime}</span>\n </div>\n `:""}\n </div>\n\n <div class="${this.cssPrefix}__footer">\n <span class="${this.cssPrefix}__timestamp">\n 📅 Submitted: ${this.formatTimestamp(t.submittedAt)}\n </span>\n ${t.completedAt?`\n <span class="${this.cssPrefix}__timestamp">\n ✅ Completed: ${this.formatTimestamp(t.completedAt)}\n </span>\n `:""}\n </div>\n </div>\n `}getStatusColor(t){return{queued:"#ffa726",printing:"#42a5f5",completed:"#66bb6a",paused:"#ffb74d",error:"#ef5350",cancelled:"#78909c"}[t]||"#999"}getStatusIcon(t){return{queued:"⏳",printing:"🔄",completed:"✅",paused:"⏸️",error:"❌",cancelled:"🚫"}[t]||"📄"}formatStatus(t){return t.charAt(0).toUpperCase()+t.slice(1)}capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1)}formatTimestamp(t){try{return new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch(e){return t}}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n background: #ffffff;\n border-radius: 12px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n padding: 20px;\n margin: 12px 0;\n font-family: system-ui, -apple-system, sans-serif;\n max-width: 500px;\n border-left: 4px solid #42a5f5;\n }\n\n .${this.cssPrefix}__header {\n display: flex;\n align-items: flex-start;\n gap: 12px;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__printer-icon {\n font-size: 32px;\n line-height: 1;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__header-content {\n flex: 1;\n min-width: 0;\n }\n\n .${this.cssPrefix}__title {\n font-size: 16px;\n font-weight: 600;\n color: #1a1a1a;\n margin-bottom: 4px;\n word-break: break-word;\n }\n\n .${this.cssPrefix}__subtitle {\n font-size: 13px;\n color: #666;\n }\n\n .${this.cssPrefix}__job-id {\n font-size: 12px;\n color: #999;\n font-family: 'Monaco', 'Courier New', monospace;\n background: #f5f5f5;\n padding: 4px 8px;\n border-radius: 4px;\n flex-shrink: 0;\n }\n\n .${this.cssPrefix}__status-row {\n display: flex;\n gap: 8px;\n flex-wrap: wrap;\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__status-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 13px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__status-badge--queued {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--printing {\n background: #e3f2fd;\n color: #0d47a1;\n }\n\n .${this.cssPrefix}__status-badge--completed {\n background: #e8f5e9;\n color: #1b5e20;\n }\n\n .${this.cssPrefix}__status-badge--paused {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__status-badge--error {\n background: #ffebee;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__status-badge--cancelled {\n background: #f5f5f5;\n color: #616161;\n }\n\n .${this.cssPrefix}__priority-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 6px 12px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n }\n\n .${this.cssPrefix}__priority-badge--high {\n background: #fff3e0;\n color: #e65100;\n }\n\n .${this.cssPrefix}__priority-badge--low {\n background: #f5f5f5;\n color: #666;\n }\n\n .${this.cssPrefix}__progress {\n margin-bottom: 16px;\n }\n\n .${this.cssPrefix}__progress-bar {\n width: 100%;\n height: 8px;\n background: #e0e0e0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n }\n\n .${this.cssPrefix}__progress-fill {\n height: 100%;\n background: linear-gradient(90deg, #42a5f5 0%, #1976d2 100%);\n transition: width 0.3s ease;\n border-radius: 4px;\n }\n\n .${this.cssPrefix}__progress-text {\n font-size: 13px;\n color: #666;\n text-align: center;\n }\n\n .${this.cssPrefix}__error-message {\n background: #ffebee;\n border-left: 3px solid #ef5350;\n padding: 12px;\n margin-bottom: 16px;\n border-radius: 4px;\n font-size: 13px;\n color: #b71c1c;\n }\n\n .${this.cssPrefix}__details {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n gap: 12px;\n margin-bottom: 16px;\n padding: 16px;\n background: #f9f9f9;\n border-radius: 8px;\n }\n\n .${this.cssPrefix}__detail-row {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 8px;\n }\n\n .${this.cssPrefix}__detail-label {\n font-size: 12px;\n color: #666;\n }\n\n .${this.cssPrefix}__detail-value {\n font-size: 13px;\n font-weight: 600;\n color: #1a1a1a;\n }\n\n .${this.cssPrefix}__footer {\n display: flex;\n flex-direction: column;\n gap: 4px;\n padding-top: 12px;\n border-top: 1px solid #e0e0e0;\n }\n\n .${this.cssPrefix}__timestamp {\n font-size: 11px;\n color: #999;\n }\n\n /* Responsive design */\n @media (max-width: 480px) {\n .${this.cssPrefix} {\n padding: 16px;\n }\n\n .${this.cssPrefix}__details {\n grid-template-columns: 1fr;\n }\n\n .${this.cssPrefix}__header {\n flex-wrap: wrap;\n }\n\n .${this.cssPrefix}__job-id {\n order: -1;\n width: 100%;\n }\n }\n `}}
2908
2917
  /**
2909
2918
  * @license
2910
2919
  * Copyright 2023 Nuraly, Laabidi Aymen
2911
2920
  * SPDX-License-Identifier: MIT
2912
- */var Fe=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class De extends ze{constructor(){super(...arguments),this.id="artifact",this.name="Artifact Plugin",this.version="1.0.0",this.artifacts=new Map}onInit(t){this.controller=t,t&&"function"==typeof t.on&&t.on("processing:end",()=>{var e,i;try{const n=[...(null===(e=t.getMessages)||void 0===e?void 0:e.call(t))||[]].reverse().find(t=>t.sender===q.Bot);n&&!(null===(i=n.metadata)||void 0===i?void 0:i.hasArtifacts)&&this.processMessage(n)}catch(t){}})}onMessageReceived(t){return Fe(this,void 0,void 0,function*(){t.sender===q.Bot&&this.processMessage(t)})}processMessage(t){var e;if(null===(e=t.metadata)||void 0===e?void 0:e.hasArtifacts)return void this.rebuildArtifactsFromMetadata(t);const i=t.text;if(!i)return;const n=/```(\w*)\n([\s\S]*?)```/g;let o;const s=[];let r=0;for(;null!==(o=n.exec(i));){const e=(o[1]||"text").toLowerCase(),i=o[2],n=`artifact-${t.id}-${r}`,a={id:n,language:e,content:i,title:this.extractTitle(i,e,r),messageId:t.id,index:r};s.push(a),this.artifacts.set(n,a),r++}if(0===s.length)return;let a=i,l=0;a=a.replaceAll(n,()=>`\0ARTIFACT_CARD_${s[l++].id}\0`),a=ct(a);for(const t of s)a=a.replace(`\0ARTIFACT_CARD_${t.id}\0`,this.renderPlaceholderCard(t));const d=this.getOncePerConversationStyleTag(this.getStyles());this.controller&&"function"==typeof this.controller.updateMessage&&this.controller.updateMessage(t.id,{text:d+a,metadata:Object.assign(Object.assign({},t.metadata),{renderAsHtml:!0,hasArtifacts:!0,artifactIds:s.map(t=>t.id),artifactOriginalText:i})})}rebuildArtifactsFromMetadata(t){var e,i;const n=null===(e=t.metadata)||void 0===e?void 0:e.artifactIds;if(!(null==n?void 0:n.length))return;if(n.every(t=>this.artifacts.has(t)))return;const o=null===(i=t.metadata)||void 0===i?void 0:i.artifactOriginalText;if(!o)return;const s=/```(\w*)\n([\s\S]*?)```/g;let r,a=0;for(;null!==(r=s.exec(o));){const e=(r[1]||"text").toLowerCase(),i=r[2],n=`artifact-${t.id}-${a}`,o=this.extractTitle(i,e,a);this.artifacts.set(n,{id:n,language:e,content:i,title:o,messageId:t.id,index:a}),a++}}getArtifact(t){return this.artifacts.get(t)}getAllArtifacts(){return Array.from(this.artifacts.values())}getArtifactsForMessage(t){return Array.from(this.artifacts.values()).filter(e=>e.messageId===t)}processNow(t){var e;if(!this.controller||"function"!=typeof this.controller.getMessages)return!1;const i=(this.controller.getMessages()||[]).find(e=>e.id===t);return!(!i||i.sender!==q.Bot)&&((null===(e=i.metadata)||void 0===e?void 0:e.hasArtifacts)?(this.rebuildArtifactsFromMetadata(i),!0):(this.processMessage(i),!0))}extractTitle(t,e,i){const n=t.trimStart().split("\n")[0]||"",o=[/^\/\/\s*(.+)/,/^#\s*(.+)/,/^--\s*(.+)/,/^\/\*\s*(.*?)\*\//,/^<!--\s*(.*?)-->/];for(const t of o){const e=t.exec(n);if(null==e?void 0:e[1]){const t=e[1].trim();if(t.length>0&&t.length<=60)return t}}return`${dt(e)} Snippet ${i+1}`}renderPlaceholderCard(t){const e=dt(t.language),i=at(t.title);return`<div class="nr-artifact-card" data-artifact-id="${t.id}" role="button" tabindex="0" aria-label="View ${i}">\n <nr-icon name="code" size="small" class="nr-artifact-card__icon"></nr-icon>\n <span class="nr-artifact-card__info">\n <span class="nr-artifact-card__title">${i}</span>\n <nr-tag size="small" class="nr-artifact-card__lang">${e}</nr-tag>\n </span>\n <nr-icon name="chevron-right" size="small" class="nr-artifact-card__chevron"></nr-icon>\n</div>`}getStyles(){return"\n .nr-artifact-card {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n margin: 8px 0;\n background: #f6f8fa;\n border: 1px solid #d0d7de;\n border-radius: 8px;\n cursor: pointer;\n transition: background 0.15s ease, border-color 0.15s ease;\n user-select: none;\n max-width: 100%;\n }\n .nr-artifact-card:hover {\n background: #eaeef2;\n border-color: #8b949e;\n }\n .nr-artifact-card:focus-visible {\n outline: 2px solid #0b5fff;\n outline-offset: 2px;\n }\n .nr-artifact-card__icon {\n flex-shrink: 0;\n color: #57606a;\n }\n .nr-artifact-card__info {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n flex: 1;\n }\n .nr-artifact-card__title {\n font-size: 13px;\n font-weight: 500;\n color: #1f2937;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n }\n .nr-artifact-card__lang {\n align-self: flex-start;\n }\n .nr-artifact-card__chevron {\n flex-shrink: 0;\n color: #6c757d;\n }\n "}}
2921
+ */var Fe=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class De extends Oe{constructor(){super(...arguments),this.id="artifact",this.name="Artifact Plugin",this.version="1.0.0",this.artifacts=new Map}onInit(t){this.controller=t,t&&"function"==typeof t.on&&t.on("processing:end",()=>{var e,i;try{const n=[...(null===(e=t.getMessages)||void 0===e?void 0:e.call(t))||[]].reverse().find(t=>t.sender===q.Bot);n&&!(null===(i=n.metadata)||void 0===i?void 0:i.hasArtifacts)&&this.processMessage(n)}catch(t){}})}onMessageReceived(t){return Fe(this,void 0,void 0,function*(){t.sender===q.Bot&&this.processMessage(t)})}processMessage(t){var e;if(null===(e=t.metadata)||void 0===e?void 0:e.hasArtifacts)return void this.rebuildArtifactsFromMetadata(t);const i=t.text;if(!i)return;const n=/```(\w*)\n([\s\S]*?)```/g;let o;const s=[];let r=0;for(;null!==(o=n.exec(i));){const e=(o[1]||"text").toLowerCase(),i=o[2],n=`artifact-${t.id}-${r}`,a={id:n,language:e,content:i,title:this.extractTitle(i,e,r),messageId:t.id,index:r};s.push(a),this.artifacts.set(n,a),r++}if(0===s.length)return;let a=i,l=0;a=a.replaceAll(n,()=>`\0ARTIFACT_CARD_${s[l++].id}\0`),a=ct(a);for(const t of s)a=a.replace(`\0ARTIFACT_CARD_${t.id}\0`,this.renderPlaceholderCard(t));const d=this.getOncePerConversationStyleTag(this.getStyles());this.controller&&"function"==typeof this.controller.updateMessage&&this.controller.updateMessage(t.id,{text:d+a,metadata:Object.assign(Object.assign({},t.metadata),{renderAsHtml:!0,hasArtifacts:!0,artifactIds:s.map(t=>t.id),artifactOriginalText:i})})}rebuildArtifactsFromMetadata(t){var e,i;const n=null===(e=t.metadata)||void 0===e?void 0:e.artifactIds;if(!(null==n?void 0:n.length))return;if(n.every(t=>this.artifacts.has(t)))return;const o=null===(i=t.metadata)||void 0===i?void 0:i.artifactOriginalText;if(!o)return;const s=/```(\w*)\n([\s\S]*?)```/g;let r,a=0;for(;null!==(r=s.exec(o));){const e=(r[1]||"text").toLowerCase(),i=r[2],n=`artifact-${t.id}-${a}`,o=this.extractTitle(i,e,a);this.artifacts.set(n,{id:n,language:e,content:i,title:o,messageId:t.id,index:a}),a++}}getArtifact(t){return this.artifacts.get(t)}getAllArtifacts(){return Array.from(this.artifacts.values())}getArtifactsForMessage(t){return Array.from(this.artifacts.values()).filter(e=>e.messageId===t)}processNow(t){var e;if(!this.controller||"function"!=typeof this.controller.getMessages)return!1;const i=(this.controller.getMessages()||[]).find(e=>e.id===t);return!(!i||i.sender!==q.Bot)&&((null===(e=i.metadata)||void 0===e?void 0:e.hasArtifacts)?(this.rebuildArtifactsFromMetadata(i),!0):(this.processMessage(i),!0))}extractTitle(t,e,i){const n=t.trimStart().split("\n")[0]||"",o=[/^\/\/\s*(.+)/,/^#\s*(.+)/,/^--\s*(.+)/,/^\/\*\s*(.*?)\*\//,/^<!--\s*(.*?)-->/];for(const t of o){const e=t.exec(n);if(null==e?void 0:e[1]){const t=e[1].trim();if(t.length>0&&t.length<=60)return t}}return`${dt(e)} Snippet ${i+1}`}renderPlaceholderCard(t){const e=dt(t.language),i=at(t.title);return`<div class="nr-artifact-card" data-artifact-id="${t.id}" role="button" tabindex="0" aria-label="View ${i}">\n <nr-icon name="code" size="small" class="nr-artifact-card__icon"></nr-icon>\n <span class="nr-artifact-card__info">\n <span class="nr-artifact-card__title">${i}</span>\n <nr-tag size="small" class="nr-artifact-card__lang">${e}</nr-tag>\n </span>\n <nr-icon name="chevron-right" size="small" class="nr-artifact-card__chevron"></nr-icon>\n</div>`}getStyles(){return"\n .nr-artifact-card {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n margin: 8px 0;\n background: #f6f8fa;\n border: 1px solid #d0d7de;\n border-radius: 8px;\n cursor: pointer;\n transition: background 0.15s ease, border-color 0.15s ease;\n user-select: none;\n max-width: 100%;\n }\n .nr-artifact-card:hover {\n background: #eaeef2;\n border-color: #8b949e;\n }\n .nr-artifact-card:focus-visible {\n outline: 2px solid #0b5fff;\n outline-offset: 2px;\n }\n .nr-artifact-card__icon {\n flex-shrink: 0;\n color: #57606a;\n }\n .nr-artifact-card__info {\n display: flex;\n flex-direction: column;\n gap: 4px;\n min-width: 0;\n flex: 1;\n }\n .nr-artifact-card__title {\n font-size: 13px;\n font-weight: 500;\n color: #1f2937;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n }\n .nr-artifact-card__lang {\n align-self: flex-start;\n }\n .nr-artifact-card__chevron {\n flex-shrink: 0;\n color: #6c757d;\n }\n "}}
2913
2922
  /**
2914
2923
  * @license
2915
2924
  * Copyright 2023 Nuraly, Laabidi Aymen
2916
2925
  * SPDX-License-Identifier: MIT
2917
- */class Be extends ze{constructor(){super(...arguments),this.id="json-graph-renderer",this.name="JSON Graph Renderer",this.version="1.0.0"}renderArtifactContent(t){if("json"!==t.language)return"";let e;try{e=JSON.parse(t.content)}catch(t){return""}if(null===e||"object"!=typeof e)return"";const i=Array.isArray(e)?e.map((t,e)=>this.renderNode(String(e),t)):Object.entries(e).map(([t,e])=>this.renderNode(t,e));return`\n <div style="padding:20px;font-family:system-ui,-apple-system,sans-serif;overflow:auto;">\n <div style="\n display:flex;align-items:center;gap:8px;\n margin-bottom:16px;padding-bottom:12px;\n border-bottom:1px solid #e2e8f0;\n ">\n <span style="\n display:inline-flex;align-items:center;justify-content:center;\n width:28px;height:28px;border-radius:6px;\n background:linear-gradient(135deg,#0ea5e9,#8b5cf6);\n color:#fff;font-size:14px;font-weight:700;\n ">{}</span>\n <span style="font-size:15px;font-weight:600;color:#1e293b;">\n JSON Graph View\n </span>\n <span style="\n margin-left:auto;font-size:12px;padding:2px 8px;border-radius:10px;\n background:#f1f5f9;color:#64748b;\n ">${Array.isArray(e)?e.length:Object.keys(e).length} root keys</span>\n </div>\n ${i.join("")}\n </div>\n `}renderNode(t,e,i=0){const n=null!==e&&"object"==typeof e&&!Array.isArray(e),o=Array.isArray(e),s=24*i;if(!n&&!o)return`\n <div style="display:flex;align-items:center;gap:8px;margin-left:${s}px;margin-bottom:6px;">\n <span style="\n display:inline-block;width:8px;height:8px;border-radius:50%;\n background:${this.typeColor(e)};flex-shrink:0;\n "></span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${at(t)}\n </span>\n <span style="\n font-size:13px;padding:2px 8px;border-radius:4px;\n background:${this.typeBg(e)};color:${this.typeColor(e)};\n border:1px solid ${this.typeColor(e)}20;\n ">${at(this.formatValue(e))}</span>\n </div>\n `;const r=o?e.map((t,e)=>[String(e),t]):Object.entries(e),a=o?`[ ${r.length} ]`:`{ ${r.length} }`,l=o?"#8b5cf6":"#0ea5e9";return`\n <div style="margin-left:${s}px;margin-bottom:4px;">\n <div style="display:flex;align-items:center;gap:8px;margin-bottom:4px;">\n <span style="\n display:inline-flex;align-items:center;justify-content:center;\n width:20px;height:20px;border-radius:4px;\n background:${l}15;color:${l};font-size:11px;font-weight:700;\n border:1px solid ${l}30;\n ">${o?"[]":"{}"}</span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${at(t)}\n </span>\n <span style="\n font-size:11px;padding:1px 6px;border-radius:10px;\n background:${l}10;color:${l};font-weight:500;\n ">${a}</span>\n </div>\n <div style="margin-left:9px;padding-left:16px;border-left:2px solid #e2e8f0;">\n ${r.map(([t,e])=>this.renderNode(t,e,0)).join("")}\n </div>\n </div>\n `}typeColor(t){if(null===t)return"#94a3b8";switch(typeof t){case"string":return"#22c55e";case"number":return"#3b82f6";case"boolean":return"#f59e0b";default:return"#94a3b8"}}typeBg(t){if(null===t)return"#f1f5f9";switch(typeof t){case"string":return"#f0fdf4";case"number":return"#eff6ff";case"boolean":return"#fffbeb";default:return"#f1f5f9"}}formatValue(t){return null==t?"null":"string"==typeof t?`"${t}"`:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}}
2926
+ */class Be extends Oe{constructor(){super(...arguments),this.id="json-graph-renderer",this.name="JSON Graph Renderer",this.version="1.0.0"}renderArtifactContent(t){if("json"!==t.language)return"";let e;try{e=JSON.parse(t.content)}catch(t){return""}if(null===e||"object"!=typeof e)return"";const i=Array.isArray(e)?e.map((t,e)=>this.renderNode(String(e),t)):Object.entries(e).map(([t,e])=>this.renderNode(t,e));return`\n <div style="padding:20px;font-family:system-ui,-apple-system,sans-serif;overflow:auto;">\n <div style="\n display:flex;align-items:center;gap:8px;\n margin-bottom:16px;padding-bottom:12px;\n border-bottom:1px solid #e2e8f0;\n ">\n <span style="\n display:inline-flex;align-items:center;justify-content:center;\n width:28px;height:28px;border-radius:6px;\n background:linear-gradient(135deg,#0ea5e9,#8b5cf6);\n color:#fff;font-size:14px;font-weight:700;\n ">{}</span>\n <span style="font-size:15px;font-weight:600;color:#1e293b;">\n JSON Graph View\n </span>\n <span style="\n margin-left:auto;font-size:12px;padding:2px 8px;border-radius:10px;\n background:#f1f5f9;color:#64748b;\n ">${Array.isArray(e)?e.length:Object.keys(e).length} root keys</span>\n </div>\n ${i.join("")}\n </div>\n `}renderNode(t,e,i=0){const n=null!==e&&"object"==typeof e&&!Array.isArray(e),o=Array.isArray(e),s=24*i;if(!n&&!o)return`\n <div style="display:flex;align-items:center;gap:8px;margin-left:${s}px;margin-bottom:6px;">\n <span style="\n display:inline-block;width:8px;height:8px;border-radius:50%;\n background:${this.typeColor(e)};flex-shrink:0;\n "></span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${at(t)}\n </span>\n <span style="\n font-size:13px;padding:2px 8px;border-radius:4px;\n background:${this.typeBg(e)};color:${this.typeColor(e)};\n border:1px solid ${this.typeColor(e)}20;\n ">${at(this.formatValue(e))}</span>\n </div>\n `;const r=o?e.map((t,e)=>[String(e),t]):Object.entries(e),a=o?`[ ${r.length} ]`:`{ ${r.length} }`,l=o?"#8b5cf6":"#0ea5e9";return`\n <div style="margin-left:${s}px;margin-bottom:4px;">\n <div style="display:flex;align-items:center;gap:8px;margin-bottom:4px;">\n <span style="\n display:inline-flex;align-items:center;justify-content:center;\n width:20px;height:20px;border-radius:4px;\n background:${l}15;color:${l};font-size:11px;font-weight:700;\n border:1px solid ${l}30;\n ">${o?"[]":"{}"}</span>\n <span style="font-weight:600;font-size:13px;color:#334155;">\n ${at(t)}\n </span>\n <span style="\n font-size:11px;padding:1px 6px;border-radius:10px;\n background:${l}10;color:${l};font-weight:500;\n ">${a}</span>\n </div>\n <div style="margin-left:9px;padding-left:16px;border-left:2px solid #e2e8f0;">\n ${r.map(([t,e])=>this.renderNode(t,e,0)).join("")}\n </div>\n </div>\n `}typeColor(t){if(null===t)return"#94a3b8";switch(typeof t){case"string":return"#22c55e";case"number":return"#3b82f6";case"boolean":return"#f59e0b";default:return"#94a3b8"}}typeBg(t){if(null===t)return"#f1f5f9";switch(typeof t){case"string":return"#f0fdf4";case"number":return"#eff6ff";case"boolean":return"#fffbeb";default:return"#f1f5f9"}}formatValue(t){return null==t?"null":"string"==typeof t?`"${t}"`:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}}
2918
2927
  /**
2919
2928
  * @license
2920
2929
  * Copyright 2023 Nuraly, Laabidi Aymen
2921
2930
  * SPDX-License-Identifier: MIT
2922
- */const Ne="nuraly:flow-diagram:split-width",Ue="nuraly:flow-diagram:panel-width",We="nr-flow-diagram-editor";class He extends HTMLElement{connectedCallback(){var t;const e=this.loadPanelWidth(),i=this.closestPanel();i&&(i.style.setProperty("width",`${e}px`),this._panelObserver=new ResizeObserver(()=>{const t=Math.round(i.getBoundingClientRect().width);t>=200&&localStorage.setItem(Ue,String(t))}),this._panelObserver.observe(i));const n=this.attachShadow({mode:"open"}),o=null!==(t=this.getAttribute("content"))&&void 0!==t?t:"",s=this.unescapeHtml(o),r=this.prettyPrint(s);let a=null;try{a=JSON.parse(s)}catch(t){}n.innerHTML=`\n <style>${He.styles()}</style>\n ${this.renderHeader(a)}\n <div class="split">\n <div class="editor-pane">\n <textarea class="editor-textarea" spellcheck="false"></textarea>\n </div>\n <div class="resize-handle"><div class="resize-handle-bar"></div></div>\n <div class="diagram-pane">\n ${a?this.renderDiagram(a):'<div class="empty">Invalid JSON</div>'}\n </div>\n </div>\n <div class="error-bar" style="display:none;"></div>\n `;const l=n.querySelector(".editor-textarea");l&&(l.value=r);const d=localStorage.getItem(Ne);d&&requestAnimationFrame(()=>{const t=n.querySelector(".editor-pane");t&&(t.style.flex="none",t.style.width=`${d}px`)});const c=n.querySelector(".diagram-pane"),h=n.querySelector(".error-bar");l&&c&&h&&(l.addEventListener("input",()=>{try{const t=JSON.parse(l.value);if(t.Steps&&t.Transitions){c.innerHTML=this.renderDiagram(t);const e=n.querySelector(".header");if(e){const i=document.createElement("template");i.innerHTML=this.renderHeader(t).trim();const n=i.content.firstElementChild;n&&e.replaceWith(n)}}h.style.display="none"}catch(t){h.textContent=`Parse error: ${t.message}`,h.style.display="flex"}}),this.initResize(n))}disconnectedCallback(){var t,e;null===(t=this._panelObserver)||void 0===t||t.disconnect(),null===(e=this.closestPanel())||void 0===e||e.style.removeProperty("width")}loadPanelWidth(){const t=localStorage.getItem(Ue);return t?Math.max(300,Number.parseInt(t,10)):500}closestPanel(){var t,e,i,n;let o=null!==(e=null!==(t=this.parentElement)&&void 0!==t?t:this.getRootNode().host)&&void 0!==e?e:null;for(;o;){if(o instanceof HTMLElement&&o.classList.contains("artifact-panel"))return o;o=null!==(n=null!==(i=o.parentElement)&&void 0!==i?i:o.getRootNode().host)&&void 0!==n?n:null}return null}initResize(t){const e=t.querySelector(".split"),i=t.querySelector(".editor-pane"),n=t.querySelector(".resize-handle");if(!e||!i||!n)return;let o=!1,s=0,r=0;const a=t=>{if(!o)return;const n=t.clientX-s,a=e.getBoundingClientRect().width,l=Math.max(200,Math.min(r+n,a-200));i.style.flex="none",i.style.width=`${l}px`},l=()=>{if(!o)return;o=!1,n.classList.remove("active"),document.body.style.cursor="",document.body.style.userSelect="";const t=Math.round(i.getBoundingClientRect().width);t>=200&&localStorage.setItem(Ne,String(t)),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l)};n.addEventListener("mousedown",t=>{const e=t;e.preventDefault(),o=!0,s=e.clientX,r=i.getBoundingClientRect().width,n.classList.add("active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",a),document.addEventListener("mouseup",l)})}prettyPrint(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch(e){return t}}unescapeHtml(t){const e=document.createElement("textarea");return e.innerHTML=t,e.value}renderHeader(t){var e,i;const n=null!==(e=null==t?void 0:t.Name)&&void 0!==e?e:"Workflow",o=(null!==(i=null==t?void 0:t.DocflowTags)&&void 0!==i?i:[]).map(t=>`<span class="tag">${at(t)}</span>`).join("");return`\n <div class="header">\n <span class="header-icon">&#x2B21;</span>\n <span class="header-name">${at(n)}</span>\n ${o}\n </div>\n `}renderDiagram(t){var e,i;const n=this.buildOrderedSteps(t),o=[];for(let t=0;t<n.length;t++){const s=n[t];o.push("event"===s.type?this.renderEventNode(s.name,null!==(e=s.eventType)&&void 0!==e?e:""):this.renderStepNode(s.name,null!==(i=s.step)&&void 0!==i?i:{})),t<n.length-1&&o.push(this.renderConnector())}return`<div class="diagram">${o.join("")}</div>`}buildOrderedSteps(t){var e,i,n,o;const s=[],r=null===(e=t.Events)||void 0===e?void 0:e.StartEvent,a=null===(i=t.Events)||void 0===i?void 0:i.EndEvent;r&&s.push({type:"event",name:r.Name||"Start",eventType:"start"});const l={};for(const e of Object.values(t.Transitions))l[e.Source]=e;let d=null!==(o=null===(n=l.StartEvent)||void 0===n?void 0:n.Target)&&void 0!==o?o:Object.keys(t.Steps)[0];const c=new Set;for(;d&&t.Steps[d]&&!c.has(d);){c.add(d),s.push({type:"step",name:d,step:t.Steps[d]});const e=l[d];if(!e||"EndEvent"===e.Target)break;d=e.Target}return a&&s.push({type:"event",name:a.Name||"End",eventType:"end"}),s}renderEventNode(t,e){const i="start"===e;return`\n <div class="node event-node ${i?"event-start":"event-end"}">\n <span class="event-icon">${i?"&#9679;":"&#9632;"}</span>\n <span class="event-label">${at(t)}</span>\n </div>\n `}renderStepNode(t,e){var i,n,o;const s=null!==(i=e.StepType)&&void 0!==i?i:"",r=null!==(o=null===(n=e.Description)||void 0===n?void 0:n.trim())&&void 0!==o?o:"",a=s?`<span class="step-badge ${"Worker"===s?"badge-worker":"badge-system"}">${at(s)}</span>`:"",l=r?`<div class="step-desc">${at(r)}</div>`:"";return`\n <div class="node step-node">\n <div class="step-header">\n <span class="step-name">${at(t)}</span>\n ${a}\n </div>\n ${l}\n </div>\n `}renderConnector(){return'\n <div class="connector">\n <div class="connector-line"></div>\n <div class="connector-arrow">&#9660;</div>\n </div>\n '}static styles(){return"\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n min-width: 480px;\n height: 100%;\n font-family: system-ui, -apple-system, sans-serif;\n color: #1e293b;\n overflow: hidden;\n }\n\n .header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n border-bottom: 1px solid #e2e8f0;\n background: #f8fafc;\n flex-shrink: 0;\n }\n .header-icon { font-size: 18px; color: #6366f1; }\n .header-name { font-weight: 600; font-size: 15px; }\n .tag {\n font-size: 11px;\n padding: 2px 8px;\n border-radius: 10px;\n background: #ede9fe;\n color: #6366f1;\n font-weight: 500;\n }\n\n .split {\n display: flex;\n flex: 1;\n min-height: 0;\n }\n\n .editor-pane {\n flex: 1;\n min-width: 200px;\n display: flex;\n overflow: hidden;\n }\n .editor-textarea {\n flex: 1;\n width: 100%;\n height: 100%;\n border: none;\n outline: none;\n resize: none;\n padding: 12px;\n font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;\n font-size: 12px;\n line-height: 1.6;\n color: #1e293b;\n background: #ffffff;\n box-sizing: border-box;\n tab-size: 2;\n }\n\n /* ── Resize handle ──────────────────────────────── */\n\n .resize-handle {\n flex-shrink: 0;\n width: 8px;\n cursor: col-resize;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f1f5f9;\n border-left: 1px solid #e2e8f0;\n border-right: 1px solid #e2e8f0;\n transition: background 0.15s;\n }\n .resize-handle:hover,\n .resize-handle.active { background: #e2e8f0; }\n .resize-handle-bar {\n width: 2px;\n height: 24px;\n border-radius: 1px;\n background: #cbd5e1;\n transition: background 0.15s;\n }\n .resize-handle:hover .resize-handle-bar,\n .resize-handle.active .resize-handle-bar { background: #94a3b8; }\n\n .diagram-pane {\n flex: 1;\n min-width: 200px;\n overflow-y: auto;\n padding: 24px;\n background: #f8fafc;\n }\n\n .diagram {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: #94a3b8;\n font-size: 14px;\n }\n\n /* ── Event nodes ──────────────────────────────────── */\n\n .event-node {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 20px;\n border-radius: 20px;\n font-size: 13px;\n font-weight: 600;\n }\n .event-start { background: #ecfdf5; border: 1.5px solid #86efac; color: #166534; }\n .event-start .event-icon { color: #22c55e; font-size: 10px; }\n .event-end { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; }\n .event-end .event-icon { color: #ef4444; font-size: 10px; }\n\n /* ── Step nodes ───────────────────────────────────── */\n\n .step-node {\n width: 220px;\n padding: 12px 16px;\n border-radius: 8px;\n background: #ffffff;\n border: 1.5px solid #e2e8f0;\n box-shadow: 0 1px 3px rgba(0,0,0,0.06);\n }\n .step-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n .step-name { font-weight: 600; font-size: 13px; color: #1e293b; }\n .step-badge {\n font-size: 10px;\n padding: 2px 6px;\n border-radius: 4px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.02em;\n flex-shrink: 0;\n }\n .badge-worker { background: #dbeafe; color: #1d4ed8; }\n .badge-system { background: #fef3c7; color: #92400e; }\n .step-desc { margin-top: 6px; font-size: 11px; color: #64748b; line-height: 1.4; }\n\n /* ── Connectors ───────────────────────────────────── */\n\n .connector {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 32px;\n }\n .connector-line { width: 2px; flex: 1; background: #cbd5e1; }\n .connector-arrow { font-size: 8px; color: #cbd5e1; line-height: 1; margin-top: -2px; }\n\n /* ── Error bar ────────────────────────────────────── */\n\n .error-bar {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 16px;\n background: #fef2f2;\n border-top: 1px solid #fecaca;\n color: #dc2626;\n font-size: 12px;\n flex-shrink: 0;\n }\n .error-bar::before { content: '⚠'; }\n "}}class Je extends ze{constructor(){super(...arguments),this.id="flow-diagram",this.name="Flow Diagram",this.version="1.0.0"}onInit(){customElements.get(We)||customElements.define(We,He)}renderArtifactContent(t){if("json"!==t.language)return"";let e;try{e=JSON.parse(t.content)}catch(t){return""}return null!==e&&"object"==typeof e&&e.Steps&&"object"==typeof e.Steps&&e.Transitions&&"object"==typeof e.Transitions?`<nr-flow-diagram-editor content="${at(t.content)}"></nr-flow-diagram-editor>`:""}}
2931
+ */const Ne="nuraly:flow-diagram:split-width",Ue="nuraly:flow-diagram:panel-width",We="nr-flow-diagram-editor";class He extends HTMLElement{connectedCallback(){var t;const e=this.loadPanelWidth(),i=this.closestPanel();i&&(i.style.setProperty("width",`${e}px`),this._panelObserver=new ResizeObserver(()=>{const t=Math.round(i.getBoundingClientRect().width);t>=200&&localStorage.setItem(Ue,String(t))}),this._panelObserver.observe(i));const n=this.attachShadow({mode:"open"}),o=null!==(t=this.getAttribute("content"))&&void 0!==t?t:"",s=this.unescapeHtml(o),r=this.prettyPrint(s);let a=null;try{a=JSON.parse(s)}catch(t){}n.innerHTML=`\n <style>${He.styles()}</style>\n ${this.renderHeader(a)}\n <div class="split">\n <div class="editor-pane">\n <textarea class="editor-textarea" spellcheck="false"></textarea>\n </div>\n <div class="resize-handle"><div class="resize-handle-bar"></div></div>\n <div class="diagram-pane">\n ${a?this.renderDiagram(a):'<div class="empty">Invalid JSON</div>'}\n </div>\n </div>\n <div class="error-bar" style="display:none;"></div>\n `;const l=n.querySelector(".editor-textarea");l&&(l.value=r);const d=localStorage.getItem(Ne);d&&requestAnimationFrame(()=>{const t=n.querySelector(".editor-pane");t&&(t.style.flex="none",t.style.width=`${d}px`)});const c=n.querySelector(".diagram-pane"),h=n.querySelector(".error-bar");l&&c&&h&&(l.addEventListener("input",()=>{try{const t=JSON.parse(l.value);if(t.Steps&&t.Transitions){c.innerHTML=this.renderDiagram(t);const e=n.querySelector(".header");if(e){const i=document.createElement("template");i.innerHTML=this.renderHeader(t).trim();const n=i.content.firstElementChild;n&&e.replaceWith(n)}}h.style.display="none"}catch(t){h.textContent=`Parse error: ${t.message}`,h.style.display="flex"}}),this.initResize(n))}disconnectedCallback(){var t,e;null===(t=this._panelObserver)||void 0===t||t.disconnect(),null===(e=this.closestPanel())||void 0===e||e.style.removeProperty("width")}loadPanelWidth(){const t=localStorage.getItem(Ue);return t?Math.max(300,Number.parseInt(t,10)):500}closestPanel(){var t,e,i,n;let o=null!==(e=null!==(t=this.parentElement)&&void 0!==t?t:this.getRootNode().host)&&void 0!==e?e:null;for(;o;){if(o instanceof HTMLElement&&o.classList.contains("artifact-panel"))return o;o=null!==(n=null!==(i=o.parentElement)&&void 0!==i?i:o.getRootNode().host)&&void 0!==n?n:null}return null}initResize(t){const e=t.querySelector(".split"),i=t.querySelector(".editor-pane"),n=t.querySelector(".resize-handle");if(!e||!i||!n)return;let o=!1,s=0,r=0;const a=t=>{if(!o)return;const n=t.clientX-s,a=e.getBoundingClientRect().width,l=Math.max(200,Math.min(r+n,a-200));i.style.flex="none",i.style.width=`${l}px`},l=()=>{if(!o)return;o=!1,n.classList.remove("active"),document.body.style.cursor="",document.body.style.userSelect="";const t=Math.round(i.getBoundingClientRect().width);t>=200&&localStorage.setItem(Ne,String(t)),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l)};n.addEventListener("mousedown",t=>{const e=t;e.preventDefault(),o=!0,s=e.clientX,r=i.getBoundingClientRect().width,n.classList.add("active"),document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",a),document.addEventListener("mouseup",l)})}prettyPrint(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch(e){return t}}unescapeHtml(t){const e=document.createElement("textarea");return e.innerHTML=t,e.value}renderHeader(t){var e,i;const n=null!==(e=null==t?void 0:t.Name)&&void 0!==e?e:"Workflow",o=(null!==(i=null==t?void 0:t.DocflowTags)&&void 0!==i?i:[]).map(t=>`<span class="tag">${at(t)}</span>`).join("");return`\n <div class="header">\n <span class="header-icon">&#x2B21;</span>\n <span class="header-name">${at(n)}</span>\n ${o}\n </div>\n `}renderDiagram(t){var e,i;const n=this.buildOrderedSteps(t),o=[];for(let t=0;t<n.length;t++){const s=n[t];o.push("event"===s.type?this.renderEventNode(s.name,null!==(e=s.eventType)&&void 0!==e?e:""):this.renderStepNode(s.name,null!==(i=s.step)&&void 0!==i?i:{})),t<n.length-1&&o.push(this.renderConnector())}return`<div class="diagram">${o.join("")}</div>`}buildOrderedSteps(t){var e,i,n,o;const s=[],r=null===(e=t.Events)||void 0===e?void 0:e.StartEvent,a=null===(i=t.Events)||void 0===i?void 0:i.EndEvent;r&&s.push({type:"event",name:r.Name||"Start",eventType:"start"});const l={};for(const e of Object.values(t.Transitions))l[e.Source]=e;let d=null!==(o=null===(n=l.StartEvent)||void 0===n?void 0:n.Target)&&void 0!==o?o:Object.keys(t.Steps)[0];const c=new Set;for(;d&&t.Steps[d]&&!c.has(d);){c.add(d),s.push({type:"step",name:d,step:t.Steps[d]});const e=l[d];if(!e||"EndEvent"===e.Target)break;d=e.Target}return a&&s.push({type:"event",name:a.Name||"End",eventType:"end"}),s}renderEventNode(t,e){const i="start"===e;return`\n <div class="node event-node ${i?"event-start":"event-end"}">\n <span class="event-icon">${i?"&#9679;":"&#9632;"}</span>\n <span class="event-label">${at(t)}</span>\n </div>\n `}renderStepNode(t,e){var i,n,o;const s=null!==(i=e.StepType)&&void 0!==i?i:"",r=null!==(o=null===(n=e.Description)||void 0===n?void 0:n.trim())&&void 0!==o?o:"",a=s?`<span class="step-badge ${"Worker"===s?"badge-worker":"badge-system"}">${at(s)}</span>`:"",l=r?`<div class="step-desc">${at(r)}</div>`:"";return`\n <div class="node step-node">\n <div class="step-header">\n <span class="step-name">${at(t)}</span>\n ${a}\n </div>\n ${l}\n </div>\n `}renderConnector(){return'\n <div class="connector">\n <div class="connector-line"></div>\n <div class="connector-arrow">&#9660;</div>\n </div>\n '}static styles(){return"\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n min-width: 480px;\n height: 100%;\n font-family: system-ui, -apple-system, sans-serif;\n color: #1e293b;\n overflow: hidden;\n }\n\n .header {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 16px;\n border-bottom: 1px solid #e2e8f0;\n background: #f8fafc;\n flex-shrink: 0;\n }\n .header-icon { font-size: 18px; color: #6366f1; }\n .header-name { font-weight: 600; font-size: 15px; }\n .tag {\n font-size: 11px;\n padding: 2px 8px;\n border-radius: 10px;\n background: #ede9fe;\n color: #6366f1;\n font-weight: 500;\n }\n\n .split {\n display: flex;\n flex: 1;\n min-height: 0;\n }\n\n .editor-pane {\n flex: 1;\n min-width: 200px;\n display: flex;\n overflow: hidden;\n }\n .editor-textarea {\n flex: 1;\n width: 100%;\n height: 100%;\n border: none;\n outline: none;\n resize: none;\n padding: 12px;\n font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;\n font-size: 12px;\n line-height: 1.6;\n color: #1e293b;\n background: #ffffff;\n box-sizing: border-box;\n tab-size: 2;\n }\n\n /* ── Resize handle ──────────────────────────────── */\n\n .resize-handle {\n flex-shrink: 0;\n width: 8px;\n cursor: col-resize;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #f1f5f9;\n border-left: 1px solid #e2e8f0;\n border-right: 1px solid #e2e8f0;\n transition: background 0.15s;\n }\n .resize-handle:hover,\n .resize-handle.active { background: #e2e8f0; }\n .resize-handle-bar {\n width: 2px;\n height: 24px;\n border-radius: 1px;\n background: #cbd5e1;\n transition: background 0.15s;\n }\n .resize-handle:hover .resize-handle-bar,\n .resize-handle.active .resize-handle-bar { background: #94a3b8; }\n\n .diagram-pane {\n flex: 1;\n min-width: 200px;\n overflow-y: auto;\n padding: 24px;\n background: #f8fafc;\n }\n\n .diagram {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .empty {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n color: #94a3b8;\n font-size: 14px;\n }\n\n /* ── Event nodes ──────────────────────────────────── */\n\n .event-node {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 20px;\n border-radius: 20px;\n font-size: 13px;\n font-weight: 600;\n }\n .event-start { background: #ecfdf5; border: 1.5px solid #86efac; color: #166534; }\n .event-start .event-icon { color: #22c55e; font-size: 10px; }\n .event-end { background: #fef2f2; border: 1.5px solid #fca5a5; color: #991b1b; }\n .event-end .event-icon { color: #ef4444; font-size: 10px; }\n\n /* ── Step nodes ───────────────────────────────────── */\n\n .step-node {\n width: 220px;\n padding: 12px 16px;\n border-radius: 8px;\n background: #ffffff;\n border: 1.5px solid #e2e8f0;\n box-shadow: 0 1px 3px rgba(0,0,0,0.06);\n }\n .step-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n .step-name { font-weight: 600; font-size: 13px; color: #1e293b; }\n .step-badge {\n font-size: 10px;\n padding: 2px 6px;\n border-radius: 4px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.02em;\n flex-shrink: 0;\n }\n .badge-worker { background: #dbeafe; color: #1d4ed8; }\n .badge-system { background: #fef3c7; color: #92400e; }\n .step-desc { margin-top: 6px; font-size: 11px; color: #64748b; line-height: 1.4; }\n\n /* ── Connectors ───────────────────────────────────── */\n\n .connector {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 32px;\n }\n .connector-line { width: 2px; flex: 1; background: #cbd5e1; }\n .connector-arrow { font-size: 8px; color: #cbd5e1; line-height: 1; margin-top: -2px; }\n\n /* ── Error bar ────────────────────────────────────── */\n\n .error-bar {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 8px 16px;\n background: #fef2f2;\n border-top: 1px solid #fecaca;\n color: #dc2626;\n font-size: 12px;\n flex-shrink: 0;\n }\n .error-bar::before { content: '⚠'; }\n "}}class Je extends Oe{constructor(){super(...arguments),this.id="flow-diagram",this.name="Flow Diagram",this.version="1.0.0"}onInit(){customElements.get(We)||customElements.define(We,He)}renderArtifactContent(t){if("json"!==t.language)return"";let e;try{e=JSON.parse(t.content)}catch(t){return""}return null!==e&&"object"==typeof e&&e.Steps&&"object"==typeof e.Steps&&e.Transitions&&"object"==typeof e.Transitions?`<nr-flow-diagram-editor content="${at(t.content)}"></nr-flow-diagram-editor>`:""}}
2923
2932
  /**
2924
2933
  * @license
2925
2934
  * Copyright 2023 Nuraly, Laabidi Aymen
2926
2935
  * SPDX-License-Identifier: MIT
2927
- */var qe=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class Ve extends ze{constructor(){super(...arguments),this.id="selection-card",this.name="Selection Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"selection",open:"[SELECTION]",close:"[/SELECTION]"}],this.cssPrefix="nr-selection-card"}renderHtmlBlockPlaceholder(t){if("selection"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`selection-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton\n active\n style="min-width: 300px; max-width: 500px; height: 80px; margin: 16px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[SelectionCardPlugin] Initialized")}afterReceive(t){return qe(this,void 0,void 0,function*(){try{const e=JSON.parse(t);if("selection"===e.type||this.isSelectionData(e))return this.renderSelectionCard(e)}catch(t){}const e=/\[SELECTION\]([\s\S]*?)\[\/SELECTION\]/g;let i,n=t;for(;null!==(i=e.exec(t));)try{const t=JSON.parse(i[1]),e=this.renderSelectionCard(t);n=n.replace(i[0],e)}catch(t){console.warn("[SelectionCardPlugin] Failed to parse selection data:",t)}return n})}renderHtmlBlock(t,e){if("selection"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderSelectionCard(t)}catch(t){return console.warn("[SelectionCardPlugin] renderHtmlBlock parse error:",t),""}}isSelectionData(t){return t&&"object"==typeof t&&Array.isArray(t.options)&&t.options.length>0&&t.options[0].label&&t.options[0].value}renderSelectionCard(t){const{title:e,options:i,columns:n=1}=t,o=this.getOncePerConversationStyleTag(this.getStyles()),s=i.map(t=>{const e=t.disabled?'aria-disabled="true"':"",i=t.disabled?`${this.cssPrefix}__option--disabled`:"",n=t.disabled?"-1":"0",o=t.disabled?"":`data-selection-value="${this.escapeHtml(t.value)}"`;return`\n <div class="${this.cssPrefix}__option ${i}"\n ${o}\n role="button"\n tabindex="${n}"\n ${e}>\n ${t.icon?`<nr-icon class="${this.cssPrefix}__option-icon" name="${this.escapeHtml(t.icon)}" size="small"></nr-icon>`:""}\n <div class="${this.cssPrefix}__option-content">\n <span class="${this.cssPrefix}__option-label">${this.escapeHtml(t.label)}</span>\n ${t.description?`<span class="${this.cssPrefix}__option-description">${this.escapeHtml(t.description)}</span>`:""}\n </div>\n </div>\n `}).join("");return`\n ${o}\n <div class="${this.cssPrefix}" data-nr-selection-card="true">\n ${e?`<div class="${this.cssPrefix}__title">${this.escapeHtml(e)}</div>`:""}\n <div class="${this.cssPrefix}__grid ${this.cssPrefix}__grid--cols-${n}">\n ${s}\n </div>\n </div>\n `}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n margin: 12px 0;\n max-width: 500px;\n font-family: system-ui, -apple-system, sans-serif;\n }\n\n .${this.cssPrefix}__title {\n font-size: 14px;\n font-weight: 600;\n color: #1a1a1a;\n margin-bottom: 10px;\n }\n\n .${this.cssPrefix}__grid {\n display: grid;\n gap: 8px;\n }\n\n .${this.cssPrefix}__grid--cols-1 {\n grid-template-columns: 1fr;\n }\n\n .${this.cssPrefix}__grid--cols-2 {\n grid-template-columns: 1fr 1fr;\n }\n\n .${this.cssPrefix}__grid--cols-3 {\n grid-template-columns: 1fr 1fr 1fr;\n }\n\n .${this.cssPrefix}__option {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 16px;\n background: #ffffff;\n border: 1px solid #e0e0e0;\n border-radius: 10px;\n cursor: pointer;\n transition: all 0.15s ease;\n user-select: none;\n -webkit-user-select: none;\n }\n\n .${this.cssPrefix}__option:hover {\n border-color: #4f8cff;\n background: #f0f6ff;\n box-shadow: 0 1px 4px rgba(79, 140, 255, 0.12);\n }\n\n .${this.cssPrefix}__option:focus-visible {\n outline: 2px solid #4f8cff;\n outline-offset: 2px;\n }\n\n .${this.cssPrefix}__option:active:not([aria-disabled="true"]) {\n transform: scale(0.98);\n background: #dfeaff;\n }\n\n .${this.cssPrefix}__option--disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .${this.cssPrefix}__option-icon {\n flex-shrink: 0;\n color: #555;\n }\n\n .${this.cssPrefix}__option-content {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n }\n\n .${this.cssPrefix}__option-label {\n font-size: 14px;\n font-weight: 500;\n color: #1a1a1a;\n line-height: 1.3;\n }\n\n .${this.cssPrefix}__option-description {\n font-size: 12px;\n color: #666;\n line-height: 1.3;\n }\n\n /* Responsive: force single column on mobile */\n @media (max-width: 480px) {\n .${this.cssPrefix}__grid--cols-2,\n .${this.cssPrefix}__grid--cols-3 {\n grid-template-columns: 1fr;\n }\n }\n `}}
2936
+ */var qe=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};class Ve extends Oe{constructor(){super(...arguments),this.id="selection-card",this.name="Selection Card Plugin",this.version="1.0.0",this.htmlTags=[{name:"selection",open:"[SELECTION]",close:"[/SELECTION]"}],this.cssPrefix="nr-selection-card"}renderHtmlBlockPlaceholder(t){if("selection"!==t.toLowerCase())return"";return`<div data-placeholder-id="${`selection-skeleton-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}"><nr-skeleton\n active\n style="min-width: 300px; max-width: 500px; height: 80px; margin: 16px 0;"\n ></nr-skeleton></div>`}onInit(){console.log("[SelectionCardPlugin] Initialized")}afterReceive(t){return qe(this,void 0,void 0,function*(){try{const e=JSON.parse(t);if("selection"===e.type||this.isSelectionData(e))return this.renderSelectionCard(e)}catch(t){}const e=/\[SELECTION\]([\s\S]*?)\[\/SELECTION\]/g;let i,n=t;for(;null!==(i=e.exec(t));)try{const t=JSON.parse(i[1]),e=this.renderSelectionCard(t);n=n.replace(i[0],e)}catch(t){console.warn("[SelectionCardPlugin] Failed to parse selection data:",t)}return n})}renderHtmlBlock(t,e){if("selection"!==t.toLowerCase())return"";try{const t=JSON.parse(e);return this.renderSelectionCard(t)}catch(t){return console.warn("[SelectionCardPlugin] renderHtmlBlock parse error:",t),""}}isSelectionData(t){return t&&"object"==typeof t&&Array.isArray(t.options)&&t.options.length>0&&t.options[0].label&&t.options[0].value}renderSelectionCard(t){const{title:e,options:i,columns:n=1}=t,o=this.getOncePerConversationStyleTag(this.getStyles()),s=i.map(t=>{const e=t.disabled?'aria-disabled="true"':"",i=t.disabled?`${this.cssPrefix}__option--disabled`:"",n=t.disabled?"-1":"0",o=t.disabled?"":`data-selection-value="${this.escapeHtml(t.value)}"`;return`\n <div class="${this.cssPrefix}__option ${i}"\n ${o}\n role="button"\n tabindex="${n}"\n ${e}>\n ${t.icon?`<nr-icon class="${this.cssPrefix}__option-icon" name="${this.escapeHtml(t.icon)}" size="small"></nr-icon>`:""}\n <div class="${this.cssPrefix}__option-content">\n <span class="${this.cssPrefix}__option-label">${this.escapeHtml(t.label)}</span>\n ${t.description?`<span class="${this.cssPrefix}__option-description">${this.escapeHtml(t.description)}</span>`:""}\n </div>\n </div>\n `}).join("");return`\n ${o}\n <div class="${this.cssPrefix}" data-nr-selection-card="true">\n ${e?`<div class="${this.cssPrefix}__title">${this.escapeHtml(e)}</div>`:""}\n <div class="${this.cssPrefix}__grid ${this.cssPrefix}__grid--cols-${n}">\n ${s}\n </div>\n </div>\n `}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}getStyles(){return`\n .${this.cssPrefix} {\n margin: 12px 0;\n max-width: 500px;\n font-family: system-ui, -apple-system, sans-serif;\n }\n\n .${this.cssPrefix}__title {\n font-size: 14px;\n font-weight: 600;\n color: #1a1a1a;\n margin-bottom: 10px;\n }\n\n .${this.cssPrefix}__grid {\n display: grid;\n gap: 8px;\n }\n\n .${this.cssPrefix}__grid--cols-1 {\n grid-template-columns: 1fr;\n }\n\n .${this.cssPrefix}__grid--cols-2 {\n grid-template-columns: 1fr 1fr;\n }\n\n .${this.cssPrefix}__grid--cols-3 {\n grid-template-columns: 1fr 1fr 1fr;\n }\n\n .${this.cssPrefix}__option {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px 16px;\n background: #ffffff;\n border: 1px solid #e0e0e0;\n border-radius: 10px;\n cursor: pointer;\n transition: all 0.15s ease;\n user-select: none;\n -webkit-user-select: none;\n }\n\n .${this.cssPrefix}__option:hover {\n border-color: #4f8cff;\n background: #f0f6ff;\n box-shadow: 0 1px 4px rgba(79, 140, 255, 0.12);\n }\n\n .${this.cssPrefix}__option:focus-visible {\n outline: 2px solid #4f8cff;\n outline-offset: 2px;\n }\n\n .${this.cssPrefix}__option:active:not([aria-disabled="true"]) {\n transform: scale(0.98);\n background: #dfeaff;\n }\n\n .${this.cssPrefix}__option--disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .${this.cssPrefix}__option-icon {\n flex-shrink: 0;\n color: #555;\n }\n\n .${this.cssPrefix}__option-content {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n }\n\n .${this.cssPrefix}__option-label {\n font-size: 14px;\n font-weight: 500;\n color: #1a1a1a;\n line-height: 1.3;\n }\n\n .${this.cssPrefix}__option-description {\n font-size: 12px;\n color: #666;\n line-height: 1.3;\n }\n\n /* Responsive: force single column on mobile */\n @media (max-width: 480px) {\n .${this.cssPrefix}__grid--cols-2,\n .${this.cssPrefix}__grid--cols-3 {\n grid-template-columns: 1fr;\n }\n }\n `}}
2928
2937
  /**
2929
2938
  * @license
2930
2939
  * Copyright 2023 Nuraly, Laabidi Aymen
@@ -2947,4 +2956,4 @@ var Qt=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){
2947
2956
  * Pipeline:
2948
2957
  * input blob → AudioContext.decodeAudioData → BufferSource → MediaStreamDestination
2949
2958
  * → MediaRecorder(ogg/opus, 32 kbps) → output blob
2950
- */var Ze=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};const ti="audio/ogg;codecs=opus";function ei(){try{return"undefined"!=typeof MediaRecorder&&MediaRecorder.isTypeSupported(ti)}catch(t){return!1}}var ii=Object.freeze({__proto__:null,canEncodeOgg:ei,compressToOpus:function(t,e){return Ze(this,void 0,void 0,function*(){if(!ei()){const i=e.includes("mp4")?"mp4":e.includes("aac")?"aac":"webm";return{blob:t,mimeType:e,ext:i}}const i=yield t.arrayBuffer(),n=new AudioContext;let o;try{o=yield n.decodeAudioData(i)}finally{n.close().catch(()=>{})}const s=new AudioContext({sampleRate:o.sampleRate}),r=s.createMediaStreamDestination(),a=new MediaRecorder(r.stream,{mimeType:ti,audioBitsPerSecond:32e3}),l=[];a.ondataavailable=t=>{t.data.size>0&&l.push(t.data)};const d=new Promise((t,e)=>{a.onstop=()=>t(),a.onerror=t=>{var i;return e(null!==(i=t.error)&&void 0!==i?i:new Error("MediaRecorder error"))}});a.start(100);const c=s.createBufferSource();return c.buffer=o,c.connect(r),c.onended=()=>{setTimeout(()=>{"recording"===a.state&&a.stop()},120)},c.start(0),yield d,s.close().catch(()=>{}),{blob:new Blob(l,{type:ti}),mimeType:ti,ext:"ogg"}})}});export{Oe as AnalyticsPlugin,De as ArtifactPlugin,ze as ChatPluginBase,X as ChatbotActionType,Xt as ChatbotCoreController,Q as ChatbotFileType,V as ChatbotLoadingType,Y as ChatbotMessageState,Xe as ChatbotScrollController,q as ChatbotSender,G as ChatbotSize,K as ChatbotVariant,re as CustomAPIProvider,ot as DEFAULT_ALLOWED_FILE_TYPES,nt as DEFAULT_MAX_FILES,it as DEFAULT_MAX_FILE_SIZE,et as DEFAULT_MAX_MESSAGES,tt as DEFAULT_TYPING_DELAY,Z as EMPTY_STRING,Ot as EventBus,st as FILE_TYPE_MAPPINGS,Ft as FileHandler,Ae as FlightCardPlugin,Je as FlowDiagramPlugin,Qe as IndexedDBStorage,Be as JsonGraphRendererPlugin,Ye as LocalStorageAdapter,je as MarkdownPlugin,Ke as MemoryStorage,jt as MessageHandler,pe as MockProvider,fe as MockProviders,Dt as ModuleHandler,Te as NativeWebSocketProvider,Ct as NrChatbotElement,ie as OpenAIProvider,Ce as PersistencePlugin,Gt as PluginService,Le as PrintJobCardPlugin,Ut as ProviderService,Ve as SelectionCardPlugin,ye as SocketProvider,It as StateHandler,qt as StorageService,Bt as SuggestionHandler,At as ThreadHandler,zt as ValidationError,Ht as ValidationService,$e as WorkflowSocketProvider};
2959
+ */var Ze=function(t,e,i,n){return new(i||(i=Promise))(function(o,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}l((n=n.apply(t,e||[])).next())})};const ti="audio/ogg;codecs=opus";function ei(){try{return"undefined"!=typeof MediaRecorder&&MediaRecorder.isTypeSupported(ti)}catch(t){return!1}}var ii=Object.freeze({__proto__:null,canEncodeOgg:ei,compressToOpus:function(t,e){return Ze(this,void 0,void 0,function*(){if(!ei()){const i=e.includes("mp4")?"mp4":e.includes("aac")?"aac":"webm";return{blob:t,mimeType:e,ext:i}}const i=yield t.arrayBuffer(),n=new AudioContext;let o;try{o=yield n.decodeAudioData(i)}finally{n.close().catch(()=>{})}const s=new AudioContext({sampleRate:o.sampleRate}),r=s.createMediaStreamDestination(),a=new MediaRecorder(r.stream,{mimeType:ti,audioBitsPerSecond:32e3}),l=[];a.ondataavailable=t=>{t.data.size>0&&l.push(t.data)};const d=new Promise((t,e)=>{a.onstop=()=>t(),a.onerror=t=>{var i;return e(null!==(i=t.error)&&void 0!==i?i:new Error("MediaRecorder error"))}});a.start(100);const c=s.createBufferSource();return c.buffer=o,c.connect(r),c.onended=()=>{setTimeout(()=>{"recording"===a.state&&a.stop()},120)},c.start(0),yield d,s.close().catch(()=>{}),{blob:new Blob(l,{type:ti}),mimeType:ti,ext:"ogg"}})}});export{ze as AnalyticsPlugin,De as ArtifactPlugin,Oe as ChatPluginBase,X as ChatbotActionType,Xt as ChatbotCoreController,Q as ChatbotFileType,V as ChatbotLoadingType,Y as ChatbotMessageState,Xe as ChatbotScrollController,q as ChatbotSender,G as ChatbotSize,K as ChatbotVariant,re as CustomAPIProvider,ot as DEFAULT_ALLOWED_FILE_TYPES,nt as DEFAULT_MAX_FILES,it as DEFAULT_MAX_FILE_SIZE,et as DEFAULT_MAX_MESSAGES,tt as DEFAULT_TYPING_DELAY,Z as EMPTY_STRING,zt as EventBus,st as FILE_TYPE_MAPPINGS,Ft as FileHandler,Ae as FlightCardPlugin,Je as FlowDiagramPlugin,Qe as IndexedDBStorage,Be as JsonGraphRendererPlugin,Ye as LocalStorageAdapter,je as MarkdownPlugin,Ke as MemoryStorage,jt as MessageHandler,pe as MockProvider,fe as MockProviders,Dt as ModuleHandler,Te as NativeWebSocketProvider,Ct as NrChatbotElement,ie as OpenAIProvider,Ce as PersistencePlugin,Gt as PluginService,Le as PrintJobCardPlugin,Ut as ProviderService,Ve as SelectionCardPlugin,ye as SocketProvider,It as StateHandler,qt as StorageService,Bt as SuggestionHandler,At as ThreadHandler,Ot as ValidationError,Ht as ValidationService,$e as WorkflowSocketProvider};