@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.
@@ -1,4 +1,4 @@
1
- import{css as e,LitElement as t,html as i,nothing as n,render as a,svg as o}from"lit";import{property as s,state as r,customElement as l,query as c}from"lit/decorators.js";import{styleMap as d}from"lit/directives/style-map.js";import{unsafeSVG as p}from"lit/directives/unsafe-svg.js";import{classMap as h}from"lit/directives/class-map.js";import{unsafeHTML as u}from"lit/directives/unsafe-html.js";import{repeat as b}from"lit/directives/repeat.js";import{io as f}from"socket.io-client";import{map as v}from"lit/directives/map.js";import{ifDefined as g}from"lit/directives/if-defined.js";import{createRef as m,ref as x}from"lit/directives/ref.js";import{CodeJar as y}from"codejar";import w from"highlight.js/lib/core";import $ from"highlight.js/lib/languages/javascript";import k from"highlight.js/lib/languages/typescript";import S from"highlight.js/lib/languages/json";import C from"highlight.js/lib/languages/xml";import T from"highlight.js/lib/languages/css";import M from"highlight.js/lib/languages/markdown";import E from"highlight.js/lib/languages/python";import A from"highlight.js/lib/languages/sql";import{choose as z}from"lit/directives/choose.js";var I=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s};let O=class extends t{constructor(){super(...arguments),this.nodes=[{id:1,x:100,y:100,label:"Node 1"},{id:2,x:300,y:150,label:"Node 2"},{id:4,x:600,y:250,label:"Node 3"}],this.connections=[{from:1,to:2}],this.activeNode=null,this.connectionStart=null,this.offsetX=0,this.offsetY=0,this.startPos=null,this.canvas=null,this.ctx=null,this.dragNode=e=>{this.activeNode&&(this.activeNode.x=e.clientX-this.offsetX,this.activeNode.y=e.clientY-this.offsetY,this.requestUpdate(),this.drawConnections())},this.stopDragging=()=>{this.activeNode=null,window.removeEventListener("mousemove",this.dragNode),window.removeEventListener("mouseup",this.stopDragging)}}render(){return i`
1
+ import{css as e,LitElement as t,html as i,nothing as n,render as a,svg as o}from"lit";import{property as s,state as r,customElement as l,query as c}from"lit/decorators.js";import{styleMap as d}from"lit/directives/style-map.js";import{unsafeSVG as p}from"lit/directives/unsafe-svg.js";import{classMap as h}from"lit/directives/class-map.js";import{unsafeHTML as u}from"lit/directives/unsafe-html.js";import{repeat as b}from"lit/directives/repeat.js";import{io as f}from"socket.io-client";import{map as v}from"lit/directives/map.js";import{ifDefined as g}from"lit/directives/if-defined.js";import{createRef as m,ref as y}from"lit/directives/ref.js";import{CodeJar as x}from"codejar";import w from"highlight.js/lib/core";import $ from"highlight.js/lib/languages/javascript";import k from"highlight.js/lib/languages/typescript";import S from"highlight.js/lib/languages/json";import C from"highlight.js/lib/languages/xml";import T from"highlight.js/lib/languages/css";import M from"highlight.js/lib/languages/markdown";import E from"highlight.js/lib/languages/python";import A from"highlight.js/lib/languages/sql";import{choose as z}from"lit/directives/choose.js";var I=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s};let O=class extends t{constructor(){super(...arguments),this.nodes=[{id:1,x:100,y:100,label:"Node 1"},{id:2,x:300,y:150,label:"Node 2"},{id:4,x:600,y:250,label:"Node 3"}],this.connections=[{from:1,to:2}],this.activeNode=null,this.connectionStart=null,this.offsetX=0,this.offsetY=0,this.startPos=null,this.canvas=null,this.ctx=null,this.dragNode=e=>{this.activeNode&&(this.activeNode.x=e.clientX-this.offsetX,this.activeNode.y=e.clientY-this.offsetY,this.requestUpdate(),this.drawConnections())},this.stopDragging=()=>{this.activeNode=null,window.removeEventListener("mousemove",this.dragNode),window.removeEventListener("mouseup",this.stopDragging)}}render(){return i`
2
2
  <div class="container">
3
3
  <div class="canvas-container">
4
4
  <!--button class="add-button" @click="${this.addNode}">+</button-->
@@ -108,7 +108,7 @@ var P,_;O.styles=e`
108
108
  * @license
109
109
  * Copyright 2023 Nuraly, Laabidi Aymen
110
110
  * SPDX-License-Identifier: MIT
111
- */const fe=e=>class extends e{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var e,t,i;super.disconnectedCallback(),null===(e=this.themeObserver)||void 0===e||e.disconnect(),null===(t=this.designSystemObserver)||void 0===t||t.disconnect(),null===(i=this.mediaQuery)||void 0===i||i.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var e,t;const i=(null===(e=this.closest("[data-theme]"))||void 0===e?void 0:e.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return i||((null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var e;const t=(null===(e=this.closest("[design-system]"))||void 0===e?void 0:e.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===t?t:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver(()=>{this.requestUpdate()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver(()=>{this.requestUpdate()}),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},ve=()=>{var e;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(e=process.env)||void 0===e?void 0:e.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},ge=e=>class extends e{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(ve())for(const e of this.requiredComponents)if(!this.isComponentAvailable(e))throw new Error(`Required component "${e}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${e}';`)}validateDependenciesWithHandler(e){if(!ve())return!0;let t=!0;for(const i of this.requiredComponents)if(!this.isComponentAvailable(i)){t=!1;const n=new Error(`Required component "${i}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);e?e(i,n):console.error(n.message)}return t}isComponentAvailable(e){return!!customElements.get(e)}getMissingDependencies(){return this.requiredComponents.filter(e=>!this.isComponentAvailable(e))}areDependenciesAvailable(){return this.requiredComponents.every(e=>this.isComponentAvailable(e))}addRequiredComponent(e){this.requiredComponents.includes(e)||this.requiredComponents.push(e)}removeRequiredComponent(e){const t=this.requiredComponents.indexOf(e);t>-1&&this.requiredComponents.splice(t,1)}},me=e=>class extends e{dispatchCustomEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(e,t){var i;const n=Object.assign(Object.assign({},t),{timestamp:Date.now(),componentName:(null===(i=this.tagName)||void 0===i?void 0:i.toLowerCase())||"unknown"});this.dispatchCustomEvent(e,n)}dispatchInputEvent(e,t){const i=Object.assign({target:t.target||this,value:t.value,originalEvent:t.originalEvent},t);this.dispatchCustomEvent(e,i)}dispatchFocusEvent(e,t){const i=Object.assign({target:t.target||this,value:t.value,focused:t.focused,cursorPosition:t.cursorPosition,selectedText:t.selectedText},t);this.dispatchCustomEvent(e,i)}dispatchValidationEvent(e,t){var i;const n=Object.assign({target:t.target||this,value:t.value,isValid:null!==(i=t.isValid)&&void 0!==i&&i,error:t.error},t);this.dispatchCustomEvent(e,n)}dispatchActionEvent(e,t){const i=Object.assign({target:t.target||this,action:t.action,previousValue:t.previousValue,newValue:t.newValue},t);this.dispatchCustomEvent(e,i)}isReadonlyKeyAllowed(e){if(e.ctrlKey||e.metaKey){return["KeyA","KeyC"].includes(e.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}isActivationKey(e){return"Enter"===e.key||" "===e.key}},xe=new Set,ye=new Map;
111
+ */const fe=e=>class extends e{constructor(){super(...arguments),this.handleSystemThemeChange=()=>{this.closest("[data-theme]")||document.documentElement.hasAttribute("data-theme")||this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this.setupThemeObserver(),this.setupDesignSystemObserver(),this.setupSystemThemeListener()}disconnectedCallback(){var e,t,i;super.disconnectedCallback(),null===(e=this.themeObserver)||void 0===e||e.disconnect(),null===(t=this.designSystemObserver)||void 0===t||t.disconnect(),null===(i=this.mediaQuery)||void 0===i||i.removeEventListener("change",this.handleSystemThemeChange)}get currentTheme(){var e,t;const i=(null===(e=this.closest("[data-theme]"))||void 0===e?void 0:e.getAttribute("data-theme"))||document.documentElement.getAttribute("data-theme");return i||((null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light")}get currentDesignSystem(){var e;const t=(null===(e=this.closest("[design-system]"))||void 0===e?void 0:e.getAttribute("design-system"))||document.documentElement.getAttribute("design-system");return"carbon"===t?t:"default"}setupThemeObserver(){this.themeObserver=new MutationObserver(()=>{this.requestUpdate()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]})}setupDesignSystemObserver(){this.designSystemObserver=new MutationObserver(()=>{this.requestUpdate()}),this.designSystemObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["design-system"]})}setupSystemThemeListener(){window.matchMedia&&(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this.handleSystemThemeChange))}},ve=()=>{var e;return void 0!==globalThis.litElementVersions||"undefined"!=typeof process&&"development"===(null===(e=process.env)||void 0===e?void 0:e.NODE_ENV)||"undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)},ge=e=>class extends e{constructor(){super(...arguments),this.requiredComponents=[]}validateDependencies(){if(ve())for(const e of this.requiredComponents)if(!this.isComponentAvailable(e))throw new Error(`Required component "${e}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}. Example: import '@nuralyui/${e}';`)}validateDependenciesWithHandler(e){if(!ve())return!0;let t=!0;for(const i of this.requiredComponents)if(!this.isComponentAvailable(i)){t=!1;const n=new Error(`Required component "${i}" is not registered. Please import and register the component before using ${this.tagName.toLowerCase()}.`);e?e(i,n):console.error(n.message)}return t}isComponentAvailable(e){return!!customElements.get(e)}getMissingDependencies(){return this.requiredComponents.filter(e=>!this.isComponentAvailable(e))}areDependenciesAvailable(){return this.requiredComponents.every(e=>this.isComponentAvailable(e))}addRequiredComponent(e){this.requiredComponents.includes(e)||this.requiredComponents.push(e)}removeRequiredComponent(e){const t=this.requiredComponents.indexOf(e);t>-1&&this.requiredComponents.splice(t,1)}},me=e=>class extends e{dispatchCustomEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}dispatchEventWithMetadata(e,t){var i;const n=Object.assign(Object.assign({},t),{timestamp:Date.now(),componentName:(null===(i=this.tagName)||void 0===i?void 0:i.toLowerCase())||"unknown"});this.dispatchCustomEvent(e,n)}dispatchInputEvent(e,t){const i=Object.assign({target:t.target||this,value:t.value,originalEvent:t.originalEvent},t);this.dispatchCustomEvent(e,i)}dispatchFocusEvent(e,t){const i=Object.assign({target:t.target||this,value:t.value,focused:t.focused,cursorPosition:t.cursorPosition,selectedText:t.selectedText},t);this.dispatchCustomEvent(e,i)}dispatchValidationEvent(e,t){var i;const n=Object.assign({target:t.target||this,value:t.value,isValid:null!==(i=t.isValid)&&void 0!==i&&i,error:t.error},t);this.dispatchCustomEvent(e,n)}dispatchActionEvent(e,t){const i=Object.assign({target:t.target||this,action:t.action,previousValue:t.previousValue,newValue:t.newValue},t);this.dispatchCustomEvent(e,i)}isReadonlyKeyAllowed(e){if(e.ctrlKey||e.metaKey){return["KeyA","KeyC"].includes(e.code)}return["Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}isActivationKey(e){return"Enter"===e.key||" "===e.key}},ye=new Set,xe=new Map;
112
112
  /**
113
113
  * @license
114
114
  * Copyright 2023 Nuraly, Laabidi Aymen
@@ -119,7 +119,7 @@ var P,_;O.styles=e`
119
119
  * Copyright 2023 Nuraly, Laabidi Aymen
120
120
  * SPDX-License-Identifier: MIT
121
121
  */
122
- const we=e=>{class t extends e{constructor(){super(...arguments),this.t=null}createRenderRoot(){return this.constructor.useShadowDom?super.createRenderRoot():this}connectedCallback(){const e=this.constructor.useShadowDom;if(!e&&null===this.t)for(this.t=[];this.firstChild;)this.t.push(this.removeChild(this.firstChild));if(super.connectedCallback(),!e){const e=this.constructor,t=this.tagName.toLowerCase(),i=e.styles;if(i){const e=ke(i);e&&function(e,t,i){var n;if(!ye.has(e)){const i=new CSSStyleSheet;i.replaceSync(t),ye.set(e,i)}const a=ye.get(e),o=`doc:${e}`;if(xe.has(o)||(document.adoptedStyleSheets=[...document.adoptedStyleSheets,a],xe.add(o)),i){let t=i;for(;t;){const i=t.getRootNode();if(!(i instanceof ShadowRoot))break;{const o=`shadow:${((null===(n=i.host)||void 0===n?void 0:n.tagName)||"").toLowerCase()}:${e}`;xe.has(o)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,a],xe.add(o)),t=i.host}}}}(t,e,this)}}}get lightChildren(){return this.t?this.t.filter(e=>!(e instanceof Element&&e.hasAttribute("slot"))):[]}lightChildrenNamed(e){return this.t?this.t.filter(t=>t instanceof Element&&t.getAttribute("slot")===e):[]}}return t.useShadowDom=!1,t},$e=e=>ge(fe(me(we(e))));function ke(e){return Array.isArray(e)?e.map(e=>ke(e)).filter(Boolean).join("\n"):e&&"string"==typeof e.cssText?e.cssText:"string"==typeof e?e:""}const Se=[e`
122
+ const we=e=>{class t extends e{constructor(){super(...arguments),this.t=null}createRenderRoot(){return this.constructor.useShadowDom?super.createRenderRoot():this}connectedCallback(){const e=this.constructor.useShadowDom;if(!e&&null===this.t)for(this.t=[];this.firstChild;)this.t.push(this.removeChild(this.firstChild));if(super.connectedCallback(),!e){const e=this.constructor,t=this.tagName.toLowerCase(),i=e.styles;if(i){const e=ke(i);e&&function(e,t,i){var n;if(!xe.has(e)){const i=new CSSStyleSheet;i.replaceSync(t),xe.set(e,i)}const a=xe.get(e),o=`doc:${e}`;if(ye.has(o)||(document.adoptedStyleSheets=[...document.adoptedStyleSheets,a],ye.add(o)),i){let t=i;for(;t;){const i=t.getRootNode();if(!(i instanceof ShadowRoot))break;{const o=`shadow:${((null===(n=i.host)||void 0===n?void 0:n.tagName)||"").toLowerCase()}:${e}`;ye.has(o)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,a],ye.add(o)),t=i.host}}}}(t,e,this)}}}get lightChildren(){return this.t?this.t.filter(e=>!(e instanceof Element&&e.hasAttribute("slot"))):[]}lightChildrenNamed(e){return this.t?this.t.filter(t=>t instanceof Element&&t.getAttribute("slot")===e):[]}}return t.useShadowDom=!1,t},$e=e=>ge(fe(me(we(e))));function ke(e){return Array.isArray(e)?e.map(e=>ke(e)).filter(Boolean).join("\n"):e&&"string"==typeof e.cssText?e.cssText:"string"==typeof e?e:""}const Se=[e`
123
123
  :host {
124
124
  display: inline-flex;
125
125
  align-items: center;
@@ -1022,7 +1022,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1022
1022
  * @license
1023
1023
  * Copyright 2021 Google LLC
1024
1024
  * SPDX-License-Identifier: BSD-3-Clause
1025
- */(t),a=e[n];if(a){if("string"==typeof a)return a;if("strTag"in a)return it(a.strings,t.values,a.values);{let e=pt.get(a);return void 0===e&&(e=a.values,pt.set(a,e)),{...a,values:e.map(e=>t.values[e])}}}}return nt(t)}function bt(e){window.dispatchEvent(new CustomEvent(tt,{detail:e}))}let ft,vt,gt,mt,xt,yt="",wt=new lt;wt.resolve();let $t=0;const kt=e=>(function(e){if(ot)throw new Error("lit-localize can only be configured once");at=e,ot=!0}((e,t)=>ut(xt,e,t)),yt=vt=e.sourceLocale,gt=new Set(e.targetLocales),gt.add(e.sourceLocale),mt=e.loadLocale,{getLocale:St,setLocale:Ct}),St=()=>yt,Ct=e=>{if(e===(ft??yt))return wt.promise;if(!gt||!mt)throw new Error("Internal error");if(!gt.has(e))throw new Error("Invalid locale code");$t++;const t=$t;ft=e,wt.settled&&(wt=new lt),bt({status:"loading",loadingLocale:e});return(e===vt?Promise.resolve({templates:void 0}):mt(e)).then(i=>{$t===t&&(yt=e,ft=void 0,xt=i.templates,bt({status:"ready",readyLocale:e}),wt.resolve())},i=>{$t===t&&(bt({status:"error",errorLocale:e,errorMessage:i.toString()}),wt.reject(i))}),wt.promise};var Tt,Mt,Et,At,zt,It,Ot,Pt=e`
1025
+ */(t),a=e[n];if(a){if("string"==typeof a)return a;if("strTag"in a)return it(a.strings,t.values,a.values);{let e=pt.get(a);return void 0===e&&(e=a.values,pt.set(a,e)),{...a,values:e.map(e=>t.values[e])}}}}return nt(t)}function bt(e){window.dispatchEvent(new CustomEvent(tt,{detail:e}))}let ft,vt,gt,mt,yt,xt="",wt=new lt;wt.resolve();let $t=0;const kt=e=>(function(e){if(ot)throw new Error("lit-localize can only be configured once");at=e,ot=!0}((e,t)=>ut(yt,e,t)),xt=vt=e.sourceLocale,gt=new Set(e.targetLocales),gt.add(e.sourceLocale),mt=e.loadLocale,{getLocale:St,setLocale:Ct}),St=()=>xt,Ct=e=>{if(e===(ft??xt))return wt.promise;if(!gt||!mt)throw new Error("Internal error");if(!gt.has(e))throw new Error("Invalid locale code");$t++;const t=$t;ft=e,wt.settled&&(wt=new lt),bt({status:"loading",loadingLocale:e});return(e===vt?Promise.resolve({templates:void 0}):mt(e)).then(i=>{$t===t&&(xt=e,ft=void 0,yt=i.templates,bt({status:"ready",readyLocale:e}),wt.resolve())},i=>{$t===t&&(bt({status:"error",errorLocale:e,errorMessage:i.toString()}),wt.reject(i))}),wt.promise};var Tt,Mt,Et,At,zt,It,Ot,Pt=e`
1026
1026
  :host {
1027
1027
  display: block;
1028
1028
  width: 100%;
@@ -1042,10 +1042,10 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1042
1042
  display: flex;
1043
1043
  width: 100%;
1044
1044
  height: 100%;
1045
- background-color: #ffffff;
1046
1045
  border-radius: 8px;
1047
1046
  position: relative;
1048
1047
  border: 1px solid #e0e0e0;
1048
+ box-sizing: border-box;
1049
1049
  }
1050
1050
 
1051
1051
  .chatbot-container {
@@ -1070,13 +1070,24 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1070
1070
  min-width: 0;
1071
1071
  }
1072
1072
 
1073
+ .chatbot-boxed-area {
1074
+ display: flex;
1075
+ flex-direction: column;
1076
+ flex: 1;
1077
+ min-height: 0;
1078
+ min-width: 0;
1079
+ width: 100%;
1080
+ }
1081
+
1073
1082
  .chatbot-header {
1074
1083
  display: flex;
1075
1084
  align-items: center;
1076
1085
  justify-content: space-between;
1077
1086
  gap: 0.5rem;
1078
1087
  padding: 0.5rem;
1079
- border-bottom: 1px solid #e0e0e0;
1088
+ min-height: 43px;
1089
+ box-sizing: border-box;
1090
+ border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
1080
1091
  }
1081
1092
 
1082
1093
  .chatbot-content {
@@ -1088,7 +1099,6 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1088
1099
  }
1089
1100
 
1090
1101
  :host([boxed]) .chat-container {
1091
- background-color: #ffffff;
1092
1102
  border: none;
1093
1103
  border-radius: 0;
1094
1104
  }
@@ -1099,22 +1109,15 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1099
1109
 
1100
1110
  :host([boxed]) .chatbot-main {
1101
1111
  width: 100%;
1102
- max-width: 768px;
1103
- margin: 0 auto;
1104
- background-color: #ffffff;
1105
1112
  border: none;
1106
1113
  border-radius: 0;
1107
1114
  box-shadow: none;
1108
1115
  height: 100%;
1109
1116
  }
1110
1117
 
1111
- /* Boxed layout with threads: background comes from theme variable with white fallback */
1112
- :host([boxed]) .chat-container--boxed.chat-container--with-threads {
1113
- background-color: #ffffff;
1114
- }
1115
-
1116
- .chat-container--boxed.chat-container--with-threads .chatbot-main {
1117
- background-color: #ffffff;
1118
+ :host([boxed]) .chatbot-boxed-area {
1119
+ max-width: 768px;
1120
+ margin: 0 auto;
1118
1121
  }
1119
1122
 
1120
1123
  .chat-container--boxed.chat-container--with-threads .chat-box {
@@ -1130,9 +1133,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1130
1133
  }
1131
1134
 
1132
1135
  :host([boxed]) .chatbot-header {
1133
- /* Keep header at the top */
1134
1136
  flex: 0 0 auto;
1135
- border-bottom: none;
1136
1137
  }
1137
1138
 
1138
1139
  :host([boxed]) .chatbot-content:has(.empty-state) {
@@ -1146,24 +1147,15 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1146
1147
  min-height: 0;
1147
1148
  }
1148
1149
 
1149
- :host([boxed]) .chatbot-main:has(.empty-state) {
1150
- /* Make main container relative for absolute positioning */
1151
- position: relative;
1152
- }
1153
-
1154
1150
  :host([boxed]) .empty-state {
1155
- /* Position empty state in the center - moved up */
1156
- position: absolute;
1157
- top: 50%;
1158
- left: 50%;
1159
- transform: translate(-50%, calc(-50% - 80px));
1151
+ display: flex;
1152
+ align-items: center;
1153
+ justify-content: center;
1154
+ flex-direction: column;
1160
1155
  width: 100%;
1156
+ height: 100%;
1161
1157
  max-width: 768px;
1162
- height: auto;
1163
1158
  padding: 0;
1164
- display: flex;
1165
- flex-direction: column;
1166
- align-items: center;
1167
1159
  gap: 1.5rem;
1168
1160
  }
1169
1161
 
@@ -1172,13 +1164,9 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1172
1164
  }
1173
1165
 
1174
1166
  :host([boxed]) .chatbot-content:has(.empty-state) + .input-box {
1175
- /* Position input-box in the middle with empty state - moved up */
1176
- position: absolute;
1177
- top: 50%;
1178
- left: 50%;
1179
- transform: translate(-50%, calc(-50% + 40px));
1180
1167
  width: 100%;
1181
1168
  max-width: 768px;
1169
+ margin: 0 auto;
1182
1170
  }
1183
1171
 
1184
1172
  :host([boxed]) .suggestion-container {
@@ -1188,7 +1176,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1188
1176
  :host([boxed]) .messages {
1189
1177
  box-shadow: none;
1190
1178
  margin-bottom: 0;
1191
- background-color: #ffffff;
1179
+ background-color: var(--chatbot-messages-bg, transparent);
1192
1180
  align-items: stretch;
1193
1181
  width: 98%;
1194
1182
  padding: 8px 1.5rem;
@@ -1232,7 +1220,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1232
1220
  align-items: center;
1233
1221
  justify-content: space-between;
1234
1222
  padding: 0.75rem;
1235
- border-bottom: 1px solid #e0e0e0;
1223
+ border-bottom: 1px solid var(--nuraly-color-divider, rgb(224, 224, 224));
1236
1224
  }
1237
1225
 
1238
1226
  .thread-sidebar__header h3 {
@@ -1443,12 +1431,13 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1443
1431
 
1444
1432
  .messages {
1445
1433
  flex: 1;
1434
+ min-height: 0;
1446
1435
  overflow-y: auto;
1447
1436
  overflow-x: hidden;
1448
1437
  display: flex;
1449
1438
  flex-direction: column;
1450
1439
  gap: 0;
1451
- background-color: #ffffff;
1440
+ background-color: var(--chatbot-messages-bg, transparent);
1452
1441
  padding: 8px 1rem;
1453
1442
  box-sizing: border-box;
1454
1443
  justify-content: flex-start; /* Always align messages to top */
@@ -1587,16 +1576,16 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
1587
1576
  }
1588
1577
 
1589
1578
  .message.user .message__content {
1590
- background-color: #7c3aed;
1591
- color: #ffffff;
1579
+ background-color: var(--nuraly-color-user-bubble-bg, rgb(124, 58, 237));
1580
+ color: var(--nuraly-color-user-bubble-fg, rgb(255, 255, 255));
1592
1581
  border-radius: var(--chatbot-radius, 8px);
1593
1582
  border: 0 solid transparent;
1594
1583
  box-shadow: none;
1595
1584
  }
1596
1585
 
1597
1586
  .message.bot .message__content {
1598
- background-color: transparent;
1599
- color: inherit;
1587
+ background-color: var(--nuraly-color-bot-bubble-bg, transparent);
1588
+ color: var(--nuraly-color-bot-bubble-fg, inherit);
1600
1589
  border-radius: 0;
1601
1590
  border: 0 solid transparent;
1602
1591
  box-shadow: none;
@@ -2641,10 +2630,10 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
2641
2630
  .artifact-panel {
2642
2631
  width: 400px;
2643
2632
  min-width: 300px;
2633
+ min-height: 0;
2644
2634
  flex-shrink: 0;
2645
2635
  display: flex;
2646
2636
  flex-direction: row;
2647
- background-color: #ffffff;
2648
2637
  overflow: hidden;
2649
2638
  position: relative;
2650
2639
  }
@@ -2946,14 +2935,14 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
2946
2935
  * Copyright 2023 Nuraly, Laabidi Aymen
2947
2936
  * SPDX-License-Identifier: MIT
2948
2937
  */
2949
- function _t(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))return"";const i=new Date,n={hour:"numeric",minute:"2-digit",hour12:!0};if(t.toDateString()===i.toDateString())return t.toLocaleTimeString(void 0,n);const a=Object.assign({month:"short",day:"numeric"},n);return t.toLocaleDateString(void 0,a)}It.Image,It.Audio,It.Video,It.Document,It.Document,It.Document,It.Document,It.Archive,It.Archive,It.Code,It.Code,It.Code;const Rt={javascript:"JavaScript",typescript:"TypeScript",python:"Python",java:"Java",go:"Go",rust:"Rust",c:"C",cpp:"C++",csharp:"C#",ruby:"Ruby",php:"PHP",swift:"Swift",kotlin:"Kotlin",html:"HTML",css:"CSS",scss:"SCSS",sql:"SQL",graphql:"GraphQL",json:"JSON",yaml:"YAML",xml:"XML",toml:"TOML",markdown:"Markdown",md:"Markdown",bash:"Bash",shell:"Shell",sh:"Shell",zsh:"Zsh",dockerfile:"Dockerfile",makefile:"Makefile",text:"Text"};function Nt(e){return e.startsWith("image/")}function Dt(e,t){const i=e.lastIndexOf(".");if(i>=0&&i<e.length-1)return e.slice(i+1).toUpperCase().slice(0,4);if(t){const e=t.indexOf("/");if(e>=0)return t.slice(e+1).toUpperCase().slice(0,4)}return"FILE"}function Lt(e,t,a){var o,s,r,l,c,d,p,b;const f=null===(o=e.text)||void 0===o?void 0:o.includes("[ERROR_START]"),v={error:!!e.error||f,introduction:!!e.introduction,[e.sender]:!0};return i`
2938
+ function _t(e){if(!e)return"";const t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))return"";const i=new Date,n={hour:"numeric",minute:"2-digit",hour12:!0};if(t.toDateString()===i.toDateString())return t.toLocaleTimeString(void 0,n);const a=Object.assign({month:"short",day:"numeric"},n);return t.toLocaleDateString(void 0,a)}It.Image,It.Audio,It.Video,It.Document,It.Document,It.Document,It.Document,It.Archive,It.Archive,It.Code,It.Code,It.Code;const Rt={javascript:"JavaScript",typescript:"TypeScript",python:"Python",java:"Java",go:"Go",rust:"Rust",c:"C",cpp:"C++",csharp:"C#",ruby:"Ruby",php:"PHP",swift:"Swift",kotlin:"Kotlin",html:"HTML",css:"CSS",scss:"SCSS",sql:"SQL",graphql:"GraphQL",json:"JSON",yaml:"YAML",xml:"XML",toml:"TOML",markdown:"Markdown",md:"Markdown",bash:"Bash",shell:"Shell",sh:"Shell",zsh:"Zsh",dockerfile:"Dockerfile",makefile:"Makefile",text:"Text"};function Nt(e){return e.startsWith("image/")}function Dt(e,t){const i=e.lastIndexOf(".");if(i>=0&&i<e.length-1)return e.slice(i+1).toUpperCase().slice(0,4);if(t){const e=t.indexOf("/");if(e>=0)return t.slice(e+1).toUpperCase().slice(0,4)}return"FILE"}function Lt(e,t,a){var o,s,r,l,c,d,p,b;const f=null===(o=e.text)||void 0===o?void 0:o.includes("[ERROR_START]"),v={error:!!e.error||f,introduction:!!e.introduction,[e.sender]:!0},g=e.sender;return i`
2950
2939
  <div
2951
2940
  class="message ${h(v)}"
2952
- part="message"
2941
+ part=${`message message-${g}`}
2953
2942
  data-sender="${e.sender}"
2954
2943
  data-id="${e.id}"
2955
2944
  >
2956
- <div class="message__content" part="message-content">
2945
+ <div class="message__content" part=${`message-content message-content-${g}`}>
2957
2946
  ${f?
2958
2947
  /**
2959
2948
  * @license
@@ -3029,6 +3018,7 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3029
3018
  size="small"
3030
3019
  color="#9ca3af"
3031
3020
  class="message__copy"
3021
+ part="message-copy"
3032
3022
  @click=${()=>t.onCopy(e)}
3033
3023
  @keydown=${i=>t.onCopyKeydown(i,e)}
3034
3024
  title="${a.messages.copyMessageLabel}"
@@ -3050,17 +3040,26 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3050
3040
  ${a.messages.retryButton}
3051
3041
  </nr-button>`:n}
3052
3042
  </div>
3053
- `}function jt(e,t,a,o,s){return i`
3043
+ `}function jt(e,t,a,o,s,r,l){return i`
3054
3044
  <div class="messages" part="messages">
3055
- ${0===e.length?function(e){return i`
3045
+ ${0===e.length?l?function(e){return i`
3046
+ <div class="empty-state empty-state--loading" part="empty-state thread-loading">
3047
+ <slot name="thread-loading">
3048
+ <div class="spinner" part="thread-loading-spinner"></div>
3049
+ <div class="empty-state__content" part="empty-state-content">
3050
+ ${e.messages.loadingConversationLabel}
3051
+ </div>
3052
+ </slot>
3053
+ </div>
3054
+ `}(s):function(e,t){const n=null!=t?t:e.messages.startConversationLabel;return i`
3056
3055
  <div class="empty-state" part="empty-state">
3057
3056
  <slot name="empty-state">
3058
- <div class="empty-state__content">
3059
- ${e.messages.startConversationLabel}
3057
+ <div class="empty-state__content" part="empty-state-content">
3058
+ ${n}
3060
3059
  </div>
3061
3060
  </slot>
3062
3061
  </div>
3063
- `}(s):n}
3062
+ `}(s,r):n}
3064
3063
  ${e.map(e=>Lt(e,o,s))}
3065
3064
  ${t}
3066
3065
  ${a}
@@ -3104,6 +3103,7 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3104
3103
  <div
3105
3104
  slot="trigger"
3106
3105
  class="file-thumb ${e.isUploading?"file-thumb--uploading":""}"
3106
+ part="file-thumb"
3107
3107
  role="button"
3108
3108
  tabindex="0"
3109
3109
  title="${e.name}"
@@ -3112,22 +3112,24 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3112
3112
  ${s(e.mimeType)&&(e.previewUrl||e.url)?i`
3113
3113
  <img
3114
3114
  class="file-thumb__image"
3115
+ part="file-thumb-image"
3115
3116
  src="${e.previewUrl||e.url}"
3116
3117
  alt="${e.name}"
3117
3118
  />
3118
3119
  `:i`
3119
- <div class="file-thumb__ext" data-ext="${o(e.name,e.mimeType)}">
3120
- <span class="file-thumb__ext-label">${o(e.name,e.mimeType)}</span>
3120
+ <div class="file-thumb__ext" part="file-thumb-ext" data-ext="${o(e.name,e.mimeType)}">
3121
+ <span class="file-thumb__ext-label" part="file-thumb-ext-label">${o(e.name,e.mimeType)}</span>
3121
3122
  </div>
3122
3123
  `}
3123
3124
  ${e.isUploading?i`
3124
- <div class="file-thumb__spinner" aria-label="${n.input.uploadingLabel}">
3125
+ <div class="file-thumb__spinner" part="file-thumb-spinner" aria-label="${n.input.uploadingLabel}">
3125
3126
  <span class="file-thumb__spinner-ring"></span>
3126
3127
  </div>
3127
3128
  `:""}
3128
3129
  <button
3129
3130
  type="button"
3130
3131
  class="file-thumb__remove"
3132
+ part="file-thumb-remove"
3131
3133
  aria-label="${n.input.removeFileLabel}"
3132
3134
  title="${n.input.removeFileLabel}"
3133
3135
  @click=${i=>{i.stopPropagation(),t(e.id)}}
@@ -3163,8 +3165,8 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3163
3165
  `)}
3164
3166
  </div>
3165
3167
  `}function Ut(e,t){return i`
3166
- <div class="action-buttons-row">
3167
- <div class="action-buttons-left">
3168
+ <div class="action-buttons-row" part="actions">
3169
+ <div class="action-buttons-left" part="actions-left">
3168
3170
  ${e.enableFileUpload?function(e,t){return i`
3169
3171
  <nr-dropdown
3170
3172
  .items=${e.fileUploadItems}
@@ -3212,11 +3214,12 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3212
3214
  `}(e,t):n}
3213
3215
  </div>
3214
3216
 
3215
- <div class="action-buttons-right">
3217
+ <div class="action-buttons-right" part="actions-right">
3216
3218
  ${e.showAudioButton&&!e.isQueryRunning?i`
3217
3219
  <!-- Speech-to-text: mic + keyboard indicator -->
3218
3220
  <button
3219
3221
  class="audio-mic-btn"
3222
+ part="audio-mic-button audio-mic-transcribe"
3220
3223
  title="${e.i18n.audio.recordSpeechLabel}"
3221
3224
  ?disabled=${e.disabled}
3222
3225
  @click=${()=>{var e;return null===(e=t.onAudioStart)||void 0===e?void 0:e.call(t,"transcribe")}}
@@ -3235,6 +3238,7 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3235
3238
  <!-- Voice message: mic + waveform indicator -->
3236
3239
  <button
3237
3240
  class="audio-mic-btn"
3241
+ part="audio-mic-button audio-mic-voice"
3238
3242
  title="${e.i18n.audio.sendVoiceMessageLabel}"
3239
3243
  ?disabled=${e.disabled}
3240
3244
  @click=${()=>{var e;return null===(e=t.onAudioStart)||void 0===e?void 0:e.call(t,"message")}}
@@ -3276,9 +3280,10 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3276
3280
  </svg>`:i`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
3277
3281
  <path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>
3278
3282
  </svg>`;return i`
3279
- <div class="audio-recording-bar">
3283
+ <div class="audio-recording-bar" part="audio-recording-bar">
3280
3284
  <button
3281
3285
  class="audio-rec-cancel"
3286
+ part="audio-cancel-button"
3282
3287
  title="${e.i18n.audio.cancelRecordingLabel}"
3283
3288
  @click=${t.onAudioCancel}
3284
3289
  aria-label="${e.i18n.audio.cancelRecordingLabel}"
@@ -3290,22 +3295,23 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3290
3295
  </svg>
3291
3296
  </button>
3292
3297
 
3293
- <div class="audio-rec-indicator">
3294
- <span class="audio-rec-dot"></span>
3295
- <div class="audio-rec-wave">
3298
+ <div class="audio-rec-indicator" part="audio-indicator">
3299
+ <span class="audio-rec-dot" part="audio-dot"></span>
3300
+ <div class="audio-rec-wave" part="audio-wave">
3296
3301
  ${a.map(e=>i`
3297
- <div class="audio-rec-bar" style=${d({height:`${Math.round(24*e)}px`})}></div>
3302
+ <div class="audio-rec-bar" part="audio-bar" style=${d({height:`${Math.round(24*e)}px`})}></div>
3298
3303
  `)}
3299
3304
  </div>
3300
- <span class="audio-rec-time">${n}</span>
3305
+ <span class="audio-rec-time" part="audio-time">${n}</span>
3301
3306
  </div>
3302
3307
 
3303
- <span class="audio-rec-mode-label">
3308
+ <span class="audio-rec-mode-label" part="audio-mode-label">
3304
3309
  ${o?e.i18n.audio.speechToTextLabel:e.i18n.audio.voiceMessageLabel}
3305
3310
  </span>
3306
3311
 
3307
3312
  <button
3308
3313
  class="audio-rec-send ${o?"audio-rec-send--transcribe":""}"
3314
+ part="audio-send-button"
3309
3315
  title="${s}"
3310
3316
  @click=${t.onAudioSend}
3311
3317
  aria-label="${s}"
@@ -3323,7 +3329,7 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3323
3329
  ${e.uploadedFiles.length>0?Bt(e.uploadedFiles,t.onFileRemove,e.i18n,t.onFileClick):n}
3324
3330
 
3325
3331
  <!-- Input area -->
3326
- <div class="input-row">
3332
+ <div class="input-row" part="input-row">
3327
3333
  <div
3328
3334
  class="input-box__input"
3329
3335
  part="input"
@@ -3358,6 +3364,7 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3358
3364
  ${t.editingThreadId===e.id&&n.onRenameThread?i`
3359
3365
  <input
3360
3366
  class="thread-item__rename-input"
3367
+ part="thread-rename-input"
3361
3368
  type="text"
3362
3369
  .value=${e.title||""}
3363
3370
  @click=${e=>e.stopPropagation()}
@@ -3365,9 +3372,9 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3365
3372
  @blur=${t=>{const i=t.target.value.trim();i&&i!==e.title?n.onRenameThread(e.id,i):n.onRenameThread(e.id,e.title||"")}}
3366
3373
  />
3367
3374
  `:i`
3368
- <div class="thread-item__title">${e.title||t.i18n.threads.newChatTitle}</div>
3375
+ <div class="thread-item__title" part="thread-title">${e.title||t.i18n.threads.newChatTitle}</div>
3369
3376
  `}
3370
- <div class="thread-item__actions">
3377
+ <div class="thread-item__actions" part="thread-actions">
3371
3378
  ${n.onBookmarkThread&&e.bookmarked?i`
3372
3379
  <button
3373
3380
  class="thread-item__action-btn thread-item__bookmark--active"
@@ -3401,10 +3408,10 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
3401
3408
  `:""}
3402
3409
  </div>
3403
3410
  </div>
3404
- <div class="thread-item__preview">
3411
+ <div class="thread-item__preview" part="thread-preview">
3405
3412
  ${o}
3406
3413
  </div>
3407
- <div class="thread-item__timestamp">${_t(e.updatedAt)}</div>
3414
+ <div class="thread-item__timestamp" part="thread-timestamp">${_t(e.updatedAt)}</div>
3408
3415
  </div>
3409
3416
  `}function qt(e,t){if(!e.isOpen||!e.file)return n;const a=e.file,o=a.mimeType.startsWith("image/"),s="application/pdf"===a.mimeType||a.name.toLowerCase().endsWith(".pdf");return i`
3410
3417
  <nr-modal
@@ -3464,15 +3471,15 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3464
3471
  */function Gt(e,t){var a;if(!e.isOpen||!e.artifact)return n;const o=e.artifact,s=(r=o.language,Rt[r]||r.charAt(0).toUpperCase()+r.slice(1));var r;return i`
3465
3472
  <div class="artifact-panel" part="artifact-panel">
3466
3473
  <div class="artifact-panel__resize-handle" part="artifact-panel-resize-handle">
3467
- <div class="artifact-panel__resize-bar"></div>
3474
+ <div class="artifact-panel__resize-bar" part="artifact-panel-resize-bar"></div>
3468
3475
  </div>
3469
- <div class="artifact-panel__body">
3470
- <div class="artifact-panel__header">
3471
- <div class="artifact-panel__header-info">
3472
- <nr-tag size="small" class="artifact-panel__lang-badge">${s}</nr-tag>
3473
- <span class="artifact-panel__title">${o.title}</span>
3476
+ <div class="artifact-panel__body" part="artifact-panel-body">
3477
+ <div class="artifact-panel__header" part="artifact-panel-header">
3478
+ <div class="artifact-panel__header-info" part="artifact-panel-header-info">
3479
+ <nr-tag size="small" class="artifact-panel__lang-badge" part="artifact-panel-lang">${s}</nr-tag>
3480
+ <span class="artifact-panel__title" part="artifact-panel-title">${o.title}</span>
3474
3481
  </div>
3475
- <div class="artifact-panel__actions">
3482
+ <div class="artifact-panel__actions" part="artifact-panel-actions">
3476
3483
  <nr-button
3477
3484
  type="text"
3478
3485
  size="small"
@@ -3491,8 +3498,8 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3491
3498
  ></nr-button>
3492
3499
  </div>
3493
3500
  </div>
3494
- <div class="artifact-panel__content">
3495
- ${(null===(a=e.renderContent)||void 0===a?void 0:a.call(e,o))||function(e){switch(e.language){case"json":{let t;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch(i){t=e.content}return i`<pre class="artifact-panel__code"><code>${t}</code></pre>`}case"md":case"markdown":return i`<div class="artifact-panel__rendered-md">${u(function(e){let t=function(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}(e);return t=t.replaceAll(/```([\s\S]*?)```/g,'<pre class="md-code"><code>$1</code></pre>'),t=t.replaceAll(/`([^`]+)`/g,'<code class="md-inline-code">$1</code>'),t=t.replaceAll(/^###[^\S\n]+(.+)$/gm,"<h3>$1</h3>"),t=t.replaceAll(/^##[^\S\n]+(.+)$/gm,"<h2>$1</h2>"),t=t.replaceAll(/^#[^\S\n]+(.+)$/gm,"<h1>$1</h1>"),t=t.replaceAll(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replaceAll(/\*([^*]+)\*/g,"<em>$1</em>"),t=t.replaceAll(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=t.replaceAll(/(?:^|\n)-\s+(.+)(?=\n|$)/g,(e,t)=>`\n<ul><li>${t}</li></ul>`),t=t.replaceAll(/<ul>\s*<li>([\s\S]*?)<\/li>\s*<\/ul>\n<ul>/g,"<ul><li>$1</li>"),t=t.split(/\n\n+/).map(e=>/^(<h\d|<pre|<ul|<ol|<blockquote)/.test(e.trim())?e:`<p>${e.replaceAll("\n","<br/>")}</p>`).join("\n"),t}(e.content))}</div>`;case"html":return i`<div class="artifact-panel__rendered-html">${u(e.content)}</div>`;case"text":case"txt":return i`<div class="artifact-panel__rendered-text">${e.content}</div>`;default:return i`<pre class="artifact-panel__code"><code>${e.content}</code></pre>`}}(o)}
3501
+ <div class="artifact-panel__content" part="artifact-panel-content">
3502
+ ${(null===(a=e.renderContent)||void 0===a?void 0:a.call(e,o))||function(e){switch(e.language){case"json":{let t;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch(i){t=e.content}return i`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${t}</code></pre>`}case"md":case"markdown":return i`<div class="artifact-panel__rendered-md" part="artifact-panel-md">${u(function(e){let t=function(e){return e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}(e);return t=t.replaceAll(/```([\s\S]*?)```/g,'<pre class="md-code"><code>$1</code></pre>'),t=t.replaceAll(/`([^`]+)`/g,'<code class="md-inline-code">$1</code>'),t=t.replaceAll(/^###[^\S\n]+(.+)$/gm,"<h3>$1</h3>"),t=t.replaceAll(/^##[^\S\n]+(.+)$/gm,"<h2>$1</h2>"),t=t.replaceAll(/^#[^\S\n]+(.+)$/gm,"<h1>$1</h1>"),t=t.replaceAll(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replaceAll(/\*([^*]+)\*/g,"<em>$1</em>"),t=t.replaceAll(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=t.replaceAll(/(?:^|\n)-\s+(.+)(?=\n|$)/g,(e,t)=>`\n<ul><li>${t}</li></ul>`),t=t.replaceAll(/<ul>\s*<li>([\s\S]*?)<\/li>\s*<\/ul>\n<ul>/g,"<ul><li>$1</li>"),t=t.split(/\n\n+/).map(e=>/^(<h\d|<pre|<ul|<ol|<blockquote)/.test(e.trim())?e:`<p>${e.replaceAll("\n","<br/>")}</p>`).join("\n"),t}(e.content))}</div>`;case"html":return i`<div class="artifact-panel__rendered-html" part="artifact-panel-html">${u(e.content)}</div>`;case"text":case"txt":return i`<div class="artifact-panel__rendered-text" part="artifact-panel-text">${e.content}</div>`;default:return i`<pre class="artifact-panel__code" part="artifact-panel-code"><code>${e.content}</code></pre>`}}(o)}
3496
3503
  </div>
3497
3504
  </div>
3498
3505
  </div>
@@ -3504,19 +3511,19 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3504
3511
  */function Wt(e,t){return!1!==e.showMessages?i`
3505
3512
  <div class="chatbot-content" part="content">
3506
3513
  ${jt(e.messages,Ft(e.chatStarted,e.suggestions,t.suggestion,e.i18n),e.isTyping?function(e,t,a){if(!e)return n;const o=t===Mt.Dots?i`
3507
- <div class="dots">
3514
+ <div class="dots" part="typing-dots">
3508
3515
  <span></span>
3509
3516
  <span></span>
3510
3517
  <span></span>
3511
3518
  </div>
3512
- `:i`<div class="spinner"></div>`;return i`
3519
+ `:i`<div class="spinner" part="typing-spinner"></div>`;return i`
3513
3520
  <div class="message bot loading" part="typing-indicator">
3514
- <div class="message__content">
3521
+ <div class="message__content" part="typing-content">
3515
3522
  ${o}
3516
- ${a?i`<span class="loading-text">${a.split("").map((e,t)=>i`<span class="loading-text__char" style="animation-delay:${.04*t}s">${" "===e?" ":e}</span>`)}</span>`:n}
3523
+ ${a?i`<span class="loading-text" part="typing-text">${a.split("").map((e,t)=>i`<span class="loading-text__char" style="animation-delay:${.04*t}s">${" "===e?" ":e}</span>`)}</span>`:n}
3517
3524
  </div>
3518
3525
  </div>
3519
- `}(e.isTyping,e.loadingIndicator||Mt.Spinner,e.loadingText):n,t.message,e.i18n)}
3526
+ `}(e.isTyping,e.loadingIndicator||Mt.Spinner,e.loadingText):n,t.message,e.i18n,e.welcomeMessage,e.isPendingThread)}
3520
3527
  <slot name="messages"></slot>
3521
3528
  </div>
3522
3529
  `:e.suggestions&&e.suggestions.length>0?i`
@@ -3533,14 +3540,14 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3533
3540
 
3534
3541
  ${e.enableThreads&&e.isThreadSidebarOpen&&e.threadSidebar&&t.threadSidebar?function(e,t){const a=e.threads.filter(e=>e.bookmarked),o=e.threads.filter(e=>!e.bookmarked);return i`
3535
3542
  <div class="thread-sidebar" part="thread-sidebar">
3536
- <div class="thread-sidebar__header">
3537
- <h3>${e.i18n.threads.conversationsTitle}</h3>
3543
+ <div class="thread-sidebar__header" part="thread-sidebar-header">
3544
+ <h3 part="thread-sidebar-title">${e.i18n.threads.conversationsTitle}</h3>
3538
3545
  </div>
3539
3546
 
3540
- <div class="thread-list">
3547
+ <div class="thread-list" part="thread-list">
3541
3548
  ${a.length>0?i`
3542
- <div class="thread-section" part="thread-section-bookmarks">
3543
- <div class="thread-section__label">
3549
+ <div class="thread-section" part="thread-section thread-section-bookmarks">
3550
+ <div class="thread-section__label" part="thread-section-label">
3544
3551
  <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>
3545
3552
  ${e.i18n.threads.bookmarksLabel}
3546
3553
  </div>
@@ -3549,11 +3556,11 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3549
3556
  `:n}
3550
3557
  ${o.length>0||0===a.length?i`
3551
3558
  ${a.length>0?i`
3552
- <div class="thread-section__label">${e.i18n.threads.allConversationsLabel}</div>
3559
+ <div class="thread-section__label" part="thread-section-label">${e.i18n.threads.allConversationsLabel}</div>
3553
3560
  `:n}
3554
3561
  ${b(o,e=>e.id,i=>Ht(i,e,t))}
3555
3562
  ${0===o.length&&0===a.length?i`
3556
- <p class="empty-msg">${e.i18n.threads.noConversationsLabel}</p>
3563
+ <p class="empty-msg" part="thread-empty">${e.i18n.threads.noConversationsLabel}</p>
3557
3564
  `:n}
3558
3565
  `:n}
3559
3566
  </div>
@@ -3591,11 +3598,13 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3591
3598
  </div>
3592
3599
  `:n}(e,t)}
3593
3600
 
3594
- <slot name="header"></slot>
3601
+ <div class="chatbot-boxed-area" part="boxed-area">
3602
+ <slot name="header"></slot>
3595
3603
 
3596
- ${Wt(e,t)}
3604
+ ${Wt(e,t)}
3597
3605
 
3598
- ${Vt(e.inputBox,t.inputBox)}
3606
+ ${Vt(e.inputBox,t.inputBox)}
3607
+ </div>
3599
3608
 
3600
3609
  <slot name="footer"></slot>
3601
3610
  </div>
@@ -3607,9 +3616,9 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3607
3616
  class="file-upload-area ${e.isDragging?"file-upload-area--dragging":""}"
3608
3617
  part="file-upload-area"
3609
3618
  >
3610
- <div class="file-upload-area__content">
3611
- <nr-icon name="upload" size="xlarge"></nr-icon>
3612
- <div class="file-upload-area__text">
3619
+ <div class="file-upload-area__content" part="file-upload-area-content">
3620
+ <nr-icon name="upload" size="xlarge" part="file-upload-area-icon"></nr-icon>
3621
+ <div class="file-upload-area__text" part="file-upload-area-text">
3613
3622
  ${e.label}
3614
3623
  </div>
3615
3624
  </div>
@@ -3721,7 +3730,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3721
3730
  * @license
3722
3731
  * Copyright 2023 Nuraly, Laabidi Aymen
3723
3732
  * SPDX-License-Identifier: MIT
3724
- */var Xt=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s},Zt=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const ei={input:{placeholder:at("Type your message..."),chatInputAriaLabel:at("Chat input"),attachButton:at("Attach"),attachFilesAriaLabel:at("Attach files"),removeFileLabel:at("Remove file"),uploadingLabel:at("Uploading"),uploadingProgress:at("Uploading…"),dropFilesHere:at("Drop files here to upload")},send:{sendButton:at("Send"),stopButton:at("Stop"),sendMessageLabel:at("Send message"),stopQueryLabel:at("Stop query")},audio:{recordSpeechLabel:at("Record speech to text"),sendVoiceMessageLabel:at("Send voice message"),cancelRecordingLabel:at("Cancel recording"),speechToTextLabel:at("Speech to text"),voiceMessageLabel:at("Voice message"),convertToTextLabel:at("Convert to text"),sendAsVoiceMessageLabel:at("Send as voice message")},modules:{moduleSelectionLabel:at("Select Modules"),moduleSearchPlaceholder:at("Search modules..."),moduleSelectAriaLabel:at("Select modules"),modulesSelectedSuffix:at("modules selected")},threads:{conversationsTitle:at("Conversations"),bookmarksLabel:at("Bookmarks"),allConversationsLabel:at("All Conversations"),noConversationsLabel:at("No conversations yet"),newChatTitle:at("New Chat"),newConversationLabel:at("New conversation"),removeBookmarkLabel:at("Remove bookmark"),bookmarkLabel:at("Bookmark"),renameLabel:at("Rename"),deleteLabel:at("Delete"),moreOptionsLabel:at("More options"),showThreadsLabel:at("Show threads"),hideThreadsLabel:at("Hide threads")},messages:{attachedFilesLabel:at("Attached files"),copyMessageLabel:at("Copy message"),retryMessageLabel:at("Retry message"),retryButton:at("Retry"),startConversationLabel:at("Start a conversation"),suggestionPrefix:at("Select suggestion: ")},urlModal:{addUrlTitle:at("Add URL"),urlLabel:at("URL"),urlPlaceholder:at("Enter URL..."),loadFromUrlLabel:at("Load file from URL"),selectedFileLabel:at("Selected file"),loadingFromUrlLabel:at("Loading file from URL..."),cancelButton:at("Cancel"),addButton:at("Add")},artifactPanel:{copyCodeLabel:at("Copy code"),closePanelLabel:at("Close panel")},loading:{agentWorkingLabel:at("Agent is working...")}};let ti=class extends($e(t)){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=Et.Medium,this.variant=At.Default,this.loadingIndicator=Mt.Dots,this.loadingText=at("Agent is working..."),this.disabled=!1,this.placeholder=at("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=at("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 Qt(this),this._audioMode="message",this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get moduleSelectOptions(){return this.modules.map(e=>({value:e.id,label:e.name,icon:e.icon,disabled:!1===e.enabled,description:e.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var e,t,i,n;null===(e=this.shadowRoot)||void 0===e||e.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(n){const e=n.dataset.artifactId;e&&this.handleArtifactClick(e)}}),null===(t=this.shadowRoot)||void 0===t||t.addEventListener("nr-thread-edit",e=>{const t=e.detail;(null==t?void 0:t.threadId)&&(this._editingThreadId=t.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".thread-item__rename-input");t&&(t.focus(),t.select())}))}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-selection-value]");if(n){const e=n.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("keydown",e=>{var t,i,n,a;const o=e;if("Enter"!==o.key&&" "!==o.key)return;const s=null===(i=(t=o.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(s){o.preventDefault();const e=s.dataset.artifactId;return void(e&&this.handleArtifactClick(e))}const r=null===(a=(n=o.target).closest)||void 0===a?void 0:a.call(n,"[data-selection-value]");if(r){o.preventDefault();const e=r.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}})}disconnectedCallback(){var e;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(e=this._artifactResizeCleanup)||void 0===e||e.call(this),this._artifactResizeBound=!1}updated(e){if(super.updated(e),e.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}this.enableUrlSync&&this.handleHashChange()}if(e.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!e.has("controller")){if(e.has("messages")||e.has("suggestions")||e.has("threads"))try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}}e.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".messages");t&&(t.scrollTop=t.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(e=>{try{e()}catch(e){}})}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 e=window.location.hash.match(/^#conversation\/(.+)$/);if(e){const t=decodeURIComponent(e[1]);t!==this.activeThreadId&&this.controller&&this.controller.switchThread(t)}}handleControllerStateChange(e){var t,i,n,a,o;if(e.messages&&(this.messages=e.messages),e.threads&&(this.threads=e.threads),e.suggestions&&e.suggestions.length>0&&(this.suggestions=e.suggestions),e.currentThreadId&&(this.activeThreadId=e.currentThreadId),this.enableUrlSync&&e.currentThreadId){const t=`#conversation/${encodeURIComponent(e.currentThreadId)}`;window.location.hash!==t&&history.replaceState(null,"",t)}if(this.chatStarted=(null===(t=e.messages)||void 0===t?void 0:t.length)>0,this.isBotTyping=e.isTyping||!1,this.statusText=e.statusText,this.isQueryRunning=e.isProcessing||!1,e.uploadedFiles&&(this.uploadedFiles=e.uploadedFiles),this.enableArtifacts){const t=null===(i=e.messages)||void 0===i?void 0:i.some(e=>{var t,i;return(null===(i=null===(t=e.metadata)||void 0===t?void 0:t.artifactIds)||void 0===i?void 0:i.length)>0});t||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(n=e.messages)||void 0===n?void 0:n.length)){const t=[...e.messages].reverse().find(e=>"bot"===e.sender),i=null===(a=null==t?void 0:t.metadata)||void 0===a?void 0:a.artifactIds;if(null==i?void 0:i.length){const e=i[i.length-1];if((null===(o=this.selectedArtifact)||void 0===o?void 0:o.id)!==e){const t=this.getArtifactPlugin(),i=null==t?void 0:t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(e){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(e){}handleControllerError(e){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",e.error)}get resolvedI18n(){var e,t,i,n,a,o,s,r,l;const c=this.i18n;return{input:Object.assign(Object.assign({},ei.input),null!==(e=null==c?void 0:c.input)&&void 0!==e?e:{}),send:Object.assign(Object.assign({},ei.send),null!==(t=null==c?void 0:c.send)&&void 0!==t?t:{}),audio:Object.assign(Object.assign({},ei.audio),null!==(i=null==c?void 0:c.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},ei.modules),null!==(n=null==c?void 0:c.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},ei.threads),null!==(a=null==c?void 0:c.threads)&&void 0!==a?a:{}),messages:Object.assign(Object.assign({},ei.messages),null!==(o=null==c?void 0:c.messages)&&void 0!==o?o:{}),urlModal:Object.assign(Object.assign({},ei.urlModal),null!==(s=null==c?void 0:c.urlModal)&&void 0!==s?s:{}),artifactPanel:Object.assign(Object.assign({},ei.artifactPanel),null!==(r=null==c?void 0:c.artifactPanel)&&void 0!==r?r:{}),loading:Object.assign(Object.assign({},ei.loading),null!==(l=null==c?void 0:c.loading)&&void 0!==l?l:{})}}render(){var e;const t=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:t},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId,i18n:t}:void 0,enableFileUpload:this.enableFileUpload,isDragging:this._isDragging,i18n:t,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(e=this.renderArtifactContent)&&void 0!==e?e:this.getPluginArtifactRenderer(),i18n:t}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName,i18n:t}:void 0},a={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 e;null===(e=this.controller)||void 0===e||e.createThread("New Chat")},onSelectThread:e=>{var t;this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(e)}`),null===(t=this.controller)||void 0===t||t.switchThread(e)},onDeleteThread:e=>{var t;null===(t=this.controller)||void 0===t||t.deleteThread(e)},onBookmarkThread:e=>{var t;null===(t=this.controller)||void 0===t||t.bookmarkThread(e)},onRenameThread:(e,t)=>{var i;null===(i=this.controller)||void 0===i||i.renameThread(e,t),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`
3733
+ */var Xt=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s},Zt=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const ei={input:{placeholder:at("Type your message..."),chatInputAriaLabel:at("Chat input"),attachButton:at("Attach"),attachFilesAriaLabel:at("Attach files"),removeFileLabel:at("Remove file"),uploadingLabel:at("Uploading"),uploadingProgress:at("Uploading…"),dropFilesHere:at("Drop files here to upload")},send:{sendButton:at("Send"),stopButton:at("Stop"),sendMessageLabel:at("Send message"),stopQueryLabel:at("Stop query")},audio:{recordSpeechLabel:at("Record speech to text"),sendVoiceMessageLabel:at("Send voice message"),cancelRecordingLabel:at("Cancel recording"),speechToTextLabel:at("Speech to text"),voiceMessageLabel:at("Voice message"),convertToTextLabel:at("Convert to text"),sendAsVoiceMessageLabel:at("Send as voice message")},modules:{moduleSelectionLabel:at("Select Modules"),moduleSearchPlaceholder:at("Search modules..."),moduleSelectAriaLabel:at("Select modules"),modulesSelectedSuffix:at("modules selected")},threads:{conversationsTitle:at("Conversations"),bookmarksLabel:at("Bookmarks"),allConversationsLabel:at("All Conversations"),noConversationsLabel:at("No conversations yet"),newChatTitle:at("New Chat"),newConversationLabel:at("New conversation"),removeBookmarkLabel:at("Remove bookmark"),bookmarkLabel:at("Bookmark"),renameLabel:at("Rename"),deleteLabel:at("Delete"),moreOptionsLabel:at("More options"),showThreadsLabel:at("Show threads"),hideThreadsLabel:at("Hide threads")},messages:{attachedFilesLabel:at("Attached files"),copyMessageLabel:at("Copy message"),retryMessageLabel:at("Retry message"),retryButton:at("Retry"),startConversationLabel:at("Start a conversation"),suggestionPrefix:at("Select suggestion: "),loadingConversationLabel:at("Loading conversation…")},urlModal:{addUrlTitle:at("Add URL"),urlLabel:at("URL"),urlPlaceholder:at("Enter URL..."),loadFromUrlLabel:at("Load file from URL"),selectedFileLabel:at("Selected file"),loadingFromUrlLabel:at("Loading file from URL..."),cancelButton:at("Cancel"),addButton:at("Add")},artifactPanel:{copyCodeLabel:at("Copy code"),closePanelLabel:at("Close panel")},loading:{agentWorkingLabel:at("Agent is working...")}};let ti=class extends($e(t)){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=Et.Medium,this.variant=At.Default,this.loadingIndicator=Mt.Dots,this.loadingText=at("Agent is working..."),this.disabled=!1,this.placeholder=at("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=at("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 Qt(this),this._audioMode="message",this._artifactResizeBound=!1,this.toggleThreadSidebar=()=>{this.isThreadSidebarOpen=!this.isThreadSidebarOpen}}get resolvedActionButtons(){var e;const t=null!==(e=this.actionButtons)&&void 0!==e?e:[];if(!this.enableFileUpload)return t;return t.some(e=>"attach"===(null==e?void 0:e.type))?t:[...t,{type:"attach",enabled:!0}]}get moduleSelectOptions(){return this.modules.map(e=>({value:e.id,label:e.name,icon:e.icon,disabled:!1===e.enabled,description:e.description}))}connectedCallback(){super.connectedCallback(),this.controller&&this.setupControllerIntegration(),this.setupUrlSync()}firstUpdated(){var e,t,i,n;null===(e=this.shadowRoot)||void 0===e||e.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(n){const e=n.dataset.artifactId;e&&this.handleArtifactClick(e)}}),null===(t=this.shadowRoot)||void 0===t||t.addEventListener("nr-thread-edit",e=>{const t=e.detail;(null==t?void 0:t.threadId)&&(this._editingThreadId=t.threadId,this.requestUpdate(),this.updateComplete.then(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".thread-item__rename-input");t&&(t.focus(),t.select())}))}),null===(i=this.shadowRoot)||void 0===i||i.addEventListener("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-selection-value]");if(n){const e=n.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}}),null===(n=this.shadowRoot)||void 0===n||n.addEventListener("keydown",e=>{var t,i,n,a;const o=e;if("Enter"!==o.key&&" "!==o.key)return;const s=null===(i=(t=o.target).closest)||void 0===i?void 0:i.call(t,"[data-artifact-id]");if(s){o.preventDefault();const e=s.dataset.artifactId;return void(e&&this.handleArtifactClick(e))}const r=null===(a=(n=o.target).closest)||void 0===a?void 0:a.call(n,"[data-selection-value]");if(r){o.preventDefault();const e=r.dataset.selectionValue;e&&this.controller&&this.controller.sendMessage(e)}})}disconnectedCallback(){var e;super.disconnectedCallback(),this.controller&&this.cleanupControllerIntegration(),this.teardownUrlSync(),null===(e=this._artifactResizeCleanup)||void 0===e||e.call(this),this._artifactResizeBound=!1}updated(e){if(super.updated(e),e.has("controller")&&(this.cleanupControllerIntegration(),this.controller)){this.setupControllerIntegration();try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}this.enableUrlSync&&this.handleHashChange(),this.syncActiveThreadToController()}if(e.has("activeThreadId")&&this.syncActiveThreadToController(),e.has("enableUrlSync")&&(this.enableUrlSync?this.setupUrlSync():this.teardownUrlSync()),this.controller&&!e.has("controller")){if(e.has("messages")||e.has("suggestions")||e.has("threads"))try{const e=this.controller.getState();this.handleControllerStateChange(e)}catch(e){}}e.has("messages")&&this.autoScroll&&this.messages.length>0&&this.scrollToLatestMessage(),this.updateArtifactPanelResize()}scrollToLatestMessage(){requestAnimationFrame(()=>{var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".messages");t&&(t.scrollTop=t.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(e=>{try{e()}catch(e){}})}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 e=window.location.hash.match(/^#conversation\/(.+)$/);if(e){const t=decodeURIComponent(e[1]);t!==this.activeThreadId&&this.controller&&this.controller.switchThread(t)}}syncActiveThreadToController(){var e;if(!this.controller||!this.activeThreadId)return void(this._pendingThreadId=void 0);let t;try{t=this.controller.getState()}catch(e){t=null}if((null==t?void 0:t.currentThreadId)===this.activeThreadId)return void(this._pendingThreadId=void 0);if(null===(e=null==t?void 0:t.threads)||void 0===e?void 0:e.some(e=>e.id===this.activeThreadId)){this._pendingThreadId=void 0;try{this.controller.switchThread(this.activeThreadId)}catch(e){this._pendingThreadId=this.activeThreadId}}else this._pendingThreadId=this.activeThreadId}handleControllerStateChange(e){var t,i,n,a,o,s,r;if(e.messages&&(this.messages=e.messages),e.threads&&(this.threads=e.threads),e.suggestions&&e.suggestions.length>0&&(this.suggestions=e.suggestions),e.currentThreadId&&e.currentThreadId!==this.activeThreadId&&(this.activeThreadId=e.currentThreadId),this._pendingThreadId&&(null===(t=e.threads)||void 0===t?void 0:t.some(e=>e.id===this._pendingThreadId))){const e=this._pendingThreadId;this._pendingThreadId=void 0;try{null===(i=this.controller)||void 0===i||i.switchThread(e)}catch(t){this._pendingThreadId=e}}if(this.enableUrlSync&&e.currentThreadId){const t=`#conversation/${encodeURIComponent(e.currentThreadId)}`;window.location.hash!==t&&history.replaceState(null,"",t)}if(this.chatStarted=(null===(n=e.messages)||void 0===n?void 0:n.length)>0,this.isBotTyping=e.isTyping||!1,this.statusText=e.statusText,this.isQueryRunning=e.isProcessing||!1,e.uploadedFiles&&(this.uploadedFiles=e.uploadedFiles),this.enableArtifacts){const t=null===(a=e.messages)||void 0===a?void 0:a.some(e=>{var t,i;return(null===(i=null===(t=e.metadata)||void 0===t?void 0:t.artifactIds)||void 0===i?void 0:i.length)>0});t||(this.isArtifactPanelOpen=!1,this.selectedArtifact=null)}if(this.enableArtifacts&&(null===(o=e.messages)||void 0===o?void 0:o.length)){const t=[...e.messages].reverse().find(e=>"bot"===e.sender),i=null===(s=null==t?void 0:t.metadata)||void 0===s?void 0:s.artifactIds;if(null==i?void 0:i.length){const e=i[i.length-1];if((null===(r=this.selectedArtifact)||void 0===r?void 0:r.id)!==e){const t=this.getArtifactPlugin(),i=null==t?void 0:t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}}}}handleControllerMessageSent(e){this.isQueryRunning=!0,this.isBotTyping=!0}handleControllerMessageReceived(e){}handleControllerError(e){this.isQueryRunning=!1,this.isBotTyping=!1,console.error("Controller error:",e.error)}get resolvedI18n(){var e,t,i,n,a,o,s,r,l;const c=this.i18n;return{input:Object.assign(Object.assign({},ei.input),null!==(e=null==c?void 0:c.input)&&void 0!==e?e:{}),send:Object.assign(Object.assign({},ei.send),null!==(t=null==c?void 0:c.send)&&void 0!==t?t:{}),audio:Object.assign(Object.assign({},ei.audio),null!==(i=null==c?void 0:c.audio)&&void 0!==i?i:{}),modules:Object.assign(Object.assign({},ei.modules),null!==(n=null==c?void 0:c.modules)&&void 0!==n?n:{}),threads:Object.assign(Object.assign({},ei.threads),null!==(a=null==c?void 0:c.threads)&&void 0!==a?a:{}),messages:Object.assign(Object.assign({},ei.messages),null!==(o=null==c?void 0:c.messages)&&void 0!==o?o:{}),urlModal:Object.assign(Object.assign({},ei.urlModal),null!==(s=null==c?void 0:c.urlModal)&&void 0!==s?s:{}),artifactPanel:Object.assign(Object.assign({},ei.artifactPanel),null!==(r=null==c?void 0:c.artifactPanel)&&void 0!==r?r:{}),loading:Object.assign(Object.assign({},ei.loading),null!==(l=null==c?void 0:c.loading)&&void 0!==l?l:{})}}render(){var e;const t=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(e=>"attach"===(null==e?void 0:e.type)&&!1!==(null==e?void 0:e.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:t},enableThreads:this.showThreads,enableThreadCreation:this.enableThreadCreation,isThreadSidebarOpen:this.showThreads&&this.isThreadSidebarOpen,threadSidebar:this.showThreads?{threads:this.threads,activeThreadId:this.activeThreadId,editingThreadId:this._editingThreadId,i18n:t}:void 0,enableFileUpload:this.enableFileUpload,isDragging:this._isDragging,i18n:t,enableArtifacts:this.enableArtifacts,artifactPanel:this.enableArtifacts?{artifact:this.selectedArtifact,isOpen:this.isArtifactPanelOpen,renderContent:null!==(e=this.renderArtifactContent)&&void 0!==e?e:this.getPluginArtifactRenderer(),i18n:t}:void 0,urlModal:this.isUrlModalOpen?{isOpen:this.isUrlModalOpen,urlInput:this.urlInput,isLoading:this.isUrlLoading,error:this.urlModalError,selectedFileName:this.selectedUrlFileName,i18n:t}:void 0},a={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 e;null===(e=this.controller)||void 0===e||e.createThread("New Chat")},onSelectThread:e=>{var t;e!==this.activeThreadId&&(this.enableUrlSync&&history.pushState(null,"",`#conversation/${encodeURIComponent(e)}`),null===(t=this.controller)||void 0===t||t.switchThread(e),this.dispatchEvent(new CustomEvent("nr-thread-change",{detail:{threadId:e},bubbles:!0,composed:!0})))},onDeleteThread:e=>{var t;null===(t=this.controller)||void 0===t||t.deleteThread(e)},onBookmarkThread:e=>{var t;null===(t=this.controller)||void 0===t||t.bookmarkThread(e)},onRenameThread:(e,t)=>{var i;null===(i=this.controller)||void 0===i||i.renameThread(e,t),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`
3725
3734
  <div
3726
3735
  class="chat-container ${h({"chat-container--with-threads":this.showThreads,"chat-container--disabled":this.disabled,"chat-container--focused":this.focused,"chat-container--boxed":this.boxed})}"
3727
3736
  dir=${this.isRTL?"rtl":"ltr"}
@@ -3744,7 +3753,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
3744
3753
  <span class="module-display-multiple">
3745
3754
  ${e} ${this.resolvedI18n.modules.modulesSelectedSuffix}
3746
3755
  </span>
3747
- `}handleContentEditableInput(e){const t=e.target.textContent||"";this.currentInput=t,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:t}})}handleInputFocus(e){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:e}})}handleInputBlur(e){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:e}})}clearInput(){var e;this.currentInput="";const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&(t.textContent="")}focusInput(){var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&t.focus()}handleAudioStart(e){this._audioMode=e,this._audio.start()}handleAudioCancel(){this._audio.cancel()}handleAudioSend(){return Zt(this,void 0,void 0,function*(){var e;const t=yield this._audio.stop();if(!t)return;const i=this._audioMode;null===(e=this.onAudioRecorded)||void 0===e||e.call(this,t.blob,t.mimeType,t.duration,i),this.dispatchEvent(new CustomEvent("nr-chatbot-audio-recorded",{detail:{blob:t.blob,mimeType:t.mimeType,duration:t.duration,mode:i},bubbles:!0,composed:!0}))})}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.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 e=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:e,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var e;try{null===(e=this.controller)||void 0===e||e.stop()}catch(e){console.warn("nr-chatbot: stop failed",e)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(e){e.text&&(this.currentInput=e.text,this.handleSendMessage())}handleCopyMessage(e){const t=e.text;if(!t)return;const i=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:e.id}})};navigator.clipboard?navigator.clipboard.writeText(t).then(i).catch(()=>{this.copyViaFallback(t,i)}):this.copyViaFallback(t,i)}copyViaFallback(e,t){const i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.left="-9999px",i.style.top="-9999px",document.body.appendChild(i),i.focus(),i.select();try{document.execCommand("copy"),t()}catch(e){}i.remove()}handleSuggestionClick(e){this.currentInput=e.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:e}})}handleModuleSelectionChange(e){const t=e.detail.value;this.selectedModules=t,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:t}})}handleFileDropdownClick(e){const t=e.detail.item.id;"upload-file"===t?this.openFileDialog():"upload-url"===t&&this.openUrlModal()}openFileDialog(){const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="image/*,application/pdf,text/*,video/*,audio/*",e.addEventListener("change",e=>Zt(this,void 0,void 0,function*(){var t;const i=e.target;if(i.files&&i.files.length>0){const e=Array.from(i.files);yield null===(t=this.controller)||void 0===t?void 0:t.uploadFiles(e)}})),e.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(e){const t=e.target;this.urlInput=t.value,this.urlModalError=""}handleUrlInputKeydown(e){"Enter"===e.key&&(e.preventDefault(),this.handleUrlAttachFile())}handleUrlConfirm(){this.handleUrlModalClose()}handleUrlAttachFile(){return Zt(this,void 0,void 0,function*(){if(this.urlInput.trim()){this.isUrlLoading=!0,this.urlModalError="";try{const e=yield fetch(this.urlInput);if(!e.ok)throw new Error(`Failed to fetch file: ${e.statusText}`);const t=yield e.blob(),i=this.urlInput.split("/").pop()||"downloaded-file",n=new File([t],i,{type:t.type});this.selectedUrlFileName=i,this.controller&&(yield this.controller.uploadFiles([n])),this.isUrlLoading=!1,setTimeout(()=>{this.handleUrlModalClose()},1e3)}catch(e){this.isUrlLoading=!1,this.urlModalError=e instanceof Error?e.message:"Failed to load file from URL"}}else this.urlModalError="Please enter a URL"})}handleFileRemove(e){var t;null===(t=this.controller)||void 0===t||t.removeFile(e)}dragHasFiles(e){var t;const i=null===(t=e.dataTransfer)||void 0===t?void 0:t.types;if(!i)return!1;for(let e=0;e<i.length;e++)if("Files"===i[e])return!0;return!1}handleDragEnter(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth++,this._isDragging=!0)}handleDragOver(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))}handleDragLeave(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),0===this._dragDepth&&(this._isDragging=!1))}handleDrop(e){return Zt(this,void 0,void 0,function*(){var t,i;if(!this.enableFileUpload||this.disabled)return;e.preventDefault(),this._dragDepth=0,this._isDragging=!1;const n=null===(t=e.dataTransfer)||void 0===t?void 0:t.files;n&&0!==n.length&&(yield null===(i=this.controller)||void 0===i?void 0:i.uploadFiles(Array.from(n)))})}handleFilePreview(e){this.previewFile=e,this.isFilePreviewModalOpen=!0}handleArtifactClick(e){if(!this.enableArtifacts||!this.controller)return;const t=this.getArtifactPlugin();if(!t)return;const i=t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}handleArtifactPanelClose(){this.isArtifactPanelOpen=!1,this.selectedArtifact=null}updateArtifactPanelResize(){var e,t,i;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".artifact-panel__resize-handle"),a=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel");if(!n||!a)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let o=!1,s=0,r=0;const l=e=>{if(!o)return;const t=e.clientX-s,i=a.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(a).minWidth,10)||300,c=Math.max(l,Math.min(r-t,n));a.style.width=`${c}px`},c=()=>{o&&(o=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c))},d=e=>{e.preventDefault(),o=!0,s=e.clientX,r=a.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",c)};n.addEventListener("mousedown",d),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",d),c()}}handleArtifactCopy(e){const t=e.content;t&&(navigator.clipboard?navigator.clipboard.writeText(t).catch(()=>{this.copyViaFallback(t,()=>{})}):this.copyViaFallback(t,()=>{}))}getArtifactPlugin(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;return t&&"function"==typeof t.get?t.get("artifact"):void 0}catch(e){return}}getPluginArtifactRenderer(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;if(!t||"function"!=typeof t.values)return;for(const e of t.values())if("function"==typeof e.renderArtifactContent)return t=>{const n=e.renderArtifactContent(t);if(n)return i`${u(n)}`};return}catch(e){return}}handleFilePreviewModalClose(){this.isFilePreviewModalOpen=!1,this.previewFile=null}addMessage(e){var t;const i=Object.assign({id:e.id||`msg-${Date.now()}`,sender:e.sender||Tt.User,text:e.text||"",timestamp:e.timestamp||(new Date).toISOString()},e);return null===(t=this.controller)||void 0===t||t.addMessage(i),this.chatStarted=!0,i}clearMessages(){this.messages=[],this.chatStarted=!1}};ti.useShadowDom=!0,ti.styles=Pt,Xt([s({type:Array})],ti.prototype,"messages",void 0),Xt([s({type:String})],ti.prototype,"currentInput",void 0),Xt([s({type:Boolean})],ti.prototype,"isBotTyping",void 0),Xt([s({type:Boolean})],ti.prototype,"isQueryRunning",void 0),Xt([s({type:Array})],ti.prototype,"suggestions",void 0),Xt([s({type:Boolean})],ti.prototype,"chatStarted",void 0),Xt([s({type:Boolean})],ti.prototype,"isRTL",void 0),Xt([s({type:String})],ti.prototype,"size",void 0),Xt([s({type:String})],ti.prototype,"variant",void 0),Xt([s({type:String})],ti.prototype,"loadingIndicator",void 0),Xt([s({type:String})],ti.prototype,"loadingText",void 0),Xt([s({type:Boolean})],ti.prototype,"disabled",void 0),Xt([s({type:String})],ti.prototype,"placeholder",void 0),Xt([s({type:Object})],ti.prototype,"i18n",void 0),Xt([s({type:Boolean})],ti.prototype,"showSendButton",void 0),Xt([s({type:Boolean})],ti.prototype,"autoScroll",void 0),Xt([s({type:Boolean})],ti.prototype,"showThreads",void 0),Xt([s({type:Boolean})],ti.prototype,"enableThreadCreation",void 0),Xt([s({type:Array})],ti.prototype,"threads",void 0),Xt([s({type:String})],ti.prototype,"activeThreadId",void 0),Xt([s({type:String})],ti.prototype,"mode",void 0),Xt([s({type:Boolean,reflect:!0})],ti.prototype,"boxed",void 0),Xt([s({type:Boolean})],ti.prototype,"enableUrlSync",void 0),Xt([s({type:Boolean})],ti.prototype,"showMessages",void 0),Xt([s({type:Boolean})],ti.prototype,"enableFileUpload",void 0),Xt([s({type:Array})],ti.prototype,"uploadedFiles",void 0),Xt([s({type:Array})],ti.prototype,"actionButtons",void 0),Xt([s({type:Boolean})],ti.prototype,"enableModuleSelection",void 0),Xt([s({type:Array})],ti.prototype,"modules",void 0),Xt([s({type:Array})],ti.prototype,"selectedModules",void 0),Xt([s({type:String})],ti.prototype,"moduleSelectionLabel",void 0),Xt([s({type:Boolean})],ti.prototype,"enableArtifacts",void 0),Xt([s({type:Boolean,attribute:"show-audio-button"})],ti.prototype,"showAudioButton",void 0),Xt([s({type:Function})],ti.prototype,"onAudioRecorded",void 0),Xt([s({type:Function})],ti.prototype,"renderArtifactContent",void 0),Xt([s({type:Object})],ti.prototype,"controller",void 0),Xt([r()],ti.prototype,"statusText",void 0),Xt([r()],ti.prototype,"focused",void 0),Xt([r()],ti.prototype,"isArtifactPanelOpen",void 0),Xt([r()],ti.prototype,"selectedArtifact",void 0),Xt([r()],ti.prototype,"isThreadSidebarOpen",void 0),Xt([r()],ti.prototype,"_editingThreadId",void 0),Xt([r()],ti.prototype,"isUrlModalOpen",void 0),Xt([r()],ti.prototype,"urlInput",void 0),Xt([r()],ti.prototype,"urlModalError",void 0),Xt([r()],ti.prototype,"isUrlLoading",void 0),Xt([r()],ti.prototype,"selectedUrlFileName",void 0),Xt([r()],ti.prototype,"isFilePreviewModalOpen",void 0),Xt([r()],ti.prototype,"previewFile",void 0),Xt([r()],ti.prototype,"_isDragging",void 0),ti=Xt([(e,t)=>(e.addInitializer(rt),e),l("nr-chatbot")],ti);
3756
+ `}handleContentEditableInput(e){const t=e.target.textContent||"";this.currentInput=t,this.dispatchEventWithMetadata("nr-chatbot-input-changed",{metadata:{value:t}})}handleInputFocus(e){this.focused=!0,this.dispatchEventWithMetadata("nr-chatbot-input-focused",{metadata:{event:e}})}handleInputBlur(e){this.focused=!1,this.dispatchEventWithMetadata("nr-chatbot-input-blurred",{metadata:{event:e}})}clearInput(){var e;this.currentInput="";const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&(t.textContent="")}focusInput(){var e;const t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".input-box__input");t&&t.focus()}handleAudioStart(e){this._audioMode=e,this._audio.start()}handleAudioCancel(){this._audio.cancel()}handleAudioSend(){return Zt(this,void 0,void 0,function*(){var e;const t=yield this._audio.stop();if(!t)return;const i=this._audioMode;null===(e=this.onAudioRecorded)||void 0===e||e.call(this,t.blob,t.mimeType,t.duration,i),this.dispatchEvent(new CustomEvent("nr-chatbot-audio-recorded",{detail:{blob:t.blob,mimeType:t.mimeType,duration:t.duration,mode:i},bubbles:!0,composed:!0}))})}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.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 e=this.uploadedFiles&&this.uploadedFiles.length>0?[...this.uploadedFiles]:void 0;this.controller.sendMessage(this.currentInput.trim(),{files:e,metadata:{selectedModules:this.selectedModules}}),this.clearInput(),this.chatStarted=!0,this.dispatchEventWithMetadata("nr-chatbot-message-sent",{metadata:{text:this.currentInput}})}handleStopQuery(){var e;try{null===(e=this.controller)||void 0===e||e.stop()}catch(e){console.warn("nr-chatbot: stop failed",e)}this.dispatchEventWithMetadata("nr-chatbot-query-stopped",{metadata:{action:"stop"}})}handleRetry(e){e.text&&(this.currentInput=e.text,this.handleSendMessage())}handleCopyMessage(e){const t=e.text;if(!t)return;const i=()=>{this.dispatchEventWithMetadata("nr-chatbot-message-copied",{metadata:{messageId:e.id}})};navigator.clipboard?navigator.clipboard.writeText(t).then(i).catch(()=>{this.copyViaFallback(t,i)}):this.copyViaFallback(t,i)}copyViaFallback(e,t){const i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.left="-9999px",i.style.top="-9999px",document.body.appendChild(i),i.focus(),i.select();try{document.execCommand("copy"),t()}catch(e){}i.remove()}handleSuggestionClick(e){this.currentInput=e.text,this.handleSendMessage(),this.dispatchEventWithMetadata("nr-chatbot-suggestion-clicked",{metadata:{suggestion:e}})}handleModuleSelectionChange(e){const t=e.detail.value;this.selectedModules=t,this.dispatchEventWithMetadata("nr-chatbot-modules-selected",{metadata:{modules:t}})}handleFileDropdownClick(e){const t=e.detail.item.id;"upload-file"===t?this.openFileDialog():"upload-url"===t&&this.openUrlModal()}openFileDialog(){const e=document.createElement("input");e.type="file",e.multiple=!0,e.accept="image/*,application/pdf,text/*,video/*,audio/*",e.addEventListener("change",e=>Zt(this,void 0,void 0,function*(){var t;const i=e.target;if(i.files&&i.files.length>0){const e=Array.from(i.files);yield null===(t=this.controller)||void 0===t?void 0:t.uploadFiles(e)}})),e.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(e){const t=e.target;this.urlInput=t.value,this.urlModalError=""}handleUrlInputKeydown(e){"Enter"===e.key&&(e.preventDefault(),this.handleUrlAttachFile())}handleUrlConfirm(){this.handleUrlModalClose()}handleUrlAttachFile(){return Zt(this,void 0,void 0,function*(){if(this.urlInput.trim()){this.isUrlLoading=!0,this.urlModalError="";try{const e=yield fetch(this.urlInput);if(!e.ok)throw new Error(`Failed to fetch file: ${e.statusText}`);const t=yield e.blob(),i=this.urlInput.split("/").pop()||"downloaded-file",n=new File([t],i,{type:t.type});this.selectedUrlFileName=i,this.controller&&(yield this.controller.uploadFiles([n])),this.isUrlLoading=!1,setTimeout(()=>{this.handleUrlModalClose()},1e3)}catch(e){this.isUrlLoading=!1,this.urlModalError=e instanceof Error?e.message:"Failed to load file from URL"}}else this.urlModalError="Please enter a URL"})}handleFileRemove(e){var t;null===(t=this.controller)||void 0===t||t.removeFile(e)}dragHasFiles(e){var t;const i=null===(t=e.dataTransfer)||void 0===t?void 0:t.types;if(!i)return!1;for(let e=0;e<i.length;e++)if("Files"===i[e])return!0;return!1}handleDragEnter(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth++,this._isDragging=!0)}handleDragOver(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"))}handleDragLeave(e){this.enableFileUpload&&!this.disabled&&this.dragHasFiles(e)&&(e.preventDefault(),this._dragDepth=Math.max(0,this._dragDepth-1),0===this._dragDepth&&(this._isDragging=!1))}handleDrop(e){return Zt(this,void 0,void 0,function*(){var t,i;if(!this.enableFileUpload||this.disabled)return;e.preventDefault(),this._dragDepth=0,this._isDragging=!1;const n=null===(t=e.dataTransfer)||void 0===t?void 0:t.files;n&&0!==n.length&&(yield null===(i=this.controller)||void 0===i?void 0:i.uploadFiles(Array.from(n)))})}handleFilePreview(e){this.previewFile=e,this.isFilePreviewModalOpen=!0}handleArtifactClick(e){if(!this.enableArtifacts||!this.controller)return;const t=this.getArtifactPlugin();if(!t)return;const i=t.getArtifact(e);i&&(this.selectedArtifact=i,this.isArtifactPanelOpen=!0)}handleArtifactPanelClose(){this.isArtifactPanelOpen=!1,this.selectedArtifact=null}updateArtifactPanelResize(){var e,t,i;const n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".artifact-panel__resize-handle"),a=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".artifact-panel");if(!n||!a)return null===(i=this._artifactResizeCleanup)||void 0===i||i.call(this),void(this._artifactResizeBound=!1);if(this._artifactResizeBound)return;this._artifactResizeBound=!0;let o=!1,s=0,r=0;const l=e=>{if(!o)return;const t=e.clientX-s,i=a.parentElement,n=i?.85*i.getBoundingClientRect().width:1200,l=Number.parseInt(getComputedStyle(a).minWidth,10)||300,c=Math.max(l,Math.min(r-t,n));a.style.width=`${c}px`},c=()=>{o&&(o=!1,n.classList.remove("artifact-panel__resize-handle--active"),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c))},d=e=>{e.preventDefault(),o=!0,s=e.clientX,r=a.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",c)};n.addEventListener("mousedown",d),this._artifactResizeCleanup=()=>{n.removeEventListener("mousedown",d),c()}}handleArtifactCopy(e){const t=e.content;t&&(navigator.clipboard?navigator.clipboard.writeText(t).catch(()=>{this.copyViaFallback(t,()=>{})}):this.copyViaFallback(t,()=>{}))}getArtifactPlugin(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;return t&&"function"==typeof t.get?t.get("artifact"):void 0}catch(e){return}}getPluginArtifactRenderer(){var e;try{const t=null===(e=this.controller)||void 0===e?void 0:e.plugins;if(!t||"function"!=typeof t.values)return;for(const e of t.values())if("function"==typeof e.renderArtifactContent)return t=>{const n=e.renderArtifactContent(t);if(n)return i`${u(n)}`};return}catch(e){return}}handleFilePreviewModalClose(){this.isFilePreviewModalOpen=!1,this.previewFile=null}addMessage(e){var t;const i=Object.assign({id:e.id||`msg-${Date.now()}`,sender:e.sender||Tt.User,text:e.text||"",timestamp:e.timestamp||(new Date).toISOString()},e);return null===(t=this.controller)||void 0===t||t.addMessage(i),this.chatStarted=!0,i}clearMessages(){this.messages=[],this.chatStarted=!1}};ti.useShadowDom=!0,ti.styles=Pt,Xt([s({type:Array})],ti.prototype,"messages",void 0),Xt([s({type:String})],ti.prototype,"currentInput",void 0),Xt([s({type:Boolean})],ti.prototype,"isBotTyping",void 0),Xt([s({type:Boolean})],ti.prototype,"isQueryRunning",void 0),Xt([s({type:Array})],ti.prototype,"suggestions",void 0),Xt([s({type:Boolean})],ti.prototype,"chatStarted",void 0),Xt([s({type:Boolean})],ti.prototype,"isRTL",void 0),Xt([s({type:String})],ti.prototype,"size",void 0),Xt([s({type:String})],ti.prototype,"variant",void 0),Xt([s({type:String})],ti.prototype,"loadingIndicator",void 0),Xt([s({type:String})],ti.prototype,"loadingText",void 0),Xt([s({type:Boolean})],ti.prototype,"disabled",void 0),Xt([s({type:String})],ti.prototype,"placeholder",void 0),Xt([s({type:Object})],ti.prototype,"i18n",void 0),Xt([s({type:Boolean})],ti.prototype,"showSendButton",void 0),Xt([s({type:Boolean})],ti.prototype,"autoScroll",void 0),Xt([s({type:Boolean})],ti.prototype,"showThreads",void 0),Xt([s({type:Boolean})],ti.prototype,"enableThreadCreation",void 0),Xt([s({type:Array})],ti.prototype,"threads",void 0),Xt([s({type:String,attribute:"active-thread-id"})],ti.prototype,"activeThreadId",void 0),Xt([s({type:String})],ti.prototype,"mode",void 0),Xt([s({type:Boolean,reflect:!0})],ti.prototype,"boxed",void 0),Xt([s({type:Boolean})],ti.prototype,"enableUrlSync",void 0),Xt([s({type:Boolean})],ti.prototype,"showMessages",void 0),Xt([s({type:String,attribute:"welcome-message"})],ti.prototype,"welcomeMessage",void 0),Xt([s({type:Boolean})],ti.prototype,"enableFileUpload",void 0),Xt([s({type:Array})],ti.prototype,"uploadedFiles",void 0),Xt([s({type:Array})],ti.prototype,"actionButtons",void 0),Xt([s({type:Boolean})],ti.prototype,"enableModuleSelection",void 0),Xt([s({type:Array})],ti.prototype,"modules",void 0),Xt([s({type:Array})],ti.prototype,"selectedModules",void 0),Xt([s({type:String})],ti.prototype,"moduleSelectionLabel",void 0),Xt([s({type:Boolean})],ti.prototype,"enableArtifacts",void 0),Xt([s({type:Boolean,attribute:"show-audio-button"})],ti.prototype,"showAudioButton",void 0),Xt([s({type:Function})],ti.prototype,"onAudioRecorded",void 0),Xt([s({type:Function})],ti.prototype,"renderArtifactContent",void 0),Xt([s({type:Object})],ti.prototype,"controller",void 0),Xt([r()],ti.prototype,"statusText",void 0),Xt([r()],ti.prototype,"focused",void 0),Xt([r()],ti.prototype,"isArtifactPanelOpen",void 0),Xt([r()],ti.prototype,"selectedArtifact",void 0),Xt([r()],ti.prototype,"isThreadSidebarOpen",void 0),Xt([r()],ti.prototype,"_editingThreadId",void 0),Xt([r()],ti.prototype,"isUrlModalOpen",void 0),Xt([r()],ti.prototype,"urlInput",void 0),Xt([r()],ti.prototype,"urlModalError",void 0),Xt([r()],ti.prototype,"isUrlLoading",void 0),Xt([r()],ti.prototype,"selectedUrlFileName",void 0),Xt([r()],ti.prototype,"isFilePreviewModalOpen",void 0),Xt([r()],ti.prototype,"previewFile",void 0),Xt([r()],ti.prototype,"_isDragging",void 0),Xt([r()],ti.prototype,"_pendingThreadId",void 0),ti=Xt([(e,t)=>(e.addInitializer(rt),e),l("nr-chatbot")],ti);
3748
3757
  /**
3749
3758
  * @license
3750
3759
  * Copyright 2023 Nuraly, Laabidi Aymen
@@ -3805,13 +3814,13 @@ class ii{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(
3805
3814
  * @license
3806
3815
  * Copyright 2023 Nuraly, Laabidi Aymen
3807
3816
  * SPDX-License-Identifier: MIT
3808
- */var mi=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class xi{constructor(e){this.plugins=new Map,e&&e.forEach(e=>this.registerPlugin(e))}registerPlugin(e,t){if(this.plugins.has(e.id))this.log(`Plugin "${e.id}" is already registered, skipping`);else if(this.plugins.set(e.id,e),this.log(`Registered plugin: ${e.name} v${e.version}`),e.onInit&&t)try{e.onInit(t)}catch(t){this.logError(`Error initializing plugin "${e.id}":`,t)}}unregisterPlugin(e){const t=this.plugins.get(e);if(t&&t.onDestroy)try{t.onDestroy()}catch(t){this.logError(`Error destroying plugin "${e}":`,t)}this.plugins.delete(e),this.log(`Unregistered plugin: ${e}`)}getPlugin(e){return this.plugins.get(e)}getAllPlugins(){return Array.from(this.plugins.values())}hasPlugin(e){return this.plugins.has(e)}getPluginsMap(){return this.plugins}executeHook(e,...t){return mi(this,void 0,void 0,function*(){for(const i of this.plugins.values()){const n=i[e];if("function"==typeof n)try{yield n(...t)}catch(t){this.logError(`Error executing hook "${String(e)}" on plugin "${i.id}":`,t)}}})}clearPlugins(){this.plugins.forEach((e,t)=>{this.unregisterPlugin(t)}),this.plugins.clear()}getPluginCount(){return this.plugins.size}log(e){console.log(`[PluginService] ${e}`)}logError(e,t){console.error(`[PluginService] ${e}`,t)}}const yi=["ar","fr"],wi="__nuraly_localization__";!function(){if(globalThis[wi])return globalThis[wi];const e=kt({sourceLocale:"en",targetLocales:yi,loadLocale:e=>import(`../../locales/generated/${e}.js`)});globalThis[wi]=e}();
3817
+ */var mi=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class yi{constructor(e){this.plugins=new Map,e&&e.forEach(e=>this.registerPlugin(e))}registerPlugin(e,t){if(this.plugins.has(e.id))this.log(`Plugin "${e.id}" is already registered, skipping`);else if(this.plugins.set(e.id,e),this.log(`Registered plugin: ${e.name} v${e.version}`),e.onInit&&t)try{e.onInit(t)}catch(t){this.logError(`Error initializing plugin "${e.id}":`,t)}}unregisterPlugin(e){const t=this.plugins.get(e);if(t&&t.onDestroy)try{t.onDestroy()}catch(t){this.logError(`Error destroying plugin "${e}":`,t)}this.plugins.delete(e),this.log(`Unregistered plugin: ${e}`)}getPlugin(e){return this.plugins.get(e)}getAllPlugins(){return Array.from(this.plugins.values())}hasPlugin(e){return this.plugins.has(e)}getPluginsMap(){return this.plugins}executeHook(e,...t){return mi(this,void 0,void 0,function*(){for(const i of this.plugins.values()){const n=i[e];if("function"==typeof n)try{yield n(...t)}catch(t){this.logError(`Error executing hook "${String(e)}" on plugin "${i.id}":`,t)}}})}clearPlugins(){this.plugins.forEach((e,t)=>{this.unregisterPlugin(t)}),this.plugins.clear()}getPluginCount(){return this.plugins.size}log(e){console.log(`[PluginService] ${e}`)}logError(e,t){console.error(`[PluginService] ${e}`,t)}}const xi=["ar","fr"],wi="__nuraly_localization__";!function(){if(globalThis[wi])return globalThis[wi];const e=kt({sourceLocale:"en",targetLocales:xi,loadLocale:e=>import(`../../locales/generated/${e}.js`)});globalThis[wi]=e}();
3809
3818
  /**
3810
3819
  * @license
3811
3820
  * Copyright 2023 Nuraly, Laabidi Aymen
3812
3821
  * SPDX-License-Identifier: MIT
3813
3822
  */
