/*!
 * PSPDFKit for Web 2021.4.1 (https://pspdfkit.com/web)
 * 
 * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved.
 * 
 * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
 * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
 * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
 * This notice may not be removed from this file.
 * 
 * PSPDFKit uses several open source third-party components: https://pspdfkit.com/acknowledgements/web/
 */
(window.webpackJsonpPSPDFKit=window.webpackJsonpPSPDFKit||[]).push([[60],{722:function(e,t,s){"use strict";s.r(t),s.d(t,"InstantProvider",(function(){return D}));var i=s(70),n=s.n(i),a=s(1),o=s.n(a),c=s(4),r=s(3),l=s(42),d=s(133),h=s(250);class u extends(c.e({clientId:"",userId:null,presenceContent:{}})){}class m extends(c.e({status:"offline",currentClient:null,clients:Object(c.b)()})){}var b=s(155),p=s(156);class _{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=null,this.tries=0}reset(){this.tries=0,this.timer&&clearTimeout(this.timer)}scheduleTimeout(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout((()=>{this.tries=this.tries+1,this.callback()}),this.timerCalc(this.tries+1))}}var f=s(7);const g="0.0.1",C=0,k=1,j=2,O={name:"PSPDFKit-Web"},F=e=>[1e3,2e3][e-1]||5e3;function y(e){return Object(r.k)("string"==typeof e.client_id,"The client payload must have a `client_id`"),Object(r.k)("object"==typeof e.presence,"The client payload must have a `presence`"),new u({clientId:e.client_id,userId:e.user_id,presenceContent:e.presence})}var w=s(368);class I extends(c.e({content:null,attachments:null,id:null,type:null,group:void 0,resolve:()=>{},reject:()=>{}})){}var v=s(338);class R extends(c.e({requestInfo:null,status:"offline",currentClient:null,localRecordsContents:Object(c.c)(),localRecordsChanges:Object(c.a)(),stagedRecordsChanges:Object(c.a)(),localRecordsRev:0,requiredAttachmentIds:Object(c.g)(),clients:Object(c.b)()})){}var x=s(289);var S=s(641),P=s(188);function q(e,t){const s=e.get("annotations"),i=e.get("formFields"),n=e.get("comments"),a=e.get("formattedFormFieldValues");let o;return t.id.startsWith("form-field-value/")&&(o=t.id.split("/")[1]),s.get(t.id)||i.find((e=>e.id===t.id))||n.get(t.id)||(o?a.get(o):void 0)}function A(e,t){return Boolean(q(e,t))}var E=s(52),T=s(171),U=s(85),V=s(135),B=s(2),z=s(33),$=s(27);class D{constructor(e,t,s,i=S.a){o()(this,"_existingBookmarksIds",Object(c.g)()),o()(this,"_existingFormFieldsIds",Object(c.g)()),o()(this,"_existingFormFieldValuesIds",Object(c.g)()),o()(this,"_existingCommentIds",Object(c.g)()),o()(this,"_documentHandleConflictCallback",(()=>{})),o()(this,"canCreateBackendOrphanWidgets",!0),o()(this,"setDocumentHandleConflictCallback",(e=>{this._documentHandleConflictCallback=e})),o()(this,"setDocumentHandleOutdated",(e=>{this._setDocumentHandleOutdatedCallback=e})),o()(this,"onDocumentHandleConflict",(()=>{this._documentHandleConflictCallback&&this._documentHandleConflictCallback(),this._setDocumentHandleOutdatedCallback&&this._setDocumentHandleOutdatedCallback(!0)})),this._serverURL=e,this._documentURL=t,this._authPayload=s,this._settings=i,this._hasLoadedInitialRecords=!1}load(e=class{getRecords(){return this._shouldFireRecordsUpdateCallback=!0,this._state.localRecordsContents.map(((e,t)=>{const{content:s,permissions:i,group:n}=e;return{content:s,permissions:i,group:n,id:t}})).toList()}createRecord(e,t,s,i){return new Promise(((n,a)=>{const o=new I({id:e,content:t,attachments:s,group:i,type:"created",resolve:n,reject:a});this.enqueueChangeRequest(o)}))}updateRecord(e,t,s){return new Promise(((i,n)=>{if(!this.isKnownRecordId(e))return n(new r.a(`Record with ID: ${e} not found.`));const a=new I({id:e,content:t,group:s,type:"updated",resolve:i,reject:n});this.enqueueChangeRequest(a)}))}deleteRecord(e){return new Promise(((t,s)=>{if(!this.isKnownRecordId(e))return s(new r.a(`Record with ID: ${e} not found.`));const i=new I({id:e,type:"deleted",resolve:t,reject:s});this.enqueueChangeRequest(i)}))}onRecordsUpdates(e,t){if("function"!=typeof e)throw new TypeError("recordsUpdateCallback must be a function");if("function"!=typeof t)throw new TypeError("acceptedRecordsCallback must be a function");this._recordsUpdatesCallback=e,this._acceptedRecordsResponseCallback=t}destroy(){this._cycle&&this._cycle.destroy()}constructor(e=new R,t=v.b){o()(this,"_recordsUpdatesCallback",(()=>{})),o()(this,"_acceptedRecordsResponseCallback",(()=>{})),o()(this,"_shouldFireRecordsUpdateCallback",!1),o()(this,"onChanges",(e=>{if(this._shouldFireRecordsUpdateCallback){const{created:t,updated:s,deleted:i}=e;this._recordsUpdatesCallback(Object(c.a)(t),Object(c.a)(s),Object(c.a)(i))}})),o()(this,"onAcceptedRecords",(e=>{if(this._shouldFireRecordsUpdateCallback){const{created:t,updated:s,deleted:i}=e;this._acceptedRecordsResponseCallback(Object(c.a)(t),Object(c.a)(s),Object(c.a)(i))}})),o()(this,"setOnDocumentHandleConflictCallback",(e=>{if("function"!=typeof e)throw new TypeError("callback must be a function");this._cycle.setOnDocumentHandleConflictCallback(e)})),o()(this,"syncChanges",Object(x.a)((()=>this._cycle.nextCycle()))),this._state=e,this._CycleClass=t}load(e,t,s=!0){return new Promise(((i,n)=>{const a=this.setState.bind(this);this.setState(this._state.set("requestInfo",{serverURL:e,authPayload:t})),this._cycle=new this._CycleClass({getState:()=>this._state,setState:a,onChanges:this.onChanges,onAcceptedRecords:this.onAcceptedRecords,longPollingTimeout:s?v.a:0}),this._cycle.nextCycle(0).then((()=>{i(this)})).catch(n)}))}setState(e){this._state=e}enqueueChangeRequest(e){const t=Object(w.a)({oldChanges:this._state.localRecordsChanges,newChanges:Object(c.a)([e])});this.setState(this._state.set("localRecordsChanges",t))}isKnownRecordId(e){function t(t){return"created"===t.type&&t.id===e}const s=this._state.localRecordsContents.has(e),i=!!this._state.localRecordsChanges.find(t),n=!!this._state.stagedRecordsChanges.find(t);return s||i||n}},t=class{constructor(e=new m,t=class{constructor(e,t,{reconnectTimerCalc:s=F,enableReconnect:i=!0,events:n=[]}={}){this.eventEmitter=new p.a(["connect","disconnect","error"].concat(n)),this.serverURL=e,this.authPayload=t,this.socket=null,this.lastRequestId=0,this.requestsWaitingForAnswers=Object(c.b)(),i&&(this.reconnectTimer=new _((()=>{this.socket&&(this.socket.close(),this.socket=null),this.connect()}),s)),this.clearAuthenticationInformation()}registerEvents(e){this.eventEmitter.events.push(...e)}connect(){if(this.socket)return;const e=new WebSocket(this.serverURL);e.onopen=this.onOpen.bind(this),e.onmessage=this.onMessage.bind(this),e.onerror=()=>{this.socket=null,this.eventEmitter.emit("error",`Failed to create the WebSocket connection to ${this.serverURL}. Please check your firewall or proxy settings.`)},this.socket=e}disconnect(){this.socket&&(this.socket.onclose=()=>{},this.socket.close(),this.clearAuthenticationInformation(),this.abortOpenRequests(),this.eventEmitter.emit("disconnect"))}get connectionState(){switch(this.socket&&this.socket.readyState){case C:return"connecting";case k:return"open";case j:return"closing";default:return"closed"}}get isAuthenticated(){return""!==this.clientId}sendRequest(e,t){return new Promise(((s,i)=>{if(!this.isAuthenticated||!this.socket)return void i(new r.a("Cannot send request when the connection is not authenticated"));const n=this.nextRequestId(),a=JSON.stringify(t);this.requestsWaitingForAnswers=this.requestsWaitingForAnswers.set(n,{resolve:s,reject:i}),this.socket.send(`${n}:${e}:${a}`)}))}on(e,t){this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}onOpen(){const e=this.socket;e&&(e.onerror=this.onError.bind(this),e.onclose=this.onClose.bind(this))}onMessage(e){const t=e.data;if(this.isAuthenticated){const e=this.parseFrame(t);if(e.requestId){const t=e.requestId;Object(f.a)(this.requestsWaitingForAnswers.has(t),"Received a reply with an unknown request ID.");const s=this.requestsWaitingForAnswers.get(t);switch(Object(f.a)(s),e.action){case"ok":s.resolve(e.payload);break;case"error":s.reject(new r.a(e.payload.reason||"Unknown error"));break;default:Object(f.a)(!1,`${e.action} is not a valid request reply`)}this.requestsWaitingForAnswers=this.requestsWaitingForAnswers.delete(t)}else this.eventEmitter.events.includes(e.action)&&this.eventEmitter.emit(e.action,e.payload),this.log("incoming info message",e)}else{const e=this.parseUnauthenticatedFrame(t);switch(e.action){case"hello":this.onHello(e.payload);break;case"authenticated":this.onAuthenticated(e.payload);break;case"error":this.eventEmitter.emit("error",e.payload.reason||"Unknown error")}}}onClose(e){this.clearAuthenticationInformation(),this.abortOpenRequests(),this.reconnectTimer&&this.reconnectTimer.scheduleTimeout(),this.eventEmitter.emit("disconnect"),this.log("close",e)}onError(e){this.reconnectTimer&&this.reconnectTimer.scheduleTimeout(),this.log("error",e)}nextRequestId(){const e=this.lastRequestId+1;return this.lastRequestId=e,e}onHello(e){const t=this.socket;if(2===e.protocol_version){const e={protocol_version:2,client_version:g,client_info:O,auth_payload:this.authPayload};t.send(`hello_web:${JSON.stringify(e)}`)}else t.send(`handshake_failed:${JSON.stringify({reason:"protocol_mismatch",protocol_version:2,client_version:g,client_info:O})}`),this.eventEmitter.emit("error","protocol_mismatch")}onAuthenticated(e){Object(f.a)(e.client_id,"`authenticated` message has no `client_id`"),this.clientId=e.client_id,this.userId=e.user_id||null,this.eventEmitter.emit("connect",{clientId:this.clientId,userId:this.userId})}log(...e){"development"===Object(b.b)()&&console.log("SYNCConnection",...e)}parseFrame(e){const[,t,s,i]=/^(\d+|info):([a-zA-Z-_]+):(.+)$/.exec(e.toString());let n=null;return"info"!==t&&(n=parseInt(t)),{requestId:n,action:s,payload:JSON.parse(i)}}parseUnauthenticatedFrame(e){const[,t,s]=/^(hello|authenticated|error):(.+)$/.exec(e.toString());return{action:t,payload:JSON.parse(s)}}abortOpenRequests(){this.requestsWaitingForAnswers.forEach((e=>{e.reject(new r.a("request aborted"))})),this.requestsWaitingForAnswers=Object(c.b)()}clearAuthenticationInformation(){this.clientId="",this.userId=null}}){this.state=e,this.connectionClass=t}load(e,t,s){return new Promise(((i,n)=>{this.setState=e=>{this.state=e},this.connection=new this.connectionClass(e,t,{events:["client_presence"]}),this.connection.on("connect",(e=>{const t=new u({clientId:e.clientId,userId:e.userId,presenceContent:s});this.setState(this.state.set("status","online").set("currentClient",t)),this.populateClients(s).then((()=>{i(this)})).catch(n)})),this.connection.on("error",(e=>{n(new r.a(e.toString()))})),this.connection.on("client_presence",(e=>this.onInfoClientPresence(e))),this.connection.connect()}))}populateClients(e){return new Promise(((t,s)=>{this.connection.sendRequest("enter_layer",{presence:e}).then((e=>{this.setState(function(e,t){return Object(f.a)(t.clients,"The payload must have a `clients` list"),e.withMutations((s=>{var i;const n=Object(c.b)(t.clients.map((e=>y(e))).map((e=>[e.clientId,e]))).set(null===(i=e.currentClient)||void 0===i?void 0:i.clientId,e.currentClient);s.set("clients",n)}))}(this.state,e)),t()})).catch(s)}))}onInfoClientPresence(e){if(this.setState(function(e,t){Object(f.a)("object"==typeof t.clients,"The payload must have `clients`");const s=e.clients.withMutations((s=>{if(t.clients.entered)for(const i of t.clients.entered){if(e.clients.has(i.client_id))throw new r.a("The client marked as entered is already known");const t=y(i);s.set(t.clientId,t)}if(t.clients.updated)for(const i of t.clients.updated){Object(f.a)("string"==typeof i.client_id,"The client payload must have a `client_id`"),Object(f.a)("object"==typeof i.presence,"The client payload must have a `presence`");const t=e.clients.get(i.client_id);if(!t)throw new r.a("The client marked as updated is not known");s.set(t.clientId,t.set("presenceContent",i.presence))}if(t.clients.left)for(const i of t.clients.left){if(!e.clients.has(i))throw new r.a("The client marked as left is not known");s.delete(i)}}));return e.set("clients",s)}(this.state,e)),this.shouldFireClientUpdatesCallback){let t=Object(c.b)();if(e.clients.entered){const s=e.clients.entered.map((e=>e.client_id));t=this.state.clients.filter((e=>-1!==s.indexOf(e.clientId))).toMap()}let s=Object(c.b)();if(e.clients.updated){const t=e.clients.updated.map((e=>e.client_id));s=this.state.clients.filter((e=>-1!==t.indexOf(e.clientId))).toMap()}let i=Object(c.a)();e.clients.updated&&(i=Object(c.a)(e.clients.left)),this.clientUpdatesCallback(t,s,i)}}disconnect(){"offline"!==this.getStatus()&&(this.setState(this.state.set("status","offline")),this.connection.disconnect())}getStatus(){return this.state.status}getCurrentClient(){return this.state.currentClient}getClients(){return this.shouldFireClientUpdatesCallback=!0,this.state.clients}updatePresence(e){return new Promise(((t,s)=>{if("online"!==this.getStatus())return s(new r.a("ClientsPresence is not connected"));this.connection.sendRequest("update_client_presence",{presence:e}).then((()=>{this.setState(function(e,t){var s;return e.setIn(["currentClient","presenceContent"],t).setIn(["clients",null===(s=e.currentClient)||void 0===s?void 0:s.clientId,"presenceContent"],t)}(this.state,e)),t(!0)}),(()=>{s(new r.a("Unable to update presence"))}))}))}onClientUpdates(e){if("function"!=typeof e)throw new TypeError("callback must be a function");this.clientUpdatesCallback=e}}){const s=[];return this._sync=new e,s.push(this._sync.load(`${this._documentURL}/sync`,this._authPayload,this._settings.listenToServerChangesEnabled).catch(r.i)),this._sync.setOnDocumentHandleConflictCallback(this.onDocumentHandleConflict),this._settings.clientsPresenceEnabled&&(this._clients=new t,s.push(this._clients.load(`${this._serverURL.replace(/^http/i,"ws")}/websocket`,this._authPayload,{}).then((()=>{const e=this._clients;null!=e&&(e.onClientUpdates((()=>this._onClientsChange(e.getClients()))),this._onClientsChange(e.getClients()))})).catch((e=>{Object(r.p)("PSPDFKit: An error occurred while initializing the connected clients module. This might be due to a lack of support for WebSockets or a related failure.\n\nFailure details:\n\n"+e.message)})))),Promise.all(s).then((()=>this)).catch((e=>{throw new r.a(`Initialization of PSPDFKit Instant failed:\n${e.message}`)}))}destroy(){this._sync&&this._sync.destroy()}setFormsEnabledInConfig(e){this._formsEnabledInConfig=e}setReadStateCallbacks(e){this._readStateCallbacks=e}setAnnotationCallbacks(e){this._annotationCallbacks=e}setBookmarkCallbacks(e){this._bookmarkCallbacks=e}setFormFieldCallbacks(e){this._formFieldCallbacks=e}setFormFieldValueCallbacks(e){this._formFieldValueCallbacks=e}setCommentCallbacks(e){this._commentCallbacks=e}createAnnotation(e,t){const s=Object(l.o)(e),{id:i}=s,a=n()(s,["id"]),{group:o,permissions:c}=a,r=n()(a,["group","permissions"]);return this._sync.createRecord(i,r,Object(l.b)(t),o)}createComment(e){const t=Object(l.p)(e),{id:s}=t,i=n()(t,["id"]),{group:a,permissions:o}=i,c=n()(i,["group","permissions"]);return this._existingCommentIds=this._existingCommentIds.add(s),this._sync.createRecord(s,c,{},a)}async updateComment(e){try{return await this.updateRecord(Object(l.p)(e))}catch(e){if(!(e instanceof r.a))throw e}}deleteComment(e){return this._existingCommentIds=this._existingCommentIds.delete(e),this._sync.deleteRecord(e).then((()=>{}))}setStateGetter(e){this._getState=e}async updateRecord(e){var t;const{id:s,permissions:i,group:a}=e,o=n()(e,["id","permissions","group"]);return this._getState&&this._getState()&&(null===(t=this._getState().backend)||void 0===t?void 0:t.isCollaborationPermissionsEnabled())?this._sync.updateRecord(s,i.edit?o:void 0,i.setGroup?a:void 0):this._sync.updateRecord(s,o,a)}async updateAnnotation(e){try{return await this.updateRecord(Object(l.o)(e))}catch(e){if(!(e instanceof r.a))throw e}}deleteAnnotation(e){return this._sync.deleteRecord(e.id).then((()=>{}))}createBookmark(e){const t=Object(d.b)(e),{id:s}=t,i=n()(t,["id"]);return this._existingBookmarksIds=this._existingBookmarksIds.add(s),this._sync.createRecord(s,i,{})}async updateBookmark(e){const t=Object(d.b)(e),{id:s}=t,i=n()(t,["id"]);try{return await this._sync.updateRecord(s,i)}catch(e){if(!(e instanceof r.a))throw e}}deleteBookmark(e){return this._sync.deleteRecord(e).then((()=>{this._existingBookmarksIds=this._existingBookmarksIds.delete(e)}))}createFormField(e){const t=Object(l.r)(e),{id:s}=t,i=n()(t,["id"]),{group:a,permissions:o}=i,c=n()(i,["group","permissions"]);return this._existingFormFieldsIds=this._existingFormFieldsIds.add(s),this._sync.createRecord(s,c,{},a)}async updateFormField(e){try{return await this.updateRecord(Object(l.r)(e))}catch(e){if(!(e instanceof r.a))throw e}}deleteFormField(e){return this._sync.deleteRecord(e.id).then((()=>{this._existingFormFieldsIds=this._existingFormFieldsIds.delete(e.id)}))}loadFormFields(){return this.loadAnnotationsForPageIndex()}createFormFieldValue(e){const t=Object(l.s)(e),s=Object(P.b)(e);return this._existingFormFieldValuesIds=this._existingFormFieldValuesIds.add(s),this._sync.createRecord(s,t,{})}async setFormFieldValue(e){const t=Object(l.s)(e);try{return await this._sync.updateRecord(Object(P.b)(e),t)}catch(e){if(!(e instanceof r.a))throw e}}deleteFormFieldValue(e){return this._sync.deleteRecord(e).then((()=>{this._existingFormFieldValuesIds=this._existingFormFieldValuesIds.delete(e)}))}loadAnnotationsForPageIndex(){return this._loadPromise||(this._loadPromise=new Promise((e=>setTimeout(e,0))).then((()=>{this._hasLoadedInitialRecords||(this._sync.onRecordsUpdates(((e,t,s)=>this._onRecordsUpdates(e,t,s,h.b)),((e,t,s)=>this._onAcceptedRecords(e,t,s))),this._onRecordsUpdates(this._sync.getRecords(),Object(c.a)(),Object(c.a)(),h.a),this._hasLoadedInitialRecords=!0)}))),this._loadPromise}async loadBookmarks(){}syncChanges(){return this._sync.syncChanges()}_filterRecords(e){return e.filter((({content:e})=>this._formsEnabledInConfig||!Object(l.l)(e)))}_onRecordsUpdates(e,t,s,i){let n=Object(c.a)();const a=[];let o=Object(c.a)(),h=Object(c.a)(),u=Object(c.g)(),m=Object(c.g)(),b=Object(c.g)(),p=Object(c.g)(),_=Object(c.g)();const g=this._getState?this._getState():void 0;let C=e,k=t,j=s;if(g&&g.backend&&g.backend.isCollaborationPermissionsEnabled()){C=C.filter((({content:e})=>!!e));const e=[];t.forEach(((t,s)=>{t.content?A(g,t)||(C=C.push(t),e.push(s)):A(g,t)?(j=j.push(t.id),e.push(s)):e.push(s)})),k=k.filter(((t,s)=>!e.includes(s))),j=j.filter((e=>g.annotations.has(e)||this._existingFormFieldValuesIds.has(e)||this._existingFormFieldsIds.has(e)||this._existingCommentIds.has(e)||this._existingBookmarksIds.has(e)))}let O=Object(c.a)().withMutations((e=>{this._filterRecords(C).forEach((({id:t,content:s,permissions:i,group:c})=>{const u={permissions:i,group:c};try{Object(l.l)(s)?(a.push(Object(l.e)(t,s,u)),this._existingFormFieldsIds=this._existingFormFieldsIds.add(t)):Object(l.m)(s)?(o=o.push(Object(l.f)(s)),this._existingFormFieldValuesIds=this._existingFormFieldValuesIds.add(t)):Object(l.j)(s)?(n=n.push(Object(d.a)(t,s)),this._existingBookmarksIds=this._existingBookmarksIds.add(t)):Object(l.k)(s)?(this._existingCommentIds=this._existingCommentIds.add(t),h=h.push(Object(l.d)(t,s,u))):Object(l.n)(s)||e.push(Object(l.c)(t,s,u))}catch(e){Object(r.j)(`Skipped creating record #${t} from payload because an error occurred while deserializing.`,s),Object(r.j)(e)}}))}));const F=!g||Object($.p)(g.features,g.signatureFeatureAvailability);a.length>0&&(Object(f.a)(this._formFieldCallbacks),g&&!F?this._formFieldCallbacks.createFormFields(Object(c.a)(a.filter((e=>!(e instanceof z.i)))),i):this._formFieldCallbacks.createFormFields(Object(c.a)(a),i)),o.size>0&&(Object(f.a)(this._formFieldValueCallbacks),g&&!F&&(o=o.filter((e=>{const t=a.find((t=>t.name===e.name))||g.formFields.get(e.formFieldName);return!(t&&t instanceof z.i)}))),this._formFieldValueCallbacks.createFormFieldValues(Object(c.a)(o),i)),O.size>0&&(Object(f.a)(this._annotationCallbacks),g&&!F&&(O=O.filter((e=>{if(!(e instanceof B.fb))return e;const t=a.find((t=>t.name===e.formFieldName))||g.formFields.get(e.formFieldName);return!(t&&t instanceof z.i)}))),this._annotationCallbacks.createAnnotations(O,Object(c.b)(),i)),h.size>0&&(Object(f.a)(this._commentCallbacks),this._commentCallbacks.createComments(h,i)),n.size>0&&(Object(f.a)(this._bookmarkCallbacks),this._bookmarkCallbacks.createBookmarks(n,i));const y=Object(c.a)().asMutable(),w=[],I=[],v=[],R=Object(c.a)().withMutations((e=>{this._filterRecords(k).map((({id:t,content:s,group:i,permissions:n})=>{const a={permissions:n,group:i};try{if(Object(l.l)(s))try{w.push(Object(l.e)(t,s,a))}catch(e){b=b.add(t),Object(r.j)(`Skipped updating form field #${t} from payload because an error occurred while deserializing. To avoid issues, we have removed the previous version from the application state.`,s),Object(r.j)(e)}else if(Object(l.m)(s))try{I.push(Object(l.f)(s))}catch(e){p=p.add(t),Object(r.j)(`Skipped updating form field value #${t} from payload because an error occurred while deserializing. To avoid issues, we have removed the previous version from the application state.`,s),Object(r.j)(e)}else if(Object(l.j)(s))try{y.push(Object(d.a)(t,s))}catch(e){m=m.add(t),Object(r.j)(`Skipped updating bookmark #${t} from payload because an error occurred while deserializing. To avoid issues, we have removed the previous version from the application state.`,s),Object(r.j)(e)}else if(Object(l.k)(s))try{v.push(Object(l.d)(t,s,a))}catch(e){_=_.add(t),Object(r.j)(`Skipped updating comment #${t} from payload because an error occurred while deserializing. To avoid issues, we have removed the previous version from the application state.`,s,e)}else e.push(Object(l.c)(t,s,a))}catch(e){u=u.add(t),Object(r.j)(`Skipped updating annotation #${t} from payload because an error occurred while deserializing. To avoid issues, we have removed the previous version from the application state.`,s),Object(r.j)(e)}}))}));R.size>0&&(Object(f.a)(this._annotationCallbacks),this._annotationCallbacks.updateAnnotations(R)),y.size>0&&(Object(f.a)(this._bookmarkCallbacks),this._bookmarkCallbacks.updateBookmarks(y)),w.length>0&&(Object(f.a)(this._formFieldCallbacks),this._formFieldCallbacks.updateFormFields(Object(c.a)(w))),I.length>0&&(Object(f.a)(this._formFieldValueCallbacks),this._formFieldValueCallbacks.setFormFieldValues(Object(c.a)(I))),v.length>0&&(Object(f.a)(this._commentCallbacks),this._commentCallbacks.updateComments(Object(c.a)(v))),u=u.concat(j.filter((e=>!(this._existingBookmarksIds.has(e)||this._existingFormFieldsIds.has(e)||this._existingFormFieldValuesIds.has(e)||this._existingCommentIds.has(e)))).toSet()),u.size>0&&(Object(f.a)(this._annotationCallbacks),this._annotationCallbacks.deleteAnnotations(u)),m=m.concat(j.filter((e=>{const t=this._existingBookmarksIds.has(e);return t&&(this._existingBookmarksIds=this._existingBookmarksIds.delete(e)),t})).toSet()),m.size>0&&(Object(f.a)(this._bookmarkCallbacks),this._bookmarkCallbacks.deleteBookmarks(m)),b=b.concat(j.filter((e=>{const t=this._existingFormFieldsIds.has(e);return t&&(this._existingFormFieldsIds=this._existingFormFieldsIds.delete(e)),t})).toSet()),b.size>0&&(Object(f.a)(this._formFieldCallbacks),this._formFieldCallbacks.deleteFormFields(b)),p=p.concat(j.filter((e=>{const t=this._existingFormFieldValuesIds.has(e);return t&&(this._existingFormFieldValuesIds=this._existingFormFieldValuesIds.delete(e)),t})).toSet()),p.size>0&&(Object(f.a)(this._formFieldValueCallbacks),this._formFieldValueCallbacks.deleteFormFieldValues(p)),_=_.concat(j.filter((e=>{const t=this._existingCommentIds.has(e);return t&&(this._existingCommentIds=this._existingCommentIds.delete(e)),t})).toSet()),_.size>0&&(Object(f.a)(this._commentCallbacks),this._commentCallbacks.deleteComments(_))}_onAcceptedRecords(e,t){const s=this._getState?this._getState():void 0;if(!s||!s.backend||!s.backend.isCollaborationPermissionsEnabled())return;const i=[],n=[],a=[],o=[],r=[],l=[];function d(e){const t={permissions:e.permissions,group:e.group};let c=q(s,e);if(c&&"string"!=typeof c){Object(V.c)(t);const e=Object(V.a)(t);c=c.merge(e),c instanceof E.a?t.permissions&&t.permissions.view?i.push(c):o.push(c.id):c instanceof T.a?t.permissions&&t.permissions.view?n.push(c):(Object(f.a)(c.id),r.push(c.id)):c instanceof U.a&&(t.permissions&&t.permissions.view?a.push(c):l.push(c.id))}}e.isEmpty()||e.forEach(d),t.isEmpty()||t.forEach(d),i.length>0&&(Object(f.a)(this._annotationCallbacks),this._annotationCallbacks.updateAnnotations(Object(c.a)(i),!0)),n.length>0&&(Object(f.a)(this._commentCallbacks),this._commentCallbacks.updateComments(Object(c.a)(n))),a.length>0&&(Object(f.a)(this._formFieldCallbacks),this._formFieldCallbacks.updateFormFields(Object(c.a)(a))),o.length>0&&(Object(f.a)(this._annotationCallbacks),this._annotationCallbacks.deleteAnnotations(Object(c.g)(o),!0)),r.length>0&&(Object(f.a)(this._commentCallbacks),this._commentCallbacks.deleteComments(Object(c.g)(r))),l.length>0&&(Object(f.a)(this._formFieldCallbacks),this._formFieldCallbacks.deleteFormFields(Object(c.g)(l)))}onClientsChange(e){if("function"!=typeof e)throw new TypeError("Callback must be a function");this.onClientsChangeCallback=e}_onClientsChange(e){this.onClientsChangeCallback.call(null,e)}}}}]);