@aquera/nile-elements 1.5.8 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +6 -0
  2. package/dist/index.js +85 -46
  3. package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
  4. package/dist/nile-dropdown/nile-dropdown.cjs.js.map +1 -1
  5. package/dist/nile-dropdown/nile-dropdown.esm.js +1 -1
  6. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
  7. package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
  8. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
  9. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
  10. package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +24 -0
  11. package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
  12. package/dist/nile-rich-text-editor/nile-rte-link.cjs.js +1 -1
  13. package/dist/nile-rich-text-editor/nile-rte-link.cjs.js.map +1 -1
  14. package/dist/nile-rich-text-editor/nile-rte-link.esm.js +59 -44
  15. package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js +1 -1
  16. package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js.map +1 -1
  17. package/dist/nile-rich-text-editor/utils/inline-utils.esm.js +1 -1
  18. package/dist/src/nile-dropdown/nile-dropdown.js +4 -2
  19. package/dist/src/nile-dropdown/nile-dropdown.js.map +1 -1
  20. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +24 -0
  21. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
  22. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +6 -0
  23. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +62 -24
  24. package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
  25. package/dist/src/nile-rich-text-editor/nile-rte-link.d.ts +12 -0
  26. package/dist/src/nile-rich-text-editor/nile-rte-link.js +239 -130
  27. package/dist/src/nile-rich-text-editor/nile-rte-link.js.map +1 -1
  28. package/dist/src/nile-rich-text-editor/nile-rte-link.test.d.ts +1 -0
  29. package/dist/src/nile-rich-text-editor/nile-rte-link.test.js +469 -0
  30. package/dist/src/nile-rich-text-editor/nile-rte-link.test.js.map +1 -0
  31. package/dist/src/nile-rich-text-editor/utils/inline-utils.js +13 -4
  32. package/dist/src/nile-rich-text-editor/utils/inline-utils.js.map +1 -1
  33. package/dist/src/version.js +1 -1
  34. package/dist/src/version.js.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
  37. package/src/nile-dropdown/nile-dropdown.ts +5 -3
  38. package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +24 -0
  39. package/src/nile-rich-text-editor/nile-rich-text-editor.ts +66 -26
  40. package/src/nile-rich-text-editor/nile-rte-link.test.ts +682 -0
  41. package/src/nile-rich-text-editor/nile-rte-link.ts +195 -100
  42. package/src/nile-rich-text-editor/utils/inline-utils.ts +11 -4
  43. package/vscode-html-custom-data.json +16 -2
