@nuraly/lumenui 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nuralyui.bundle.js +121 -58
- package/dist/nuralyui.bundle.js.gz +0 -0
- package/dist/src/components/canvas/bundle.js +135 -61
- package/dist/src/components/canvas/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/bundle.js +103 -29
- package/dist/src/components/chatbot/bundle.js.gz +0 -0
- package/dist/src/components/chatbot/chatbot.component.d.ts +13 -0
- package/dist/src/components/chatbot/chatbot.component.js +50 -5
- package/dist/src/components/chatbot/chatbot.style.js +53 -0
- package/dist/src/components/chatbot/chatbot.types.d.ts +2 -0
- package/dist/src/components/chatbot/templates/chatbot-main.template.d.ts +2 -0
- package/dist/src/components/chatbot/templates/chatbot-main.template.js +1 -1
- package/dist/src/components/chatbot/templates/message.template.d.ts +3 -1
- package/dist/src/components/chatbot/templates/message.template.js +45 -12
- package/package.json +1 -1
|
@@ -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
|
|
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`
|
|
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}},
|
|
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;
|
|
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(!
|
|
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`
|
|
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,yt
|
|
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`
|
|
1026
1026
|
:host {
|
|
1027
1027
|
display: block;
|
|
1028
1028
|
width: 100%;
|
|
@@ -1443,6 +1443,11 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1443
1443
|
justify-content: flex-start; /* Always align messages to top */
|
|
1444
1444
|
}
|
|
1445
1445
|
|
|
1446
|
+
.messages--inverted {
|
|
1447
|
+
flex-direction: column-reverse;
|
|
1448
|
+
justify-content: flex-start;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1446
1451
|
.empty-state {
|
|
1447
1452
|
display: flex;
|
|
1448
1453
|
flex-direction: column;
|
|
@@ -1583,6 +1588,54 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
1583
1588
|
box-shadow: none;
|
|
1584
1589
|
}
|
|
1585
1590
|
|
|
1591
|
+
.message__text-collapsible {
|
|
1592
|
+
position: relative;
|
|
1593
|
+
max-height: var(--chatbot-message-collapsed-height, 200px);
|
|
1594
|
+
overflow: hidden;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
.message__text-collapsible--expanded {
|
|
1598
|
+
max-height: none;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
.message__text-collapsible:not(.message__text-collapsible--expanded)::after {
|
|
1602
|
+
content: '';
|
|
1603
|
+
position: absolute;
|
|
1604
|
+
inset: auto 0 0 0;
|
|
1605
|
+
height: 48px;
|
|
1606
|
+
pointer-events: none;
|
|
1607
|
+
background: linear-gradient(
|
|
1608
|
+
to bottom,
|
|
1609
|
+
transparent,
|
|
1610
|
+
var(--nuraly-color-user-bubble-bg, rgb(124, 58, 237))
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
.message__show-more-toggle {
|
|
1615
|
+
margin-top: 6px;
|
|
1616
|
+
background: transparent;
|
|
1617
|
+
border: 0;
|
|
1618
|
+
padding: 4px 0;
|
|
1619
|
+
font: inherit;
|
|
1620
|
+
font-size: 12px;
|
|
1621
|
+
font-weight: 500;
|
|
1622
|
+
color: inherit;
|
|
1623
|
+
opacity: 0.85;
|
|
1624
|
+
cursor: pointer;
|
|
1625
|
+
text-decoration: underline;
|
|
1626
|
+
text-underline-offset: 2px;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
.message__show-more-toggle:hover {
|
|
1630
|
+
opacity: 1;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
.message__show-more-toggle:focus-visible {
|
|
1634
|
+
outline: 1px solid currentColor;
|
|
1635
|
+
outline-offset: 2px;
|
|
1636
|
+
border-radius: 2px;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1586
1639
|
.message.bot .message__content {
|
|
1587
1640
|
background-color: var(--nuraly-color-bot-bubble-bg, transparent);
|
|
1588
1641
|
color: var(--nuraly-color-bot-bubble-fg, inherit);
|
|
@@ -2935,15 +2988,7 @@ class lt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._re
|
|
|
2935
2988
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
2936
2989
|
* SPDX-License-Identifier: MIT
|
|
2937
2990
|
*/
|
|
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
|
|
2939
|
-
<div
|
|
2940
|
-
class="message ${h(v)}"
|
|
2941
|
-
part=${`message message-${g}`}
|
|
2942
|
-
data-sender="${e.sender}"
|
|
2943
|
-
data-id="${e.id}"
|
|
2944
|
-
>
|
|
2945
|
-
<div class="message__content" part=${`message-content message-content-${g}`}>
|
|
2946
|
-
${f?
|
|
2991
|
+
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;const p=null===(o=e.text)||void 0===o?void 0:o.includes("[ERROR_START]"),b={error:!!e.error||p,introduction:!!e.introduction,[e.sender]:!0},f=e.sender,v=null!==(r=null===(s=e.text)||void 0===s?void 0:s.trim())&&void 0!==r?r:"",g=null!==(l=t.collapseThreshold)&&void 0!==l?l:0,m="user"===f&&!p&&g>0&&v.length>g,x=!m||!!(null===(c=t.isExpanded)||void 0===c?void 0:c.call(t,e.id)),y=p?
|
|
2947
2992
|
/**
|
|
2948
2993
|
* @license
|
|
2949
2994
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -2954,7 +2999,29 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
|
|
|
2954
2999
|
${e?i`<div class="message__error-title" part="message-error-title">${e}</div>`:""}
|
|
2955
3000
|
<div class="message__error-description" part="message-error-description">${n}</div>
|
|
2956
3001
|
</div>
|
|
2957
|
-
`}return i`${e}`}(
|
|
3002
|
+
`}return i`${e}`}(v):(null===(d=null==e?void 0:e.metadata)||void 0===d?void 0:d.renderAsHtml)?u(v):u(v.replaceAll("\n","<br>"));return i`
|
|
3003
|
+
<div
|
|
3004
|
+
class="message ${h(b)}"
|
|
3005
|
+
part=${`message message-${f}`}
|
|
3006
|
+
data-sender="${e.sender}"
|
|
3007
|
+
data-id="${e.id}"
|
|
3008
|
+
>
|
|
3009
|
+
<div class="message__content" part=${`message-content message-content-${f}`}>
|
|
3010
|
+
${m?i`
|
|
3011
|
+
<div
|
|
3012
|
+
class="message__text-collapsible ${x?"message__text-collapsible--expanded":""}"
|
|
3013
|
+
part="message-text-collapsible"
|
|
3014
|
+
>
|
|
3015
|
+
<div class="message__text-inner">${y}</div>
|
|
3016
|
+
</div>
|
|
3017
|
+
<button
|
|
3018
|
+
class="message__show-more-toggle"
|
|
3019
|
+
part="message-show-more"
|
|
3020
|
+
type="button"
|
|
3021
|
+
data-message-toggle="${e.id}"
|
|
3022
|
+
aria-expanded="${x?"true":"false"}"
|
|
3023
|
+
>${x?a.messages.showLessLabel:a.messages.showMoreLabel}</button>
|
|
3024
|
+
`:y}
|
|
2958
3025
|
</div>
|
|
2959
3026
|
${e.files&&e.files.length>0?i`
|
|
2960
3027
|
<div class="message__attachments" part="message-attachments" role="list" aria-label="${a.messages.attachedFilesLabel}">
|
|
@@ -3040,9 +3107,7 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
|
|
|
3040
3107
|
${a.messages.retryButton}
|
|
3041
3108
|
</nr-button>`:n}
|
|
3042
3109
|
</div>
|
|
3043
|
-
`}function jt(e,t,a,o,s,r,l){return i`
|
|
3044
|
-
<div class="messages" part="messages">
|
|
3045
|
-
${0===e.length?l?function(e){return i`
|
|
3110
|
+
`}function jt(e,t,a,o,s,r,l,c){const d=0===e.length?l?function(e){return i`
|
|
3046
3111
|
<div class="empty-state empty-state--loading" part="empty-state thread-loading">
|
|
3047
3112
|
<slot name="thread-loading">
|
|
3048
3113
|
<div class="spinner" part="thread-loading-spinner"></div>
|
|
@@ -3059,8 +3124,17 @@ function(e){const t=e.match(/\[ERROR_START\]\[ERROR_TITLE_START\]([\s\S]*?)\[ERR
|
|
|
3059
3124
|
</div>
|
|
3060
3125
|
</slot>
|
|
3061
3126
|
</div>
|
|
3062
|
-
`}(s,r):n
|
|
3063
|
-
|
|
3127
|
+
`}(s,r):n,p=e=>Lt(e,o,s);if(c){const n=[...e].reverse();return i`
|
|
3128
|
+
<div class="messages messages--inverted" part="messages">
|
|
3129
|
+
${a}
|
|
3130
|
+
${t}
|
|
3131
|
+
${b(n,e=>e.id,p)}
|
|
3132
|
+
${d}
|
|
3133
|
+
</div>
|
|
3134
|
+
`}return i`
|
|
3135
|
+
<div class="messages" part="messages">
|
|
3136
|
+
${d}
|
|
3137
|
+
${b(e,e=>e.id,p)}
|
|
3064
3138
|
${t}
|
|
3065
3139
|
${a}
|
|
3066
3140
|
</div>
|
|
@@ -3523,7 +3597,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
3523
3597
|
${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}
|
|
3524
3598
|
</div>
|
|
3525
3599
|
</div>
|
|
3526
|
-
`}(e.isTyping,e.loadingIndicator||Mt.Spinner,e.loadingText):n,t.message,e.i18n,e.welcomeMessage,e.isPendingThread)}
|
|
3600
|
+
`}(e.isTyping,e.loadingIndicator||Mt.Spinner,e.loadingText):n,t.message,e.i18n,e.welcomeMessage,e.isPendingThread,e.invertedScroll)}
|
|
3527
3601
|
<slot name="messages"></slot>
|
|
3528
3602
|
</div>
|
|
3529
3603
|
`:e.suggestions&&e.suggestions.length>0?i`
|
|
@@ -3730,7 +3804,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
3730
3804
|
* @license
|
|
3731
3805
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
3732
3806
|
* SPDX-License-Identifier: MIT
|
|
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`
|
|
3807
|
+
*/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…"),showMoreLabel:at("Show more"),showLessLabel:at("Show less")},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._expandedMessageIds=new Set,this.messageCollapseThreshold=600,this.invertedScroll=!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,a;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("click",e=>{var t,i;const n=null===(i=(t=e.target).closest)||void 0===i?void 0:i.call(t,"[data-message-toggle]");if(n){const e=n.dataset.messageToggle;if(e){const t=new Set(this._expandedMessageIds);t.has(e)?t.delete(e):t.add(e),this._expandedMessageIds=t}}}),null===(a=this.shadowRoot)||void 0===a||a.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.invertedScroll&&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,invertedScroll:this.invertedScroll,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),collapseThreshold:this.messageCollapseThreshold,isExpanded:e=>this._expandedMessageIds.has(e)},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`
|
|
3734
3808
|
<div
|
|
3735
3809
|
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})}"
|
|
3736
3810
|
dir=${this.isRTL?"rtl":"ltr"}
|
|
@@ -3753,7 +3827,7 @@ function(e){if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(102
|
|
|
3753
3827
|
<span class="module-display-multiple">
|
|
3754
3828
|
${e} ${this.resolvedI18n.modules.modulesSelectedSuffix}
|
|
3755
3829
|
</span>
|
|
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);
|
|
3830
|
+
`}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),Xt([r()],ti.prototype,"_expandedMessageIds",void 0),Xt([s({type:Number,attribute:"message-collapse-threshold"})],ti.prototype,"messageCollapseThreshold",void 0),Xt([s({type:Boolean,attribute:"inverted-scroll",reflect:!0})],ti.prototype,"invertedScroll",void 0),ti=Xt([(e,t)=>(e.addInitializer(rt),e),l("nr-chatbot")],ti);
|
|
3757
3831
|
/**
|
|
3758
3832
|
* @license
|
|
3759
3833
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
@@ -3814,13 +3888,13 @@ class ii{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(
|
|
|
3814
3888
|
* @license
|
|
3815
3889
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
3816
3890
|
* SPDX-License-Identifier: MIT
|
|
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
|
|
3891
|
+
*/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}();
|
|
3818
3892
|
/**
|
|
3819
3893
|
* @license
|
|
3820
3894
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
3821
3895
|
* SPDX-License-Identifier: MIT
|
|
3822
3896
|
*/
|
|
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)}}
|
|
3897
|
+
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)}}
|
|
3824
3898
|
/**
|
|
3825
3899
|
* @license
|
|
3826
3900
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
@@ -5263,7 +5337,7 @@ const hn=e`
|
|
|
5263
5337
|
></nr-select>
|
|
5264
5338
|
${this.description?i`<span class="field-description">${this.description}</span>`:n}
|
|
5265
5339
|
</div>
|
|
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
|
|
5340
|
+
`}};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`
|
|
5267
5341
|
<nr-select
|
|
5268
5342
|
.value=${this.value||""}
|
|
5269
5343
|
.options=${e}
|
|
@@ -5272,7 +5346,7 @@ const hn=e`
|
|
|
5272
5346
|
size="small"
|
|
5273
5347
|
@nr-change=${this.handleChange}
|
|
5274
5348
|
></nr-select>
|
|
5275
|
-
`}};
|
|
5349
|
+
`}};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`
|
|
5276
5350
|
<div class="field-container">
|
|
5277
5351
|
${this.label?i`<label class="field-label">${this.label}</label>`:n}
|
|
5278
5352
|
<nr-select
|
|
@@ -5287,7 +5361,7 @@ const hn=e`
|
|
|
5287
5361
|
></nr-select>
|
|
5288
5362
|
${this.description?i`<span class="field-description">${this.description}</span>`:n}
|
|
5289
5363
|
</div>
|
|
5290
|
-
`}};
|
|
5364
|
+
`}};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`
|
|
5291
5365
|
<div class="filter-condition">
|
|
5292
5366
|
<nr-select
|
|
5293
5367
|
.value=${e.field}
|
|
@@ -7819,7 +7893,7 @@ function ga(e,t){const a=e.checks||[],o=e=>{const i={type:e,action:"block"};"pii
|
|
|
7819
7893
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
7820
7894
|
* SPDX-License-Identifier: MIT
|
|
7821
7895
|
*/
|
|
7822
|
-
const
|
|
7896
|
+
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"}];
|
|
7823
7897
|
/**
|
|
7824
7898
|
* @license
|
|
7825
7899
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
@@ -8436,7 +8510,7 @@ const vo=[{value:"invitee.created",label:"Invitee Created (meeting booked)"},{va
|
|
|
8436
8510
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
8437
8511
|
* SPDX-License-Identifier: MIT
|
|
8438
8512
|
*/
|
|
8439
|
-
const mo=[{value:"none",label:"None — No acknowledgment"},{value:"leader",label:"Leader — Leader broker only"},{value:"all",label:"All — All in-sync replicas"}],
|
|
8513
|
+
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`
|
|
8440
8514
|
<div class="trigger-stats-row">
|
|
8441
8515
|
<span class="trigger-stat">
|
|
8442
8516
|
<nr-icon name="message-square" size="small"></nr-icon>
|
|
@@ -8470,7 +8544,7 @@ const mo=[{value:"none",label:"None — No acknowledgment"},{value:"leader",labe
|
|
|
8470
8544
|
<div class="trigger-status-reason">${e.stateReason}</div>
|
|
8471
8545
|
`:n}
|
|
8472
8546
|
|
|
8473
|
-
${c&&e?
|
|
8547
|
+
${c&&e?yo(e):n}
|
|
8474
8548
|
|
|
8475
8549
|
${(null==e?void 0:e.inDevMode)?i`
|
|
8476
8550
|
<div class="trigger-dev-mode-badge">
|
|
@@ -9262,12 +9336,12 @@ var os=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.
|
|
|
9262
9336
|
<div class="editor-container ${e?"dark":"light"}" part="editor-container">
|
|
9263
9337
|
<div class="line-numbers-gutter" style="display: ${this.lineNumbers?"block":"none"}"></div>
|
|
9264
9338
|
<code
|
|
9265
|
-
${
|
|
9339
|
+
${x(this.editorRef)}
|
|
9266
9340
|
class="editor language-${this.language}"
|
|
9267
9341
|
style="font-size: ${this.fontSize}px; tab-size: ${this.tabSize}; white-space: ${this.wordWrap?"pre-wrap":"pre"};"
|
|
9268
9342
|
></code>
|
|
9269
9343
|
</div>
|
|
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=
|
|
9344
|
+
`}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,"&").replace(/</g,"<").replace(/>/g,">")}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);
|
|
9271
9345
|
/**
|
|
9272
9346
|
* @license
|
|
9273
9347
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
@@ -12543,7 +12617,7 @@ return function(e,t){return i`
|
|
|
12543
12617
|
value=${e.resource||"ORDER"}
|
|
12544
12618
|
@nr-change=${e=>t("resource",e.detail.value)}
|
|
12545
12619
|
>
|
|
12546
|
-
${
|
|
12620
|
+
${xa.map(e=>i`
|
|
12547
12621
|
<nr-option value=${e.value}>${e.label}</nr-option>
|
|
12548
12622
|
`)}
|
|
12549
12623
|
</nr-select>
|
|
@@ -12554,7 +12628,7 @@ return function(e,t){return i`
|
|
|
12554
12628
|
value=${r}
|
|
12555
12629
|
@nr-change=${e=>t("operation",e.detail.value)}
|
|
12556
12630
|
>
|
|
12557
|
-
${
|
|
12631
|
+
${ya.map(e=>i`
|
|
12558
12632
|
<nr-option value=${e.value}>${e.label}</nr-option>
|
|
12559
12633
|
`)}
|
|
12560
12634
|
</nr-select>
|
|
@@ -14468,7 +14542,7 @@ return function(e,t){return i`
|
|
|
14468
14542
|
<label>Compression</label>
|
|
14469
14543
|
<nr-select
|
|
14470
14544
|
.value=${e.kafkaCompressionType||"none"}
|
|
14471
|
-
.options=${
|
|
14545
|
+
.options=${xo}
|
|
14472
14546
|
@nr-change=${e=>t("kafkaCompressionType",e.detail.value)}
|
|
14473
14547
|
></nr-select>
|
|
14474
14548
|
<span class="field-description">Compression codec for message batches</span>
|
|
@@ -14916,7 +14990,7 @@ return function(e,t){return i`
|
|
|
14916
14990
|
<span class="field-description">Variable name to store the HubSpot API response for downstream nodes</span>
|
|
14917
14991
|
</div>
|
|
14918
14992
|
</div>
|
|
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,
|
|
14993
|
+
`}(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`
|
|
14920
14994
|
<div class="config-section">
|
|
14921
14995
|
<div class="config-section-header">
|
|
14922
14996
|
<span class="config-section-title">Connection</span>
|
|
@@ -14935,7 +15009,7 @@ return function(e,t){return i`
|
|
|
14935
15009
|
<label>Credentials</label>
|
|
14936
15010
|
<nr-kv-secret-select
|
|
14937
15011
|
.provider=${"jira"}
|
|
14938
|
-
.entries=${
|
|
15012
|
+
.entries=${y}
|
|
14939
15013
|
.value=${e.credentialPath||""}
|
|
14940
15014
|
placeholder="Select Jira credentials..."
|
|
14941
15015
|
@value-change=${e=>t("credentialPath",e.detail.value)}
|
|
@@ -15268,7 +15342,7 @@ return function(e,t){return i`
|
|
|
15268
15342
|
</div>
|
|
15269
15343
|
`:n}
|
|
15270
15344
|
|
|
15271
|
-
${
|
|
15345
|
+
${x?i`
|
|
15272
15346
|
<div class="config-section">
|
|
15273
15347
|
<div class="config-section-header">
|
|
15274
15348
|
<span class="config-section-title">Pagination</span>
|
|
@@ -16565,7 +16639,7 @@ return function(e,t){const a="string"==typeof e.workflowId?e.workflowId:"",o="st
|
|
|
16565
16639
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
16566
16640
|
* SPDX-License-Identifier: MIT
|
|
16567
16641
|
*/
|
|
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
|
|
16642
|
+
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;
|
|
16569
16643
|
/**
|
|
16570
16644
|
* @license
|
|
16571
16645
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
@@ -16576,15 +16650,15 @@ const us={[U.LOOP]:{title:"How the Loop node works",description:'Iterates over t
|
|
|
16576
16650
|
<div class="config-panel-title">
|
|
16577
16651
|
<div
|
|
16578
16652
|
class="config-panel-icon"
|
|
16579
|
-
style="background: ${(null==
|
|
16653
|
+
style="background: ${(null==x?void 0:x.color)||"#3b82f6"}"
|
|
16580
16654
|
>
|
|
16581
|
-
<nr-icon name=${(null==
|
|
16655
|
+
<nr-icon name=${(null==x?void 0:x.icon)||"box"} size="small"></nr-icon>
|
|
16582
16656
|
</div>
|
|
16583
16657
|
<nr-label size="medium">${t.name}</nr-label>
|
|
16584
|
-
${
|
|
16658
|
+
${y?i`
|
|
16585
16659
|
<nr-popconfirm
|
|
16586
|
-
title=${
|
|
16587
|
-
description=${
|
|
16660
|
+
title=${y.title}
|
|
16661
|
+
description=${y.description}
|
|
16588
16662
|
icon="question-circle"
|
|
16589
16663
|
ok-text="Got it"
|
|
16590
16664
|
?show-cancel=${!1}
|
|
@@ -16774,7 +16848,7 @@ function(e,t){var n;return i`
|
|
|
16774
16848
|
* @license
|
|
16775
16849
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
16776
16850
|
* SPDX-License-Identifier: MIT
|
|
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,
|
|
16851
|
+
*/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`
|
|
16778
16852
|
<g class="edge-group" data-edge-id=${e.id}>
|
|
16779
16853
|
<!-- Invisible wider path for easier clicking -->
|
|
16780
16854
|
<path
|
|
@@ -16792,13 +16866,13 @@ function(e,t){var n;return i`
|
|
|
16792
16866
|
class="edge-path"
|
|
16793
16867
|
d=${v}
|
|
16794
16868
|
fill="none"
|
|
16795
|
-
style="pointer-events: none; stroke: ${
|
|
16869
|
+
style="pointer-events: none; stroke: ${y}; stroke-width: ${w}px; transition: stroke 0.15s ease, stroke-width 0.15s ease;"
|
|
16796
16870
|
/>
|
|
16797
16871
|
<polygon
|
|
16798
16872
|
class="edge-arrow"
|
|
16799
16873
|
points="${k+6},${S} ${k-6},${S-4} ${k-6},${S+4}"
|
|
16800
16874
|
transform="rotate(${E}, ${k}, ${S})"
|
|
16801
|
-
style="pointer-events: none; fill: ${
|
|
16875
|
+
style="pointer-events: none; fill: ${y}; transition: fill 0.15s ease;"
|
|
16802
16876
|
/>
|
|
16803
16877
|
${e.label?o`
|
|
16804
16878
|
<text
|
|
@@ -16818,13 +16892,13 @@ function(e,t){var n;return i`
|
|
|
16818
16892
|
* @license
|
|
16819
16893
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
16820
16894
|
* SPDX-License-Identifier: MIT
|
|
16821
|
-
*/const
|
|
16895
|
+
*/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"}];
|
|
16822
16896
|
/**
|
|
16823
16897
|
* @license
|
|
16824
16898
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
16825
16899
|
* SPDX-License-Identifier: MIT
|
|
16826
16900
|
*/
|
|
16827
|
-
function
|
|
16901
|
+
function ys(e){e.stopPropagation()}
|
|
16828
16902
|
/**
|
|
16829
16903
|
* @license
|
|
16830
16904
|
* Copyright 2024 Nuraly, Laabidi Aymen
|
|
@@ -17229,9 +17303,9 @@ function(e){const{cursors:t,viewport:a,localUserId:o}=e,s=t.filter(e=>e.userId!=
|
|
|
17229
17303
|
`}({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`
|
|
17230
17304
|
<div class="chatbot-panel"
|
|
17231
17305
|
data-theme=${e.currentTheme}
|
|
17232
|
-
@mousedown=${
|
|
17233
|
-
@touchstart=${
|
|
17234
|
-
@pointerdown=${
|
|
17306
|
+
@mousedown=${ys}
|
|
17307
|
+
@touchstart=${ys}
|
|
17308
|
+
@pointerdown=${ys}
|
|
17235
17309
|
>
|
|
17236
17310
|
<div class="chatbot-panel-header">
|
|
17237
17311
|
<span class="chatbot-panel-title">
|
|
@@ -23091,7 +23165,7 @@ const pr=e`
|
|
|
23091
23165
|
:host([size="large"]) .radio-label { font-size: 16px; }
|
|
23092
23166
|
|
|
23093
23167
|
:host([disabled]) .radio-label { color: #bfbfbf; }
|
|
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`
|
|
23168
|
+
`;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`
|
|
23095
23169
|
<div class="search-container">
|
|
23096
23170
|
<nr-input
|
|
23097
23171
|
type="text"
|
|
@@ -23128,7 +23202,7 @@ const pr=e`
|
|
|
23128
23202
|
* @license
|
|
23129
23203
|
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
23130
23204
|
* SPDX-License-Identifier: MIT
|
|
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=
|
|
23205
|
+
*/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`
|
|
23132
23206
|
<slot name="label"></slot>
|
|
23133
23207
|
<div
|
|
23134
23208
|
class="${h(Object.assign({wrapper:!0},t))}"
|
|
@@ -23227,7 +23301,7 @@ const pr=e`
|
|
|
23227
23301
|
aria-label="Remove ${e.label}"
|
|
23228
23302
|
></nr-icon>
|
|
23229
23303
|
</span>
|
|
23230
|
-
`):i`${e[0].label}`}renderStatusIcon(){switch(this.status){case
|
|
23304
|
+
`):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`
|
|
23231
23305
|
<nr-icon
|
|
23232
23306
|
part="clear"
|
|
23233
23307
|
name="x"
|
|
@@ -24695,13 +24769,13 @@ var Kr,Jr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Obje
|
|
|
24695
24769
|
${this.remoteTyping.username} is typing...
|
|
24696
24770
|
</div>
|
|
24697
24771
|
`:n}
|
|
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
|
|
24772
|
+
`}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`
|
|
24699
24773
|
<div class="remote-overlay-wrapper" style="position: relative;">
|
|
24700
|
-
${
|
|
24774
|
+
${x}
|
|
24701
24775
|
${this.renderRemoteOverlays()}
|
|
24702
24776
|
</div>
|
|
24703
|
-
${
|
|
24704
|
-
`:
|
|
24777
|
+
${y?this.renderActionIndicator():n}
|
|
24778
|
+
`: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`
|
|
24705
24779
|
:host {
|
|
24706
24780
|
display: block;
|
|
24707
24781
|
width: 100%;
|
|
@@ -25777,7 +25851,7 @@ var Zr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.
|
|
|
25777
25851
|
</button>
|
|
25778
25852
|
${e.shapesFlyoutOpen?i`
|
|
25779
25853
|
<div class="wb-shapes-flyout">
|
|
25780
|
-
${
|
|
25854
|
+
${xs.map(t=>i`
|
|
25781
25855
|
<button
|
|
25782
25856
|
class="wb-shapes-flyout-btn"
|
|
25783
25857
|
@click=${()=>e.onAddNode(t.type)}
|
|
@@ -25932,4 +26006,4 @@ var Zr=function(e,t,i,n){for(var a,o=arguments.length,s=o<3?t:null===n?n=Object.
|
|
|
25932
26006
|
* input blob → AudioContext.decodeAudioData → BufferSource → MediaStreamDestination
|
|
25933
26007
|
* → MediaRecorder(ogg/opus, 32 kbps) → output blob
|
|
25934
26008
|
*/
|
|
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};
|
|
26009
|
+
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};
|