"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[73312],{73312:(e,t,r)=>{r.r(t),r.d(t,{CoreEditorOffline:()=>g,CoreEditorOfflineProvider:()=>l});var i=r(10467),a=r(75629),n=r(52749),o=r(58364),c=r(79555),d=r(6787),f=r(63316),s=r(54438);let l=(()=>{var e;class CoreEditorOfflineProvider{constructor(){this.logger=d.CoreLogger.getInstance("CoreEditorOfflineProvider")}deleteDraft(e,t,r,a,o){var c=this;return(0,i.A)((function*(){try{const i=yield n.CoreSites.getSiteDb(o),d=c.fixDraftPrimaryData(e,t,r,a);yield i.deleteRecords(f.T,d)}catch{}}))()}fixDraftPrimaryData(e,t,r,i){return{contextlevel:e,contextinstanceid:t,elementid:r,extraparams:o.T.sortAndStringify(i||{})}}getDraft(e,t,r,a,o){var c=this;return(0,i.A)((function*(){const i=yield n.CoreSites.getSiteDb(o),d=c.fixDraftPrimaryData(e,t,r,a);return i.getRecord(f.T,d)}))()}resumeDraft(e,t,r,a,o,c,d){var s=this;return(0,i.A)((function*(){try{const i=yield s.getDraft(e,t,r,a,d);try{const e=yield n.CoreSites.getSiteDb(d);i.pageinstance=o,i.timemodified=Date.now(),c&&i.originalcontent!=c&&(i.originalcontent=c,i.drafttext=""),yield e.insertRecord(f.T,i)}catch{}return i}catch{yield s.saveDraft(e,t,r,a,o,"",c,d)}}))()}saveDraft(e,t,r,o,c,d,s,l){var g=this;return(0,i.A)((function*(){let i,D=Date.now();try{i=yield g.getDraft(e,t,r,o,l),D=i.timecreated||D}catch(e){}if(i){if(i.pageinstance!=c)throw g.logger.warn(`Discarding draft because of pageinstance. Context '${e}' '${t}', element '${r}'`),new a.CoreError("Draft was discarded because it was modified in another page.");s||(s=i.originalcontent)}const u=yield n.CoreSites.getSiteDb(l),y=g.fixDraftPrimaryData(e,t,r,o);y.drafttext=(d||"").trim(),y.pageinstance=c,y.timecreated=D,y.timemodified=Date.now(),s&&(y.originalcontent=s),yield u.insertRecord(f.T,y)}))()}}return(e=CoreEditorOfflineProvider).ɵfac=function CoreEditorOfflineProvider_Factory(t){return new(t||e)},e.ɵprov=s.jDH({token:e,factory:e.ɵfac,providedIn:"root"}),CoreEditorOfflineProvider})();const g=(0,c.Qd)(l)}}]);