/** 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([[21],{474:function(Ba,wa,r){r.r(wa);var oa=r(0),na=r(8),ma=r(2);Ba=r(48);var fa=r(23),ea=r(11);r=function(){function aa(){this.init()}aa.prototype.init=function(){this.o9=!1;this.af=this.Jl=this.connection=null;this.zs={};this.fa=this.lG=null};aa.prototype.gqa=function(w){for(var x=this,h=0;h<w.length;++h){var e=w[h];switch(e.at){case "create":this.zs[e.author]||(this.zs[e.author]=e.aName);this.xga(e);break;case "modify":this.fa.sm(e.xfdf).then(function(a){x.fa.jb(a[0])});
break;case "delete":this.fa.sm("<delete><id>"+e.aId+"</id></delete>")}}};aa.prototype.xga=function(w){var x=this;this.fa.sm(w.xfdf).then(function(h){h=h[0];h.authorId=w.author;x.fa.jb(h);x.fa.trigger(na.c.UPDATE_ANNOTATION_PERMISSION,[h])})};aa.prototype.Zfa=function(w,x,h){this.Jl&&this.Jl(w,x,h)};aa.prototype.preloadAnnotations=function(w){this.addEventListener("webViewerServerAnnotationsEnabled",this.Zfa.bind(this,w,"add",{imported:!1}),{once:!0})};aa.prototype.initiateCollaboration=function(w,
x,h){var e=this;if(w){e.af=x;e.fa=h.la();h.addEventListener(na.f.DOCUMENT_UNLOADED,function(){e.disableCollaboration()});e.Hqa(w);var a=new XMLHttpRequest;a.addEventListener("load",function(){if(200===a.status&&0<a.responseText.length)try{var b=JSON.parse(a.responseText);e.connection=exports.Ta.pra(Object(fa.k)(e.af,"blackbox/"),"annot");e.lG=b.id;e.zs[b.id]=b.user_name;e.fa.FN(b.id);e.connection.nua(function(f){f.t&&f.t.startsWith("a_")&&f.data&&e.gqa(f.data)},function(){e.connection.send({t:"a_retrieve",
dId:w});e.trigger(aa.Events.WEBVIEWER_SERVER_ANNOTATIONS_ENABLED,[e.zs[b.id],e.lG])},function(){e.disableCollaboration()})}catch(f){Object(ma.g)(f.message)}});a.open("GET",Object(fa.k)(this.af,"demo/SessionInfo.jsp"));a.withCredentials=!0;a.send();e.o9=!0;e.fa.O_(function(b){return e.zs[b.Author]||b.Author})}else Object(ma.g)("Document ID required for collaboration")};aa.prototype.disableCollaboration=function(){this.Jl&&(this.fa.removeEventListener(ea.a.Events.ANNOTATION_CHANGED,this.Jl),this.Jl=
null);this.connection&&this.connection.kq();this.fa&&this.fa.FN("Guest");this.init();this.trigger(aa.Events.WEBVIEWER_SERVER_ANNOTATIONS_DISABLED)};aa.prototype.Hqa=function(w){var x=this;this.Jl&&this.fa.removeEventListener(ea.a.Events.ANNOTATION_CHANGED,this.Jl);this.Jl=function(h,e,a){return Object(oa.b)(this,void 0,void 0,function(){var b,f,n,z,y,da,ia,ca,ba;return Object(oa.d)(this,function(ja){switch(ja.label){case 0:if(a.imported)return[2];b={t:"a_"+e,dId:w,annots:[]};return[4,x.fa.FJ()];case 1:f=
ja.ca();"delete"!==e&&(n=(new DOMParser).parseFromString(f,"text/xml"),z=new XMLSerializer);for(y=0;y<h.length;y++)da=h[y],ca=ia=void 0,"add"===e?(ia=n.querySelector('[name="'+da.Id+'"]'),ca=z.serializeToString(ia),ba=null,da.InReplyTo&&(ba=x.fa.tf(da.InReplyTo).authorId||"default"),b.annots.push({at:"create",aId:da.Id,author:x.lG,aName:x.zs[x.lG],parent:ba,xfdf:"<add>"+ca+"</add>"})):"modify"===e?(ia=n.querySelector('[name="'+da.Id+'"]'),ca=z.serializeToString(ia),b.annots.push({at:"modify",aId:da.Id,
xfdf:"<modify>"+ca+"</modify>"})):"delete"===e&&b.annots.push({at:"delete",aId:da.Id});0<b.annots.length&&x.connection.send(b);return[2]}})})}.bind(x);this.fa.addEventListener(ea.a.Events.ANNOTATION_CHANGED,this.Jl)};aa.Events={WEBVIEWER_SERVER_ANNOTATIONS_ENABLED:"webViewerServerAnnotationsEnabled",WEBVIEWER_SERVER_ANNOTATIONS_DISABLED:"webViewerServerAnnotationsDisabled"};return aa}();Object(Ba.a)(r);wa["default"]=r}}]);}).call(this || window)