3814
- var $i=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class ki{constructor(e={}){this.plugins=new Map,this.config=e,this.ui=e.ui||{},this.eventBus=new ii,this.pluginService=new xi,this.plugins=this.pluginService.getPluginsMap(),e.plugins&&e.plugins.forEach(e=>this.pluginService.registerPlugin(e,this));const t=this.initializeState(e);if(this.stateHandler=new ai(t,this.eventBus,this.ui,this.plugins,this.config),this.messageHandler=new oi(this.stateHandler,this.eventBus,this.plugins),this.threadHandler=new ri(this.stateHandler,this.eventBus,this.ui,this.config,e.provider),this.fileHandler=new ci(this.stateHandler,this.eventBus),this.moduleHandler=new di(this.stateHandler,this.eventBus),this.suggestionHandler=new pi(this.stateHandler),this.providerService=new ui(e.provider,this.stateHandler,this.messageHandler,this.fileHandler,this.eventBus,this.ui,this.plugins),this.validationService=new fi(this.config),this.storageService=new gi(e.storage,this.stateHandler,this.config),e.provider){const t=e.provider;queueMicrotask(()=>{this.initializeProvider(t)})}this.setupLifecycleHooks()}initializeProvider(e){return $i(this,void 0,void 0,function*(){try{e.isConnected()||(yield e.connect({})),yield this.autoLoadConversations(e)}catch(e){this.logError("Failed to connect provider:",e)}})}initializeState(e){const t=e.initialMessages?e.initialMessages.map(e=>this.processMessageThroughPlugins(e)):[];return{messages:t,threads:e.initialThreads||[],modules:e.enableModules?[]:void 0,selectedModules:[],uploadedFiles:[],suggestions:e.initialSuggestions||[],isTyping:!1,isProcessing:!1,currentThreadId:void 0,metadata:e.metadata||{}}}processMessageThroughPlugins(e){if(!e.text||"string"!=typeof e.text)return e;const t=Array.from(this.plugins.values()).filter(e=>Array.isArray(e.htmlTags)&&e.htmlTags.length>0);if(0===t.length)return e;let i=e.text,n=!1;for(const e of t){const t=e.htmlTags;for(const a of t){const t=a.open,o=a.close;let s=0;for(;;){const r=i.indexOf(t,s);if(-1===r)break;const l=r+t.length,c=i.indexOf(o,l);if(-1===c){s=l;continue}const d=i.substring(l,c);let p="";if("function"==typeof e.renderHtmlBlock)try{p=e.renderHtmlBlock(a.name,d)}catch(t){console.error(`[ChatbotCore] Error rendering HTML block for plugin ${e.id}:`,t)}p?(i=i.substring(0,r)+p+i.substring(c+o.length),n=!0,s=r+p.length):s=c+o.length}}}return n?Object.assign(Object.assign({},e),{text:i,metadata:Object.assign(Object.assign({},e.metadata),{renderAsHtml:!0})}):e}processRestoredMessagesForPlugins(){const e=this.stateHandler.getState();if(e.messages&&0!==e.messages.length)for(const t of e.messages)"bot"===t.sender&&this.plugins.forEach(e=>{if(e.onMessageReceived)try{e.onMessageReceived(t)}catch(e){}})}setupLifecycleHooks(){this.onBeforeInit(),this.onReady().catch(e=>{this.logError("Error during initialization:",e)})}onBeforeInit(){this.log("Initializing chatbot controller...")}onReady(){return $i(this,void 0,void 0,function*(){this.log("Chatbot controller ready");try{const e=this.stateHandler.getState(),t=e.messages&&e.messages.length>0?e.messages[0]:void 0;t&&"bot"===t.sender&&t.introduction&&Array.isArray(t.suggestions)&&t.suggestions.length>0&&this.suggestionHandler.setSuggestions(t.suggestions)}catch(e){this.logError("Error initializing suggestions from initial messages:",e)}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(e){this.stateHandler.updateState(e)}sendMessage(e){return $i(this,arguments,void 0,function*(e,t={}){this.log("Sending message:",e);try{const i=this.stateHandler.getState();this.config.enableThreads&&!i.currentThreadId&&(yield this.threadHandler.createThread("New Chat"));const n=yield this.beforeMessageSent(e,t);if(!t.skipValidation){const e=yield this.validationService.validateMessage(n);if(!e.isValid){const t=new ni(e.errors);throw this.handleValidationError(t),t}}const a=this.messageHandler.createUserMessage(n,t.metadata);t.files&&(a.files=t.files),this.messageHandler.addMessage(a);const o=this.stateHandler.getState();return(t.threadId||o.currentThreadId)&&this.threadHandler.updateThreadMessages(t.threadId||o.currentThreadId),yield this.afterMessageSent(a),this.providerService.processMessage(a).catch(e=>{this.logError("Error processing with provider:",e)}),a}catch(e){throw this.handleError(e),e}})}stop(){this.providerService.stopCurrentProcessing()}addMessage(e){const t=this.messageHandler.createMessage(e),i="bot"===t.sender?this.processMessageThroughPlugins(t):t;return this.messageHandler.addMessage(i),i}updateMessage(e,t){this.messageHandler.updateMessage(e,t)}deleteMessage(e){this.messageHandler.deleteMessage(e)}clearMessages(){this.updateState({messages:[]})}getMessages(){return this.stateHandler.getState().messages}uploadFiles(e){return $i(this,void 0,void 0,function*(){if(!this.config.enableFileUpload)throw new Error("File upload is not enabled");let t=e;if(!t&&this.ui.openFileDialog&&(t=yield this.ui.openFileDialog()),!t||0===t.length)return[];const i=[];for(const e of t)try{const t=yield this.validationService.validateFile(e,{maxFileSize:this.config.maxFileSize,allowedTypes:this.config.allowedFileTypes});if(!t.isValid){this.ui.showNotification&&this.ui.showNotification(t.errors[0]||"File validation failed","error");continue}const n=yield this.fileHandler.createChatbotFile(e);this.fileHandler.addFile(n);try{const t=yield this.providerService.uploadFileToProvider(e),a=Object.assign({isUploading:!1,uploadProgress:100},t||{});this.fileHandler.updateFile(n.id,a),Object.assign(n,a),i.push(n),this.ui.showFilePreview&&this.ui.showFilePreview(n)}catch(e){throw this.fileHandler.removeFile(n.id),e}}catch(t){this.logError("Error uploading file:",t),this.ui.showNotification&&this.ui.showNotification(`Failed to upload ${e.name}`,"error")}return i})}removeFile(e){this.fileHandler.removeFile(e)}clearFiles(){this.fileHandler.clearFiles()}getUploadedFiles(){return this.stateHandler.getState().uploadedFiles}createThread(e){return $i(this,void 0,void 0,function*(){return yield this.threadHandler.createThread(e)})}switchThread(e){this.threadHandler.switchThread(e),this.processRestoredMessagesForPlugins()}deleteThread(e){this.threadHandler.deleteThread(e)}renameThread(e,t){this.threadHandler.renameThread(e,t)}bookmarkThread(e){this.threadHandler.bookmarkThread(e)}getCurrentThread(){const e=this.stateHandler.getState();return e.threads.find(t=>t.id===e.currentThreadId)}getThreads(){return this.stateHandler.getState().threads}setModules(e){this.moduleHandler.setModules(e)}selectModules(e){this.moduleHandler.selectModules(e)}toggleModule(e){this.moduleHandler.toggleModule(e)}getSelectedModules(){return this.moduleHandler.getSelectedModules()}setSuggestions(e){this.suggestionHandler.setSuggestions(e)}clearSuggestions(){this.suggestionHandler.clearSuggestions()}beforeMessageSent(e,t){return $i(this,void 0,void 0,function*(){let t=e;for(const e of this.plugins.values())e.beforeSend&&(t=yield e.beforeSend(t));return t})}afterMessageSent(e){return $i(this,void 0,void 0,function*(){this.log("Message sent:",e)})}beforeProviderCall(e){return $i(this,void 0,void 0,function*(){this.log("Calling provider for message:",e.id)})}afterProviderCall(){return $i(this,void 0,void 0,function*(){this.log("Provider call completed")})}handleProviderError(e){return $i(this,void 0,void 0,function*(){this.logError("Provider error:",e);const t=this.messageHandler.createMessage({sender:Tt.Bot,text:"Sorry, there was an error processing your request.",state:zt.Error,timestamp:(new Date).toISOString()});this.messageHandler.addMessage(t),this.ui.showNotification&&this.ui.showNotification("Failed to process message","error"),this.emit("provider:error",e),yield this.pluginService.executeHook("onError",e)})}handleValidationError(e){this.logError("Validation error:",e),this.ui.showNotification&&this.ui.showNotification(e.errors[0],"error"),this.emit("validation:error",e)}handleError(e){this.logError("Error:",e),this.emit("error",e),this.plugins.forEach(t=>{t.onError&&t.onError(e)})}registerPlugin(e){this.pluginService.registerPlugin(e,this)}unregisterPlugin(e){this.pluginService.unregisterPlugin(e)}getPlugin(e){return this.pluginService.getPlugin(e)}setProvider(e){this.providerService.setProvider(e),e.isConnected()?(this.autoLoadConversations(e).catch(e=>{this.logError("Failed to auto-load conversations:",e)}),this.emit("provider:connected",e.id)):e.connect({}).then(()=>$i(this,void 0,void 0,function*(){yield this.autoLoadConversations(e),this.emit("provider:connected",e.id)})).catch(e=>{this.logError("Failed to connect provider:",e)})}setStorage(e){this.storageService.setStorage(e)}saveToStorage(){return $i(this,arguments,void 0,function*(e="chatbot-state"){yield this.storageService.saveState(e)})}loadFromStorage(){return $i(this,arguments,void 0,function*(e="chatbot-state"){yield this.storageService.loadState(e);const t=this.stateHandler.getState();if(t.messages&&t.messages.length>0){const e=t.messages.map(e=>this.processMessageThroughPlugins(e));this.stateHandler.updateState({messages:e}),this.processRestoredMessagesForPlugins()}})}on(e,t){return this.eventBus.on(e,t)}emit(e,t){this.eventBus.emit(e,t)}getState(){return this.stateHandler.getState()}setState(e){e.messages&&Array.isArray(e.messages)&&(e.messages=e.messages.map(e=>this.processMessageThroughPlugins(e))),e.threads&&Array.isArray(e.threads)&&(e.threads=e.threads.map(e=>Object.assign(Object.assign({},e),{messages:e.messages.map(e=>this.processMessageThroughPlugins(e))}))),this.updateState(e),e.messages&&this.processRestoredMessagesForPlugins()}loadConversations(e){const t=e.map(e=>Object.assign(Object.assign({},e),{messages:e.messages.map(e=>this.processMessageThroughPlugins(e))}));this.updateState({threads:t,currentThreadId:t.length>0?t[0].id:void 0,messages:t.length>0?t[0].messages:[]}),this.processRestoredMessagesForPlugins()}autoLoadConversations(e){return $i(this,void 0,void 0,function*(){if(e&&"function"==typeof e.loadConversations)try{this.log("Auto-loading conversations from provider...");const t=yield e.loadConversations();if(Array.isArray(t)&&t.length>0){this.log(`Loaded ${t.length} conversation summaries`);const i=[];if("function"==typeof e.loadConversation)for(const n of t)try{const t=yield e.loadConversation(n.id);if(t){const e={id:t.id,title:t.title,messages:t.messages||[],createdAt:t.createdAt,updatedAt:t.updatedAt};i.push(e)}}catch(e){this.logError(`Failed to load conversation ${n.id}:`,e)}else for(const e of t){const t={id:e.id,title:e.title,messages:[],createdAt:e.createdAt,updatedAt:e.updatedAt};i.push(t)}i.length>0&&(this.log(`Successfully loaded ${i.length} conversations`),this.loadConversations(i))}else this.log("No conversations to load from provider")}catch(e){this.logError("Failed to auto-load conversations from provider:",e)}})}setUICallbacks(e){this.ui=Object.assign(Object.assign({},this.ui),e)}getConfig(){return Object.freeze(Object.assign({},this.config))}updateConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}setTyping(e){this.updateState({isTyping:e}),this.emit(e?"typing:start":"typing:end")}setStatusText(e){this.updateState({statusText:e})}clearStatusText(){this.updateState({statusText:void 0})}getContext(){const e=this.stateHandler.getState();return{messages:e.messages,currentThread:this.getCurrentThread(),selectedModules:e.selectedModules,metadata:e.metadata,uploadedFiles:e.uploadedFiles}}destroy(){this.onDestroy()}generateId(e){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatFileSize(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(2)} KB`:`${(e/1048576).toFixed(2)} MB`}log(...e){this.config.debug&&console.log("[ChatbotCore]",...e)}logError(...e){console.error("[ChatbotCore]",...e)}}
3823
+ var $i=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class ki{constructor(e={}){this.plugins=new Map,this.config=e,this.ui=e.ui||{},this.eventBus=new ii,this.pluginService=new yi,this.plugins=this.pluginService.getPluginsMap(),e.plugins&&e.plugins.forEach(e=>this.pluginService.registerPlugin(e,this));const t=this.initializeState(e);if(this.stateHandler=new ai(t,this.eventBus,this.ui,this.plugins,this.config),this.messageHandler=new oi(this.stateHandler,this.eventBus,this.plugins),this.threadHandler=new ri(this.stateHandler,this.eventBus,this.ui,this.config,e.provider),this.fileHandler=new ci(this.stateHandler,this.eventBus),this.moduleHandler=new di(this.stateHandler,this.eventBus),this.suggestionHandler=new pi(this.stateHandler),this.providerService=new ui(e.provider,this.stateHandler,this.messageHandler,this.fileHandler,this.eventBus,this.ui,this.plugins),this.validationService=new fi(this.config),this.storageService=new gi(e.storage,this.stateHandler,this.config),e.provider){const t=e.provider;queueMicrotask(()=>{this.initializeProvider(t)})}this.setupLifecycleHooks()}initializeProvider(e){return $i(this,void 0,void 0,function*(){try{e.isConnected()||(yield e.connect({})),yield this.autoLoadConversations(e)}catch(e){this.logError("Failed to connect provider:",e)}})}initializeState(e){const t=e.initialMessages?e.initialMessages.map(e=>this.processMessageThroughPlugins(e)):[];return{messages:t,threads:e.initialThreads||[],modules:e.enableModules?[]:void 0,selectedModules:[],uploadedFiles:[],suggestions:e.initialSuggestions||[],isTyping:!1,isProcessing:!1,currentThreadId:void 0,metadata:e.metadata||{}}}processMessageThroughPlugins(e){if(!e.text||"string"!=typeof e.text)return e;const t=Array.from(this.plugins.values()).filter(e=>Array.isArray(e.htmlTags)&&e.htmlTags.length>0);if(0===t.length)return e;let i=e.text,n=!1;for(const e of t){const t=e.htmlTags;for(const a of t){const t=a.open,o=a.close;let s=0;for(;;){const r=i.indexOf(t,s);if(-1===r)break;const l=r+t.length,c=i.indexOf(o,l);if(-1===c){s=l;continue}const d=i.substring(l,c);let p="";if("function"==typeof e.renderHtmlBlock)try{p=e.renderHtmlBlock(a.name,d)}catch(t){console.error(`[ChatbotCore] Error rendering HTML block for plugin ${e.id}:`,t)}p?(i=i.substring(0,r)+p+i.substring(c+o.length),n=!0,s=r+p.length):s=c+o.length}}}return n?Object.assign(Object.assign({},e),{text:i,metadata:Object.assign(Object.assign({},e.metadata),{renderAsHtml:!0})}):e}processRestoredMessagesForPlugins(){const e=this.stateHandler.getState();if(e.messages&&0!==e.messages.length)for(const t of e.messages)"bot"===t.sender&&this.plugins.forEach(e=>{if(e.onMessageReceived)try{e.onMessageReceived(t)}catch(e){}})}setupLifecycleHooks(){this.onBeforeInit(),this.onReady().catch(e=>{this.logError("Error during initialization:",e)})}onBeforeInit(){this.log("Initializing chatbot controller...")}onReady(){return $i(this,void 0,void 0,function*(){this.log("Chatbot controller ready");try{const e=this.stateHandler.getState(),t=e.messages&&e.messages.length>0?e.messages[0]:void 0;t&&"bot"===t.sender&&t.introduction&&Array.isArray(t.suggestions)&&t.suggestions.length>0&&this.suggestionHandler.setSuggestions(t.suggestions)}catch(e){this.logError("Error initializing suggestions from initial messages:",e)}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(e){this.stateHandler.updateState(e)}sendMessage(e){return $i(this,arguments,void 0,function*(e,t={}){this.log("Sending message:",e);try{const i=this.stateHandler.getState();this.config.enableThreads&&!i.currentThreadId&&(yield this.threadHandler.createThread("New Chat"));const n=yield this.beforeMessageSent(e,t);if(!t.skipValidation){const e=yield this.validationService.validateMessage(n);if(!e.isValid){const t=new ni(e.errors);throw this.handleValidationError(t),t}}const a=this.messageHandler.createUserMessage(n,t.metadata);t.files&&(a.files=t.files),this.messageHandler.addMessage(a);const o=this.stateHandler.getState();return(t.threadId||o.currentThreadId)&&this.threadHandler.updateThreadMessages(t.threadId||o.currentThreadId),yield this.afterMessageSent(a),this.providerService.processMessage(a).catch(e=>{this.logError("Error processing with provider:",e)}),a}catch(e){throw this.handleError(e),e}})}stop(){this.providerService.stopCurrentProcessing()}addMessage(e){const t=this.messageHandler.createMessage(e),i="bot"===t.sender?this.processMessageThroughPlugins(t):t;return this.messageHandler.addMessage(i),i}updateMessage(e,t){this.messageHandler.updateMessage(e,t)}deleteMessage(e){this.messageHandler.deleteMessage(e)}clearMessages(){this.updateState({messages:[]})}getMessages(){return this.stateHandler.getState().messages}uploadFiles(e){return $i(this,void 0,void 0,function*(){if(!this.config.enableFileUpload)throw new Error("File upload is not enabled");let t=e;if(!t&&this.ui.openFileDialog&&(t=yield this.ui.openFileDialog()),!t||0===t.length)return[];const i=[];for(const e of t)try{const t=yield this.validationService.validateFile(e,{maxFileSize:this.config.maxFileSize,allowedTypes:this.config.allowedFileTypes});if(!t.isValid){this.ui.showNotification&&this.ui.showNotification(t.errors[0]||"File validation failed","error");continue}const n=yield this.fileHandler.createChatbotFile(e);this.fileHandler.addFile(n);try{const t=yield this.providerService.uploadFileToProvider(e),a=Object.assign({isUploading:!1,uploadProgress:100},t||{});this.fileHandler.updateFile(n.id,a),Object.assign(n,a),i.push(n),this.ui.showFilePreview&&this.ui.showFilePreview(n)}catch(e){throw this.fileHandler.removeFile(n.id),e}}catch(t){this.logError("Error uploading file:",t),this.ui.showNotification&&this.ui.showNotification(`Failed to upload ${e.name}`,"error")}return i})}removeFile(e){this.fileHandler.removeFile(e)}clearFiles(){this.fileHandler.clearFiles()}getUploadedFiles(){return this.stateHandler.getState().uploadedFiles}createThread(e){return $i(this,void 0,void 0,function*(){return yield this.threadHandler.createThread(e)})}switchThread(e){this.threadHandler.switchThread(e),this.processRestoredMessagesForPlugins()}deleteThread(e){this.threadHandler.deleteThread(e)}renameThread(e,t){this.threadHandler.renameThread(e,t)}bookmarkThread(e){this.threadHandler.bookmarkThread(e)}getCurrentThread(){const e=this.stateHandler.getState();return e.threads.find(t=>t.id===e.currentThreadId)}getThreads(){return this.stateHandler.getState().threads}setModules(e){this.moduleHandler.setModules(e)}selectModules(e){this.moduleHandler.selectModules(e)}toggleModule(e){this.moduleHandler.toggleModule(e)}getSelectedModules(){return this.moduleHandler.getSelectedModules()}setSuggestions(e){this.suggestionHandler.setSuggestions(e)}clearSuggestions(){this.suggestionHandler.clearSuggestions()}beforeMessageSent(e,t){return $i(this,void 0,void 0,function*(){let t=e;for(const e of this.plugins.values())e.beforeSend&&(t=yield e.beforeSend(t));return t})}afterMessageSent(e){return $i(this,void 0,void 0,function*(){this.log("Message sent:",e)})}beforeProviderCall(e){return $i(this,void 0,void 0,function*(){this.log("Calling provider for message:",e.id)})}afterProviderCall(){return $i(this,void 0,void 0,function*(){this.log("Provider call completed")})}handleProviderError(e){return $i(this,void 0,void 0,function*(){this.logError("Provider error:",e);const t=this.messageHandler.createMessage({sender:Tt.Bot,text:"Sorry, there was an error processing your request.",state:zt.Error,timestamp:(new Date).toISOString()});this.messageHandler.addMessage(t),this.ui.showNotification&&this.ui.showNotification("Failed to process message","error"),this.emit("provider:error",e),yield this.pluginService.executeHook("onError",e)})}handleValidationError(e){this.logError("Validation error:",e),this.ui.showNotification&&this.ui.showNotification(e.errors[0],"error"),this.emit("validation:error",e)}handleError(e){this.logError("Error:",e),this.emit("error",e),this.plugins.forEach(t=>{t.onError&&t.onError(e)})}registerPlugin(e){this.pluginService.registerPlugin(e,this)}unregisterPlugin(e){this.pluginService.unregisterPlugin(e)}getPlugin(e){return this.pluginService.getPlugin(e)}setProvider(e){this.providerService.setProvider(e),e.isConnected()?(this.autoLoadConversations(e).catch(e=>{this.logError("Failed to auto-load conversations:",e)}),this.emit("provider:connected",e.id)):e.connect({}).then(()=>$i(this,void 0,void 0,function*(){yield this.autoLoadConversations(e),this.emit("provider:connected",e.id)})).catch(e=>{this.logError("Failed to connect provider:",e)})}setStorage(e){this.storageService.setStorage(e)}saveToStorage(){return $i(this,arguments,void 0,function*(e="chatbot-state"){yield this.storageService.saveState(e)})}loadFromStorage(){return $i(this,arguments,void 0,function*(e="chatbot-state"){yield this.storageService.loadState(e);const t=this.stateHandler.getState();if(t.messages&&t.messages.length>0){const e=t.messages.map(e=>this.processMessageThroughPlugins(e));this.stateHandler.updateState({messages:e}),this.processRestoredMessagesForPlugins()}})}on(e,t){return this.eventBus.on(e,t)}emit(e,t){this.eventBus.emit(e,t)}getState(){return this.stateHandler.getState()}setState(e){e.messages&&Array.isArray(e.messages)&&(e.messages=e.messages.map(e=>this.processMessageThroughPlugins(e))),e.threads&&Array.isArray(e.threads)&&(e.threads=e.threads.map(e=>Object.assign(Object.assign({},e),{messages:e.messages.map(e=>this.processMessageThroughPlugins(e))}))),this.updateState(e),e.messages&&this.processRestoredMessagesForPlugins()}loadConversations(e){const t=e.map(e=>Object.assign(Object.assign({},e),{messages:e.messages.map(e=>this.processMessageThroughPlugins(e))}));this.updateState({threads:t,currentThreadId:t.length>0?t[0].id:void 0,messages:t.length>0?t[0].messages:[]}),this.processRestoredMessagesForPlugins()}autoLoadConversations(e){return $i(this,void 0,void 0,function*(){if(e&&"function"==typeof e.loadConversations)try{this.log("Auto-loading conversations from provider...");const t=yield e.loadConversations();if(Array.isArray(t)&&t.length>0){this.log(`Loaded ${t.length} conversation summaries`);const i=[];if("function"==typeof e.loadConversation)for(const n of t)try{const t=yield e.loadConversation(n.id);if(t){const e={id:t.id,title:t.title,messages:t.messages||[],createdAt:t.createdAt,updatedAt:t.updatedAt};i.push(e)}}catch(e){this.logError(`Failed to load conversation ${n.id}:`,e)}else for(const e of t){const t={id:e.id,title:e.title,messages:[],createdAt:e.createdAt,updatedAt:e.updatedAt};i.push(t)}i.length>0&&(this.log(`Successfully loaded ${i.length} conversations`),this.loadConversations(i))}else this.log("No conversations to load from provider")}catch(e){this.logError("Failed to auto-load conversations from provider:",e)}})}setUICallbacks(e){this.ui=Object.assign(Object.assign({},this.ui),e)}getConfig(){return Object.freeze(Object.assign({},this.config))}updateConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}setTyping(e){this.updateState({isTyping:e}),this.emit(e?"typing:start":"typing:end")}setStatusText(e){this.updateState({statusText:e})}clearStatusText(){this.updateState({statusText:void 0})}getContext(){const e=this.stateHandler.getState();return{messages:e.messages,currentThread:this.getCurrentThread(),selectedModules:e.selectedModules,metadata:e.metadata,uploadedFiles:e.uploadedFiles}}destroy(){this.onDestroy()}generateId(e){return`${e}_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}formatFileSize(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(2)} KB`:`${(e/1048576).toFixed(2)} MB`}log(...e){this.config.debug&&console.log("[ChatbotCore]",...e)}logError(...e){console.error("[ChatbotCore]",...e)}}
3815
3824
  /**
3816
3825
  * @license
3817
3826
  * Copyright 2024 Nuraly, Laabidi Aymen
@@ -5254,7 +5263,7 @@ const hn=e`
5254
5263
  ></nr-select>
5255
5264
  ${this.description?i`<span class="field-description">${this.description}</span>`:n}
5256
5265
  </div>
5257
- `}};mn.useShadowDom=!0,mn.styles=hn,un([s({type:String})],mn.prototype,"value",void 0),un([s({type:Array})],mn.prototype,"entities",void 0),un([s({type:Boolean})],mn.prototype,"disabled",void 0),un([s({type:Boolean})],mn.prototype,"loading",void 0),un([s({type:String})],mn.prototype,"placeholder",void 0),un([s({type:String})],mn.prototype,"label",void 0),un([s({type:String})],mn.prototype,"description",void 0),mn=un([l("nr-entity-select")],mn);let xn=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-select"],this.value=null,this.fields=[],this.disabled=!1,this.placeholder="Select field..."}handleChange(e){this.value=e.detail.value||null,this.dispatchEvent(new CustomEvent("value-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}render(){const e=this.fields.map(e=>({value:e.name,label:e.name,description:e.type}));return i`
5266
+ `}};mn.useShadowDom=!0,mn.styles=hn,un([s({type:String})],mn.prototype,"value",void 0),un([s({type:Array})],mn.prototype,"entities",void 0),un([s({type:Boolean})],mn.prototype,"disabled",void 0),un([s({type:Boolean})],mn.prototype,"loading",void 0),un([s({type:String})],mn.prototype,"placeholder",void 0),un([s({type:String})],mn.prototype,"label",void 0),un([s({type:String})],mn.prototype,"description",void 0),mn=un([l("nr-entity-select")],mn);let yn=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-select"],this.value=null,this.fields=[],this.disabled=!1,this.placeholder="Select field..."}handleChange(e){this.value=e.detail.value||null,this.dispatchEvent(new CustomEvent("value-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}render(){const e=this.fields.map(e=>({value:e.name,label:e.name,description:e.type}));return i`
5258
5267
  <nr-select
5259
5268
  .value=${this.value||""}
5260
5269
  .options=${e}
@@ -5263,7 +5272,7 @@ const hn=e`
5263
5272
  size="small"
5264
5273
  @nr-change=${this.handleChange}
5265
5274
  ></nr-select>
5266
- `}};xn.useShadowDom=!0,xn.styles=hn,un([s({type:String})],xn.prototype,"value",void 0),un([s({type:Array})],xn.prototype,"fields",void 0),un([s({type:Boolean})],xn.prototype,"disabled",void 0),un([s({type:String})],xn.prototype,"placeholder",void 0),xn=un([l("nr-field-select")],xn);let yn=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-select"],this.value=[],this.fields=[],this.disabled=!1,this.placeholder="All fields",this.label="",this.description=""}handleChange(e){this.value=Array.isArray(e.detail.value)?e.detail.value:[e.detail.value].filter(Boolean),this.dispatchEvent(new CustomEvent("value-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}render(){const e=this.fields.map(e=>({value:e.name,label:e.name,description:e.type}));return i`
5275
+ `}};yn.useShadowDom=!0,yn.styles=hn,un([s({type:String})],yn.prototype,"value",void 0),un([s({type:Array})],yn.prototype,"fields",void 0),un([s({type:Boolean})],yn.prototype,"disabled",void 0),un([s({type:String})],yn.prototype,"placeholder",void 0),yn=un([l("nr-field-select")],yn);let xn=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-select"],this.value=[],this.fields=[],this.disabled=!1,this.placeholder="All fields",this.label="",this.description=""}handleChange(e){this.value=Array.isArray(e.detail.value)?e.detail.value:[e.detail.value].filter(Boolean),this.dispatchEvent(new CustomEvent("value-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}render(){const e=this.fields.map(e=>({value:e.name,label:e.name,description:e.type}));return i`
5267
5276
  <div class="field-container">
5268
5277
  ${this.label?i`<label class="field-label">${this.label}</label>`:n}
5269
5278
  <nr-select
@@ -5278,7 +5287,7 @@ const hn=e`
5278
5287
  ></nr-select>
5279
5288
  ${this.description?i`<span class="field-description">${this.description}</span>`:n}
5280
5289
  </div>
5281
- `}};yn.useShadowDom=!0,yn.styles=hn,un([s({type:Array})],yn.prototype,"value",void 0),un([s({type:Array})],yn.prototype,"fields",void 0),un([s({type:Boolean})],yn.prototype,"disabled",void 0),un([s({type:String})],yn.prototype,"placeholder",void 0),un([s({type:String})],yn.prototype,"label",void 0),un([s({type:String})],yn.prototype,"description",void 0),yn=un([l("nr-field-multi-select")],yn);let wn=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-select","nr-input","nr-icon"],this.value=null,this.fields=[],this.disabled=!1,this.label="",this.description="",this.allowExpressions=!0}getEmptyGroup(e="and"){return{[e]:[]}}getEmptyCondition(){return{field:"",op:_.EQUALS,value:""}}updateValue(e){this.value=e,this.dispatchEvent(new CustomEvent("value-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}toggleLogic(e){return e.and?{or:e.and}:e.or?{and:e.or}:e}addCondition(){if(this.value){const e=this.value.and?"and":"or",t=this.value[e]||[];this.updateValue({[e]:[...t,this.getEmptyCondition()]})}else this.updateValue({and:[this.getEmptyCondition()]})}addGroup(){if(this.value){const e=this.value.and?"and":"or",t=this.value[e]||[];this.updateValue({[e]:[...t,this.getEmptyGroup("and")]})}else this.updateValue({and:[this.getEmptyGroup("and")]})}removeCondition(e){if(!this.value)return;const t=this.value.and?"and":"or",i=(this.value[t]||[]).filter((t,i)=>i!==e);0===i.length?this.updateValue(null):this.updateValue({[t]:i})}updateCondition(e,t){if(!this.value)return;const i=this.value.and?"and":"or",n=[...this.value[i]||[]];n[e]=Object.assign(Object.assign({},n[e]),t),this.updateValue({[i]:n})}renderCondition(e,t){const n=R.find(t=>t.value===e.op),a=!1!==(null==n?void 0:n.requiresValue),o=this.fields.map(e=>({value:e.name,label:e.name})),s=R.map(e=>({value:e.value,label:e.label}));return i`
5290
+ `}};xn.useShadowDom=!0,xn.styles=hn,un([s({type:Array})],xn.prototype,"value",void 0),un([s({type:Array})],xn.prototype,"fields",void 0),un([s({type:Boolean})],xn.prototype,"disabled",void 0),un([s({type:String})],xn.prototype,"placeholder",void 0),un([s({type:String})],xn.prototype,"label",void 0),un([s({type:String})],xn.prototype,"description",void 0),xn=un([l("nr-field-multi-select")],xn);let wn=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-select","nr-input","nr-icon"],this.value=null,this.fields=[],this.disabled=!1,this.label="",this.description="",this.allowExpressions=!0}getEmptyGroup(e="and"){return{[e]:[]}}getEmptyCondition(){return{field:"",op:_.EQUALS,value:""}}updateValue(e){this.value=e,this.dispatchEvent(new CustomEvent("value-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}toggleLogic(e){return e.and?{or:e.and}:e.or?{and:e.or}:e}addCondition(){if(this.value){const e=this.value.and?"and":"or",t=this.value[e]||[];this.updateValue({[e]:[...t,this.getEmptyCondition()]})}else this.updateValue({and:[this.getEmptyCondition()]})}addGroup(){if(this.value){const e=this.value.and?"and":"or",t=this.value[e]||[];this.updateValue({[e]:[...t,this.getEmptyGroup("and")]})}else this.updateValue({and:[this.getEmptyGroup("and")]})}removeCondition(e){if(!this.value)return;const t=this.value.and?"and":"or",i=(this.value[t]||[]).filter((t,i)=>i!==e);0===i.length?this.updateValue(null):this.updateValue({[t]:i})}updateCondition(e,t){if(!this.value)return;const i=this.value.and?"and":"or",n=[...this.value[i]||[]];n[e]=Object.assign(Object.assign({},n[e]),t),this.updateValue({[i]:n})}renderCondition(e,t){const n=R.find(t=>t.value===e.op),a=!1!==(null==n?void 0:n.requiresValue),o=this.fields.map(e=>({value:e.name,label:e.name})),s=R.map(e=>({value:e.value,label:e.label}));return i`
5282
5291
  <div class="filter-condition">
5283
5292
  <nr-select
5284
5293
  .value=${e.field}
@@ -7810,7 +7819,7 @@ function ga(e,t){const a=e.checks||[],o=e=>{const i={type:e,action:"block"};"pii
7810
7819
  * Copyright 2024 Nuraly, Laabidi Aymen
7811
7820
  * SPDX-License-Identifier: MIT
7812
7821
  */
7813
- const xa=[{value:"ORDER",label:"Order"},{value:"DRAFT_ORDER",label:"Draft Order"},{value:"PRODUCT",label:"Product"},{value:"PRODUCT_VARIANT",label:"Product Variant"},{value:"PRODUCT_IMAGE",label:"Product Image"},{value:"CUSTOMER",label:"Customer"},{value:"INVENTORY",label:"Inventory"},{value:"FULFILLMENT",label:"Fulfillment"},{value:"COLLECTION",label:"Collection"},{value:"SMART_COLLECTION",label:"Smart Collection"}],ya=[{value:"LIST",label:"List"},{value:"READ",label:"Read"},{value:"CREATE",label:"Create"},{value:"UPDATE",label:"Update"},{value:"DELETE",label:"Delete"}],wa=[{value:"2025-01",label:"2025-01"},{value:"2024-10",label:"2024-10"},{value:"2024-07",label:"2024-07"},{value:"2024-04",label:"2024-04"},{value:"2024-01",label:"2024-01"},{value:"2023-10",label:"2023-10"}],$a=[{value:"",label:"None"},{value:"created_at",label:"Created At"},{value:"updated_at",label:"Updated At"},{value:"id",label:"ID"}],ka=[{value:"asc",label:"Ascending"},{value:"desc",label:"Descending"}],Sa=[{value:"any",label:"Any"},{value:"open",label:"Open"},{value:"closed",label:"Closed"},{value:"cancelled",label:"Cancelled"}],Ca=[{value:"any",label:"Any"},{value:"authorized",label:"Authorized"},{value:"pending",label:"Pending"},{value:"paid",label:"Paid"},{value:"partially_paid",label:"Partially Paid"},{value:"refunded",label:"Refunded"},{value:"voided",label:"Voided"}],Ta=[{value:"any",label:"Any"},{value:"shipped",label:"Shipped"},{value:"partial",label:"Partial"},{value:"unshipped",label:"Unshipped"},{value:"unfulfilled",label:"Unfulfilled"}];
7822
+ const ya=[{value:"ORDER",label:"Order"},{value:"DRAFT_ORDER",label:"Draft Order"},{value:"PRODUCT",label:"Product"},{value:"PRODUCT_VARIANT",label:"Product Variant"},{value:"PRODUCT_IMAGE",label:"Product Image"},{value:"CUSTOMER",label:"Customer"},{value:"INVENTORY",label:"Inventory"},{value:"FULFILLMENT",label:"Fulfillment"},{value:"COLLECTION",label:"Collection"},{value:"SMART_COLLECTION",label:"Smart Collection"}],xa=[{value:"LIST",label:"List"},{value:"READ",label:"Read"},{value:"CREATE",label:"Create"},{value:"UPDATE",label:"Update"},{value:"DELETE",label:"Delete"}],wa=[{value:"2025-01",label:"2025-01"},{value:"2024-10",label:"2024-10"},{value:"2024-07",label:"2024-07"},{value:"2024-04",label:"2024-04"},{value:"2024-01",label:"2024-01"},{value:"2023-10",label:"2023-10"}],$a=[{value:"",label:"None"},{value:"created_at",label:"Created At"},{value:"updated_at",label:"Updated At"},{value:"id",label:"ID"}],ka=[{value:"asc",label:"Ascending"},{value:"desc",label:"Descending"}],Sa=[{value:"any",label:"Any"},{value:"open",label:"Open"},{value:"closed",label:"Closed"},{value:"cancelled",label:"Cancelled"}],Ca=[{value:"any",label:"Any"},{value:"authorized",label:"Authorized"},{value:"pending",label:"Pending"},{value:"paid",label:"Paid"},{value:"partially_paid",label:"Partially Paid"},{value:"refunded",label:"Refunded"},{value:"voided",label:"Voided"}],Ta=[{value:"any",label:"Any"},{value:"shipped",label:"Shipped"},{value:"partial",label:"Partial"},{value:"unshipped",label:"Unshipped"},{value:"unfulfilled",label:"Unfulfilled"}];
7814
7823
  /**
7815
7824
  * @license
7816
7825
  * Copyright 2024 Nuraly, Laabidi Aymen
@@ -8427,7 +8436,7 @@ const vo=[{value:"invitee.created",label:"Invitee Created (meeting booked)"},{va
8427
8436
  * Copyright 2024 Nuraly, Laabidi Aymen
8428
8437
  * SPDX-License-Identifier: MIT
8429
8438
  */
8430
- const mo=[{value:"none",label:"None — No acknowledgment"},{value:"leader",label:"Leader — Leader broker only"},{value:"all",label:"All — All in-sync replicas"}],xo=[{value:"none",label:"None"},{value:"gzip",label:"Gzip"},{value:"snappy",label:"Snappy"},{value:"lz4",label:"LZ4"}];function yo(e){return i`
8439
+ const mo=[{value:"none",label:"None — No acknowledgment"},{value:"leader",label:"Leader — Leader broker only"},{value:"all",label:"All — All in-sync replicas"}],yo=[{value:"none",label:"None"},{value:"gzip",label:"Gzip"},{value:"snappy",label:"Snappy"},{value:"lz4",label:"LZ4"}];function xo(e){return i`
8431
8440
  <div class="trigger-stats-row">
8432
8441
  <span class="trigger-stat">
8433
8442
  <nr-icon name="message-square" size="small"></nr-icon>
@@ -8461,7 +8470,7 @@ const mo=[{value:"none",label:"None — No acknowledgment"},{value:"leader",labe
8461
8470
  <div class="trigger-status-reason">${e.stateReason}</div>
8462
8471
  `:n}
8463
8472
 
8464
- ${c&&e?yo(e):n}
8473
+ ${c&&e?xo(e):n}
8465
8474
 
8466
8475
  ${(null==e?void 0:e.inDevMode)?i`
8467
8476
  <div class="trigger-dev-mode-badge">
@@ -9253,12 +9262,12 @@ var os=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.
9253
9262
  <div class="editor-container ${e?"dark":"light"}" part="editor-container">
9254
9263
  <div class="line-numbers-gutter" style="display: ${this.lineNumbers?"block":"none"}"></div>
9255
9264
  <code
9256
- ${x(this.editorRef)}
9265
+ ${y(this.editorRef)}
9257
9266
  class="editor language-${this.language}"
9258
9267
  style="font-size: ${this.fontSize}px; tab-size: ${this.tabSize}; white-space: ${this.wordWrap?"pre-wrap":"pre"};"
9259
9268
  ></code>
9260
9269
  </div>
9261
- `}getValue(){var e,t;return null!==(t=null===(e=this.editorRef.value)||void 0===e?void 0:e.textContent)&&void 0!==t?t:""}setValue(e){this.jar&&(this.suppressChange=!0,this.jar.updateCode(e),this.suppressChange=!1)}focus(){var e;null===(e=this.editorRef.value)||void 0===e||e.focus()}firstUpdated(){this.editorRef.value&&this.initializeEditor()}initializeEditor(){const e=this.editorRef.value;e.textContent=this.code;this.jar=y(e,e=>{const t=e.textContent||"",i=this.language||"plaintext";try{"plaintext"!==i&&w.getLanguage(i)?e.innerHTML=w.highlight(t,{language:i}).value:e.innerHTML=this.escapeHtml(t)}catch(i){e.innerHTML=this.escapeHtml(t)}},{tab:" ".repeat(this.tabSize),indentOn:/[({[]$/,addClosing:!0,catchTab:!0,preserveIdent:!0,history:!0}),this.isEditorReady=!0,this.jar.onUpdate(e=>{this.suppressChange||(this.code=e,this.updateLineNumbers(),this.emit("nr-change",{value:e}))}),e.addEventListener("keydown",e=>{this.readonly?e.preventDefault():this.emit("nr-keydown",this.createKeyEventDetail(e))}),e.addEventListener("keyup",e=>{this.emit("nr-keyup",this.createKeyEventDetail(e))}),e.addEventListener("focus",()=>this.emit("nr-focus")),e.addEventListener("blur",()=>this.emit("nr-blur")),this.readonly&&e.setAttribute("contenteditable","false"),this.updateLineNumbers(),this.emit("nr-ready",{editor:this.jar})}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}updateLineNumbers(){var e,t,i;const n=null!==(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".line-numbers-gutter"))&&void 0!==t?t:null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(".line-numbers-gutter");if(!n||!this.lineNumbers)return;const a=this.getValue().split("\n").length;n.innerHTML=Array.from({length:a},(e,t)=>`<div class="line-number">${t+1}</div>`).join("")}createKeyEventDetail(e){return{event:e,key:e.key,code:e.code,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey}}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}isDarkTheme(){var e,t;return this.theme===ts||this.theme===is||this.theme!==es&&this.theme!==ns&&(null!==(t=null===(e=this.currentTheme)||void 0===e?void 0:e.includes("dark"))&&void 0!==t&&t)}updated(e){var t;if(super.updated(e),this.isEditorReady&&this.jar){if(e.has("code")&&this.code!==e.get("code")){const e=this.getValue();this.code!==e&&(this.setValue(this.code),this.updateLineNumbers())}e.has("readonly")&&(null===(t=this.editorRef.value)||void 0===t||t.setAttribute("contenteditable",this.readonly?"false":"true"))}}disconnectedCallback(){super.disconnectedCallback(),this.jar&&(this.jar.destroy(),this.jar=void 0),this.isEditorReady=!1}};ss.styles=Zo,ss.useShadowDom=!0,os([s({type:Boolean,reflect:!0})],ss.prototype,"readonly",void 0),os([s({type:String,reflect:!0})],ss.prototype,"theme",void 0),os([s({type:String,reflect:!0})],ss.prototype,"language",void 0),os([s({type:String})],ss.prototype,"code",void 0),os([s({type:Boolean,attribute:"line-numbers"})],ss.prototype,"lineNumbers",void 0),os([s({type:Number,attribute:"font-size"})],ss.prototype,"fontSize",void 0),os([s({type:Boolean,attribute:"word-wrap"})],ss.prototype,"wordWrap",void 0),os([s({type:Number,attribute:"tab-size"})],ss.prototype,"tabSize",void 0),ss=os([l("nr-code-editor")],ss);
9270
+ `}getValue(){var e,t;return null!==(t=null===(e=this.editorRef.value)||void 0===e?void 0:e.textContent)&&void 0!==t?t:""}setValue(e){this.jar&&(this.suppressChange=!0,this.jar.updateCode(e),this.suppressChange=!1)}focus(){var e;null===(e=this.editorRef.value)||void 0===e||e.focus()}firstUpdated(){this.editorRef.value&&this.initializeEditor()}initializeEditor(){const e=this.editorRef.value;e.textContent=this.code;this.jar=x(e,e=>{const t=e.textContent||"",i=this.language||"plaintext";try{"plaintext"!==i&&w.getLanguage(i)?e.innerHTML=w.highlight(t,{language:i}).value:e.innerHTML=this.escapeHtml(t)}catch(i){e.innerHTML=this.escapeHtml(t)}},{tab:" ".repeat(this.tabSize),indentOn:/[({[]$/,addClosing:!0,catchTab:!0,preserveIdent:!0,history:!0}),this.isEditorReady=!0,this.jar.onUpdate(e=>{this.suppressChange||(this.code=e,this.updateLineNumbers(),this.emit("nr-change",{value:e}))}),e.addEventListener("keydown",e=>{this.readonly?e.preventDefault():this.emit("nr-keydown",this.createKeyEventDetail(e))}),e.addEventListener("keyup",e=>{this.emit("nr-keyup",this.createKeyEventDetail(e))}),e.addEventListener("focus",()=>this.emit("nr-focus")),e.addEventListener("blur",()=>this.emit("nr-blur")),this.readonly&&e.setAttribute("contenteditable","false"),this.updateLineNumbers(),this.emit("nr-ready",{editor:this.jar})}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}updateLineNumbers(){var e,t,i;const n=null!==(t=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".line-numbers-gutter"))&&void 0!==t?t:null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(".line-numbers-gutter");if(!n||!this.lineNumbers)return;const a=this.getValue().split("\n").length;n.innerHTML=Array.from({length:a},(e,t)=>`<div class="line-number">${t+1}</div>`).join("")}createKeyEventDetail(e){return{event:e,key:e.key,code:e.code,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey}}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}isDarkTheme(){var e,t;return this.theme===ts||this.theme===is||this.theme!==es&&this.theme!==ns&&(null!==(t=null===(e=this.currentTheme)||void 0===e?void 0:e.includes("dark"))&&void 0!==t&&t)}updated(e){var t;if(super.updated(e),this.isEditorReady&&this.jar){if(e.has("code")&&this.code!==e.get("code")){const e=this.getValue();this.code!==e&&(this.setValue(this.code),this.updateLineNumbers())}e.has("readonly")&&(null===(t=this.editorRef.value)||void 0===t||t.setAttribute("contenteditable",this.readonly?"false":"true"))}}disconnectedCallback(){super.disconnectedCallback(),this.jar&&(this.jar.destroy(),this.jar=void 0),this.isEditorReady=!1}};ss.styles=Zo,ss.useShadowDom=!0,os([s({type:Boolean,reflect:!0})],ss.prototype,"readonly",void 0),os([s({type:String,reflect:!0})],ss.prototype,"theme",void 0),os([s({type:String,reflect:!0})],ss.prototype,"language",void 0),os([s({type:String})],ss.prototype,"code",void 0),os([s({type:Boolean,attribute:"line-numbers"})],ss.prototype,"lineNumbers",void 0),os([s({type:Number,attribute:"font-size"})],ss.prototype,"fontSize",void 0),os([s({type:Boolean,attribute:"word-wrap"})],ss.prototype,"wordWrap",void 0),os([s({type:Number,attribute:"tab-size"})],ss.prototype,"tabSize",void 0),ss=os([l("nr-code-editor")],ss);
9262
9271
  /**
9263
9272
  * @license
9264
9273
  * Copyright 2024 Nuraly, Laabidi Aymen
@@ -12534,7 +12543,7 @@ return function(e,t){return i`
12534
12543
  value=${e.resource||"ORDER"}
12535
12544
  @nr-change=${e=>t("resource",e.detail.value)}
12536
12545
  >
12537
- ${xa.map(e=>i`
12546
+ ${ya.map(e=>i`
12538
12547
  <nr-option value=${e.value}>${e.label}</nr-option>
12539
12548
  `)}
12540
12549
  </nr-select>
@@ -12545,7 +12554,7 @@ return function(e,t){return i`
12545
12554
  value=${r}
12546
12555
  @nr-change=${e=>t("operation",e.detail.value)}
12547
12556
  >
12548
- ${ya.map(e=>i`
12557
+ ${xa.map(e=>i`
12549
12558
  <nr-option value=${e.value}>${e.label}</nr-option>
12550
12559
  `)}
12551
12560
  </nr-select>
@@ -14459,7 +14468,7 @@ return function(e,t){return i`
14459
14468
  <label>Compression</label>
14460
14469
  <nr-select
14461
14470
  .value=${e.kafkaCompressionType||"none"}
14462
- .options=${xo}
14471
+ .options=${yo}
14463
14472
  @nr-change=${e=>t("kafkaCompressionType",e.detail.value)}
14464
14473
  ></nr-select>
14465
14474
  <span class="field-description">Compression codec for message batches</span>
@@ -14907,7 +14916,7 @@ return function(e,t){return i`
14907
14916
  <span class="field-description">Variable name to store the HubSpot API response for downstream nodes</span>
14908
14917
  </div>
14909
14918
  </div>
14910
- `}(t,a,s,r);case U.JIRA:return function(e,t,a,o){var s,r;const l=e.operation||"createIssue",c=["getIssue","updateIssue","deleteIssue","transitionIssue","addComment","listComments","getChangelog","addAttachment","listAttachments","addWorklog","listWorklogs"].includes(l),d=["createIssue","searchJql"].includes(l),p=["createIssue","updateIssue"].includes(l),h="searchJql"===l,u="transitionIssue"===l,b="addComment"===l,f="addAttachment"===l,v="addWorklog"===l,g="getUser"===l,m="searchUsers"===l,x=["searchJql","listProjects","listComments","listAttachments","listWorklogs","searchUsers"].includes(l),y=(a||[]).filter(e=>e.keyPath.startsWith("jira/")),w=e.customFields||[];return i`
14919
+ `}(t,a,s,r);case U.JIRA:return function(e,t,a,o){var s,r;const l=e.operation||"createIssue",c=["getIssue","updateIssue","deleteIssue","transitionIssue","addComment","listComments","getChangelog","addAttachment","listAttachments","addWorklog","listWorklogs"].includes(l),d=["createIssue","searchJql"].includes(l),p=["createIssue","updateIssue"].includes(l),h="searchJql"===l,u="transitionIssue"===l,b="addComment"===l,f="addAttachment"===l,v="addWorklog"===l,g="getUser"===l,m="searchUsers"===l,y=["searchJql","listProjects","listComments","listAttachments","listWorklogs","searchUsers"].includes(l),x=(a||[]).filter(e=>e.keyPath.startsWith("jira/")),w=e.customFields||[];return i`
14911
14920
  <div class="config-section">
14912
14921
  <div class="config-section-header">
14913
14922
  <span class="config-section-title">Connection</span>
@@ -14926,7 +14935,7 @@ return function(e,t){return i`
14926
14935
  <label>Credentials</label>
14927
14936
  <nr-kv-secret-select
14928
14937
  .provider=${"jira"}
14929
- .entries=${y}
14938
+ .entries=${x}
14930
14939
  .value=${e.credentialPath||""}
14931
14940
  placeholder="Select Jira credentials..."
14932
14941
  @value-change=${e=>t("credentialPath",e.detail.value)}
@@ -15259,7 +15268,7 @@ return function(e,t){return i`
15259
15268
  </div>
15260
15269
  `:n}
15261
15270
 
15262
- ${x?i`
15271
+ ${y?i`
15263
15272
  <div class="config-section">
15264
15273
  <div class="config-section-header">
15265
15274
  <span class="config-section-title">Pagination</span>
@@ -16556,7 +16565,7 @@ return function(e,t){const a="string"==typeof e.workflowId?e.workflowId:"",o="st
16556
16565
  * Copyright 2024 Nuraly, Laabidi Aymen
16557
16566
  * SPDX-License-Identifier: MIT
16558
16567
  */
16559
- const us={[U.LOOP]:{title:"How the Loop node works",description:'Iterates over the array resolved from "arrayExpression" and runs the item-port subgraph once per element. Each iteration binds the current value to ${variables.<iteratorVariable>} and its position to ${variables.<iteratorVariable>_index}. Wire downstream nodes to the "item" port to run them per element, and to the "done" port for whatever should run after the loop finishes. A Break node anywhere in the item subgraph short-circuits the remaining iterations.'}};function bs(e){const{node:t,position:a,callbacks:o,workflowId:s,workflow:r,dynamicVariables:l,loadingVariables:c,nodeExecution:p,executionId:h,kvEntries:u,onCreateKvEntry:b,applicationId:f,databaseProvider:v,triggerInfo:g,triggerActions:m}=e;if(!t||!a)return n;const x=Z.find(e=>e.type===t.type),y=(w=t.type,us[w]);var w;
16568
+ const us={[U.LOOP]:{title:"How the Loop node works",description:'Iterates over the array resolved from "arrayExpression" and runs the item-port subgraph once per element. Each iteration binds the current value to ${variables.<iteratorVariable>} and its position to ${variables.<iteratorVariable>_index}. Wire downstream nodes to the "item" port to run them per element, and to the "done" port for whatever should run after the loop finishes. A Break node anywhere in the item subgraph short-circuits the remaining iterations.'}};function bs(e){const{node:t,position:a,callbacks:o,workflowId:s,workflow:r,dynamicVariables:l,loadingVariables:c,nodeExecution:p,executionId:h,kvEntries:u,onCreateKvEntry:b,applicationId:f,databaseProvider:v,triggerInfo:g,triggerActions:m}=e;if(!t||!a)return n;const y=Z.find(e=>e.type===t.type),x=(w=t.type,us[w]);var w;
16560
16569
  /**
16561
16570
  * @license
16562
16571
  * Copyright 2024 Nuraly, Laabidi Aymen
@@ -16567,15 +16576,15 @@ const us={[U.LOOP]:{title:"How the Loop node works",description:'Iterates over t
16567
16576
  <div class="config-panel-title">
16568
16577
  <div
16569
16578
  class="config-panel-icon"
16570
- style="background: ${(null==x?void 0:x.color)||"#3b82f6"}"
16579
+ style="background: ${(null==y?void 0:y.color)||"#3b82f6"}"
16571
16580
  >
16572
- <nr-icon name=${(null==x?void 0:x.icon)||"box"} size="small"></nr-icon>
16581
+ <nr-icon name=${(null==y?void 0:y.icon)||"box"} size="small"></nr-icon>
16573
16582
  </div>
16574
16583
  <nr-label size="medium">${t.name}</nr-label>
16575
- ${y?i`
16584
+ ${x?i`
16576
16585
  <nr-popconfirm
16577
- title=${y.title}
16578
- description=${y.description}
16586
+ title=${x.title}
16587
+ description=${x.description}
16579
16588
  icon="question-circle"
16580
16589
  ok-text="Got it"
16581
16590
  ?show-cancel=${!1}
@@ -16765,7 +16774,7 @@ function(e,t){var n;return i`
16765
16774
  * @license
16766
16775
  * Copyright 2024 Nuraly, Laabidi Aymen
16767
16776
  * SPDX-License-Identifier: MIT
16768
- */function fs(e,t){var i;if(!e.parentFrameId)return null;const n=t.find(t=>t.id===e.parentFrameId);if(!n)return null;return(null===(i=n.configuration)||void 0===i?void 0:i.frameCollapsed)?n:null}function vs(e,t,i=0,n=1){const a=e.position.y+46,o=16*(i-(n-1)/2);return t?{x:e.position.x,y:a+o}:{x:e.position.x+180,y:a+o}}function gs(e,t,i,a,s,r){if(e._hiddenByFrame)return n;const l=t.find(t=>t.id===e.sourceNodeId),c=t.find(t=>t.id===e.targetNodeId);if(!l||!c)return n;const d=fs(l,t),p=fs(c,t);if(d&&p&&d.id===p.id)return n;let h,u;h=d?vs(d,!1,0,1):r.getPortPosition(l,e.sourcePortId,!1),u=p?vs(p,!0,0,1):r.getPortPosition(c,e.targetPortId,!0);const b=u.x-h.x,f=Math.min(.5*Math.abs(b),100),v=`M ${h.x} ${h.y} C ${h.x+f} ${h.y}, ${u.x-f} ${u.y}, ${u.x} ${u.y}`,g=i.has(e.id),m=a===e.id,x=function(e,t,i){if(e.status)return e.status;const n=null==t?void 0:t.status,a=null==i?void 0:i.status;if(n&&n!==K.IDLE){if(n===K.COMPLETED||n===K.FAILED){if(!a||a===K.IDLE||a===K.PENDING)return;return n===K.FAILED||a===K.FAILED?K.FAILED:K.COMPLETED}return n!==K.RUNNING||a!==K.PENDING&&a!==K.RUNNING?void 0:K.RUNNING}}(e,l,c),y=function(e,t,i,n){const a=(null==n?void 0:n.includes("light"))||"default"===n;return i===K.COMPLETED?"#22c55e":i===K.RUNNING?"#3b82f6":i===K.FAILED?"#ef4444":i===K.PENDING?"#f59e0b":e?"#3b82f6":t?"#60a5fa":a?"#9ca3af":"#6b7280"}(g,m,x,s),w=g||m||x?3:2,$=.5,k=Math.pow(.5,3)*h.x+3*Math.pow(.5,2)*$*(h.x+f)+1.5*Math.pow($,2)*(u.x-f)+Math.pow($,3)*u.x,S=Math.pow(.5,3)*h.y+3*Math.pow(.5,2)*$*h.y+1.5*Math.pow($,2)*u.y+Math.pow($,3)*u.y,C=.55,T=Math.pow(1-C,3)*h.x+3*Math.pow(1-C,2)*C*(h.x+f)+3*(1-C)*Math.pow(C,2)*(u.x-f)+Math.pow(C,3)*u.x,M=Math.pow(1-C,3)*h.y+3*Math.pow(1-C,2)*C*h.y+3*(1-C)*Math.pow(C,2)*u.y+Math.pow(C,3)*u.y,E=180*Math.atan2(M-S,T-k)/Math.PI;return o`
16777
+ */function fs(e,t){var i;if(!e.parentFrameId)return null;const n=t.find(t=>t.id===e.parentFrameId);if(!n)return null;return(null===(i=n.configuration)||void 0===i?void 0:i.frameCollapsed)?n:null}function vs(e,t,i=0,n=1){const a=e.position.y+46,o=16*(i-(n-1)/2);return t?{x:e.position.x,y:a+o}:{x:e.position.x+180,y:a+o}}function gs(e,t,i,a,s,r){if(e._hiddenByFrame)return n;const l=t.find(t=>t.id===e.sourceNodeId),c=t.find(t=>t.id===e.targetNodeId);if(!l||!c)return n;const d=fs(l,t),p=fs(c,t);if(d&&p&&d.id===p.id)return n;let h,u;h=d?vs(d,!1,0,1):r.getPortPosition(l,e.sourcePortId,!1),u=p?vs(p,!0,0,1):r.getPortPosition(c,e.targetPortId,!0);const b=u.x-h.x,f=Math.min(.5*Math.abs(b),100),v=`M ${h.x} ${h.y} C ${h.x+f} ${h.y}, ${u.x-f} ${u.y}, ${u.x} ${u.y}`,g=i.has(e.id),m=a===e.id,y=function(e,t,i){if(e.status)return e.status;const n=null==t?void 0:t.status,a=null==i?void 0:i.status;if(n&&n!==K.IDLE){if(n===K.COMPLETED||n===K.FAILED){if(!a||a===K.IDLE||a===K.PENDING)return;return n===K.FAILED||a===K.FAILED?K.FAILED:K.COMPLETED}return n!==K.RUNNING||a!==K.PENDING&&a!==K.RUNNING?void 0:K.RUNNING}}(e,l,c),x=function(e,t,i,n){const a=(null==n?void 0:n.includes("light"))||"default"===n;return i===K.COMPLETED?"#22c55e":i===K.RUNNING?"#3b82f6":i===K.FAILED?"#ef4444":i===K.PENDING?"#f59e0b":e?"#3b82f6":t?"#60a5fa":a?"#9ca3af":"#6b7280"}(g,m,y,s),w=g||m||y?3:2,$=.5,k=Math.pow(.5,3)*h.x+3*Math.pow(.5,2)*$*(h.x+f)+1.5*Math.pow($,2)*(u.x-f)+Math.pow($,3)*u.x,S=Math.pow(.5,3)*h.y+3*Math.pow(.5,2)*$*h.y+1.5*Math.pow($,2)*u.y+Math.pow($,3)*u.y,C=.55,T=Math.pow(1-C,3)*h.x+3*Math.pow(1-C,2)*C*(h.x+f)+3*(1-C)*Math.pow(C,2)*(u.x-f)+Math.pow(C,3)*u.x,M=Math.pow(1-C,3)*h.y+3*Math.pow(1-C,2)*C*h.y+3*(1-C)*Math.pow(C,2)*u.y+Math.pow(C,3)*u.y,E=180*Math.atan2(M-S,T-k)/Math.PI;return o`
16769
16778
  <g class="edge-group" data-edge-id=${e.id}>
16770
16779
  <!-- Invisible wider path for easier clicking -->
16771
16780
  <path
@@ -16783,13 +16792,13 @@ function(e,t){var n;return i`
16783
16792
  class="edge-path"
16784
16793
  d=${v}
16785
16794
  fill="none"
16786
- style="pointer-events: none; stroke: ${y}; stroke-width: ${w}px; transition: stroke 0.15s ease, stroke-width 0.15s ease;"
16795
+ style="pointer-events: none; stroke: ${x}; stroke-width: ${w}px; transition: stroke 0.15s ease, stroke-width 0.15s ease;"
16787
16796
  />
16788
16797
  <polygon
16789
16798
  class="edge-arrow"
16790
16799
  points="${k+6},${S} ${k-6},${S-4} ${k-6},${S+4}"
16791
16800
  transform="rotate(${E}, ${k}, ${S})"
16792
- style="pointer-events: none; fill: ${y}; transition: fill 0.15s ease;"
16801
+ style="pointer-events: none; fill: ${x}; transition: fill 0.15s ease;"
16793
16802
  />
16794
16803
  ${e.label?o`
16795
16804
  <text
@@ -16809,13 +16818,13 @@ function(e,t){var n;return i`
16809
16818
  * @license
16810
16819
  * Copyright 2024 Nuraly, Laabidi Aymen
16811
16820
  * SPDX-License-Identifier: MIT
16812
- */const xs=[{type:q.SHAPE_RECTANGLE,icon:"square",label:"Rectangle"},{type:q.SHAPE_CIRCLE,icon:"circle",label:"Circle"},{type:q.SHAPE_DIAMOND,icon:"diamond",label:"Diamond"},{type:q.SHAPE_TRIANGLE,icon:"triangle",label:"Triangle"},{type:q.SHAPE_ARROW,icon:"arrow-right",label:"Arrow"},{type:q.SHAPE_LINE,icon:"minus",label:"Line"},{type:q.SHAPE_STAR,icon:"star",label:"Star"},{type:q.SHAPE_HEXAGON,icon:"hexagon",label:"Hexagon"}];
16821
+ */const ys=[{type:q.SHAPE_RECTANGLE,icon:"square",label:"Rectangle"},{type:q.SHAPE_CIRCLE,icon:"circle",label:"Circle"},{type:q.SHAPE_DIAMOND,icon:"diamond",label:"Diamond"},{type:q.SHAPE_TRIANGLE,icon:"triangle",label:"Triangle"},{type:q.SHAPE_ARROW,icon:"arrow-right",label:"Arrow"},{type:q.SHAPE_LINE,icon:"minus",label:"Line"},{type:q.SHAPE_STAR,icon:"star",label:"Star"},{type:q.SHAPE_HEXAGON,icon:"hexagon",label:"Hexagon"}];
16813
16822
  /**
16814
16823
  * @license
16815
16824
  * Copyright 2024 Nuraly, Laabidi Aymen
16816
16825
  * SPDX-License-Identifier: MIT
16817
16826
  */
16818
- function ys(e){e.stopPropagation()}
16827
+ function xs(e){e.stopPropagation()}
16819
16828
  /**
16820
16829
  * @license
16821
16830
  * Copyright 2024 Nuraly, Laabidi Aymen
@@ -17220,9 +17229,9 @@ function(e){const{cursors:t,viewport:a,localUserId:o}=e,s=t.filter(e=>e.userId!=
17220
17229
  `}({users:this.collaborationController.getUsers(),connected:this.collaborationController.isConnected(),onUserClick:e=>this.handlePanToUser(e)}):n}renderConfigPanel(){return bs({node:this.configuredNode,position:this.configController.getPanelPosition(),callbacks:{onClose:()=>this.configController.closeConfig(),onUpdateName:e=>this.configController.updateName(e),onUpdateDescription:e=>this.configController.updateDescription(e),onUpdateConfig:(e,t)=>{this.configController.updateConfig(e,t),this.collaborative&&this.configuredNode&&this.collaborationController.broadcastOperation("UPDATE",this.configuredNode.id,{[e]:t})}},workflow:this.workflow})}renderChatbotPanel(){return e={isOpen:this.showChatbotPanel,controller:this.canvasChatbotController,unreadCount:this.chatbotUnreadCount,currentTheme:this.currentTheme},t={onClose:()=>this.toggleChatbotPanel()},e.isOpen?i`
17221
17230
  <div class="chatbot-panel"
17222
17231
  data-theme=${e.currentTheme}
17223
- @mousedown=${ys}
17224
- @touchstart=${ys}
17225
- @pointerdown=${ys}
17232
+ @mousedown=${xs}
17233
+ @touchstart=${xs}
17234
+ @pointerdown=${xs}
17226
17235
  >
17227
17236
  <div class="chatbot-panel-header">
17228
17237
  <span class="chatbot-panel-title">
@@ -23082,7 +23091,7 @@ const pr=e`
23082
23091
  :host([size="large"]) .radio-label { font-size: 16px; }
23083
23092
 
23084
23093
  :host([disabled]) .radio-label { color: #bfbfbf; }
23085
- `;var mr,xr,yr,wr,$r,kr,Sr,Cr,Tr;!function(e){e.Default="default",e.Inline="inline",e.Button="button",e.Slot="slot"}(mr||(mr={})),function(e){e.Default="default",e.Warning="warning",e.Error="error",e.Success="success"}(xr||(xr={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(yr||(yr={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(wr||(wr={})),function(e){e.Horizontal="horizontal",e.Vertical="vertical"}($r||($r={})),function(e){e.Default="default",e.Solid="solid",e.Outline="outline",e.Borderless="borderless"}(kr||(kr={})),function(e){e.Bottom="bottom",e.Top="top",e.Auto="auto"}(Sr||(Sr={})),function(e){e.None="none",e.StartsWith="starts-with",e.Contains="contains",e.Fuzzy="fuzzy"}(Cr||(Cr={}));class Mr extends Ve{}class Er extends Mr{constructor(){super(...arguments),this._selectedOptions=[],this._initialized=!1}getSelectedOptions(){return[...this._selectedOptions]}getSelectedOption(){return this._selectedOptions[0]}selectOption(e){try{if(this.isOptionDisabled(e))return;const t=this.host.multiple,i=this.getCurrentValue();t?this.isOptionSelected(e)||(this._selectedOptions=[...this._selectedOptions,e],this.updateHostValue(),this.dispatchChangeEvent(i)):(this.isOptionSelected(e)?this._selectedOptions=[]:this._selectedOptions=[e],this.updateHostValue(),this.dispatchChangeEvent(i)),this.requestUpdate()}catch(e){this.handleError(e,"selectOption")}}unselectOption(e){try{if(this.isOptionSelected(e)){const t=this.getCurrentValue();this._selectedOptions=this._selectedOptions.filter(t=>t.value!==e.value),this.updateHostValue(),this.dispatchChangeEvent(t),this.requestUpdate()}}catch(e){this.handleError(e,"unselectOption")}}clearSelection(){try{if(this._selectedOptions.length>0){const e=this.getCurrentValue();this._selectedOptions=[],this.updateHostValue(),this.dispatchChangeEvent(e),this.requestUpdate()}}catch(e){this.handleError(e,"clearSelection")}}isOptionSelected(e){return this._selectedOptions.some(t=>t.value===e.value)}isOptionDisabled(e){return Boolean(e.disabled)||this.host.disabled}toggleOption(e){this.isOptionSelected(e)?this.unselectOption(e):this.selectOption(e)}initializeFromValue(){try{if(this._initialized)return;const e=this.host.value;if(!e||Array.isArray(e)&&0===e.length)return;const t=Array.isArray(e)?e:[e],i=this.host.options.filter(e=>t.includes(e.value));i.length>0&&(this._selectedOptions=this.host.multiple?i:[i[0]],this.requestUpdate()),this._initialized=!0}catch(e){this.handleError(e,"initializeFromValue")}}updateHostValue(){var e;const t=this.host.multiple?this._selectedOptions.map(e=>e.value):(null===(e=this._selectedOptions[0])||void 0===e?void 0:e.value)||"",i=this.host.value;let n=!1;if(this.host.multiple){const e=Array.isArray(i)?i:[],a=Array.isArray(t)?t:[];n=e.length===a.length&&e.every((e,t)=>e===a[t])}else n=i===t;n||(this.host.value=t)}getCurrentValue(){var e;return this.host.multiple?this._selectedOptions.map(e=>e.value):(null===(e=this._selectedOptions[0])||void 0===e?void 0:e.value)||""}dispatchChangeEvent(e){const t={value:this.getCurrentValue(),selectedOptions:this.getSelectedOptions(),previousValue:e};this.dispatchEvent(new CustomEvent("nr-change",{detail:t,bubbles:!0,composed:!0}))}hostUpdated(){this.syncWithHostOptions()}syncWithHostOptions(){try{this._selectedOptions=this._selectedOptions.filter(e=>this.host.options.some(t=>t.value===e.value)),this._selectedOptions=this._selectedOptions.map(e=>this.host.options.find(t=>t.value===e.value)||e),this.updateHostValue()}catch(e){this.handleError(e,"syncWithHostOptions")}}}class Ar extends Mr{constructor(e,t,i){super(e),this.selectionController=t,this.dropdownController=i,this._focusedIndex=-1,this._hasKeyboardNavigated=!1}handleKeyDown(e){try{const t=this.isSearchInputFocused();switch(e.key){case"ArrowDown":e.preventDefault(),this.dropdownController.isOpen?this.navigateNext():this.openDropdown();break;case"ArrowUp":e.preventDefault(),this.dropdownController.isOpen?this.navigatePrevious():this.openDropdown();break;case"Enter":this.dropdownController.isOpen?t&&this._focusedIndex>=0?(e.preventDefault(),this.selectFocused()):t||(e.preventDefault(),this.selectFocused()):(e.preventDefault(),this.openDropdown());break;case" ":t||(e.preventDefault(),this.dropdownController.isOpen?this.selectFocused():this.openDropdown());break;case"Escape":e.preventDefault(),this.closeDropdown();break;case"Tab":this.closeDropdown();break;case"Home":this.dropdownController.isOpen&&(e.preventDefault(),this.setFocusedIndex(0));break;case"End":this.dropdownController.isOpen&&(e.preventDefault(),this.setFocusedIndex(this.host.options.length-1));break;default:1===e.key.length&&/[a-zA-Z0-9]/.test(e.key)&&this.handleAlphanumericKey(e.key.toLowerCase())}}catch(e){this.handleError(e,"handleKeyDown")}}navigateNext(){try{const e=this.getNavigableOptions();if(0===e.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(0);let t=this._focusedIndex+1;t>=e.length&&(t=0),this.setFocusedIndex(t)}catch(e){this.handleError(e,"navigateNext")}}navigatePrevious(){try{const e=this.getNavigableOptions();if(0===e.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(e.length-1);let t=this._focusedIndex-1;t<0&&(t=e.length-1),this.setFocusedIndex(t)}catch(e){this.handleError(e,"navigatePrevious")}}selectFocused(){try{const e=this.getNavigableOptions()[this._focusedIndex];e&&!this.selectionController.isOptionDisabled(e)&&(this.selectionController.selectOption(e),this.host.multiple||this.closeDropdown())}catch(e){this.handleError(e,"selectFocused")}}openDropdown(){try{this.dropdownController.open(),this._hasKeyboardNavigated=!1,this._focusedIndex=-1}catch(e){this.handleError(e,"openDropdown")}}closeDropdown(){try{this.dropdownController.close(),this._focusedIndex=-1,this._hasKeyboardNavigated=!1}catch(e){this.handleError(e,"closeDropdown")}}setFocusedIndex(e){try{const t=this.getNavigableOptions();e>=0&&e<t.length&&(this._focusedIndex=e,this.dispatchFocusEvent(t[e],e),this.requestUpdate(),this.scrollToFocusedOption(e))}catch(e){this.handleError(e,"setFocusedIndex")}}scrollToFocusedOption(e){var t;try{const i=this.host,n=null===(t=i.querySelector)||void 0===t?void 0:t.call(i,".options");if(!n)return;setTimeout(()=>{const t=n.querySelector(".option.focused");if(t)t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const t=40,i=n.clientHeight,a=n.scrollTop,o=e*t,s=o+t,r=a+i;o<a?n.scrollTo({top:o,behavior:"smooth"}):s>r&&n.scrollTo({top:s-i,behavior:"smooth"})}},10)}catch(e){console.warn("Failed to scroll to focused option:",e)}}get focusedIndex(){return this._focusedIndex}get focusedOption(){return this.getNavigableOptions()[this._focusedIndex]}handleAlphanumericKey(e){try{const t=this.getNavigableOptions(),i=this._focusedIndex+1;for(let n=0;n<t.length;n++){const a=(i+n)%t.length;if(t[a].label.toLowerCase().startsWith(e)){this.setFocusedIndex(a),this.dropdownController.isOpen||this.openDropdown();break}}}catch(e){this.handleError(e,"handleAlphanumericKey")}}getNavigableOptions(){const e=this.host;if(!e.options||!Array.isArray(e.options))return[];let t=e.options;return e.searchable&&e.searchQuery&&"function"==typeof e.getFilteredOptions&&(t=e.getFilteredOptions()),t.filter(e=>!e.disabled)}dispatchFocusEvent(e,t){const i={focusedOption:e,focusedIndex:t};this.dispatchEvent(new CustomEvent("nr-select-focus",{detail:i,bubbles:!0,composed:!0}))}isSearchInputFocused(){var e;try{const t=this.host;if(!t.searchable)return!1;const i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".search-input");return!!i&&(document.activeElement===i||i.contains(document.activeElement))}catch(e){return!1}}hostUpdated(){this.dropdownController.isOpen||-1===this._focusedIndex||(this._focusedIndex=-1)}}function zr(e){if(e.parentElement)return e.parentElement;const t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function Ir(e,t,i={}){var n,a;const{offset:o=4,viewportMargin:s=8}=i,r=e.getBoundingClientRect(),l=t.getBoundingClientRect(),c=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||window.innerHeight,d=(null===(a=window.visualViewport)||void 0===a?void 0:a.width)||window.innerWidth,p=function(e){let t=e;for(;t;){const e=zr(t);if(!e||e===document.body||e===document.documentElement)break;if(e instanceof HTMLElement){const t=getComputedStyle(e),i=t.transform,n=t.willChange,a=t.filter,o=t.perspective,s=t.contain;if(i&&"none"!==i||o&&"none"!==o||a&&"none"!==a||"transform"===n||"perspective"===n||"filter"===n||s&&s.includes("paint"))return e}t=e}return null}(t);let h={top:0,left:0};if(p){const e=p.getBoundingClientRect();h={top:e.top,left:e.left}}const u=c-r.bottom,b=r.top,f=l.height||200,v=function(e,t,i){return i>=e?"bottom":t>=e||t>i?"top":"bottom"}(f,b,u);let g;g="bottom"===v?r.bottom+o:r.top-f-o;let m=r.left;const x=r.width;return m=Math.max(s,Math.min(m,d-x-s)),g=Math.max(s,Math.min(g,c-f-s)),p&&(g-=h.top,m-=h.left),{top:g,left:m,width:r.width,placement:v}}function Or(e,t,i,n={}){var a;const{viewportMargin:o=8,maxHeight:s}=n,r=(null===(a=window.visualViewport)||void 0===a?void 0:a.height)||window.innerHeight,l=t.getBoundingClientRect(),c=e.scrollHeight;let d;d="bottom"===i?r-l.bottom-o-2:l.top-o-2,s?(e.style.maxHeight=s,e.style.overflowY="auto"):c>d?(e.style.maxHeight=`${d}px`,e.style.overflowY="auto"):(e.style.maxHeight=`${c}px`,e.style.overflowY="auto")}class Pr extends Mr{constructor(){super(...arguments),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._dropdownElement=null,this._triggerElement=null,this.handleResize=()=>{this._isOpen&&this.calculatePosition()},this.handleScroll=()=>{this._isOpen&&this._triggerElement&&(!function(e){var t;const i=e.getBoundingClientRect(),n=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight;return i.bottom>=0&&i.top<=n}(this._triggerElement)?this.close():this.calculatePosition())}}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}open(){try{this._isOpen||(this._isOpen=!0,this.host.show=!0,this.requestUpdate(),this.findElements(),setTimeout(()=>{this.calculatePosition()},10),this.host&&"function"==typeof this.host.setupEventListeners&&setTimeout(()=>{this.host.setupEventListeners()},50),this.focusSearchInput(),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"open")}}close(){try{this._isOpen&&(this._isOpen=!1,this.host.show=!1,this.resetPosition(),this.requestUpdate(),this.host&&"function"==typeof this.host.removeEventListeners&&this.host.removeEventListeners(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"close")}}toggle(){this._isOpen?this.close():this.open()}focusSearchInput(){try{const e=this.host;e&&e.searchable&&setTimeout(()=>{var t;const i=null===(t=e.querySelector)||void 0===t?void 0:t.call(e,".search-input");i&&"function"==typeof i.focus&&i.focus()},100)}catch(e){console.warn("Failed to focus search input:",e)}}calculatePosition(){try{if(this._dropdownElement&&this._triggerElement||this.findElements(),!this._dropdownElement||!this._triggerElement)return;const e=Ir(this._triggerElement,this._dropdownElement,{offset:4,viewportMargin:8});this._position=e,this.applyPosition()}catch(e){this.handleError(e,"calculatePosition")}}resetPosition(){try{if(this._dropdownElement){e=this._dropdownElement,["position","top","left","right","bottom","width","min-width","max-height","min-height","height","overflow-y","transform","display","opacity","visibility","z-index"].forEach(t=>e.style.removeProperty(t)),e.classList.remove("placement-top","placement-bottom");this.host.maxHeight||this._dropdownElement.style.removeProperty("max-height")}}catch(e){this.handleError(e,"resetPosition")}var e}setElements(e,t){this._dropdownElement=e,this._triggerElement=t}findElements(){try{const e=this._host;if(e.optionsElement&&e.wrapper)return this._dropdownElement=e.optionsElement,void(this._triggerElement=e.wrapper);e.querySelector&&(this._dropdownElement=e.querySelector(".options"),this._triggerElement=e.querySelector(".wrapper"))}catch(e){this.handleError(e,"findElements")}}applyPosition(){var e;try{if(!this._dropdownElement||!this._triggerElement)return;const t=this.host.maxHeight,i=null===(e=getComputedStyle(this._dropdownElement).getPropertyValue("--nuraly-select-local-dropdown-max-height"))||void 0===e?void 0:e.trim(),n="auto"===i||!t&&"auto"===i;!function(e,t,i="9999"){e.style.position="fixed",e.style.top=`${t.top}px`,e.style.left=`${t.left}px`,e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.minWidth=`${t.width}px`,e.style.removeProperty("width"),e.style.zIndex=i,e.style.height="auto",e.style.minHeight="auto",e.classList.remove("placement-top","placement-bottom"),e.classList.add(`placement-${t.placement}`)}(this._dropdownElement,this._position,"9999"),t||n||(this._dropdownElement.style.maxHeight="none"),t?Or(this._dropdownElement,this._triggerElement,this._position.placement,{viewportMargin:10,maxHeight:t}):n?(this._dropdownElement.style.removeProperty("max-height"),this._dropdownElement.style.overflowY="visible"):Or(this._dropdownElement,this._triggerElement,this._position.placement,{viewportMargin:10})}catch(e){this.handleError(e,"applyPosition")}}getAvailableSpace(){var e,t;if(!this._triggerElement)return{above:0,below:0,left:0,right:0};const i=this._triggerElement.getBoundingClientRect(),n=(null===(e=window.visualViewport)||void 0===e?void 0:e.height)||window.innerHeight,a=(null===(t=window.visualViewport)||void 0===t?void 0:t.width)||window.innerWidth;return{above:i.top,below:n-i.bottom,left:i.left,right:a-i.right}}hostConnected(){window.addEventListener("resize",this.handleResize),window.addEventListener("scroll",this.handleScroll,!0)}hostDisconnected(){window.removeEventListener("resize",this.handleResize),window.removeEventListener("scroll",this.handleScroll,!0)}}class _r extends Mr{constructor(){super(...arguments),this._focusedIndex=-1,this._hasFocus=!1}get focusedIndex(){return this._focusedIndex}getFocusedOption(){if(this._focusedIndex>=0&&this._focusedIndex<this.host.options.length)return this.host.options[this._focusedIndex]}get hasFocus(){return this._hasFocus}setFocusedOption(e){try{e>=0&&e<this.host.options.length&&(this._focusedIndex=e,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus-change",{detail:{focusedIndex:e,focusedOption:this.getFocusedOption()},bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"setFocusedOption")}}focus(){var e;try{const t=this._host,i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".wrapper");i&&(i.focus(),this._hasFocus=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus",{bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"focus")}}blur(){var e;try{const t=this._host,i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".wrapper");i&&i.blur(),this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-blur",{bubbles:!0,composed:!0}))}catch(e){this.handleError(e,"blur")}}focusNext(){try{const e=this.getNextFocusableIndex(this._focusedIndex);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusNext")}}focusPrevious(){try{const e=this.getPreviousFocusableIndex(this._focusedIndex);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusPrevious")}}focusFirst(){try{const e=this.getNextFocusableIndex(-1);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusFirst")}}focusLast(){try{const e=this.getPreviousFocusableIndex(this.host.options.length);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusLast")}}clearFocus(){this._focusedIndex=-1,this._hasFocus=!1,this.requestUpdate()}handleFocus(){this._hasFocus=!0,this.requestUpdate()}handleBlur(){this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate()}getNextFocusableIndex(e){const t=this.host.options;for(let i=e+1;i<t.length;i++)if(!t[i].disabled)return i;for(let i=0;i<=e;i++)if(!t[i].disabled)return i;return-1}getPreviousFocusableIndex(e){const t=this.host.options;for(let i=e-1;i>=0;i--)if(!t[i].disabled)return i;for(let i=t.length-1;i>=e;i--)if(!t[i].disabled)return i;return-1}findOptionIndex(e){return this.host.options.findIndex(t=>t.value===e)}focusOptionByValue(e){const t=this.findOptionIndex(e);-1!==t&&this.setFocusedOption(t)}}!function(e){e.Valid="valid",e.Invalid="invalid",e.Pending="pending",e.Pristine="pristine"}(Tr||(Tr={}));class Rr extends He{constructor(e,t){super(e),this.selectionController=t}get validationState(){return this._validationState}validate(){try{this._validationState=Tr.Pending;const e=this.selectionController.getSelectedOptions().length>0;return this.host.required&&!e?(this.setValidationResult(!1,"This field is required",Tr.Invalid),!1):(this.setValidationResult(!0,"",Tr.Valid),!0)}catch(e){return this.handleError(e,"validate"),this.setValidationResult(!1,"Validation error occurred",Tr.Invalid),!1}}reset(){try{this._isValid=!0,this._validationMessage="",this._validationState=Tr.Pristine,this.requestUpdate(),this.dispatchValidationEvent()}catch(e){this.handleError(e,"reset")}}getFormData(){var e;try{const t=this._host,i=t.name||t.getAttribute("name")||"select",n=this.selectionController.getSelectedOptions();return this.host.multiple?{[i]:n.map(e=>e.value)}:{[i]:(null===(e=n[0])||void 0===e?void 0:e.value)||""}}catch(e){return this.handleError(e,"getFormData"),{}}}reportValidity(){var e;const t=this.validate();if(!t){const t=this._host,i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".wrapper");i&&i.focus()}return t}setCustomValidity(e){try{e?this.setValidationResult(!1,e,Tr.Invalid):this.validate()}catch(e){this.handleError(e,"setCustomValidity")}}validateOnChange(){this._validationState!==Tr.Pristine&&this.validate()}validateOnBlur(){this._validationState===Tr.Pristine&&(this._validationState=Tr.Pending),this.validate()}setValidationResult(e,t,i){const n=this._isValid!==e||this._validationMessage!==t||this._validationState!==i;this._isValid=e,this._validationMessage=t,this._validationState=i,n&&(this.requestUpdate(),this.dispatchValidationEvent())}dispatchValidationEvent(){const e={isValid:this._isValid,validationMessage:this._validationMessage,validationState:this._validationState};this.dispatchEvent(new CustomEvent("nr-validation",{detail:e,bubbles:!0,composed:!0}))}hostUpdated(){this.validateOnChange()}getValidationClasses(){return{valid:this._isValid&&this._validationState===Tr.Valid,invalid:!this._isValid&&this._validationState===Tr.Invalid,pending:this._validationState===Tr.Pending,pristine:this._validationState===Tr.Pristine}}getAriaAttributes(){const e={};return this.host.required&&(e["aria-required"]="true"),this._isValid||(e["aria-invalid"]="true",this._validationMessage&&(e["aria-describedby"]="validation-message")),e}}class Nr extends Mr{constructor(){super(...arguments),this._searchQuery="",this.handleSearchInput=e=>{this.setSearchQuery(e.detail.value||"")},this.handleSearchClear=()=>{this.clearSearch()},this.handleSearchKeyDown=e=>{if(["ArrowDown","ArrowUp","Enter","Home","End"].includes(e.key)){const t=this.host.keyboardController;return void(t&&t.handleKeyDown(e))}e.stopPropagation(),"Escape"===e.key&&(this.host.closeDropdown(),this.host.focus())}}get searchQuery(){return this._searchQuery}get hasSearch(){return""!==this._searchQuery.trim()}setSearchQuery(e){this._searchQuery=e,this.host.searchQuery=e,this.host.requestUpdate()}search(e){this.setSearchQuery(e)}clearSearch(){this.setSearchQuery("")}getFilteredOptions(e){if(!this.host.searchable||!this._searchQuery.trim())return e;const t=this._searchQuery.toLowerCase().trim();return e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t))}renderSearchInput(){return this.host.searchable?i`
23094
+ `;var mr,yr,xr,wr,$r,kr,Sr,Cr,Tr;!function(e){e.Default="default",e.Inline="inline",e.Button="button",e.Slot="slot"}(mr||(mr={})),function(e){e.Default="default",e.Warning="warning",e.Error="error",e.Success="success"}(yr||(yr={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(xr||(xr={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(wr||(wr={})),function(e){e.Horizontal="horizontal",e.Vertical="vertical"}($r||($r={})),function(e){e.Default="default",e.Solid="solid",e.Outline="outline",e.Borderless="borderless"}(kr||(kr={})),function(e){e.Bottom="bottom",e.Top="top",e.Auto="auto"}(Sr||(Sr={})),function(e){e.None="none",e.StartsWith="starts-with",e.Contains="contains",e.Fuzzy="fuzzy"}(Cr||(Cr={}));class Mr extends Ve{}class Er extends Mr{constructor(){super(...arguments),this._selectedOptions=[],this._initialized=!1}getSelectedOptions(){return[...this._selectedOptions]}getSelectedOption(){return this._selectedOptions[0]}selectOption(e){try{if(this.isOptionDisabled(e))return;const t=this.host.multiple,i=this.getCurrentValue();t?this.isOptionSelected(e)||(this._selectedOptions=[...this._selectedOptions,e],this.updateHostValue(),this.dispatchChangeEvent(i)):(this.isOptionSelected(e)?this._selectedOptions=[]:this._selectedOptions=[e],this.updateHostValue(),this.dispatchChangeEvent(i)),this.requestUpdate()}catch(e){this.handleError(e,"selectOption")}}unselectOption(e){try{if(this.isOptionSelected(e)){const t=this.getCurrentValue();this._selectedOptions=this._selectedOptions.filter(t=>t.value!==e.value),this.updateHostValue(),this.dispatchChangeEvent(t),this.requestUpdate()}}catch(e){this.handleError(e,"unselectOption")}}clearSelection(){try{if(this._selectedOptions.length>0){const e=this.getCurrentValue();this._selectedOptions=[],this.updateHostValue(),this.dispatchChangeEvent(e),this.requestUpdate()}}catch(e){this.handleError(e,"clearSelection")}}isOptionSelected(e){return this._selectedOptions.some(t=>t.value===e.value)}isOptionDisabled(e){return Boolean(e.disabled)||this.host.disabled}toggleOption(e){this.isOptionSelected(e)?this.unselectOption(e):this.selectOption(e)}initializeFromValue(){try{if(this._initialized)return;const e=this.host.value;if(!e||Array.isArray(e)&&0===e.length)return;const t=Array.isArray(e)?e:[e],i=this.host.options.filter(e=>t.includes(e.value));i.length>0&&(this._selectedOptions=this.host.multiple?i:[i[0]],this.requestUpdate()),this._initialized=!0}catch(e){this.handleError(e,"initializeFromValue")}}updateHostValue(){var e;const t=this.host.multiple?this._selectedOptions.map(e=>e.value):(null===(e=this._selectedOptions[0])||void 0===e?void 0:e.value)||"",i=this.host.value;let n=!1;if(this.host.multiple){const e=Array.isArray(i)?i:[],a=Array.isArray(t)?t:[];n=e.length===a.length&&e.every((e,t)=>e===a[t])}else n=i===t;n||(this.host.value=t)}getCurrentValue(){var e;return this.host.multiple?this._selectedOptions.map(e=>e.value):(null===(e=this._selectedOptions[0])||void 0===e?void 0:e.value)||""}dispatchChangeEvent(e){const t={value:this.getCurrentValue(),selectedOptions:this.getSelectedOptions(),previousValue:e};this.dispatchEvent(new CustomEvent("nr-change",{detail:t,bubbles:!0,composed:!0}))}hostUpdated(){this.syncWithHostOptions()}syncWithHostOptions(){try{this._selectedOptions=this._selectedOptions.filter(e=>this.host.options.some(t=>t.value===e.value)),this._selectedOptions=this._selectedOptions.map(e=>this.host.options.find(t=>t.value===e.value)||e),this.updateHostValue()}catch(e){this.handleError(e,"syncWithHostOptions")}}}class Ar extends Mr{constructor(e,t,i){super(e),this.selectionController=t,this.dropdownController=i,this._focusedIndex=-1,this._hasKeyboardNavigated=!1}handleKeyDown(e){try{const t=this.isSearchInputFocused();switch(e.key){case"ArrowDown":e.preventDefault(),this.dropdownController.isOpen?this.navigateNext():this.openDropdown();break;case"ArrowUp":e.preventDefault(),this.dropdownController.isOpen?this.navigatePrevious():this.openDropdown();break;case"Enter":this.dropdownController.isOpen?t&&this._focusedIndex>=0?(e.preventDefault(),this.selectFocused()):t||(e.preventDefault(),this.selectFocused()):(e.preventDefault(),this.openDropdown());break;case" ":t||(e.preventDefault(),this.dropdownController.isOpen?this.selectFocused():this.openDropdown());break;case"Escape":e.preventDefault(),this.closeDropdown();break;case"Tab":this.closeDropdown();break;case"Home":this.dropdownController.isOpen&&(e.preventDefault(),this.setFocusedIndex(0));break;case"End":this.dropdownController.isOpen&&(e.preventDefault(),this.setFocusedIndex(this.host.options.length-1));break;default:1===e.key.length&&/[a-zA-Z0-9]/.test(e.key)&&this.handleAlphanumericKey(e.key.toLowerCase())}}catch(e){this.handleError(e,"handleKeyDown")}}navigateNext(){try{const e=this.getNavigableOptions();if(0===e.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(0);let t=this._focusedIndex+1;t>=e.length&&(t=0),this.setFocusedIndex(t)}catch(e){this.handleError(e,"navigateNext")}}navigatePrevious(){try{const e=this.getNavigableOptions();if(0===e.length)return;if(this.isSearchInputFocused()&&(this._focusedIndex<0||!this._hasKeyboardNavigated))return this._hasKeyboardNavigated=!0,void this.setFocusedIndex(e.length-1);let t=this._focusedIndex-1;t<0&&(t=e.length-1),this.setFocusedIndex(t)}catch(e){this.handleError(e,"navigatePrevious")}}selectFocused(){try{const e=this.getNavigableOptions()[this._focusedIndex];e&&!this.selectionController.isOptionDisabled(e)&&(this.selectionController.selectOption(e),this.host.multiple||this.closeDropdown())}catch(e){this.handleError(e,"selectFocused")}}openDropdown(){try{this.dropdownController.open(),this._hasKeyboardNavigated=!1,this._focusedIndex=-1}catch(e){this.handleError(e,"openDropdown")}}closeDropdown(){try{this.dropdownController.close(),this._focusedIndex=-1,this._hasKeyboardNavigated=!1}catch(e){this.handleError(e,"closeDropdown")}}setFocusedIndex(e){try{const t=this.getNavigableOptions();e>=0&&e<t.length&&(this._focusedIndex=e,this.dispatchFocusEvent(t[e],e),this.requestUpdate(),this.scrollToFocusedOption(e))}catch(e){this.handleError(e,"setFocusedIndex")}}scrollToFocusedOption(e){var t;try{const i=this.host,n=null===(t=i.querySelector)||void 0===t?void 0:t.call(i,".options");if(!n)return;setTimeout(()=>{const t=n.querySelector(".option.focused");if(t)t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const t=40,i=n.clientHeight,a=n.scrollTop,o=e*t,s=o+t,r=a+i;o<a?n.scrollTo({top:o,behavior:"smooth"}):s>r&&n.scrollTo({top:s-i,behavior:"smooth"})}},10)}catch(e){console.warn("Failed to scroll to focused option:",e)}}get focusedIndex(){return this._focusedIndex}get focusedOption(){return this.getNavigableOptions()[this._focusedIndex]}handleAlphanumericKey(e){try{const t=this.getNavigableOptions(),i=this._focusedIndex+1;for(let n=0;n<t.length;n++){const a=(i+n)%t.length;if(t[a].label.toLowerCase().startsWith(e)){this.setFocusedIndex(a),this.dropdownController.isOpen||this.openDropdown();break}}}catch(e){this.handleError(e,"handleAlphanumericKey")}}getNavigableOptions(){const e=this.host;if(!e.options||!Array.isArray(e.options))return[];let t=e.options;return e.searchable&&e.searchQuery&&"function"==typeof e.getFilteredOptions&&(t=e.getFilteredOptions()),t.filter(e=>!e.disabled)}dispatchFocusEvent(e,t){const i={focusedOption:e,focusedIndex:t};this.dispatchEvent(new CustomEvent("nr-select-focus",{detail:i,bubbles:!0,composed:!0}))}isSearchInputFocused(){var e;try{const t=this.host;if(!t.searchable)return!1;const i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".search-input");return!!i&&(document.activeElement===i||i.contains(document.activeElement))}catch(e){return!1}}hostUpdated(){this.dropdownController.isOpen||-1===this._focusedIndex||(this._focusedIndex=-1)}}function zr(e){if(e.parentElement)return e.parentElement;const t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function Ir(e,t,i={}){var n,a;const{offset:o=4,viewportMargin:s=8}=i,r=e.getBoundingClientRect(),l=t.getBoundingClientRect(),c=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||window.innerHeight,d=(null===(a=window.visualViewport)||void 0===a?void 0:a.width)||window.innerWidth,p=function(e){let t=e;for(;t;){const e=zr(t);if(!e||e===document.body||e===document.documentElement)break;if(e instanceof HTMLElement){const t=getComputedStyle(e),i=t.transform,n=t.willChange,a=t.filter,o=t.perspective,s=t.contain;if(i&&"none"!==i||o&&"none"!==o||a&&"none"!==a||"transform"===n||"perspective"===n||"filter"===n||s&&s.includes("paint"))return e}t=e}return null}(t);let h={top:0,left:0};if(p){const e=p.getBoundingClientRect();h={top:e.top,left:e.left}}const u=c-r.bottom,b=r.top,f=l.height||200,v=function(e,t,i){return i>=e?"bottom":t>=e||t>i?"top":"bottom"}(f,b,u);let g;g="bottom"===v?r.bottom+o:r.top-f-o;let m=r.left;const y=r.width;return m=Math.max(s,Math.min(m,d-y-s)),g=Math.max(s,Math.min(g,c-f-s)),p&&(g-=h.top,m-=h.left),{top:g,left:m,width:r.width,placement:v}}function Or(e,t,i,n={}){var a;const{viewportMargin:o=8,maxHeight:s}=n,r=(null===(a=window.visualViewport)||void 0===a?void 0:a.height)||window.innerHeight,l=t.getBoundingClientRect(),c=e.scrollHeight;let d;d="bottom"===i?r-l.bottom-o-2:l.top-o-2,s?(e.style.maxHeight=s,e.style.overflowY="auto"):c>d?(e.style.maxHeight=`${d}px`,e.style.overflowY="auto"):(e.style.maxHeight=`${c}px`,e.style.overflowY="auto")}class Pr extends Mr{constructor(){super(...arguments),this._isOpen=!1,this._position={top:0,left:0,width:0,placement:"bottom"},this._dropdownElement=null,this._triggerElement=null,this.handleResize=()=>{this._isOpen&&this.calculatePosition()},this.handleScroll=()=>{this._isOpen&&this._triggerElement&&(!function(e){var t;const i=e.getBoundingClientRect(),n=(null===(t=window.visualViewport)||void 0===t?void 0:t.height)||window.innerHeight;return i.bottom>=0&&i.top<=n}(this._triggerElement)?this.close():this.calculatePosition())}}get isOpen(){return this._isOpen}get position(){return Object.assign({},this._position)}open(){try{this._isOpen||(this._isOpen=!0,this.host.show=!0,this.requestUpdate(),this.findElements(),setTimeout(()=>{this.calculatePosition()},10),this.host&&"function"==typeof this.host.setupEventListeners&&setTimeout(()=>{this.host.setupEventListeners()},50),this.focusSearchInput(),this.dispatchEvent(new CustomEvent("nr-dropdown-open",{bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"open")}}close(){try{this._isOpen&&(this._isOpen=!1,this.host.show=!1,this.resetPosition(),this.requestUpdate(),this.host&&"function"==typeof this.host.removeEventListeners&&this.host.removeEventListeners(),this.dispatchEvent(new CustomEvent("nr-dropdown-close",{bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"close")}}toggle(){this._isOpen?this.close():this.open()}focusSearchInput(){try{const e=this.host;e&&e.searchable&&setTimeout(()=>{var t;const i=null===(t=e.querySelector)||void 0===t?void 0:t.call(e,".search-input");i&&"function"==typeof i.focus&&i.focus()},100)}catch(e){console.warn("Failed to focus search input:",e)}}calculatePosition(){try{if(this._dropdownElement&&this._triggerElement||this.findElements(),!this._dropdownElement||!this._triggerElement)return;const e=Ir(this._triggerElement,this._dropdownElement,{offset:4,viewportMargin:8});this._position=e,this.applyPosition()}catch(e){this.handleError(e,"calculatePosition")}}resetPosition(){try{if(this._dropdownElement){e=this._dropdownElement,["position","top","left","right","bottom","width","min-width","max-height","min-height","height","overflow-y","transform","display","opacity","visibility","z-index"].forEach(t=>e.style.removeProperty(t)),e.classList.remove("placement-top","placement-bottom");this.host.maxHeight||this._dropdownElement.style.removeProperty("max-height")}}catch(e){this.handleError(e,"resetPosition")}var e}setElements(e,t){this._dropdownElement=e,this._triggerElement=t}findElements(){try{const e=this._host;if(e.optionsElement&&e.wrapper)return this._dropdownElement=e.optionsElement,void(this._triggerElement=e.wrapper);e.querySelector&&(this._dropdownElement=e.querySelector(".options"),this._triggerElement=e.querySelector(".wrapper"))}catch(e){this.handleError(e,"findElements")}}applyPosition(){var e;try{if(!this._dropdownElement||!this._triggerElement)return;const t=this.host.maxHeight,i=null===(e=getComputedStyle(this._dropdownElement).getPropertyValue("--nuraly-select-local-dropdown-max-height"))||void 0===e?void 0:e.trim(),n="auto"===i||!t&&"auto"===i;!function(e,t,i="9999"){e.style.position="fixed",e.style.top=`${t.top}px`,e.style.left=`${t.left}px`,e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.minWidth=`${t.width}px`,e.style.removeProperty("width"),e.style.zIndex=i,e.style.height="auto",e.style.minHeight="auto",e.classList.remove("placement-top","placement-bottom"),e.classList.add(`placement-${t.placement}`)}(this._dropdownElement,this._position,"9999"),t||n||(this._dropdownElement.style.maxHeight="none"),t?Or(this._dropdownElement,this._triggerElement,this._position.placement,{viewportMargin:10,maxHeight:t}):n?(this._dropdownElement.style.removeProperty("max-height"),this._dropdownElement.style.overflowY="visible"):Or(this._dropdownElement,this._triggerElement,this._position.placement,{viewportMargin:10})}catch(e){this.handleError(e,"applyPosition")}}getAvailableSpace(){var e,t;if(!this._triggerElement)return{above:0,below:0,left:0,right:0};const i=this._triggerElement.getBoundingClientRect(),n=(null===(e=window.visualViewport)||void 0===e?void 0:e.height)||window.innerHeight,a=(null===(t=window.visualViewport)||void 0===t?void 0:t.width)||window.innerWidth;return{above:i.top,below:n-i.bottom,left:i.left,right:a-i.right}}hostConnected(){window.addEventListener("resize",this.handleResize),window.addEventListener("scroll",this.handleScroll,!0)}hostDisconnected(){window.removeEventListener("resize",this.handleResize),window.removeEventListener("scroll",this.handleScroll,!0)}}class _r extends Mr{constructor(){super(...arguments),this._focusedIndex=-1,this._hasFocus=!1}get focusedIndex(){return this._focusedIndex}getFocusedOption(){if(this._focusedIndex>=0&&this._focusedIndex<this.host.options.length)return this.host.options[this._focusedIndex]}get hasFocus(){return this._hasFocus}setFocusedOption(e){try{e>=0&&e<this.host.options.length&&(this._focusedIndex=e,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus-change",{detail:{focusedIndex:e,focusedOption:this.getFocusedOption()},bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"setFocusedOption")}}focus(){var e;try{const t=this._host,i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".wrapper");i&&(i.focus(),this._hasFocus=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-focus",{bubbles:!0,composed:!0})))}catch(e){this.handleError(e,"focus")}}blur(){var e;try{const t=this._host,i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".wrapper");i&&i.blur(),this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate(),this.dispatchEvent(new CustomEvent("nr-blur",{bubbles:!0,composed:!0}))}catch(e){this.handleError(e,"blur")}}focusNext(){try{const e=this.getNextFocusableIndex(this._focusedIndex);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusNext")}}focusPrevious(){try{const e=this.getPreviousFocusableIndex(this._focusedIndex);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusPrevious")}}focusFirst(){try{const e=this.getNextFocusableIndex(-1);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusFirst")}}focusLast(){try{const e=this.getPreviousFocusableIndex(this.host.options.length);-1!==e&&this.setFocusedOption(e)}catch(e){this.handleError(e,"focusLast")}}clearFocus(){this._focusedIndex=-1,this._hasFocus=!1,this.requestUpdate()}handleFocus(){this._hasFocus=!0,this.requestUpdate()}handleBlur(){this._hasFocus=!1,this._focusedIndex=-1,this.requestUpdate()}getNextFocusableIndex(e){const t=this.host.options;for(let i=e+1;i<t.length;i++)if(!t[i].disabled)return i;for(let i=0;i<=e;i++)if(!t[i].disabled)return i;return-1}getPreviousFocusableIndex(e){const t=this.host.options;for(let i=e-1;i>=0;i--)if(!t[i].disabled)return i;for(let i=t.length-1;i>=e;i--)if(!t[i].disabled)return i;return-1}findOptionIndex(e){return this.host.options.findIndex(t=>t.value===e)}focusOptionByValue(e){const t=this.findOptionIndex(e);-1!==t&&this.setFocusedOption(t)}}!function(e){e.Valid="valid",e.Invalid="invalid",e.Pending="pending",e.Pristine="pristine"}(Tr||(Tr={}));class Rr extends He{constructor(e,t){super(e),this.selectionController=t}get validationState(){return this._validationState}validate(){try{this._validationState=Tr.Pending;const e=this.selectionController.getSelectedOptions().length>0;return this.host.required&&!e?(this.setValidationResult(!1,"This field is required",Tr.Invalid),!1):(this.setValidationResult(!0,"",Tr.Valid),!0)}catch(e){return this.handleError(e,"validate"),this.setValidationResult(!1,"Validation error occurred",Tr.Invalid),!1}}reset(){try{this._isValid=!0,this._validationMessage="",this._validationState=Tr.Pristine,this.requestUpdate(),this.dispatchValidationEvent()}catch(e){this.handleError(e,"reset")}}getFormData(){var e;try{const t=this._host,i=t.name||t.getAttribute("name")||"select",n=this.selectionController.getSelectedOptions();return this.host.multiple?{[i]:n.map(e=>e.value)}:{[i]:(null===(e=n[0])||void 0===e?void 0:e.value)||""}}catch(e){return this.handleError(e,"getFormData"),{}}}reportValidity(){var e;const t=this.validate();if(!t){const t=this._host,i=null===(e=t.querySelector)||void 0===e?void 0:e.call(t,".wrapper");i&&i.focus()}return t}setCustomValidity(e){try{e?this.setValidationResult(!1,e,Tr.Invalid):this.validate()}catch(e){this.handleError(e,"setCustomValidity")}}validateOnChange(){this._validationState!==Tr.Pristine&&this.validate()}validateOnBlur(){this._validationState===Tr.Pristine&&(this._validationState=Tr.Pending),this.validate()}setValidationResult(e,t,i){const n=this._isValid!==e||this._validationMessage!==t||this._validationState!==i;this._isValid=e,this._validationMessage=t,this._validationState=i,n&&(this.requestUpdate(),this.dispatchValidationEvent())}dispatchValidationEvent(){const e={isValid:this._isValid,validationMessage:this._validationMessage,validationState:this._validationState};this.dispatchEvent(new CustomEvent("nr-validation",{detail:e,bubbles:!0,composed:!0}))}hostUpdated(){this.validateOnChange()}getValidationClasses(){return{valid:this._isValid&&this._validationState===Tr.Valid,invalid:!this._isValid&&this._validationState===Tr.Invalid,pending:this._validationState===Tr.Pending,pristine:this._validationState===Tr.Pristine}}getAriaAttributes(){const e={};return this.host.required&&(e["aria-required"]="true"),this._isValid||(e["aria-invalid"]="true",this._validationMessage&&(e["aria-describedby"]="validation-message")),e}}class Nr extends Mr{constructor(){super(...arguments),this._searchQuery="",this.handleSearchInput=e=>{this.setSearchQuery(e.detail.value||"")},this.handleSearchClear=()=>{this.clearSearch()},this.handleSearchKeyDown=e=>{if(["ArrowDown","ArrowUp","Enter","Home","End"].includes(e.key)){const t=this.host.keyboardController;return void(t&&t.handleKeyDown(e))}e.stopPropagation(),"Escape"===e.key&&(this.host.closeDropdown(),this.host.focus())}}get searchQuery(){return this._searchQuery}get hasSearch(){return""!==this._searchQuery.trim()}setSearchQuery(e){this._searchQuery=e,this.host.searchQuery=e,this.host.requestUpdate()}search(e){this.setSearchQuery(e)}clearSearch(){this.setSearchQuery("")}getFilteredOptions(e){if(!this.host.searchable||!this._searchQuery.trim())return e;const t=this._searchQuery.toLowerCase().trim();return e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t))}renderSearchInput(){return this.host.searchable?i`
23086
23095
  <div class="search-container">
23087
23096
  <nr-input
23088
23097
  type="text"
@@ -23119,7 +23128,7 @@ const pr=e`
23119
23128
  * @license
23120
23129
  * Copyright 2023 Nuraly, Laabidi Aymen
23121
23130
  * SPDX-License-Identifier: MIT
23122
- */var Lr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s};let jr=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-input","nr-icon"],this.options=[],this.placeholder="Select an option",this.disabled=!1,this.type=mr.Default,this.multiple=!1,this.show=!1,this.status=xr.Default,this.size=yr.Medium,this.required=!1,this.name="",this.value="",this.noOptionsMessage="No options available",this.noOptionsIcon="info",this.searchable=!1,this.clearable=!1,this.searchPlaceholder="Search options...",this.searchQuery="",this.useCustomSelectedDisplay=!1,this.maxHeight="",this.block=!1,this.selectionController=new Er(this),this.dropdownController=new Pr(this),this.keyboardController=new Ar(this,this.selectionController,this.dropdownController),this.focusController=new _r(this),this.validationController=new Rr(this,this.selectionController),this.searchController=new Nr(this),this.eventController=new Dr(this),this.handleTriggerClick=e=>{this.eventController.handleTriggerClick(e)},this.handleOptionClick=(e,t)=>{this.eventController.handleOptionClick(e,t)},this.handleTagRemove=(e,t)=>{this.eventController.handleTagRemove(e,t)},this.handleClearAll=e=>{this.eventController.handleClearAll(e)},this.handleKeyDown=e=>{this.eventController.handleKeyDown(e)},this.handleFocus=()=>{this.eventController.handleFocus()},this.handleBlur=()=>{this.eventController.handleBlur()}}get optionsElement(){return this.renderRoot.querySelector(".options")}get wrapper(){return this.renderRoot.querySelector(".wrapper")}get searchInput(){return this.renderRoot.querySelector(".search-input")}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}willUpdate(e){super.willUpdate(e),(e.has("options")||e.has("value"))&&this.options.length>0&&this.value&&(Array.isArray(this.value)?this.value.length>0:""!==this.value)&&(this.selectionController._initialized=!1,this.selectionController.initializeFromValue())}firstUpdated(e){super.firstUpdated(e),this.optionsElement&&this.wrapper?this.dropdownController.setElements(this.optionsElement,this.wrapper):setTimeout(()=>{this.optionsElement&&this.wrapper&&this.dropdownController.setElements(this.optionsElement,this.wrapper)},100),this.value&&(Array.isArray(this.value)?this.value.length>0:""!==this.value)&&this.selectionController.initializeFromValue()}get selectedOptions(){return this.selectionController.getSelectedOptions()}get selectedOption(){return this.selectionController.getSelectedOption()}selectOption(e){this.selectionController.selectOption(e)}unselectOption(e){this.selectionController.unselectOption(e)}toggleOption(e){this.selectionController.toggleOption(e)}clearSelection(){this.selectionController.clearSelection()}isOptionSelected(e){return this.selectionController.isOptionSelected(e)}toggleDropdown(){this.dropdownController.toggle()}openDropdown(){this.dropdownController.open()}closeDropdown(){this.dropdownController.close()}focus(){this.focusController.focus()}blur(){this.focusController.blur()}validate(){return this.validationController.validate()}checkValidity(){return this.validationController.checkValidity()}reportValidity(){return this.validationController.reportValidity()}setCustomValidity(e){this.validationController.setCustomValidity(e)}getValidationStatus(){return{isValid:this.validationController.checkValidity(),validationMessage:this.validationController.validationMessage||""}}get validationMessage(){return this.validationController.validationMessage||""}clearValidation(){this.validationController.setCustomValidity(""),this.status=xr.Default}searchOptions(e){this.searchController.search(e)}clearSearch(){this.searchController.clearSearch()}getSearchFilteredOptions(){return this.searchController.getFilteredOptions(this.options)}getCurrentSearchQuery(){return this.searchController.searchQuery}getSelectedOptions(){return this.selectedOptions}setupGlobalEventListeners(){this.eventController.setupEventListeners()}removeGlobalEventListeners(){this.eventController.removeEventListeners()}getFilteredOptions(){return this.searchController.getFilteredOptions(this.options)}setupEventListeners(){this.eventController.setupEventListeners()}removeEventListeners(){this.eventController.removeEventListeners()}render(){return i`${z(this.type,[[mr.Default,()=>this.renderDefault()],[mr.Inline,()=>this.renderInline()],[mr.Button,()=>this.renderButton()],[mr.Slot,()=>this.renderSlot()]])}`}renderDefault(){const e=this.selectedOptions,t=this.validationController.getValidationClasses();return i`
23131
+ */var Lr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,r=e.length-1;r>=0;r--)(a=e[r])&&(s=(o<3?a(s):o>3?a(t,i,s):a(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s};let jr=class extends($e(t)){constructor(){super(...arguments),this.requiredComponents=["nr-input","nr-icon"],this.options=[],this.placeholder="Select an option",this.disabled=!1,this.type=mr.Default,this.multiple=!1,this.show=!1,this.status=yr.Default,this.size=xr.Medium,this.required=!1,this.name="",this.value="",this.noOptionsMessage="No options available",this.noOptionsIcon="info",this.searchable=!1,this.clearable=!1,this.searchPlaceholder="Search options...",this.searchQuery="",this.useCustomSelectedDisplay=!1,this.maxHeight="",this.block=!1,this.selectionController=new Er(this),this.dropdownController=new Pr(this),this.keyboardController=new Ar(this,this.selectionController,this.dropdownController),this.focusController=new _r(this),this.validationController=new Rr(this,this.selectionController),this.searchController=new Nr(this),this.eventController=new Dr(this),this.handleTriggerClick=e=>{this.eventController.handleTriggerClick(e)},this.handleOptionClick=(e,t)=>{this.eventController.handleOptionClick(e,t)},this.handleTagRemove=(e,t)=>{this.eventController.handleTagRemove(e,t)},this.handleClearAll=e=>{this.eventController.handleClearAll(e)},this.handleKeyDown=e=>{this.eventController.handleKeyDown(e)},this.handleFocus=()=>{this.eventController.handleFocus()},this.handleBlur=()=>{this.eventController.handleBlur()}}get optionsElement(){return this.renderRoot.querySelector(".options")}get wrapper(){return this.renderRoot.querySelector(".wrapper")}get searchInput(){return this.renderRoot.querySelector(".search-input")}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}willUpdate(e){super.willUpdate(e),(e.has("options")||e.has("value"))&&this.options.length>0&&this.value&&(Array.isArray(this.value)?this.value.length>0:""!==this.value)&&(this.selectionController._initialized=!1,this.selectionController.initializeFromValue())}firstUpdated(e){super.firstUpdated(e),this.optionsElement&&this.wrapper?this.dropdownController.setElements(this.optionsElement,this.wrapper):setTimeout(()=>{this.optionsElement&&this.wrapper&&this.dropdownController.setElements(this.optionsElement,this.wrapper)},100),this.value&&(Array.isArray(this.value)?this.value.length>0:""!==this.value)&&this.selectionController.initializeFromValue()}get selectedOptions(){return this.selectionController.getSelectedOptions()}get selectedOption(){return this.selectionController.getSelectedOption()}selectOption(e){this.selectionController.selectOption(e)}unselectOption(e){this.selectionController.unselectOption(e)}toggleOption(e){this.selectionController.toggleOption(e)}clearSelection(){this.selectionController.clearSelection()}isOptionSelected(e){return this.selectionController.isOptionSelected(e)}toggleDropdown(){this.dropdownController.toggle()}openDropdown(){this.dropdownController.open()}closeDropdown(){this.dropdownController.close()}focus(){this.focusController.focus()}blur(){this.focusController.blur()}validate(){return this.validationController.validate()}checkValidity(){return this.validationController.checkValidity()}reportValidity(){return this.validationController.reportValidity()}setCustomValidity(e){this.validationController.setCustomValidity(e)}getValidationStatus(){return{isValid:this.validationController.checkValidity(),validationMessage:this.validationController.validationMessage||""}}get validationMessage(){return this.validationController.validationMessage||""}clearValidation(){this.validationController.setCustomValidity(""),this.status=yr.Default}searchOptions(e){this.searchController.search(e)}clearSearch(){this.searchController.clearSearch()}getSearchFilteredOptions(){return this.searchController.getFilteredOptions(this.options)}getCurrentSearchQuery(){return this.searchController.searchQuery}getSelectedOptions(){return this.selectedOptions}setupGlobalEventListeners(){this.eventController.setupEventListeners()}removeGlobalEventListeners(){this.eventController.removeEventListeners()}getFilteredOptions(){return this.searchController.getFilteredOptions(this.options)}setupEventListeners(){this.eventController.setupEventListeners()}removeEventListeners(){this.eventController.removeEventListeners()}render(){return i`${z(this.type,[[mr.Default,()=>this.renderDefault()],[mr.Inline,()=>this.renderInline()],[mr.Button,()=>this.renderButton()],[mr.Slot,()=>this.renderSlot()]])}`}renderDefault(){const e=this.selectedOptions,t=this.validationController.getValidationClasses();return i`
23123
23132
  <slot name="label"></slot>
23124
23133
  <div
23125
23134
  class="${h(Object.assign({wrapper:!0},t))}"
@@ -23218,7 +23227,7 @@ const pr=e`
23218
23227
  aria-label="Remove ${e.label}"
23219
23228
  ></nr-icon>
23220
23229
  </span>
23221
- `):i`${e[0].label}`}renderStatusIcon(){switch(this.status){case xr.Warning:return i`<nr-icon name="alert-triangle" size="${this.size}" class="status-icon warning"></nr-icon>`;case xr.Error:return i`<nr-icon name="alert-circle" size="${this.size}" class="status-icon error"></nr-icon>`;case xr.Success:return i`<nr-icon name="circle-check" size="${this.size}" class="status-icon success"></nr-icon>`;default:return n}}renderClearButton(e){return!this.clearable||0===e.length||this.disabled?n:i`
23230
+ `):i`${e[0].label}`}renderStatusIcon(){switch(this.status){case yr.Warning:return i`<nr-icon name="alert-triangle" size="${this.size}" class="status-icon warning"></nr-icon>`;case yr.Error:return i`<nr-icon name="alert-circle" size="${this.size}" class="status-icon error"></nr-icon>`;case yr.Success:return i`<nr-icon name="circle-check" size="${this.size}" class="status-icon success"></nr-icon>`;default:return n}}renderClearButton(e){return!this.clearable||0===e.length||this.disabled?n:i`
23222
23231
  <nr-icon
23223
23232
  part="clear"
23224
23233
  name="x"
@@ -24686,13 +24695,13 @@ var Kr,Jr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Obje
24686
24695
  ${this.remoteTyping.username} is typing...
24687
24696
  </div>
24688
24697
  `:n}
24689
- `}render(){var e,t;const a=this.node.configuration||{},o=this.node.type,s=a.width||200,r=a.height||200,l=a.backgroundColor||a.fillColor||Q[this.node.type]||"#3b82f6",c=a.textColor||"#1a1a1a",d=a.fontSize||14,p=a.textAlign||"center",h=a.borderColor||"transparent",u=a.borderWidth||0,b=a.borderRadius||0,f=null!==(e=a.opacity)&&void 0!==e?e:1,v=a.rotation||0,g={"node-container":!0,"wb-node":!0,selected:this.selected,dragging:this.dragging,editing:this.editing,"remote-selected":!!this.remoteSelection},m={left:`${this.node.position.x}px`,top:`${this.node.position.y}px`,"--wb-width":`${s}px`,"--wb-height":`${r}px`,"--wb-bg":l,"--wb-text-color":c,"--wb-font-size":`${d}px`,"--wb-text-align":p,"--wb-border-color":h,"--wb-border-width":`${u}px`,"--wb-border-radius":`${b}px`,"--wb-opacity":`${f}`,"--wb-rotation":`${v}deg`};let x;switch(this.remoteSelection&&(m["--remote-selection-color"]=this.remoteSelection.color),o){case q.STICKY_NOTE:x=this.renderWbStickyNote(g,m,a);break;case q.TEXT_BLOCK:x=this.renderWbTextBlock(g,m,a);break;case q.SHAPE_CIRCLE:x=this.renderWbShape(g,m,a,"circle");break;case q.SHAPE_DIAMOND:x=this.renderWbShape(g,m,a,"diamond");break;case q.SHAPE_TRIANGLE:x=this.renderWbShape(g,m,a,"triangle");break;case q.SHAPE_STAR:x=this.renderWbShape(g,m,a,"star");break;case q.SHAPE_HEXAGON:x=this.renderWbShape(g,m,a,"hexagon");break;case q.SHAPE_ARROW:case q.SHAPE_LINE:x=this.renderWbLine(g,m,a,o===q.SHAPE_ARROW);break;case q.IMAGE:x=this.renderWbImage(g,m,a);break;case q.FRAME:x=this.renderWbFrame(g,m,a);break;case q.VOTING:x=this.renderWbVoting(g,m,a);break;case q.MERMAID:x=this.renderWbMermaid(g,m,a);break;case q.ANCHOR:x=this.renderWbAnchor(g,m,a);break;case q.WORKFLOW:x=this.renderWbWorkflow(g,m,a);break;case q.DATABASE:x=this.renderWbDatabase(g,m,a);break;case q.SHAPE_RECTANGLE:default:x=this.renderWbRectangle(g,m,a)}const y=(null===(t=this.node.configuration)||void 0===t?void 0:t.onClickAction)&&"none"!==this.node.configuration.onClickAction;return this.remoteSelection||this.remoteTyping?i`
24698
+ `}render(){var e,t;const a=this.node.configuration||{},o=this.node.type,s=a.width||200,r=a.height||200,l=a.backgroundColor||a.fillColor||Q[this.node.type]||"#3b82f6",c=a.textColor||"#1a1a1a",d=a.fontSize||14,p=a.textAlign||"center",h=a.borderColor||"transparent",u=a.borderWidth||0,b=a.borderRadius||0,f=null!==(e=a.opacity)&&void 0!==e?e:1,v=a.rotation||0,g={"node-container":!0,"wb-node":!0,selected:this.selected,dragging:this.dragging,editing:this.editing,"remote-selected":!!this.remoteSelection},m={left:`${this.node.position.x}px`,top:`${this.node.position.y}px`,"--wb-width":`${s}px`,"--wb-height":`${r}px`,"--wb-bg":l,"--wb-text-color":c,"--wb-font-size":`${d}px`,"--wb-text-align":p,"--wb-border-color":h,"--wb-border-width":`${u}px`,"--wb-border-radius":`${b}px`,"--wb-opacity":`${f}`,"--wb-rotation":`${v}deg`};let y;switch(this.remoteSelection&&(m["--remote-selection-color"]=this.remoteSelection.color),o){case q.STICKY_NOTE:y=this.renderWbStickyNote(g,m,a);break;case q.TEXT_BLOCK:y=this.renderWbTextBlock(g,m,a);break;case q.SHAPE_CIRCLE:y=this.renderWbShape(g,m,a,"circle");break;case q.SHAPE_DIAMOND:y=this.renderWbShape(g,m,a,"diamond");break;case q.SHAPE_TRIANGLE:y=this.renderWbShape(g,m,a,"triangle");break;case q.SHAPE_STAR:y=this.renderWbShape(g,m,a,"star");break;case q.SHAPE_HEXAGON:y=this.renderWbShape(g,m,a,"hexagon");break;case q.SHAPE_ARROW:case q.SHAPE_LINE:y=this.renderWbLine(g,m,a,o===q.SHAPE_ARROW);break;case q.IMAGE:y=this.renderWbImage(g,m,a);break;case q.FRAME:y=this.renderWbFrame(g,m,a);break;case q.VOTING:y=this.renderWbVoting(g,m,a);break;case q.MERMAID:y=this.renderWbMermaid(g,m,a);break;case q.ANCHOR:y=this.renderWbAnchor(g,m,a);break;case q.WORKFLOW:y=this.renderWbWorkflow(g,m,a);break;case q.DATABASE:y=this.renderWbDatabase(g,m,a);break;case q.SHAPE_RECTANGLE:default:y=this.renderWbRectangle(g,m,a)}const x=(null===(t=this.node.configuration)||void 0===t?void 0:t.onClickAction)&&"none"!==this.node.configuration.onClickAction;return this.remoteSelection||this.remoteTyping?i`
24690
24699
  <div class="remote-overlay-wrapper" style="position: relative;">
24691
- ${x}
24700
+ ${y}
24692
24701
  ${this.renderRemoteOverlays()}
24693
24702
  </div>
24694
- ${y?this.renderActionIndicator():n}
24695
- `:y?i`${x}${this.renderActionIndicator()}`:x}};Qr.useShadowDom=!0,Qr.styles=Wr,Qr.CLICK_THRESHOLD=5,Jr([s({type:Object})],Qr.prototype,"node",void 0),Jr([s({type:Boolean})],Qr.prototype,"selected",void 0),Jr([s({type:Boolean})],Qr.prototype,"dragging",void 0),Jr([s({type:String})],Qr.prototype,"connectingPortId",void 0),Jr([s({type:Boolean})],Qr.prototype,"editing",void 0),Jr([s({type:Object})],Qr.prototype,"remoteSelection",void 0),Jr([s({type:Object})],Qr.prototype,"remoteTyping",void 0),Jr([s({type:String})],Qr.prototype,"actionTargetLabel",void 0),Jr([r()],Qr.prototype,"_mermaidSvg",void 0),Jr([r()],Qr.prototype,"_mermaidError",void 0),Qr=Kr=Jr([l("whiteboard-node")],Qr);const Xr=[e`
24703
+ ${x?this.renderActionIndicator():n}
24704
+ `:x?i`${y}${this.renderActionIndicator()}`:y}};Qr.useShadowDom=!0,Qr.styles=Wr,Qr.CLICK_THRESHOLD=5,Jr([s({type:Object})],Qr.prototype,"node",void 0),Jr([s({type:Boolean})],Qr.prototype,"selected",void 0),Jr([s({type:Boolean})],Qr.prototype,"dragging",void 0),Jr([s({type:String})],Qr.prototype,"connectingPortId",void 0),Jr([s({type:Boolean})],Qr.prototype,"editing",void 0),Jr([s({type:Object})],Qr.prototype,"remoteSelection",void 0),Jr([s({type:Object})],Qr.prototype,"remoteTyping",void 0),Jr([s({type:String})],Qr.prototype,"actionTargetLabel",void 0),Jr([r()],Qr.prototype,"_mermaidSvg",void 0),Jr([r()],Qr.prototype,"_mermaidError",void 0),Qr=Kr=Jr([l("whiteboard-node")],Qr);const Xr=[e`
24696
24705
  :host {
24697
24706
  display: block;
24698
24707
  width: 100%;
@@ -25768,7 +25777,7 @@ var Zr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.
25768
25777
  </button>
25769
25778
  ${e.shapesFlyoutOpen?i`
25770
25779
  <div class="wb-shapes-flyout">
25771
- ${xs.map(t=>i`
25780
+ ${ys.map(t=>i`
25772
25781
  <button
25773
25782
  class="wb-shapes-flyout-btn"
25774
25783
  @click=${()=>e.onAddNode(t.type)}
@@ -25923,4 +25932,4 @@ var Zr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.
25923
25932
  * input blob → AudioContext.decodeAudioData → BufferSource → MediaStreamDestination
25924
25933
  * → MediaRecorder(ogg/opus, 32 kbps) → output blob
25925
25934
  */
25926
- var tl=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const il="audio/ogg;codecs=opus";function nl(){try{return"undefined"!=typeof MediaRecorder&&MediaRecorder.isTypeSupported(il)}catch(e){return!1}}var al=Object.freeze({__proto__:null,canEncodeOgg:nl,compressToOpus:function(e,t){return tl(this,void 0,void 0,function*(){if(!nl()){const i=t.includes("mp4")?"mp4":t.includes("aac")?"aac":"webm";return{blob:e,mimeType:t,ext:i}}const i=yield e.arrayBuffer(),n=new AudioContext;let a;try{a=yield n.decodeAudioData(i)}finally{n.close().catch(()=>{})}const o=new AudioContext({sampleRate:a.sampleRate}),s=o.createMediaStreamDestination(),r=new MediaRecorder(s.stream,{mimeType:il,audioBitsPerSecond:32e3}),l=[];r.ondataavailable=e=>{e.data.size>0&&l.push(e.data)};const c=new Promise((e,t)=>{r.onstop=()=>e(),r.onerror=e=>{var i;return t(null!==(i=e.error)&&void 0!==i?i:new Error("MediaRecorder error"))}});r.start(100);const d=o.createBufferSource();return d.buffer=a,d.connect(s),d.onended=()=>{setTimeout(()=>{"recording"===r.state&&r.stop()},120)},d.start(0),yield c,o.close().catch(()=>{}),{blob:new Blob(l,{type:il}),mimeType:il,ext:"ogg"}})}});const ol=(e,t=0,i=1)=>e>i?i:e<t?t:e,sl=(e,t=0,i=Math.pow(10,t))=>Math.round(i*e)/i,rl=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?sl(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?sl(parseInt(e.substring(6,8),16)/255,2):1}),ll=e=>{const{h:t,s:i,l:n}=(({h:e,s:t,v:i,a:n})=>{const a=(200-t)*i/100;return{h:sl(e),s:sl(a>0&&a<200?t*i/100/(a<=100?a:200-a)*100:0),l:sl(a/2),a:sl(n,2)}})(e);return`hsl(${t}, ${i}%, ${n}%)`},cl=({h:e,s:t,v:i,a:n})=>{e=e/360*6,t/=100,i/=100;const a=Math.floor(e),o=i*(1-t),s=i*(1-(e-a)*t),r=i*(1-(1-e+a)*t),l=a%6;return{r:sl(255*[i,s,o,o,r,i][l]),g:sl(255*[r,i,i,s,o,o][l]),b:sl(255*[o,o,r,i,i,s][l]),a:sl(n,2)}},dl=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},pl=({r:e,g:t,b:i,a:n})=>{const a=n<1?dl(sl(255*n)):"";return"#"+dl(e)+dl(t)+dl(i)+a},hl=({r:e,g:t,b:i,a:n})=>{const a=Math.max(e,t,i),o=a-Math.min(e,t,i),s=o?a===e?(t-i)/o:a===t?2+(i-e)/o:4+(e-t)/o:0;return{h:sl(60*(s<0?s+6:s)),s:sl(a?o/a*100:0),v:sl(a/255*100),a:n}},ul=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},bl={},fl=e=>{let t=bl[e];return t||(t=document.createElement("template"),t.innerHTML=e,bl[e]=t),t},vl=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let gl=!1;const ml=e=>"touches"in e,xl=(e,t)=>{const i=ml(t)?t.touches[0]:t,n=e.el.getBoundingClientRect();vl(e.el,"move",e.getMove({x:ol((i.pageX-(n.left+window.pageXOffset))/n.width),y:ol((i.pageY-(n.top+window.pageYOffset))/n.height)}))};class yl{constructor(e,t,i,n){const a=fl(`<div role="slider" tabindex="0" part="${t}" ${i}><div part="${t}-pointer"></div></div>`);e.appendChild(a.content.cloneNode(!0));const o=e.querySelector(`[part=${t}]`);o.addEventListener("mousedown",this),o.addEventListener("touchstart",this),o.addEventListener("keydown",this),this.el=o,this.xy=n,this.nodes=[o.firstChild,o]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(gl?"touchmove":"mousemove",this),t(gl?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(gl&&!ml(e)||(gl||(gl=ml(e)),0)))(e)||!gl&&0!=e.button)return;this.el.focus(),xl(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),xl(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const i=t.keyCode;i>40||e.xy&&i<37||i<33||(t.preventDefault(),vl(e.el,"move",e.getMove({x:39===i?.01:37===i?-.01:34===i?.05:33===i?-.05:35===i?1:36===i?-1:0,y:40===i?.01:38===i?-.01:0},!0)))})(this,e)}}style(e){e.forEach((e,t)=>{for(const i in e)this.nodes[t].style.setProperty(i,e[i])})}}class wl extends yl{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:ll({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${sl(e)}`)}getMove(e,t){return{h:t?ol(this.h+360*e.x,0,360):360*e.x}}}class $l extends yl{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:ll(e)},{"background-color":ll({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${sl(e.s)}%, Brightness ${sl(e.v)}%`)}getMove(e,t){return{s:t?ol(this.hsva.s+100*e.x,0,100):100*e.x,v:t?ol(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const kl=Symbol("same"),Sl=Symbol("color"),Cl=Symbol("hsva"),Tl=Symbol("update"),Ml=Symbol("parts"),El=Symbol("css"),Al=Symbol("sliders");class zl extends HTMLElement{static get observedAttributes(){return["color"]}get[El](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[Al](){return[$l,wl]}get color(){return this[Sl]}set color(e){if(!this[kl](e)){const t=this.colorModel.toHsva(e);this[Tl](t),this[Sl]=e}}constructor(){super();const e=fl(`<style>${this[El].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[Ml]=this[Al].map(e=>new e(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,i){const n=this.colorModel.fromAttr(i);this[kl](n)||(this.color=n)}handleEvent(e){const t=this[Cl],i={...t,...e.detail};let n;this[Tl](i),ul(i,t)||this[kl](n=this.colorModel.fromHsva(i))||(this[Sl]=n,vl(this,"color-changed",{value:n}))}[kl](e){return this.color&&this.colorModel.equal(e,this.color)}[Tl](e){this[Cl]=e,this[Ml].forEach(t=>t.update(e))}}const Il={defaultColor:"#000",toHsva:e=>hl(rl(e)),fromHsva:({h:e,s:t,v:i})=>pl(cl({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||ul(rl(e),rl(t)),fromAttr:e=>e};class Ol extends zl{get colorModel(){return Il}}class Pl extends Ol{}customElements.define("hex-color-picker",Pl);var _l=Object.freeze({__proto__:null,HexColorPicker:Pl});export{V as AgentNodeType,Hs as BORDER_COLOR_PRESETS,Xs as BaseCanvasElement,In as CHATBOT_TRIGGER_EVENTS,Y as CanvasMode,G as CanvasType,Fn as ChatbotPreviewComponent,Nn as ChatbotSizeSelectComponent,zn as ChatbotTriggerEvent,Dn as ChatbotVariantSelectComponent,j as DATA_NODE_SECTIONS,L as DATA_OPERATIONS,On as DEFAULT_CHATBOT_TRIGGER_CONFIG,D as DEFAULT_DATA_NODE_CONFIG,P as DataOperation,L as DataOperations,gn as DataSourceSelectComponent,H as DbDesignerNodeType,mn as EntitySelectComponent,K as ExecutionStatus,bn as ExpressionInputComponent,Vs as FILL_COLOR_PRESETS,R as FILTER_OPERATORS,Gs as FONT_FAMILY_OPTIONS,ce as FRAME_COLOR_PRESETS,ks as FRAME_DEFAULT_BG_COLOR,Ss as FRAME_DEFAULT_BORDER_COLOR,$s as FRAME_DEFAULT_HEIGHT,Cs as FRAME_DEFAULT_LABEL,Ms as FRAME_DEFAULT_LABEL_PLACEMENT,Ts as FRAME_DEFAULT_LABEL_POSITION,ws as FRAME_DEFAULT_WIDTH,Ln as FeatureToggleComponent,$n as FieldMapperComponent,yn as FieldMultiSelectComponent,xn as FieldSelectComponent,wn as FilterBuilderComponent,_ as FilterOperator,Bn as LoadingTypeSelectComponent,Ws as MERMAID_THEME_OPTIONS,ee as NODE_CATEGORIES,Q as NODE_COLORS,X as NODE_ICONS,Z as NODE_TEMPLATES,le as NOTE_COLOR_PRESETS,_s as NOTE_MIN_HEIGHT,Ps as NOTE_MIN_WIDTH,vn as OperationSelectComponent,ue as PERSISTENT_TRIGGER_TYPES,Us as PERSISTENT_TRIGGER_TYPE_NAMES,J as PortType,kn as SortBuilderComponent,jn as SuggestionListComponent,Ns as TABLE_DEFAULT_HEIGHT,Rs as TABLE_DEFAULT_WIDTH,Ls as TABLE_MIN_HEIGHT,Ds as TABLE_MIN_WIDTH,qs as TEXT_COLOR_PRESETS,Bs as TRIGGER_POLL_INTERVAL_MS,W as TriggerConnectionState,Rn as TriggerEventSelectComponent,js as VIEWPORT_ADD_NODE_OFFSET_X,Fs as VIEWPORT_ADD_NODE_OFFSET_Y,fn as VariableNameInputComponent,Os as WHITEBOARD_NODE_DEFAULT_SIZE,As as WORKFLOW_NODE_HEIGHT,Es as WORKFLOW_NODE_WIDTH,Is as WORKFLOW_NOTE_DEFAULT_HEIGHT,zs as WORKFLOW_NOTE_DEFAULT_WIDTH,el as WhiteboardCanvasElement,Qr as WhiteboardNodeElement,q as WhiteboardNodeType,Gr as WorkflowCanvasElement,dr as WorkflowNodeElement,U as WorkflowNodeType,An as chatbotTriggerFieldStyles,re as createNodeFromTemplate,hn as dataNodeFieldStyles,se as getCategoriesForCanvasType,te as getNodeTemplate,ie as isAgentNode,de as isAnnotationNode,ae as isDbDesignerNode,pe as isFrameNode,he as isNoteNode,be as isPersistentTriggerNode,oe as isWhiteboardNode,ne as isWorkflowNode,F as shouldShowSection,Pn as validateChatbotTriggerConfig,B as validateDataNodeConfig};
25935
+ var tl=function(e,t,i,n){return new(i||(i=Promise))(function(a,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function r(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const il="audio/ogg;codecs=opus";function nl(){try{return"undefined"!=typeof MediaRecorder&&MediaRecorder.isTypeSupported(il)}catch(e){return!1}}var al=Object.freeze({__proto__:null,canEncodeOgg:nl,compressToOpus:function(e,t){return tl(this,void 0,void 0,function*(){if(!nl()){const i=t.includes("mp4")?"mp4":t.includes("aac")?"aac":"webm";return{blob:e,mimeType:t,ext:i}}const i=yield e.arrayBuffer(),n=new AudioContext;let a;try{a=yield n.decodeAudioData(i)}finally{n.close().catch(()=>{})}const o=new AudioContext({sampleRate:a.sampleRate}),s=o.createMediaStreamDestination(),r=new MediaRecorder(s.stream,{mimeType:il,audioBitsPerSecond:32e3}),l=[];r.ondataavailable=e=>{e.data.size>0&&l.push(e.data)};const c=new Promise((e,t)=>{r.onstop=()=>e(),r.onerror=e=>{var i;return t(null!==(i=e.error)&&void 0!==i?i:new Error("MediaRecorder error"))}});r.start(100);const d=o.createBufferSource();return d.buffer=a,d.connect(s),d.onended=()=>{setTimeout(()=>{"recording"===r.state&&r.stop()},120)},d.start(0),yield c,o.close().catch(()=>{}),{blob:new Blob(l,{type:il}),mimeType:il,ext:"ogg"}})}});const ol=(e,t=0,i=1)=>e>i?i:e<t?t:e,sl=(e,t=0,i=Math.pow(10,t))=>Math.round(i*e)/i,rl=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?sl(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?sl(parseInt(e.substring(6,8),16)/255,2):1}),ll=e=>{const{h:t,s:i,l:n}=(({h:e,s:t,v:i,a:n})=>{const a=(200-t)*i/100;return{h:sl(e),s:sl(a>0&&a<200?t*i/100/(a<=100?a:200-a)*100:0),l:sl(a/2),a:sl(n,2)}})(e);return`hsl(${t}, ${i}%, ${n}%)`},cl=({h:e,s:t,v:i,a:n})=>{e=e/360*6,t/=100,i/=100;const a=Math.floor(e),o=i*(1-t),s=i*(1-(e-a)*t),r=i*(1-(1-e+a)*t),l=a%6;return{r:sl(255*[i,s,o,o,r,i][l]),g:sl(255*[r,i,i,s,o,o][l]),b:sl(255*[o,o,r,i,i,s][l]),a:sl(n,2)}},dl=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},pl=({r:e,g:t,b:i,a:n})=>{const a=n<1?dl(sl(255*n)):"";return"#"+dl(e)+dl(t)+dl(i)+a},hl=({r:e,g:t,b:i,a:n})=>{const a=Math.max(e,t,i),o=a-Math.min(e,t,i),s=o?a===e?(t-i)/o:a===t?2+(i-e)/o:4+(e-t)/o:0;return{h:sl(60*(s<0?s+6:s)),s:sl(a?o/a*100:0),v:sl(a/255*100),a:n}},ul=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},bl={},fl=e=>{let t=bl[e];return t||(t=document.createElement("template"),t.innerHTML=e,bl[e]=t),t},vl=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let gl=!1;const ml=e=>"touches"in e,yl=(e,t)=>{const i=ml(t)?t.touches[0]:t,n=e.el.getBoundingClientRect();vl(e.el,"move",e.getMove({x:ol((i.pageX-(n.left+window.pageXOffset))/n.width),y:ol((i.pageY-(n.top+window.pageYOffset))/n.height)}))};class xl{constructor(e,t,i,n){const a=fl(`<div role="slider" tabindex="0" part="${t}" ${i}><div part="${t}-pointer"></div></div>`);e.appendChild(a.content.cloneNode(!0));const o=e.querySelector(`[part=${t}]`);o.addEventListener("mousedown",this),o.addEventListener("touchstart",this),o.addEventListener("keydown",this),this.el=o,this.xy=n,this.nodes=[o.firstChild,o]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(gl?"touchmove":"mousemove",this),t(gl?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(gl&&!ml(e)||(gl||(gl=ml(e)),0)))(e)||!gl&&0!=e.button)return;this.el.focus(),yl(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),yl(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const i=t.keyCode;i>40||e.xy&&i<37||i<33||(t.preventDefault(),vl(e.el,"move",e.getMove({x:39===i?.01:37===i?-.01:34===i?.05:33===i?-.05:35===i?1:36===i?-1:0,y:40===i?.01:38===i?-.01:0},!0)))})(this,e)}}style(e){e.forEach((e,t)=>{for(const i in e)this.nodes[t].style.setProperty(i,e[i])})}}class wl extends xl{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:ll({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${sl(e)}`)}getMove(e,t){return{h:t?ol(this.h+360*e.x,0,360):360*e.x}}}class $l extends xl{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:ll(e)},{"background-color":ll({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${sl(e.s)}%, Brightness ${sl(e.v)}%`)}getMove(e,t){return{s:t?ol(this.hsva.s+100*e.x,0,100):100*e.x,v:t?ol(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const kl=Symbol("same"),Sl=Symbol("color"),Cl=Symbol("hsva"),Tl=Symbol("update"),Ml=Symbol("parts"),El=Symbol("css"),Al=Symbol("sliders");class zl extends HTMLElement{static get observedAttributes(){return["color"]}get[El](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[Al](){return[$l,wl]}get color(){return this[Sl]}set color(e){if(!this[kl](e)){const t=this.colorModel.toHsva(e);this[Tl](t),this[Sl]=e}}constructor(){super();const e=fl(`<style>${this[El].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[Ml]=this[Al].map(e=>new e(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,i){const n=this.colorModel.fromAttr(i);this[kl](n)||(this.color=n)}handleEvent(e){const t=this[Cl],i={...t,...e.detail};let n;this[Tl](i),ul(i,t)||this[kl](n=this.colorModel.fromHsva(i))||(this[Sl]=n,vl(this,"color-changed",{value:n}))}[kl](e){return this.color&&this.colorModel.equal(e,this.color)}[Tl](e){this[Cl]=e,this[Ml].forEach(t=>t.update(e))}}const Il={defaultColor:"#000",toHsva:e=>hl(rl(e)),fromHsva:({h:e,s:t,v:i})=>pl(cl({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||ul(rl(e),rl(t)),fromAttr:e=>e};class Ol extends zl{get colorModel(){return Il}}class Pl extends Ol{}customElements.define("hex-color-picker",Pl);var _l=Object.freeze({__proto__:null,HexColorPicker:Pl});export{V as AgentNodeType,Hs as BORDER_COLOR_PRESETS,Xs as BaseCanvasElement,In as CHATBOT_TRIGGER_EVENTS,Y as CanvasMode,G as CanvasType,Fn as ChatbotPreviewComponent,Nn as ChatbotSizeSelectComponent,zn as ChatbotTriggerEvent,Dn as ChatbotVariantSelectComponent,j as DATA_NODE_SECTIONS,L as DATA_OPERATIONS,On as DEFAULT_CHATBOT_TRIGGER_CONFIG,D as DEFAULT_DATA_NODE_CONFIG,P as DataOperation,L as DataOperations,gn as DataSourceSelectComponent,H as DbDesignerNodeType,mn as EntitySelectComponent,K as ExecutionStatus,bn as ExpressionInputComponent,Vs as FILL_COLOR_PRESETS,R as FILTER_OPERATORS,Gs as FONT_FAMILY_OPTIONS,ce as FRAME_COLOR_PRESETS,ks as FRAME_DEFAULT_BG_COLOR,Ss as FRAME_DEFAULT_BORDER_COLOR,$s as FRAME_DEFAULT_HEIGHT,Cs as FRAME_DEFAULT_LABEL,Ms as FRAME_DEFAULT_LABEL_PLACEMENT,Ts as FRAME_DEFAULT_LABEL_POSITION,ws as FRAME_DEFAULT_WIDTH,Ln as FeatureToggleComponent,$n as FieldMapperComponent,xn as FieldMultiSelectComponent,yn as FieldSelectComponent,wn as FilterBuilderComponent,_ as FilterOperator,Bn as LoadingTypeSelectComponent,Ws as MERMAID_THEME_OPTIONS,ee as NODE_CATEGORIES,Q as NODE_COLORS,X as NODE_ICONS,Z as NODE_TEMPLATES,le as NOTE_COLOR_PRESETS,_s as NOTE_MIN_HEIGHT,Ps as NOTE_MIN_WIDTH,vn as OperationSelectComponent,ue as PERSISTENT_TRIGGER_TYPES,Us as PERSISTENT_TRIGGER_TYPE_NAMES,J as PortType,kn as SortBuilderComponent,jn as SuggestionListComponent,Ns as TABLE_DEFAULT_HEIGHT,Rs as TABLE_DEFAULT_WIDTH,Ls as TABLE_MIN_HEIGHT,Ds as TABLE_MIN_WIDTH,qs as TEXT_COLOR_PRESETS,Bs as TRIGGER_POLL_INTERVAL_MS,W as TriggerConnectionState,Rn as TriggerEventSelectComponent,js as VIEWPORT_ADD_NODE_OFFSET_X,Fs as VIEWPORT_ADD_NODE_OFFSET_Y,fn as VariableNameInputComponent,Os as WHITEBOARD_NODE_DEFAULT_SIZE,As as WORKFLOW_NODE_HEIGHT,Es as WORKFLOW_NODE_WIDTH,Is as WORKFLOW_NOTE_DEFAULT_HEIGHT,zs as WORKFLOW_NOTE_DEFAULT_WIDTH,el as WhiteboardCanvasElement,Qr as WhiteboardNodeElement,q as WhiteboardNodeType,Gr as WorkflowCanvasElement,dr as WorkflowNodeElement,U as WorkflowNodeType,An as chatbotTriggerFieldStyles,re as createNodeFromTemplate,hn as dataNodeFieldStyles,se as getCategoriesForCanvasType,te as getNodeTemplate,ie as isAgentNode,de as isAnnotationNode,ae as isDbDesignerNode,pe as isFrameNode,he as isNoteNode,be as isPersistentTriggerNode,oe as isWhiteboardNode,ne as isWorkflowNode,F as shouldShowSection,Pn as validateChatbotTriggerConfig,B as validateDataNodeConfig};