text: var Ms=Object.defineProperty;var Bs=(o,e,t)=>e in o?Ms(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var B=(o,e,t)=>(Bs(o,typeof e!="symbol"?e+"":e,t),t),ui=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var m=(o,e,t)=>(ui(o,e,"read from private field"),t?t.call(o):e.get(o)),l=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)},E=(o,e,t,i)=>(ui(o,e,"write to private field"),i?i.call(o,t):e.set(o,t),t);var u=(o,e,t)=>(ui(o,e,"access private method"),t);var O=Object.freeze({CENTER:"center",LEFT:"left",NONE:"none",RIGHT:"right"}),p=Object.freeze({INVALID_ARGUMENT:"Invalid argument",MISSING_NAME:"Missing name",NOT_IMPLEMENTED:"Not implemented"}),a=Object.freeze({A:"a",B:"b",BACKSPACE:"Backspace",C:"c",D:"d",DEL:"Delete",DOWN:"ArrowDown",E:"e",END:"End",ENTER:"Enter",ESC:"Escape",F:"f",G:"g",HOME:"Home",I:"i",J:"j",K:"k",L:"l",LEFT:"ArrowLeft",M:"m",O:"o",Q:"q",R:"r",RIGHT:"ArrowRight",S:"s",SPACE:" ",T:"t",TAB:"Tab",U:"u",UP:"ArrowUp",V:"v",W:"w",X:"x",Y:"y",Z:"z"}),A=Object.freeze({AFTERBEGIN:"afterbegin",AFTEREND:"afterend",BEFOREBEGIN:"beforebegin",BEFOREEND:"beforeend"}),w=Object.freeze({FIRST:"first",LAST:"last",NEXT:"next",PREV:"prev"}),s=Object.freeze({AUDIO:"audio",BLOCK:"block",BREAK:"break",CAPTION:"caption",CONTAINER:"container",FIGURE:"figure",FORMAT:"format",HEADING:"heading",IFRAME:"iframe",IMAGE:"image",LIST:"list",LISTITEM:"listitem",PARAGRAPH:"paragraph",PREFORMAT:"preformat",QUOTE:"quote",ROOT:"root",RULE:"rule",SLOT:"slot",SUMMARY:"summary",TABLE:"table",TABLECELL:"tablecell",TABLEROW:"tablerow",TABLESECTION:"tablesection",VIDEO:"video"}),r=Object.freeze({A:"a",ABBR:"abbr",ALL:"*",AUDIO:"audio",B:"b",BLOCK:"app-block",BLOCKQUOTE:"blockquote",BR:"br",BUTTON:"button",CITE:"cite",CODE:"code",DATA:"data",DEL:"del",DETAILS:"details",DFN:"dfn",DIALOG:"editor-dialog",DIV:"div",EDITOR:"akilli-editor",EM:"em",FIELDSET:"fieldset",FIGCAPTION:"figcaption",FIGURE:"figure",FOCUSBAR:"editor-focusbar",FORM:"form",FORMATBAR:"editor-formatbar",H2:"h2",H3:"h3",HR:"hr",I:"i",IFRAME:"iframe",IMG:"img",INPUT:"input",INS:"ins",KBD:"kbd",LABEL:"label",LEGEND:"legend",LI:"li",MARK:"mark",OL:"ol",P:"p",PRE:"pre",Q:"q",ROOT:"editor-root",S:"s",SAMP:"samp",SECTION:"section",SLOT:"slot",SMALL:"small",STRONG:"strong",SUB:"sub",SUMMARY:"summary",SUP:"sup",TABLE:"table",TBODY:"tbody",TD:"td",TFOOT:"tfoot",TH:"th",THEAD:"thead",TIME:"time",TOOLBAR:"editor-toolbar",TR:"tr",U:"u",UL:"ul",VAR:"var",VIDEO:"video"}),Tt=Object.freeze({FUNCTION:"function",STRING:"string",UNDEFINED:"undefined"});function x(o,e,{alt:t=!1,ctrl:i=!1,shift:n=!1}={}){return(Array.isArray(e)&&e.includes(o.key)||o.key===e)&&o.altKey===t&&o.ctrlKey===i&&o.shiftKey===n}function De(o){return typeof o===Tt.UNDEFINED}function v(o){return typeof o===Tt.FUNCTION}function I(o){return o&&typeof o===Tt.STRING}function V(o){return De(o)||I(o)}function fi(o){return De(o)||Array.isArray(o)&&o.length>0}function pi(o){return De(o)||o instanceof HTMLElement}var Re,Me,Be,Oe,Se,Ai,Ce,xi,C=class{constructor(e,t,i=void 0){l(this,Se);l(this,Ce);l(this,Re,void 0);l(this,Me,void 0);l(this,Be,void 0);l(this,Oe,void 0);if(!(e instanceof R)||!I(t)||!V(i))throw new Error(p.INVALID_ARGUMENT);E(this,Re,e),E(this,Me,t),E(this,Be,i&&this.editor.tags.get(i)),E(this,Oe,this.editor.dialogs.get(t))}get editor(){return m(this,Re)}get name(){return m(this,Me)}get tag(){return m(this,Be)}get dialog(){return m(this,Oe)}execute(){this.dialog?this.openDialog():this.insert(u(this,Se,Ai).call(this))}insert(e={}){if(!this.tag)return;u(this,Ce,xi).call(this,e);let t=this.editor.dom.getSelectedElementByName(this.tag.name);this.tag.group!==s.FORMAT?this.editor.dom.insert(this.editor.dom.createElement(this.tag.name,{attributes:e})):t&&Object.keys(e).length>0?t.parentElement.replaceChild(this.editor.dom.createElement(this.tag.name,{attributes:e,html:t.textContent}),t):t?t.parentElement.replaceChild(this.editor.dom.createText(t.textContent),t):this.editor.dom.format(this.editor.dom.createElement(this.tag.name,{attributes:e}))}openDialog(){this.dialog?.open(e=>this.insert(e),u(this,Se,Ai).call(this))}};Re=new WeakMap,Me=new WeakMap,Be=new WeakMap,Oe=new WeakMap,Se=new WeakSet,Ai=function(){if(!this.tag)return{};let e=this.editor.dom.getSelectedAttributesByName(this.tag.name);return u(this,Ce,xi).call(this,e),e},Ce=new WeakSet,xi=function(e){Object.keys(e).forEach(t=>this.tag.attributes.includes(t)&&e[t]||delete e[t])};var K,jt=class{constructor(e=[]){l(this,K,new Map);e.forEach(t=>this.set(t))}get(e){return m(this,K).get(e)}set(e){if(!(e instanceof C))throw new Error(p.INVALID_ARGUMENT);m(this,K).set(e.name,e)}find(e){return Array.from(m(this,K).values()).find(t=>t.tag?.name===e)}execute(e){this.get(e).execute()}freeze(){m(this,K).forEach(e=>Object.freeze(e)),Object.freeze(m(this,K)),Object.freeze(this)}};K=new WeakMap;var J,Lt=class{constructor(e=[]){l(this,J,new Map);e.forEach(t=>this.set(t))}get(e){return m(this,J).get(e)}set(e){if(!(e instanceof L))throw new Error(p.INVALID_ARGUMENT);m(this,J).set(e.name,e)}freeze(){m(this,J).forEach(e=>Object.freeze(e)),Object.freeze(m(this,J)),Object.freeze(this)}};J=new WeakMap;var ae,ne,gi,At,Os,ee=class{constructor(e){l(this,ne);l(this,At);l(this,ae,void 0);if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);E(this,ae,e),this.register(u(this,At,Os).bind(this))}dispatch(e,t=void 0,i=void 0){if(!I(e)||!pi(t)||!pi(i))throw new Error(p.INVALID_ARGUMENT);m(this,ae).dispatchEvent(new CustomEvent(e,{detail:{element:t,target:i}}))}register(e,t={childList:!0,subtree:!0}){if(!v(e))throw new Error(p.INVALID_ARGUMENT);new MutationObserver(e).observe(m(this,ae),t)}};ae=new WeakMap,ne=new WeakSet,gi=function(e,t,i){t instanceof HTMLElement&&i instanceof HTMLElement&&(this.dispatch(e,t,i),this.dispatch(`${e}${t.localName.replace("-","")}`,t,i))},At=new WeakSet,Os=function(e){e.forEach(t=>{t.addedNodes.forEach(i=>{i instanceof HTMLElement&&(u(this,ne,gi).call(this,"insert",i,t.target),Array.from(i.getElementsByTagName(r.ALL)).forEach(n=>u(this,ne,gi).call(this,"insert",n,t.target)))}),t.removedNodes.forEach(i=>i instanceof HTMLElement&&u(this,ne,gi).call(this,"delete",i,t.target))})};var ye,Fe,Pe,ke,xt,It,Ss,le=class{constructor(e,t){l(this,It);l(this,ye,void 0);l(this,Fe,void 0);l(this,Pe,void 0);l(this,ke,void 0);l(this,xt,{alwaysRaised:"yes",dependent:"yes",height:"",location:"no",menubar:"no",minimizable:"no",modal:"yes",resizable:"yes",scrollbars:"yes",toolbar:"no",width:""});if(!(e instanceof R)||!(t instanceof Document))throw new Error(p.INVALID_ARGUMENT);E(this,ye,e),E(this,Fe,t),E(this,Pe,this.document.defaultView),E(this,ke,this.document.documentElement)}get editor(){return m(this,ye)}get document(){return m(this,Fe)}get window(){return m(this,Pe)}get root(){return m(this,ke)}registerElement(e,t,i=void 0){De(this.window.customElements.get(e))&&this.window.customElements.define(e,t,i?{extends:i}:void 0)}createElement(e,{attributes:t={},html:i=""}={}){let n=this.document.createElement(e);return n.innerHTML=i,Object.entries(t).forEach(([h,f])=>f&&n.setAttribute(h,`${f}`)),n}insert(e){if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);let t=this.getSelectedEditable();if(t instanceof HTMLSlotElement&&this.editor.tags.allowed(t.parentElement,e))t.insertAdjacentElement(A.BEFOREBEGIN,e);else if(t)this.closest(t,e)?.insertAdjacentElement(A.AFTEREND,e),t.hasAttribute("data-deletable")&&!t.textContent.trim()&&t.parentElement.removeChild(t);else if(this.editor.tags.allowed(this.editor.root,e))this.editor.root.appendChild(e);else throw new Error(p.INVALID_ARGUMENT)}insertText(e){let t=this.getSelectedEditable();if(t){let i=this.getRange();i.deleteContents(),i.insertNode(this.createText(e)),i.collapse(),t.normalize()}}format(e){if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);let t=this.getRange(),i=this.getSelectedEditable();if(!t||t.collapsed||!t.toString().trim()||!i||!this.editor.tags.allowed(i,e))return;t.startContainer instanceof Text&&t.startContainer.parentElement!==i&&t.setStartBefore(t.startContainer.parentElement),t.endContainer instanceof Text&&t.endContainer.parentElement!==i&&t.setEndAfter(t.endContainer.parentElement);let n=t.toString(),h=Array.from(t.cloneContents().childNodes).every(f=>f instanceof Text&&!f.textContent.trim()||f instanceof HTMLElement&&f.localName===e.localName);t.deleteContents(),h?t.insertNode(this.createText(n)):(e.textContent=n,t.insertNode(e)),i.normalize()}createText(e){return this.document.createTextNode(e)}arbitrary(e){return e===this.editor.root||e?.hasAttribute("data-arbitrary")}contains(e){if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);if(this.editor.root.contains(e))return!0;let t=e.closest(this.editor.root.localName);return t&&!t.parentElement}closest(e,t){if(!(e instanceof HTMLElement)||!this.contains(e.parentElement))throw new Error(p.INVALID_ARGUMENT);let i=e,n=e.parentElement;do if(this.arbitrary(n)&&this.editor.tags.allowed(n,t))return i;while((i=n)&&(n=n.parentElement)&&this.contains(n))}wrap(e,t,i={}){let n;if(e instanceof HTMLElement){if(e.parentElement.localName!==t&&(n=this.closest(e,t))){let h=this.createElement(t,i);n.insertAdjacentElement(A.AFTEREND,h),h.appendChild(e)}}else throw new Error(p.INVALID_ARGUMENT)}getActiveElement(){let e=this.document.activeElement;return e&&this.contains(e)?e:void 0}getSelectedElement(){let e=this.getSelection(),t=e.anchorNode instanceof Text?e.anchorNode.parentElement:e.anchorNode,i=e.focusNode instanceof Text?e.focusNode.parentElement:e.focusNode;if(t instanceof HTMLElement&&i instanceof HTMLElement&&t===i&&this.contains(t))return t}getSelectedElementByName(e){let t=this.getSelectedElement();return t?.localName===e&&t||void 0}getSelectedAttributesByName(e){let t=this.getSelectedElementByName(e),i={};return t&&Array.from(t.attributes).forEach(n=>i[n.nodeName]=n.nodeValue),i}getSelectedEditable(){let e=this.getSelection(),t=e.anchorNode instanceof Text?e.anchorNode.parentElement:e.anchorNode,i=e.focusNode instanceof Text?e.focusNode.parentElement:e.focusNode;if(t instanceof HTMLElement&&i instanceof HTMLElement){let n=t.closest("[contenteditable=true]"),h=i.closest("[contenteditable=true]");if(n instanceof HTMLElement&&n===h&&this.contains(n))return n}}getSelection(){return this.window.getSelection()}getRange(){let e=this.getSelection();return e.rangeCount>0?e.getRangeAt(0):void 0}setRange(e){let t=this.getSelection();t.removeAllRanges(),t.addRange(e)}selectContents(e){if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);let t=this.document.createRange();t.selectNodeContents(e),this.setRange(t)}focusEnd(e){if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);e.focus();let t=this.document.createRange();t.selectNodeContents(e),t.collapse(),this.setRange(t)}delete(e){if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);let t=e.previousElementSibling,i=e.nextElementSibling;e.parentElement.removeChild(e),t instanceof HTMLElement&&t.hasAttribute("data-focusable")?this.focusEnd(t):i instanceof HTMLElement&&i.hasAttribute("data-focusable")&&i.focus()}sort(e,t){if(!(e instanceof HTMLElement)||!Object.values(w).includes(t))throw new Error(p.INVALID_ARGUMENT);let i=e.parentElement,n=e.previousElementSibling,h=e.nextElementSibling,f=i.firstElementChild,b=i.lastElementChild,T=e===f,j=e===b;t===w.PREV&&!T&&n.hasAttribute("data-sortable")?(n.insertAdjacentHTML(A.BEFOREBEGIN,e.outerHTML),i.removeChild(e)):t===w.NEXT&&!j&&h.hasAttribute("data-sortable")?(h.insertAdjacentHTML(A.AFTEREND,e.outerHTML),i.removeChild(e)):(t===w.FIRST&&!T||t===w.NEXT&&j)&&f.hasAttribute("data-sortable")?(f.insertAdjacentHTML(A.BEFOREBEGIN,e.outerHTML),i.removeChild(e)):(t===w.LAST&&!j||t===w.PREV&&T)&&b.hasAttribute("data-sortable")&&(b.insertAdjacentHTML(A.AFTEREND,e.outerHTML),i.removeChild(e))}open({url:e,name:t,call:i,params:n={}}){if(!I(e)||!I(t)||!v(i))throw new Error(p.INVALID_ARGUMENT);let h=this.createElement(r.A,{attributes:{href:e}}),f=new URL(h.href);Object.entries(n).forEach(([T,j])=>f.searchParams.set(T,`${j}`));let b=this.window.open(f.toString(),t,u(this,It,Ss).call(this));this.window.addEventListener("message",T=>{T.origin===f.origin&&T.source===b&&(i(T.data),b.close())},!1)}getWidth(){return this.window.screen.width}getHeight(){return this.window.screen.height}};ye=new WeakMap,Fe=new WeakMap,Pe=new WeakMap,ke=new WeakMap,xt=new WeakMap,It=new WeakSet,Ss=function(){let e=Object.assign({},m(this,xt),{height:`${this.getHeight()}`,width:`${this.getWidth()}`},this.editor.config.base.browser);return Object.entries(e).filter(([,t])=>!!t).map(([t,i])=>`${t}=${i}`).join(",")};var Ue,D=class{constructor(e){l(this,Ue,void 0);if(!(e instanceof R))throw new Error(p.INVALID_ARGUMENT);E(this,Ue,e)}get editor(){return m(this,Ue)}filter(e){throw new Error(p.NOT_IMPLEMENTED)}};Ue=new WeakMap;var te,Nt=class{constructor(){l(this,te,new Set)}add(e){if(!(e instanceof D))throw new Error(p.INVALID_ARGUMENT);m(this,te).add(e)}filter(e){if(!(e instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);m(this,te).forEach(t=>{e.normalize(),t.filter(e)})}freeze(){m(this,te).forEach(e=>Object.freeze(e)),Object.freeze(m(this,te)),Object.freeze(this)}};te=new WeakMap;var me=class{constructor({name:e,group:t,...i}={}){B(this,"name");B(this,"group");B(this,"children");B(this,"attributes");B(this,"alignable");B(this,"arbitrary");B(this,"deletable");B(this,"editable");B(this,"empty");B(this,"focusable");B(this,"navigable");B(this,"slotable");B(this,"sortable");B(this,"enter");if(!I(e)||!I(t)||!fi(i.children)||!fi(i.attributes)||!V(i.enter))throw new Error(p.INVALID_ARGUMENT);this.name=e,this.group=t,this.children=i.children||[],this.attributes=i.attributes||[],this.arbitrary=i.arbitrary===!0,this.alignable=i.alignable===!0,this.deletable=i.deletable===!0,this.editable=i.editable===!0,this.empty=i.empty===!0,this.focusable=i.focusable===!0,this.navigable=i.navigable===!0,this.slotable=i.slotable===!0,this.sortable=i.sortable===!0,this.enter=i.enter}};var Ge,de,bi,d=class{constructor(e){l(this,de);l(this,Ge,void 0);if(!(e instanceof R))throw new Error(p.INVALID_ARGUMENT);E(this,Ge,e)}get editor(){return m(this,Ge)}static get name(){throw new Error(p.MISSING_NAME)}static get dependencies(){return[]}static get config(){return{}}init(){throw new Error(p.NOT_IMPLEMENTED)}_(e){return this.editor.translator.translate(this.constructor.name,e)}_base(e){return this.editor.translator.translate("base",e)}_i18n(e){e[this.editor.config.base.lang]&&this.editor.translator.set(this.constructor.name,e[this.editor.config.base.lang])}_tag(e){this.editor.tags.set(new me(e))}_command(e){this.editor.commands.set(new C(this.editor,this.constructor.name,e))}_toolbar(e,t=void 0){this.editor.toolbar.appendChild(u(this,de,bi).call(this,e,e,void 0,t))}_formatbar(e,t=void 0,i=void 0){let n=this._base("Alt"),h=this._base("Shift"),f=e+(t?` [${n} + ${h} + ${t}]`:"");this.editor.formatbar.appendChild(u(this,de,bi).call(this,e,f,t,i))}_focusbar(e,t=void 0){this.editor.focusbar.appendChild(u(this,de,bi).call(this,e,e,void 0,t))}};Ge=new WeakMap,de=new WeakSet,bi=function(e,t,i=void 0,n=void 0){if(!I(e)||!I(t)||!V(i))throw new Error(p.INVALID_ARGUMENT);return this.editor.dom.createElement(r.BUTTON,{attributes:{type:"button",title:t,"data-command":n||this.constructor.name,"data-key":i},html:e})};var z,_t=class{constructor(e=[]){l(this,z,new Map);e.forEach(t=>this.set(t))}get(e){return m(this,z).get(e)}set(e){if(!(e instanceof d))throw new Error(p.INVALID_ARGUMENT);m(this,z).set(e.constructor.name,e)}init(){m(this,z).forEach(e=>e.init())}freeze(){m(this,z).forEach(e=>Object.freeze(e)),Object.freeze(m(this,z)),Object.freeze(this)}};z=new WeakMap;var re,wt=class{constructor(e=[]){l(this,re,new Map);e.forEach(t=>this.set(t))}get(e){return m(this,re).get(e instanceof HTMLElement?e.localName:e)}set(e){if(!(e instanceof me))throw new Error(p.INVALID_ARGUMENT);m(this,re).set(e.name,e)}allowed(e,t,i=!1){let n=i?t:this.get(t)?.group;return!!this.get(e)?.children.includes(n)}freeze(){m(this,re).forEach(e=>{Object.freeze(e.children),Object.freeze(e.attributes),Object.freeze(e)}),Object.freeze(m(this,re)),Object.freeze(this)}};re=new WeakMap;var ie,Dt=class{constructor(){l(this,ie,new Map)}get(e){return m(this,ie).get(e)}set(e,t){if(!I(e)||!(t instanceof Object))throw new Error(p.INVALID_ARGUMENT);m(this,ie).set(e,t)}translate(e,t){return this.get(e)?.[t]||t}freeze(){m(this,ie).forEach(e=>Object.freeze(e)),Object.freeze(m(this,ie)),Object.freeze(this)}};ie=new WeakMap;var He,ce,ve,Ve,Ke,ze,qe,We,$e,Qe,Ye,Ze,Rt,Mt,Bt,Ot,St,Ct,R=class{constructor(e,t={}){l(this,He,void 0);l(this,ce,{});l(this,ve,void 0);l(this,Ve,void 0);l(this,Ke,void 0);l(this,ze,void 0);l(this,qe,void 0);l(this,We,void 0);l(this,$e,void 0);l(this,Qe,void 0);l(this,Ye,void 0);l(this,Ze,void 0);l(this,Rt,new Dt);l(this,Mt,new wt);l(this,Bt,new Nt);l(this,Ot,new Lt);l(this,St,new jt);l(this,Ct,new _t);if(!(e instanceof HTMLElement)||!(t instanceof Object))throw new Error(p.INVALID_ARGUMENT);E(this,He,e),E(this,ce,t),E(this,ve,new le(this,this.orig.ownerDocument)),E(this,Ve,this.dom.createElement(r.EDITOR)),E(this,Ke,this.dom.createElement(r.TOOLBAR,{attributes:{role:"toolbar"}})),this.element.appendChild(this.toolbar),E(this,ze,new ee(this.toolbar)),E(this,qe,this.dom.createElement(r.FORMATBAR,{attributes:{role:"toolbar"}})),this.formatbar.hidden=!0,this.element.appendChild(this.formatbar),E(this,We,new ee(this.formatbar)),E(this,$e,this.dom.createElement(r.FOCUSBAR,{attributes:{role:"toolbar"}})),this.focusbar.hidden=!0,this.element.appendChild(this.focusbar),E(this,Qe,new ee(this.focusbar)),E(this,Ye,this.dom.createElement(r.ROOT)),this.element.appendChild(this.root),E(this,Ze,new ee(this.root))}get orig(){return m(this,He)}get config(){return m(this,ce)}get dom(){return m(this,ve)}get element(){return m(this,Ve)}get toolbar(){return m(this,Ke)}get toolbarDispatcher(){return m(this,ze)}get formatbar(){return m(this,qe)}get formatbarDispatcher(){return m(this,We)}get focusbar(){return m(this,$e)}get focusbarDispatcher(){return m(this,Qe)}get root(){return m(this,Ye)}get rootDispatcher(){return m(this,Ze)}get translator(){return m(this,Rt)}get tags(){return m(this,Mt)}get filters(){return m(this,Bt)}get dialogs(){return m(this,Ot)}get commands(){return m(this,St)}get plugins(){return m(this,Ct)}static get defaultConfig(){return{}}init(){let e=this.config;E(this,ce,{});let t=this.constructor.defaultConfig.base?.plugins||[],i=t;if(Array.isArray(e.base?.plugins)&&e.base.plugins.length>0){let f=e.base.plugins;e.base?.pluginsDisabled?i=i.filter(b=>!f.includes(b.name)):(i=[],f.forEach(b=>{let T=t.find(j=>j.name===b);T&&i.push(T)}))}let n=new Set,h=f=>{f.dependencies?.forEach(h),n.add(f)};i.map(h),n.forEach(f=>{Object.entries(f.config).forEach(([b,T])=>{var j,S;(j=this.config)[S=f.name]??(j[S]={}),this.config[f.name][b]=e[f.name]?.[b]||this.constructor.defaultConfig[f.name]?.[b]||T}),this.plugins.set(new f(this))}),this.config.base.lang&&(this.element.lang=this.config.base.lang),this.plugins.init(),this.toolbarDispatcher.dispatch("init"),this.formatbarDispatcher.dispatch("init"),this.focusbarDispatcher.dispatch("init"),this.rootDispatcher.dispatch("init")}freeze(){Object.freeze(this.config),this.translator.freeze(),this.tags.freeze(),this.filters.freeze(),this.dialogs.freeze(),this.commands.freeze(),this.plugins.freeze()}load(){this.orig instanceof HTMLTextAreaElement?(this.orig.form.addEventListener("submit",()=>this.save()),this.setHtml(this.orig.value.replace("/&nbsp;/g"," "))):this.setHtml(this.orig.innerHTML),this.orig.insertAdjacentElement(A.AFTEREND,this.element),this.orig.hidden=!0,this.rootDispatcher.dispatch("load")}destroy(){this.element.parentElement.removeChild(this.element),this.orig.hidden=!1,this.rootDispatcher.dispatch("destroy")}getHtml(){let e=this.dom.createElement(this.root.localName,{html:this.root.innerHTML});return this.filters.filter(e),this.rootDispatcher.dispatch("gethtml",e),e.innerHTML}setHtml(e){let t=this.dom.createElement(this.root.localName,{html:e});this.rootDispatcher.dispatch("sethtml",t),this.filters.filter(t),this.root.innerHTML=t.innerHTML}save(){this.orig instanceof HTMLTextAreaElement?this.orig.value=this.getHtml():this.orig.innerHTML=this.getHtml(),this.rootDispatcher.dispatch("save")}url(e){let t=this.dom.window.origin||this.dom.window.location.origin,i=this.dom.createElement(r.A,{attributes:{href:e}});return t===i.origin?i.pathname:i.href}static create(e,t={}){let i=new this(e,t);return i.init(),i.freeze(),i.load(),i}};He=new WeakMap,ce=new WeakMap,ve=new WeakMap,Ve=new WeakMap,Ke=new WeakMap,ze=new WeakMap,qe=new WeakMap,We=new WeakMap,$e=new WeakMap,Qe=new WeakMap,Ye=new WeakMap,Ze=new WeakMap,Rt=new WeakMap,Mt=new WeakMap,Bt=new WeakMap,Ot=new WeakMap,St=new WeakMap,Ct=new WeakMap;var F,q,W,Ft,Cs,Pt,ys,yt=class{constructor(e,t,i,n){l(this,Ft);l(this,Pt);l(this,F,void 0);l(this,q,void 0);l(this,W,void 0);var h,f;if(!(e instanceof le)||!I(t)||!I(i)||!v(n))throw new Error(p.INVALID_ARGUMENT);E(this,F,e),E(this,q,m(this,F).createElement(r.FORM,{attributes:{method:"dialog"}})),u(f=u(h=this.addFieldset(),Ft,Cs).call(h,i,n),Pt,ys).call(f,t)}get form(){return m(this,q)}addFieldset(){let e=m(this,F).createElement(r.FIELDSET);return m(this,W)?m(this,W).insertAdjacentElement(A.AFTEREND,e):m(this,q).insertAdjacentElement(A.AFTERBEGIN,e),E(this,W,e),this}addLegend(e){if(!I(e))throw new Error(p.INVALID_ARGUMENT);return m(this,W).appendChild(m(this,F).createElement(r.LEGEND,{html:e})),this}addTextInput(e,t,i={}){return this.addInput(e,t,i,"text")}addNumberInput(e,t,i={}){return this.addInput(e,t,i,"number")}addInput(e,t,i={},n="text"){if(!I(e)||!I(t)||!I(n))throw new Error(p.INVALID_ARGUMENT);Object.assign(i,{id:`editor-${e}`,name:e,type:n});let h=m(this,F).createElement(r.DIV);return h.appendChild(m(this,F).createElement(r.LABEL,{attributes:{for:i.id},html:t})),h.appendChild(m(this,F).createElement(r.INPUT,{attributes:i})),i.required&&h.setAttribute("data-required",""),m(this,W).appendChild(h),this}};F=new WeakMap,q=new WeakMap,W=new WeakMap,Ft=new WeakSet,Cs=function(e,t){let i=m(this,F).createElement(r.BUTTON,{attributes:{type:"button"},html:e});return i.addEventListener("click",t),m(this,q).appendChild(i),this},Pt=new WeakSet,ys=function(e){return m(this,q).appendChild(m(this,F).createElement(r.BUTTON,{html:e})),this};var Xe,Je,et,tt,kt,Fs,Ut,Ps,rt,Ii,L=class{constructor(e,t,i=void 0){l(this,kt);l(this,Ut);l(this,rt);l(this,Xe,void 0);l(this,Je,void 0);l(this,et,void 0);l(this,tt,void 0);if(!(e instanceof R)||!I(t)||!V(i))throw new Error(p.INVALID_ARGUMENT);E(this,Xe,e),E(this,Je,t),E(this,et,i)}get editor(){return m(this,Xe)}get name(){return m(this,Je)}get url(){return m(this,et)}get formCreator(){return m(this,tt)}open(e,t={}){this.url?u(this,kt,Fs).call(this,e,t):u(this,Ut,Ps).call(this,e,t)}_(e){return this.editor.translator.translate(this.name,e)}_prepareForm(){throw new Error(p.NOT_IMPLEMENTED)}};Xe=new WeakMap,Je=new WeakMap,et=new WeakMap,tt=new WeakMap,kt=new WeakSet,Fs=function(e,t={}){this.editor.dom.open({url:this.url,name:this.name,call:e,params:t})},Ut=new WeakSet,Ps=function(e,t={}){let i=this.editor.dom.getRange(),n=()=>{i&&this.editor.dom.setRange(i),u(this,rt,Ii).call(this)};u(this,rt,Ii).call(this),E(this,tt,new yt(this.editor.dom,this._("Save"),this._("Cancel"),n)),this._prepareForm();let h=this.formCreator.form;h.addEventListener("submit",b=>{b.preventDefault(),b.stopPropagation(),n();let T={};Array.from(h.elements).forEach(j=>T[j.name]=j.value),e(T)}),Object.entries(t).forEach(([b,T])=>h.elements[b]&&(h.elements[b].value=T));let f=this.editor.dom.createElement(r.DIALOG);f.addEventListener("close",n),f.appendChild(h),f.show(),this.editor.element.appendChild(f)},rt=new WeakSet,Ii=function(){Array.from(this.editor.element.getElementsByTagName(r.DIALOG)).forEach(e=>{e.parentElement.removeChild(e)})};var Gt=class extends L{constructor(e){super(e,he.name)}_prepareForm(){this.formCreator.addLegend(this._("Abbreviation")).addTextInput("title",this._("Full term"),{placeholder:this._("Insert full term or leave empty to remove it")})}};var it,g=class{constructor(e){l(this,it,void 0);if(!(e instanceof R))throw new Error(p.INVALID_ARGUMENT);E(this,it,e)}get editor(){return m(this,it)}handleEvent(e){v(this[e.type])&&this[e.type](e)}};it=new WeakMap;var Ht=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.hasAttribute("data-alignable")&&e.detail.element.addEventListener("keydown",this)}keydown(e){let t={[a.UP]:O.NONE,[a.LEFT]:O.LEFT,[a.DOWN]:O.CENTER,[a.RIGHT]:O.RIGHT};e.target===e.currentTarget&&x(e,Object.keys(t),{shift:!0})&&(e.preventDefault(),e.stopPropagation(),e.target.classList.remove(...Object.values(t)),t[e.key]!==O.NONE&&e.target.classList.add(t[e.key]))}};var Vt,ks,st,Ni,vt=class extends D{constructor(){super(...arguments);l(this,Vt);l(this,st)}filter(e){let t=this.editor.tags.get(e),i=this.editor.tags.allowed(e,r.P),n=t.editable||t.group===s.FORMAT,h=[],f=(b=null)=>{i&&h.length>0&&(e.insertBefore(this.editor.dom.createElement(r.P,{html:h.join(" ")}),b),h=[])};Array.from(e.childNodes).forEach(b=>{let T=b.textContent.trim();if(b instanceof HTMLElement){let j=u(this,Vt,ks).call(this,b),S=this.editor.tags.get(j);if(S&&this.editor.tags.allowed(e,j))f(j),u(this,st,Ni).call(this,j,S);else if(S&&S.group===s.FORMAT&&i){let _=u(this,st,Ni).call(this,j,S);_&&(h.push(_.outerHTML),e.removeChild(_))}else!n&&T&&i?(h.push(T),e.removeChild(j)):n&&T?e.replaceChild(this.editor.dom.createText(T),j):e.removeChild(j)}else b instanceof Text?(!n&&T&&i&&h.push(T),(!n||!T)&&e.removeChild(b)):b instanceof Node&&e.removeChild(b)}),f()}};Vt=new WeakSet,ks=function(e){let t=this.editor.config.base.filter[e.localName];if(!t)return e;let i=this.editor.dom.createElement(t,{html:e.innerHTML});return e.parentElement.replaceChild(i,e),i},st=new WeakSet,Ni=function(e,t){if(Array.from(e.attributes).forEach(i=>!t.attributes.includes(i.name)&&e.removeAttribute(i.name)),e.hasChildNodes()&&this.editor.filters.filter(e),e.hasChildNodes()||t.empty)return e;e.parentElement?.removeChild(e)};var Kt=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.hasAttribute("data-deletable")&&e.detail.element.addEventListener("keydown",this)}keydown(e){e.target===e.currentTarget&&x(e,a.DEL,{ctrl:!0})&&(this.editor.dom.delete(e.target),e.preventDefault(),e.stopPropagation())}};var zt=class extends HTMLElement{get open(){return this.hasAttribute("open")}set open(e){e===!0?this.setAttribute("open",""):this.removeAttribute("open")}constructor(){super();this.addEventListener("keydown",e=>e.key===a.ESC&&this.close()),this.addEventListener("click",e=>e.target===this&&this.close())}connectedCallback(){this.setAttribute("role","dialog"),this.tabIndex=-1,this.focus()}show(){this.open=!0,this.dispatchEvent(new CustomEvent("show",{detail:{element:this,target:this}}))}close(){this.open=!1,this.dispatchEvent(new CustomEvent("close",{detail:{element:this,target:this}}))}};var qt=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.contentEditable==="true"?e.detail.element.addEventListener("keydown",this):e.detail.element.parentElement.contentEditable==="true"&&e.detail.element.addEventListener("dblclick",this)}keydown(e){if(x(e,a.ENTER,{shift:!0})&&!this.editor.tags.allowed(e.target,r.BR))e.preventDefault(),e.stopPropagation();else if(x(e,a.ENTER)){e.preventDefault(),e.stopPropagation();let t=this.editor.tags.get(e.target)?.enter;t&&(e.target.textContent.trim()||!e.target.hasAttribute("data-deletable")?this.editor.dom.closest(e.target,t)?.insertAdjacentElement(A.AFTEREND,this.editor.dom.createElement(t)):e.target instanceof HTMLParagraphElement||(this.editor.dom.closest(e.target,r.P)?.insertAdjacentElement(A.AFTEREND,this.editor.dom.createElement(r.P)),e.target.parentElement.removeChild(e.target)))}else x(e,a.BACKSPACE)&&!e.target.textContent&&e.target.hasAttribute("data-deletable")?(this.editor.dom.delete(e.target),e.preventDefault(),e.stopPropagation()):/^[A-Z]$/.test(e.key)&&x(e,e.key,{alt:!0,shift:!0})&&(e.preventDefault(),e.stopPropagation(),this.editor.formatbar.querySelector(`${r.BUTTON}[data-key=${e.key.toLowerCase()}]`)?.click())}dblclick(e){this.editor.dom.selectContents(e.target),this.editor.commands.find(e.target.localName)?.execute()}};var Wt=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.hasAttribute("data-focusable")&&e.detail.element.focus()}};var $=class extends g{insertbutton(e){e.detail.element.getAttribute("data-command")&&e.detail.element.addEventListener("click",this)}click(e){this.editor.commands.execute(e.target.getAttribute("data-command"))}keydown(e){if(x(e,[a.LEFT,a.RIGHT,a.HOME,a.END])){let t=e.target.previousElementSibling,i=e.target.nextElementSibling,n=e.target.parentElement.firstElementChild,h=e.target.parentElement.lastElementChild,f=e.target===n,b=e.target===h;e.key===a.LEFT&&!f?t.focus():e.key===a.RIGHT&&!b?i.focus():e.key===a.HOME||e.key===a.RIGHT&&b?n.focus():(e.key===a.END||e.key===a.LEFT&&f)&&h.focus(),e.preventDefault(),e.stopPropagation()}}_show(e,t){if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement))throw new Error(p.INVALID_ARGUMENT);e.hidden=!1;let{x:i,y:n}=t.getBoundingClientRect(),{x:h,y:f}=this.editor.root.getBoundingClientRect(),b=i-h+e.clientWidth-this.editor.root.clientWidth,T=n-f-t.scrollTop+this.editor.root.offsetTop-e.clientHeight,j=e.clientWidth<this.editor.root.clientWidth?i-h:0;j>0&&b>0&&(j=j>b?(j-b)/2:0),e.style.left=`${j}px`,e.style.top=`${T}px`}_hide(e){e.hidden=!0,e.removeAttribute("style")}};var ot,_i,at,wi,$t=class extends ${constructor(e){super(e);l(this,ot);l(this,at);this.editor.focusbar.addEventListener("insertbutton",this),this.editor.root.addEventListener("focusin",this),this.editor.root.addEventListener("focusout",this),this.editor.dom.document.addEventListener("selectionchange",this)}insertbutton(e){super.insertbutton(e),e.detail.element.getAttribute("data-command")&&e.detail.element.addEventListener("mousedown",this)}mousedown(e){e.preventDefault(),e.stopPropagation()}focusin(e){e.target instanceof HTMLElement&&e.target.hasAttribute("data-focusable")&&u(this,ot,_i).call(this,e.target)}focusout(){u(this,at,wi).call(this)}selectionchange(){let e=this.editor.dom.getActiveElement();!this.editor.dom.getSelection().isCollapsed||!e?u(this,at,wi).call(this):e instanceof HTMLElement&&e.hasAttribute("data-focusable")&&u(this,ot,_i).call(this,e)}};ot=new WeakSet,_i=function(e){!this.editor.focusbar.children.length||(this._show(this.editor.focusbar,e),Object.keys(e.dataset).forEach(t=>this.editor.focusbar.dataset[t]=e.dataset[t]),this.editor.focusbar.dataset.tag=e.localName)},at=new WeakSet,wi=function(){this._hide(this.editor.focusbar),Object.keys(this.editor.focusbar.dataset).forEach(e=>delete this.editor.focusbar.dataset[e])};var Qt=class extends ${constructor(e){super(e);this.editor.formatbar.addEventListener("insertbutton",this),this.editor.dom.document.addEventListener("selectionchange",this)}selectionchange(){let e=this.editor.dom.getSelectedEditable();e&&!this.editor.dom.getSelection().isCollapsed&&this.editor.tags.allowed(e,s.FORMAT,!0)?this._show(this.editor.formatbar,e):this._hide(this.editor.formatbar)}};var Zt,Us,Yt=class extends g{constructor(e){super(e);l(this,Zt);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.hasAttribute("data-navigable")&&(e.detail.element.tabIndex=0,e.detail.element.addEventListener("keydown",this))}keydown(e){if(e.target===e.currentTarget&&x(e,[a.UP,a.DOWN,a.HOME,a.END])&&u(this,Zt,Us).call(this,e.target)){let t=e.target.previousElementSibling,i=e.target.nextElementSibling,n=e.target.parentElement.firstElementChild,h=e.target.parentElement.lastElementChild,f=e.target===n,b=e.target===h;e.key===a.UP&&!f&&t.hasAttribute("data-navigable")?t.focus():e.key===a.DOWN&&!b&&i.hasAttribute("data-navigable")?i.focus():(e.key===a.HOME||e.key===a.DOWN&&b)&&n.hasAttribute("data-navigable")?n.focus():(e.key===a.END||e.key===a.UP&&f)&&h.hasAttribute("data-navigable")&&h.focus(),e.preventDefault(),e.stopPropagation()}}};Zt=new WeakSet,Us=function(e){if(e.contentEditable!=="true")return!0;let t=this.editor.dom.getSelection(),i=this.editor.dom.getSelectedEditable(),n=this.editor.dom.getSelectedElement();return t.isCollapsed&&t.anchorOffset===0&&[i,e.firstChild].includes(n)};var Xt=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element instanceof HTMLSlotElement?e.detail.element.addEventListener("keydown",this):e.detail.element.hasAttribute("data-slotable")&&!e.detail.element.querySelector(":scope > "+r.SLOT)&&e.detail.element.appendChild(this.editor.dom.createElement(r.SLOT))}keydown(e){!x(e,a.TAB)&&!x(e,a.TAB,{shift:!0})&&(e.preventDefault(),e.stopPropagation())}};var nt,Di,lt,Ri,Jt=class extends g{constructor(e){super(e);l(this,nt);l(this,lt);this.editor.root.addEventListener("insert",this)}insert(e){e.detail.element.hasAttribute("data-sortable")&&(e.detail.element.addEventListener("keydown",this),e.detail.element.addEventListener("pointerdown",this),e.detail.element.addEventListener("pointermove",this),e.detail.element.addEventListener("pointerup",this))}keydown(e){let t={[a.HOME]:w.FIRST,[a.UP]:w.PREV,[a.DOWN]:w.NEXT,[a.END]:w.LAST};e.target===e.currentTarget&&x(e,Object.keys(t),{ctrl:!0})&&(this.editor.dom.sort(e.target,t[e.key]),e.preventDefault(),e.stopPropagation())}pointerdown(e){let t=e.target.closest("[data-sortable]");t&&this.editor.dom.contains(t)&&(t.setAttribute("data-sort",""),t.setPointerCapture(e.pointerId))}pointermove(e){let t=e.target.closest("[data-sortable][data-sort]"),i=this.editor.dom.document.elementFromPoint(e.x,e.y);u(this,nt,Di).call(this),t&&this.editor.dom.contains(t)&&u(this,lt,Ri).call(this,t,i)&&i.setAttribute("data-sortover","")}pointerup(e){let t=e.target.closest("[data-sortable][data-sort]");if(t&&this.editor.dom.contains(t)){let i=this.editor.dom.document.elementFromPoint(e.x,e.y);u(this,nt,Di).call(this),t.removeAttribute("data-sort"),t.releasePointerCapture(e.pointerId),u(this,lt,Ri).call(this,t,i)&&i.insertAdjacentElement(A.BEFOREBEGIN,t)}}};nt=new WeakSet,Di=function(){this.editor.root.querySelectorAll("[data-sortover]").forEach(e=>e.removeAttribute("data-sortover"))},lt=new WeakSet,Ri=function(e,t){return e instanceof HTMLElement&&t instanceof HTMLElement&&this.editor.dom.contains(t)&&![this.editor.root,e].includes(t)&&t.hasAttribute("data-sortable")&&(e.parentElement===t.parentElement||this.editor.dom.arbitrary(e.parentElement)&&this.editor.dom.arbitrary(t.parentElement))&&this.editor.tags.allowed(t.parentElement,e)};var er=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insert",this)}insert(e){let t=this.editor.tags.get(e.detail.element);t&&(t.editable&&(e.detail.element.contentEditable="true"),["alignable","arbitrary","deletable","focusable","navigable","slotable","sortable"].forEach(i=>{t[i]&&(e.detail.element.dataset[i]="")}))}};var tr=class extends ${constructor(e){super(e);this.editor.toolbar.addEventListener("insertbutton",this)}insertbutton(e){super.insertbutton(e),e.detail.element.tabIndex=e.detail.element===this.editor.toolbar.firstElementChild?0:-1,e.detail.element.addEventListener("keydown",this)}};var Mi={de:{Alt:"Alt",Shift:"Umschalt"}};var c=class extends d{static get name(){return"base"}static get config(){return{browser:{},filter:{},lang:void 0,plugins:[],pluginsDisabled:!1}}init(){this._i18n(Mi),this.editor.dom.registerElement(r.DIALOG,zt),this._tag({name:r.ROOT,group:s.ROOT,children:[s.AUDIO,s.BLOCK,s.CONTAINER,s.FIGURE,s.HEADING,s.IFRAME,s.IMAGE,s.LIST,s.PARAGRAPH,s.PREFORMAT,s.QUOTE,s.RULE,s.TABLE,s.VIDEO]}),this._tag({name:r.SLOT,group:s.SLOT,editable:!0,focusable:!0,navigable:!0,sortable:!0}),new er(this.editor),new tr(this.editor),new Qt(this.editor),new $t(this.editor),new qt(this.editor),new Kt(this.editor),new Yt(this.editor),new Jt(this.editor),new Ht(this.editor),new Wt(this.editor),new Xt(this.editor),this.editor.filters.add(new vt(this.editor))}};var Bi={de:{Abbreviation:"Abk\xFCrzung",Cancel:"Abbrechen","Full term":"Langform","Insert full term or leave empty to remove it":"Langform eingeben oder zum Entfernen leer lassen",Save:"Speichern"}};var he=class extends d{static get name(){return"abbreviation"}static get dependencies(){return[c]}init(){this._i18n(Bi),this._tag({name:r.ABBR,group:s.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new Gt(this.editor)),this._command(r.ABBR),this._formatbar(this._("Abbreviation"),a.A)}};var ue,rr=class extends C{constructor(e,t){let i=Object.entries(O).find(([,n])=>n===t)?.[0].toLowerCase();if(!i)throw new Error(p.INVALID_ARGUMENT);super(e,fe.name+"-"+i);l(this,ue,void 0);E(this,ue,t)}execute(){let e=this.editor.dom.getActiveElement();e?.hasAttribute("data-alignable")&&(e.classList.remove(...Object.values(O)),m(this,ue)!==O.NONE&&e.classList.add(m(this,ue)))}};ue=new WeakMap;var Oi={de:{"Align center":"zentriert","Align left":"linksb\xFCndig","Align right":"rechtsb\xFCndig","No alignment":"Keine Ausrichtung"}};var fe=class extends d{static get name(){return"align"}static get dependencies(){return[c]}init(){this._i18n(Oi);let e={[O.NONE]:this._("No alignment"),[O.LEFT]:this._("Align left"),[O.CENTER]:this._("Align center"),[O.RIGHT]:this._("Align right")};Object.entries(e).forEach(([t,i])=>{let n=new rr(this.editor,t);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var ir=class extends L{constructor(e,t=void 0){super(e,Q.name,t)}_prepareForm(){this.formCreator.addLegend(this._("Audio")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to audio"),required:"required"}).addTextInput("id",this._("ID"))}};var mt,Si,sr=class extends g{constructor(e){super(e);l(this,mt);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertaudio",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.AUDIO)).forEach(t=>u(this,mt,Si).call(this,t))}insertaudio(e){u(this,mt,Si).call(this,e.detail.element)}};mt=new WeakSet,Si=function(e){let t=e.getAttribute("src");t?(e.setAttribute("src",this.editor.url(t)),e.controls=!0,this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:Q.name}})):e.parentElement.removeChild(e)};var or=class extends D{filter(e){e.querySelectorAll(`${r.FIGURE} > ${r.FIGCAPTION}:only-child`).forEach(t=>t.parentElement.removeChild(t))}};var ar=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insertfigure",this)}insertfigure(e){e.detail.element.querySelector(":scope > "+r.FIGCAPTION)||e.detail.element.appendChild(this.editor.dom.createElement(r.FIGCAPTION))}};var M=class extends d{static get name(){return"figure"}static get dependencies(){return[c]}init(){this._tag({name:r.FIGURE,group:s.FIGURE,children:[s.AUDIO,s.CAPTION,s.IFRAME,s.IMAGE,s.PREFORMAT,s.QUOTE,s.TABLE,s.VIDEO],attributes:["class"],alignable:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._tag({name:r.FIGCAPTION,group:s.CAPTION,children:[s.FORMAT],editable:!0,navigable:!0,enter:r.P}),new ar(this.editor),this.editor.filters.add(new or(this.editor))}};var Ci={de:{Audio:"Audio",Cancel:"Abbrechen",ID:"ID","Insert URL to audio":"URL zur Audiodatei eingeben",Save:"Speichern",URL:"URL"}};var Q=class extends d{static get name(){return"audio"}static get dependencies(){return[c,M]}static get config(){return{browser:void 0}}init(){this._i18n(Ci),this._tag({name:r.AUDIO,group:s.AUDIO,attributes:["controls","id","src"],empty:!0,navigable:!0}),new sr(this.editor),this.editor.dialogs.set(new ir(this.editor,this.editor.config.audio.browser)),this._command(r.AUDIO),this._toolbar(this._("Audio"))}};var nr=class extends L{constructor(e,t=void 0){super(e,pe.name,t)}_prepareForm(){this.formCreator.addLegend(this._("Block")).addTextInput("id",this._("ID"),{required:"required"})}};var lr=class extends HTMLElement{get content(){return this.shadowRoot.innerHTML}set content(e){this.shadowRoot.innerHTML=e}constructor(){super();this.attachShadow({mode:"open"})}};var mr=class extends g{constructor(e){super(e);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertappblock",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.BLOCK)).forEach(t=>t.id||t.parentElement.removeChild(t))}async insertappblock(e){if(!e.detail.element.id){e.detail.element.parentElement.removeChild(e.detail.element);return}if(!this.editor.config.block.api)return;let t=this.editor.config.block.api.replace("{id}",e.detail.element.id),i=await fetch(t,{mode:"no-cors"});if(!i.ok)return;let n="";this.editor.config.block.css&&(n=this.editor.config.block.css.split(",").map(f=>`<link rel="stylesheet" href="${f}">`).join(""));let h=await i.text();e.detail.element.content=n+h}};var dr={de:{Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID",Ifrane:"Iframe","Insert URL to embedded page":"URL zur eingebetteten Seite eingeben",Save:"Speichern",URL:"URL",Width:"Breite"}};var pe=class extends d{static get name(){return"block"}static get dependencies(){return[c]}static get config(){return{api:void 0,browser:void 0,css:void 0}}init(){this._i18n(dr),this.editor.dom.registerElement(r.BLOCK,lr),this._tag({name:r.BLOCK,group:s.BLOCK,attributes:["id"],deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),new mr(this.editor),this.editor.dialogs.set(new nr(this.editor,this.editor.config.block.browser)),this._command(r.BLOCK),this._toolbar(this._("Block"))}};var cr=class extends D{filter(e){e instanceof HTMLElement&&e.localName===r.FIGURE&&e.classList.contains(G.name)&&e.querySelector(":scope > "+r.BLOCKQUOTE)&&!e.querySelector(":scope > "+r.FIGCAPTION)&&(e.insertAdjacentElement(A.BEFOREBEGIN,e.querySelector(":scope > "+r.BLOCKQUOTE)),e.parentElement.removeChild(e))}};var hr=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insertblockquote",this),this.editor.root.addEventListener("deleteblockquote",this)}insertblockquote(e){this.editor.dom.wrap(e.detail.element,r.FIGURE,{attributes:{class:G.name}})}deleteblockquote(e){e.detail.target.localName===r.FIGURE&&e.detail.target.classList.contains(G.name)&&e.detail.target.parentElement.removeChild(e.detail.target)}};var ur=class extends D{filter(e){if(e instanceof HTMLPreElement){e.outerHTML=e.outerHTML.replace(/(<br\s*\/?>)/gi,`
  `);return}e.innerHTML=e.innerHTML.replace(/^\s*(<br\s*\/?>\s*)+/gi,"").replace(/\s*(<br\s*\/?>\s*)+$/gi,""),e instanceof HTMLParagraphElement?e.outerHTML=e.outerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"</p><p>"):e.innerHTML=e.innerHTML.replace(/\s*(<br\s*\/?>\s*){2,}/gi,"<br>")}};var P=class extends d{static get name(){return"break"}static get dependencies(){return[c]}init(){this._tag({name:r.BR,group:s.BREAK,empty:!0}),this.editor.filters.add(new ur(this.editor))}};var yi={de:{Blockquote:"Blockzitat"}};var G=class extends d{static get name(){return"blockquote"}static get dependencies(){return[c,P,M]}init(){this._i18n(yi),this._tag({name:r.BLOCKQUOTE,group:s.QUOTE,children:[s.BREAK,s.FORMAT],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new hr(this.editor),this._command(r.BLOCKQUOTE),this._toolbar(this._("Blockquote")),this.editor.filters.add(new cr(this.editor))}};var Fi={de:{bold:"fett"}};var fr=class extends d{static get name(){return"bold"}static get dependencies(){return[c]}init(){this._i18n(Fi),this._tag({name:r.B,group:s.FORMAT}),this._command(r.B),this._formatbar(this._("bold"),a.B)}};var Pi={de:{Citation:"Zitatquelle"}};var pr=class extends d{static get name(){return"cite"}static get dependencies(){return[c]}init(){this._i18n(Pi),this._tag({name:r.CITE,group:s.FORMAT}),this._command(r.CITE),this._formatbar(this._("Citation"),a.Z)}};var ki={de:{Code:"Quelltext"}};var gr=class extends d{static get name(){return"code"}static get dependencies(){return[c]}init(){this._i18n(ki),this._tag({name:r.CODE,group:s.FORMAT}),this._command(r.CODE),this._formatbar(this._("Code"),a.C)}};var br=class extends L{constructor(e){super(e,ge.name)}_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("value",this._("Machine-readable Value"),{placeholder:this._("Insert value or leave empty to remove it")})}};var Ui={de:{Cancel:"Abbrechen",Data:"Data","Machine-readable Value":"Maschinenlesbarer Wert","Insert value or leave empty to remove it":"Wert eingeben oder zum Entfernen leer lassen",Save:"Speichern"}};var ge=class extends d{static get name(){return"data"}static get dependencies(){return[c]}init(){this._i18n(Ui),this._tag({name:r.DATA,group:s.FORMAT,attributes:["value"]}),this.editor.dialogs.set(new br(this.editor)),this._command(r.DATA),this._formatbar(this._("Data"),a.J)}};var Er=class extends L{constructor(e){super(e,be.name)}_prepareForm(){this.formCreator.addLegend(this._("Definition")).addTextInput("title",this._("Term"),{placeholder:this._("Insert term or leave empty to remove it")})}};var Gi={de:{Definition:"Definition","Insert term or leave empty to remove it":"Begriff eingeben oder zum Entfernen leer lassen",Term:"Begriff"}};var be=class extends d{static get name(){return"definition"}static get dependencies(){return[c]}init(){this._i18n(Gi),this._tag({name:r.DFN,group:s.FORMAT,attributes:["title"]}),this.editor.dialogs.set(new Er(this.editor)),this._command(r.DFN),this._formatbar(this._("Definition"),a.D)}};var Tr=class extends C{constructor(e){super(e,Ee.name)}execute(){let e=this.editor.dom.getActiveElement();e?.hasAttribute("data-deletable")&&this.editor.dom.delete(e)}};var Hi={de:{Delete:"L\xF6schen"}};var Ee=class extends d{static get name(){return"delete"}static get dependencies(){return[c]}init(){this._i18n(Hi),this.editor.commands.set(new Tr(this.editor)),this._focusbar(this._("Delete"),this.constructor.name)}};var vi={de:{"Text Deletion":"Textl\xF6schung"}};var jr=class extends d{static get name(){return"deletion"}static get dependencies(){return[c]}init(){this._i18n(vi),this._tag({name:r.DEL,group:s.FORMAT}),this._command(r.DEL),this._formatbar(this._("Text Deletion"),a.G)}};var Lr=class extends D{filter(e){e.querySelectorAll(`${r.SUMMARY}:not(:first-child)`).forEach(t=>t.parentElement.removeChild(t)),e.querySelectorAll(`${r.SUMMARY}:only-child`).forEach(t=>t.parentElement.removeChild(t))}};var dt,Vi,Ar=class extends g{constructor(e){super(e);l(this,dt);this.editor.root.addEventListener("insertdetails",this),this.editor.root.addEventListener("insertsummary",this)}insertdetails(e){e.detail.element.open=!0,e.detail.element.querySelector(`:scope > ${r.SUMMARY}:first-child`)||e.detail.element.insertAdjacentElement(A.AFTERBEGIN,this.editor.dom.createElement(r.SUMMARY))}insertsummary(e){u(this,dt,Vi).call(this,e.detail.element),e.detail.element.addEventListener("click",this),e.detail.element.addEventListener("blur",this),e.detail.element.addEventListener("keydown",this)}click(e){e.preventDefault(),e.stopPropagation(),e.target.parentElement.open=!0}blur(e){u(this,dt,Vi).call(this,e.target)}keydown(e){x(e,a.SPACE)?(e.preventDefault(),e.stopPropagation(),this.editor.dom.insertText(" ")):x(e,a.ENTER)&&(e.preventDefault(),e.stopPropagation(),e.target.parentElement.open=!0)}};dt=new WeakSet,Vi=function(e){e.textContent.trim()?e.querySelectorAll(r.BR+":not(:last-child)").forEach(t=>t.parentElement.removeChild(t)):e.textContent=this.editor.translator.translate(Te.name,"Details"),e.lastElementChild instanceof HTMLBRElement||e.appendChild(this.editor.dom.createElement(r.BR))};var Ki={de:{Details:"Details"}};var Te=class extends d{static get name(){return"details"}static get dependencies(){return[c]}init(){this._i18n(Ki),this._tag({name:r.DETAILS,group:s.CONTAINER,children:[s.AUDIO,s.FIGURE,s.IFRAME,s.IMAGE,s.LIST,s.PARAGRAPH,s.PREFORMAT,s.QUOTE,s.RULE,s.SUMMARY,s.TABLE,s.VIDEO],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this._tag({name:r.SUMMARY,group:s.SUMMARY,editable:!0,navigable:!0,enter:r.P}),new Ar(this.editor),this._command(r.DETAILS),this._toolbar(this._("Details")),this.editor.filters.add(new Lr(this.editor))}};var xr=class extends L{constructor(e){super(e,je.name)}_prepareForm(){this.formCreator.addLegend(this._("Division")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var zi={de:{Cancel:"Abbrechen","CSS class":"CSS-Klasse",Division:"Division","Insert CSS class":"CSS-Klasse eingeben",Save:"Speichern"}};var je=class extends d{static get name(){return"division"}static get dependencies(){return[c]}init(){this._i18n(zi),this._tag({name:r.DIV,group:s.CONTAINER,children:[s.AUDIO,s.BLOCK,s.FIGURE,s.IFRAME,s.IMAGE,s.PREFORMAT,s.QUOTE,s.RULE,s.TABLE,s.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new xr(this.editor)),this._command(r.DIV),this._toolbar(this._("Division"))}};var qi={de:{emphasized:"betont"}};var Ir=class extends d{static get name(){return"emphasis"}static get dependencies(){return[c]}init(){this._i18n(qi),this._tag({name:r.EM,group:s.FORMAT}),this._command(r.EM),this._formatbar(this._("emphasized"),a.E)}};var Wi={de:{Heading:"\xDCberschrift"}};var Nr=class extends d{static get name(){return"heading"}static get dependencies(){return[c]}init(){this._i18n(Wi),this._tag({name:r.H2,group:s.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H2),this._toolbar(this._("Heading"))}};var $i={de:{"Horizontal Rule":"Horizontale Linie"}};var _r=class extends d{static get name(){return"horizontalrule"}static get dependencies(){return[c]}init(){this._i18n($i),this._tag({name:r.HR,group:s.RULE,deletable:!0,empty:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.HR),this._toolbar(this._("Horizontal Rule"))}};var wr=class extends L{constructor(e,t=void 0){super(e,Y.name,t)}_prepareForm(){this.formCreator.addLegend(this._("Iframe")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to embedded page"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var ct,Qi,Dr=class extends g{constructor(e){super(e);l(this,ct);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertiframe",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.IFRAME)).forEach(t=>u(this,ct,Qi).call(this,t))}insertiframe(e){u(this,ct,Qi).call(this,e.detail.element)}};ct=new WeakSet,Qi=function(e){let t=e.getAttribute("src");t?(e.setAttribute("src",this.editor.url(t)),e.allowFullscreen=!0,this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:Y.name}})):e.parentElement.removeChild(e)};var Y=class extends d{static get name(){return"iframe"}static get dependencies(){return[c,M]}static get config(){return{browser:void 0}}init(){this._i18n(dr),this._tag({name:r.IFRAME,group:s.IFRAME,attributes:["allowfullscreen","height","id","src","width"],empty:!0,navigable:!0}),new Dr(this.editor),this.editor.dialogs.set(new wr(this.editor,this.editor.config.iframe.browser)),this._command(r.IFRAME),this._toolbar(this._("Iframe"))}};var Rr=class extends L{constructor(e,t=void 0){super(e,Z.name,t)}_prepareForm(){this.formCreator.addLegend(this._("Image")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to image"),required:"required"}).addTextInput("alt",this._("Alternative text"),{placeholder:this._("Text shown when media element is not available")}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var ht,Yi,Mr=class extends g{constructor(e){super(e);l(this,ht);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertimg",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.IMG)).forEach(t=>u(this,ht,Yi).call(this,t))}insertimg(e){u(this,ht,Yi).call(this,e.detail.element)}};ht=new WeakSet,Yi=function(e){let t=e.getAttribute("src");t?(e.setAttribute("src",this.editor.url(t)),this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:Z.name}})):e.parentElement.removeChild(e)};var Zi={de:{"Alternative text":"Alternativtext",Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID",Image:"Bild","Insert URL to image":"URL zur Bilddatei eingeben",Save:"Speichern","Text shown when media element is not available":"Ersatztext, falls Medienelement nicht verf\xFCgbar ist",URL:"URL",Width:"Breite"}};var Z=class extends d{static get name(){return"image"}static get dependencies(){return[c,M]}static get config(){return{browser:void 0}}init(){this._i18n(Zi),this._tag({name:r.IMG,group:s.IMAGE,attributes:["alt","height","id","src","width"],empty:!0,navigable:!0}),new Mr(this.editor),this.editor.dialogs.set(new Rr(this.editor,this.editor.config.image.browser)),this._command(r.IMG),this._toolbar(this._("Image"))}};var Xi={de:{"Text Insertion":"Texteinf\xFCgung"}};var Br=class extends d{static get name(){return"insertion"}static get dependencies(){return[c]}init(){this._i18n(Xi),this._tag({name:r.INS,group:s.FORMAT}),this._command(r.INS),this._formatbar(this._("Text Insertion"),a.F)}};var Ji={de:{italic:"kursiv"}};var Or=class extends d{static get name(){return"italic"}static get dependencies(){return[c]}init(){this._i18n(Ji),this._tag({name:r.I,group:s.FORMAT}),this._command(r.I),this._formatbar(this._("italic"),a.I)}};var es={de:{"User Input":"Benutzereingabe"}};var Sr=class extends d{static get name(){return"keyboard"}static get dependencies(){return[c]}init(){this._i18n(es),this._tag({name:r.KBD,group:s.FORMAT}),this._command(r.KBD),this._formatbar(this._("User Input"),a.K)}};var Cr=class extends L{constructor(e){super(e,Le.name)}_prepareForm(){this.formCreator.addLegend(this._("Link")).addTextInput("href",this._("URL"),{pattern:"(https?|/|mailto:|tel:).+",placeholder:this._("Insert link or leave empty to unlink")})}};var ut,ts,yr=class extends g{constructor(e){super(e);l(this,ut);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("inserta",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.A)).forEach(t=>u(this,ut,ts).call(this,t))}inserta(e){u(this,ut,ts).call(this,e.detail.element)}};ut=new WeakSet,ts=function(e){let t=e.getAttribute("href");t?e.setAttribute("href",this.editor.url(t)):e.parentElement.replaceChild(this.editor.dom.createText(e.textContent),e)};var rs={de:{Cancel:"Abbrechen","Insert link or leave empty to unlink":"Link eingeben oder zum Entfernen leer lassen",Link:"Link",Save:"Speichern",URL:"URL"}};var Le=class extends d{static get name(){return"link"}static get dependencies(){return[c]}init(){this._i18n(rs),this._tag({name:r.A,group:s.FORMAT,attributes:["href"]}),new yr(this.editor),this.editor.dialogs.set(new Cr(this.editor)),this._command(r.A),this._formatbar(this._("Link"),a.L)}};var is={de:{mark:"markiert"}};var Fr=class extends d{static get name(){return"mark"}static get dependencies(){return[c]}init(){this._i18n(is),this._tag({name:r.MARK,group:s.FORMAT}),this._command(r.MARK),this._formatbar(this._("mark"),a.M)}};var ft,ss,Pr=class extends g{constructor(e){super(e);l(this,ft);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertli",this),this.editor.root.addEventListener("deleteli",this),this.editor.root.addEventListener("insertol",this),this.editor.root.addEventListener("insertul",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.LI)).forEach(t=>u(this,ft,ss).call(this,t))}insertli(e){u(this,ft,ss).call(this,e.detail.element)}deleteli(e){e.detail.target.children.length===0&&e.detail.target.parentElement.removeChild(e.detail.target)}insertol(e){e.detail.element.children.length===0&&e.detail.element.appendChild(this.editor.dom.createElement(r.LI))}insertul(e){this.insertol(e)}};ft=new WeakSet,ss=function(e){!(e.parentElement instanceof HTMLOListElement)&&!(e.parentElement instanceof HTMLUListElement)&&this.editor.dom.wrap(e,r.UL)};var Ae=class extends d{static get name(){return"list"}static get dependencies(){return[c,P]}init(){this._tag({name:r.LI,group:s.LISTITEM,children:[s.BREAK,s.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.LI}),new Pr(this.editor)}};var os={de:{"Ordered List":"Geordnete Liste"}};var kr=class extends d{static get name(){return"orderedlist"}static get dependencies(){return[c,Ae]}init(){this._i18n(os),this._tag({name:r.OL,group:s.LIST,children:[s.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.OL),this._toolbar(this._("Ordered List"))}};var pt,as,Ur=class extends g{constructor(e){super(e);l(this,pt);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertp",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.P)).forEach(t=>u(this,pt,as).call(this,t))}insertp(e){u(this,pt,as).call(this,e.detail.element)}paste(e){this.editor.dom.window.setTimeout(()=>this.editor.filters.filter(e.target))}};pt=new WeakSet,as=function(e){e.addEventListener("paste",this)};var ns={de:{Paragraph:"Absatz"}};var Gr=class extends d{static get name(){return"paragraph"}static get dependencies(){return[c,P]}init(){this._i18n(ns),this._tag({name:r.P,group:s.PARAGRAPH,children:[s.BREAK,s.FORMAT],deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),new Ur(this.editor),this._command(r.P),this._toolbar(this._("Paragraph"))}};var Hr=class extends D{filter(e){e instanceof HTMLElement&&e.localName===r.FIGURE&&e.classList.contains(H.name)&&e.querySelector(":scope > "+r.PRE)&&!e.querySelector(":scope > "+r.FIGCAPTION)&&(e.insertAdjacentElement(A.BEFOREBEGIN,e.querySelector(":scope > "+r.PRE)),e.parentElement.removeChild(e))}};var vr=class extends g{constructor(e){super(e);this.editor.root.addEventListener("insertpre",this),this.editor.root.addEventListener("deletepre",this)}insertpre(e){this.editor.dom.wrap(e.detail.element,r.FIGURE,{attributes:{class:H.name}})}deletepre(e){e.detail.target.localName===r.FIGURE&&e.detail.target.classList.contains(H.name)&&e.detail.target.parentElement.removeChild(e.detail.target)}};var ls={de:{"Preformatted Text":"Vorformatierter Text"}};var H=class extends d{static get name(){return"preformat"}static get dependencies(){return[c,P,M]}init(){this._i18n(ls),this._tag({name:r.PRE,group:s.PREFORMAT,children:[s.BREAK],deletable:!0,editable:!0,navigable:!0,enter:r.P}),new vr(this.editor),this._command(r.PRE),this._toolbar(this._("Preformatted Text")),this.editor.filters.add(new Hr(this.editor))}};var ms={de:{Quote:"Zitat"}};var Vr=class extends d{static get name(){return"quote"}static get dependencies(){return[c]}init(){this._i18n(ms),this._tag({name:r.Q,group:s.FORMAT}),this._command(r.Q),this._formatbar(this._("Quote"),a.Q)}};var ds={de:{"Sample Output":"Beispielausgabe"}};var Kr=class extends d{static get name(){return"sample"}static get dependencies(){return[c]}init(){this._i18n(ds),this._tag({name:r.SAMP,group:s.FORMAT}),this._command(r.SAMP),this._formatbar(this._("Sample Output"),a.O)}};var zr=class extends L{constructor(e){super(e,xe.name)}_prepareForm(){this.formCreator.addLegend(this._("Section")).addTextInput("class",this._("CSS class"),{placeholder:this._("Insert CSS class")})}};var cs={de:{Cancel:"Abbrechen","CSS class":"CSS-Klasse","Insert CSS class":"CSS-Klasse eingeben",Save:"Speichern",Section:"Sektion"}};var xe=class extends d{static get name(){return"section"}static get dependencies(){return[c]}init(){this._i18n(cs),this._tag({name:r.SECTION,group:s.CONTAINER,children:[s.AUDIO,s.FIGURE,s.HEADING,s.IFRAME,s.IMAGE,s.LIST,s.PARAGRAPH,s.PREFORMAT,s.QUOTE,s.RULE,s.TABLE,s.VIDEO],attributes:["class"],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,slotable:!0,sortable:!0}),this.editor.dialogs.set(new zr(this.editor)),this._command(r.SECTION),this._toolbar(this._("Section"))}};var hs={de:{small:"klein"}};var qr=class extends d{static get name(){return"small"}static get dependencies(){return[c]}init(){this._i18n(hs),this._tag({name:r.SMALL,group:s.FORMAT}),this._command(r.SMALL),this._formatbar(this._("small"),a.W)}};var gt,Wr=class extends C{constructor(e,t){let i=Object.entries(w).find(([,n])=>n===t)?.[0].toLowerCase();if(!i)throw new Error(p.INVALID_ARGUMENT);super(e,Ie.name+"-"+i);l(this,gt,void 0);E(this,gt,t)}execute(){let e=this.editor.dom.getActiveElement();e?.hasAttribute("data-sortable")&&this.editor.dom.sort(e,m(this,gt))}};gt=new WeakMap;var us={de:{"Sort after next element":"Hinter das n\xE4chste Element sortieren","Sort before previous element":"Vor das vorherige Element sortieren","Sort to the beginning":"An den Anfang sortieren","Sort to the end":"Ans Ende sortieren"}};var Ie=class extends d{static get name(){return"sort"}static get dependencies(){return[c]}init(){this._i18n(us);let e={[w.FIRST]:this._("Sort to the beginning"),[w.PREV]:this._("Sort before previous element"),[w.NEXT]:this._("Sort after next element"),[w.LAST]:this._("Sort to the end")};Object.entries(e).forEach(([t,i])=>{let n=new Wr(this.editor,t);this.editor.commands.set(n),this._focusbar(i,n.name)})}};var fs={de:{strikethrough:"durchgestrichen"}};var $r=class extends d{static get name(){return"strikethrough"}static get dependencies(){return[c]}init(){this._i18n(fs),this._tag({name:r.S,group:s.FORMAT}),this._command(r.S),this._formatbar(this._("strikethrough"),a.R)}};var ps={de:{"strongly emphasized":"stark betont"}};var Qr=class extends d{static get name(){return"strong"}static get dependencies(){return[c]}init(){this._i18n(ps),this._tag({name:r.STRONG,group:s.FORMAT}),this._command(r.STRONG),this._formatbar(this._("strongly emphasized"),a.S)}};var gs={de:{Subheading:"Unter\xFCberschrift"}};var Yr=class extends d{static get name(){return"subheading"}static get dependencies(){return[c]}init(){this._i18n(gs),this._tag({name:r.H3,group:s.HEADING,deletable:!0,editable:!0,focusable:!0,navigable:!0,sortable:!0,enter:r.P}),this._command(r.H3),this._toolbar(this._("Subheading"))}};var bs={de:{subscript:"tiefgestellt"}};var Zr=class extends d{static get name(){return"subscript"}static get dependencies(){return[c]}init(){this._i18n(bs),this._tag({name:r.SUB,group:s.FORMAT}),this._command(r.SUB),this._formatbar(this._("subscript"),a.X)}};var Es={de:{superscript:"hochgestellt"}};var Xr=class extends d{static get name(){return"superscript"}static get dependencies(){return[c]}init(){this._i18n(Es),this._tag({name:r.SUP,group:s.FORMAT}),this._command(r.SUP),this._formatbar(this._("superscript"),a.Y)}};var Jr=class extends C{constructor(e){super(e,y.name,r.TABLE)}insert({rows:e,cols:t}={}){let i=this.editor.dom.createElement(r.FIGURE,{attributes:{class:y.name}}),n=this.editor.dom.createElement(r.TABLE),h=this.editor.dom.createElement(r.TBODY),f=parseInt(e,10)||1,b=parseInt(t,10)||1;for(let T=0;T<f;T++){let j=this.editor.dom.createElement(r.TR);h.appendChild(j);for(let S=0;S<b;++S)j.appendChild(this.editor.dom.createElement(r.TD))}n.appendChild(h),i.appendChild(n),this.editor.dom.insert(i)}};var ei=class extends L{constructor(e){super(e,y.name)}_prepareForm(){this.formCreator.addLegend(this._("Table")).addNumberInput("rows",this._("Rows"),{min:"1",required:"required",value:"1"}).addNumberInput("cols",this._("Columns"),{min:"1",required:"required",value:"1"})}};var ti=class extends D{filter(e){e instanceof HTMLElement&&e.localName===r.FIGURE&&e.classList.contains(y.name)&&e.querySelector(":scope > "+r.TABLE)&&!e.querySelector(":scope > "+r.FIGCAPTION)?(e.insertAdjacentElement(A.BEFOREBEGIN,e.querySelector(":scope > "+r.TABLE)),e.parentElement.removeChild(e)):(e instanceof HTMLTableElement&&e.querySelector(`:scope > ${r.THEAD}, :scope > ${r.TFOOT}`)&&!e.querySelector(":scope > "+r.TBODY)||e instanceof HTMLTableSectionElement&&e.rows.length<=0||e instanceof HTMLTableRowElement&&!e.querySelector(`:scope > ${r.TH}:not(:empty), :scope > ${r.TD}:not(:empty)`))&&e.parentElement.removeChild(e)}};var se,ii,Ne,Ei,si,Gs,ri=class extends g{constructor(e){super(e);l(this,se);l(this,Ne);l(this,si);this.editor.root.addEventListener("inserttable",this),this.editor.root.addEventListener("inserttd",this),this.editor.root.addEventListener("insertth",this)}inserttable(e){this.editor.dom.wrap(e.detail.element,r.FIGURE,{attributes:{class:y.name}}),e.detail.element.tBodies.length>0&&e.detail.element.tBodies[0].rows[0]&&(!e.detail.element.tHead||!e.detail.element.tFoot)&&(e.detail.element.tHead||u(this,se,ii).call(this,e.detail.element.createTHead(),e.detail.element.tBodies[0].rows[0].cells.length),e.detail.element.tFoot||u(this,se,ii).call(this,e.detail.element.createTFoot(),e.detail.element.tBodies[0].rows[0].cells.length))}inserttd(e){e.detail.element.addEventListener("keydown",this)}insertth(e){e.detail.element.addEventListener("keydown",this)}keydown(e){let t=e.target,i=t.parentElement,n=i.parentElement,h=n instanceof HTMLTableElement?n:n.parentElement,f=[a.LEFT,a.RIGHT,a.UP,a.DOWN],b=x(e,f),T=x(e,f,{ctrl:!0}),j=x(e,f,{alt:!0}),S=x(e,f,{alt:!0,shift:!0});if(t instanceof HTMLTableCellElement&&i instanceof HTMLTableRowElement&&(n instanceof HTMLTableElement||n instanceof HTMLTableSectionElement)&&h instanceof HTMLTableElement&&(b&&u(this,si,Gs).call(this,t,e.key)||T||j||S)){let _=t.cellIndex,U=i.cells.length,oe=n.rows.length,k=n instanceof HTMLTableElement?i.rowIndex:i.sectionRowIndex,ci=_===0,hi=_===U-1,Ds=k===0,Rs=k===oe-1,ji=i.rowIndex===0,Li=i.rowIndex===h.rows.length-1;e.preventDefault(),e.stopPropagation(),b?e.key===a.LEFT&&!ci?this.editor.dom.focusEnd(i.cells[_-1]):e.key===a.LEFT&&ji?this.editor.dom.focusEnd(h.rows[h.rows.length-1].cells[U-1]):e.key===a.LEFT?this.editor.dom.focusEnd(h.rows[i.rowIndex-1].cells[U-1]):e.key===a.RIGHT&&!hi?i.cells[_+1].focus():e.key===a.RIGHT&&Li?h.rows[0].cells[0].focus():e.key===a.RIGHT?h.rows[i.rowIndex+1].cells[0].focus():e.key===a.UP&&ji?h.rows[h.rows.length-1].cells[_].focus():e.key===a.UP?h.rows[i.rowIndex-1].cells[_].focus():e.key===a.DOWN&&Li?h.rows[0].cells[_].focus():e.key===a.DOWN&&h.rows[i.rowIndex+1].cells[_].focus():T?(e.key===a.LEFT&&U>1&&ci?Array.from(h.rows).forEach(N=>N.appendChild(N.cells[_])):e.key===a.LEFT&&U>1?Array.from(h.rows).forEach(N=>N.insertBefore(N.cells[_],N.cells[_-1])):e.key===a.RIGHT&&U>1&&hi?Array.from(h.rows).forEach(N=>N.insertBefore(N.cells[_],N.cells[0])):e.key===a.RIGHT&&U>1?Array.from(h.rows).forEach(N=>N.insertBefore(N.cells[_+1],N.cells[_])):e.key===a.UP&&oe>1&&Ds?n.appendChild(i):e.key===a.UP&&oe>1?n.insertBefore(i,n.rows[k-1]):e.key===a.DOWN&&oe>1&&Rs?n.insertBefore(i,n.rows[0]):e.key===a.DOWN&&oe>1&&n.insertBefore(n.rows[k+1],i),t.focus()):j?e.key===a.LEFT?Array.from(h.rows).forEach(N=>u(this,Ne,Ei).call(this,N,N.cells[_])):e.key===a.RIGHT?Array.from(h.rows).forEach(N=>u(this,Ne,Ei).call(this,N,N.cells[_+1])):e.key===a.UP?u(this,se,ii).call(this,n,U,k):e.key===a.DOWN&&u(this,se,ii).call(this,n,U,k+1):S&&(e.key===a.LEFT&&!ci?Array.from(h.rows).forEach(N=>N.deleteCell(_-1)):e.key===a.RIGHT&&!hi?Array.from(h.rows).forEach(N=>N.deleteCell(_+1)):e.key===a.UP&&k>0?n.deleteRow(k-1):e.key===a.DOWN&&k<oe-1&&n.deleteRow(k+1))}}};se=new WeakSet,ii=function(e,t,i=0){let n=e.insertRow(i);for(let h=0;h<t;h++)u(this,Ne,Ei).call(this,n)},Ne=new WeakSet,Ei=function(e,t=null){let i=e.parentElement.localName===r.THEAD?r.TH:r.TD;e.insertBefore(this.editor.dom.createElement(i),t)},si=new WeakSet,Gs=function(e,t){if([a.UP,a.DOWN].includes(t))return!0;let i=this.editor.dom.getSelection(),n=i.anchorNode instanceof HTMLElement?i.anchorNode:e;if(!i.isCollapsed)return!1;if(t===a.LEFT){let f=e.firstChild;return f instanceof HTMLElement&&(f=f.firstChild),i.anchorOffset===0&&[e,f].includes(n)}let h=e.lastChild;return e.lastChild instanceof HTMLBRElement&&e.lastChild.previousSibling&&(h=e.lastChild.previousSibling),h instanceof HTMLElement&&(h=h.lastChild),i.anchorOffset===n.textContent.length&&[e,h].includes(n)};var Ts={de:{Cancel:"Abbrechen",Columns:"Spalten","Delete next column":"N\xE4chste Spalte l\xF6schen","Delete next row":"N\xE4chste Zeile l\xF6schen","Delete previous column":"Vorherige Spalte l\xF6schen","Delete previous row":"Vorherige Zeile l\xF6schen",Rows:"Zeilen",Save:"Speichern","Sort after next column":"Hinter die n\xE4chste Spalte sortieren","Sort after next row":"Hinter die n\xE4chste Zeile sortieren","Sort before previous column":"Vor die vorherige Spalte sortieren","Sort before previous row":"Vor die vorherige Zeile sortieren","Sort column to the beginning":"Spalte an den Anfang sortieren","Sort row to the beginning":"Zeile an den Anfang sortieren","Sort column to the end":"Spalte ans Ende sortieren","Sort row to the end":"Zeile ans Ende sortieren",Table:"Tabelle"}};var _e,Ti,bt,js,y=class extends d{constructor(){super(...arguments);l(this,_e);l(this,bt)}static get name(){return"table"}static get dependencies(){return[c,P,M]}init(){this._i18n(Ts),this._tag({name:r.TABLE,group:s.TABLE,children:[s.TABLESECTION],deletable:!0,navigable:!0}),this._tag(u(this,_e,Ti).call(this,r.THEAD)),this._tag(u(this,_e,Ti).call(this,r.TBODY)),this._tag(u(this,_e,Ti).call(this,r.TFOOT)),this._tag({name:r.TR,group:s.TABLEROW,children:[s.TABLECELL]}),this._tag(u(this,bt,js).call(this,r.TH)),this._tag(u(this,bt,js).call(this,r.TD)),new ri(this.editor),this.editor.filters.add(new ti(this.editor)),this.editor.dialogs.set(new ei(this.editor)),this.editor.commands.set(new Jr(this.editor)),this._toolbar(this._("Table"))}};_e=new WeakSet,Ti=function(e){return{name:e,group:s.TABLESECTION,children:[s.TABLEROW]}},bt=new WeakSet,js=function(e){return{name:e,group:s.TABLECELL,children:[s.BREAK,s.FORMAT],editable:!0,empty:!0}};var oi=class extends L{constructor(e){super(e,we.name)}_prepareForm(){this.formCreator.addLegend(this._("Data")).addTextInput("datetime",this._("Machine-readable Datetime"),{placeholder:this._("Insert date/time or leave empty to remove it")})}};var Ls={de:{Cancel:"Abbrechen","Insert date/time or leave empty to remove it":"Datum/Zeit eingeben oder zum Entfernen leer lassen","Machine-readable Datetime":"Maschinenlesbare Datums-/Zeitangabe",Save:"Speichern",Time:"Zeit"}};var we=class extends d{static get name(){return"time"}static get dependencies(){return[c]}init(){this._i18n(Ls),this._tag({name:r.TIME,group:s.FORMAT,attributes:["datetime"]}),this.editor.dialogs.set(new oi(this.editor)),this._command(r.TIME),this._formatbar(this._("Time"),a.T)}};var As={de:{underline:"unterstrichen"}};var ai=class extends d{static get name(){return"underline"}static get dependencies(){return[c]}init(){this._i18n(As),this._tag({name:r.U,group:s.FORMAT}),this._command(r.U),this._formatbar(this._("underline"),a.U)}};var xs={de:{"Unordered List":"Ungeordnete Liste"}};var ni=class extends d{static get name(){return"unorderedlist"}static get dependencies(){return[c,Ae]}init(){this._i18n(xs),this._tag({name:r.UL,group:s.LIST,children:[s.LISTITEM],arbitrary:!0,deletable:!0,focusable:!0,navigable:!0,sortable:!0}),this._command(r.UL),this._toolbar(this._("Unordered List"))}};var Is={de:{Variable:"Variable"}};var li=class extends d{static get name(){return"variable"}static get dependencies(){return[c]}init(){this._i18n(Is),this._tag({name:r.VAR,group:s.FORMAT}),this._command(r.VAR),this._formatbar(this._("Variable"),a.V)}};var mi=class extends L{constructor(e,t=void 0){super(e,X.name,t)}_prepareForm(){this.formCreator.addLegend(this._("Video")).addTextInput("src",this._("URL"),{pattern:"(https?|/).+",placeholder:this._("Insert URL to video"),required:"required"}).addNumberInput("width",this._("Width")).addNumberInput("height",this._("Height")).addTextInput("id",this._("ID"))}};var Et,Ns,di=class extends g{constructor(e){super(e);l(this,Et);this.editor.root.addEventListener("sethtml",this),this.editor.root.addEventListener("insertvideo",this)}sethtml(e){Array.from(e.detail.element.getElementsByTagName(r.VIDEO)).forEach(t=>u(this,Et,Ns).call(this,t))}insertvideo(e){u(this,Et,Ns).call(this,e.detail.element)}};Et=new WeakSet,Ns=function(e){let t=e.getAttribute("src");t?(e.setAttribute("src",this.editor.url(t)),e.controls=!0,this.editor.dom.wrap(e,r.FIGURE,{attributes:{class:X.name}})):e.parentElement.removeChild(e)};var _s={de:{Cancel:"Abbrechen",Height:"H\xF6he",ID:"ID","Insert URL to video":"URL zur Videodatei eingeben",Save:"Speichern",URL:"URL",Video:"Video",Width:"Breite"}};var X=class extends d{static get name(){return"video"}static get dependencies(){return[c,M]}static get config(){return{browser:void 0}}init(){this._i18n(_s),this._tag({name:r.VIDEO,group:s.VIDEO,attributes:["controls","height","id","src","width"],empty:!0,navigable:!0}),new di(this.editor),this.editor.dialogs.set(new mi(this.editor,this.editor.config.video.browser)),this._command(r.VIDEO),this._toolbar(this._("Video"))}};var ws=class extends R{static get defaultConfig(){return{base:{plugins:[fr,Or,Qr,Ir,ai,$r,Le,Fr,qr,be,he,Vr,pr,gr,Sr,Kr,li,Zr,Xr,we,ge,Br,jr,Gr,Nr,Yr,ni,kr,_r,G,Z,X,Q,Y,y,H,xe,Te,je,pe,fe,Ie,Ee]}}}};export{ws as default};
  