package/README.md CHANGED
@@ -79,6 +79,12 @@ To run a local development server that serves the basic demo located in `demo/in
79
79
 
80
80
  In this section, you can find the updates for each release of `nile-elements`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
81
81
 
82
+ #### Version 1.6.0 (March 06, 2026)
83
+ - Nile Rich Text Editor: Added New Link Feature (UIF-1131)
84
+
85
+ #### Version 1.5.9 (March 05, 2026)
86
+ - Nile Dropdown: Preserve trigger disabled state (UIF-1129)
87
+
82
88
  #### Version 1.5.8 (March 03, 2026)
83
89
  - Nile Icon: Publishing NxtGen Icons ng-building-07, ng-clock-refresh, ng-dataflow-02, ng-folder-code, ng-lightbulb-05, ng-number, ng-boolean, ng-string (UIF-1125)(UIF-1128)
84
90
  - Nile Grid: Prevent scroll lock in Nile Grid when rows are limited (UIF-1126)
package/dist/index.js CHANGED
@@ -5915,7 +5915,7 @@ class bM{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
5915
5915
  max-width: var(--auto-size-available-width) !important;
5916
5916
  max-height: var(--auto-size-available-height) !important;
5917
5917
  }
5918
- `;let rn=class{static calculateAvailableSpace(e){const t=e.getBoundingClientRect(),i=window.innerHeight,M=window.innerWidth,n=i-t.bottom,o=t.top,r=M-t.right;return{spaceAbove:o,spaceBelow:n,spaceLeft:t.left,spaceRight:r,viewportHeight:i,viewportWidth:M}}static getOptimalPlacement(e){const{spaceAbove:t,spaceBelow:i,spaceLeft:M,spaceRight:n}=this.calculateAvailableSpace(e);return i>=200&&i>=t?"bottom":t>=200&&t>i?"top":n>=200&&n>=M?"right":M>=200?"left":"bottom"}static findBoundaryElements(e){const t=[];let i=e.parentElement;for(;i&&i!==document.body;){const e=window.getComputedStyle(i),M=e.overflow,n=e.overflowY,o=e.overflowX;"auto"!==M&&"scroll"!==M&&"auto"!==n&&"scroll"!==n&&"auto"!==o&&"scroll"!==o||t.push(i),(i.hasAttribute("data-floating-boundary")||i.classList.contains("floating-boundary")||i.classList.contains("scroll-container"))&&t.push(i),i=i.parentElement}return t.length>0?t:void 0}static calculateOptimalHeight(e,t,i){const M=t-(e.y+e.height),n=e.y;return i.startsWith("top")?Math.max(n-20,100):i.startsWith("bottom")?Math.max(M-20,100):(i.startsWith("left")||i.startsWith("right"),Math.max(Math.min(n,M)-20,100))}static extractStylesAsCSS(e){return"string"==typeof e?e:Array.isArray(e)?e.map((e=>this.extractStylesAsCSS(e))).join("\n"):e&&"object"==typeof e&&e.cssText?e.cssText:""}static generateStyleId(){return`nile-dropdown-styles-${Math.random().toString(36).substring(2,11)}`}static isPositioningOptimal(e,t){const{spaceAbove:i,spaceBelow:M,spaceLeft:n,spaceRight:o}=this.calculateAvailableSpace(t),r=e.startsWith("top"),s=e.startsWith("bottom"),a=e.startsWith("left"),l=e.startsWith("right");return!(r&&M>i)&&(!(s&&i>M)&&(!(a&&o>n)&&!(l&&n>o)))}static applyCollisionData(e,t,i){if(t.flip){const{overflows:M}=t.flip;if(e.setAttribute("data-placement",i),M&&M.length>0){const t=M.map((e=>e.placement)).join(",");e.setAttribute("data-overflow",t)}else e.removeAttribute("data-overflow")}if(t.shift){const{x:i,y:M}=t.shift;void 0===i||void 0===M||0===i&&0===M?e.removeAttribute("data-shift"):e.setAttribute("data-shift",`${i},${M}`)}if(t.size){const{availableWidth:i,availableHeight:M}=t.size;void 0!==i&&e.setAttribute("data-available-width",i.toString()),void 0!==M&&e.setAttribute("data-available-height",M.toString())}}},sn=class{static createPortalPanel(e){const t=e.shadowRoot?.querySelector(".dropdown__panel");if(!t){const t=e.querySelector("[slot]");if(!t||"trigger"===t.getAttribute("slot"))return document.createElement("div")}let i=t?.assignedElements({flatten:!0})||[];if(0===i.length){i=Array.from(e.children).filter((e=>{const t=e.getAttribute("slot");return!t||"trigger"!==t}))}const M=document.createElement("div");return M.className="dropdown__panel",M.setAttribute("part","panel"),M.setAttribute("aria-hidden","false"),M.setAttribute("aria-labelledby","dropdown"),i.forEach((e=>{const t=e.cloneNode(!0);this.processInlineEventHandlers(t),M.appendChild(t)})),M}static updatePortalPanel(e,t){if(!e)return;e.innerHTML="";const i=t.shadowRoot?.querySelector(".dropdown__panel");let M=i?.assignedElements({flatten:!0})||[];if(0===M.length){M=Array.from(t.children).filter((e=>{const t=e.getAttribute("slot");return!t||"trigger"!==t}))}M.forEach((t=>{const i=t.cloneNode(!0);this.processInlineEventHandlers(i),e.appendChild(i)}))}static processInlineEventHandlers(e){["onclick","onchange","oninput","onsubmit","onfocus","onblur","onkeydown","onkeyup"].forEach((t=>{e.removeAttribute(t),e.querySelectorAll(`[${t}]`).forEach((e=>{e.removeAttribute(t)}))}))}},an=class{static setupPortalEventListeners(e,t){e&&(this.setupMenuSelectListeners(e,t),this.setupKeyDownListeners(e,t),this.setupEventForwarding(e,t))}static setupMenuSelectListeners(e,t){e&&e.addEventListener("nile-select",(e=>{const i=e;t.handlePanelSelect&&t.handlePanelSelect(i)}))}static setupKeyDownListeners(e,t){e&&e.addEventListener("keydown",(e=>{t.handleKeyDown&&t.handleKeyDown(e)}))}static setupEventForwarding(e,t){if(!e)return;const i=t.shadowRoot?.querySelector(".dropdown__panel");if(!i)return;let M=i.assignedElements({flatten:!0})||[];if(0===M.length){M=Array.from(t.children).filter((e=>{const t=e.getAttribute("slot");return!t||"trigger"!==t}))}const n=M[0];if(!n)return;const o=t=>{const i=t.closest("nile-menu-item");if(i){const M=Array.from(e.querySelectorAll("nile-menu-item")),o=Array.from(n.querySelectorAll("nile-menu-item"))[M.indexOf(i)];if(o){if(t===i)return o;const e=t.tagName.toLowerCase(),M=Array.from(i.querySelectorAll(e)),n=Array.from(o.querySelectorAll(e)),r=M.indexOf(t);return r>=0&&n[r]?n[r]:o}}return null},r=(e,t)=>{const i=e;let M;M=i instanceof MouseEvent?new MouseEvent(e.type,{bubbles:!0,cancelable:!0,composed:!0,button:i.button,buttons:i.buttons,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,metaKey:i.metaKey}):i instanceof KeyboardEvent?new KeyboardEvent(e.type,{bubbles:!0,cancelable:!0,composed:!0,key:i.key,code:i.code,keyCode:i.keyCode,which:i.which,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,metaKey:i.metaKey}):i instanceof CustomEvent?new CustomEvent(e.type,{bubbles:!0,cancelable:!0,composed:!0,detail:i.detail}):new Event(e.type,{bubbles:!0,cancelable:!0,composed:!0}),t.dispatchEvent(M)},s=(e,t)=>{if("nile-checkbox"===e.tagName.toLowerCase()&&"nile-checkbox"===t.tagName.toLowerCase()){const i=e,M=t;"checked"in M&&"checked"in i&&(i.checked=M.checked),"indeterminate"in M&&"indeterminate"in i&&(i.indeterminate=M.indeterminate)}};["click","change","input","submit","focus","blur","keydown","keyup","mousedown","mouseup"].forEach((t=>{e.addEventListener(t,(e=>{const i=e.target;if(!i)return;const M=o(i);if(M)if("click"===t)if("nile-checkbox"===i.tagName.toLowerCase()){e.stopImmediatePropagation(),e.preventDefault();const t=M;t&&"function"==typeof t.click?(t.click(),setTimeout((()=>{s(i,M)}),10)):(r(e,M),setTimeout((()=>{s(i,M)}),10))}else e.stopImmediatePropagation(),e.preventDefault(),r(e,M);else r(e,M)}),!0)}));const a=Array.from(e.querySelectorAll("nile-checkbox")),l=Array.from(n.querySelectorAll("nile-checkbox"));a.forEach(((e,t)=>{const i=l[t];i&&i.addEventListener("nile-change",(()=>{s(e,i)}))})),e.addEventListener("nile-change",(e=>{const t=e.target;if(!t)return;const i=o(t);if(i){const M=e;if("nile-checkbox"===t.tagName.toLowerCase()&&void 0!==M.detail?.checked){t.checked=M.detail.checked}const n=new CustomEvent("nile-change",{bubbles:!0,cancelable:!0,composed:!0,detail:M.detail});i.dispatchEvent(n)}}),!0)}},ln=class{constructor(e){this.portalContainer=null,this.measuredPanelHeight=null,this.clonedPanel=null,this.cleanupAutoUpdate=null,this.currentPlacement="bottom-start",this.currentMiddlewareData=null,this.boundHandleWindowResize=null,this.component=e}createPortalAppendContainer(){const e=document.createElement("div");return e.style.position="absolute",e.style.zIndex="9999",e.style.pointerEvents="none",e.style.width="auto",e.style.maxWidth="none",e.style.minWidth="auto",e.className="nile-dropdown-portal-append",e}positionPortalAppend(){this.portalContainer&&this.component.open&&(this.measurePanelHeight(),this.computeFloatingUIPosition())}measurePanelHeight(){!this.measuredPanelHeight&&this.portalContainer&&(this.portalContainer.style.position="absolute",this.portalContainer.style.visibility="hidden",this.portalContainer.style.top="0px",this.portalContainer.style.left="0px",this.portalContainer.offsetHeight,this.measuredPanelHeight=this.portalContainer.offsetHeight,this.portalContainer.style.visibility="")}async computeFloatingUIPosition(){if(!this.portalContainer)return;const e=this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component,t=this.portalContainer;try{const{x:i,y:M,placement:n,middlewareData:o}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,i,M,n,o)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const i=rn.findBoundaryElements(e),M=this.getInitialPlacement(),n=this.createFloatingUIMiddleware(i);return await Ji(e,t,{placement:M,strategy:"fixed",middleware:n,platform:this.createCustomPlatform()})}getInitialPlacement(){return this.component.placement||"bottom-start"}createFloatingUIMiddleware(e){const t=[Bi(this.component.distance||0)];return this.component.sync&&t.push(Fi({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e})),t.push(_i({fallbackPlacements:this.getFallbackPlacements(),fallbackStrategy:"bestFit",padding:10,boundary:e})),t.push(Gi({padding:10,crossAxis:!0,boundary:e})),t}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:i,rects:M}){const n=rn.calculateOptimalHeight(M.reference,window.innerHeight,this.currentPlacement);"width"!==this.component.sync&&"both"!==this.component.sync||(i.floating.style.width=`${M.reference.width}px`),"height"!==this.component.sync&&"both"!==this.component.sync||(i.floating.style.height=`${M.reference.height}px`),i.floating.style.maxHeight=`${n}px`,i.floating.style.setProperty("--auto-size-available-width",`${e}px`),i.floating.style.setProperty("--auto-size-available-height",`${n}px`)}getFallbackPlacements(){const e=this.component.placement||"bottom-start",t=[];return e.startsWith("top")?t.push("bottom-start","bottom","bottom-end","top","top-end","right-start","left-start"):e.startsWith("bottom")?t.push("top-start","top","top-end","bottom","bottom-end","right-start","left-start"):e.startsWith("left")?t.push("right-start","right","right-end","left","left-end","top-start","bottom-start"):e.startsWith("right")&&t.push("left-start","left","left-end","right","right-end","top-start","bottom-start"),t}createCustomPlatform(){return Wi}applyFloatingUIPosition(e,t,i,M,n,o){const r=t.getBoundingClientRect();Object.assign(e.style,{left:`${i}px`,top:`${M}px`,position:"fixed",pointerEvents:"auto",width:"auto",minWidth:"auto"}),"width"!==this.component.sync&&"both"!==this.component.sync||(e.style.width=`${r.width}px`),this.currentPlacement=n,this.currentMiddlewareData=o,rn.applyCollisionData(e,o,n);const s=n.split("-")[0];e.className=`nile-dropdown-portal-append dropdown--open dropdown__panel--${s}`}fallbackPositioning(){if(!this.portalContainer)return;const e=(this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component).getBoundingClientRect(),t=window.innerHeight,i=window.innerWidth,M=t-e.bottom,n=e.top,o=i-e.right,r=e.left;let s,a,l,N=e.left;const g=this.component.placement||"bottom-start";g.startsWith("bottom")?(l=Math.max(M-20,100),s=e.bottom+(this.component.distance||0),a="bottom"):g.startsWith("top")?(l=Math.max(n-20,100),s=Math.max(e.top-l-(this.component.distance||0),10),a="top"):g.startsWith("right")?(l=Math.max(Math.min(o,M,n)-20,100),s=e.top,N=e.right+(this.component.distance||0),a="right"):(l=Math.max(Math.min(r,M,n)-20,100),s=e.top,N=Math.max(e.left-200-(this.component.distance||0),10),a="left"),this.portalContainer.style.left=`${N}px`,this.portalContainer.style.top=`${s}px`,this.portalContainer.style.maxHeight=`${l}px`,this.portalContainer.style.pointerEvents="auto",this.portalContainer.style.width="auto",this.portalContainer.style.minWidth="auto","width"!==this.component.sync&&"both"!==this.component.sync||(this.portalContainer.style.width=`${e.width}px`),this.portalContainer.className=`nile-dropdown-portal-append dropdown__panel--${a}`,this.calculateAndSetAutoSizeProperties(e,s,a)}calculateAndSetAutoSizeProperties(e,t,i){if(!this.portalContainer)return;const M=window.innerHeight,n=window.innerWidth;let o,r=n-e.left-10;"top"===i?o=e.top-10:"bottom"===i?o=M-e.bottom-10:"left"===i?(o=Math.min(M-e.top,e.bottom),r=e.left-10):(o=Math.min(M-e.top,e.bottom),r=n-e.right-10),this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(o,100)}px`),this.portalContainer.style.setProperty("--auto-size-available-width",`${Math.max(r,200)}px`)}updatePortalAppendPosition(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}handleWindowResize(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}setupAutoUpdatePositioning(){if(!this.portalContainer||!this.component)return;this.cleanupAutoUpdatePositioning();const e=this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component;this.cleanupAutoUpdate=Ri(e,this.portalContainer,(()=>{this.computeFloatingUIPosition()}),{ancestorScroll:!0,ancestorResize:!0,elementResize:!0,layoutShift:!0,animationFrame:!0})}cleanupAutoUpdatePositioning(){this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null)}injectStylesToDocument(){if(!this.portalContainer)return;const e=rn.generateStyleId();if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const i=document.createElement("style");i.id=e,i.textContent=rn.extractStylesAsCSS(t),document.head.appendChild(i),this.portalContainer.__injectedStyleId=e}adoptStylesToPortalAppend(){this.portalContainer&&this.injectStylesToDocument()}setupPortalAppend(){this.component.portal&&this.component.updateComplete.then((()=>{setTimeout((()=>{this.component.open&&(this.clonedPanel=this.createPortalPanel(),this.portalContainer=this.createPortalAppendContainer(),this.portalContainer.appendChild(this.clonedPanel),document.body.appendChild(this.portalContainer),this.adoptStylesToPortalAppend(),this.clonedPanel.style.display="",this.positionPortalAppend(),this.setupPortalEventListeners(),this.setupAutoUpdatePositioning(),this.boundHandleWindowResize=this.handleWindowResize.bind(this),window.addEventListener("resize",this.boundHandleWindowResize))}),10)}))}createPortalPanel(){return sn.createPortalPanel(this.component)}setupPortalEventListeners(){an.setupPortalEventListeners(this.clonedPanel,this.component)}cleanupPortalAppend(){if(this.cleanupAutoUpdatePositioning(),this.portalContainer&&this.portalContainer.parentNode){const e=this.portalContainer.__injectedStyleId;if(e){const t=document.getElementById(e);t&&t.remove()}this.portalContainer.parentNode.removeChild(this.portalContainer)}this.boundHandleWindowResize&&(window.removeEventListener("resize",this.boundHandleWindowResize),this.boundHandleWindowResize=null),this.portalContainer=null,this.clonedPanel=null,this.measuredPanelHeight=null,this.currentPlacement="bottom-start",this.currentMiddlewareData=null}get portalContainerElement(){return this.portalContainer}resetMeasuredHeight(){this.measuredPanelHeight=null}forceReposition(){this.portalContainer&&this.computeFloatingUIPosition()}getCurrentPlacement(){return this.currentPlacement}getCurrentMiddlewareData(){return this.currentMiddlewareData}isUsingFloatingUI(){return null!==this.cleanupAutoUpdate}isPositioningOptimal(){if(!this.portalContainer||!this.currentMiddlewareData)return!0;const e=(this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component).getBoundingClientRect(),t=window.innerHeight-e.bottom,i=e.top,M=this.currentPlacement.startsWith("top"),n=this.currentPlacement.startsWith("bottom");return!(M&&t>i)&&!(n&&i>t)}updatePortalPanel(){this.portalContainer&&this.clonedPanel&&(sn.updatePortalPanel(this.clonedPanel,this.component),this.setupPortalEventListeners(),this.forceReposition())}},Nn=class extends Re{constructor(){super(...arguments),this.open=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.noOpenOnClick=!1,this.skidding=0,this.hoist=!1,this.portal=!1,this.enableVisibilityEffect=!1,this.enableTabClose=!1,this.portalManager=null}connectedCallback(){super.connectedCallback(),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init"),requestAnimationFrame((()=>{this.portal&&!this.portalManager&&(this.portalManager=new ln(this))}))}async firstUpdated(e){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0),await this.updateComplete;const t=this.trigger.assignedElements({flatten:!0})[0];this.visibilityManager=new tM({host:this,target:t||null,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"})},emit:(e,t)=>this.emit(`nile-${e}`,t)})}disconnectedCallback(){super.disconnectedCallback(),this.visibilityManager?.cleanup(),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy"),this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)}focusOnTrigger(){const e=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof e?.focus&&e.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((e=>"nile-menu"===e.tagName.toLowerCase()))}handleKeyDown(e){this.open&&"Escape"===e.key&&(e.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(e){if("Escape"===e.key&&this.open)return e.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===e.key){if(this.open&&"nile-menu-item"===document.activeElement?.tagName.toLowerCase())return e.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{const e=this.containingElement?.getRootNode()instanceof ShadowRoot?document.activeElement?.shadowRoot?.activeElement:document.activeElement,t=this.containingElement&&e?.closest(this.containingElement.tagName.toLowerCase())===this.containingElement,i=this.portal&&this.portalManager?.portalContainerElement&&(e===this.portalManager.portalContainerElement||e?.closest(".nile-dropdown-portal-append")===this.portalManager.portalContainerElement);t||i||this.hide()}))}}handleDocumentMouseDown(e){const t=e.composedPath(),i=this.containingElement&&t.includes(this.containingElement),M=this.portal&&this.portalManager?.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||M||this.hide()}handlePanelSelect(e){const t=e.target;this.stayOpenOnSelect||"nile-menu"!==t.tagName.toLowerCase()?this.stayOpenOnSelect&&"nile-menu"===t.tagName.toLowerCase()&&(this.show(),this.focusOnTrigger()):(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()))}handleTriggerKeyDown(e){const t=this.getMenu();if(t){const i=t.getAllItems(),M=i[0],n=i[i.length-1];["ArrowDown","ArrowUp","Home","End"].includes(e.key)&&(e.preventDefault(),this.open||this.show(),i.length>0&&this.updateComplete.then((()=>{"ArrowDown"!==e.key&&"Home"!==e.key||(t.setCurrentItem(M),M.focus()),"ArrowUp"!==e.key&&"End"!==e.key||(t.setCurrentItem(n),n.focus())})))}}handleTriggerKeyUp(e){" "===e.key&&e.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const e=this.trigger.assignedElements({flatten:!0}).find((e=>Et(e).start));let t;if(e){switch(e.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":t=e.button;break;default:t=e}t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded",this.open?"true":"false")}}async show(){if(!this.open)return this.open=!0,mt(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,mt(this,"nile-after-hide")}reposition(){this.popup.reposition()}addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}updated(e){super.updated(e),e.has("portal")&&(this.portal&&!this.portalManager?(this.portalManager=new ln(this),this.open&&this.portalManager.setupPortalAppend()):!this.portal&&this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)),e.has("disabled")&&this.updateTriggerDisabledState()}updateTriggerDisabledState(){const e=this.querySelector('[slot="trigger"]');e&&"disabled"in e&&(e.disabled=this.disabled)}async handleOpenChange(){if(this.visibilityManager?.setup(),this.disabled)this.open=!1;else if(this.updateAccessibleTrigger(),this.open){if(this.emit("nile-show"),this.addOpenListeners(),this.portal&&this.portalManager?this.portalManager.setupPortalAppend():this.portal&&!this.portalManager&&(this.portalManager=new ln(this),this.portalManager.setupPortalAppend()),await jt(this),!this.portal){this.panel.hidden=!1,this.popup.active=!0;const{keyframes:e,options:t}=yt(this,"dropdown.show",{dir:""});await ut(this.popup.popup,e,t)}this.emit("nile-after-show")}else{if(this.emit("nile-hide"),this.removeOpenListeners(),this.visibilityManager?.cleanup(),this.portal&&this.portalManager&&this.portalManager.cleanupPortalAppend(),await jt(this),!this.portal){const{keyframes:e,options:t}=yt(this,"dropdown.hide",{dir:""});await ut(this.popup.popup,e,t),this.panel.hidden=!0,this.popup.active=!1}this.emit("nile-after-hide")}}render(){return R`
5918
+ `;let rn=class{static calculateAvailableSpace(e){const t=e.getBoundingClientRect(),i=window.innerHeight,M=window.innerWidth,n=i-t.bottom,o=t.top,r=M-t.right;return{spaceAbove:o,spaceBelow:n,spaceLeft:t.left,spaceRight:r,viewportHeight:i,viewportWidth:M}}static getOptimalPlacement(e){const{spaceAbove:t,spaceBelow:i,spaceLeft:M,spaceRight:n}=this.calculateAvailableSpace(e);return i>=200&&i>=t?"bottom":t>=200&&t>i?"top":n>=200&&n>=M?"right":M>=200?"left":"bottom"}static findBoundaryElements(e){const t=[];let i=e.parentElement;for(;i&&i!==document.body;){const e=window.getComputedStyle(i),M=e.overflow,n=e.overflowY,o=e.overflowX;"auto"!==M&&"scroll"!==M&&"auto"!==n&&"scroll"!==n&&"auto"!==o&&"scroll"!==o||t.push(i),(i.hasAttribute("data-floating-boundary")||i.classList.contains("floating-boundary")||i.classList.contains("scroll-container"))&&t.push(i),i=i.parentElement}return t.length>0?t:void 0}static calculateOptimalHeight(e,t,i){const M=t-(e.y+e.height),n=e.y;return i.startsWith("top")?Math.max(n-20,100):i.startsWith("bottom")?Math.max(M-20,100):(i.startsWith("left")||i.startsWith("right"),Math.max(Math.min(n,M)-20,100))}static extractStylesAsCSS(e){return"string"==typeof e?e:Array.isArray(e)?e.map((e=>this.extractStylesAsCSS(e))).join("\n"):e&&"object"==typeof e&&e.cssText?e.cssText:""}static generateStyleId(){return`nile-dropdown-styles-${Math.random().toString(36).substring(2,11)}`}static isPositioningOptimal(e,t){const{spaceAbove:i,spaceBelow:M,spaceLeft:n,spaceRight:o}=this.calculateAvailableSpace(t),r=e.startsWith("top"),s=e.startsWith("bottom"),a=e.startsWith("left"),l=e.startsWith("right");return!(r&&M>i)&&(!(s&&i>M)&&(!(a&&o>n)&&!(l&&n>o)))}static applyCollisionData(e,t,i){if(t.flip){const{overflows:M}=t.flip;if(e.setAttribute("data-placement",i),M&&M.length>0){const t=M.map((e=>e.placement)).join(",");e.setAttribute("data-overflow",t)}else e.removeAttribute("data-overflow")}if(t.shift){const{x:i,y:M}=t.shift;void 0===i||void 0===M||0===i&&0===M?e.removeAttribute("data-shift"):e.setAttribute("data-shift",`${i},${M}`)}if(t.size){const{availableWidth:i,availableHeight:M}=t.size;void 0!==i&&e.setAttribute("data-available-width",i.toString()),void 0!==M&&e.setAttribute("data-available-height",M.toString())}}},sn=class{static createPortalPanel(e){const t=e.shadowRoot?.querySelector(".dropdown__panel");if(!t){const t=e.querySelector("[slot]");if(!t||"trigger"===t.getAttribute("slot"))return document.createElement("div")}let i=t?.assignedElements({flatten:!0})||[];if(0===i.length){i=Array.from(e.children).filter((e=>{const t=e.getAttribute("slot");return!t||"trigger"!==t}))}const M=document.createElement("div");return M.className="dropdown__panel",M.setAttribute("part","panel"),M.setAttribute("aria-hidden","false"),M.setAttribute("aria-labelledby","dropdown"),i.forEach((e=>{const t=e.cloneNode(!0);this.processInlineEventHandlers(t),M.appendChild(t)})),M}static updatePortalPanel(e,t){if(!e)return;e.innerHTML="";const i=t.shadowRoot?.querySelector(".dropdown__panel");let M=i?.assignedElements({flatten:!0})||[];if(0===M.length){M=Array.from(t.children).filter((e=>{const t=e.getAttribute("slot");return!t||"trigger"!==t}))}M.forEach((t=>{const i=t.cloneNode(!0);this.processInlineEventHandlers(i),e.appendChild(i)}))}static processInlineEventHandlers(e){["onclick","onchange","oninput","onsubmit","onfocus","onblur","onkeydown","onkeyup"].forEach((t=>{e.removeAttribute(t),e.querySelectorAll(`[${t}]`).forEach((e=>{e.removeAttribute(t)}))}))}},an=class{static setupPortalEventListeners(e,t){e&&(this.setupMenuSelectListeners(e,t),this.setupKeyDownListeners(e,t),this.setupEventForwarding(e,t))}static setupMenuSelectListeners(e,t){e&&e.addEventListener("nile-select",(e=>{const i=e;t.handlePanelSelect&&t.handlePanelSelect(i)}))}static setupKeyDownListeners(e,t){e&&e.addEventListener("keydown",(e=>{t.handleKeyDown&&t.handleKeyDown(e)}))}static setupEventForwarding(e,t){if(!e)return;const i=t.shadowRoot?.querySelector(".dropdown__panel");if(!i)return;let M=i.assignedElements({flatten:!0})||[];if(0===M.length){M=Array.from(t.children).filter((e=>{const t=e.getAttribute("slot");return!t||"trigger"!==t}))}const n=M[0];if(!n)return;const o=t=>{const i=t.closest("nile-menu-item");if(i){const M=Array.from(e.querySelectorAll("nile-menu-item")),o=Array.from(n.querySelectorAll("nile-menu-item"))[M.indexOf(i)];if(o){if(t===i)return o;const e=t.tagName.toLowerCase(),M=Array.from(i.querySelectorAll(e)),n=Array.from(o.querySelectorAll(e)),r=M.indexOf(t);return r>=0&&n[r]?n[r]:o}}return null},r=(e,t)=>{const i=e;let M;M=i instanceof MouseEvent?new MouseEvent(e.type,{bubbles:!0,cancelable:!0,composed:!0,button:i.button,buttons:i.buttons,clientX:i.clientX,clientY:i.clientY,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,metaKey:i.metaKey}):i instanceof KeyboardEvent?new KeyboardEvent(e.type,{bubbles:!0,cancelable:!0,composed:!0,key:i.key,code:i.code,keyCode:i.keyCode,which:i.which,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,metaKey:i.metaKey}):i instanceof CustomEvent?new CustomEvent(e.type,{bubbles:!0,cancelable:!0,composed:!0,detail:i.detail}):new Event(e.type,{bubbles:!0,cancelable:!0,composed:!0}),t.dispatchEvent(M)},s=(e,t)=>{if("nile-checkbox"===e.tagName.toLowerCase()&&"nile-checkbox"===t.tagName.toLowerCase()){const i=e,M=t;"checked"in M&&"checked"in i&&(i.checked=M.checked),"indeterminate"in M&&"indeterminate"in i&&(i.indeterminate=M.indeterminate)}};["click","change","input","submit","focus","blur","keydown","keyup","mousedown","mouseup"].forEach((t=>{e.addEventListener(t,(e=>{const i=e.target;if(!i)return;const M=o(i);if(M)if("click"===t)if("nile-checkbox"===i.tagName.toLowerCase()){e.stopImmediatePropagation(),e.preventDefault();const t=M;t&&"function"==typeof t.click?(t.click(),setTimeout((()=>{s(i,M)}),10)):(r(e,M),setTimeout((()=>{s(i,M)}),10))}else e.stopImmediatePropagation(),e.preventDefault(),r(e,M);else r(e,M)}),!0)}));const a=Array.from(e.querySelectorAll("nile-checkbox")),l=Array.from(n.querySelectorAll("nile-checkbox"));a.forEach(((e,t)=>{const i=l[t];i&&i.addEventListener("nile-change",(()=>{s(e,i)}))})),e.addEventListener("nile-change",(e=>{const t=e.target;if(!t)return;const i=o(t);if(i){const M=e;if("nile-checkbox"===t.tagName.toLowerCase()&&void 0!==M.detail?.checked){t.checked=M.detail.checked}const n=new CustomEvent("nile-change",{bubbles:!0,cancelable:!0,composed:!0,detail:M.detail});i.dispatchEvent(n)}}),!0)}},ln=class{constructor(e){this.portalContainer=null,this.measuredPanelHeight=null,this.clonedPanel=null,this.cleanupAutoUpdate=null,this.currentPlacement="bottom-start",this.currentMiddlewareData=null,this.boundHandleWindowResize=null,this.component=e}createPortalAppendContainer(){const e=document.createElement("div");return e.style.position="absolute",e.style.zIndex="9999",e.style.pointerEvents="none",e.style.width="auto",e.style.maxWidth="none",e.style.minWidth="auto",e.className="nile-dropdown-portal-append",e}positionPortalAppend(){this.portalContainer&&this.component.open&&(this.measurePanelHeight(),this.computeFloatingUIPosition())}measurePanelHeight(){!this.measuredPanelHeight&&this.portalContainer&&(this.portalContainer.style.position="absolute",this.portalContainer.style.visibility="hidden",this.portalContainer.style.top="0px",this.portalContainer.style.left="0px",this.portalContainer.offsetHeight,this.measuredPanelHeight=this.portalContainer.offsetHeight,this.portalContainer.style.visibility="")}async computeFloatingUIPosition(){if(!this.portalContainer)return;const e=this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component,t=this.portalContainer;try{const{x:i,y:M,placement:n,middlewareData:o}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,i,M,n,o)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const i=rn.findBoundaryElements(e),M=this.getInitialPlacement(),n=this.createFloatingUIMiddleware(i);return await Ji(e,t,{placement:M,strategy:"fixed",middleware:n,platform:this.createCustomPlatform()})}getInitialPlacement(){return this.component.placement||"bottom-start"}createFloatingUIMiddleware(e){const t=[Bi(this.component.distance||0)];return this.component.sync&&t.push(Fi({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e})),t.push(_i({fallbackPlacements:this.getFallbackPlacements(),fallbackStrategy:"bestFit",padding:10,boundary:e})),t.push(Gi({padding:10,crossAxis:!0,boundary:e})),t}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:i,rects:M}){const n=rn.calculateOptimalHeight(M.reference,window.innerHeight,this.currentPlacement);"width"!==this.component.sync&&"both"!==this.component.sync||(i.floating.style.width=`${M.reference.width}px`),"height"!==this.component.sync&&"both"!==this.component.sync||(i.floating.style.height=`${M.reference.height}px`),i.floating.style.maxHeight=`${n}px`,i.floating.style.setProperty("--auto-size-available-width",`${e}px`),i.floating.style.setProperty("--auto-size-available-height",`${n}px`)}getFallbackPlacements(){const e=this.component.placement||"bottom-start",t=[];return e.startsWith("top")?t.push("bottom-start","bottom","bottom-end","top","top-end","right-start","left-start"):e.startsWith("bottom")?t.push("top-start","top","top-end","bottom","bottom-end","right-start","left-start"):e.startsWith("left")?t.push("right-start","right","right-end","left","left-end","top-start","bottom-start"):e.startsWith("right")&&t.push("left-start","left","left-end","right","right-end","top-start","bottom-start"),t}createCustomPlatform(){return Wi}applyFloatingUIPosition(e,t,i,M,n,o){const r=t.getBoundingClientRect();Object.assign(e.style,{left:`${i}px`,top:`${M}px`,position:"fixed",pointerEvents:"auto",width:"auto",minWidth:"auto"}),"width"!==this.component.sync&&"both"!==this.component.sync||(e.style.width=`${r.width}px`),this.currentPlacement=n,this.currentMiddlewareData=o,rn.applyCollisionData(e,o,n);const s=n.split("-")[0];e.className=`nile-dropdown-portal-append dropdown--open dropdown__panel--${s}`}fallbackPositioning(){if(!this.portalContainer)return;const e=(this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component).getBoundingClientRect(),t=window.innerHeight,i=window.innerWidth,M=t-e.bottom,n=e.top,o=i-e.right,r=e.left;let s,a,l,N=e.left;const g=this.component.placement||"bottom-start";g.startsWith("bottom")?(l=Math.max(M-20,100),s=e.bottom+(this.component.distance||0),a="bottom"):g.startsWith("top")?(l=Math.max(n-20,100),s=Math.max(e.top-l-(this.component.distance||0),10),a="top"):g.startsWith("right")?(l=Math.max(Math.min(o,M,n)-20,100),s=e.top,N=e.right+(this.component.distance||0),a="right"):(l=Math.max(Math.min(r,M,n)-20,100),s=e.top,N=Math.max(e.left-200-(this.component.distance||0),10),a="left"),this.portalContainer.style.left=`${N}px`,this.portalContainer.style.top=`${s}px`,this.portalContainer.style.maxHeight=`${l}px`,this.portalContainer.style.pointerEvents="auto",this.portalContainer.style.width="auto",this.portalContainer.style.minWidth="auto","width"!==this.component.sync&&"both"!==this.component.sync||(this.portalContainer.style.width=`${e.width}px`),this.portalContainer.className=`nile-dropdown-portal-append dropdown__panel--${a}`,this.calculateAndSetAutoSizeProperties(e,s,a)}calculateAndSetAutoSizeProperties(e,t,i){if(!this.portalContainer)return;const M=window.innerHeight,n=window.innerWidth;let o,r=n-e.left-10;"top"===i?o=e.top-10:"bottom"===i?o=M-e.bottom-10:"left"===i?(o=Math.min(M-e.top,e.bottom),r=e.left-10):(o=Math.min(M-e.top,e.bottom),r=n-e.right-10),this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(o,100)}px`),this.portalContainer.style.setProperty("--auto-size-available-width",`${Math.max(r,200)}px`)}updatePortalAppendPosition(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}handleWindowResize(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}setupAutoUpdatePositioning(){if(!this.portalContainer||!this.component)return;this.cleanupAutoUpdatePositioning();const e=this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component;this.cleanupAutoUpdate=Ri(e,this.portalContainer,(()=>{this.computeFloatingUIPosition()}),{ancestorScroll:!0,ancestorResize:!0,elementResize:!0,layoutShift:!0,animationFrame:!0})}cleanupAutoUpdatePositioning(){this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null)}injectStylesToDocument(){if(!this.portalContainer)return;const e=rn.generateStyleId();if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const i=document.createElement("style");i.id=e,i.textContent=rn.extractStylesAsCSS(t),document.head.appendChild(i),this.portalContainer.__injectedStyleId=e}adoptStylesToPortalAppend(){this.portalContainer&&this.injectStylesToDocument()}setupPortalAppend(){this.component.portal&&this.component.updateComplete.then((()=>{setTimeout((()=>{this.component.open&&(this.clonedPanel=this.createPortalPanel(),this.portalContainer=this.createPortalAppendContainer(),this.portalContainer.appendChild(this.clonedPanel),document.body.appendChild(this.portalContainer),this.adoptStylesToPortalAppend(),this.clonedPanel.style.display="",this.positionPortalAppend(),this.setupPortalEventListeners(),this.setupAutoUpdatePositioning(),this.boundHandleWindowResize=this.handleWindowResize.bind(this),window.addEventListener("resize",this.boundHandleWindowResize))}),10)}))}createPortalPanel(){return sn.createPortalPanel(this.component)}setupPortalEventListeners(){an.setupPortalEventListeners(this.clonedPanel,this.component)}cleanupPortalAppend(){if(this.cleanupAutoUpdatePositioning(),this.portalContainer&&this.portalContainer.parentNode){const e=this.portalContainer.__injectedStyleId;if(e){const t=document.getElementById(e);t&&t.remove()}this.portalContainer.parentNode.removeChild(this.portalContainer)}this.boundHandleWindowResize&&(window.removeEventListener("resize",this.boundHandleWindowResize),this.boundHandleWindowResize=null),this.portalContainer=null,this.clonedPanel=null,this.measuredPanelHeight=null,this.currentPlacement="bottom-start",this.currentMiddlewareData=null}get portalContainerElement(){return this.portalContainer}resetMeasuredHeight(){this.measuredPanelHeight=null}forceReposition(){this.portalContainer&&this.computeFloatingUIPosition()}getCurrentPlacement(){return this.currentPlacement}getCurrentMiddlewareData(){return this.currentMiddlewareData}isUsingFloatingUI(){return null!==this.cleanupAutoUpdate}isPositioningOptimal(){if(!this.portalContainer||!this.currentMiddlewareData)return!0;const e=(this.component.shadowRoot?.querySelector('[slot="anchor"]')?.assignedElements({flatten:!0})[0]||this.component.querySelector('[slot="trigger"]')?.assignedElements({flatten:!0})[0]||this.component).getBoundingClientRect(),t=window.innerHeight-e.bottom,i=e.top,M=this.currentPlacement.startsWith("top"),n=this.currentPlacement.startsWith("bottom");return!(M&&t>i)&&!(n&&i>t)}updatePortalPanel(){this.portalContainer&&this.clonedPanel&&(sn.updatePortalPanel(this.clonedPanel,this.component),this.setupPortalEventListeners(),this.forceReposition())}},Nn=class extends Re{constructor(){super(...arguments),this.open=!1,this.placement="bottom-start",this.disabled=!1,this.stayOpenOnSelect=!1,this.distance=0,this.noOpenOnClick=!1,this.skidding=0,this.hoist=!1,this.portal=!1,this.enableVisibilityEffect=!1,this.enableTabClose=!1,this.portalManager=null}connectedCallback(){super.connectedCallback(),this.handlePanelSelect=this.handlePanelSelect.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this),this.emit("nile-init"),requestAnimationFrame((()=>{this.portal&&!this.portalManager&&(this.portalManager=new ln(this))}))}async firstUpdated(e){this.panel.hidden=!this.open,this.open&&(this.addOpenListeners(),this.popup.active=!0),await this.updateComplete;const t=this.trigger.assignedElements({flatten:!0})[0];this.visibilityManager=new tM({host:this,target:t||null,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view"})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden"})},emit:(e,t)=>this.emit(`nile-${e}`,t)})}disconnectedCallback(){super.disconnectedCallback(),this.visibilityManager?.cleanup(),this.removeOpenListeners(),this.hide(),this.emit("nile-destroy"),this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)}focusOnTrigger(){const e=this.trigger.assignedElements({flatten:!0})[0];"function"==typeof e?.focus&&e.focus()}getMenu(){return this.panel.assignedElements({flatten:!0}).find((e=>"nile-menu"===e.tagName.toLowerCase()))}handleKeyDown(e){this.open&&"Escape"===e.key&&(e.stopPropagation(),this.hide(),this.focusOnTrigger())}handleDocumentKeyDown(e){if("Escape"===e.key&&this.open)return e.stopPropagation(),this.focusOnTrigger(),void this.hide();if("Tab"===e.key){if(this.open&&"nile-menu-item"===document.activeElement?.tagName.toLowerCase())return e.preventDefault(),this.hide(),void this.focusOnTrigger();setTimeout((()=>{const e=this.containingElement?.getRootNode()instanceof ShadowRoot?document.activeElement?.shadowRoot?.activeElement:document.activeElement,t=this.containingElement&&e?.closest(this.containingElement.tagName.toLowerCase())===this.containingElement,i=this.portal&&this.portalManager?.portalContainerElement&&(e===this.portalManager.portalContainerElement||e?.closest(".nile-dropdown-portal-append")===this.portalManager.portalContainerElement);t||i||this.hide()}))}}handleDocumentMouseDown(e){const t=e.composedPath(),i=this.containingElement&&t.includes(this.containingElement),M=this.portal&&this.portalManager?.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||M||this.hide()}handlePanelSelect(e){const t=e.target;this.stayOpenOnSelect||"nile-menu"!==t.tagName.toLowerCase()?this.stayOpenOnSelect&&"nile-menu"===t.tagName.toLowerCase()&&(this.show(),this.focusOnTrigger()):(this.hide(),this.focusOnTrigger())}handleTriggerClick(){this.noOpenOnClick||(this.open?this.hide():(this.show(),this.focusOnTrigger()))}handleTriggerKeyDown(e){const t=this.getMenu();if(t){const i=t.getAllItems(),M=i[0],n=i[i.length-1];["ArrowDown","ArrowUp","Home","End"].includes(e.key)&&(e.preventDefault(),this.open||this.show(),i.length>0&&this.updateComplete.then((()=>{"ArrowDown"!==e.key&&"Home"!==e.key||(t.setCurrentItem(M),M.focus()),"ArrowUp"!==e.key&&"End"!==e.key||(t.setCurrentItem(n),n.focus())})))}}handleTriggerKeyUp(e){" "===e.key&&e.preventDefault()}handleTriggerSlotChange(){this.updateAccessibleTrigger()}updateAccessibleTrigger(){const e=this.trigger.assignedElements({flatten:!0}).find((e=>Et(e).start));let t;if(e){switch(e.tagName.toLowerCase()){case"nile-button":case"nile-icon-button":t=e.button;break;default:t=e}t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded",this.open?"true":"false")}}async show(){if(!this.open)return this.open=!0,mt(this,"nile-after-show")}async hide(){if(this.open)return this.open=!1,mt(this,"nile-after-hide")}reposition(){this.popup.reposition()}addOpenListeners(){this.panel.addEventListener("nile-select",this.handlePanelSelect),this.panel.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){this.panel&&(this.panel.removeEventListener("nile-select",this.handlePanelSelect),this.panel.removeEventListener("keydown",this.handleKeyDown)),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}updated(e){super.updated(e),e.has("portal")&&(this.portal&&!this.portalManager?(this.portalManager=new ln(this),this.open&&this.portalManager.setupPortalAppend()):!this.portal&&this.portalManager&&(this.portalManager.cleanupPortalAppend(),this.portalManager=null)),e.has("disabled")&&this.updateTriggerDisabledState()}updateTriggerDisabledState(){const e=this.querySelector('[slot="trigger"]');if(!e)return;const t=e.hasAttribute("disabled");(this.disabled||t)&&(e.disabled=!0,this.disabled=!0)}async handleOpenChange(){if(this.visibilityManager?.setup(),this.disabled)this.open=!1;else if(this.updateAccessibleTrigger(),this.open){if(this.emit("nile-show"),this.addOpenListeners(),this.portal&&this.portalManager?this.portalManager.setupPortalAppend():this.portal&&!this.portalManager&&(this.portalManager=new ln(this),this.portalManager.setupPortalAppend()),await jt(this),!this.portal){this.panel.hidden=!1,this.popup.active=!0;const{keyframes:e,options:t}=yt(this,"dropdown.show",{dir:""});await ut(this.popup.popup,e,t)}this.emit("nile-after-show")}else{if(this.emit("nile-hide"),this.removeOpenListeners(),this.visibilityManager?.cleanup(),this.portal&&this.portalManager&&this.portalManager.cleanupPortalAppend(),await jt(this),!this.portal){const{keyframes:e,options:t}=yt(this,"dropdown.hide",{dir:""});await ut(this.popup.popup,e,t),this.panel.hidden=!0,this.popup.active=!1}this.emit("nile-after-hide")}}render(){return R`
5919
5919
  <nile-popup
5920
5920
  part="base"
5921
5921
  id="dropdown"
@@ -15484,58 +15484,73 @@ nile-badge::part(content) {
15484
15484
  </div>
15485
15485
  </div>
15486
15486
  </nile-popover>
15487
- `}};e([ce({type:String,attribute:!0,reflect:!0})],Cm.prototype,"mode",void 0),e([ce({type:String,attribute:!0,reflect:!0})],Cm.prototype,"label",void 0),e([ce({type:String,attribute:!0,reflect:!0})],Cm.prototype,"value",void 0),e([ce({type:Array,attribute:!0,reflect:!0})],Cm.prototype,"palette",void 0),e([De()],Cm.prototype,"recentColors",void 0),Cm=e([Ne("nile-rte-color")],Cm);let fm=class extends ae{createRenderRoot(){return this}shouldUpdate(){return!1}};fm=e([Ne("nile-rte-divider")],fm);let vm=class extends ae{createRenderRoot(){return this}shouldUpdate(){return!1}};vm=e([Ne("nile-rte-preview")],vm);let Um=class extends ae{constructor(){super(...arguments),this.displayFormat=!1,this.mentions={},this.mentionFormat={},this.itemsFormats={},this.mentionColors={},this.externalConfig={},this.itemsConfig={},this.mentionActiveIndex=-1,this.itemsColors={},this.editorEl=null,this.hostEl=null,this.dropdownEl=null,this.menuEl=null,this.lastRange=null,this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionSuggestions=[],this.mentionFiltered=[],this.mentionX=0,this.mentionY=0,this.triggerBtn=null,this.mo=null,this.onSelectionChange=()=>{if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);this.editorEl.contains(t.commonAncestorContainer)&&(this.lastRange=t.cloneRange())},this.saveSelection=()=>{const e=window.getSelection();e&&e.rangeCount&&(this.lastRange=e.getRangeAt(0).cloneRange())},this.onEditorInput=()=>{if(this.mentionOpen)return void this.handleMention();const e=window.getSelection();if(!e||!e.anchorNode)return;let t=e.anchorNode;if(t.nodeType!==Node.TEXT_NODE&&t.firstChild?.nodeType===Node.TEXT_NODE&&(t=t.firstChild),!t||t.nodeType!==Node.TEXT_NODE)return;const i=t.textContent||"",M=this.config;for(const t of Object.keys(M)){const M=i.lastIndexOf(t);if(-1!==M){const i=e.focusOffset;if(i>=M+t.length&&i<=M+t.length+1)return void this.openMention(t)}}},this.onEditorKeyUp=e=>{this.saveSelection();const t=e.key,i=this.config;if(t&&i[t])return this.mentionOpen&&this.mentionTrigger!==t&&this.closeMention(),void this.openMention(t);this.mentionOpen&&this.handleMention()},this.onEditorKeyDown=e=>{if(!this.mentionOpen)return;const t=e.key;if("ArrowDown"===t||"ArrowUp"===t){if(e.preventDefault(),!this.mentionFiltered.length)return;this.mentionActiveIndex="ArrowDown"===t?(this.mentionActiveIndex+1)%this.mentionFiltered.length:(this.mentionActiveIndex-1+this.mentionFiltered.length)%this.mentionFiltered.length,this.renderMentionList()}else"Enter"===t?this.mentionActiveIndex>=0&&this.mentionFiltered[this.mentionActiveIndex]&&(e.preventDefault(),this.selectMention(this.mentionFiltered[this.mentionActiveIndex])):"Escape"===t&&(e.preventDefault(),this.closeMention())},this.repositionMention=()=>{if(!this.mentionOpen||!this.hostEl||!this.triggerBtn)return;const e=this.getCaretClientRect();if(!e)return;const t=this.hostEl.getBoundingClientRect();this.mentionX=e.left-t.left,this.mentionY=e.bottom-t.top,this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`}}createRenderRoot(){return this}getTriggerFormat(e){const t=this.itemsFormats[e]||{},i=this.mentionFormat[e]||{};return{prefix:t.prefix??i.prefix??"",suffix:t.suffix??i.suffix??""}}formatLabel(e,t){const{prefix:i,suffix:M}=this.getTriggerFormat(e);return`${i??""}${t}${M??""}`}get config(){return{...this.externalConfig,...this.mentions,...this.itemsConfig}}attach(e,t){this.editorEl=e,this.hostEl=t,this.injectStyles(),this.ensureMentionDropdown(),this.rebuildConfigFromChildren(),this.mo=new MutationObserver((()=>this.rebuildConfigFromChildren())),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0}),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.saveSelection),this.editorEl.addEventListener("keyup",this.onEditorKeyUp),this.editorEl.addEventListener("keydown",this.onEditorKeyDown),this.editorEl.addEventListener("scroll",this.repositionMention),document.addEventListener("selectionchange",this.onSelectionChange,!0)}detach(){this.mo&&(this.mo.disconnect(),this.mo=null),this.editorEl&&(this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.saveSelection),this.editorEl.removeEventListener("keyup",this.onEditorKeyUp),this.editorEl.removeEventListener("keydown",this.onEditorKeyDown),this.editorEl.removeEventListener("scroll",this.repositionMention)),document.removeEventListener("selectionchange",this.onSelectionChange,!0)}setExternalConfig(e){this.externalConfig=e||{}}disconnectedCallback(){this.detach(),super.disconnectedCallback()}rebuildConfigFromChildren(){const e={},t={},i={},M=Array.from(this.querySelectorAll("nile-rte-mentions-item"));for(const n of M){const M=n.mentionsCharacter??n.getAttribute("mentionscharacter")??"";if(!M||"string"!=typeof M)continue;let o=n.mentionsData??(()=>{const e=n.getAttribute("mentionsdata");if(!e)return null;try{const t=JSON.parse(e);return Array.isArray(t)?t.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)):[]}catch{return[]}})();const r=n.mentionsColor??n.getAttribute("mentionscolor")??"",s=n.mentionsPrefix??n.getAttribute("mentionsprefix")??"",a=n.mentionsSuffix??n.getAttribute("mentionssuffix")??"";Array.isArray(o)||(o=[]),e[M]=o,r&&(t[M]=String(r)),(s||a)&&(i[M]={prefix:s,suffix:a})}this.itemsConfig=e,this.itemsColors=t,this.itemsFormats=i}injectStyles(){if(this.querySelector("style[data-mentions-style]"))return;const e=document.createElement("style");e.setAttribute("data-mentions-style","true"),e.textContent="\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n nile-menu.mentions-menu::part(menu__items-wrapper){\n max-height: 260px;\n overflow-y: auto;\n }\n .mentions-menu nile-menu-item.active {\n background: #dbeafe; /* highlight */\n outline: none;\n}\n\n\n ",this.insertBefore(e,this.firstChild)}getTriggerColor(e){return this.itemsColors[e]??this.mentionColors[e]}ensureMentionDropdown(){if(this.dropdownEl||!this.hostEl)return;const e=document.createElement("nile-dropdown");e.style.zIndex="1000";const t=document.createElement("nile-button");t.setAttribute("slot","trigger"),t.style.position="absolute",t.style.width="1px",t.style.height="1px",t.style.border="0",t.style.padding="0",t.style.opacity="0",t.style.pointerEvents="none",e.appendChild(t),this.triggerBtn=t;const i=document.createElement("nile-menu");i.classList.add("mentions-menu"),e.appendChild(i),this.hostEl.appendChild(e),this.dropdownEl=e,this.menuEl=i}restoreSelection(){if(!this.lastRange)return;const e=document.getSelection();e&&(e.removeAllRanges(),e.addRange(this.lastRange))}getCaretClientRect(){const e=document.getSelection();if(!e||0===e.rangeCount)return null;const t=e.getRangeAt(0).cloneRange();t.collapse(!1);const i=t.getClientRects();if(i&&i.length>0)return i[0];const M=document.createElement("span");M.setAttribute("data-caret-marker","1"),M.textContent="​",t.insertNode(M);const n=M.getBoundingClientRect(),o=document.createRange();return o.setStartAfter(M),o.collapse(!0),e.removeAllRanges(),e.addRange(o),M.remove(),n||null}openMention(e){if(this.saveSelection(),!this.editorEl||!this.dropdownEl||!this.hostEl)return;const t=this.getCaretClientRect();if(!t)return;const i=this.hostEl.getBoundingClientRect();this.mentionX=t.left-i.left,this.mentionY=t.bottom-i.top,this.mentionTrigger=e,this.mentionSuggestions=this.config[e]||[],this.mentionQuery="",this.updateMentionFiltered(),this.mentionActiveIndex=this.mentionFiltered.length?0:-1,this.mentionOpen=!0,this.renderMentionList(),this.dispatchEvent(new CustomEvent("nile-mention-opened",{detail:{trigger:e,suggestions:this.mentionSuggestions},bubbles:!0,composed:!0}))}closeMention(){this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionFiltered=[],this.dropdownEl?.removeAttribute("open")}handleMention(){if(!this.mentionOpen||!this.mentionTrigger)return;const e=window.getSelection();if(!e||!e.anchorNode)return;let t=e.anchorNode;if(t.nodeType!==Node.TEXT_NODE){const i=t.childNodes?.[e.anchorOffset]||t.firstChild;i?.nodeType===Node.TEXT_NODE&&(t=i)}const i=t&&t.nodeType===Node.TEXT_NODE&&t.textContent||"",M=i.lastIndexOf(this.mentionTrigger);M>=0?(this.mentionQuery=i.substring(M+1),this.updateMentionFiltered(),this.renderMentionList()):this.closeMention()}updateMentionFiltered(){const e=this.mentionQuery.toLowerCase();this.mentionFiltered=(this.mentionSuggestions||[]).filter((t=>t.label.toLowerCase().startsWith(e)))}renderMentionList(){this.dropdownEl&&this.menuEl&&this.triggerBtn&&(this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`,this.menuEl.innerHTML="",this.mentionOpen&&this.mentionFiltered.length?(this.mentionFiltered.forEach(((e,t)=>{const i=document.createElement("nile-menu-item");i.textContent=e.label,i.setAttribute("role","option"),t===this.mentionActiveIndex?(i.classList.add("active"),i.setAttribute("aria-selected","true")):(i.classList.remove("active"),i.removeAttribute("aria-selected")),i.addEventListener("mouseenter",(()=>{this.mentionActiveIndex=t,this.renderMentionList()})),i.addEventListener("pointerdown",(t=>{t.preventDefault(),this.selectMention(e)})),this.menuEl?.appendChild(i)})),this.dropdownEl.setAttribute("open","")):this.dropdownEl.removeAttribute("open"))}selectMention(e){if(this.restoreSelection(),!this.lastRange||!this.mentionTrigger||!this.editorEl)return;const t=this.mentionTrigger;let i=this.lastRange.startContainer,M=this.lastRange.startOffset;if(i.nodeType!==Node.TEXT_NODE){const e=i.childNodes[M];if(e?.nodeType!==Node.TEXT_NODE)return;i=e,M=0}const n=i,o=(n.textContent||"").lastIndexOf(this.mentionTrigger,M);if(o<0)return;const r=o+1+this.mentionQuery.length,s=document.createRange();s.setStart(n,o),s.setEnd(n,r),s.deleteContents();const a=document.createElement("span");a.classList.add("mention");const l=this.getTriggerFormat(this.mentionTrigger);this.displayFormat?a.textContent=`${l.prefix??""}${e.label}${l.suffix??""}`:(a.textContent=`${this.mentionTrigger}${e.label}`,l.prefix&&a.setAttribute("data-mention-prefix",l.prefix),l.suffix&&a.setAttribute("data-mention-suffix",l.suffix)),a.setAttribute("data-mention-key",e.key),a.setAttribute("data-mention-label",e.label),a.setAttribute("data-mention-trigger",this.mentionTrigger);const N=this.getTriggerColor(this.mentionTrigger);N&&(a.style.backgroundColor=N),s.insertNode(a);const g=document.createTextNode(" ");a.after(g);const u=window.getSelection(),c=document.createRange();c.setStartAfter(g),c.collapse(!0),u?.removeAllRanges(),u?.addRange(c),this.lastRange=c.cloneRange(),this.closeMention(),this.dispatchEvent(new CustomEvent("nile-mention-selected",{detail:{trigger:t,key:e.key,label:e.label,prefix:l.prefix??"",suffix:l.suffix??""},bubbles:!0,composed:!0})),this.editorEl.dispatchEvent(new InputEvent("input",{bubbles:!0}))}};e([ce({type:Boolean,attribute:"displayformat",reflect:!0})],Um.prototype,"displayFormat",void 0),e([ce({attribute:"mentions",converter:{fromAttribute:e=>{try{const t=JSON.parse(e),i={};for(const e of Object.keys(t)){const M=t[e];Array.isArray(M)&&(i[e]=M.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)).map((e=>({key:e.key,label:e.label}))))}return i}catch{return{}}},toAttribute:e=>JSON.stringify(e)}})],Um.prototype,"mentions",void 0),e([ce({attribute:"mentionformat",converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch{return{}}},toAttribute:e=>JSON.stringify(e??{})}})],Um.prototype,"mentionFormat",void 0),e([De()],Um.prototype,"itemsFormats",void 0),e([ce({attribute:"mentioncolors",converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch{return{}}},toAttribute:e=>JSON.stringify(e??{})}})],Um.prototype,"mentionColors",void 0),e([De()],Um.prototype,"externalConfig",void 0),e([De()],Um.prototype,"itemsConfig",void 0),e([De()],Um.prototype,"mentionActiveIndex",void 0),e([De()],Um.prototype,"itemsColors",void 0),Um=e([Ne("nile-rte-mentions")],Um);let Ym=class extends ae{constructor(){super(...arguments),this.newTab=!1,this.placeholder="Type or paste link here",this.label="Link",this.linkValue="",this.hasActiveLink=!1,this.popoverStyle="",this.selectionRange=null,this.activeAnchor=null,this.ignoreBlur=!1,this.isApplying=!1,this.onScroll=()=>{this.closePopover()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.injectCss("\n nile-popover.rte-link-popover::part(popover) {\n min-width: 316px;\n background: white;\n border: 1px solid var(--nile-colors-neutral-400,var(--ng-componentcolors-utility-gray-400));\n border-radius: 4px;\n padding: 0;\n gap: 0;\n }\n\n .link-popup {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 8px;\n }\n\n .link-input {\n flex: 1;\n padding: 6px 8px;\n font-size: 14px;\n width: 276px;\n height: 14px;\n padding: 12px;\n border: 1px solid var(--nile-colors-primary-600, var(--ng-colors-border-brand));\n border-radius: 4px;\n }\n nile-button.rte-link-button::part(base) {\n border: none;\n height: 32px; \n width: 32px;\n }\n nile-button.rte-edit-button::part(base) {\n border: none;\n height: 38px; \n width: 38px;\n }\n ")}injectCss(e){if(this.querySelector("style[data-rte-link-style]"))return;const t=document.createElement("style");t.setAttribute("data-rte-link-style","true"),t.textContent=e,this.insertBefore(t,this.firstChild)}normalizeUrl(e){return/^(https?:|mailto:|tel:)/i.test(e)?e:`https://${e}`}displayUrl(e){return e.replace(/^https?:\/\//i,"")}getSelectionRect(){if(!this.selectionRange)return null;let e=this.selectionRange.getBoundingClientRect();if(0===e.width&&0===e.height){const t=document.createElement("span");t.textContent="​";this.selectionRange.cloneRange().insertNode(t),e=t.getBoundingClientRect(),t.remove()}return e}positionPopover(){const e=this.getSelectionRect();e&&(this.popoverStyle=`\n position: fixed;\n top: ${e.bottom+8}px;\n left: ${e.left+e.width/2}px;\n transform: translateX(-50%);\n z-index: 1000;\n `)}openPopover(){requestAnimationFrame((()=>{const e=this.querySelector("nile-popover");e&&(e.isShow=!0),window.addEventListener("scroll",this.onScroll,!0)}))}closePopover(){const e=this.querySelector("nile-popover");e&&(e.isShow=!1),window.removeEventListener("scroll",this.onScroll,!0),this.linkValue="",this.selectionRange=null,this.activeAnchor=null,this.hasActiveLink=!1,this.popoverStyle=""}unwrapLink(e){for(;e.firstChild;)e.parentNode?.insertBefore(e.firstChild,e);e.remove()}onOpen(){const e=document.getSelection();if(!e||0===e.rangeCount)return;this.selectionRange=e.getRangeAt(0).cloneRange(),this.activeAnchor=null,this.hasActiveLink=!1;let t=this.selectionRange.startContainer;for(;t&&t!==this.editorEl;){if(t instanceof HTMLAnchorElement){this.activeAnchor=t,this.hasActiveLink=!0;break}t=t.parentNode}this.linkValue=this.activeAnchor?this.displayUrl(this.activeAnchor.href):"",this.positionPopover(),this.openPopover(),requestAnimationFrame((()=>{this.querySelector(".link-input")?.focus()}))}onInputKeydown(e){if("Escape"===e.key||"Enter"===e.key)if(e.preventDefault(),e.stopPropagation(),"Escape"!==e.key){this.isApplying=!0;try{this.applyLink()}finally{this.isApplying=!1}}else this.closePopover()}onInputBlur(){this.ignoreBlur||this.isApplying||this.closePopover()}applyLink(){if(!(this.selectionRange instanceof Range))return;let e,t=this.linkValue.trim();if(!t)return;try{if(e=new URL(t,window.location.href),!["http:","https:","mailto:","tel:"].includes(e.protocol))return}catch{return}t=e.href,t=this.normalizeUrl(t),this.editorEl.focus();const i=document.getSelection();if(i){if(i.removeAllRanges(),i.addRange(this.selectionRange),this.activeAnchor)this.activeAnchor.href=t,this.newTab?(this.activeAnchor.target="_blank",this.activeAnchor.rel="noopener noreferrer"):(this.activeAnchor.removeAttribute("target"),this.activeAnchor.removeAttribute("rel"));else{const e=document.createElement("a");if(e.href=t,this.newTab?(e.target="_blank",e.rel="noopener noreferrer"):(e.removeAttribute("target"),e.removeAttribute("rel")),this.selectionRange.collapsed)e.textContent=t,this.selectionRange.insertNode(e);else try{this.selectionRange.surroundContents(e)}catch{const t=this.selectionRange.extractContents();e.appendChild(t),this.selectionRange.insertNode(e)}}this.emit(t),this.closePopover()}}onRemove(){this.activeAnchor&&(this.unwrapLink(this.activeAnchor),this.emit(""),this.closePopover())}emit(e){this.dispatchEvent(new CustomEvent("nile-link-changed",{detail:{href:e},bubbles:!0,composed:!0}))}render(){return R`
15488
- <nile-lite-tooltip content=${this.label}>
15489
- <nile-button
15490
- variant="tertiary"
15491
- size="small"
15492
- @mousedown=${e=>e.preventDefault()}
15493
- @click=${()=>this.onOpen()}
15494
- class="rte-link-button"
15495
- >
15496
- <nile-icon name="link_2"></nile-icon>
15497
- </nile-button>
15498
- </nile-lite-tooltip>
15487
+ `}};e([ce({type:String,attribute:!0,reflect:!0})],Cm.prototype,"mode",void 0),e([ce({type:String,attribute:!0,reflect:!0})],Cm.prototype,"label",void 0),e([ce({type:String,attribute:!0,reflect:!0})],Cm.prototype,"value",void 0),e([ce({type:Array,attribute:!0,reflect:!0})],Cm.prototype,"palette",void 0),e([De()],Cm.prototype,"recentColors",void 0),Cm=e([Ne("nile-rte-color")],Cm);let fm=class extends ae{createRenderRoot(){return this}shouldUpdate(){return!1}};fm=e([Ne("nile-rte-divider")],fm);let vm=class extends ae{createRenderRoot(){return this}shouldUpdate(){return!1}};vm=e([Ne("nile-rte-preview")],vm);let Um=class extends ae{constructor(){super(...arguments),this.displayFormat=!1,this.mentions={},this.mentionFormat={},this.itemsFormats={},this.mentionColors={},this.externalConfig={},this.itemsConfig={},this.mentionActiveIndex=-1,this.itemsColors={},this.editorEl=null,this.hostEl=null,this.dropdownEl=null,this.menuEl=null,this.lastRange=null,this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionSuggestions=[],this.mentionFiltered=[],this.mentionX=0,this.mentionY=0,this.triggerBtn=null,this.mo=null,this.onSelectionChange=()=>{if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);this.editorEl.contains(t.commonAncestorContainer)&&(this.lastRange=t.cloneRange())},this.saveSelection=()=>{const e=window.getSelection();e&&e.rangeCount&&(this.lastRange=e.getRangeAt(0).cloneRange())},this.onEditorInput=()=>{if(this.mentionOpen)return void this.handleMention();const e=window.getSelection();if(!e||!e.anchorNode)return;let t=e.anchorNode;if(t.nodeType!==Node.TEXT_NODE&&t.firstChild?.nodeType===Node.TEXT_NODE&&(t=t.firstChild),!t||t.nodeType!==Node.TEXT_NODE)return;const i=t.textContent||"",M=this.config;for(const t of Object.keys(M)){const M=i.lastIndexOf(t);if(-1!==M){const i=e.focusOffset;if(i>=M+t.length&&i<=M+t.length+1)return void this.openMention(t)}}},this.onEditorKeyUp=e=>{this.saveSelection();const t=e.key,i=this.config;if(t&&i[t])return this.mentionOpen&&this.mentionTrigger!==t&&this.closeMention(),void this.openMention(t);this.mentionOpen&&this.handleMention()},this.onEditorKeyDown=e=>{if(!this.mentionOpen)return;const t=e.key;if("ArrowDown"===t||"ArrowUp"===t){if(e.preventDefault(),!this.mentionFiltered.length)return;this.mentionActiveIndex="ArrowDown"===t?(this.mentionActiveIndex+1)%this.mentionFiltered.length:(this.mentionActiveIndex-1+this.mentionFiltered.length)%this.mentionFiltered.length,this.renderMentionList()}else"Enter"===t?this.mentionActiveIndex>=0&&this.mentionFiltered[this.mentionActiveIndex]&&(e.preventDefault(),this.selectMention(this.mentionFiltered[this.mentionActiveIndex])):"Escape"===t&&(e.preventDefault(),this.closeMention())},this.repositionMention=()=>{if(!this.mentionOpen||!this.hostEl||!this.triggerBtn)return;const e=this.getCaretClientRect();if(!e)return;const t=this.hostEl.getBoundingClientRect();this.mentionX=e.left-t.left,this.mentionY=e.bottom-t.top,this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`}}createRenderRoot(){return this}getTriggerFormat(e){const t=this.itemsFormats[e]||{},i=this.mentionFormat[e]||{};return{prefix:t.prefix??i.prefix??"",suffix:t.suffix??i.suffix??""}}formatLabel(e,t){const{prefix:i,suffix:M}=this.getTriggerFormat(e);return`${i??""}${t}${M??""}`}get config(){return{...this.externalConfig,...this.mentions,...this.itemsConfig}}attach(e,t){this.editorEl=e,this.hostEl=t,this.injectStyles(),this.ensureMentionDropdown(),this.rebuildConfigFromChildren(),this.mo=new MutationObserver((()=>this.rebuildConfigFromChildren())),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0}),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.saveSelection),this.editorEl.addEventListener("keyup",this.onEditorKeyUp),this.editorEl.addEventListener("keydown",this.onEditorKeyDown),this.editorEl.addEventListener("scroll",this.repositionMention),document.addEventListener("selectionchange",this.onSelectionChange,!0)}detach(){this.mo&&(this.mo.disconnect(),this.mo=null),this.editorEl&&(this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.saveSelection),this.editorEl.removeEventListener("keyup",this.onEditorKeyUp),this.editorEl.removeEventListener("keydown",this.onEditorKeyDown),this.editorEl.removeEventListener("scroll",this.repositionMention)),document.removeEventListener("selectionchange",this.onSelectionChange,!0)}setExternalConfig(e){this.externalConfig=e||{}}disconnectedCallback(){this.detach(),super.disconnectedCallback()}rebuildConfigFromChildren(){const e={},t={},i={},M=Array.from(this.querySelectorAll("nile-rte-mentions-item"));for(const n of M){const M=n.mentionsCharacter??n.getAttribute("mentionscharacter")??"";if(!M||"string"!=typeof M)continue;let o=n.mentionsData??(()=>{const e=n.getAttribute("mentionsdata");if(!e)return null;try{const t=JSON.parse(e);return Array.isArray(t)?t.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)):[]}catch{return[]}})();const r=n.mentionsColor??n.getAttribute("mentionscolor")??"",s=n.mentionsPrefix??n.getAttribute("mentionsprefix")??"",a=n.mentionsSuffix??n.getAttribute("mentionssuffix")??"";Array.isArray(o)||(o=[]),e[M]=o,r&&(t[M]=String(r)),(s||a)&&(i[M]={prefix:s,suffix:a})}this.itemsConfig=e,this.itemsColors=t,this.itemsFormats=i}injectStyles(){if(this.querySelector("style[data-mentions-style]"))return;const e=document.createElement("style");e.setAttribute("data-mentions-style","true"),e.textContent="\n .mention-dropdown {\n position: absolute; z-index: 1000; list-style: none; margin: 0; padding: 4px;\n border: 1px solid #e5e7eb; border-radius: 6px; background: #fff;\n box-shadow: 0 4px 10px rgba(0,0,0,.08); max-height: 180px; overflow: auto; font-size: 14px;\n }\n .mention-dropdown li { padding: 6px 8px; cursor: pointer; border-radius: 4px; }\n .mention-dropdown li:hover { background: #f1f5f9; }\n .mention { background: #eef2ff; padding: 0 3px; border-radius: 3px; }\n nile-menu.mentions-menu::part(menu__items-wrapper){\n max-height: 260px;\n overflow-y: auto;\n }\n .mentions-menu nile-menu-item.active {\n background: #dbeafe; /* highlight */\n outline: none;\n}\n\n\n ",this.insertBefore(e,this.firstChild)}getTriggerColor(e){return this.itemsColors[e]??this.mentionColors[e]}ensureMentionDropdown(){if(this.dropdownEl||!this.hostEl)return;const e=document.createElement("nile-dropdown");e.style.zIndex="1000";const t=document.createElement("nile-button");t.setAttribute("slot","trigger"),t.style.position="absolute",t.style.width="1px",t.style.height="1px",t.style.border="0",t.style.padding="0",t.style.opacity="0",t.style.pointerEvents="none",e.appendChild(t),this.triggerBtn=t;const i=document.createElement("nile-menu");i.classList.add("mentions-menu"),e.appendChild(i),this.hostEl.appendChild(e),this.dropdownEl=e,this.menuEl=i}restoreSelection(){if(!this.lastRange)return;const e=document.getSelection();e&&(e.removeAllRanges(),e.addRange(this.lastRange))}getCaretClientRect(){const e=document.getSelection();if(!e||0===e.rangeCount)return null;const t=e.getRangeAt(0).cloneRange();t.collapse(!1);const i=t.getClientRects();if(i&&i.length>0)return i[0];const M=document.createElement("span");M.setAttribute("data-caret-marker","1"),M.textContent="​",t.insertNode(M);const n=M.getBoundingClientRect(),o=document.createRange();return o.setStartAfter(M),o.collapse(!0),e.removeAllRanges(),e.addRange(o),M.remove(),n||null}openMention(e){if(this.saveSelection(),!this.editorEl||!this.dropdownEl||!this.hostEl)return;const t=this.getCaretClientRect();if(!t)return;const i=this.hostEl.getBoundingClientRect();this.mentionX=t.left-i.left,this.mentionY=t.bottom-i.top,this.mentionTrigger=e,this.mentionSuggestions=this.config[e]||[],this.mentionQuery="",this.updateMentionFiltered(),this.mentionActiveIndex=this.mentionFiltered.length?0:-1,this.mentionOpen=!0,this.renderMentionList(),this.dispatchEvent(new CustomEvent("nile-mention-opened",{detail:{trigger:e,suggestions:this.mentionSuggestions},bubbles:!0,composed:!0}))}closeMention(){this.mentionOpen=!1,this.mentionTrigger=null,this.mentionQuery="",this.mentionFiltered=[],this.dropdownEl?.removeAttribute("open")}handleMention(){if(!this.mentionOpen||!this.mentionTrigger)return;const e=window.getSelection();if(!e||!e.anchorNode)return;let t=e.anchorNode;if(t.nodeType!==Node.TEXT_NODE){const i=t.childNodes?.[e.anchorOffset]||t.firstChild;i?.nodeType===Node.TEXT_NODE&&(t=i)}const i=t&&t.nodeType===Node.TEXT_NODE&&t.textContent||"",M=i.lastIndexOf(this.mentionTrigger);M>=0?(this.mentionQuery=i.substring(M+1),this.updateMentionFiltered(),this.renderMentionList()):this.closeMention()}updateMentionFiltered(){const e=this.mentionQuery.toLowerCase();this.mentionFiltered=(this.mentionSuggestions||[]).filter((t=>t.label.toLowerCase().startsWith(e)))}renderMentionList(){this.dropdownEl&&this.menuEl&&this.triggerBtn&&(this.triggerBtn.style.left=`${this.mentionX}px`,this.triggerBtn.style.top=`${this.mentionY}px`,this.menuEl.innerHTML="",this.mentionOpen&&this.mentionFiltered.length?(this.mentionFiltered.forEach(((e,t)=>{const i=document.createElement("nile-menu-item");i.textContent=e.label,i.setAttribute("role","option"),t===this.mentionActiveIndex?(i.classList.add("active"),i.setAttribute("aria-selected","true")):(i.classList.remove("active"),i.removeAttribute("aria-selected")),i.addEventListener("mouseenter",(()=>{this.mentionActiveIndex=t,this.renderMentionList()})),i.addEventListener("pointerdown",(t=>{t.preventDefault(),this.selectMention(e)})),this.menuEl?.appendChild(i)})),this.dropdownEl.setAttribute("open","")):this.dropdownEl.removeAttribute("open"))}selectMention(e){if(this.restoreSelection(),!this.lastRange||!this.mentionTrigger||!this.editorEl)return;const t=this.mentionTrigger;let i=this.lastRange.startContainer,M=this.lastRange.startOffset;if(i.nodeType!==Node.TEXT_NODE){const e=i.childNodes[M];if(e?.nodeType!==Node.TEXT_NODE)return;i=e,M=0}const n=i,o=(n.textContent||"").lastIndexOf(this.mentionTrigger,M);if(o<0)return;const r=o+1+this.mentionQuery.length,s=document.createRange();s.setStart(n,o),s.setEnd(n,r),s.deleteContents();const a=document.createElement("span");a.classList.add("mention");const l=this.getTriggerFormat(this.mentionTrigger);this.displayFormat?a.textContent=`${l.prefix??""}${e.label}${l.suffix??""}`:(a.textContent=`${this.mentionTrigger}${e.label}`,l.prefix&&a.setAttribute("data-mention-prefix",l.prefix),l.suffix&&a.setAttribute("data-mention-suffix",l.suffix)),a.setAttribute("data-mention-key",e.key),a.setAttribute("data-mention-label",e.label),a.setAttribute("data-mention-trigger",this.mentionTrigger);const N=this.getTriggerColor(this.mentionTrigger);N&&(a.style.backgroundColor=N),s.insertNode(a);const g=document.createTextNode(" ");a.after(g);const u=window.getSelection(),c=document.createRange();c.setStartAfter(g),c.collapse(!0),u?.removeAllRanges(),u?.addRange(c),this.lastRange=c.cloneRange(),this.closeMention(),this.dispatchEvent(new CustomEvent("nile-mention-selected",{detail:{trigger:t,key:e.key,label:e.label,prefix:l.prefix??"",suffix:l.suffix??""},bubbles:!0,composed:!0})),this.editorEl.dispatchEvent(new InputEvent("input",{bubbles:!0}))}};e([ce({type:Boolean,attribute:"displayformat",reflect:!0})],Um.prototype,"displayFormat",void 0),e([ce({attribute:"mentions",converter:{fromAttribute:e=>{try{const t=JSON.parse(e),i={};for(const e of Object.keys(t)){const M=t[e];Array.isArray(M)&&(i[e]=M.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)).map((e=>({key:e.key,label:e.label}))))}return i}catch{return{}}},toAttribute:e=>JSON.stringify(e)}})],Um.prototype,"mentions",void 0),e([ce({attribute:"mentionformat",converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch{return{}}},toAttribute:e=>JSON.stringify(e??{})}})],Um.prototype,"mentionFormat",void 0),e([De()],Um.prototype,"itemsFormats",void 0),e([ce({attribute:"mentioncolors",converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch{return{}}},toAttribute:e=>JSON.stringify(e??{})}})],Um.prototype,"mentionColors",void 0),e([De()],Um.prototype,"externalConfig",void 0),e([De()],Um.prototype,"itemsConfig",void 0),e([De()],Um.prototype,"mentionActiveIndex",void 0),e([De()],Um.prototype,"itemsColors",void 0),Um=e([Ne("nile-rte-mentions")],Um);let Ym=class extends ae{constructor(){super(...arguments),this.newTab=!1,this.disabled=!1,this.showTextSupport=!1,this.placeholder="Type or paste link here",this.textPlaceholder="Display text",this.label="Link",this.linkValue="",this.textValue="",this.hasActiveLink=!1,this.popoverStyle="",this.selectionRange=null,this.activeAnchor=null,this.ignoreBlur=!1,this.isApplying=!1,this.onScroll=()=>{this.closePopover()},this.onOpen=()=>{if(this.disabled)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;if(!this.editorEl.contains(e.getRangeAt(0).commonAncestorContainer))return;this.selectionRange=e.getRangeAt(0).cloneRange(),this.activeAnchor=null,this.hasActiveLink=!1;let t=this.selectionRange.startContainer;for(;t&&t!==this.editorEl;){if(t instanceof HTMLAnchorElement){this.activeAnchor=t,this.hasActiveLink=!0;break}t=t.parentNode}this.linkValue=this.activeAnchor?this.displayUrl(this.activeAnchor.href):"",this.showTextSupport&&(this.activeAnchor?this.textValue=this.activeAnchor.textContent||"":this.selectionRange.collapsed?this.textValue="":this.textValue=this.selectionRange.toString()),this.positionPopover(),this.openPopover(),requestAnimationFrame((()=>{const e=this.querySelectorAll("nile-input"),t=e.length>1?e[1]:e[0];t?.focus()}))},this.onInputKeydown=e=>{if("Escape"===e.key||"Enter"===e.key)if(e.preventDefault(),e.stopPropagation(),"Escape"!==e.key){this.isApplying=!0;try{this.applyLink()}finally{this.isApplying=!1}}else this.closePopover()},this.onInputBlur=()=>{this.ignoreBlur||this.isApplying||requestAnimationFrame((()=>{if(this.ignoreBlur||this.isApplying)return;const e=this.querySelector("nile-popover");e?.matches(":focus-within")||this.closePopover()}))},this.onLinkInput=e=>{this.linkValue=e.detail.value},this.onTextInput=e=>{this.textValue=e.detail.value},this.onPopoverMousedown=()=>{this.ignoreBlur=!0},this.onPopoverMouseup=()=>{this.ignoreBlur=!1},this.onToolbarButtonMousedown=e=>{e.preventDefault()},this.onActionMousedown=e=>{e.preventDefault(),this.ignoreBlur=!0},this.onApplyClick=()=>{this.isApplying=!0,this.applyLink(),this.isApplying=!1,this.ignoreBlur=!1},this.onUnlinkClick=()=>{this.isApplying=!0,this.onRemove(),this.isApplying=!1,this.ignoreBlur=!1}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.injectCss("\n nile-popover.rte-link-popover::part(popover) {\n min-width: 340px;\n max-width: 420px;\n background: white;\n border: 1px solid var(--nile-colors-neutral-400, var(--ng-componentcolors-utility-gray-400));\n border-radius: 8px;\n padding: 0;\n gap: 0;\n overflow: hidden;\n height: auto;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);\n }\n\n .link-popup-wrap {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px;\n }\n\n .link-popup-wrap nile-input {\n width: 100%;\n }\n\n .link-popup-wrap .link-input-row {\n width: 100%;\n }\n\n .link-popup-wrap .link-actions-row {\n display: flex;\n align-items: flex-end;\n gap: 4px;\n width: 100%;\n }\n\n .link-popup-wrap .link-actions-row nile-input {\n flex: 1;\n min-width: 0;\n }\n\n \n nile-button.rte-link-button::part(base) {\n border: none;\n height: 32px;\n width: 32px;\n }\n nile-button.rte-edit-button::part(base) {\n border: none;\n height: 32px;\n width: 32px;\n flex-shrink: 0;\n }\n ")}injectCss(e){if(this.querySelector("style[data-rte-link-style]"))return;const t=document.createElement("style");t.setAttribute("data-rte-link-style","true"),t.textContent=e,this.insertBefore(t,this.firstChild)}normalizeUrl(e){return/^(https?:|mailto:|tel:)/i.test(e)?e:`https://${e}`}displayUrl(e){return e}getSelectionRect(){if(!this.selectionRange)return null;let e=this.selectionRange.getBoundingClientRect();if(0===e.width&&0===e.height){const t=document.createElement("span");t.textContent="​";this.selectionRange.cloneRange().insertNode(t),e=t.getBoundingClientRect(),t.remove()}return e}positionPopover(){const e=this.getSelectionRect();e&&(this.popoverStyle=`\n position: fixed;\n top: ${e.bottom+8}px;\n left: ${e.left+e.width/2}px;\n transform: translateX(-50%);\n z-index: 1000;\n `)}openPopover(){requestAnimationFrame((()=>{const e=this.querySelector("nile-popover");e&&(e.isShow=!0),window.addEventListener("scroll",this.onScroll,!0)}))}closePopover(){const e=this.querySelector("nile-popover");e&&(e.isShow=!1),window.removeEventListener("scroll",this.onScroll,!0),this.linkValue="",this.textValue="",this.selectionRange=null,this.activeAnchor=null,this.hasActiveLink=!1,this.popoverStyle=""}unwrapLink(e){for(;e.firstChild;)e.parentNode?.insertBefore(e.firstChild,e);e.remove()}applyLink(){if(!(this.selectionRange instanceof Range))return;let e=this.linkValue.trim();if(!e)return;if(/^javascript:/i.test(e))return;/^(https?:\/\/|mailto:|tel:|\/)/i.test(e)||(e=`https://${e}`),this.editorEl.focus();const t=document.getSelection();if(!t)return;t.removeAllRanges(),t.addRange(this.selectionRange);const i=this.showTextSupport&&this.textValue.trim()?this.textValue.trim():"";if(this.activeAnchor)this.activeAnchor.href=e,i&&(this.activeAnchor.textContent=i),this.newTab?(this.activeAnchor.target="_blank",this.activeAnchor.rel="noopener noreferrer"):(this.activeAnchor.removeAttribute("target"),this.activeAnchor.removeAttribute("rel"));else{const t=document.createElement("a");if(t.href=e,this.newTab?(t.target="_blank",t.rel="noopener noreferrer"):(t.removeAttribute("target"),t.removeAttribute("rel")),i)this.selectionRange.deleteContents(),t.textContent=i,this.selectionRange.insertNode(t);else if(this.selectionRange.collapsed)t.textContent=e,this.selectionRange.insertNode(t);else try{this.selectionRange.surroundContents(t)}catch{const e=this.selectionRange.extractContents();t.appendChild(e),this.selectionRange.insertNode(t)}}this.emit(e),this.closePopover()}onRemove(){this.activeAnchor&&(this.unwrapLink(this.activeAnchor),this.emit(""),this.closePopover())}emit(e){this.dispatchEvent(new CustomEvent("nile-link-changed",{detail:{href:e},bubbles:!0,composed:!0}))}render(){const e=this.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))";return R`
15488
+ <nile-lite-tooltip content=${this.label}>
15489
+ <nile-button
15490
+ variant="tertiary"
15491
+ size="small"
15492
+ ?disabled=${this.disabled}
15493
+ @mousedown=${this.onToolbarButtonMousedown}
15494
+ @click=${this.onOpen}
15495
+ class="rte-link-button"
15496
+ >
15497
+ <nile-icon name="link_2" color=${e}></nile-icon>
15498
+ </nile-button>
15499
+ </nile-lite-tooltip>
15499
15500
 
