import{s as e,c as t,a6 as r,P as s,Z as n}from"./p-7e9c2be7.js";import{R as i}from"./p-fcabf0dc.js";import{c as o,d as a,h as d}from"./p-46048b08.js";import{i as l}from"./p-add8f9c6.js";import{V as c}from"./p-a7b5f497.js";import"./p-dcc98162.js";import{D as p}from"./p-2d3e1a65.js";import{d as u,c as g}from"./p-633fe47e.js";import{V as h}from"./p-dfd0e4f2.js";import{vegaNonceManager as f}from"./p-503d32d7.js";const m=new class{constructor(){this.extensionContextMap=new WeakMap}setExtensionContext(e){e&&e.host&&this.extensionContextMap.set(e.host,e)}getExtensionContext(e){return e?this.extensionContextMap.get(e):null}};class x extends c{injectRTEScopeStyles(){return""}render(e,t,r){var s;const n=this.doRender(r,e,t);return this.fallbackRegisterRef(n,e),this.appendChildren((null===(s=n.childrenContainerGetter)||void 0===s?void 0:s.call(n))||n,e,t,r),n}useRef(t){return t[x.REGISTER_REF_FLAG]=!0,function(r){r&&e.register(r,t)}}getDTORenderer(e){return i.getRTERenderer(e)}getExtensionContext(e){return m.getExtensionContext(e)}appendChildren(e,t,r,s){Array.isArray(t.children)&&t.children.length&&!e.t&&(e.t=t.children.map((e=>this.renderChildren(e,r,s))).filter(l))}renderChildren(e,t,r){const s=this.getDTORenderer(e.type);if(s)return s.render(e,t,r)}fallbackRegisterRef(e,t){t[x.REGISTER_REF_FLAG]||!e.i||e.i.ref||(e.i.ref=this.useRef(t))}}x.REGISTER_REF_FLAG="__registeredRef__";class b{constructor(){this.extensionContext=null,this.hasCustomStylesRenderers=new Set}static registerActionHandleStrategy(e,r,s){t.register(r,e,s)}static registerActionHandlerInterceptor(e,t,s){r.register(t,e,s)}static registerFilterStylesStrategy(e,t){s.register(e,t)}initialExtension(e){this.extensionContext=e,m.setExtensionContext(e)}destroyExtension(){}collectExtensionRendererStyles(){let e="";return this.hasCustomStylesRenderers.size>0&&this.hasCustomStylesRenderers.forEach((t=>{e+=`${t.injectRTEScopeStyles()}\n`})),e}registerNode(e,t){n.registerRTEDTOClass(e,t)}registerRenderer(e,t){i.registerRTEDTORenderer(e,t),t instanceof x&&t.injectRTEScopeStyles()&&this.hasCustomStylesRenderers.add(t)}registerToolbarButtonRenderer(e,t){i.registerRTEToolbarButtonRenderer(e,t)}registerBlockBasicStrategies(e){o.registerBlockBasicStrategies(e)}unRegisterStrategy(e,r){t.unregister(e,r)}unRegisterInterceptor(e,t,s){r.unregister(e,t,s)}registerElementToBlockDTOClassStrategy(e){a.registerElementToBlockStrategy(e)}registerElementToNodeDTOClassStrategy(e){a.registerElementToNodeStrategy(e)}getElementToNodeDTOClassStrategies(){return a.getElementToNodeStrategies()}registerAnnotationHandler(e){d.registerHandler(e)}}class y{isHidden(e){return e.sourceEditMode}getExtensionContext(e){return m.getExtensionContext(e)}renderDropdown(e,t,r,s){return e("vega-dropdown",Object.assign({trigger:"click",searchable:!1,maxWidth:"200",itemDisplayRule:"ellipsis",ref:e=>{p.addUniqueObserverToNode(e,u,(e=>{this.handleDropdownClick(e.detail,t)}))}},r),s)}renderDropdownListTemplate(e,t){return e("div",{slot:"items",onMouseDown:this.preventDefault,class:"rte-dropdown-list"},[e("style",{nonce:f.nonce},".rte-dropdown-list vega-dropdown-group vega-dropdown-group { padding-left: 4px }"),...t.map((t=>"children"in t?this.renderDropdownGroup(e,t):this.renderDropdownItem(e,t)))])}renderDropdownItem(e,t){return e("vega-dropdown-item",{key:t.key,itemKey:t.key,label:t.label,prefixIcon:t.icon})}renderDropdownGroup(e,t){return e("vega-dropdown-group",{key:t.key,label:t.label,divide:!1},t.children.map((t=>"children"in t?this.renderDropdownGroup(e,t):this.renderDropdownItem(e,t))))}renderButton(e,t,r){const{icon:s,label:n,showArrowIcon:i}=r,o=this.isDisabled(t);return e("vega-rich-text-editor-toolbar-button",{disabled:o,icon:s,hidden:this.isHidden(t),selected:this.isSelected(t),ref:e=>{p.addUniqueObserverToNode(e,g,(()=>this.handleButtonClick(t)))},onMouseDown:this.preventDefault},[this.renderButtonLabel(e,t,n),i?e("vega-icon",{size:"size-8",color:o?"text-disabled":"text-secondary",style:{marginLeft:"8px"},icon:h.getIconKey("chevron-down")}):null].filter(l))}renderButtonLabel(e,t,r){return r?e("vega-font",{variant:"font-field-label-sm",color:this.isDisabled(t)?"text-disabled":"text-primary"},r):null}isDisabled(e){return e.host.disabled}isSelected(e){return!1}preventDefault(e){e.preventDefault()}getListItemByKey(e,t){for(const r of e)if("children"in r){const e=this.getListItemByKey(r.children,t);if(e)return e}else if(r.key===t)return r;return null}}export{m as R,y as V,x as a,b}