/*!
 * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
 */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CKEditor5=t():(e.CKEditor5=e.CKEditor5||{},e.CKEditor5.realtimeCommentNotifications=t())}(self,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>o});const o={RealtimeCommentNotifications:class{constructor(e){this.editor=e}static get pluginName(){return"RealtimeCommentNotifications"}init(){this.editor.plugins.has("CommentsRepository")&&(this.commentsRepositoryPlugin=this.editor.plugins.get("CommentsRepository"),this.channelId=this.editor.config._config.collaboration.channelId,this.isEntityNew()||this.commentsRepositoryPlugin.on("addComment",((e,t)=>{setTimeout((()=>{this.sendNotification(e,t)}),"1000")})))}sendNotification(e,t){if(void 0!==t.isFromAdapter)return;const o=this.commentsRepositoryPlugin.getCommentThread(t.threadId),i=o.comments._items.length-1,n={comment:o.comments._items[i],editor_content:this.editor.getData(),element_key:e.source.context.sourceElement.dataset.ckeditor5PremiumElementId,channel_id:this.channelId,thread_id:t.threadId,thread:o},s=new XMLHttpRequest,r="/ckeditor5-premium-features-realtime-collaboration/realtime-comment-notification/"+this.channelId;s.open("POST",r),s.setRequestHeader("Content-Type","application/json;charset=UTF-8"),s.send(JSON.stringify(n))}isEntityNew(){const e="/ckeditor5-premium-features-realtime-collaboration/check-channel/"+this.channelId,t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(),"false"===t.responseText}}};return t=t.default})()));