15500
15501
  <nile-popover
15501
15502
  class="rte-link-popover"
15502
15503
  .arrow=${!1}
15503
15504
  style=${this.popoverStyle}
15504
- @mousedown=${()=>this.ignoreBlur=!0}
15505
- @mouseup=${()=>this.ignoreBlur=!1}
15505
+ @mousedown=${this.onPopoverMousedown}
15506
+ @mouseup=${this.onPopoverMouseup}
15506
15507
  >
15507
- <div class="link-popup">
15508
- <input
15509
- class="link-input"
15510
- placeholder=${this.placeholder}
15511
- .value=${this.linkValue}
15512
- @input=${e=>this.linkValue=e.target.value}
15513
- @keydown=${this.onInputKeydown}
15514
- @blur=${this.onInputBlur}
15515
- />
15516
-
15517
- ${this.hasActiveLink?R`
15518
- <nile-button
15519
- size="small"
15520
- variant="tertiary"
15521
- class="rte-edit-button"
15522
- @click=${()=>this.applyLink()}
15523
- >
15524
- <nile-icon name="pencil"></nile-icon>
15525
- </nile-button>
15526
-
15527
- <nile-button
15528
- size="small"
15529
- variant="tertiary"
15530
- class="rte-edit-button"
15531
- @click=${()=>this.onRemove()}
15532
- >
15533
- <nile-icon name="unlink"></nile-icon>
15534
- </nile-button>
15535
- `:null}
15508
+ <div class="link-popup-wrap">
15509
+ ${this.showTextSupport?R`
15510
+ <div class="link-input-row">
15511
+ <nile-input
15512
+ label="Text"
15513
+ placeholder=${this.textPlaceholder}
15514
+ .value=${this.textValue}
15515
+ @nile-input=${this.onTextInput}
15516
+ @keydown=${this.onInputKeydown}
15517
+ @nile-blur=${this.onInputBlur}
15518
+ ></nile-input>
15519
+ </div>
15520
+ `:null}
15521
+ <div class="link-actions-row">
15522
+ <nile-input
15523
+ label=${this.showTextSupport?"URL":""}
15524
+ placeholder=${this.placeholder}
15525
+ .value=${this.linkValue}
15526
+ @nile-input=${this.onLinkInput}
15527
+ @keydown=${this.onInputKeydown}
15528
+ @nile-blur=${this.onInputBlur}
15529
+ ></nile-input>
15530
+ ${this.hasActiveLink?R`
15531
+ <nile-button
15532
+ size="small"
15533
+ variant="tertiary"
15534
+ class="rte-edit-button"
15535
+ @mousedown=${this.onActionMousedown}
15536
+ @click=${this.onApplyClick}
15537
+ >
15538
+ <nile-icon name="pencil"></nile-icon>
15539
+ </nile-button>
15540
+ <nile-button
15541
+ size="small"
15542
+ variant="tertiary"
15543
+ class="rte-edit-button"
15544
+ @mousedown=${this.onActionMousedown}
15545
+ @click=${this.onUnlinkClick}
15546
+ >
15547
+ <nile-icon name="unlink"></nile-icon>
15548
+ </nile-button>
15549
+ `:null}
15550
+ </div>
15536
15551
  </div>
