import{Command as oe,Plugin as V}from"@ckeditor/ckeditor5-core";import{findAttributeRange as R,TwoStepCaretMovement as re,Input as Ne,inlineHighlight as Be,Delete as He,TextWatcher as Fe,getLastTextLine as Re}from"@ckeditor/ckeditor5-typing";import{ClipboardPipeline as Ue}from"@ckeditor/ckeditor5-clipboard";import{priorities as _,toMap as D,Collection as le,first as ae,diff as Oe,ObservableMixin as ze,env as je,keyCodes as Ke,FocusTracker as U,KeystrokeHandler as O}from"@ckeditor/ckeditor5-utils";import{ModelLivePosition as ce,ClickObserver as Ye,Matcher as qe}from"@ckeditor/ckeditor5-engine";import{IconPreviousArrow as z,IconNextArrow as $e,IconUnlink as Ge,IconPencil as Qe,IconSettings as Ze,IconLink as de}from"@ckeditor/ckeditor5-icons";import{ButtonView as p,View as M,ViewCollection as j,FocusCycler as K,submitHandler as We,FormHeaderView as Y,ListView as q,ListItemView as $,LabeledFieldView as ue,createLabeledInputText as ke,FormRowView as he,IconView as Xe,ContextualBalloon as me,ToolbarView as Je,CssTransitionDisablerMixin as fe,SwitchButtonView as et,MenuBarMenuListItemButtonView as tt,clickOutsideHandler as it}from"@ckeditor/ckeditor5-ui";import{isWidget as nt}from"@ckeditor/ckeditor5-widget";/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ge{_definitions=new Set;_conflictChecker;get length(){return this._definitions.size}setConflictChecker(e){this._conflictChecker=e}add(e){Array.isArray(e)?e.forEach(t=>this._definitions.add(t)):this._definitions.add(e)}getDispatcher(){return e=>{const t=(n,s)=>{const o=s.createAttributeElement("a",n.attributes,{priority:5});n.classes&&s.addClass(n.classes,o);for(const l in n.styles)s.setStyle(l,n.styles[l],o);return s.setCustomProperty("link",!0,o),o},i=n=>(s,o,l)=>{if(o.attributeKey.startsWith("link")&&!(o.attributeKey=="linkHref"&&!l.consumable.test(o.item,"attribute:linkHref"))&&!(!o.item.is("selection")&&!l.schema.isInline(o.item)))for(const c of this._definitions)c.callback(o.item.getAttribute("linkHref"))&&!this._conflictChecker?.(c,o.item)&&n?o.item.is("selection")?l.writer.wrap(l.writer.document.selection.getFirstRange(),t(c,l.writer)):l.writer.wrap(l.mapper.toViewRange(o.range),t(c,l.writer)):l.writer.unwrap(l.mapper.toViewRange(o.range),t(c,l.writer))};e.on("attribute",i(!1),{priority:_.high-1}),e.on("attribute",i(!0),{priority:_.high-2})}}getDispatcherForLinkedImage(){return e=>{const t=i=>(n,s,{writer:o,mapper:l})=>{if(!s.item.is("element","imageBlock")||!s.attributeKey.startsWith("link"))return;const c=l.toViewElement(s.item),a=Array.from(c.getChildren()).find(d=>d.is("element","a"));if(a)for(const d of this._definitions){const h=D(d.attributes);if(d.callback(s.item.getAttribute("linkHref"))&&!this._conflictChecker?.(d,s.item)&&i){for(const[k,u]of h)k==="class"?o.addClass(u,a):o.setAttribute(k,u,!1,a);d.classes&&o.addClass(d.classes,a);for(const k in d.styles)o.setStyle(k,d.styles[k],a)}else{for(const[k,u]of h)k==="class"?o.removeClass(u,a):o.removeAttribute(k,u,a);d.classes&&o.removeClass(d.classes,a);for(const k in d.styles)o.removeStyle(k,a)}}};e.on("attribute",t(!1),{priority:_.high-1}),e.on("attribute",t(!0),{priority:_.high-2})}}}function be(r){if(r==null)return"";if(typeof r=="string")return r;if(Array.isArray(r))return r.map(be).join(",");const e=String(r);return e==="0"&&Object.is(Number(r),-0)?"-0":e}function st(r){return r.substring(0,1).toUpperCase()+r.substring(1)}function ot(r){return st(be(r))}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const rt=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,lt="^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))",at=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,ct=/^((\w+:(\/{2,})?)|(\W))/i,dt=["https?","ftps?","mailto"],L="Ctrl+K";function G(r){return r.is("attributeElement")&&!!r.getCustomProperty("link")}function N(r,{writer:e}){const t=e.createAttributeElement("a",{href:r},{priority:5});return e.setCustomProperty("link",!0,t),t}function T(r,e=dt){const t=String(r),i=e.join("|"),n=new RegExp(`${lt.replace("<protocols>",i)}`,"i");return ut(t,n)?t:"#"}function ut(r,e){return!!r.replace(rt,"").match(e)}function Q(r,e){const t={"Open in a new tab":r("Open in a new tab"),Downloadable:r("Downloadable")};return e.forEach(i=>("label"in i&&t[i.label]&&(i.label=t[i.label]),i)),e}function Z(r){const e=[];if(r)for(const[t,i]of Object.entries(r)){const n=Object.assign({},i,{id:`link${ot(t)}`});e.push(n)}return e}function E(r,e){return r?e.checkAttribute(r.name,"linkHref"):!1}function W(r){return at.test(r)}function C(r,e){const t=W(r)?"mailto:":e,i=!!t&&!B(r);return r&&i?t+r:r}function B(r){return ct.test(r)}function X(r){window.open(r,"_blank","noopener")}function P(r){let e="";for(const t of r.getItems()){if(!t.is("$text")&&!t.is("$textProxy"))return;e+=t.data}return e}var kt=Object.freeze({__proto__:null,LINK_KEYSTROKE:L,addLinkProtocolIfApplicable:C,createLinkElement:N,ensureSafeUrl:T,extractTextFromLinkRange:P,getLocalizedDecorators:Q,isEmail:W,isLinkElement:G,isLinkableElement:E,linkHasProtocol:B,normalizeDecorators:Z,openLink:X});/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function J(r,e){if(r.attributes&&e.attributes&&Object.keys(r.attributes).some(n=>!t(n)&&n in e.attributes)||r.styles&&e.styles&&Object.keys(r.styles).some(n=>n in e.styles))return!0;return!1;function t(i){return i==="class"||i==="style"||i==="rel"}}function ht({decoratorStates:r,allDecorators:e}){const t={...r};for(const n in r)if(r[n]&&i(n)){const s=mt(n,e);for(const o of s)t[o]=!1}function i(n){return e.some(s=>s.id===n&&!s.value)}return t}function mt(r,e){const t=e.find(i=>i.id===r);/* istanbul ignore next -- @preserve */return t?e.filter(i=>i.id!==r&&J(t,i)).map(i=>i.id):[]}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class pe extends oe{manualDecorators=new le;automaticDecorators=new ge;restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||ae(t.getSelectedBlocks());E(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const n of this.manualDecorators)n.value=this._getDecoratorStateFromModel(n.id)}execute(e,t={},i){const n=this.editor.model,s=n.document.selection,o=ht({allDecorators:Array.from(this.manualDecorators),decoratorStates:t}),l=[],c=[];for(const a in o)o[a]?l.push(a):c.push(a);n.change(a=>{const d=u=>{a.setAttribute("linkHref",e,u),l.forEach(f=>a.setAttribute(f,!0,u)),c.forEach(f=>a.removeAttribute(f,u))},h=(u,f)=>{const g=P(u);if(!g)return u;let b=i;if(b||(b=f&&f==g?e:g),b!=g){const I=a.createDocumentFragment();for(const H of u.getItems()){const S=H;a.append(a.createText(S.data,S.getAttributes()),I)}const m=a.createRangeIn(I),x=ft(g,b);let A=0;for(const{offset:H,actual:S,expected:ie}of x){const ne=H+A,F=a.createRange(m.start.getShiftedBy(ne),m.start.getShiftedBy(ne+S.length)),Se=gt(F,m).getAttributes(),De=Array.from(Se).filter(([Me])=>n.schema.getAttributeProperties(Me).isFormatting),se=a.createText(ie,De);d(se),a.remove(F),a.insert(se,F.start),A+=ie.length}return n.insertContent(I,u),a.createRange(u.start,u.start.getShiftedBy(b.length))}},k=u=>{const{plugins:f}=this.editor;if(a.setSelection(u.end),f.has("TwoStepCaretMovement"))f.get("TwoStepCaretMovement")._handleForwardMovement();else for(const g of["linkHref",...l,...c])a.removeSelectionAttribute(g)};if(s.isCollapsed){const u=s.getFirstPosition();if(s.hasAttribute("linkHref")){const f=s.getAttribute("linkHref"),g=R(u,"linkHref",f,n),b=h(g,f);d(b||g),b&&k(b)}else if(e!==""){const f=D(s.getAttributes());f.set("linkHref",e),l.forEach(b=>{f.set(b,!0)});const g=n.insertContent(a.createText(i||e,f),u);k(g)}}else{const u=Array.from(s.getRanges()),f=n.schema.getValidRanges(u,"linkHref"),g=[];for(const m of s.getSelectedBlocks())n.schema.checkAttribute(m,"linkHref")&&g.push(a.createRangeOn(m));const b=g.slice();for(const m of f)this._isRangeToUpdate(m,g)&&b.push(m);const I=u.map(m=>({start:ce.fromPosition(m.start,"toPrevious"),end:ce.fromPosition(m.end,"toNext")}));for(let m of b){const x=(m.start.textNode||m.start.nodeAfter).getAttribute("linkHref");m=h(m,x)||m,d(m)}a.setSelection(I.map(m=>{const x=m.start.toPosition(),A=m.end.toPosition();return m.start.detach(),m.end.detach(),n.createRange(x,A)}))}}),this.restoreManualDecoratorStates()}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return E(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}function ft(r,e){const t=Oe(r,e),i={equal:0,insert:0,delete:0},n=[];let s="",o="";for(const l of[...t,null])l=="insert"?o+=e[i.equal+i.insert]:l=="delete"?s+=r[i.equal+i.delete]:(s.length||o.length)&&(n.push({offset:i.equal,actual:s,expected:o}),s="",o=""),l&&i[l]++;return n}function gt(r,e){if(!r.isCollapsed)return ae(r.getItems());const t=r.start;return t.textNode?t.textNode:!t.nodeBefore||t.isEqual(e.start)?t.nodeAfter:t.nodeBefore}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class we extends oe{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();E(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change(s=>{const o=i.isCollapsed?[R(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const l of o)if(s.removeAttribute("linkHref",l),n)for(const c of n.manualDecorators)s.removeAttribute(c.id,l)})}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class _e extends ze(){id;defaultValue;label;attributes;classes;styles;constructor({id:e,label:t,attributes:i,classes:n,styles:s,defaultValue:o}){super(),this.id=e,this.set("value",void 0),this.defaultValue=o,this.label=t,this.attributes=i,this.classes=n,this.styles=s}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}function v(r,{insertAt:e}={}){if(!r||typeof document>"u")return;const t=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",window.litNonce&&i.setAttribute("nonce",window.litNonce),e==="top"&&t.firstChild?t.insertBefore(i,t.firstChild):t.appendChild(i),i.styleSheet?i.styleSheet.cssText=r:i.appendChild(document.createTextNode(r))}v(".ck .ck-link_selected{background:var(--ck-color-link-selected-background)}.ck .ck-link_selected span.image-inline{outline:var(--ck-widget-outline-thickness) solid var(--ck-color-link-selected-background)}.ck .ck-fake-link-selection{background:var(--ck-color-link-fake-selection)}.ck .ck-fake-link-selection_collapsed{border-right:1px solid var(--ck-color-base-text);height:100%;margin-right:-1px;outline:1px solid hsla(0,0%,100%,.5)}");/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const bt="ck-link_selected",ve="automatic",pt="manual",wt=/^(https?:)?\/\//;class y extends V{_linkOpeners=[];static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[re,Ne,Ue]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1,toolbar:["linkPreview","|","editLink","linkProperties","unlink"]})}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:N}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(s,o)=>N(T(s,t),o)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:s=>s.getAttribute("href")}}),e.commands.add("link",new pe(e)),e.commands.add("unlink",new we(e));const i=Q(e.t,Z(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(s=>s.mode===ve)),this._enableManualDecorators(i.filter(s=>s.mode===pt)),e.plugins.get(re).registerAttribute("linkHref"),Be(e,"linkHref","a",bt),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration(),this._enableDecoratorConflictPostfixer()}_registerLinkOpener(e){this._linkOpeners.push(e)}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link"),n=i.automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:ve,callback:s=>!!s&&wt.test(s),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(e),n.setConflictChecker((s,o)=>{for(const l of i.manualDecorators)if(o.hasAttribute(l.id)&&J(s,l))return!0}),n.length&&t.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,n=t.commands.get("link").manualDecorators;e.forEach(s=>{t.model.schema.extend("$text",{allowAttributes:s.id});const o=new _e(s);n.add(o),t.conversion.for("downcast").add(l=>{const c=d=>{const h=d.createAttributeElement("a",o.attributes,{priority:5});o.classes&&d.addClass(o.classes,h);for(const k in o.styles)d.setStyle(k,o.styles[k],h);return d.setCustomProperty("link",!0,h),h},a=d=>(h,k,u)=>{if(!(!k.item.is("selection")&&!u.schema.isInline(k.item))){if(!d&&k.attributeOldValue){if(!u.consumable.test(k.item,h.name))return;u.writer.unwrap(u.mapper.toViewRange(k.range),c(u.writer))}if(d&&k.attributeNewValue){if(!u.consumable.consume(k.item,h.name))return;k.item.is("selection")?u.writer.wrap(u.writer.document.selection.getFirstRange(),c(u.writer)):u.writer.wrap(u.mapper.toViewRange(k.range),c(u.writer))}}};l.on(`attribute:${o.id}`,a(!1),{priority:_.high-1}),l.on(`attribute:${o.id}`,a(!0),{priority:_.high-2})}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...o._createPattern()},model:{key:o.id}})})}_enableLinkOpen(){const e=this.editor,i=e.editing.view.document,n=s=>{this._linkOpeners.some(o=>o(s))||X(s)};this.listenTo(i,"click",(s,o)=>{if(!(je.isMac?o.domEvent.metaKey:o.domEvent.ctrlKey))return;let c=o.domTarget;if(c.tagName.toLowerCase()!="a"&&(c=c.closest("a")),!c)return;const a=c.getAttribute("href");a&&(s.stop(),o.preventDefault(),n(a))},{context:"$capture"}),this.listenTo(i,"keydown",(s,o)=>{const c=e.commands.get("link").value;c&&o.keyCode===Ke.enter&&o.altKey&&(s.stop(),n(c))})}_enableSelectionAttributesFixer(){const t=this.editor.model,i=t.document.selection;this.listenTo(i,"change:attribute",(n,{attributeKeys:s})=>{!s.includes("linkHref")||i.hasAttribute("linkHref")||t.change(o=>{_t(o,vt(t.schema))})})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(n,s)=>{t.change(o=>{const l=o.createRangeIn(s.content);for(const c of l.getItems())if(c.hasAttribute("linkHref")){const a=C(c.getAttribute("linkHref"),i);o.setAttribute("linkHref",a,c)}})})}_enableDecoratorConflictPostfixer(){const e=this.editor,t=e.model,i=e.commands.get("link");t.document.registerPostFixer(n=>{let s=!1;const o=t.document.differ.getChanges(),l=new Set,c=new Set(i.manualDecorators.map(a=>a.id));for(const a of o){if(a.type==="attribute"){if(a.attributeKey!=="linkHref"&&!c.has(a.attributeKey))continue;for(const d of a.range.getItems())d.hasAttribute("linkHref")&&l.add(d)}a.type==="insert"&&a.attributes.has("linkHref")&&a.position.nodeAfter&&l.add(a.position.nodeAfter)}for(const a of l){const d=[];for(const h of i.manualDecorators)if(a.hasAttribute(h.id)){for(let k=d.length-1;k>=0;k--){const u=d[k];J(u,h)&&(n.removeAttribute(u.id,a),d.splice(k,1),s=!0)}d.push(h)}}return s})}}function _t(r,e){r.removeSelectionAttribute("linkHref");for(const t of e)r.removeSelectionAttribute(t)}function vt(r){return r.getDefinition("$text").allowAttributes.filter(t=>t.startsWith("link")||t==="htmlA")}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ve extends p{constructor(e){super(e);const t=this.bindTemplate;this.set({href:void 0,withText:!0}),this.extendTemplate({attributes:{class:["ck-link-toolbar__preview"],href:t.to("href"),target:"_blank",rel:"noopener noreferrer"},on:{click:t.to(i=>{if(this.href){const n=()=>i.preventDefault();this.fire("navigate",this.href,n)}})}}),this.template.tag="a"}}v('.ck-vertical-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck-vertical-form .ck-button:focus:after{display:none}@media screen and (max-width:600px){.ck.ck-responsive-form .ck-button:after{bottom:-1px;content:"";position:absolute;right:-1px;top:-1px;width:0;z-index:1}.ck.ck-responsive-form .ck-button:focus:after{display:none}}.ck-vertical-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form{padding:var(--ck-spacing-large)}.ck.ck-responsive-form:focus{outline:none}[dir=ltr] .ck.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-responsive-form>:not(:last-child){margin-left:var(--ck-spacing-standard)}@media screen and (max-width:600px){.ck.ck-responsive-form{padding:0;width:calc(var(--ck-input-width)*.8)}.ck.ck-responsive-form .ck-labeled-field-view{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-responsive-form .ck-labeled-field-view .ck-input-number,.ck.ck-responsive-form .ck-labeled-field-view .ck-input-text{min-width:0;width:100%}.ck.ck-responsive-form .ck-labeled-field-view .ck-labeled-field-view__error{white-space:normal}.ck.ck-responsive-form>.ck-button:nth-last-child(2):after{border-right:1px solid var(--ck-color-base-border)}.ck.ck-responsive-form>.ck-button:last-child,.ck.ck-responsive-form>.ck-button:nth-last-child(2){border-radius:0;margin-top:var(--ck-spacing-large);padding:var(--ck-spacing-standard)}.ck.ck-responsive-form>.ck-button:last-child:not(:focus),.ck.ck-responsive-form>.ck-button:nth-last-child(2):not(:focus){border-top:1px solid var(--ck-color-base-border)}[dir=ltr] .ck.ck-responsive-form>.ck-button:last-child,[dir=ltr] .ck.ck-responsive-form>.ck-button:nth-last-child(2),[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2){margin-left:0}[dir=rtl] .ck.ck-responsive-form>.ck-button:last-child:last-of-type,[dir=rtl] .ck.ck-responsive-form>.ck-button:nth-last-child(2):last-of-type{border-right:1px solid var(--ck-color-base-border)}}'),v(":root{--ck-form-default-width:340px}.ck.ck-form{padding:0 0 var(--ck-spacing-large)}.ck.ck-form.ck-form_default-width{width:var(--ck-form-default-width)}.ck.ck-form:focus{outline:none}.ck.ck-form .ck.ck-input-number,.ck.ck-form .ck.ck-input-text{min-width:100%;width:0}.ck.ck-form .ck.ck-dropdown{min-width:100%}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button:not(:focus){border:1px solid var(--ck-color-base-border)}.ck.ck-form .ck.ck-dropdown .ck-dropdown__button .ck-button__label{width:100%}@media screen and (max-width:600px){.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit{align-items:stretch;flex-direction:column;padding:0}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit>.ck{margin:var(--ck-spacing-large) var(--ck-spacing-large) 0}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_with-submit .ck-button_with-text{justify-content:center}.ck.ck-form.ck-responsive-form .ck.ck-form__row.ck-form__row_large-bottom-padding{padding-bottom:var(--ck-spacing-large)}}[dir=ltr] .ck.ck-form.ck-responsive-form>:not(:first-child),[dir=rtl] .ck.ck-form.ck-responsive-form>:not(:last-child){margin-left:0}"),v(".ck.ck-link-form .ck-link-form__providers-list{display:flex;flex-direction:column}.ck.ck-link-form .ck-link-form__providers-list .ck-link__button>.ck-button__label{flex-grow:1}.ck.ck-link-form .ck-link__items:empty{display:none}:root{--ck-link-panel-width:340px;--ck-link-provider-list-item-text-height:calc(var(--ck-line-height-base)*var(--ck-font-size-base));--ck-link-provider-list-item-height:calc(var(--ck-link-provider-list-item-text-height) + var(--ck-spacing-small) + var(--ck-spacing-small))}@media screen and (max-width:600px){:root{--ck-link-panel-width:300px}}.ck.ck-form.ck-link-form{padding-bottom:0;width:var(--ck-link-panel-width)}@media screen and (max-width:600px){.ck.ck-form.ck-link-form.ck-responsive-form .ck-labeled-field-view{margin:0}}.ck.ck-form.ck-link-form .ck-link-form__providers-list{border-top:1px solid var(--ck-color-base-border)}.ck.ck-form.ck-link-form .ck-link-form__providers-list:has(.ck-list__item:nth-child(n+5)){max-height:calc(var(--ck-link-provider-list-item-height)*4 + var(--ck-spacing-large) + 1px);overflow:auto}.ck.ck-form.ck-link-form .ck-link-form__providers-list .ck-link__button{border-radius:0;padding:var(--ck-spacing-small) var(--ck-spacing-large)}.ck.ck-form.ck-link-form .ck-link-form__providers-list .ck-link__button>.ck-button__label{overflow:hidden;text-overflow:ellipsis}");/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Le extends M{focusTracker=new U;keystrokes=new O;backButtonView;saveButtonView;displayedTextInputView;urlInputView;children;providersListChildren;_validators;_focusables=new j;_focusCycler;constructor(e,t){super(e),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.displayedTextInputView=this._createDisplayedTextInput(),this.urlInputView=this._createUrlInput(),this.providersListChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView()]),this._createFormChildren(),this.listenTo(this.providersListChildren,"add",()=>{this.stopListening(this.providersListChildren,"add"),this.children.add(this._createProvidersListView())}),this._focusCycler=new K({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-link-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),We({view:this}),[this.urlInputView,this.saveButtonView,...this.providersListChildren,this.backButtonView,this.displayedTextInputView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createBackButton(){const e=this.locale.t,t=new p(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:z,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new p(this.locale);return t.set({label:e("Insert"),tooltip:!1,withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Y(this.locale,{label:e("Link")});return t.children.add(this.backButtonView,0),t}_createProvidersListView(){const e=new q(this.locale);return e.extendTemplate({attributes:{class:["ck-link-form__providers-list"]}}),e.items.bindTo(this.providersListChildren).using(t=>{const i=new $(this.locale);return i.children.add(t),i}),e}_createDisplayedTextInput(){const e=this.locale.t,t=new ue(this.locale,ke);return t.label=e("Displayed text"),t.class="ck-labeled-field-view_full-width",t}_createUrlInput(){const e=this.locale.t,t=new ue(this.locale,ke);return t.fieldView.inputMode="url",t.label=e("Link URL"),t.class="ck-labeled-field-view_full-width",t}_createFormChildren(){this.children.add(new he(this.locale,{children:[this.displayedTextInputView],class:["ck-form__row_large-top-padding"]})),this.children.add(new he(this.locale,{children:[this.urlInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding","ck-form__row_large-bottom-padding"]}))}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}v(".ck.ck-link-providers>.ck-link-providers__list{overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain}.ck.ck-link-providers>.ck-link-providers__list .ck-button>.ck-icon{flex-shrink:0}:root{--ck-link-providers-width:340px;--ck-link-list-view-max-height:240px;--ck-link-list-view-icon-size:calc(var(--ck-icon-size)*0.8)}@media screen and (max-width:600px){:root{--ck-link-providers-width:300px}}.ck.ck-link-providers{width:var(--ck-link-providers-width)}.ck.ck-link-providers .ck-form__header__label{overflow:hidden;text-overflow:ellipsis}.ck.ck-link-providers>.ck-link-providers__list{max-height:min(var(--ck-link-list-view-max-height),40vh)}.ck.ck-link-providers>.ck-link-providers__list .ck-button>.ck-icon{height:var(--ck-link-list-view-icon-size);width:var(--ck-link-list-view-icon-size)}.ck.ck-link-providers>.ck-link-providers__list .ck-button>.ck-button__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ck.ck-link-providers .ck-link__empty-list-info{font-style:italic;padding:calc(var(--ck-spacing-large)*2) var(--ck-spacing-medium);text-align:center}");/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ye extends M{focusTracker=new U;keystrokes=new O;backButtonView;listView;listChildren;emptyListInformation;children;_focusables=new j;_focusCycler;constructor(e){super(e),this.listChildren=this.createCollection(),this.backButtonView=this._createBackButton(),this.listView=this._createListView(),this.emptyListInformation=this._createEmptyLinksListItemView(),this.children=this.createCollection([this._createHeaderView(),this.emptyListInformation]),this.set("title",""),this.set("emptyListPlaceholder",""),this.set("hasItems",!1),this.listenTo(this.listChildren,"change",()=>{this.hasItems=this.listChildren.length>0}),this.on("change:hasItems",(t,i,n)=>{n?(this.children.remove(this.emptyListInformation),this.children.add(this.listView)):(this.children.remove(this.listView),this.children.add(this.emptyListInformation))}),this.keystrokes.set("Esc",(t,i)=>{this.fire("cancel"),i()}),this._focusCycler=new K({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-providers"],tabindex:"-1"},children:this.children})}render(){super.render(),[this.listView,this.backButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createListView(){const e=new q(this.locale);return e.extendTemplate({attributes:{class:["ck-link-providers__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new $(this.locale);return i.children.add(t),i}),e}_createBackButton(){const e=this.locale.t,t=new p(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:z,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=new Y(this.locale);return e.bind("label").to(this,"title"),e.children.add(this.backButtonView,0),e}_createEmptyLinksListItemView(){const e=new M(this.locale);return e.setTemplate({tag:"p",attributes:{class:["ck","ck-link__empty-list-info"]},children:[{text:this.bindTemplate.to("emptyListPlaceholder")}]}),e}}v(":root{--ck-link-properties-width:340px}@media screen and (max-width:600px){:root{--ck-link-properties-width:300px}}.ck.ck-link-properties{width:var(--ck-link-properties-width)}");/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ie extends M{focusTracker=new U;keystrokes=new O;backButtonView;children;listChildren;_focusables=new j;_focusCycler;constructor(e){super(e),this.backButtonView=this._createBackButton(),this.listChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView(),this._createListView()]),this._focusCycler=new K({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-properties"],tabindex:"-1"},children:this.children}),this.keystrokes.set("Esc",(t,i)=>{this.fire("back"),i()})}render(){super.render(),[...this.listChildren,this.backButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new p(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:z,tooltip:!0}),t.delegate("execute").to(this,"back"),t}_createHeaderView(){const e=this.locale.t,t=new Y(this.locale,{label:e("Link properties")});return t.children.add(this.backButtonView,0),t}_createListView(){const e=new q(this.locale);return e.extendTemplate({attributes:{class:["ck-link__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new $(this.locale);return i.children.add(t),i}),e}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class xe extends p{arrowView;constructor(e){super(e),this.set({withText:!0}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-link__button"]}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new Xe;return e.content=$e,e}}v(".ck.ck-link-toolbar__preview{display:inline-block}.ck.ck-link-toolbar__preview .ck-button__label{overflow:hidden}:root{--ck-link-bookmark-icon-size:calc(var(--ck-icon-size)*0.7)}.ck.ck-toolbar.ck-link-toolbar>.ck-toolbar__items{flex-wrap:nowrap}a.ck.ck-button.ck-link-toolbar__preview{color:var(--ck-color-link-default);cursor:pointer;justify-content:center;padding:0 var(--ck-spacing-medium)}a.ck.ck-button.ck-link-toolbar__preview .ck.ck-button__label{max-width:var(--ck-input-width);text-overflow:ellipsis}a.ck.ck-button.ck-link-toolbar__preview,a.ck.ck-button.ck-link-toolbar__preview:active,a.ck.ck-button.ck-link-toolbar__preview:focus,a.ck.ck-button.ck-link-toolbar__preview:hover{background:none}a.ck.ck-button.ck-link-toolbar__preview:active{box-shadow:none}a.ck.ck-button.ck-link-toolbar__preview:focus,a.ck.ck-button.ck-link-toolbar__preview:hover{text-decoration:underline}a.ck.ck-button.ck-link-toolbar__preview.ck-button_with-text .ck.ck-icon.ck-button__icon{height:var(--ck-link-bookmark-icon-size);width:var(--ck-link-bookmark-icon-size)}[dir=ltr] a.ck.ck-button.ck-link-toolbar__preview.ck-button_with-text .ck.ck-icon.ck-button__icon{margin-left:var(--ck-spacing-small);margin-right:var(--ck-spacing-tiny)}[dir=rtl] a.ck.ck-button.ck-link-toolbar__preview.ck-button_with-text .ck.ck-icon.ck-button__icon{margin-left:var(--ck-spacing-tiny);margin-right:var(--ck-spacing-small)}a.ck.ck-button.ck-link-toolbar__preview:has(.ck-icon){padding-left:var(--ck-spacing-extra-tiny )}");/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const w="link-ui";class ee extends V{toolbarView=null;formView=null;linkProviderItemsView=null;propertiesView=null;_balloon;_linksProviders=new le;static get requires(){return[me,y]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;this.set("selectedLinkableText",void 0),e.editing.view.addObserver(Ye),this._balloon=e.plugins.get(me),this._registerComponents(),this._registerEditingOpeners(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:w,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:w,view:(i,{writer:n})=>{if(!i.markerRange.isCollapsed)return null;const s=n.createUIElement("span");return n.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],s),s}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:L},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.propertiesView&&this.propertiesView.destroy(),this.formView&&this.formView.destroy(),this.toolbarView&&this.toolbarView.destroy(),this.linkProviderItemsView&&this.linkProviderItemsView.destroy()}registerLinksListProvider(e){const t=this._linksProviders.filter(i=>(i.order||0)<=(e.order||0)).length;this._linksProviders.add(e,t)}_createViews(){const e=this.editor.commands.get("link");this.toolbarView=this._createToolbarView(),this.formView=this._createFormView(),e.manualDecorators.length&&(this.propertiesView=this._createPropertiesView()),this._enableUserBalloonInteractions()}_createToolbarView(){const e=this.editor,t=new Je(e.locale),i=e.commands.get("link");t.class="ck-link-toolbar";let n=e.config.get("link.toolbar");return i.manualDecorators.length||(n=n.filter(s=>s!=="linkProperties")),t.fillFromConfig(n,e.ui.componentFactory),t.keystrokes.set("Esc",(s,o)=>{this._hideUI(),o()}),t.keystrokes.set(L,(s,o)=>{this._addFormView(),o()}),e.ui.addToolbar(t,{isContextual:!0,beforeFocus:()=>{this._getSelectedLinkElement()&&!this._isToolbarVisible&&this._showUI(!0)},afterBlur:()=>{this._hideUI(!1)}}),t}_createFormView(){const e=this.editor,t=e.locale.t,i=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),s=new(fe(Le))(e.locale,Vt(e));return s.displayedTextInputView.bind("isEnabled").to(this,"selectedLinkableText",o=>o!==void 0),s.urlInputView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("label").to(i,"value",o=>t(o?"Update":"Insert")),this.listenTo(s,"submit",()=>{if(s.isValid()){const o=s.urlInputView.fieldView.element.value,l=C(o,n),c=s.displayedTextInputView.fieldView.element.value;e.execute("link",l,this._getDecoratorSwitchesState(),c!==this.selectedLinkableText?c:void 0),this._closeFormView()}}),this.listenTo(s.urlInputView,"change:errorText",()=>{e.ui.update()}),this.listenTo(s,"cancel",()=>{this._closeFormView()}),s.keystrokes.set("Esc",(o,l)=>{this._closeFormView(),l()}),s.providersListChildren.bindTo(this._linksProviders).using(o=>this._createLinksListProviderButton(o)),s}_createLinkProviderListView(e){return e.getListItems().map(({href:t,label:i,icon:n})=>{const s=new p;return s.set({label:i,icon:n,tooltip:!1,withText:!0}),s.on("execute",()=>{this.formView.resetFormStatus(),this.formView.urlInputView.fieldView.value=t,this.editor.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),s})}_createLinkProviderItemsView(e){const t=this.editor,i=t.locale.t,n=new ye(t.locale),{emptyListPlaceholder:s,label:o}=e;return n.emptyListPlaceholder=s||i("No links available"),n.title=o,this.listenTo(n,"cancel",()=>{t.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),n}_createPropertiesView(){const e=this.editor,t=this.editor.commands.get("link"),i=new(fe(Ie))(e.locale);return this.listenTo(i,"back",()=>{e.editing.view.focus(),this._removePropertiesView()}),i.listChildren.bindTo(t.manualDecorators).using(n=>{const s=new et(e.locale);return s.set({label:n.label,withText:!0}),s.bind("isOn").toMany([n,t],"value",(o,l)=>l===void 0&&o===void 0?!!n.defaultValue:!!o),s.on("execute",()=>{e.execute("link",t.value,{...this._getDecoratorSwitchesState(),[n.id]:!s.isOn})}),s}),i}_getDecoratorSwitchesState(){const e=this.editor.commands.get("link");return Array.from(e.manualDecorators).reduce((t,i)=>{const n=e.value===void 0&&i.value===void 0?i.defaultValue:i.value;return{...t,[i.id]:!!n}},{})}_registerEditingOpeners(){this.editor.plugins.get(y)._registerLinkOpener(t=>{const i=this._getLinkProviderLinkByHref(t);if(!i)return!1;const{item:n,provider:s}=i;return s.navigate?s.navigate(n):!1})}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("link",()=>{const t=this._createButton(p);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:link",()=>{const t=this._createButton(tt);return t.set({role:"menuitemcheckbox"}),t}),e.ui.componentFactory.add("linkPreview",t=>{const i=new Ve(t),n=e.config.get("link.allowedProtocols"),s=e.commands.get("link"),o=t.t;i.bind("isEnabled").to(s,"value",c=>!!c),i.bind("href").to(s,"value",c=>c&&T(c,n));const l=c=>{if(!c){i.label=void 0,i.icon=void 0,i.tooltip=o("Open link in new tab");return}const a=this._getLinkProviderLinkByHref(c);if(a){const{label:d,tooltip:h,icon:k}=a.item;i.label=d,i.tooltip=h||!1,i.icon=k}else i.label=c,i.icon=void 0,i.tooltip=o("Open link in new tab")};return l(s.value),this.listenTo(s,"change:value",(c,a,d)=>{l(d)}),this.listenTo(i,"navigate",(c,a,d)=>{const h=this._getLinkProviderLinkByHref(a);if(!h)return;const{provider:k,item:u}=h,{navigate:f}=k;f&&f(u)&&(c.stop(),d())}),i}),e.ui.componentFactory.add("unlink",t=>{const i=e.commands.get("unlink"),n=new p(t),s=t.t;return n.set({label:s("Unlink"),icon:Ge,tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{e.execute("unlink"),this._hideUI()}),n}),e.ui.componentFactory.add("editLink",t=>{const i=e.commands.get("link"),n=new p(t),s=t.t;return n.set({label:s("Edit link"),icon:Qe,tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{this._addFormView()}),n}),e.ui.componentFactory.add("linkProperties",t=>{const i=e.commands.get("link"),n=new p(t),s=t.t;return n.set({label:s("Link properties"),icon:Ze,tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled",i,"value",i,"manualDecorators",(o,l,c)=>o&&!!l&&c.length>0),this.listenTo(n,"execute",()=>{this._addPropertiesView()}),n})}_createLinksListProviderButton(e){const t=this.editor.locale,i=new xe(t);return i.set({label:e.label}),this.listenTo(i,"execute",()=>{this._showLinksProviderView(e)}),i}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),s=new e(t.locale),o=i.t;return s.set({label:o("Link"),icon:de,keystroke:L,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",l=>!!l),this.listenTo(s,"execute",()=>{t.editing.view.scrollToTheSelection(),this._showUI(!0),this._getSelectedLinkElement()&&this._addFormView()}),s}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),e.keystrokes.set(L,(i,n)=>{n(),e.commands.get("link").isEnabled&&(e.editing.view.scrollToTheSelection(),this._showUI(!0))})}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",(e,t)=>{this._isToolbarVisible&&!this.toolbarView.focusTracker.isFocused&&(this.toolbarView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),it({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideUI(!1)}})}_addToolbarView(){this.toolbarView||this._createViews(),!this._isToolbarInPanel&&this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this.formView.backButtonView.isVisible=e.isEnabled&&!!e.value,this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.selectedLinkableText=this._getSelectedLinkableText(),this.formView.displayedTextInputView.fieldView.value=this.selectedLinkableText||"",this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_addPropertiesView(){this.propertiesView||this._createViews(),!this._arePropertiesInPanel&&(this.propertiesView.disableCssTransitions(),this._balloon.add({view:this.propertiesView,position:this._getBalloonPositionData()}),this.propertiesView.enableCssTransitions(),this.propertiesView.focus())}_showLinksProviderView(e){this.linkProviderItemsView&&this._removeLinksProviderView(),this.linkProviderItemsView=this._createLinkProviderItemsView(e),this._addLinkProviderItemsView(e)}_addLinkProviderItemsView(e){this.linkProviderItemsView.listChildren.clear(),this.linkProviderItemsView.listChildren.addMany(this._createLinkProviderListView(e)),this._balloon.add({view:this.linkProviderItemsView,position:this._getBalloonPositionData()}),this.linkProviderItemsView.focus()}_closeFormView(){const e=this.editor.commands.get("link");this.selectedLinkableText=void 0,e.value!==void 0?this._removeFormView():this._hideUI()}_removePropertiesView(){this._arePropertiesInPanel&&this._balloon.remove(this.propertiesView)}_removeLinksProviderView(){this._isLinksListInPanel&&this._balloon.remove(this.linkProviderItemsView)}_removeFormView(e=!0){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.displayedTextInputView.fieldView.reset(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._isToolbarVisible?this._addFormView():this._addToolbarView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addToolbarView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(e=!0){const t=this.editor;this._isUIInPanel&&(this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeLinksProviderView(),this._removePropertiesView(),this._removeFormView(e),this._isToolbarInPanel&&this._balloon.remove(this.toolbarView),this._hideFakeVisualSelection())}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=o();const s=()=>{const l=this._getSelectedLinkElement(),c=o();i&&!l||!i&&c!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=l,n=c};function o(){return t.selection.focus.getAncestors().reverse().find(l=>l.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _arePropertiesInPanel(){return!!this.propertiesView&&this._balloon.hasView(this.propertiesView)}get _isLinksListInPanel(){return!!this.linkProviderItemsView&&this._balloon.hasView(this.linkProviderItemsView)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isToolbarInPanel(){return!!this.toolbarView&&this._balloon.hasView(this.toolbarView)}get _isPropertiesVisible(){return!!this.propertiesView&&this._balloon.visibleView===this.propertiesView}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}get _isToolbarVisible(){return!!this.toolbarView&&this._balloon.visibleView===this.toolbarView}get _isUIInPanel(){return this._arePropertiesInPanel||this._isLinksListInPanel||this._isFormInPanel||this._isToolbarInPanel}get _isUIVisible(){return this._isPropertiesVisible||this._isLinksListInPanel||this._isFormVisible||this._isToolbarVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;if(this.editor.model.markers.has(w)){const n=this.editor.editing.mapper.markerNameToElements(w);if(n){const s=Array.from(n),o=e.createRange(e.createPositionBefore(s[0]),e.createPositionAfter(s[s.length-1]));return{target:e.domConverter.viewRangeToDom(o)}}}return{target:()=>{const n=this._getSelectedLinkElement();return n?e.domConverter.mapViewToDom(n):e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&nt(i))return te(t.getFirstPosition());{const n=t.getFirstRange().getTrimmed(),s=te(n.start),o=te(n.end);return!s||s!=o?null:e.createRangeIn(s).getTrimmed().isEqual(n)?s:null}}_getSelectedLinkableText(){const e=this.editor.model,t=this.editor.editing,i=this._getSelectedLinkElement();if(!i)return P(e.document.selection.getFirstRange());const n=t.view.createRangeOn(i),s=t.mapper.toModelRange(n);return P(s)}_getLinkProviderLinkByHref(e){if(!e)return null;for(const t of this._linksProviders){const i=t.getItem?t.getItem(e):t.getListItems().find(n=>n.href===e);if(i)return{provider:t,item:i}}return null}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(w))t.updateMarker(w,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(w,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(w,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(w)&&e.change(t=>{t.removeMarker(w)})}}function te(r){return r.getAncestors().find(e=>G(e))||null}function Vt(r){const e=r.t,t=r.config.get("link.allowCreatingEmptyLinks");return[i=>{if(!t&&!i.url.length)return e("Link URL must not be empty.")}]}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Lt=4,Te=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63}))|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i"),yt=2;class Ee extends V{static get requires(){return[He,y]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}init(){const t=this.editor.model.document.selection;t.on("change:range",()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?R(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const n=this.editor.model,s=n.document.selection,o=s.getFirstPosition(),l=s.getLastPosition();let c=t.getJoined(this._expandLinkRange(n,o)||t);c&&(c=c.getJoined(this._expandLinkRange(n,l)||t)),c&&(c.start.isBefore(o)||c.end.isAfter(l))&&e.setSelection(c)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");n.on("inputTransformation",(o,l)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||l.method!=="paste"||i.rangeCount>1)return;const c=i.getFirstRange(),a=l.dataTransfer.getData("text/plain");if(!a)return;const d=a.match(Te);d&&d[2]===a&&(t.change(h=>{this._selectEntireLinks(h,c),s.execute(a)}),o.stop())},{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new Fe(e.model,i=>{let n=i;if(!It(n))return;n=n.slice(0,-1),"!.:,;?".includes(n[n.length-1])&&(n=n.slice(0,-1));const s=Ce(n);if(s)return{url:s,removedTrailingCharacters:i.length-n.length}});t.on("matched:data",(i,n)=>{const{batch:s,range:o,url:l,removedTrailingCharacters:c}=n;if(!s.isTyping)return;const a=o.end.getShiftedBy(-c),d=a.getShiftedBy(-l.length),h=e.model.createRange(d,a);this._applyAutoLink(l,h)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",()=>{const n=t.document.selection.getFirstPosition();let s;n.parent.previousSibling?.is("element")?s=t.createRangeIn(n.parent.previousSibling):s=t.createRange(t.createPositionAt(n.parent,0),n),this._checkAndApplyAutoLinkOnRange(s)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",()=>{const n=t.document.selection.getFirstPosition(),s=t.createRange(t.createPositionAt(n.parent,0),n.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(s)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=Re(e,t),s=Ce(i);if(s){const o=t.createRange(n.end.getShiftedBy(-s.length),n.end);this._applyAutoLink(s,o)}}_applyAutoLink(e,t){const i=this.editor.model,n=this.editor.config.get("link.defaultProtocol"),s=C(e,n);!this.isEnabled||!xt(t,i)||!B(s)||Tt(t)||this._persistAutoLink(s,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange(s=>{s.setAttribute("linkHref",e,t),i.enqueueChange(()=>{n.requestUndoOnBackspace()})})}}function It(r){return r.length>Lt&&r[r.length-1]===" "&&r[r.length-2]!==" "}function Ce(r){const e=Te.exec(r);return e?e[yt]:null}function xt(r,e){return e.schema.checkAttributeInSelection(e.createSelection(r),"linkHref")}function Tt(r){const e=r.start.nodeAfter;return!!e&&e.hasAttribute("linkHref")}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Et extends V{static get requires(){return[y,ee,Ee]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Pe extends V{static get requires(){return["ImageEditing","ImageUtils",y]}static get pluginName(){return"LinkImageEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(Ct(e)),e.conversion.for("downcast").add(Pt(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,i=e.commands.get("link").automaticDecorators;i.length&&e.conversion.for("downcast").add(i.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(At(i)),e.conversion.for("upcast").add(St(e,i))}}function Ct(r){const e=r.plugins.has("ImageInlineEditing"),t=r.plugins.get("ImageUtils");return i=>{i.on("element:a",(n,s,o)=>{const l=s.viewItem,c=t.findViewImgElement(l);if(!c)return;const a=c.findAncestor(u=>t.isBlockImageView(u));if(e&&!a)return;const d={attributes:["href"]};if(!o.consumable.test(l,d))return;const h=l.getAttribute("href"),k=s.modelCursor.parent;k.is("element","imageBlock")&&(o.writer.setAttribute("linkHref",h,k),o.consumable.consume(l,d))},{priority:"high"})}}function Pt(r){const e=r.plugins.get("ImageUtils");return t=>{t.on("attribute:linkHref:imageBlock",(i,n,s)=>{if(!s.consumable.consume(n.item,i.name))return;const o=s.mapper.toViewElement(n.item),l=s.writer,c=Array.from(o.getChildren()).find(h=>h.is("element","a")),a=e.findViewImgElement(o),d=a.parent.is("element","picture")?a.parent:a;if(c)n.attributeNewValue?l.setAttribute("href",n.attributeNewValue,c):(l.move(l.createRangeOn(d),l.createPositionAt(o,0)),l.remove(c));else{const h=l.createContainerElement("a",{href:n.attributeNewValue});l.insert(l.createPositionAt(o,0),h),l.move(l.createRangeOn(d),l.createPositionAt(h,0))}},{priority:"high"})}}function At(r){return e=>{const t=i=>(n,s,o)=>{const l=o.mapper.toViewElement(s.item),c=Array.from(l.getChildren()).find(a=>a.is("element","a"));if(c){if(!i&&s.attributeOldValue){for(const[a,d]of D(r.attributes))o.writer.removeAttribute(a,d,c);r.classes&&o.writer.removeClass(r.classes,c);for(const a in r.styles)o.writer.removeStyle(a,c)}if(i&&s.attributeNewValue){for(const[a,d]of D(r.attributes))o.writer.setAttribute(a,d,!1,c);r.classes&&o.writer.addClass(r.classes,c);for(const a in r.styles)o.writer.setStyle(a,r.styles[a],c)}}};e.on(`attribute:${r.id}:imageBlock`,t(!1),{priority:_.high-1}),e.on(`attribute:${r.id}:imageBlock`,t(!0),{priority:_.high-2})}}function St(r,e){const t=r.plugins.has("ImageInlineEditing"),i=r.plugins.get("ImageUtils");return n=>{n.on("element:a",(s,o,l)=>{const c=o.viewItem,a=i.findViewImgElement(c);if(!a)return;const d=a.findAncestor(f=>i.isBlockImageView(f));if(t&&!d)return;const k=new qe(e._createPattern()).match(c);if(!k||!l.consumable.test(c,k.match))return;const u=o.modelCursor.parent;u?.is("element","imageBlock")&&(l.writer.setAttribute(e.id,!0,u),l.consumable.consume(c,k.match))},{priority:"high"})}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ae extends V{static get requires(){return[y,ee,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(i,n)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(n.preventDefault(),i.stop())},{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",i=>{const n=new p(i),s=e.plugins.get("LinkUI"),o=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:de,keystroke:L,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(o,"isEnabled"),n.bind("isOn").to(o,"value",l=>!!l),this.listenTo(n,"execute",()=>{this._isSelectedLinkedImage(e.model.document.selection)?s._addToolbarView():s._showUI(!0)}),n})}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}v('.ck.ck-editor__editable a span.image-inline:after,.ck.ck-editor__editable figure.image>a:after{display:block;position:absolute}:root{--ck-link-image-indicator-icon-size:20;--ck-link-image-indicator-icon-is-visible:clamp(0px,100% - 50px,1px)}.ck.ck-editor__editable a span.image-inline:after,.ck.ck-editor__editable figure.image>a:after{background-color:rgba(0,0,0,.4);background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTExLjA3NyAxNSAuOTkxLTEuNDE2YS43NS43NSAwIDEgMSAxLjIyOS44NmwtMS4xNDggMS42NGEuNzUuNzUgMCAwIDEtLjIxNy4yMDYgNS4yNTEgNS4yNTEgMCAwIDEtOC41MDMtNS45NTUuNy43IDAgMCAxIC4xMi0uMjc0bDEuMTQ3LTEuNjM5YS43NS43NSAwIDEgMSAxLjIyOC44Nkw0LjkzMyAxMC43bC4wMDYuMDAzYTMuNzUgMy43NSAwIDAgMCA2LjEzMiA0LjI5NHptNS40OTQtNS4zMzVhLjc1Ljc1IDAgMCAxLS4xMi4yNzRsLTEuMTQ3IDEuNjM5YS43NS43NSAwIDEgMS0xLjIyOC0uODZsLjg2LTEuMjNhMy43NSAzLjc1IDAgMCAwLTYuMTQ0LTQuMzAxbC0uODYgMS4yMjlhLjc1Ljc1IDAgMCAxLTEuMjI5LS44NmwxLjE0OC0xLjY0YS43NS43NSAwIDAgMSAuMjE3LS4yMDYgNS4yNTEgNS4yNTEgMCAwIDEgOC41MDMgNS45NTVtLTQuNTYzLTIuNTMyYS43NS43NSAwIDAgMSAuMTg0IDEuMDQ1bC0zLjE1NSA0LjUwNWEuNzUuNzUgMCAxIDEtMS4yMjktLjg2bDMuMTU1LTQuNTA2YS43NS43NSAwIDAgMSAxLjA0NS0uMTg0Ii8+PC9zdmc+");background-position:50%;background-repeat:no-repeat;background-size:14px;border-radius:100%;content:"";height:calc(var(--ck-link-image-indicator-icon-is-visible)*var(--ck-link-image-indicator-icon-size));overflow:hidden;right:min(var(--ck-spacing-medium),6%);top:min(var(--ck-spacing-medium),6%);width:calc(var(--ck-link-image-indicator-icon-is-visible)*var(--ck-link-image-indicator-icon-size))}');/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Dt extends V{static get requires(){return[Pe,Ae]}static get pluginName(){return"LinkImage"}static get isOfficialPlugin(){return!0}}export{Ee as AutoLink,ge as AutomaticLinkDecorators,Et as Link,pe as LinkCommand,y as LinkEditing,Le as LinkFormView,Dt as LinkImage,Pe as LinkImageEditing,Ae as LinkImageUI,_e as LinkManualDecorator,Ie as LinkPropertiesView,ye as LinkProviderItemsView,ee as LinkUI,kt as LinkUtils,we as UnlinkCommand,L as _LINK_KEYSTROKE,xe as _LinkButtonView,Ve as _LinkPreviewButtonView,N as _createLinkElement,T as _ensureSafeLinkUrl,P as _extractTextFromLinkRange,Q as _getLocalizedLinkDecorators,B as _hasLinkProtocol,W as _isEmailLink,Z as _normalizeLinkDecorators,X as _openLink,C as addLinkProtocolIfApplicable,T as ensureSafeUrl,G as isLinkElement,E as isLinkableElement};
