/** Notice * This file contains works from many authors under various (but compatible) licenses. Please see core.txt for more information. **/
(function(){(window.wpCoreControlsBundle=window.wpCoreControlsBundle||[]).push([[22],{341:function(Ca,va,ba){ba.r(va);var pa=ba(2),ka=ba(13),la=ba(1);Ca=ba(44);var fa=ba(31),ca=ba(9);ba=function(){function z(){this.init()}z.prototype.init=function(){this.IV=!1;this.re=this.Hi=this.connection=null;this.bo={};this.Da=this.bz=null};z.prototype.k8=function(r){for(var n=this,b=0;b<r.length;++b){var a=r[b];switch(a.at){case "create":this.bo[a.author]||(this.bo[a.author]=a.aName);this.q0(a);break;case "modify":this.Da.Wo(a.xfdf).then(function(e){n.Da.PN(e[0])});
break;case "delete":this.Da.Wo("<delete><id>"+a.aId+"</id></delete>")}}};z.prototype.q0=function(r){var n=this;this.Da.Wo(r.xfdf).then(function(b){b=b[0];b.authorId=r.author;n.Da.PN(b);n.Da.trigger(ka.a.UPDATE_ANNOTATION_PERMISSION,[b])})};z.prototype.T_=function(r,n,b){this.Hi&&this.Hi(r,n,b)};z.prototype.preloadAnnotations=function(r){this.addEventListener("webViewerServerAnnotationsEnabled",this.T_.bind(this,r,"add",{imported:!1}),{once:!0})};z.prototype.initiateCollaboration=function(r,n,b){var a=
this;if(r){a.re=n;a.Da=b.Ga();b.addEventListener(ka.c.DOCUMENT_UNLOADED,function(){a.disableCollaboration()});a.F8(r);var e=new XMLHttpRequest;e.addEventListener("load",function(){if(200===e.status&&0<e.responseText.length)try{var f=JSON.parse(e.responseText);a.connection=exports.ab.m9(Object(fa.h)(a.re,"blackbox/"),"annot");a.bz=f.id;a.bo[f.id]=f.user_name;a.Da.NO(f.id);a.connection.gF(function(x){x.t&&x.t.startsWith("a_")&&x.data&&a.k8(x.data)},function(){a.connection.send({t:"a_retrieve",dId:r});
a.trigger(z.Events.WEBVIEWER_SERVER_ANNOTATIONS_ENABLED,[a.bo[f.id],a.bz])},function(){a.disableCollaboration()})}catch(x){Object(la.f)(x.message)}});e.open("GET",Object(fa.h)(this.re,"demo/SessionInfo.jsp"));e.withCredentials=!0;e.send();a.IV=!0;a.Da.T5(function(f){return a.bo[f.Author]||f.Author})}else Object(la.f)("Document ID required for collaboration")};z.prototype.disableCollaboration=function(){this.Hi&&(this.Da.removeEventListener(ca.a.Events.ANNOTATION_CHANGED,this.Hi),this.Hi=null);this.connection&&
this.connection.CB();this.Da&&this.Da.NO("Guest");this.init();this.trigger(z.Events.WEBVIEWER_SERVER_ANNOTATIONS_DISABLED)};z.prototype.F8=function(r){var n=this;this.Hi&&this.Da.removeEventListener(ca.a.Events.ANNOTATION_CHANGED,this.Hi);this.Hi=function(b,a,e){return Object(pa.b)(this,void 0,void 0,function(){var f,x,w,h,y,aa,ja,ha,ia;return Object(pa.d)(this,function(ea){switch(ea.label){case 0:if(e.imported)return[2];f={t:"a_"+a,dId:r,annots:[]};return[4,n.Da.qY()];case 1:x=ea.ia();"delete"!==
a&&(w=(new DOMParser).parseFromString(x,"text/xml"),h=new XMLSerializer);for(y=0;y<b.length;y++)aa=b[y],ha=ja=void 0,"add"===a?(ja=w.querySelector('[name="'+aa.Id+'"]'),ha=h.serializeToString(ja),ia=null,aa.InReplyTo&&(ia=n.Da.aK(aa.InReplyTo).authorId||"default"),f.annots.push({at:"create",aId:aa.Id,author:n.bz,aName:n.bo[n.bz],parent:ia,xfdf:"<add>"+ha+"</add>"})):"modify"===a?(ja=w.querySelector('[name="'+aa.Id+'"]'),ha=h.serializeToString(ja),f.annots.push({at:"modify",aId:aa.Id,xfdf:"<modify>"+
ha+"</modify>"})):"delete"===a&&f.annots.push({at:"delete",aId:aa.Id});0<f.annots.length&&n.connection.send(f);return[2]}})})}.bind(n);this.Da.addEventListener(ca.a.Events.ANNOTATION_CHANGED,this.Hi)};z.Events={WEBVIEWER_SERVER_ANNOTATIONS_ENABLED:"webViewerServerAnnotationsEnabled",WEBVIEWER_SERVER_ANNOTATIONS_DISABLED:"webViewerServerAnnotationsDisabled"};return z}();Object(Ca.a)(ba);va["default"]=ba}}]);}).call(this || window)