15537
15552
  </nile-popover>
15538
- `}};function Zm(e,t){for(;e&&e!==t;){if(e instanceof HTMLElement){const t=getComputedStyle(e).display;if(e.tagName.match(/^(P|DIV|H1|H2|H3|H4|H5|H6|LI)$/)||"block"===t||"list-item"===t)return e}e=e?.parentNode||null}return t}function Vm(e,t){const i=window.getSelection();if(!i||0===i.rangeCount)return;const M=i.getRangeAt(0),n=M.commonAncestorContainer,o=[],r=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t=e;return M.intersectsNode(t)&&/^(P|DIV|LI|H[1-6])$/.test(t.tagName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let s=r.nextNode();for(;s;)o.push(s),s=r.nextNode();if(0===o.length){const t=Zm(i.focusNode,e);t&&o.push(t)}o.forEach((e=>{e.style.textAlign=t}))}function Wm(e,t,i){const M=window.getSelection();if(!M||0===M.rangeCount)return;const n=M.getRangeAt(0),o={strong:["strong","b"],em:["em","i"],u:["u"],span:["span"]}[t]??[t],r=e=>o.includes(e.tagName.toLowerCase());function s(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function a(e){e.querySelectorAll(o.join(",")).forEach((e=>{if(!e.textContent?.trim())return void e.remove();Array.from(e.querySelectorAll(o.join(","))).forEach((t=>{if(t!==e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}}))}))}function l(e){Array.from(e.querySelectorAll(o.join(","))).forEach((e=>{const t=e.nextSibling;if(t instanceof HTMLElement&&r(t)){for(;t.firstChild;)e.appendChild(t.firstChild);t.remove()}}))}if(n.collapsed){let o=!1,N=n.startContainer;for(;N&&N!==e;){if(N instanceof HTMLElement&&r(N)){o=!0;break}N=N.parentNode}if(o&&N instanceof HTMLElement)s(N);else{const e=document.createElement(t);i&&Object.entries(i).forEach((([t,i])=>e.setAttribute(t,i))),e.appendChild(document.createTextNode("​")),n.insertNode(e),n.setStart(e.firstChild,1),n.collapse(!0),M.removeAllRanges(),M.addRange(n)}return a(e),void l(e)}n.startContainer.nodeType===Node.TEXT_NODE&&n.startContainer.splitText(n.startOffset),n.endContainer.nodeType===Node.TEXT_NODE&&n.endContainer.splitText(n.endOffset);const N=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:e=>{if(!e.nodeValue?.trim())return NodeFilter.FILTER_REJECT;const t=document.createRange();t.selectNodeContents(e);return n.compareBoundaryPoints(Range.END_TO_START,t)<0&&n.compareBoundaryPoints(Range.START_TO_END,t)>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),g=[];let u;for(;u=N.nextNode();)g.push(u);const c=g.length>0&&g.every((t=>{let i=t;for(;i&&i!==e;){if(i instanceof HTMLElement&&r(i))return!0;i=i.parentNode}return!1}));if(c){const i=g[0],M=g[g.length-1],n=i.parentElement?.closest(t);if(n&&n.contains(M)){const e=n.parentNode;if(e){const o=document.createRange();o.setStartBefore(n),o.setEndBefore(i);const r=o.cloneContents(),s=document.createRange();s.setStartAfter(M),s.setEndAfter(n);const a=s.cloneContents(),l=document.createRange();l.setStartBefore(i),l.setEndAfter(M);const N=l.extractContents(),g=document.createDocumentFragment();if(r.childNodes.length){const e=document.createElement(t);for(;r.firstChild;)e.appendChild(r.firstChild);g.appendChild(e)}for(;N.firstChild;)g.appendChild(N.firstChild);if(a.childNodes.length){const e=document.createElement(t);for(;a.firstChild;)e.appendChild(a.firstChild);g.appendChild(e)}e.insertBefore(g,n),e.removeChild(n)}}else g.forEach((t=>{let i=t;for(;i&&i!==e;){if(i instanceof HTMLElement&&r(i)){s(i);break}i=i.parentNode}}))}else g.forEach((e=>{const M=e.parentElement?.closest("a, .mention, nile-mention");if(M)return;const n=document.createElement(t);i&&Object.entries(i).forEach((([e,t])=>n.setAttribute(e,t))),e.parentNode?.insertBefore(n,e),n.appendChild(e)}));a(e),l(e),M.removeAllRanges(),M.addRange(n)}function Pm(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(!t)return"#000000";return`#${Number(t[1]).toString(16).padStart(2,"0")}${Number(t[2]).toString(16).padStart(2,"0")}${Number(t[3]).toString(16).padStart(2,"0")}`}function Rm(e,t){const i=document.getSelection();if(!i||0===i.rangeCount)return;const M=i.getRangeAt(0);if(M.collapsed){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),M.insertNode(e);const n=document.createRange();return n.setStart(e.firstChild,1),n.collapse(!0),i.removeAllRanges(),void i.addRange(n)}!function(e,t,i){const M=document.createElement(t);i&&Object.entries(i).forEach((([e,t])=>M.setAttribute(e,t)));try{e.surroundContents(M)}catch{const t=e.extractContents();M.appendChild(t),e.insertNode(M)}}(M,"span",{style:`font-family:${t}`})}function Bm(e,t,i){for(;t&&t!==e;){if(t instanceof HTMLSpanElement&&t.hasAttribute(i))return t;t=t.parentNode}return null}function Gm(e,t,i,M){const n=window.getSelection();if(!n||0===n.rangeCount)return;const o=n.getRangeAt(0);if(!e.contains(o.commonAncestorContainer))return;const r=o.cloneRange();if(r.collapsed){const o=Bm(e,r.startContainer,M);if(o)return o.style[t]=i,void _m(e,M,t);const s=document.createElement("span");s.setAttribute(M,"1"),s.style[t]=i,s.appendChild(document.createTextNode("​")),r.insertNode(s);const a=document.createRange();return a.setStart(s.firstChild,1),a.collapse(!0),n.removeAllRanges(),n.addRange(a),void _m(e,M,t)}const s=Bm(e,r.startContainer,M),a=Bm(e,r.endContainer,M);if(s&&s===a){if(function(e,t){const i=document.createRange();return i.selectNodeContents(t),e.compareBoundaryPoints(Range.START_TO_START,i)<=0&&e.compareBoundaryPoints(Range.END_TO_END,i)>=0}(r,s))s.style[t]=i;else{const e=function(e,t,i,M,n){const o=e.style[M],r=document.createRange();r.setStart(e,0),r.setEnd(t.startContainer,t.startOffset);const s=document.createRange();s.setStart(t.endContainer,t.endOffset),s.setEnd(e,e.childNodes.length);const a=document.createDocumentFragment(),l=e=>{const t=document.createElement("span");return t.setAttribute(i,"1"),t.style[M]=e,t};if(Fm(r)){const e=l(o);e.appendChild(r.cloneContents()),a.appendChild(e)}const N=l(n);if(N.appendChild(t.cloneContents()),a.appendChild(N),Fm(s)){const e=l(o);e.appendChild(s.cloneContents()),a.appendChild(e)}return e.replaceWith(a),N}(s,r,M,t,i),n=window.getSelection(),o=document.createRange();o.selectNodeContents(e),n?.removeAllRanges(),n?.addRange(o)}return void _m(e,M,t)}const l=(()=>{let e=r.commonAncestorContainer;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e})(),N=document.createTreeWalker(l||e,NodeFilter.SHOW_TEXT,{acceptNode:e=>{if(!e.nodeValue||!e.nodeValue.trim())return NodeFilter.FILTER_REJECT;const t=document.createRange();t.selectNodeContents(e);return r.compareBoundaryPoints(Range.END_TO_START,t)<0&&r.compareBoundaryPoints(Range.START_TO_END,t)>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),g=[];let u;for(;u=N.nextNode();)g.push(u);g.forEach((n=>{let o=0,s=n.length;n===r.startContainer&&(o=r.startOffset),n===r.endContainer&&(s=r.endOffset),o>0&&(n=n.splitText(o)),s<n.length&&n.splitText(s);const a=Bm(e,n,M);if(a)return void(a.style[t]=i);const l=document.createElement("span");l.setAttribute(M,"1"),l.style[t]=i;n.parentElement.replaceChild(l,n),l.appendChild(n)})),_m(e,M,t),n.removeAllRanges(),n.addRange(r)}function _m(e,t,i){const M=Array.from(e.querySelectorAll(`span[${t}]`)),n=e=>e.style[i];M.forEach((e=>{Array.from(e.querySelectorAll(`span[${t}]`)).forEach((t=>{if(n(t)===n(e)){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}}));const i=e.previousSibling;if(i instanceof HTMLSpanElement&&i.hasAttribute(t)&&n(i)===n(e)){for(;e.firstChild;)i.appendChild(e.firstChild);return void e.remove()}const M=e.nextSibling;if(M instanceof HTMLSpanElement&&M.hasAttribute(t)&&n(M)===n(e)){for(;M.firstChild;)e.appendChild(M.firstChild);M.remove()}}))}function Fm(e){if(e.collapsed)return!1;return(e.cloneContents().textContent||"").length>0}function Hm(e,t){const i=document.getSelection();if(!i||0===i.rangeCount)return;const M=i.getRangeAt(0);function n(e){e.style.paddingInlineStart="0",e.style.margin="0"}function o(e){const t=document.getSelection();if(!t)return;const i=document.createRange();i.selectNodeContents(e),i.collapse(!0),t.removeAllRanges(),t.addRange(i)}function r(t){for(;t&&t!==e;){if(t instanceof HTMLElement){const e=getComputedStyle(t).display;if(t.tagName.match(/^(P|DIV|H[1-6]|LI)$/)||"block"===e||"list-item"===e)return t}t=t.parentNode}return null}function s(e,t){const i=document.createElement(t);for(n(i);e.firstChild;)i.appendChild(e.firstChild);e.replaceWith(i)}if(M.collapsed){const i=r(M.startContainer),l=i?.closest("ul,ol");if(l&&l.tagName.toLowerCase()===t)return void function(e){const t=e.closest("li");if(!t)return;const i=t.parentElement,M=document.createElement("p");for(t.style.textAlign&&(M.style.textAlign=t.style.textAlign);t.firstChild;)M.appendChild(t.firstChild);i.parentNode?.insertBefore(M,i.nextSibling),t.remove(),0===i.childNodes.length&&i.remove(),o(M)}(i);if(l&&l.tagName.toLowerCase()!==t)return void s(l,t);if(!i||i===e||0===i.childNodes.length||(a=i,!a.textContent?.trim()&&!a.querySelector("img,br"))){const e=document.createElement(t),i=document.createElement("li");return i.appendChild(document.createElement("br")),e.appendChild(i),n(e),M.insertNode(e),void o(i)}const N=document.createElement(t);n(N);const g=document.createElement("li");for(i.style.textAlign&&(g.style.textAlign=i.style.textAlign);i.firstChild;)g.appendChild(i.firstChild);return N.appendChild(g),i.replaceWith(N),void o(g)}var a;const l=[],N=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(!(e instanceof HTMLElement))return NodeFilter.FILTER_SKIP;if(!/^(P|DIV|LI|H[1-6])$/.test(e.tagName))return NodeFilter.FILTER_SKIP;const t=document.createRange();t.selectNodeContents(e);return M.compareBoundaryPoints(Range.END_TO_START,t)<0&&M.compareBoundaryPoints(Range.START_TO_END,t)>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let g;for(;g=N.nextNode();)l.push(g);if(0===l.length){const e=r(M.startContainer);e&&l.push(e)}const u=l[0].closest("li");if(u){const e=u.closest("ul,ol");if(!e)return;return void(e.tagName.toLowerCase()===t?function(e){const t=document.createDocumentFragment();Array.from(e.querySelectorAll("li")).forEach((e=>{const i=document.createElement("p");for(e.style.textAlign&&(i.style.textAlign=e.style.textAlign);e.firstChild;)i.appendChild(e.firstChild);t.appendChild(i)})),e.replaceWith(t)}(e):s(e,t))}const c=document.createElement(t);n(c);for(const e of l){const t=document.createElement("li");for(e.style.textAlign&&(t.style.textAlign=e.style.textAlign);e.firstChild;)t.appendChild(e.firstChild);c.appendChild(t)}l[0].replaceWith(c);for(let e=1;e<l.length;e++)l[e].remove()}e([ce({attribute:!1})],Ym.prototype,"editorEl",void 0),e([ce({type:Boolean})],Ym.prototype,"newTab",void 0),e([ce({type:String})],Ym.prototype,"placeholder",void 0),e([ce({type:String})],Ym.prototype,"label",void 0),e([De()],Ym.prototype,"linkValue",void 0),e([De()],Ym.prototype,"hasActiveLink",void 0),e([De()],Ym.prototype,"popoverStyle",void 0),Ym=e([Ne("nile-rte-link")],Ym);const Jm=r`
15553
+ `}};function Zm(e,t){for(;e&&e!==t;){if(e instanceof HTMLElement){const t=getComputedStyle(e).display;if(e.tagName.match(/^(P|DIV|H1|H2|H3|H4|H5|H6|LI)$/)||"block"===t||"list-item"===t)return e}e=e?.parentNode||null}return t}function Vm(e,t){const i=window.getSelection();if(!i||0===i.rangeCount)return;const M=i.getRangeAt(0),n=M.commonAncestorContainer,o=[],r=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t=e;return M.intersectsNode(t)&&/^(P|DIV|LI|H[1-6])$/.test(t.tagName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let s=r.nextNode();for(;s;)o.push(s),s=r.nextNode();if(0===o.length){const t=Zm(i.focusNode,e);t&&o.push(t)}o.forEach((e=>{e.style.textAlign=t}))}function Wm(e,t,i){const M=window.getSelection();if(!M||0===M.rangeCount)return;const n=M.getRangeAt(0),o={strong:["strong","b"],em:["em","i"],u:["u"],span:["span"]}[t]??[t],r=e=>o.includes(e.tagName.toLowerCase());function s(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function a(e){e.querySelectorAll(o.join(",")).forEach((e=>{if(!e.textContent?.trim())return void e.remove();Array.from(e.querySelectorAll(o.join(","))).forEach((t=>{if(t!==e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}}))}))}function l(e){Array.from(e.querySelectorAll(o.join(","))).forEach((e=>{const t=e.nextSibling;if(t instanceof HTMLElement&&r(t)){for(;t.firstChild;)e.appendChild(t.firstChild);t.remove()}}))}if(n.collapsed){let o=!1,N=n.startContainer;for(;N&&N!==e;){if(N instanceof HTMLElement&&r(N)){o=!0;break}N=N.parentNode}if(o&&N instanceof HTMLElement)s(N);else{const e=document.createElement(t);i&&Object.entries(i).forEach((([t,i])=>e.setAttribute(t,i))),e.appendChild(document.createTextNode("​")),n.insertNode(e),n.setStart(e.firstChild,1),n.collapse(!0),M.removeAllRanges(),M.addRange(n)}return a(e),void l(e)}n.startContainer.nodeType===Node.TEXT_NODE&&n.startContainer.splitText(n.startOffset),n.endContainer.nodeType===Node.TEXT_NODE&&n.endContainer.splitText(n.endOffset);const N=document.createTreeWalker(n.commonAncestorContainer,NodeFilter.SHOW_TEXT,{acceptNode:e=>{if(!e.nodeValue?.trim())return NodeFilter.FILTER_REJECT;const t=document.createRange();t.selectNodeContents(e);return n.compareBoundaryPoints(Range.END_TO_START,t)<0&&n.compareBoundaryPoints(Range.START_TO_END,t)>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),g=[];let u;for(;u=N.nextNode();)g.push(u);const c=g.length>0&&g.every((t=>{let i=t;for(;i&&i!==e;){if(i instanceof HTMLElement&&r(i))return!0;i=i.parentNode}return!1}));if(c){const i=g[0],M=g[g.length-1],n=i.parentElement?.closest(t);if(n&&n.contains(M)){const e=n.parentNode;if(e){const o=document.createRange();o.setStartBefore(n),o.setEndBefore(i);const r=o.cloneContents(),s=document.createRange();s.setStartAfter(M),s.setEndAfter(n);const a=s.cloneContents(),l=document.createRange();l.setStartBefore(i),l.setEndAfter(M);const N=l.extractContents(),g=document.createDocumentFragment();if(r.childNodes.length){const e=document.createElement(t);for(;r.firstChild;)e.appendChild(r.firstChild);g.appendChild(e)}for(;N.firstChild;)g.appendChild(N.firstChild);if(a.childNodes.length){const e=document.createElement(t);for(;a.firstChild;)e.appendChild(a.firstChild);g.appendChild(e)}e.insertBefore(g,n),e.removeChild(n)}}else g.forEach((t=>{let i=t;for(;i&&i!==e;){if(i instanceof HTMLElement&&r(i)){s(i);break}i=i.parentNode}}))}else g.forEach((e=>{const M=e.parentElement?.closest(".mention, nile-mention");if(M)return;const n=e.parentElement?.closest("a");if(n&&"span"===t)return;const o=document.createElement(t);i&&Object.entries(i).forEach((([e,t])=>o.setAttribute(e,t))),n?(n.insertBefore(o,e),o.appendChild(e)):(e.parentNode?.insertBefore(o,e),o.appendChild(e))}));a(e),l(e),M.removeAllRanges(),M.addRange(n)}function Pm(e){const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);if(!t)return"#000000";return`#${Number(t[1]).toString(16).padStart(2,"0")}${Number(t[2]).toString(16).padStart(2,"0")}${Number(t[3]).toString(16).padStart(2,"0")}`}function Rm(e,t){const i=document.getSelection();if(!i||0===i.rangeCount)return;const M=i.getRangeAt(0);if(M.collapsed){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),M.insertNode(e);const n=document.createRange();return n.setStart(e.firstChild,1),n.collapse(!0),i.removeAllRanges(),void i.addRange(n)}!function(e,t,i){const M=document.createElement(t);i&&Object.entries(i).forEach((([e,t])=>M.setAttribute(e,t)));try{e.surroundContents(M)}catch{const t=e.extractContents();M.appendChild(t),e.insertNode(M)}}(M,"span",{style:`font-family:${t}`})}function Bm(e,t,i){for(;t&&t!==e;){if(t instanceof HTMLSpanElement&&t.hasAttribute(i))return t;t=t.parentNode}return null}function Gm(e,t,i,M){const n=window.getSelection();if(!n||0===n.rangeCount)return;const o=n.getRangeAt(0);if(!e.contains(o.commonAncestorContainer))return;const r=o.cloneRange();if(r.collapsed){const o=Bm(e,r.startContainer,M);if(o)return o.style[t]=i,void _m(e,M,t);const s=document.createElement("span");s.setAttribute(M,"1"),s.style[t]=i,s.appendChild(document.createTextNode("​")),r.insertNode(s);const a=document.createRange();return a.setStart(s.firstChild,1),a.collapse(!0),n.removeAllRanges(),n.addRange(a),void _m(e,M,t)}const s=Bm(e,r.startContainer,M),a=Bm(e,r.endContainer,M);if(s&&s===a){if(function(e,t){const i=document.createRange();return i.selectNodeContents(t),e.compareBoundaryPoints(Range.START_TO_START,i)<=0&&e.compareBoundaryPoints(Range.END_TO_END,i)>=0}(r,s))s.style[t]=i;else{const e=function(e,t,i,M,n){const o=e.style[M],r=document.createRange();r.setStart(e,0),r.setEnd(t.startContainer,t.startOffset);const s=document.createRange();s.setStart(t.endContainer,t.endOffset),s.setEnd(e,e.childNodes.length);const a=document.createDocumentFragment(),l=e=>{const t=document.createElement("span");return t.setAttribute(i,"1"),t.style[M]=e,t};if(Fm(r)){const e=l(o);e.appendChild(r.cloneContents()),a.appendChild(e)}const N=l(n);if(N.appendChild(t.cloneContents()),a.appendChild(N),Fm(s)){const e=l(o);e.appendChild(s.cloneContents()),a.appendChild(e)}return e.replaceWith(a),N}(s,r,M,t,i),n=window.getSelection(),o=document.createRange();o.selectNodeContents(e),n?.removeAllRanges(),n?.addRange(o)}return void _m(e,M,t)}const l=(()=>{let e=r.commonAncestorContainer;for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e})(),N=document.createTreeWalker(l||e,NodeFilter.SHOW_TEXT,{acceptNode:e=>{if(!e.nodeValue||!e.nodeValue.trim())return NodeFilter.FILTER_REJECT;const t=document.createRange();t.selectNodeContents(e);return r.compareBoundaryPoints(Range.END_TO_START,t)<0&&r.compareBoundaryPoints(Range.START_TO_END,t)>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),g=[];let u;for(;u=N.nextNode();)g.push(u);g.forEach((n=>{let o=0,s=n.length;n===r.startContainer&&(o=r.startOffset),n===r.endContainer&&(s=r.endOffset),o>0&&(n=n.splitText(o)),s<n.length&&n.splitText(s);const a=Bm(e,n,M);if(a)return void(a.style[t]=i);const l=document.createElement("span");l.setAttribute(M,"1"),l.style[t]=i;n.parentElement.replaceChild(l,n),l.appendChild(n)})),_m(e,M,t),n.removeAllRanges(),n.addRange(r)}function _m(e,t,i){const M=Array.from(e.querySelectorAll(`span[${t}]`)),n=e=>e.style[i];M.forEach((e=>{Array.from(e.querySelectorAll(`span[${t}]`)).forEach((t=>{if(n(t)===n(e)){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}}));const i=e.previousSibling;if(i instanceof HTMLSpanElement&&i.hasAttribute(t)&&n(i)===n(e)){for(;e.firstChild;)i.appendChild(e.firstChild);return void e.remove()}const M=e.nextSibling;if(M instanceof HTMLSpanElement&&M.hasAttribute(t)&&n(M)===n(e)){for(;M.firstChild;)e.appendChild(M.firstChild);M.remove()}}))}function Fm(e){if(e.collapsed)return!1;return(e.cloneContents().textContent||"").length>0}function Hm(e,t){const i=document.getSelection();if(!i||0===i.rangeCount)return;const M=i.getRangeAt(0);function n(e){e.style.paddingInlineStart="0",e.style.margin="0"}function o(e){const t=document.getSelection();if(!t)return;const i=document.createRange();i.selectNodeContents(e),i.collapse(!0),t.removeAllRanges(),t.addRange(i)}function r(t){for(;t&&t!==e;){if(t instanceof HTMLElement){const e=getComputedStyle(t).display;if(t.tagName.match(/^(P|DIV|H[1-6]|LI)$/)||"block"===e||"list-item"===e)return t}t=t.parentNode}return null}function s(e,t){const i=document.createElement(t);for(n(i);e.firstChild;)i.appendChild(e.firstChild);e.replaceWith(i)}if(M.collapsed){const i=r(M.startContainer),l=i?.closest("ul,ol");if(l&&l.tagName.toLowerCase()===t)return void function(e){const t=e.closest("li");if(!t)return;const i=t.parentElement,M=document.createElement("p");for(t.style.textAlign&&(M.style.textAlign=t.style.textAlign);t.firstChild;)M.appendChild(t.firstChild);i.parentNode?.insertBefore(M,i.nextSibling),t.remove(),0===i.childNodes.length&&i.remove(),o(M)}(i);if(l&&l.tagName.toLowerCase()!==t)return void s(l,t);if(!i||i===e||0===i.childNodes.length||(a=i,!a.textContent?.trim()&&!a.querySelector("img,br"))){const e=document.createElement(t),i=document.createElement("li");return i.appendChild(document.createElement("br")),e.appendChild(i),n(e),M.insertNode(e),void o(i)}const N=document.createElement(t);n(N);const g=document.createElement("li");for(i.style.textAlign&&(g.style.textAlign=i.style.textAlign);i.firstChild;)g.appendChild(i.firstChild);return N.appendChild(g),i.replaceWith(N),void o(g)}var a;const l=[],N=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(!(e instanceof HTMLElement))return NodeFilter.FILTER_SKIP;if(!/^(P|DIV|LI|H[1-6])$/.test(e.tagName))return NodeFilter.FILTER_SKIP;const t=document.createRange();t.selectNodeContents(e);return M.compareBoundaryPoints(Range.END_TO_START,t)<0&&M.compareBoundaryPoints(Range.START_TO_END,t)>0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}});let g;for(;g=N.nextNode();)l.push(g);if(0===l.length){const e=r(M.startContainer);e&&l.push(e)}const u=l[0].closest("li");if(u){const e=u.closest("ul,ol");if(!e)return;return void(e.tagName.toLowerCase()===t?function(e){const t=document.createDocumentFragment();Array.from(e.querySelectorAll("li")).forEach((e=>{const i=document.createElement("p");for(e.style.textAlign&&(i.style.textAlign=e.style.textAlign);e.firstChild;)i.appendChild(e.firstChild);t.appendChild(i)})),e.replaceWith(t)}(e):s(e,t))}const c=document.createElement(t);n(c);for(const e of l){const t=document.createElement("li");for(e.style.textAlign&&(t.style.textAlign=e.style.textAlign);e.firstChild;)t.appendChild(e.firstChild);c.appendChild(t)}l[0].replaceWith(c);for(let e=1;e<l.length;e++)l[e].remove()}e([ce({attribute:!1})],Ym.prototype,"editorEl",void 0),e([ce({type:Boolean,reflect:!0,attribute:!0})],Ym.prototype,"newTab",void 0),e([ce({type:Boolean,reflect:!0,attribute:!0})],Ym.prototype,"disabled",void 0),e([ce({type:Boolean,reflect:!0,attribute:!0})],Ym.prototype,"showTextSupport",void 0),e([ce({type:String,reflect:!0,attribute:!0})],Ym.prototype,"placeholder",void 0),e([ce({type:String,reflect:!0,attribute:!0})],Ym.prototype,"textPlaceholder",void 0),e([ce({type:String,reflect:!0,attribute:!0})],Ym.prototype,"label",void 0),e([De()],Ym.prototype,"linkValue",void 0),e([De()],Ym.prototype,"textValue",void 0),e([De()],Ym.prototype,"hasActiveLink",void 0),e([De()],Ym.prototype,"popoverStyle",void 0),Ym=e([Ne("nile-rte-link")],Ym);const Jm=r`
15539
15554
  .editor { all: revert; }
15540
15555
 
15541
15556
  nile-rich-text-editor {
@@ -15706,6 +15721,30 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
15706
15721
  background-color: var(--nile-colors-primary-500, var(--ng-componentcolors-utility-blue-500));
15707
15722
  }
15708
15723
 
15724
+ nile-rte-link nile-button[data-active]::part(base) {
15725
+ background-color: var(--nile-colors-primary-400, var(--ng-componentcolors-utility-blue-400));
15726
+ }
15727
+
15728
+ nile-rte-link nile-button[data-active]::part(base):hover {
15729
+ background-color: var(--nile-colors-primary-500, var(--ng-componentcolors-utility-blue-500));
15730
+ }
15731
+
15732
+ .editor a {
15733
+ color: var(--nile-colors-primary-600, var(--ng-colors-text-brand-tertiary-600));
15734
+ cursor: pointer;
15735
+ text-decoration: none;
15736
+ }
15737
+
15738
+ .editor a:hover {
15739
+ text-decoration: none;
15740
+ }
15741
+
15742
+ nile-rich-text-editor[disabled] .editor a {
15743
+ color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
15744
+ cursor: not-allowed;
15745
+ pointer-events: none;
15746
+ }
15747
+
15709
15748
  .editor.empty::before {
15710
15749
  content: attr(data-placeholder);
15711
15750
  color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary));
@@ -15723,7 +15762,7 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
15723
15762
 
15724
15763
 
15725
15764
 
15726
- `,$m={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"format_list_bulleted",ol:"format_list_numbered",clear:"format_clear"},Xm=["font-weight","font-style","text-decoration","color","background-color","font-size","font-family","text-align","line-height","letter-spacing","white-space","vertical-align","list-style-position","padding-inline-start"];let qm=class extends ae{constructor(){super(...arguments),this.value="",this.noStyles=!1,this.disabled=!1,this.singleLineEditor=!1,this.placeholder="",this.mentions={},this.whitelist=[],this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.bgColorInput=null,this.colorSwatchEl=null,this.bgSwatchEl=null,this.containerEl=null,this.mentionsEl=null,this.onEditorKeydown=e=>{if(this.singleLineEditor&&"Enter"===e.key&&e.shiftKey)return void e.preventDefault();if(e.ctrlKey&&"i"===e.key.toLowerCase()&&(e.preventDefault(),Wm(this.editorEl,"em"),this.updateContent(),this.updateToolbarState()),this.singleLineEditor&&"Enter"===e.key)return void e.preventDefault();if("Tab"!==e.key)return;e.preventDefault(),this.focusAndRestore();const t=window.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);if(e.shiftKey){if(i.collapsed&&i.startContainer.nodeType===Node.TEXT_NODE){const e=i.startContainer,M=i.startOffset,n=e.data.slice(0,M),o=n.replace(/(\t|[ \u00a0]{2})$/,"");if(o.length!==n.length){e.data=o+e.data.slice(M);const i=document.createRange();i.setStart(e,o.length),i.collapse(!0),t.removeAllRanges(),t.addRange(i),this.updateContent(),this.updateToolbarState()}}return}i.deleteContents();const M=document.createTextNode("\t");i.insertNode(M);const n=document.createRange();n.setStartAfter(M),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.updateContent(),this.updateToolbarState()},this.onSelectionChange=()=>{if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);this.editorEl.contains(t.commonAncestorContainer)&&(this.lastRange=t.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}injectCss(e){if(this.querySelector("style[data-rte-style]"))return;const t=document.createElement("style");t.setAttribute("data-rte-style","true"),t.textContent=e,this.insertBefore(t,this.firstChild)}connectedCallback(){super.connectedCallback(),this.injectCss(Jm.cssText),this.ensureStructure(),this.placeholder&&this.editorEl&&(this.editorEl.dataset.placeholder=this.placeholder),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),document.addEventListener("selectionchange",this.onSelectionChange,{passive:!0}),this.updateToolbarState(),this.syncPreview()}ensureStructure(){this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.containerEl=this.querySelector(".rte-container"),this.containerEl||(this.containerEl=document.createElement("div"),this.containerEl.className="rte-container",this.appendChild(this.containerEl)),this.ensureEditor(),this.toolbarEl&&this.toolbarEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.toolbarEl),this.editorEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.editorEl),this.previewEl&&(this.previewEl.parentElement!==this&&this.appendChild(this.previewEl),this.previewEl.previousElementSibling!==this.containerEl&&this.insertBefore(this.previewEl,this.containerEl.nextSibling))}updateContentWithMention(e){this.updateContent(),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content,mention:e},bubbles:!0,composed:!0}))}disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}updated(e){e.has("value")&&this.editorEl&&this.value!==this.editorEl.innerHTML&&(this.editorEl.innerHTML=this.value||"<p><br></p>",this.content=this.editorEl.innerHTML,this.syncPreview()),e.has("singleLineEditor")&&(this.editorEl&&this.editorEl.classList.toggle("single-line",this.singleLineEditor),this.previewEl&&this.previewEl.classList.toggle("single-line",this.singleLineEditor)),e.has("disabled")&&this.editorEl&&(this.editorEl.setAttribute("contenteditable",this.disabled?"false":"true"),this.editorEl.tabIndex=this.disabled?-1:0)}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const e=document.createElement("article");e.className="editor",e.setAttribute("contenteditable",this.disabled?"false":"true"),e.tabIndex=this.disabled?-1:0,this.editorEl=e}this.placeholder&&(this.editorEl.dataset.placeholder=this.placeholder),this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>")}unwrapMention(e,t=!0){const i=e.parentNode;if(!i)return;const M=t?(e.textContent??"").replace(/\u200B/g,""):"",n=document.createTextNode(M);i.insertBefore(n,e),i.removeChild(e);const o=document.createRange();o.setStartAfter(n),o.collapse(!0);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(o)}scrubBrokenMentions(){if(!this.editorEl)return;this.editorEl.querySelectorAll("span.mention").forEach((e=>{const t=e,i=t.getAttribute("data-mention-key"),M=t.getAttribute("data-mention-label"),n=t.getAttribute("data-mention-trigger")||"",o=(t.textContent??"").replace(/\u200B/g,"").trim(),r=!!i&&!!M&&o.length>0&&o.startsWith(n)&&o.includes(M);o&&r||this.unwrapMention(t,!0)}))}wireEditor(){this.editorEl.addEventListener("input",(()=>{this.ensureAtLeastOneParagraph(),this.scrubBrokenMentions(),this.updateContent(),this.updateToolbarState()})),this.editorEl.addEventListener("mouseup",(()=>{this.saveSelection(),this.updateToolbarState()})),this.editorEl.addEventListener("keyup",(e=>{this.saveSelection(),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)&&this.updateToolbarState()})),this.editorEl.addEventListener("keydown",this.onEditorKeydown)}wireAuthoredToolbar(e){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(e.children).forEach((e=>{const t=e.tagName.toLowerCase();if("nile-rte-select"===t&&"align"===e.getAttribute("type"))return e.disabled=this.disabled,void e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;Vm(this.editorEl,t),this.updateContent(),this.updateToolbarState()}));if("nile-rte-link"===t)return e.editorEl=this.editorEl,void e.addEventListener("link-changed",(()=>{this.updateContent(),this.updateToolbarState()}));if("nile-rte-toolbar-item"===t){let t=e.querySelector(":scope > nile-button");const i=e.getAttribute("name")||"",M=e.getAttribute("label")||i,n=e.getAttribute("icon"),o=e.innerHTML.trim().length>0;if(t||(t=document.createElement("nile-button"),t.variant="tertiary",t.size="small"),t.disabled=this.disabled,n)t.innerHTML=`<nile-icon name="${n}" color="${this.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"}" ></nile-icon>`,e.innerHTML="";else if(o)t.innerHTML=e.innerHTML,e.innerHTML="";else{const n=$m[i];n?t.innerHTML=`<nile-icon name="${n}" size="20" color="${this.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"}" ></nile-icon>`:t.textContent=M||i,e.innerHTML=""}if(!t.isConnected)if(this.disabled)e.appendChild(t);else{const i=document.createElement("nile-lite-tooltip");i.setAttribute("content",M),i.appendChild(t),e.appendChild(i)}t.setAttribute("aria-label",M),t.addEventListener("mousedown",(e=>e.preventDefault())),t.addEventListener("click",(()=>this.onToolbarCommand(i)));const r=this.buttonMap.get(i)??[];return r.push(t),void this.buttonMap.set(i,r)}if("nile-rte-select"!==t)"nile-rte-color"!==t||e.addEventListener("change",(e=>{this.focusAndRestore();const{mode:t,value:i}=e.detail;"backColor"===t?Gm(this.editorEl,"backgroundColor",i,"data-rte-bg"):function(e,t){Gm(e,"color",t,"data-rte-color")}(this.editorEl,i),this.updateContent(),this.updateToolbarState()}));else{const t=e.getAttribute("type")||"";e.addEventListener("change",(e=>{this.focusAndRestore();const i=e.detail;"heading"===t?function(e,t){const i=document.getSelection();if(!i||0===i.rangeCount)return;const M=Zm(i.getRangeAt(0).startContainer,e);if(!M)return;if(M.tagName.toLowerCase()===t)return;const n=document.createElement(t);for(;M.firstChild;)n.appendChild(M.firstChild);M.replaceWith(n);const o=document.createRange();o.selectNodeContents(n),o.collapse(!0),i.removeAllRanges(),i.addRange(o)}(this.editorEl,i):"font"===t&&Rm(this.editorEl,i),this.updateContent(),this.updateToolbarState()}))}}))}saveSelection(){const e=window.getSelection();e&&e.rangeCount&&(this.lastRange=e.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const e=document.getSelection();e&&(e.removeAllRanges(),e.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}getCleanContent(){const e=this.editorEl.cloneNode(!0);return e.querySelectorAll("*").forEach((e=>{e.removeAttribute("style")})),e.innerHTML}insertList(e){if(this.restoreSelection(),!this.lastRange)return;const t=document.createElement(e),i=this.lastRange.extractContents(),M=document.createElement("div");M.appendChild(i),Array.from(M.childNodes).forEach((e=>{if(e.nodeType===Node.TEXT_NODE&&!e.textContent?.trim())return;const i=document.createElement("li");i.appendChild(e),t.appendChild(i)})),this.lastRange.insertNode(t),this.afterListEdit(t)}afterListEdit(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const i=window.getSelection();i?.removeAllRanges(),i?.addRange(t),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const e=this.editorEl;if(!e)return;const t=""===(e.textContent??"").replace(/\u200B/g,"").trim();if(0===e.childNodes.length||t)return void(e.innerHTML="<p><br></p>");if(!e.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const t=document.createElement("p");for(;e.firstChild;)t.appendChild(e.firstChild);return t.hasChildNodes()||t.appendChild(document.createElement("br")),void e.appendChild(t)}e.querySelectorAll("p").forEach((e=>{""===(e.textContent??"").replace(/\u200B/g,"")&&(e.innerHTML.toLowerCase().includes("<br")||(e.innerHTML="<br>"))}))}onToolbarCommand(e){switch(this.focusAndRestore(),e){case"bold":Wm(this.editorEl,"strong");break;case"italic":Wm(this.editorEl,"em");break;case"underline":Wm(this.editorEl,"u");break;case"left":Vm(this.editorEl,"left");break;case"center":Vm(this.editorEl,"center");break;case"right":Vm(this.editorEl,"right");break;case"justify":Vm(this.editorEl,"justify");break;case"ul":Hm(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":Hm(this.editorEl,"ol"),this.updateContent(),this.updateToolbarState();break;case"link":break;case"clear":const e=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),t=[];for(;e.nextNode();){const i=e.currentNode;i.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(i.tagName)&&t.push(i)}for(const e of t){for(;e.firstChild;)e.parentNode?.insertBefore(e.firstChild,e);e.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(e,t){const i=this.buttonMap.get(e);if(i)for(const e of i)e.toggleAttribute("data-active",!!t)}updateToolbarState(){if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);if(!this.editorEl.contains(t.commonAncestorContainer))return;const i=function(e){for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e}(t.startContainer)||this.editorEl,M=getComputedStyle(i),n=Zm(t.startContainer,this.editorEl)||this.editorEl,o=(()=>{let e=i;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("strong"===t||"b"===t)return!0;const i=getComputedStyle(e).fontWeight;if(parseInt(i,10)>=600)return!0}e=e.parentNode}return!1})(),r=(()=>{let e=i;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("em"===t||"i"===t)return!0;if("italic"===getComputedStyle(e).fontStyle)return!0}e=e.parentNode}return!1})(),s=(()=>{let e=i;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=getComputedStyle(e).textDecorationLine;if(t&&t.includes("underline"))return!0;if("u"===e.tagName.toLowerCase())return!0}e=e.parentNode}return!1})(),a=!!i.closest("a"),l=n.style.textAlign||getComputedStyle(n).textAlign||"start",N="start"===l?"left":l,g=!!i.closest("li")&&i.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",o),this.setBtnActive("italic",r),this.setBtnActive("underline",s),this.setBtnActive("link",a),this.setBtnActive("left","left"===N&&!["center","right","justify"].includes(N)),this.setBtnActive("center","center"===N),this.setBtnActive("right","right"===N),this.setBtnActive("justify","justify"===N),this.setBtnActive("ul","ul"===g),this.setBtnActive("ol","ol"===g),this.headingSelect){const e=n.tagName.toLowerCase(),t=["h1","h2","h3"].includes(e)?e:"p";this.headingSelect.value!==t&&(this.headingSelect.value=t)}if(this.fontSelect){const e=(M.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(e)for(const t of Array.from(this.fontSelect.options))if(t.value.toLowerCase()===e){this.fontSelect.value=t.value;break}}if(this.colorInput){const e=Pm(M.color);e&&this.colorInput.value.toLowerCase()!==e.toLowerCase()&&(this.colorInput.value=e),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value)}if(this.bgColorInput){const e=getComputedStyle(i).backgroundColor;if(e&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(e)){const t=Pm(e);t&&this.bgColorInput.value.toLowerCase()!==t.toLowerCase()&&(this.bgColorInput.value=t)}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value)}}syncPreview(){this.updateContent()}getComputedImportantProps(){return Array.from(new Set([...Xm,...this.whitelist??[]]))}updateContent(){if(!this.editorEl)return;this.ensureAtLeastOneParagraph();const e=""===(this.editorEl.textContent??"").trim();this.editorEl.classList.toggle("empty",e);const t=this.editorEl.cloneNode(!0);if(this.noStyles)t.querySelectorAll("[style]").forEach((e=>e.removeAttribute("style")));else{const e=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),M=this.getComputedImportantProps();for(;e.nextNode()&&i.nextNode();){const t=e.currentNode,n=i.currentNode,o=window.getComputedStyle(t),r=M.map((e=>`${e}:${o.getPropertyValue(e)}`)).join(";");r.trim()&&n.setAttribute("style",r)}}this.content=t.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content},bubbles:!0,composed:!0}))}};e([ce({type:String,attribute:!0,reflect:!0})],qm.prototype,"value",void 0),e([ce({type:Boolean,attribute:!0,reflect:!0})],qm.prototype,"noStyles",void 0),e([ce({type:Boolean,attribute:!0,reflect:!0})],qm.prototype,"disabled",void 0),e([ce({type:Boolean,attribute:"singlelineeditor",reflect:!0})],qm.prototype,"singleLineEditor",void 0),e([ce({type:String})],qm.prototype,"placeholder",void 0),e([ce({attribute:"mentions",reflect:!0,converter:{fromAttribute:e=>{try{const t=JSON.parse(e),i={};for(const e of Object.keys(t)){const M=t[e];Array.isArray(M)&&(i[e]=M.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)).map((e=>({key:e.key,label:e.label}))))}return i}catch{return{}}},toAttribute:e=>JSON.stringify(e)}})],qm.prototype,"mentions",void 0),e([ce({attribute:"whitelist",reflect:!1,converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return Array.isArray(t)?t.filter((e=>"string"==typeof e)):[]}catch{return[]}}}})],qm.prototype,"whitelist",void 0),e([De()],qm.prototype,"content",void 0),qm=e([Ne("nile-rich-text-editor")],qm);"undefined"!=typeof window&&(window.nileElementsVersion='"1.5.8"',window.nileVersion="__NILE_VERSION__",window.process=window.process||{env:{NODE_ENV:"production"}});const Km=r`
15765
+ `,$m={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"format_list_bulleted",ol:"format_list_numbered",clear:"format_clear"},Xm=["font-weight","font-style","text-decoration","color","background-color","font-size","font-family","text-align","line-height","letter-spacing","white-space","vertical-align","list-style-position","padding-inline-start"];let qm=class extends ae{constructor(){super(...arguments),this.value="",this.noStyles=!1,this.disabled=!1,this.singleLineEditor=!1,this.placeholder="",this.mentions={},this.whitelist=[],this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.bgColorInput=null,this.colorSwatchEl=null,this.bgSwatchEl=null,this.containerEl=null,this.linkEl=null,this.mentionsEl=null,this.onEditorClick=e=>{const t=e.target.closest?.("a");t&&e.preventDefault()},this.onEditorInput=()=>{this.ensureAtLeastOneParagraph(),this.scrubBrokenMentions(),this.updateContent(),this.updateToolbarState()},this.onEditorMouseup=()=>{this.saveSelection(),this.updateToolbarState()},this.onEditorKeyup=e=>{this.saveSelection(),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)&&this.updateToolbarState()},this.onEditorKeydown=e=>{if(this.singleLineEditor&&"Enter"===e.key&&e.shiftKey)return void e.preventDefault();if(e.ctrlKey&&"i"===e.key.toLowerCase()&&(e.preventDefault(),Wm(this.editorEl,"em"),this.updateContent(),this.updateToolbarState()),this.singleLineEditor&&"Enter"===e.key)return void e.preventDefault();if("Tab"!==e.key)return;e.preventDefault(),this.focusAndRestore();const t=window.getSelection();if(!t||0===t.rangeCount)return;const i=t.getRangeAt(0);if(e.shiftKey){if(i.collapsed&&i.startContainer.nodeType===Node.TEXT_NODE){const e=i.startContainer,M=i.startOffset,n=e.data.slice(0,M),o=n.replace(/(\t|[ \u00a0]{2})$/,"");if(o.length!==n.length){e.data=o+e.data.slice(M);const i=document.createRange();i.setStart(e,o.length),i.collapse(!0),t.removeAllRanges(),t.addRange(i),this.updateContent(),this.updateToolbarState()}}return}i.deleteContents();const M=document.createTextNode("\t");i.insertNode(M);const n=document.createRange();n.setStartAfter(M),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.updateContent(),this.updateToolbarState()},this.onSelectionChange=()=>{if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);this.editorEl.contains(t.commonAncestorContainer)&&(this.lastRange=t.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}injectCss(e){if(this.querySelector("style[data-rte-style]"))return;const t=document.createElement("style");t.setAttribute("data-rte-style","true"),t.textContent=e,this.insertBefore(t,this.firstChild)}connectedCallback(){super.connectedCallback(),this.injectCss(Jm.cssText),this.ensureStructure(),this.placeholder&&this.editorEl&&(this.editorEl.dataset.placeholder=this.placeholder),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),document.addEventListener("selectionchange",this.onSelectionChange,{passive:!0}),this.updateToolbarState(),this.syncPreview()}ensureStructure(){this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.containerEl=this.querySelector(".rte-container"),this.containerEl||(this.containerEl=document.createElement("div"),this.containerEl.className="rte-container",this.appendChild(this.containerEl)),this.ensureEditor(),this.toolbarEl&&this.toolbarEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.toolbarEl),this.editorEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.editorEl),this.previewEl&&(this.previewEl.parentElement!==this&&this.appendChild(this.previewEl),this.previewEl.previousElementSibling!==this.containerEl&&this.insertBefore(this.previewEl,this.containerEl.nextSibling))}updateContentWithMention(e){this.updateContent(),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content,mention:e},bubbles:!0,composed:!0}))}disconnectedCallback(){this.unwireEditor(),document.removeEventListener("selectionchange",this.onSelectionChange),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}updated(e){e.has("value")&&this.editorEl&&this.value!==this.editorEl.innerHTML&&(this.editorEl.innerHTML=this.value||"<p><br></p>",this.content=this.editorEl.innerHTML,this.syncPreview()),e.has("singleLineEditor")&&(this.editorEl&&this.editorEl.classList.toggle("single-line",this.singleLineEditor),this.previewEl&&this.previewEl.classList.toggle("single-line",this.singleLineEditor)),e.has("disabled")&&this.editorEl&&(this.editorEl.setAttribute("contenteditable",this.disabled?"false":"true"),this.editorEl.tabIndex=this.disabled?-1:0,this.linkEl&&(this.linkEl.disabled=this.disabled)),e.has("placeholder")&&this.editorEl&&(this.placeholder?this.editorEl.dataset.placeholder=this.placeholder:delete this.editorEl.dataset.placeholder)}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const e=document.createElement("article");e.className="editor",e.setAttribute("contenteditable",this.disabled?"false":"true"),e.tabIndex=this.disabled?-1:0,this.editorEl=e}this.placeholder&&(this.editorEl.dataset.placeholder=this.placeholder),this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>")}unwrapMention(e,t=!0){const i=e.parentNode;if(!i)return;const M=t?(e.textContent??"").replace(/\u200B/g,""):"",n=document.createTextNode(M);i.insertBefore(n,e),i.removeChild(e);const o=document.createRange();o.setStartAfter(n),o.collapse(!0);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(o)}scrubBrokenMentions(){if(!this.editorEl)return;this.editorEl.querySelectorAll("span.mention").forEach((e=>{const t=e,i=t.getAttribute("data-mention-key"),M=t.getAttribute("data-mention-label"),n=t.getAttribute("data-mention-trigger")||"",o=(t.textContent??"").replace(/\u200B/g,"").trim(),r=!!i&&!!M&&o.length>0&&o.startsWith(n)&&o.includes(M);o&&r||this.unwrapMention(t,!0)}))}wireEditor(){this.editorEl.addEventListener("click",this.onEditorClick),this.editorEl.addEventListener("input",this.onEditorInput),this.editorEl.addEventListener("mouseup",this.onEditorMouseup),this.editorEl.addEventListener("keyup",this.onEditorKeyup),this.editorEl.addEventListener("keydown",this.onEditorKeydown)}unwireEditor(){this.editorEl&&(this.editorEl.removeEventListener("click",this.onEditorClick),this.editorEl.removeEventListener("input",this.onEditorInput),this.editorEl.removeEventListener("mouseup",this.onEditorMouseup),this.editorEl.removeEventListener("keyup",this.onEditorKeyup),this.editorEl.removeEventListener("keydown",this.onEditorKeydown))}wireAuthoredToolbar(e){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(e.children).forEach((e=>{const t=e.tagName.toLowerCase();if("nile-rte-select"===t&&"align"===e.getAttribute("type"))return e.disabled=this.disabled,void e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;Vm(this.editorEl,t),this.updateContent(),this.updateToolbarState()}));if("nile-rte-link"===t)return e.editorEl=this.editorEl,e.disabled=this.disabled,this.linkEl=e,void e.addEventListener("nile-link-changed",(()=>{this.updateContent(),this.updateToolbarState()}));if("nile-rte-toolbar-item"===t){let t=e.querySelector(":scope > nile-button");const i=e.getAttribute("name")||"",M=e.getAttribute("label")||i,n=e.getAttribute("icon"),o=e.innerHTML.trim().length>0;if(t||(t=document.createElement("nile-button"),t.variant="tertiary",t.size="small"),t.disabled=this.disabled,n)t.innerHTML=`<nile-icon name="${n}" color="${this.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"}" ></nile-icon>`,e.innerHTML="";else if(o)t.innerHTML=e.innerHTML,e.innerHTML="";else{const n=$m[i];n?t.innerHTML=`<nile-icon name="${n}" size="20" color="${this.disabled?"var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))":"var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))"}" ></nile-icon>`:t.textContent=M||i,e.innerHTML=""}if(!t.isConnected)if(this.disabled)e.appendChild(t);else{const i=document.createElement("nile-lite-tooltip");i.setAttribute("content",M),i.appendChild(t),e.appendChild(i)}t.setAttribute("aria-label",M),t.addEventListener("mousedown",(e=>e.preventDefault())),t.addEventListener("click",(()=>this.onToolbarCommand(i)));const r=this.buttonMap.get(i)??[];return r.push(t),void this.buttonMap.set(i,r)}if("nile-rte-select"!==t)"nile-rte-color"!==t||e.addEventListener("change",(e=>{this.focusAndRestore();const{mode:t,value:i}=e.detail;"backColor"===t?Gm(this.editorEl,"backgroundColor",i,"data-rte-bg"):function(e,t){Gm(e,"color",t,"data-rte-color")}(this.editorEl,i),this.updateContent(),this.updateToolbarState()}));else{const t=e.getAttribute("type")||"";e.addEventListener("change",(e=>{this.focusAndRestore();const i=e.detail;"heading"===t?function(e,t){const i=document.getSelection();if(!i||0===i.rangeCount)return;const M=Zm(i.getRangeAt(0).startContainer,e);if(!M)return;if(M.tagName.toLowerCase()===t)return;const n=document.createElement(t);for(;M.firstChild;)n.appendChild(M.firstChild);M.replaceWith(n);const o=document.createRange();o.selectNodeContents(n),o.collapse(!0),i.removeAllRanges(),i.addRange(o)}(this.editorEl,i):"font"===t&&Rm(this.editorEl,i),this.updateContent(),this.updateToolbarState()}))}}))}saveSelection(){const e=window.getSelection();e&&e.rangeCount&&(this.lastRange=e.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const e=document.getSelection();e&&(e.removeAllRanges(),e.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}getCleanContent(){const e=this.editorEl.cloneNode(!0);return e.querySelectorAll("*").forEach((e=>{e.removeAttribute("style")})),e.innerHTML}insertList(e){if(this.restoreSelection(),!this.lastRange)return;const t=document.createElement(e),i=this.lastRange.extractContents(),M=document.createElement("div");M.appendChild(i),Array.from(M.childNodes).forEach((e=>{if(e.nodeType===Node.TEXT_NODE&&!e.textContent?.trim())return;const i=document.createElement("li");i.appendChild(e),t.appendChild(i)})),this.lastRange.insertNode(t),this.afterListEdit(t)}afterListEdit(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const i=window.getSelection();i?.removeAllRanges(),i?.addRange(t),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const e=this.editorEl;if(!e)return;const t=""===(e.textContent??"").replace(/\u200B/g,"").trim();if(0===e.childNodes.length||t)return void(e.innerHTML="<p><br></p>");if(!e.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const t=document.createElement("p");for(;e.firstChild;)t.appendChild(e.firstChild);return t.hasChildNodes()||t.appendChild(document.createElement("br")),void e.appendChild(t)}e.querySelectorAll("p").forEach((e=>{""===(e.textContent??"").replace(/\u200B/g,"")&&(e.innerHTML.toLowerCase().includes("<br")||(e.innerHTML="<br>"))}))}onToolbarCommand(e){switch(this.focusAndRestore(),e){case"bold":Wm(this.editorEl,"strong");break;case"italic":Wm(this.editorEl,"em");break;case"underline":Wm(this.editorEl,"u");break;case"left":Vm(this.editorEl,"left");break;case"center":Vm(this.editorEl,"center");break;case"right":Vm(this.editorEl,"right");break;case"justify":Vm(this.editorEl,"justify");break;case"ul":Hm(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":Hm(this.editorEl,"ol"),this.updateContent(),this.updateToolbarState();break;case"link":break;case"clear":const e=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),t=[];for(;e.nextNode();){const i=e.currentNode;i.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(i.tagName)&&t.push(i)}for(const e of t){for(;e.firstChild;)e.parentNode?.insertBefore(e.firstChild,e);e.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(e,t){const i=this.buttonMap.get(e);if(i)for(const e of i)e.toggleAttribute("data-active",!!t)}updateToolbarState(){if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);if(!this.editorEl.contains(t.commonAncestorContainer))return;const i=function(e){for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e}(t.startContainer)||this.editorEl,M=getComputedStyle(i),n=Zm(t.startContainer,this.editorEl)||this.editorEl,o=(()=>{let e=i;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("strong"===t||"b"===t)return!0;const i=getComputedStyle(e).fontWeight;if(parseInt(i,10)>=600)return!0}e=e.parentNode}return!1})(),r=(()=>{let e=i;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("em"===t||"i"===t)return!0;if("italic"===getComputedStyle(e).fontStyle)return!0}e=e.parentNode}return!1})(),s=(()=>{let e=i;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=getComputedStyle(e).textDecorationLine;if(t&&t.includes("underline"))return!0;if("u"===e.tagName.toLowerCase())return!0}e=e.parentNode}return!1})(),a=!!i.closest("a"),l=n.style.textAlign||getComputedStyle(n).textAlign||"start",N="start"===l?"left":l,g=!!i.closest("li")&&i.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",o),this.setBtnActive("italic",r),this.setBtnActive("underline",s),this.setBtnActive("link",a),this.linkEl){const e=this.linkEl.querySelector("nile-button");e&&e.toggleAttribute("data-active",a)}if(this.setBtnActive("left","left"===N&&!["center","right","justify"].includes(N)),this.setBtnActive("center","center"===N),this.setBtnActive("right","right"===N),this.setBtnActive("justify","justify"===N),this.setBtnActive("ul","ul"===g),this.setBtnActive("ol","ol"===g),this.headingSelect){const e=n.tagName.toLowerCase(),t=["h1","h2","h3"].includes(e)?e:"p";this.headingSelect.value!==t&&(this.headingSelect.value=t)}if(this.fontSelect){const e=(M.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(e)for(const t of Array.from(this.fontSelect.options))if(t.value.toLowerCase()===e){this.fontSelect.value=t.value;break}}if(this.colorInput){const e=Pm(M.color);e&&this.colorInput.value.toLowerCase()!==e.toLowerCase()&&(this.colorInput.value=e),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value)}if(this.bgColorInput){const e=getComputedStyle(i).backgroundColor;if(e&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(e)){const t=Pm(e);t&&this.bgColorInput.value.toLowerCase()!==t.toLowerCase()&&(this.bgColorInput.value=t)}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value)}}syncPreview(){this.updateContent()}getComputedImportantProps(){return Array.from(new Set([...Xm,...this.whitelist??[]]))}updateContent(){if(!this.editorEl)return;this.ensureAtLeastOneParagraph();const e=""===(this.editorEl.textContent??"").trim();this.editorEl.classList.toggle("empty",e);const t=this.editorEl.cloneNode(!0);if(this.noStyles)t.querySelectorAll("[style]").forEach((e=>e.removeAttribute("style")));else{const e=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),M=this.getComputedImportantProps();for(;e.nextNode()&&i.nextNode();){const t=e.currentNode,n=i.currentNode,o=window.getComputedStyle(t),r=M.map((e=>`${e}:${o.getPropertyValue(e)}`)).join(";");r.trim()&&n.setAttribute("style",r)}}this.content=t.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content},bubbles:!0,composed:!0}))}};e([ce({type:String,attribute:!0,reflect:!0})],qm.prototype,"value",void 0),e([ce({type:Boolean,attribute:!0,reflect:!0})],qm.prototype,"noStyles",void 0),e([ce({type:Boolean,attribute:!0,reflect:!0})],qm.prototype,"disabled",void 0),e([ce({type:Boolean,attribute:"singlelineeditor",reflect:!0})],qm.prototype,"singleLineEditor",void 0),e([ce({type:String})],qm.prototype,"placeholder",void 0),e([ce({attribute:"mentions",reflect:!0,converter:{fromAttribute:e=>{try{const t=JSON.parse(e),i={};for(const e of Object.keys(t)){const M=t[e];Array.isArray(M)&&(i[e]=M.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)).map((e=>({key:e.key,label:e.label}))))}return i}catch{return{}}},toAttribute:e=>JSON.stringify(e)}})],qm.prototype,"mentions",void 0),e([ce({attribute:"whitelist",reflect:!1,converter:{fromAttribute:e=>{try{const t=JSON.parse(e);return Array.isArray(t)?t.filter((e=>"string"==typeof e)):[]}catch{return[]}}}})],qm.prototype,"whitelist",void 0),e([De()],qm.prototype,"content",void 0),qm=e([Ne("nile-rich-text-editor")],qm);"undefined"!=typeof window&&(window.nileElementsVersion='"1.6.0"',window.nileVersion="__NILE_VERSION__",window.process=window.process||{env:{NODE_ENV:"production"}});const Km=r`
15727
15766
  :host {
15728
15767
 
15729
15768
  top: 0;