1"use strict";(self["webpackChunkclinux_vue"]=self["webpackChunkclinux_vue"]||[]).push([[6263],{27114:function(e,t,i){i.d(t,{M:function(){return L}});var r=i(62377),o=i(79804),n=i(95525),s=i(8527),a=i(41807),l=i(15693),d=i(68886),h=i(97827),c=i(25679),p=i(44298),g=i(16223),u=i(55029),m=i(30610),f=i(4925),v=i(39967),y=i(79401),F=i(21274),H=i(71814),C=i(31822),w=i(12498),I=i(22665),b=i(94517),W=i(57021),x=i(48590),P=i(89981),R=i(92599),k=i(46124),T=i(9366),S=i(31353),L=function(){function e(e){var t=this;this.nodes=[],this.editHyperlinkInternal=!1,this.startParagraph=void 0,this.endParagraph=void 0,this.formFieldCounter=1,this.skipFieldDeleteTracking=!1,this.isForHyperlinkFormat=!1,this.isTrackingFormField=!1,this.isInsertText=!1,this.removeEditRange=!1,this.isRemoveRevision=!1,this.isFootNoteInsert=!1,this.isTableInsert=!1,this.isFootNote=!1,this.isHandledComplex=!1,this.isUserInsert=!1,this.tableResize=void 0,this.tocStyles={},this.triggerPageSpellCheck=!0,this.chartType=!1,this.removedBookmarkElements=[],this.tocBookmarkId=0,this.copiedData=void 0,this.pageRefFields={},this.delBlockContinue=!1,this.delBlock=void 0,this.delSection=void 0,this.isInsertingTOC=!1,this.editStartRangeCollection=[],this.skipReplace=!1,this.skipTableElements=!1,this.listNumberFormat="",this.listLevelNumber=0,this.isXmlMapped=!1,this.combineLastBlock=!1,this.copiedContent="",this.copiedTextContent="",this.previousParaFormat=void 0,this.previousCharFormat=void 0,this.previousSectionFormat=void 0,this.pasteTextPosition=void 0,this.isPaste=!1,this.isPasteListUpdated=!1,this.isHtmlPaste=!1,this.isInsertField=!1,this.isBordersAndShadingDialog=!1,this.onTextInputInternal=function(){if(a.AR.isDevice){var e=t.documentHelper,i=new RegExp(String.fromCharCode(160),"g"),r=new RegExp(String.fromCharCode(10),"g");e.prefix=e.prefix.replace(i," ").replace(r," ");var o=e.editableDiv.textContent.replace(i," ").replace(r," "),n=o.substring(2);if(e.isCompositionStart&&e.isCompositionUpdated)return e.isCompositionUpdated=!1,void(!e.owner.isReadOnlyMode&&e.owner.isDocumentLoaded&&t.canEditContentControl&&e.prefix.substring(2)!==n&&(t.selection.isEmpty?(t.selection.start.setPositionForLineWidget(e.selection.start.currentWidget,t.selection.start.offset-(e.prefix.length-2)),t.handleTextInput(n),e.prefix="@"+String.fromCharCode(160)+n):(t.handleTextInput(n),e.prefix="@"+String.fromCharCode(160)+n)));if(e.isCompositionStart&&e.isCompositionEnd&&""===e.suffix)return e.prefix.substring(2)!==n?t.selection.isEmpty&&e.isCompositionStart?(e.isCompositionStart=!1,t.selection.start.setPositionForLineWidget(e.selection.start.currentWidget,t.selection.start.offset-e.prefix.substring(2).length),t.selection.retrieveCurrentFormatProperties(),""!==e.suffix&&""!==n||t.handleTextInput(n)):t.selection.isEmpty||(e.isCompositionStart=!1,t.handleTextInput(n)):""===n?(e.isCompositionStart=!1,t.handleBackKey()):e.prefix.substring(2)===n&&""===e.suffix&&(e.isCompositionStart=!1,t.handleTextInput(" ")),void(e.isCompositionEnd=!1);if(e.isCompositionEnd||e.isCompositionStart&&!e.isCompositionUpdated){if(n.length<e.prefix.length&&n===e.prefix.substring(2,e.prefix.length-1)||e.editableDiv.innerText.length<2)return void t.handleBackKey();if(""!==e.suffix&&e.editableDiv.innerText[e.editableDiv.innerText.length-1]!==String.fromCharCode(160))return e.isCompositionStart=!1,t.selection.start.setPositionForLineWidget(e.selection.start.currentWidget,t.selection.start.offset-(e.prefix.length-2)),t.selection.end.setPositionForLineWidget(e.selection.end.currentWidget,t.selection.end.offset+e.suffix.length),t.selection.retrieveCurrentFormatProperties(),void t.handleTextInput(n)}"\r"!==o&&"\b"!==o&&o!==String.fromCharCode(27)&&!e.owner.isReadOnlyMode&&!1===e.isControlPressed&&t.canEditContentControl&&("@"===o||"@"!==o[0]||""===o||o.length<e.prefix.length&&n===e.prefix.substring(2,e.prefix.length-1)?(t.handleBackKey(),e.editableDiv.innerText.length<2&&t.predictText()):0===o.indexOf(e.prefix)&&o.length>e.prefix.length?t.handleTextInput(o.substring(e.prefix.length)):-1===o.indexOf(e.prefix)&&o[o.length-1]!==String.fromCharCode(160)&&" "!==o[o.length-1]?(n.charAt(0).toLowerCase()+n.slice(1)===e.prefix.substring(2)&&t.selection.start.setPositionParagraph(e.selection.start.currentWidget,t.selection.start.offset-(e.prefix.length-2)),t.handleTextInput(n)):2!==o.length&&t.handleTextInput(" "))}else{o=t.documentHelper.editableDiv.innerText;o!==String.fromCharCode(160)?"\r"!==o&&"\b"!==o&&o!==String.fromCharCode(27)&&!t.owner.isReadOnlyMode&&!1===t.documentHelper.isControlPressed&&t.canEditContentControl&&t.handleTextInput(o):t.handleTextInput(" "),t.documentHelper.editableDiv.innerText=""}},this.onPaste=function(e){!t.owner.isReadOnlyMode&&t.canEditContentControl&&t.pasteInternal(e),e.preventDefault()},this.documentHelper=e,this.tableResize=new W.d(this.documentHelper.owner),this.base64=new s.DS}return Object.defineProperty(e.prototype,"restrictFormatting",{get:function(){return this.documentHelper.isDocumentProtected&&(this.documentHelper.restrictFormatting||!this.documentHelper.restrictFormatting&&!this.selection.isSelectionInEditRegion())&&"RevisionsOnly"!==this.documentHelper.protectionType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"restrictEditing",{get:function(){return this.documentHelper.isDocumentProtected&&(("ReadOnly"===this.documentHelper.protectionType||this.documentHelper.isCommentOnlyMode)&&!this.selection.isSelectionInEditRegion()||"FormFieldsOnly"===this.documentHelper.protectionType)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canEditContentControl",{get:function(){return!this.owner.isReadOnlyMode&&!this.selection.checkContentControl
1Locked()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewer",{get:function(){if(!(0,a.le)(this.owner))return this.owner.viewer},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editorHistory",{get:function(){return this.documentHelper.owner.editorHistory},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){if(this.documentHelper)return this.documentHelper.selection},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"owner",{get:function(){return this.documentHelper.owner},enumerable:!0,configurable:!0}),e.prototype.getModuleName=function(){return"Editor"},e.prototype.setFieldInfo=function(e){var t=this.selection.getHyperlinkField(!0);(0,a.le)(t)||(this.selection.selectField(),this.insertField(e.code,e.result))},e.prototype.insertField=function(e,t){this.isInsertField=!0;var i=e;if(i=s.o_.trimStart(i),"NUMPAGES"===i.substring(0,8))this.insertPageCount(t);else if("PAGE"===i.substring(0,4))this.insertPageNumber(t);else{if((0,a.le)(t)&&"MERGEFIELD"===i.substring(0,10)){i=i.substring(10).trim();var r=i.indexOf("\\*");t="«"+i.substring(0,r).trim()+"»"}var d=new o.ZH,h=new n.a,c=this.copyInsertFormat(h,!1),p=new o.z7(d),g=new o.V8(0);g.characterFormat.mergeFormat(c),p.children.push(g);var u=new o.a3;u.characterFormat.mergeFormat(c),u.text=e,p.children.push(u);var m=new o.V8(2);m.characterFormat.mergeFormat(c),m.fieldBegin=g,g.fieldSeparator=m,p.children.push(m);var f=new o.a3;f.text=t,f.characterFormat.mergeFormat(c),p.children.push(f);var v=new o.V8(1);v.characterFormat.mergeFormat(c),v.fieldSeparator=m,v.fieldBegin=g,g.fieldEnd=v,m.fieldEnd=v,p.children.push(v),g.line=p,d.childWidgets.push(p),this.documentHelper.fields.push(g);var y=new o.VB;y.sectionFormat=new l.Z(y),y.childWidgets.push(d),this.pasteContentsInternal([y],!1)}this.isInsertField=!1},e.prototype.isLinkedStyle=function(e){var t=this.documentHelper.styles.findByName(e);return!(0,a.le)(t.link)},e.prototype.applyStyle=function(e,t){t=!(0,a.le)(t)&&t;var i=void 0,r=void 0;if(t){this.initComplexHistory("ApplyStyle"),this.setOffsetValue(this.selection),i=this.startOffset,r=this.endOffset;var o=this.selection.isEmpty;this.clearFormattingInternal(!this.isLinkedStyle(e)),o&&!this.selection.isEmpty&&this.selection.end.setPositionInternal(this.selection.start)}var n=this.documentHelper.styles.findByName(e);if(void 0!==n)if(n instanceof I.l2&&"Character"===n.type)if(this.selection.isEmpty){var s=this.selection.start.offset,l=this.selection.start.clone(),d=this.selection.end.clone();this.selection.selectCurrentWord(),s===this.selection.start.offset||s===this.selection.end.offset-1?(this.selection.start=l,this.selection.end=d,this.selection.characterFormat.copyFormat(n.characterFormat)):this.onApplyCharacterFormat("styleName",n,!1,!0)}else this.onApplyCharacterFormat("styleName",n,!1,!0);else this.onApplyParagraphFormat("styleName",n,!1,!0);else this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),JSON.parse(this.documentHelper.preDefinedStyles.get(e)),this.documentHelper.styles),this.applyStyle(e);this.editorHistory&&this.editorHistory.currentHistoryInfo&&"ApplyStyle"===this.editorHistory.currentHistoryInfo.action&&(this.startOffset=i,this.endOffset=r,this.editorHistory.updateComplexHistory()),this.startParagraph=void 0,this.endParagraph=void 0},e.prototype.cut=function(){this.owner.isReadOnlyMode||this.selection.isEmpty||!this.canEditContentControl||(this.selection.copySelectedContent(!0),this.documentHelper.owner.parser.isCutPerformed=!0)},e.prototype.insertEditingRegion=function(e){this.insertEditRangeElement(e&&""!==e?e:"Everyone")},e.prototype.enforceProtection=function(e,t,i){var r,o;"boolean"===typeof t?(r=i?"ReadOnly":this.documentHelper.protectionType,o=t):(o=!0,r=t),this.documentHelper.restrictFormatting=o,this.documentHelper.protectionType=r,this.selection.isHighlightEditRegion=!0,this.addProtection(e,this.documentHelper.protectionType)},e.prototype.getCommentHierarchicalIndex=function(e){var t="";while(e.ownerComment)(0,a.le)(e.ownerComment)?t=e.replyComments.indexOf(e)+";"+t:(t=e.ownerComment.replyComments.indexOf(e)+";"+t,e=e.ownerComment);return t="C;"+this.documentHelper.comments.indexOf(e)+";"+t,t},e.prototype.alertBox=function(){var e=new a.E7("documenteditor",this.owner.defaultLocale);e.setLocale(this.owner.locale),R.hZ.alert({title:e.getConstant("Information"),content:e.getConstant("Multiple Comment")})},e.prototype.insertComment=function(e){if(!((0,a.le)(this.selection.start)||this.owner.isReadOnlyMode&&!this.documentHelper.isCommentOnlyMode||this.viewer.owner.enableHeaderAndFooter)&&this.viewer.owner.enableComment){if(this.viewer.owner.commentReviewPane.commentPane.isEditMode)return this.alertBox();(0,a.le)(e)&&(e=""),this.insertCommentInternal(e)}},e.prototype.insertCommentInternal=function(e){if(this.documentHelper.layout.allowLayout=!1,this.selection.isEmpty){if(this.selection.start.isAtSamePosition(this.selection.end)&&this.selection.start.isAtParagraphEnd){var t=this.selection.start.offset;this.selection.start.offset=t-1!==-1?t-1:t}this.selection.selectCurrentWord()}this.selection.isParagraphLastLine(this.selection.end.currentWidget)&&this.selection.end.offset===this.selection.getLineLength(this.selection.end.currentWidget)+1&&(this.selection.end.offset-=1);var i=this.selection.getParagraphInfo(this.selection.start),n=(this.selection.getHierarchicalIndex(i.paragraph,i.offset.toString()),this.selection.getParagraphInfo(this.selection.end)),l=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString());this.initComplexHistory("InsertComment");var d=this.selection.start,h=this.selection.end,c=new r.JK(this.owner);this.selection.isForward||(d=this.selection.end,h=this.selection.start),c.setPositionInternal(h);var p=new o.Xw(0),g=new o.Xw(1),u=d.currentWidget===h.currentWidget;if(h.setPositionInternal(d),this.initInsertInline(p),(0,a.le)(c.paragraph)||c.currentWidget&&0===c.currentWidget.children.length&&-1===c.currentWidget.indexInOwner){var m=this.selection.getTextPosBasedOnLogicalIndex(l);c.setPositionInternal(m)}u&&c.setPositionParagraph(c.currentWidget,c.offset+p.length),d.setPositionInternal(c),h.setPositionInternal(c),this.initInsertInline(g);var f=new o._A(s.o_.getUtcDate());if(this.owner.editorHistory&&(this.initHistory("InsertCommentWidget"),this.owner.editorHistory.currentBaseHistoryInfo.removedNodes.push(f)),f.author=this.owner.currentUser?this.owner.currentUser:"Guest user",f.initial=this.constructCommentInitial(f.author),f.text=e,f.commentId=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),p.comment=f,p.commentId=f.commentId,g.comment=f,g.commentId=f.commentId,f.commentStart=p,f.commentEnd=g,this.addCommentWidget(f,!0,!0,!0),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=this.getCommentHierarchicalIndex(f),this.editorHistory.updateHistory()),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.reLayout(this.selection,!1),this.documentHelper.layout.allowLayout=!0,!this.isUserInsert){var v=this.owner.commentReviewPane.commentPane.comments.get(f);v.postComment()}},e.prototype.deleteAllComments=function(){if(0!==this.documentHelper.comments.length){var e;this.initComplexHistory("DeleteAllComments"),this.owner.isLayoutEnabled=!1,this.editorHistory&&this.editorHistory.currentHistoryInfo&&(e=this.editorHistory.currentHistoryInfo);while(this.documentHelper.comments.length>0){var t=this.documentHelper.comments[0];this.initComplexHistory("DeleteComment"),this.deleteCommentInternal(t),this.editorHistory&&this.editorHistory.currentHistoryInfo&&e.addModifiedAction(this.editorHistory.currentHistoryInfo)}this.selection.selectContent(this.owner.documentStart,!0),this.editorHistory&&(this.editorHistory.currentHistoryInfo=e,this.editorHistory.updateComplexHistory())}},e.prototype.deleteComment=function(){this.owner.isReadOnlyMode&&!this.documentHelper.isCommentOnlyMode||(0,a.le)(this.owner)||(0,a.le)(this.owner.viewer)||(0,a.le)(this.owner.documentHelper.currentSelectedComment)||this.owner.enableHeaderAndFooter||!this.viewer.owner.enableComment||this.deleteCommentInternal(this.owner.documentHelper.currentSelectedComment)},e.prototype.deleteCommentInternal=function(e){if(this.initComplexHistory("DeleteComment"),e){if(e.replyComments.length>0)for(var t=e.replyComments.length-1;t>=0;t--)this.deleteCommentInternal(e.replyComments[t]);this.deleteCommentWidgetInternal(e);var i=e.commentStart,r=e.commentEnd;-1!==r.indexInOwner&&this.removeInline(r),-1!==i.indexInOwner&&this.removeInline(i),i.removeCommentMark()}this.editorHistory&&this.editorHistory.updateComplexHistory()},e.prototype.deleteCommentWidgetInternal=function(e){this.owner.editorHistory&&(this.initHistory("DeleteCommentWidget"),this.owner.editorHistory.currentBaseHistoryInfo.insertPosition=this.getCommentHierarchicalIndex(e),this.owner.editorHistory.currentBaseHistoryInfo.removedNodes.push(e)),this.deleteCommentWidget(e),this.editorHistory&&this.editorHistory.updateHistory()},e.prototype.deleteCommentWidget=function(e){var t=this.documentHelper.comments.indexOf(e);-1!==t?this.documentHelper.comments.splice(t,1):e.isReply&&e.ownerComment&&(t=e.ownerComment.replyComments.indexOf(e),e.ownerComment.replyComments.splice(t,1)
1),this.owner.commentReviewPane&&(this.owner.commentReviewPane.deleteComment(e),this.documentHelper.currentSelectedComment===e&&(this.documentHelper.currentSelectedComment=void 0))},e.prototype.resolveComment=function(e){if(!this.owner.isReadOnlyMode||this.documentHelper.isCommentOnlyMode){var t={author:e.author,cancel:!1,type:"Resolve"};this.owner.trigger(H.x$,t),t.cancel&&"Resolve"===t.type||(this.initHistory("ResolveComment"),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.removedNodes.push(e),this.resolveOrReopenComment(e,!0))}},e.prototype.reopenComment=function(e){if(!this.owner.isReadOnlyMode||this.documentHelper.isCommentOnlyMode){var t={author:e.author,cancel:!1,type:"Reopen"};this.owner.trigger(H.x$,t),t.cancel&&"Reopen"===t.type||(this.initHistory("ResolveComment"),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.removedNodes.push(e),this.resolveOrReopenComment(e,!1))}},e.prototype.resolveOrReopenComment=function(e,t){e.isResolved=t;for(var i=0;i<e.replyComments.length;i++)e.replyComments[i].isResolved=t;this.owner.commentReviewPane&&(t?this.owner.commentReviewPane.resolveComment(e):this.owner.commentReviewPane.reopenComment(e)),this.reLayout(this.selection,!1,!1)},e.prototype.replyComment=function(e,t){if(!this.owner.isReadOnlyMode||this.documentHelper.isCommentOnlyMode){var i=e;if(e){this.initComplexHistory("InsertComment");var n=i.commentStart,a=i.commentEnd,l=n.line.getOffset(n,1),d=new r.JK(this.documentHelper.owner);d.setPositionParagraph(n.line,l);var h=a.line.getOffset(a,1),c=new r.JK(this.documentHelper.owner);c.setPositionParagraph(a.line,h),this.selection.start.setPositionInternal(d),this.selection.end.setPositionInternal(c),d=this.selection.start,c=this.selection.end;var p=new r.JK(this.owner);p.setPositionInternal(c);var g=new o.Xw(0),u=new o.Xw(1),m=d.currentWidget===c.currentWidget;c.setPositionInternal(d),this.initInsertInline(g),m&&p.setPositionParagraph(p.currentWidget,p.offset+g.length),d.setPositionInternal(p),c.setPositionInternal(p),this.initInsertInline(u);var f=new o._A(s.o_.getUtcDate());f.author=this.owner.currentUser?this.owner.currentUser:"Guest user",f.text=t||"",f.commentId=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),f.isReply=!0,i.replyComments.push(f),f.ownerComment=i,this.owner.editorHistory&&(this.initHistory("InsertCommentWidget"),this.owner.editorHistory.currentBaseHistoryInfo.removedNodes.push(f)),g.comment=f,g.commentId=f.commentId,u.comment=f,u.commentId=f.commentId,f.commentStart=g,f.commentEnd=u,this.owner.commentReviewPane&&this.owner.commentReviewPane.addReply(f,!1,!0),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=this.getCommentHierarchicalIndex(f),this.editorHistory.updateHistory()),this.editorHistory&&this.editorHistory.updateComplexHistory(),this.reLayout(this.selection)}}},e.prototype.removeInline=function(e){this.selection.start.setPositionParagraph(e.line,e.line.getOffset(e,0)),this.selection.end.setPositionParagraph(this.selection.start.currentWidget,this.selection.start.offset+e.length),this.initHistory("RemoveInline"),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.updateHistoryPosition(this.selection.start,!0),this.removeSelectedContents(this.documentHelper.selection),this.editorHistory&&this.editorHistory.updateHistory(),this.fireContentChange()},e.prototype.addCommentWidget=function(e,t,i,r){if(-1===this.documentHelper.comments.indexOf(e)){var o=!1;if(this.documentHelper.comments.length>0)for(var n=this.selection.getElementPosition(e.commentStart).startPosition,s=0;s<this.documentHelper.comments.length;s++){var a=this.selection.getElementPosition(this.documentHelper.comments[s].commentStart).startPosition;if(n.isExistBefore(a)){o=!0,this.documentHelper.comments.splice(s,0,e);break}}o||this.documentHelper.comments.push(e),this.owner.commentReviewPane&&(this.owner.showComments=i,this.owner.commentReviewPane.selectedTab=0,this.owner.commentReviewPane.addComment(e,t,r),r&&this.owner.selection.selectComment(e))}},e.prototype.addReplyComment=function(e,t){var i=t.split(";"),r=this.documentHelper.comments[parseInt(i[1],10)];""!==i[2]&&(r.replyComments.splice(parseInt(i[2],10),0,e),e.ownerComment=r),this.owner.commentReviewPane&&(this.owner.showComments=!0,this.owner.commentReviewPane.addReply(e,!1,!0),this.owner.selection.selectComment(e))},e.prototype.addProtection=function(e,t){if(""===e)this.protectDocument(t);else{this.currentProtectionType=t;var i=new T.q,r=this.base64.encodeString(e),o={passwordBase64:r,saltBase64:"",spinCount:1e5},n=this.owner.serviceUrl+this.owner.serverActionSettings.restrictEditing;i.url=n,i.contentType="application/json;charset=UTF-8",i.onSuccess=this.enforceProtectionInternal.bind(this),i.onFailure=this.protectionFailureHandler.bind(this),i.onError=this.protectionFailureHandler.bind(this),i.customHeaders=this.owner.headers;var s={serverActionType:"RestrictEditing",headers:this.owner.headers,timeout:0,cancel:!1,withCredentials:!1};this.owner.trigger(H.z1,s),s.cancel?this.documentHelper.dialog.visible&&this.documentHelper.dialog.hide():i.send(o,s)}},e.prototype.protectionFailureHandler=function(e){var t=new a.E7("documenteditor",this.owner.defaultLocale);t.setLocale(this.documentHelper.owner.locale),"onError"===e.name?R.hZ.alert(t.getConstant("Error in establishing connection with web server")):(this.owner.fireServiceFailure(e),console.error(e.statusText))},e.prototype.enforceProtectionInternal=function(e){var t=JSON.parse(e.data);this.documentHelper.saltValue=t[0],this.documentHelper.hashValue=t[1],this.protectDocument(this.currentProtectionType)},e.prototype.toggleTrackChangesProtection=function(e){this.viewer.owner.enableTrackChanges=e;var t={isTrackChangesEnabled:e};this.owner.trigger(H.rC,t)},e.prototype.protectDocument=function(e){this.protect(e);var t=this.documentHelper.restrictEditingPane.restrictPane;t&&"block"===t.style.display&&(this.documentHelper.restrictEditingPane.showStopProtectionPane(!0),this.documentHelper.restrictEditingPane.loadPaneValue(),this.documentHelper.dialog.hide()),this.owner.notify(H.Bx,{}),"RevisionsOnly"===e&&this.toggleTrackChangesProtection(!0),this.owner.trackChangesPane.enableDisableButton(!1)},e.prototype.stopProtection=function(e){if(this.documentHelper.isDocumentProtected){if(!(0,a.le)(this.documentHelper.saltValue)&&""===this.documentHelper.saltValue&&!(0,a.le)(this.documentHelper.hashValue)&&""===this.documentHelper.hashValue&&!(0,a.le)(e)&&""===e)return void this.unProtectDocument();var t=new T.q,i=this.base64.encodeString(e),r={passwordBase64:i,saltBase64:this.documentHelper.saltValue,spinCount:1e5};t.url=this.owner.serviceUrl+this.owner.serverActionSettings.restrictEditing,t.contentType="application/json;charset=UTF-8",t.customHeaders=this.owner.headers,t.onSuccess=this.onUnProtectionSuccess.bind(this),t.onFailure=this.protectionFailureHandler.bind(this),t.onError=this.protectionFailureHandler.bind(this);var o={serverActionType:"RestrictEditing",headers:this.owner.headers,timeout:0,cancel:!1,withCredentials:!1};this.owner.trigger(H.z1,o),o.cancel?this.documentHelper.dialog.visible&&this.documentHelper.dialog.hide():t.send(r,o),this.toggleTrackChangesProtection(!1)}},e.prototype.onUnProtectionSuccess=function(e){var t=JSON.parse(e.data);this.validateHashValue(t[1])},e.prototype.validateHashValue=function(e){var t=new a.E7("documenteditor",this.owner.defaultLocale);t.setLocale(this.documentHelper.owner.locale);var i=this.base64.decodeString(e),r=this.documentHelper.hashValue,o=this.base64.decodeString(r),n=!0;if(i.length===o.length){for(var s=0;s<i.length;s++)if(i[s]!==o[s]){n=!1;break}}else n=!1;n?this.unProtectDocument():R.hZ.alert(t.getConstant("The password is incorrect"))},e.prototype.unProtectDocument=function(){var e=this.documentHelper.protectionType;this.documentHelper.isDocumentProtected=!1,this.documentHelper.restrictFormatting=!1,this.documentHelper.protectionType="NoProtection",this.documentHelper.saltValue="",this.documentHelper.hashValue="",this.documentHelper.selection.highlightEditRegion();var t=this.documentHelper.restrictEditingPane.restrictPane;t&&"block"===t.style.display&&this.documentHelper.restrictEditingPane.showStopProtectionPane(!1),"RevisionsOnly"===e&&this.toggleTrackChangesProtection(!1),this.owner.trackChangesPane.enableDisableButton(!0),(0,a.le)(this.editorHistory)||this.owner.editorHistory.clearHistory(),this.owner.notify(H.Bx,{}),this.documentHelper.dialog.hide()},e.prototype.fireContentChange=function(){this.selection.isHighlightEditRegion&&(this.owner.enableLockAndEdit?this.owner.collaborativeEditingModule.updateLockRegion():this.selection.on
1Highlight()),this.selection.highlightFormFields(),this.isPaste||(this.copiedContent=void 0,this.copiedTextContent="",this.previousSectionFormat=void 0,this.previousParaFormat=void 0,this.previousCharFormat=void 0,this.selection.isViewPasteOptions=!1,this.isPasteListUpdated&&(this.isPasteListUpdated=!1),this.selection.showHidePasteOptions(void 0,void 0)),!this.documentHelper.owner.isLayoutEnabled||this.documentHelper.owner.editor.isUserInsert||this.documentHelper.owner.isShiftingEnabled||this.documentHelper.owner.fireContentChange(),this.owner.isSpellCheck&&!(0,a.le)(this.selection.editPosition)&&(this.triggerPageSpellCheck=!1)},e.prototype.updateSelectionTextPosition=function(e){this.getOffsetValue(this.selection),this.selection.start.updatePhysicalPosition(!0),this.selection.isEmpty?this.selection.end.setPositionInternal(this.selection.start):this.selection.end.updatePhysicalPosition(!0),this.selection.upDownSelectionLength=this.selection.end.location.x,this.selection.fireSelectionChanged(e)},e.prototype.predictText=function(){this.documentHelper.suffix="",this.selection.start.paragraph.isEmpty()||0===this.selection.start.offset&&this.selection.start.currentWidget.isFirstLine()||0===this.selection.end.offset&&this.selection.end.currentWidget.isFirstLine()?this.documentHelper.prefix="":this.getPrefixAndSuffix(),this.documentHelper.prefix="@"+String.fromCharCode(160)+this.documentHelper.prefix,this.documentHelper.editableDiv.innerText=this.documentHelper.prefix,this.documentHelper.selection.setEditableDivCaretPosition(this.documentHelper.prefix.length)},e.prototype.getPrefixAndSuffix=function(){var e=this.owner,t=e.documentHelper;if(""===this.selection.text){var i=0,r=this.selection.start.currentWidget.getInline(this.selection.start.offset,i),n=r.element;if(i=r.index,void 0!==n){var s=this.selection.getElementBoxInternal(n,i),l=s.element;i=s.index;var d=0;if(!(0,a.le)(l)){var h=!1;l instanceof o.a3&&i>0&&l.line.isFirstLine()&&(t.prefix=""),n instanceof o.a3||(n=this.selection.getPreviousTextElement(n));while((d=t.prefix.lastIndexOf(" "))<0&&n instanceof o.a3)if(n.previousNode instanceof o.a3&&-1===t.prefix.indexOf(" ")){if(h?t.prefix=n.text+t.prefix:(t.prefix=n.text.substring(0,i),h=!0),n=n.previousNode,n instanceof o.no)break;n instanceof o.a3||(n=this.selection.getPreviousTextElement(n))}else if(!(n.previousNode instanceof o.a3)){h?t.prefix=n.text+t.prefix:(t.prefix=n.text.substring(0,i),h=!0);break}t.prefix.length>1&&" "===t.prefix[t.prefix.length-1]&&"."===t.prefix[t.prefix.length-2]?(d=-1,t.prefix=""):d=t.prefix.lastIndexOf(" "),t.prefix=d<0?t.prefix:t.prefix.substring(d),0===t.prefix.indexOf(" ")&&t.prefix.length>=1&&(t.prefix=t.prefix.substring(1));var c=0,p=this.selection.end.currentWidget.getInline(this.selection.end.offset,c),g=p.element;if(c=p.index,s=this.selection.getElementBoxInternal(g,c),l=s.element,c=s.index,l){var u=!1;l instanceof o.a3&&c<l.length&&(t.suffix="");while((d=t.suffix.indexOf(" "))<0&&g instanceof o.a3)if(g.nextNode instanceof o.a3&&-1===t.suffix.indexOf(" "))u?t.suffix=t.suffix+g.text:(t.suffix=l.text.substring(c),u=!0),g=g.nextNode;else if(!(g.nextNode instanceof o.a3)){u?t.suffix=t.suffix+g.text:(t.suffix=l.text.substring(c),u=!0);break}d=t.suffix.indexOf(" "),t.suffix=d<0?t.suffix:t.suffix.substring(0,d)}}}}else t.prefix=""},e.prototype.onKeyDownInternal=function(e,t,i,r){var o=e.which||e.keyCode;if(!t||i||r)if(!i||t||r)if(i&&t&&!r)switch(o){case 13:this.owner.isReadOnlyMode||(e.preventDefault(),this.insertColumnBreak());break;case 68:this.owner.isReadOnlyMode||this.owner.selection.toggleUnderline("Double");break;case 77:this.owner.isReadOnlyMode||this.owner.selection.decreaseIndent(),e.preventDefault();break;case 188:e.preventDefault(),this.owner.isReadOnlyMode||this.onApplyCharacterFormat("fontSize","decrement",!0);break;case 190:e.preventDefault(),this.owner.isReadOnlyMode||this.onApplyCharacterFormat("fontSize","increment",!0);break;case 187:e.preventDefault(),this.owner.isReadOnlyMode||this.toggleBaselineAlignment("Superscript");break;case 69:if(e.preventDefault(),!this.owner.isReadOnlyMode){var n={isTrackChangesEnabled:!this.owner.enableTrackChanges};this.owner.trigger(H.rC,n)}}else if(!i&&t&&r)switch(o){case 72:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.isDocumentLoaded&&this.toggleHighlightColor();break;case 70:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.isDocumentLoaded&&this.insertFootnote();break;case 68:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.isDocumentLoaded&&this.insertEndnote();break}else switch(o){case 8:e.preventDefault(),this.handleBackKey();break;case 9:e.preventDefault(),this.owner.acceptTab&&this.selection.handleTabKey(!0,!1);break;case 13:e.preventDefault(),this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!0),this.handleEnterKey(),this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!1);break;case 27:e.preventDefault(),this.isPaste||(this.copiedContent=void 0,this.copiedTextContent="",this.previousParaFormat=void 0,this.previousCharFormat=void 0,this.previousSectionFormat=void 0,this.selection.isViewPasteOptions=!1,this.isPasteListUpdated&&(this.isPasteListUpdated=!1),this.selection.showHidePasteOptions(void 0,void 0));break;case 46:this.handleDelete(),e.preventDefault();break;case 32:this.selection.handleSpaceBarKey();break;case 120:var s=this.selection.getDocumentEnd();s.offset=this.selection.getDocumentEnd().offset+1,this.selection.start.isAtSamePosition(this.selection.getDocumentStart())&&this.selection.end.isAtSamePosition(s)?this.owner.updateFields():this.selection.updateRefField();break}else switch(o){case 9:e.preventDefault(),this.owner.acceptTab&&this.selection.handleTabKey(!1,!0);break;case 13:this.handleShiftEnter(),e.preventDefault();break}else switch(this.documentHelper.isControlPressed=!0,o){case 8:e.preventDefault(),this.handleCtrlBackKey();break;case 46:e.preventDefault(),this.handleCtrlDelete();break;case 9:e.preventDefault(),this.owner.acceptTab&&this.selection.handleTabKey(!1,!1);break;case 13:e.preventDefault(),this.insertPageBreak();break;case 48:e.preventDefault();var a=0,l=this.documentHelper.selection.start.paragraph.paragraphFormat.beforeSpacing;l>12?a=12:l>0&&l<=12?a=0:0===l&&(a=12),this.onApplyParagraphFormat("beforeSpacing",a,!0,!1);break;case 49:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.onApplyParagraphFormat("lineSpacing",1,!1,!1);break;case 50:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.onApplyParagraphFormat("lineSpacing",2,!1,!1);break;case 53:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.onApplyParagraphFormat("lineSpacing",1.5,!1,!1);break;case 66:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.toggleBold();break;case 68:e.preventDefault(),!this.owner.isReadOnlyMode&&this.owner.fontDialogModule&&this.owner.fontDialogModule.showFontDialog();break;case 69:this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.toggleTextAlignment("Center"),e.preventDefault();break;case 72:e.preventDefault(),!this.owner.isReadOnly&&this.owner.optionsPaneModule&&(this.owner.optionsPaneModule.isReplace=!0,this.owner.optionsPaneModule.showHideOptionsPane(!0));break;case 73:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.toggleItalic();break;case 74:this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.toggleTextAlignment("Justify"),e.preventDefault();break;case 75:e.preventDefault(),this.owner.hyperlinkDialogModule&&!this.owner.isReadOnlyMode&&this.owner.hyperlinkDialogModule.show();break;case 76:this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.toggleTextAlignment("Left"),e.preventDefault();break;case 77:this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.owner.selection.increaseIndent(),e.preventDefault();break;case 78:e.preventDefault(),this.owner.isReadOnlyMode||this.owner.openBlank();break;case 82:this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.toggleTextAlignment("Right"),e.preventDefault();break;case 85:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.owner.selection.toggleUnderline("Single");break;case 88:e.preventDefault(),this.owner.isReadOnlyMode||this.owner.editor.cut();break;case 89:this.owner.enableEditorHistory&&(this.editorHistory.redo(),e.preventDefault());break;case 90:this.owner.enableEditorHistory&&(this.editorHistory.undo(),e.preventDefault());break;case 219:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.onApplyCharacterFormat("fontSize","decrement",!0);break;case 221:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.onApplyCharacterFormat("fontSize","increment",!0);break;case 187:e.preventDefault(),this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.toggleBaselineAlignment("Subscript");break}},e.prototype.handleShiftEnter=function(){this.owner.isReadOnlyMode||this.handleTextInput("\v"),this.selection.checkForCursorVisibility()},e.prototype.handleBackKey=function(){(!this.owner.isReadOnlyMode&&this.canEditContentControl||this.selection.isInlineFormFillMode())&&this.owner.editorModule.onBackSpace(),this.selection.checkForCursorVisibility()},e.prototype.handleDelete=function(){(!this.owner.isReadOnlyMode&&this.canEditContentControl||this.selection.isInlineFormFillMode())&&this.owner.editorModule.delete(),this.selection.checkForCursorVisibility()},e.prototype.handleEnterKey=function(){(!this.owner.isReadOnlyMode&&this.canEditContentControl||this.selection.isInlineFormFillMode())&&(a.AR.isDevice&&(this.documentHelper.isCompositionStart=!1),this.owner.editorModule.onEnter()),this.selection.checkForCursorVisibility()},e.prototype.handleCtrlBackKey=function(){var e=this.selection.start,t=this.selection.end;if(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode())if(this.selection.isForward||(e=t),this.selection.isEmpty)this.selection.handleControlShiftLeftKey(),this.owner.editorModule.onBackSpace();else{if(((0,a.le)(e.paragraph.previousRenderedWidget)||e.paragraph.previousRenderedWidget instanceof o.dm)&&0===e.offset)return;this.selection.handleLeftKey(),this.selection.handleControlShiftLeftKey(),this.owner.editorModule.onBackSpace()}},e.prototype.handleCtrlDelete=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl||this.selection.isInlineFormFillMode())if(this.selection.isEmpty)this.selection.handleControlShiftRightKey(),this.owner.editorModule.delete();else{this.selection.handleLeftKey(),this.selection.handleControlShiftRightKey();var e=this.selection.text,t=s.o_.endsWith(e);t&&this.selection.handleShiftLeftKey(),this.owner.editorModule.delete()}},e.prototype.handleTextInput=function(e){var t=this;(!this.owner.isReadOnlyMode&&this.canEditContentControl||this.selection.isInlineFormFillMode())&&(this.animationTimer&&clearTimeout(this.animationTimer),(0,a.s1)(this.selection.caret,[],["e-de-cursor-animation"]),this.owner.editorModule.insertText(e),this.animationTimer=setTimeout((function(){t.animationTimer&&clearTimeout(t.animationTimer),t.selection&&t.selection.caret&&(0,a.s1)(t.selection.caret,["e-de-cursor-animation"],[])}),600)),this.selection.checkForCursorVisibility()},e.prototype.copyInsertFormat=function(e,t){var i=new n.a,r=this.selection.characterFormat;
1return t&&i.copyFormat(e),(0,a.le)(r.bidi)||e.bidi===r.bidi||(i.bidi=r.bidi),(0,a.le)(r.bold)||e.bold===r.bold||(i.bold=r.bold),(0,a.le)(r.italic)||e.italic===r.italic||(i.italic=r.italic),r.fontSize>0&&e.fontSize!==r.fontSize&&(i.fontSize=r.fontSize),(0,a.le)(r.fontFamily)||e.fontFamily===r.fontFamily||(i.fontFamily=r.fontFamily),(0,a.le)(r.highlightColor)||e.highlightColor===r.highlightColor||(i.highlightColor=r.highlightColor),(0,a.le)(r.baselineAlignment)||e.baselineAlignment===r.baselineAlignment||(i.baselineAlignment=r.baselineAlignment),(0,a.le)(r.fontColor)||e.fontColor===r.fontColor||(i.fontColor=r.fontColor),(0,a.le)(r.underline)||e.underline===r.underline||(i.underline=r.underline),(0,a.le)(r.strikethrough)||e.strikethrough===r.strikethrough||(i.strikethrough=r.strikethrough),i},e.prototype.getResultContentControlText=function(e){var t=e.nextNode,i="";while(!(t instanceof o.h)){if(t instanceof o.a3&&(i+=t.text),(0,a.le)(t))break;if((0,a.le)(t.nextNode)){if(!t.paragraph.nextRenderedWidget)break;t=t.paragraph.nextRenderedWidget.firstChild.children[0]}else t=t.nextNode}return i},e.prototype.updateXmlMappedContentControl=function(){if(this.isXmlMapped){var e=this.getContentControl();e&&e.contentControlProperties&&this.updateCustomXml(e.contentControlProperties.xmlMapping.storeItemId,e.contentControlProperties.xmlMapping.xPath,this.getResultContentControlText(e))}},e.prototype.updateCustomXml=function(e,t,i){if(this.documentHelper.customXmlData.containsKey(e)){var r=this.documentHelper.customXmlData.get(e),o=new DOMParser,n=o.parseFromString(r,"text/xml"),s=t.substring(t.lastIndexOf("/")+1);s=s.split("[")[0],s=s.substring(s.lastIndexOf(":")+1),s=s.substring(s.lastIndexOf("@")+1);var a=n.getElementsByTagName(s);if(a.length>0)a[0].childNodes[0].nodeValue=i;else{if(!(n.documentElement.attributes.length>0&&null!==n.documentElement.attributes.getNamedItem(s)))return;n.documentElement.attributes.getNamedItem(s).value=i}var l=new XMLSerializer,d=l.serializeToString(n);this.documentHelper.customXmlData.set(e,d)}},e.prototype.insertText=function(e){(0,a.le)(e)||""===e||this.owner.isReadOnly||"ReadOnly"===this.documentHelper.protectionType&&!this.selection.isSelectionInEditRegion()||"CommentsOnly"===this.documentHelper.protectionType||this.insertTextInternal(e,!1)},e.prototype.insertTextInternal=function(e,t,i,r){if(e.indexOf("\r")>=0||e.indexOf("\n")>=0)"\r"===e||"\n"===e||"\r\n"===e?this.onEnter():(this.isInsertText=!0,this.pasteContents(e),this.isInsertText=!1);else{if("FormFieldsOnly"===this.documentHelper.protectionType&&this.selection.isInlineFormFillMode()){var n=this.selection.getCurrentFormField();if(!n.formFieldData.enabled)return;var s=this.getFieldResultText(n),l=new RegExp(this.owner.documentHelper.textHelper.getEnSpaceCharacter(),"gi");s.length>0&&""===s.replace(l,"")&&(s="",this.selection.selectFieldInternal(n));var d=n.formFieldData.maxLength;if(0!==d&&s.length>=d)return}t&&(this.documentHelper.layout.isReplaceAll=!(0,a.le)(r)&&!r);var h,c=this.documentHelper.selection,p=!0;i=this.owner.enableTrackChanges&&(0,a.le)(i)?"Insertion":i;var g=this.checkAndRemoveComments();this.isListTextSelected(),c.bookmarks.length>0&&this.extendSelectionToBookmarkStart(),((0,a.le)(i)||"Insertion"===i)&&this.initHistory("Insert");var u=this.selection.getParagraphInfo(c.start),m=u.paragraph.paragraphFormat;c.editPosition=c.getHierarchicalIndex(u.paragraph,u.offset.toString());var f=c.start.paragraph.paragraphFormat.bidi;if(!c.isEmpty&&!c.isImageSelected||this.documentHelper.isListTextSelected&&"List"===c.contextType){c.isSkipLayouting=!0,c.skipFormatRetrieval=!0;var v=void 0,y=void 0,F=0,H=0;if(this.owner.enableTrackChanges&&(this.selection.start.isExistBefore(this.selection.end)?(y=this.selection.getParagraphInfo(c.end),v=this.selection.end.clone()):(y=this.selection.getParagraphInfo(c.start),v=this.selection.start.clone()),H=y.paragraph.getLength(),F=y.offset,this.skipReplace=!0),p=this.removeSelectedContents(c),this.skipReplace=!1,!(0,a.le)(v)&&this.owner.search&&this.owner.search.isRepalceTracking)this.owner.search.isRepalceTracking=!1,this.selection.start.setPositionInternal(this.selection.start),this.selection.end.setPositionInternal(v);else if(F>0){var C=y.paragraph.getLength();H!==C&&(F-=H-C),this.setPositionParagraph(y.paragraph,F,!0)}c.skipFormatRetrieval=!1,c.isSkipLayouting=!1}else!c.isEmpty||this.documentHelper.isListTextSelected||t||(this.documentHelper.isTextInput=!0);u=this.selection.getParagraphInfo(c.start),u.paragraph.paragraphFormat.copyFormat(m);var w=this.documentHelper.textHelper.containsSpecialCharAlone(e);if(p){if(c.owner.isShiftingEnabled=!0,this.updateInsertPosition(),h=c.start,h.paragraph.isEmpty()){var I=new o.a3,b=this.copyInsertFormat(h.paragraph.characterFormat,!0);I.characterFormat.copyFormat(b),I.text=e;var W=this.documentHelper.textHelper.getRtlLanguage(e).isRtl||this.selection.characterFormat.bidi;if(I.characterFormat.bidi=W,I.isRightToLeft=W,I.line=h.paragraph.childWidgets[0],I.margin=new o.Zt(0,0,0,0),I.line.children.push(I),this.owner.enableTrackChanges)if(I.paragraph.characterFormat.revisions.length>0){var x=this.getMatchedRevisionsToCombine(I.paragraph.characterFormat.revisions,i);x.length>0&&this.mapMatchedRevisions(x,I.paragraph.characterFormat,I,!0)}else this.checkToCombineRevisionWithPrevPara(I,i)||this.insertRevision(I,i);"Center"!==h.paragraph.paragraphFormat.textAlignment&&"Right"!==h.paragraph.paragraphFormat.textAlignment||-1!==h.paragraph.paragraphFormat.listFormat.listId||(h.paragraph.x=this.owner.viewer.clientActiveArea.x),this.documentHelper.layout.reLayoutParagraph(h.paragraph,0,0)}else{var P=0,R=h.currentWidget.getInline(h.offset,P,f,!t);n=R.element;P=R.index,n.ischangeDetected=!0,n instanceof o.a3&&" "!==e&&this.documentHelper.owner.isSpellCheck&&(this.owner.spellChecker.removeErrorsFromCollection({element:n,text:n.text}),t||(n.ignoreOnceItems=[])),n.canTrigger&&n.text.length<=1&&(n.canTrigger=!1);b=this.copyInsertFormat(n.characterFormat,!0),W=this.documentHelper.textHelper.getRtlLanguage(e).isRtl||this.selection.characterFormat.bidi,this.documentHelper.textHelper.getRtlLanguage(e).id;var k=0,T=!1,S=!1;if(n instanceof o.a3&&(k=this.documentHelper.textHelper.getRtlLanguage(n.text).id,T=this.documentHelper.textHelper.getRtlLanguage(n.text).isRtl,S=this.documentHelper.textHelper.containsSpecialCharAlone(e)),(!W&&n.characterFormat.bidi&&(0!==k||S&&T)||" "===e&&this.selection.characterFormat.bidi)&&(W=!0),!W&&this.documentHelper.owner.isSpellCheck||(b.bidi=W),(!this.documentHelper.owner.isSpellCheck||" "!==e&&" "!==n.text)&&b.isSameFormat(n.characterFormat)&&this.canInsertRevision(n,i)||""===e.trim()&&!W&&n.characterFormat.bidi||T&&b.isSameFormat(n.characterFormat)&&w)this.insertTextInline(n,c,e,P);else{var L=new o.a3;L.text=e,L.line=n.line,L.isRightToLeft=T,L.characterFormat.copyFormat(b),n instanceof o.R5&&(L.characterFormat.baselineAlignment="Normal");var B=!1,E=n.indexInOwner,O=L.revisions.length;if(P===n.length){var N=-1;N=E+1,!this.owner.enableTrackChanges||n instanceof o.aQ||(B=this.checkToMapRevisionWithInlineText(n,P,L,W,i),B||L.revisions.length!==O||(B=void 0!=n.nextNode&&1==n.nextNode.revisions.length?this.checkToMapRevisionWithNextNode(n.nextNode,L,W,i):1==n.paragraph.characterFormat.revisions.length&&"Deletion"==n.paragraph.characterFormat.revisions[0].revisionType?this.checkToMapRevisionWithNextNode(n.nextNode,L,W,i,n.paragraph):this.checkToMapRevisionWithNextNode(n.nextNode,L,W,i))),B||(n.line.children.splice(N,0,L),this.checkToCombineRevisionsinBlocks(L,O===L.revisions.length,!0,i))}else if(0===P)this.owner.enableTrackChanges&&(B=this.checkToMapRevisionWithInlineText(n,P,L,W,i),B||0!==L.revisions.length||this.checkToMapRevisionWithPreviousNode(n.previousNode,L,W,i)),B||(n.line.children.splice(E,0,L),this.checkToCombineRevisionsinBlocks(L,O===L.revisions.length,!0,i));else{if(n instanceof o.a3){var M=new o.a3;M.line=n.line,M.characterFormat.copyFormat(n.characterFormat),M.text=n.text.substring(P),this.owner.enableTrackChanges||this.selection.isInField||this.updateRevisionForSpittedTextElement(n,M),n.text=n.text.slice(0,P),this.owner.enableTrackChanges?(B=this.checkToMapRevisionWithInlineText(n,P,L,W,i),B||L.revisions.length>O?this.copyElementRevision(n,M,!0):L.revisions.length===O&&(this.updateRevisionForSpittedTextElement(n,M),this.insertRevision(L,i))):this.selection.isInField&&(this.copyElementRevision(n,M,!1),this.updateElementInFieldRevision(n,L,n.revisions,!0)),this.owner.isSpellCheck&&this.owner.spellChecker.updateSplittedElementError(n,M),n.line.children.splice(E+1,0,M)}B||n.line.children.splice(E+1,0,L)}this.documentHelper.layout.reLayoutParagraph(h.paragraph,n.line.indexInOwner,0)}}this.documentHelper.layout.allowLayout=!0,this.setPositionParagraph(u.paragraph,u.offset+e.length,!0),this.updateEndPosition(),(0,a.le)(this.editorHistory)||(0,a.le)(this.editorHistory.currentHistoryInfo)||"ListSelect"!==this.editorHistory.currentHistoryInfo.action||!this.documentHelper.isListTextSelected||(this.editorHistory.updateHistory(),this.editorHistory.updateComplexHistory()),((0,a.le)(i)||"Insertion"===i)&&this.reLayout(c),this.documentHelper.isTextInput=!1}if(this.updateXmlMappedContentControl(),!t&&p&&(" "===e||"\t"===e||"\v"===e)){var A=!1;
1if("\v"!==e&&(A=this.checkAndConvertList(c,"\t"===e)),!A){if(!(0,a.le)(c.getHyperlinkField()))return;this.checkAndConvertToHyperlink(c,!1)}}this.updateHistoryForComments(g)}},e.prototype.extendSelectionToBookmarkStart=function(){if(this.documentHelper.bookmarks.length>0){var e=this.selection.start;this.selection.end;this.selection.isForward||(e=this.selection.end,this.selection.start);for(var t=void 0,i=this.selection.bookmarks,r=0;r<i.length;r++)if(t=this.documentHelper.bookmarks.get(i[r]),this.selection.isElementInSelection(t.reference,!1)&&!this.selection.isElementInSelection(t,!0)){var o=t.line.paragraph,n=this.selection.getParagraphInfo(e);if(o.equals(n.paragraph)){var s=t.line.getOffset(t,t.bookmarkType);t.line===e.currentWidget&&n.offset===s+1&&e.offset--}}}},e.prototype.updateElementInFieldRevision=function(e,t,i,r){for(var o=0;o<i.length;o++){var n=i[o],s=n.range.indexOf(e);n.range.splice(r?s+1:s,0,t)}},e.prototype.retrieveFieldResultantText=function(e){var t="";if(1===e.fieldType){var i=e.previousElement;while(!(0,a.le)(i)&&i instanceof o.a3)t=i.text+t,i=(0,a.le)(i.previousNode)?void 0:i.previousNode.previousValidNodeForTracking}return t},e.prototype.checkToCombineRevisionsinBlocks=function(e,t,i,r){if(t&&this.owner.enableTrackChanges&&!(e instanceof o.aQ||e instanceof o.Xw||e instanceof o.Cw||e instanceof o.jn)){var n=!1;n=i?this.combineRevisionWithNextPara(e,r):this.combineRevisionWithPrevPara(e,r),n||this.insertRevision(e,r)}},e.prototype.checkToMapRevisionWithNextNode=function(e,t,i,r,o){if(!(0,a.le)(o)&&1==o.characterFormat.revisions.length){var n=o.characterFormat;return!(0,a.le)(n)&&this.checkToMapRevisionWithInlineText(void 0,0,t,i,r,n)}if((0,a.le)(e))return!1;var s=e.nextValidNodeForTracking;return!(0,a.le)(s)&&this.checkToMapRevisionWithInlineText(s,0,t,i,r)},e.prototype.checkToMapRevisionWithPreviousNode=function(e,t,i,r){if((0,a.le)(e))return!1;var o=e.previousValidNodeForTracking;return!(0,a.le)(o)&&this.checkToMapRevisionWithInlineText(o,o.length,t,i,r)},e.prototype.checkToMapRevisionWithInlineText=function(e,t,i,r,o,n){if((0,a.le)(n)){if(!(0,a.le)(e))if("Deletion"===o&&this.updateLastElementRevision(i),e.length===t&&void 0!=e.previousValidNodeForTracking){if(e=e.previousValidNodeForTracking,t=e.length,e.revisions.length>0)return this.applyMatchedRevisionInorder(e,i,t,!1,r,o)}else if(0===t&&(e=e.nextValidNodeForTracking,!(0,a.le)(e)&&e.revisions.length>0))return this.applyMatchedRevisionInorder(e,i,t,!0,r,o)}else if("Deletion"===o&&this.updateLastElementRevision(i),!(0,a.le)(n)&&n.revisions.length>0)return this.applyMatchedRevisionInorder(void 0,i,t,!0,r,o,n);return!1},e.prototype.combineElementRevisions=function(e,t){if(0!==e.revisions.length&&0!==t.revisions.length)for(var i=0;i<e.revisions.length;i++)for(var r=e.revisions[i],o=0;o<t.revisions.length;o++){var n=t.revisions[i];-1===r.range.indexOf(t)&&n.revisionType===r.revisionType&&n.author===r.author&&(t.revisions.splice(o,1),r.range.push(t),t.revisions.splice(o,0,r))}},e.prototype.applyMatchedRevisionInorder=function(e,t,i,r,o,n,s){var l;return!(0,a.le)(s)&&(0,a.le)(e)?(l=this.getMatchedRevisionsToCombine(s.revisions,n),l.length>0&&this.mapMatchedRevisions(l,s,t,r),!1):(l=this.getMatchedRevisionsToCombine(e.revisions,n),l.length>0&&this.mapMatchedRevisions(l,e,t,r),!1)},e.prototype.copyElementRevision=function(e,t,i){if(!this.isTrackingFormField)for(var r=0;r<e.revisions.length;r++){var o=e.revisions[r],n=o.range.indexOf(e);t.revisions.splice(0,0,o),o.range.splice(n+(i?2:1),0,t)}},e.prototype.mapMatchedRevisions=function(e,t,i,r){for(var o=0;o<e.length;o++){var s=e[o];if(!this.isRevisionAlreadyIn(i,s)||i instanceof n.a){i.revisions.splice(0,0,s);var a=s.range.indexOf(t);s.range.splice(r?a:a+1,0,i)}}},e.prototype.isRevisionAlreadyIn=function(e,t){if(e.revisions.length>0)for(var i=0;i<e.revisions.length;i++){var r=e.revisions[i];if(r.revisionID===t.revisionID)return!0}return!1},e.prototype.getMatchedRevisionsToCombine=function(e,t){for(var i=[],r=0;r<e.length;r++)this.isRevisionMatched(e[r],t)&&i.push(e[r]);return i},e.prototype.decideInlineForTrackChanges=function(e,t){var i=!1;if(this.owner.enableTrackChanges&&!this.canInsertRevision(e,t)){var r=e.nextValidNodeForTracking;!(0,a.le)(r)&&this.canInsertRevision(r,t)&&(e=r,i=!0)}return{element:e,isMatched:i}},e.prototype.insertIMEText=function(e,t){if(this.documentHelper.lastComposedText!==e||!t){var i=this.selection.getParagraphInfo(this.selection.start),o=this.selection.getHierarchicalIndex(i.paragraph,i.offset.toString());this.insertText(e),this.documentHelper.lastComposedText=e;var n=this.selection.start;this.setPositionForCurrentIndex(n,o);var s=new r.JK(this.owner);s.setPositionForLineWidget(n.currentWidget,n.offset+e.length),this.selection.selectPosition(t?n:s,s)}},e.prototype.insertSectionBreak=function(e){(0,a.le)(e)&&(e=S.nj.NewPage);var t=this.documentHelper.selection;(0,a.le)(t)||this.owner.isReadOnlyMode||t.start.paragraph.isInHeaderFooter||(e===S.nj.Continuous?this.initHistory("SectionBreakContinuous"):this.initHistory("SectionBreak"),t.isEmpty||t.selectContent(t.isForward?t.start:t.end,!0),this.documentHelper.owner.isShiftingEnabled=!0,this.updateInsertPosition(),e===S.nj.Continuous?this.insertSection(t,!0,void 0,!0):this.insertSection(t,!0),this.updateEndPosition(),this.reLayout(t,!0),this.layoutWholeDocument(!0))},e.prototype.combineRevisionWithBlocks=function(e,t){if(this.owner.enableTrackChanges&&!(0,a.le)(e)){while(e instanceof o.aQ||e instanceof o.Xw)e=e.nextElement;if(!(0,a.le)(e)){var i=e.paragraph.previousRenderedWidget;if(!(i instanceof o.dm)){if(!(0,a.le)(i)&&!i.isEmpty()&&i.characterFormat.revisions.length>0){var r=i.lastChild;if((0,a.le)(r)||0===r.children.length)return;var n=r.children[r.children.length-1];while(n instanceof o.aQ||n instanceof o.Xw)n=n.previousElement;if(n.revisions.length>0&&this.compareElementRevision(i.characterFormat,e)){var s=e.revisions[e.revisions.length-1];if(this.compareElementRevision(n,e)){var l=n.revisions[n.revisions.length-1];!1,s!==l&&this.clearAndUpdateRevisons(s.range,l,l.range.indexOf(n)+1)}}}i=null;var d=e.paragraph.lastChild,h=d.children[d.children.length-1];e=h;var c=e.paragraph.nextRenderedWidget;if(!(c instanceof o.dm)){if(!(0,a.le)(c)&&!c.isEmpty()&&e.paragraph.characterFormat.revisions.length>0){var p=c.firstChild,g=p.children[0];while(g instanceof o.aQ||g instanceof o.Xw)g=g.previousElement;if((0,a.le)(g))return;if(g.revisions.length>0){var u=g.revisions[g.revisions.length-1];if(this.compareElementRevision(e.paragraph.characterFormat,g)&&this.compareElementRevision(e,g)){l=e.revisions[e.revisions.length-1];!1,u!==l&&this.clearAndUpdateRevisons(u.range,l,l.range.indexOf(e)+1)}}}0===e.revisions.length&&this.insertRevision(e,t)}}}}},e.prototype.checkToCombineRevisionWithNextPara=function(e,t){var i=e.paragraph.nextRenderedWidget;if(i instanceof o.dm)return!1;if(!(0,a.le)(i)&&!i.isEmpty()){var r=i.firstChild,n=r.children[0];while(n instanceof o.aQ||n instanceof o.Xw)n=n.previousElement;if((0,a.le)(n))return!1;if(n.revisions.length>0){var s=this.getMatchedRevisionsToCombine(n.revisions,t);if(s.length>0)return this.mapMatchedRevisions(s,n,e,!0),!0}}return!1},e.prototype.checkToCombineRevisionWithPrevPara=function(e,t){var i=e.paragraph.previousRenderedWidget;if(i instanceof o.dm)return!1;if(!(0,a.le)(i)&&i.characterFormat.revisions.length>0){if(!this.isRevisionMatched(i.characterFormat,t))return!1;var r=this.getMatchedRevisionsToCombine(i.characterFormat.revisions,t);if(r.length>0)return this.mapMatchedRevisions(r,i.characterFormat,e,!1),!0}return!1},e.prototype.combineRevisionWithNextPara=function(e,t){var i=e.line.isLastLine(),r=e.nextNode;return!(!i||!(0,a.le)(r))&&this.checkToCombineRevisionWithNextPara(e,t)},e.prototype.combineRevisionWithPrevPara=function(e,t){var i=e.line.isFirstLine(),r=e.previousNode;return!(!i||!(0,a.le)(r))&&this.checkToCombineRevisionWithPrevPara(e,t)},e.prototype.removeRevision=function(e){var t=this.selection.start.currentWidget.getInline(this.selection.start.offset+1,0),i=t.element;if(t.element.revisions.length>0)for(var r=0;r<i.revisions.length;r++)if(i.revisions[r].revisionType===e.revisionType)for(var o=i.revisions[r],n=o.range.indexOf(i),s=n;n<o.range.length;n++)o.range[s].revisions.splice(r,1),o.range.splice(s,1)},e.prototype.clearElementRevision=function(e){if(!(0,a.le)(e))for(var t=0;t<e.range.length;t++)if(e.range[t]instanceof o.nR){var i=e.range[t];i.revisions.splice(i.revisions.length-1,1),e.range.splice(t,1)}},e.prototype.insertRevision=function(e,t,i,r,l){i=(0,a.le)(i)?this.owner.currentUser?this.owner.currentUser:"Guest user":i;var d=(0,a.le)(r)?s.o_.getUtcDate():r;if(e instanceof o.nR&&!(0,a.le)(e.line)&&e.line.paragraph.associatedCell||e instanceof n.a&&e.ownerBase instanceof o.ZH&&e.ownerBase.associatedCell){var h=void 0;if(e instanceof o.nR?h=e.line.paragraph.associatedCell:e instanceof n.a&&(h=e.ownerBase.associatedCell),h.ownerRow.rowFormat.revisions.length>0){var c=h.ownerRow.rowFormat,p=this.getMatchedRevisionsToCombine(c.revisions,t);if(p.length>0){for(var g=0;g<p.length;g++)e.revisions.splice(0,0,p[g]),p[g].range.push(e);return}}}var u=new k.k(this.owner,i,d);u.revisionType=t,u.revisionID=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),!(0,a.le)(l)&&l.length>0&&this.clearAndUpdateRevisons(l,u,l.indexOf(e)),(0,a.le)(e)||(e.revisions.push(u),u.range.push(e)),this.updateRevisionCollection(u)},e.prototype.clearAndUpdateRevisons=function(e,t,i){for(var r=0;r<e.length;r++)if(e[r]instanceof o.nR){var n=e[r];n.revisions.splice(n.revisions.length-1,1),n.revisions.push(t),t.range.splice(i+r,0,n)}},e.prototype.splitRevisionByElement=function(e,t){if(e.revisions.length>0){var i=t.range,r=i.indexOf(e);return t.range=i.splice(0,r+1),i}},e.prototype.updateRevisionForSpittedTextElement=function(e,t){for(var i=0;i<e.revisions.length;i++){var r=e.revisions[i],o=this.splitRevisionByElement(e,r);this.insertRevision(t,r.revisionType,r.author,r.date,o)}},e.prototype.isRevisionMatched=function(e,t){var i=this.owner.currentUser?this.owner.currentUser:"Guest user";if(e instanceof k.k){if(((0,a.le)(t)||t===e.revisionType)&&e.author===i)return!0}else if(e.revisions.length>0)for(var r=0;r<e.revisions.length;r++){var o=e.revisions[r];if(((0,a.le)(t)||t===o.revisionType)&&o.author===i)return!0}return!1},e.prototype.compareElementRevision=function(e,t){if(0===e.revisions.length||0===t.revisions.length)return!1;for(var i=0;i<e.revisions.length;i++)for(var r=e.revisions[i],o=0;o<t.revisions.length;o++)if(r.author===t.revisions[i].author&&r.revisionType===t.revisions[i].revisionType)return!0;return!1},e.prototype.canInsertRevision=function(e,t){var i=(0,a.le)(t)?"Insertion":t;
1return"Deletion"!==i&&(this.owner.enableTrackChanges?this.isRevisionMatched(e,i):!(e.revisions.length>0))},e.prototype.insertRevisionAtEnd=function(e,t,i){return!(t instanceof o.aQ||t instanceof o.Xw||t instanceof o.Cw||t instanceof o.jn)&&(e=e.previousValidNodeForTracking,!(0,a.le)(e)&&this.insertRevisionAtPosition(e,t,!0,i))},e.prototype.insertRevisionAtPosition=function(e,t,i,r){var o=t.revisions.length,n=this.checkToMapRevisionWithInlineText(e,i?e.length:0,t,!1,r);return i?n||t.revisions.length!==o||(n=this.checkToMapRevisionWithNextNode(e.nextNode,t,!1,r)):n||t.revisions.length!==o||(n=this.checkToMapRevisionWithPreviousNode(e.previousNode,t,!1,r)),n},e.prototype.insertRevisionAtBegining=function(e,t,i){return!(t instanceof o.aQ||t instanceof o.Xw||t instanceof o.Cw||t instanceof o.jn)&&(e=e.nextValidNodeForTracking,!(0,a.le)(e)&&this.insertRevisionAtPosition(e,t,!1,i))},e.prototype.splitRevisionForSpittedElement=function(e,t){for(var i=e.revisions.length-1;i>=0;i--){var r=e.revisions[i],o=this.splitRevisionByElement(e,r);this.insertRevision(t,r.revisionType,r.author,r.date,o)}},e.prototype.combineElementRevision=function(e,t){for(var i=0;i<e.length;i++)for(var r=0;r<t.length;r++){var o=e[i],n=t[i];if(o.author===n.author&&o.revisionType===n.revisionType){for(var s=n.range.length,a=0;a<s;a++){var l=n.range[0];l.revisions.splice(l.revisions.indexOf(n),1),n.range.splice(0,1),o.range.push(l),l.revisions.push(o)}0===n.range.length&&this.owner.revisions.remove(n)}}},e.prototype.combineRevisions=function(e,t,i){if(this.owner.enableTrackChanges){var r=this.selection.getLineInfo(e,t.offset),o=r.line.getInline(t.offset,0),n=o.element;if(n.revisions.length>0&&this.isRevisionMatched(n,"Insertion")){var s=n.nextElement;if(!(0,a.le)(s)&&s.revisions.length>0){var l=n.revisions[n.revisions.length-1],d=s.revisions[s.revisions.length-1].range;this.clearAndUpdateRevisons(d,l,l.range.indexOf(n)+1)}}}},e.prototype.insertRevisionForBlock=function(e,t,i,r,n){if(0!==e.childWidgets.length&&this.owner.enableTrackChanges)if("Deletion"===t){var l=this.selection.editPosition,d=this.selection.start.clone(),h=this.selection.end.clone();this.documentHelper.layout.clearListElementBox(e);for(var c=0;c<e.childWidgets.length;c++){var p=e.childWidgets[c];this.removeContent(p,0,this.documentHelper.selection.getLineLength(p))}this.selection.editPosition=l,this.selection.start.setPositionInternal(d),this.selection.end.setPositionInternal(h),this.removeEmptyLine(e),n||this.documentHelper.layout.reLayoutParagraph(e,0,0)}else{var g=!1;if((0,a.le)(r)){var u=this.owner.currentUser?this.owner.currentUser:"Guest user";r=new k.k(this.owner,u,s.o_.getUtcDate()),r.revisionID=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),r.revisionType=t}for(c=0;c<e.childWidgets.length;c++){var m=e.childWidgets[c].children;if(0===m.length){var f=e.containerWidget.childWidgets.indexOf(e),v=void 0;if(f>0&&(v=e.containerWidget.childWidgets[f-1]),!(0,a.le)(v)&&v instanceof o.ZH&&v.characterFormat.revisions.length>0&&this.isRevisionMatched(v.characterFormat,t)){var y=this.getMatchedRevisionsToCombine(v.characterFormat.revisions,t);y.length>0&&(this.mapMatchedRevisions(y,v.characterFormat,e.characterFormat,!1),g=!0,r=void 0)}}for(var F=0;F<m.length;F++)if(0!==F||i)m[F].revisions.push(r),r.range.push(m[F]);else{var H=m[c].revisions.length;this.checkToCombineRevisionsinBlocks(m[c],!0,!1,"Insertion"),m[c].revisions.length>H?r=m[c].revisions[m[c].revisions.length-1]:(m[F].revisions.push(r),r.range.push(m[F]))}}i||g||(e.characterFormat.revisions.push(r),r.range.push(e.characterFormat)),(0,a.le)(r)||this.updateRevisionCollection(r)}},e.prototype.updateRevisionCollection=function(e){var t=!1,i=void 0;if(this.owner.revisions.changes.indexOf(e)<0){if(this.documentHelper.revisionsInternal.containsKey(e.revisionID)||this.documentHelper.revisionsInternal.add(e.revisionID,e),this.owner.revisions.changes.length>0)for(var s=this.owner.selection.start,l=0;l<this.owner.revisions.changes.length;l++){var h=this.owner.revisions.changes[l].range[0];if(h instanceof o.nR&&!(0,a.le)(h.line)&&h.line.paragraph.bodyWidget)i=this.selection.getElementPosition(this.owner.revisions.changes[l].range[0]).startPosition;else if(h instanceof d.J){var c=h.ownerBase,p=c.childWidgets[0],g=this.selection.getFirstParagraph(p);if(g.bodyWidget){var u=this.documentHelper.selection;this.updateEditPosition(p,u),i=this.selection.getTextPosBasedOnLogicalIndex(u.editPosition)}}else if(h instanceof n.a){var m=h.ownerBase;if(m.lastChild&&m.lastChild.paragraph.bodyWidget){var f=m.getLength(),v=new r.JK(this.owner);v.setPositionParagraph(m.lastChild,f),i=v}}if(!(0,a.le)(i)&&!(0,a.le)(s)&&s.isExistBefore(i)){t=!0,this.owner.revisions.changes.splice(l,0,e);break}}t||this.owner.revisions.changes.push(e),this.documentHelper.updateAuthorIdentity()}},e.prototype.insertSection=function(e,t,i,r){var n,s,l=this.selection.start.paragraph.bodyWidget.sectionFormat.cloneFormat();if(e.start.paragraph.isInsideTable){var d=this.documentHelper.layout.getParentTable(e.start.paragraph);d=d.combineWidget(this.owner.viewer);var h=!1;0===e.start.paragraph.associatedCell.rowIndex&&(h=!0);var c=new o.ZH,p=d.previousRenderedWidget;h?n=d:(n=this.splitTable(d,e.start.paragraph.associatedCell.ownerRow),this.documentHelper.layout.layoutBodyWidgetCollection(n.index,n.containerWidget,n,!1),n=n.getSplitWidgets().pop());var g=0;!(0,a.le)(p)&&p.bodyWidget.equals(n.bodyWidget)||!h?(g=n.indexInOwner+1,c.index=n.index+1):(g=0,c.index=0),n.containerWidget.childWidgets.splice(g,0,c),c.containerWidget=n.containerWidget,this.updateNextBlocksIndex(c,!0),this.documentHelper.layout.layoutBodyWidgetCollection(c.index,c.containerWidget,c,!1),n=c}else{var u=this.selection.getParagraphInfo(e.start),m=this.selection.getHierarchicalIndex(u.paragraph,u.offset.toString());i||this.splitParagraphInternal(e,e.start.paragraph,e.start.currentWidget,e.start.offset),this.setPositionForCurrentIndex(e.start,m),n=e.start.paragraph.getSplitWidgets().pop(),i&&void 0!==n.previousRenderedWidget&&(n=n.previousRenderedWidget)}return s=this.splitBodyWidget(n.bodyWidget,l,n,r).firstChild,i&&this.layoutWholeDocument(!0),s instanceof o.dm&&s.updateRowIndex(0),this.documentHelper.layout.layoutBodyWidgetCollection(s.index,s.containerWidget,s,!1),s instanceof o.dm&&(s=this.documentHelper.getFirstParagraphInFirstCell(s)),t&&e.selectParagraphInternal(s,!0),s},e.prototype.splitBodyWidget=function(e,t,i,r){var o=this.documentHelper.layout.moveBlocksToNextPage(i,!0,void 0,r);if(void 0===o.page)o.page=e.page,e.page.bodyWidgets.splice(e.index+1,0,o);else if(e.page.bodyWidgets.length>1&&void 0!==o.page&&!this.editorHistory.isUndoing){var n=o;while(!(0,a.le)(e.nextRenderedWidget)&&o!==e.nextRenderedWidget){var s=e.nextRenderedWidget.page.bodyWidgets.indexOf(e.nextRenderedWidget);o.page.bodyWidgets.push(e.nextRenderedWidget),e.nextRenderedWidget.page.bodyWidgets.splice(s,1)}while(!(0,a.le)(o.nextRenderedWidget))o.nextRenderedWidget.page=o.page,o=o.nextRenderedWidget;o=n,o.sectionFormat.breakCode="NewPage"}return r&&(o.sectionFormat.breakCode="NoBreak"),this.updateSectionIndex(o.sectionFormat,o,
1!0),this.editorHistory&&!this.editorHistory.isUndoing&&this.insertRemoveHeaderFooter(o.sectionIndex,!0),this.updateBlockIndex(0,o.firstChild),this.owner.viewer.updateClientArea(o,o.page),o},e.prototype.insertRemoveHeaderFooter=function(e,t){this.documentHelper.headersFooters[e]?this.documentHelper.headersFooters.splice(e,0,{}):this.documentHelper.headersFooters[e]={}},e.prototype.updateBlockIndex=function(e,t){var i,r=t.bodyWidget.sectionIndex;do{i=t.getSplitWidgets();for(var o=0;o<i.length;o++)i[o].index=e;e++,t=i.pop().nextRenderedWidget}while(!(0,a.le)(t)&&t.bodyWidget.sectionIndex===r)},e.prototype.updateSectionIndex=function(e,t,i){var r=t.sectionIndex,o=t;do{o.index===r&&e&&(o.sectionFormat=e),i?o.index++:o.index--,o=o.nextRenderedWidget}while(o)},e.prototype.checkAndConvertList=function(e,t){var i=e.paragraphFormat.getList();if(!(0,a.le)(i)||e.start.paragraph.containerWidget instanceof o.tf)return!1;var r=!1,n=!1,l=0,d=e.start.currentWidget.getInline(e.start.offset-1,l),h=d.element;if(l=d.index,!(h instanceof o.a3))return!1;var c=h,p=c.text.substring(0,l),g=0,u=0;while(!(0,a.le)(c.previousNode)){if(!(c.previousNode instanceof o.a3)||"\t"!==c.previousNode.text&&0!==c.previousNode.text.trim().length)return!1;"\t"===c.previousNode.text?g+=36:u=2.5*c.previousNode.text.length,c=c.previousNode}c=h;var m=0,f=p.lastIndexOf("\t");m=f>=0?f+1:p.lastIndexOf(" ")+1;while(c.previousNode instanceof o.a3&&0===m){c=c.previousNode;var v=c.text;f=v.lastIndexOf("\t"),m=f>=0?f+1:v.lastIndexOf(" ")+1,p=c.text+p,p=p.substring(m)}p=s.o_.trimStart(p);var F=p.substring(1,2),H=void 0,C=this.getListLevelPattern(p.substring(0,1));if("None"!==C&&this.checkNumberFormat(F,"Bullet"===C,p)?r=!0:this.checkLeadingZero(p)?(n=!0,r=!0):(H=this.checkNextLevelAutoList(p),(0,a.le)(H)||(r=!0)),r){this.initComplexHistory("AutoList");var w=h.paragraph;e.start.setPositionParagraph(w.childWidgets[0],w.childWidgets[0].getOffset(h,l+1)),e.end.setPositionParagraph(w.childWidgets[0],0),this.initHistory("Delete"),this.deleteSelectedContents(e,!1),this.reLayout(e,!1);var I=t?"Tab":"Space";F=n?"%1"+p.substring(p.length-1,p.length):"%1"+F;var b=p.substring(p.length-3,p.length-1);C=n?this.getListLevelPattern(b):C;var W=new y.q(void 0);W.listLevelPattern=C,"Bullet"===C?"*"===p?(W.numberFormat=String.fromCharCode(61623),W.characterFormat.fontFamily="Symbol"):"-"===p&&(W.numberFormat="-"):W.numberFormat=F,W.followCharacter=I;var x=e.paragraphFormat.leftIndent;W.paragraphFormat.leftIndent=0!==g||0!==u?x+18+g+u:l>2?x+2.5*(l-2)+18:x>0?x+18:36,W.paragraphFormat.firstLineIndent=-18,!n&&"0"===p.substring(0,1)||"00"===b?W.startAt=0:W.startAt=1,(0,a.le)(H)?this.autoConvertList(e,W):e.paragraphFormat.setList(H),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)?this.editorHistory.updateComplexHistory():this.reLayout(e)}return r},e.prototype.checkNextLevelAutoList=function(e){var t=this.documentHelper.selection,i=void 0,r=!1,n=t.start.paragraph,s=t.getPreviousParagraphBlock(n),l=!1;while(!(0,a.le)(s)&&s instanceof o.ZH){if(s.paragraphFormat.listFormat&&-1!==s.paragraphFormat.listFormat.listId){l=!0;break}s=t.getPreviousParagraphBlock(s)}if(l){var d=this.documentHelper.layout.getListNumber(s.paragraphFormat.listFormat,!0),h=d.substring(0,d.length-1),c=e.substring(0,e.length-1),p=void 0;if(d.substring(d.length-1)!==e.substring(e.length-1))r=!1;else if(c.match(/^[0-9]+$/)&&h.match(/^[0-9]+$/))p=parseInt(c,10),parseInt(h,10)!==p&&parseInt(h,10)+1!==p&&parseInt(h,10)+2!==p||(r=!0);else if(c.match(/^[a-zA-Z]+$/)&&h.match(/^[a-zA-Z]+$/))if(h.charCodeAt(0)===e.charCodeAt(0)||h.charCodeAt(0)+1===e.charCodeAt(0)||h.charCodeAt(0)+2===e.charCodeAt(0))r=!0;else if(c.match(/^[MDCLXVImdclxvi]+$/)&&h.match(/^[MDCLXVImdclxvi]+$/)){var g=this.getNumber(h.toUpperCase()),u=this.getNumber(c.toUpperCase());g!==u&&g+1!==u&&g+2!==u||(r=!0)}r&&(i=this.documentHelper.getListById(s.paragraphFormat.listFormat.listId))}return i},e.prototype.getNumber=function(e){for(var t={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1},i=e.split(""),r=0,o=0;o<i.length;o++){var n=t[i[o]],s=t[i[o+1]];n<s?r-=n:r+=n}return r},e.prototype.getListLevelPattern=function(e){switch(e){case"0":case"1":return"Arabic";case"I":return"UpRoman";case"i":return"LowRoman";case"A":return"UpLetter";case"a":return"LowLetter";case"*":case"-":return"Bullet";case"00":case"01":return"LeadingZero";default:return"None"}},e.prototype.autoConvertList=function(e,t){e.start;e.isForward||e.end;var i=new f.f;this.documentHelper.lists.length>0?i.listId=this.documentHelper.lists[this.documentHelper.lists.length-1].listId+1:i.listId=0;var r=new v.S,o=this.documentHelper;o.abstractLists.length>0?r.abstractListId=o.abstractLists[o.abstractLists.length-1].abstractListId+1:r.abstractListId=0,i.abstractListId=r.abstractListId,i.abstractList=r,o.abstractLists.push(r),r.levels.push(t),t.ownerBase=r,e.paragraphFormat.setList(i),e.paragraphFormat.listLevelNumber=0},e.prototype.checkNumberFormat=function(e,t,i){if(t)return""===e;var r=i.indexOf(e);return("."===e||")"===e||">"===e||"-"===e)&&""===i.substring(r,i.length-1)},e.prototype.checkLeadingZero=function(e){for(var t,i=!1,r=0;r<=e.length-1;r++){if("0"!==e.charAt(r)){t=r;break}i=!0}
1var o=void 0;return o="1"===e.charAt(t)?e.charAt(t+1):e.charAt(t),i&&this.checkNumberFormat(o,!1,e)},e.prototype.getPageFromBlockWidget=function(e){var t=void 0;return e.containerWidget instanceof o.VB||e.containerWidget instanceof o.NB?t=e.containerWidget.page:e.containerWidget instanceof o.nb&&(t=e.containerWidget.bodyWidget.page),t},e.prototype.insertTextInline=function(e,t,i,r,n){if(e instanceof o.a3){e.text=s.o_.insert(e.text,r,i);var l=e.line.paragraph,d=l.childWidgets.indexOf(e.line),h=e.line.children.indexOf(e);!(0,a.le)(n)&&n||this.documentHelper.layout.reLayoutParagraph(l,d,h,e.line.paragraph.bidi)}else e instanceof o.XY?this.insertImageText(e,t,i,r):e instanceof o.V8?0===e.fieldType?this.insertFieldBeginText(e,t,i,r):2===e.fieldType?this.insertFieldSeparatorText(e,t,i,r):this.insertFieldEndText(e,t,i,r):(e instanceof o.aQ||e instanceof o.Cw||e instanceof o.jn)&&this.insertBookMarkText(e,i)},e.prototype.insertFieldBeginText=function(e,t,i,r){var n=new o.a3;n.text=i;var s=e.line.paragraph.childWidgets.indexOf(e.line),a=e.line.children.indexOf(e);n.characterFormat.copyFormat(e.characterFormat),e.line.children.splice(a,0,n),n.line=e.line,this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,s,a)},e.prototype.insertBookMarkText=function(e,t){var i=new o.a3;i.text=t;var r=e.line.paragraph.childWidgets.indexOf(e.line),n=e.line.children.indexOf(e);i.characterFormat.copyFormat(e.characterFormat),e instanceof o.jn||e instanceof o.aQ?e.line.children.splice(n,0,i):e.line.children.splice(n+1,0,i),i.line=e.line,this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,r,n)},e.prototype.insertFieldSeparatorText=function(e,t,i,r){var n=t.getPreviousTextInline(e),s=t.getNextTextInline(e),l=new o.a3;l.text=i;var d=e.line.children.indexOf(e);r===e.length&&d++,(0,a.le)(n)&&(0,a.le)(s)?l.characterFormat.copyFormat(e.line.paragraph.characterFormat):(0,a.le)(n)?l.characterFormat.copyFormat(s.characterFormat):l.characterFormat.copyFormat(n.characterFormat),e.line.children.splice(d,0,l),l.line=e.line;var h=e.line.paragraph.childWidgets.indexOf(e.line);this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,h,d)},e.prototype.insertFieldEndText=function(e,t,i,r){var n=new o.a3;n.text=i;var s=e.line.children.indexOf(e);n.characterFormat.copyFormat(e.characterFormat),t.isInlineFormFillMode()&&0==r?e.line.children.splice(s,0,n):e.line.children.splice(s+1,0,n),n.line=e.line;var a=e.line.paragraph.childWidgets.indexOf(e.line);if(this.owner.enableTrackChanges){var l=this.documentHelper.textHelper.getRtlLanguage(i).isRtl,d="Insertion",h=this.checkToMapRevisionWithInlineText(e,r,n,l,d);h||0!==n.revisions.length||(h=this.checkToMapRevisionWithNextNode(e.nextNode,n,l,d))}this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,a,s)},e.prototype.insertImageText=function(e,t,i,r){var n=t.getPreviousTextInline(e),s=t.getNextTextInline(e),l=e.line,d=new o.a3,h=l.paragraph,c=h.childWidgets.indexOf(l);d.text=i;var p=l.children.indexOf(e);r===e.length&&p++,(0,a.le)(n)&&(0,a.le)(s)?d.characterFormat.copyFormat(h.characterFormat):(0,a.le)(n)?d.characterFormat.copyFormat(s.characterFormat):d.characterFormat.copyFormat(n.characterFormat),l.children.splice(p,0,d),d.line=l,this.documentHelper.layout.reLayoutParagraph(h,c,p)},e.prototype.isListTextSelected=function(){this.documentHelper.isListTextSelected&&(this.initComplexHistory("ListSelect"),this.documentHelper.selection.start.paragraph.paragraphFormat.listFormat&&-1!==this.documentHelper.selection.start.paragraph.paragraphFormat.listFormat.listId&&this.onApplyList(void 0))},e.prototype.checkAndConvertToHyperlink=function(e,t,i){var n,s;if(t)s=i.lastChild.children[i.lastChild.children.length-1],n=s.text;else{var a=0,l=e.start.currentWidget.getInline(e.start.offset-1,a),d=l.element;if(a=l.index,!(d instanceof o.a3))return;s=d,n=s.text.substring(0,a)}var h=0,c=n.lastIndexOf("\t");h=c>=0?c+1:n.lastIndexOf(" ")+1;while(s.previousElement instanceof o.a3&&0===h){s=s.previousNode;var p=s.text;c=p.lastIndexOf("\t"),h=c>=0?c+1:p.lastIndexOf(" ")+1,n=s.text+n}n=n.substring(h);var g=n.toLowerCase(),u=!1;if("file:///"===g.substring(0,8)||"http://"===g.substring(0,7)&&g.length>7||"https://"===g.substring(0,8)&&g.length>8||"www."===g.substring(0,4)&&g.length>4||"\\"===g.substring(0,3)&&g.length>3||"mailto:"===g.substring(0,7)&&g.length>7)u=!0,"www."===g.substring(0,4)&&g.length>4&&(n="http://"+n);else{var m=n.indexOf("@"),f=n.indexOf(".");m>0&&m<f&&f<n.length-1&&(u=!0,n="mailto:"+n)}if(u){var v=new r.JK(this.documentHelper.owner);v.setPositionParagraph(s.line,s.line.getOffset(s,h));var y=new r.JK(this.documentHelper.owner);if(t)y.setPositionParagraph(s.line,s.line.getEndOffset());else if(0===e.end.currentWidget.children.length&&0===e.end.offset){var F=e.end.currentWidget.previousLine;y.setPositionParagraph(F,F.getEndOffset())}else y.setPositionParagraph(e.end.currentWidget,e.end.offset-1);this.autoFormatHyperlink(e,n,v,y)}},e.prototype.autoFormatHyperlink=function(e,t,i,r){this.initComplexHistory("AutoFormatHyperlink");var o=this.selection.getParagraphInfo(i),s=this.selection.getHierarchicalIndex(o.paragraph,o.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.insertPosition=s),e.start.setPositionInternal(i),e.end.setPositionInternal(r);var a=this.getCharacterFormat(e),l=new n.a;l.copyFormat(a);var d=this.createHyperlinkElement(t,i,r,l);e.start.setPositionParagraph(d.line,d.line.getOffset(d,1)),e.start.moveNextPosition(),e.end.setPositionInternal(e.start),o=this.selection.getParagraphInfo(e.end);var h=this.selection.getHierarchicalIndex(o.paragraph,o.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo?(this.editorHistory.currentHistoryInfo.endPosition=h,this.editorHistory.updateComplexHistory(),this.reLayout(e)):this.updateComplexWithoutHistory(0,s,h)},e.prototype.appylingHyperlinkFormat=function(e){this.initHistory("Underline"),this.updateCharacterFormatWithUp
1date(e,"underline","Single",!1),this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1),this.initHistory("FontColor"),this.isForHyperlinkFormat=!0,this.updateCharacterFormatWithUpdate(e,"fontColor","#0563c1",!1),this.isForHyperlinkFormat=!1,this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1)},e.prototype.createHyperlinkElement=function(e,t,i,r){var n=this.selection;this.documentHelper.layout.allowLayout=!1,this.appylingHyperlinkFormat(n);var s=new o.V8(1);s.characterFormat.copyFormat(r),s.line=n.end.currentWidget,n.start.setPositionInternal(n.end),this.initInsertInline(s),n.start.setPositionInternal(t),n.end.setPositionInternal(n.start);var a=this.insertHyperlinkfield(n,r,e),l=n.start.paragraph.childWidgets.indexOf(a.line),d=a.line.children.indexOf(a);return s.linkFieldCharacter(this.documentHelper),this.documentHelper.layout.allowLayout=!0,this.documentHelper.layout.reLayoutParagraph(n.start.paragraph,l,d),s},e.prototype.insertHyperlinkfield=function(e,t,i,r){var n=new o.V8(0);n.characterFormat.copyFormat(t),n.line=e.start.currentWidget,this.initInsertInline(n);var s=new o.a3;s.characterFormat.copyFormat(t),s.text=r?' HYPERLINK \\l "'+i+'" ':' HYPERLINK "'+i+'" ',s.line=e.start.currentWidget,this.initInsertInline(s);var a=new o.V8(2);return a.characterFormat.copyFormat(t),a.line=e.start.currentWidget,this.initInsertInline(a),n},e.prototype.unlinkRangeFromRevision=function(e,t){for(var i=0;i<e.revisions.length;i++){var r=e.revisions[i],o=r.range.indexOf(e);o>=0&&r.range.splice(o,1),0===r.range.length&&t&&(this.owner.revisions.remove(r),this.isRemoveRevision&&this.documentHelper.revisionsInternal.containsKey(r.revisionID)&&(this.documentHelper.revisionsInternal.remove(r.revisionID),this.owner.trackChangesPane.updateTrackChanges()))}},e.prototype.unlinkWholeRangeInRevision=function(e,t){var i=t;e.revisions.splice(e.revisions.indexOf(e),1);for(var r=i.range.length,o=0;o<r;o++)i.range.splice(0,1);0===i.range.length&&(this.owner.revisions.remove(i),this.isRemoveRevision&&this.documentHelper.revisionsInternal.containsKey(i.revisionID)&&(this.documentHelper.revisionsInternal.remove(i.revisionID),this.owner.trackChangesPane.updateTrackChanges()))},e.prototype.unLinkFieldCharacter=function(e){if(e instanceof o.V8&&0===e.fieldType&&e.fieldEnd&&(this.documentHelper&&(this.documentHelper.fieldToLayout=e,this.documentHelper.fieldEndParagraph=e.line.paragraph),e.fieldEnd&&(e.fieldEnd.fieldBegin=void 0),e.fieldEnd=void 0),e instanceof o.V8&&2===e.fieldType)(0,a.le)(e.fieldEnd)||(this.documentHelper&&(this.documentHelper.fieldToLayout=e.fieldBegin,this.documentHelper.fieldEndParagraph=e.line.paragraph),e.fieldBegin.fieldSeparator=void 0,e.fieldEnd.fieldSeparator=void 0);else if(e instanceof o.V8&&1===e.fieldType&&e.fieldBegin){(0,a.le)(this.documentHelper)||(this.documentHelper.fieldToLayout=e.fieldBegin,this.documentHelper.fieldEndParagraph=e.line.paragraph);var t=this.documentHelper.fields.indexOf(e.fieldBegin);-1!==t&&this.documentHelper.fields.splice(t,1);var i=this.documentHelper.formFields.indexOf(e.fieldBegin);-1!==i&&this.documentHelper.formFields.splice(i,1),e.fieldBegin.fieldEnd=void 0,e.fieldBegin=void 0}},e.prototype.getCharacterFormat=function(e){if(e.start.paragraph.isEmpty())return e.start.paragraph.characterFormat;var t=e.start.currentWidget.getInline(e.start.offset,0);return t.element.characterFormat},e.prototype.insertHyperlink=function(e,t,i){e=e.replace(/\s/g,""),(0,a.le)(t)&&(t=e),(0,a.le)(i)||(e=e+'" \\o "'+i),this.insertHyperlinkInternal(e,t,this.owner.selection.text!==t,!1)},e.prototype.insertHyperlinkInternal=function(e,t,i,s){var a=this.documentHelper.selection;if(a.start.paragraph.associatedCell===a.end.paragraph.associatedCell)if(i)this.insertHyperlinkInternalInternal(a,e,t,s);else{this.documentHelper.layout.allowLayout=!1;var l=a.start,d=a.end;a.isForward||(l=a.end,d=a.start);var h=new r.JK(this.documentHelper.owner);h.setPositionInternal(l);var c=this.getCharacterFormat(a),p=new n.a(void 0);p.copyFormat(c),this.initComplexHistory("InsertHyperlink");var g=this.selection.getParagraphInfo(l),u=this.selection.getHierarchicalIndex(g.paragraph,g.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.insertPosition=this.selection.getHierarchicalIndex(g.paragraph,g.offset.toString())),this.appylingHyperlinkFormat(a),l.setPositionInternal(d);var m=new o.V8(1);m.characterFormat.copyFormat(p),m.line=a.end.currentWidget,l.setPositionInternal(d),this.initInsertInline(m),l.setPositionInternal(h),d.setPositionInternal(l);var f=this.insertHyperlinkfield(a,p,e,s);m.linkFieldCharacter(this.documentHelper);var v=a.start.paragraph.childWidgets.indexOf(f.line),y=f.line.children.indexOf(f);this.documentHelper.layout.allowLayout=!0,this.documentHelper.layout.reLayoutParagraph(a.start.paragraph,v,y);var F=m.line;a.selects(F,F.getOffset(m,m.length),!0),g=this.selection.getParagraphInfo(d);var H=this.selection.getHierarchicalIndex(g.paragraph,g.offset.toString());this.editorHistory&&this.editorHistory.currentHistoryInfo?(this.editorHistory.currentHistoryInfo.endPosition=this.selection.getHierarchicalIndex(g.paragraph,g.offset.toString()),this.editorHistory.updateComplexHistory()):this.updateComplexWithoutHistory(1,u,H)}},e.prototype.insertHyperlinkInternalInternal=function(e,t,i,r){if(!(0,a.le)(e.start)&&!this.editHyperlink(e,t,i)){var o=this.checkAndRemoveComments();this.initHistory("InsertHyperlink");var s=!0;if(!e.isEmpty){var l=this.owner.enableTrackChanges;this.owner.enableTrackChanges=!1,s=this.removeSelectedContents(e),this.owner.enableTrackChanges=l}if(s){var d=this.getCharacterFormat(e),h=new n.a;h.copyFormat(d),this.insertHyperlinkByFormat(e,t,i,h,r)}this.updateHistoryForComments(o)}},e.prototype.insertHyperlinkByFormat=function(e,t,i,r,n){this.updateInsertPosition(),e.owner.isShiftingEnabled=!0;var s=[],l=new o.V8(0);s.push(l);var d=new o.a3;d.text=n?' HYPERLINK \\l "'+t+'" ':' HYPERLINK "'+t+'" ',s.push(d);var h=new o.V8(2);s.push(h),(0,a.le)(i)||""===i||(d=new o.a3,d.characterFormat.underline="Single",d.characterFormat.fontColor="#0563c1",d.text=i,s.push(d));var c=new o.V8(1);s.push(c),this.insertElement(s),c.linkFieldCharacter(this.documentHelper),-1===this.documentHelper.fields.indexOf(l)&&this.documentHelper.fields.push(l),e.selects(c.line,c.line.getOffset(c,c.length),!0),this.updateEndPosition(),this.reLayout(e,!0)},e.prototype.initInsertInline=function(e,t,i){var r=this.selection,n=!1;!this.isInsertingTOC&&i&&e instanceof o.aQ&&(r.start.offset--,r.end.offset--,n=!0),this.initHistory("InsertInline"),this.insertInlineInSelection(r,e),this.editorHistory&&this.editorHistory.updateHistory(),n&&(r.start.offset++,r.end.offset++)},e.prototype.insertElementInCurrentLine=function(e,t){this.checkIsNotRedoing()&&(e.owner.isShiftingEnabled=!0),e.isEmpty||this.removeSelectedContents(e),this.updateInsertPosition(),this.insertElement([t]),this.checkEndPosition(e)&&this.updateHistoryPosition(e.start,!1),this.fireContentChange()},e.prototype.editHyperlink=function(e,t,i,r){var s=e.getHyperlinkField();if((0,a.le)(s))return!1;this.initHistory("InsertHyperlink"),this.editHyperlinkInternal=(0,a.le)(this.editorHistory)||this.editorHistory&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo);var l="",d=!1,h=this.getCharacterFormat(e),c=new n.a;c.copyFormat(h);var p=void 0;if(!(0,a.le)(s.fieldSeparator)){p=s.fieldSeparator;var g=e.getHyperlinkDisplayText(s.fieldSeparator.line.paragraph,s.fieldSeparator,s.fieldEnd,d,c);l=g.displayText,d=g.isNestedField,c=g.format}var u=s.line.getOffset(s,0);if(e.start.setPositionParagraph(s.line,u),u=s.fieldEnd.line.getOffset(s.fieldEnd,1),e.end.setPositionParagraph(s.fieldEnd.line,u),this.skipFieldDeleteTracking=!0,this.deleteSelectedContents(e,!1),!d&&l!==i||(0,a.le)(p))this.insertHyperlinkByFormat(e,t,i,c,r),this.skipFieldDeleteTracking=!1;else{this.updateInsertPosition();var m=new o.V8(0);m.characterFormat.copyFormat(s.characterFormat),m.line=e.start.currentWidget,this.insertInlineInternal(m);var f=new o.a3;f.characterFormat.copyFormat(s.characterFormat),f.text=r?' HYPERLINK \\l "'+t+'" ':' HYPERLINK "'+t+'" ',f.line=e.start.currentWidget,this.insertInlineInternal(f);var v=this.editorHistory&&this.editorHistory.currentBaseHistoryInfo?this.editorHistory.currentBaseHistoryInfo.removedNodes:this.nodes;this.insertClonedFieldResult(e,v,p);var y=e.end.currentWidget.getInline(e.end.offset,0).element;y.linkFieldCharacter(this.documentHelper),this.skipFieldDeleteTracking=!1;var F=m.line.paragraph,H=m.line.paragraph.childWidgets.indexOf(m.line),C=m.line.children.indexOf(m);this.documentHelper.layout.reLayoutParagraph(F,H,C),u=m.fieldEnd.line.getOffset(m.fieldEnd,1),e.selects(m.fieldEnd.line,u,!0),this.updateEndPosition(),this.reLayout(e,!0)}return this.editHyperlinkInternal=!1,this.nodes=[],!0},e.prototype.insertClonedFieldResult=function(e,t,i){for(var r=!1,n=t.length-1;n>-1;n--){var s=t[n];if(!r){if(i!==s){if(s instanceof o.ZH&&s===i.line.paragraph){r=!0;var a=void 0;if(n===t.length-1){a=e.start.paragraph;var l=i.line.paragraph;this.getClonedFieldResultWithSel(l,e,i)}else a=this.getClonedFieldResult(i.line.paragraph,i),this.insertParagraph(a,!0);e.selectParagraphInternal(e.getNextParagraphBlock(a),!0)}continue}r=!0}s instanceof o.nR?this.insertInlineInternal(s.clone()):s instanceof o.qc&&this.insertBlock(s.clone())}},e.prototype.getClonedFieldResultWithSel=function(e,t,i){for(var r=e.childWidgets.indexOf(i.line),o=e.childWidgets[r].children.indexOf(i),n=r;n<e.childWidgets.length;n++){var s=e.childWidgets[n];n!==r&&(o=0);for(var a=o;a<s.children.length;a++)this.insertInlineInternal(s.children[a].clone())}},e.prototype.getClonedFieldResult=function(e,t){var i=new o.ZH;i.characterFormat.copyFormat(e.characterFormat),i.paragraphFormat.copyFormat(e.paragraphFormat);for(var r=e.childWidgets.indexOf(t.line),n=e.childWidgets[r].children.indexOf(t),s=r;s<e.childWidgets.length;s++){var a=e.childWidgets[s];s!==r&&(n=0);for(var l=n;l<a.children.length;l++)i.childWidgets[0].children.push(a.children[l])}return i},e.prototype.removeHyperlink=function(){if(!this.owner.isReadOnlyMode){var e=this.selection,t=e.getHyperlinkField();if(!(0,a.le)(t)){var i=t.fieldEnd,o=t.fieldSeparator,n=new r.JK(e.owner);n.setPositionParagraph(t.line,t.line.getOffset(t,0));var s=this.selection.getParagraphInfo(n),l=this.selection.getHierarchicalIndex(s.paragraph,s.offset.toString()),d=new r.JK(e.owner);d.setPositionParagraph(o.line,o.line.getOffset(o,o.length)),s=this.selection.getParagraphInfo(d);var h=this.selection.getHierarchicalIndex(s.paragraph,s.offset.toString());this.initComplexHistory("RemoveHyperlink"),e.start.setPositionParagraph(i.line,i.line.getOffset(i,0)),s=this.selection.getParagraphInfo(e.start);var c=this.selection.getHierarchicalIndex(s.paragraph,s.offset.toString());e.end.setPositionInternal(e.start),this.delete(),e.start.setPositionInternal(this.selection.getTextPosBasedOnLogicalIndex(h)),this.initHistory("Underline"),this.updateCharacterFormatWithUp
1date(e,"underline","None",!1),this.editorHistory&&this.editorHistory.updateHistory(),e.end.setPositionInternal(this.selection.getTextPosBasedOnLogicalIndex(c)),this.initHistory("FontColor"),this.updateCharacterFormatWithUpdate(e,"fontColor",void 0,!1),this.editorHistory&&this.editorHistory.updateHistory(),this.reLayout(e,!1),e.end.setPositionInternal(e.start),e.start.setPositionInternal(this.selection.getTextPosBasedOnLogicalIndex(l)),this.initHistory("Delete"),this.deleteSelectedContents(e,!1),this.reLayout(e,!0),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&this.editorHistory.updateComplexHistory()}}},e.prototype.pasteInternal=function(e,t){if(this.currentPasteOptions=this.owner.defaultPasteOption,this.isHtmlPaste=!1,this.documentHelper.owner.enableLocalPaste)this.paste();else{this.selection.isViewPasteOptions=!0,this.selection.pasteElement&&(this.selection.pasteElement.style.display="none"),(0,a.le)(t)&&(t=window);var i="",r="",o="",s=t.clipboardData?t.clipboardData:e.clipboardData;if("msie"!==a.AR.info.name&&(o=s.getData("Text/Rtf"),r=s.getData("Text/Html")),this.copiedTextContent=i=s.getData("Text"),this.previousCharFormat=new n.a,this.previousCharFormat.copyFormat(this.selection.start.paragraph.characterFormat),this.previousParaFormat=new h.h,this.previousParaFormat.copyFormat(this.selection.start.paragraph.paragraphFormat),"FormFieldsOnly"===this.documentHelper.protectionType&&this.documentHelper.selection.isInlineFormFillMode()&&(r="",o=""),""!==o)this.pasteAjax(o,".rtf");else if(""!==r){this.isHtmlPaste=!0;var l=(new DOMParser).parseFromString(r,"text/html"),d=(new XMLSerializer).serializeToString(l);d=d.replace(/<!--StartFragment-->/gi,""),d=d.replace(/<!--EndFragment-->/gi,""),d=d.replace('xmlns="http://www.w3.org/1999/xhtml"',""),this.pasteAjax(d,".html")}else if(null!==i&&""!==i)this.selection.currentPasteAction="TextOnly",this.pasteContents(i),this.applyPasteOptions(this.currentPasteOptions,!0),this.copiedContent=void 0,this.documentHelper.editableDiv.innerHTML="";else if("msie"!==a.AR.info.name&&void 0!==s.items&&0!==s.items.length)for(var c=0;c<s.items.length;c++){var p=s.items[c];("image/png"===p.type||"image/svg+xml"===p.type&&"string"!==p.kind)&&this.pasteImage(p.getAsFile())}else"msie"===a.AR.info.name&&void 0!==s.files&&0!==s.files.length&&"image/png"===s.files[0].type&&this.pasteImage(s.files[0])}},e.prototype.pasteImage=function(e){var t=this,i=new FileReader;i.onload=function(){t.onPasteImage(i.result)},i.readAsDataURL(e)},e.prototype.onPasteImage=function(e){var t=document.createElement("img"),i=this;t.addEventListener("load",(function(){i.insertImage(e,this.width,this.height)})),t.src=e},e.prototype.pasteAjax=function(e,t){var i=this,r={content:e,type:t};this.pasteRequestHandler=new T.q,this.owner.documentHelper.viewerContainer.focus(),(0,P.yh)(this.owner.element),this.pasteRequestHandler.url=i.owner.serviceUrl+this.owner.serverActionSettings.systemClipboard,this.pasteRequestHandler.responseType="json",this.pasteRequestHandler.contentType="application/json;charset=UTF-8",this.pasteRequestHandler.customHeaders=i.owner.headers,this.pasteRequestHandler.onSuccess=this.pasteFormattedContent.bind(this),this.pasteRequestHandler.onFailure=this.onPasteFailure.bind(this),this.pasteRequestHandler.onError=this.onPasteFailure.bind(this);var o={serverActionType:"SystemClipboard",headers:this.owner.headers,timeout:0,cancel:!1,withCredentials:!1,clipboardData:r};this.owner.trigger(H.z1,o),o.cancel?(0,P.v3)(this.owner.element):this.pasteRequestHandler.send(r,o)},e.prototype.pasteFormattedContent=function(e){var t=this;this.isPasteListUpdated&&(this.isPasteListUpdated=!1),this.pasteContents((0,a.le)(e.data)?this.copiedTextContent:e.data),"KeepSourceFormatting"!==this.currentPasteOptions&&this.applyPasteOptions(this.currentPasteOptions),(0,P.v3)(this.owner.element),setTimeout((function(){(0,a.le)(t.viewer)||t.viewer.updateScrollBars()}),0)},e.prototype.onPasteFailure=function(e){this.owner.fireServiceFailure(e),console.error(e.status,e.statusText),(0,P.v3)(this.owner.element),this.documentHelper.updateFocus()},e.prototype.paste=function(e,t){var i=this;if((0,a.le)(e)&&(e=this.owner.enableLocalPaste?this.copiedData:void 0),(0,a.le)(t)||(this.currentPasteOptions=t),e){var r=JSON.parse(e);this.pasteContents(r),this.applyPasteOptions(this.currentPasteOptions),this.chartType&&(setTimeout((function(){(0,a.le)(i.viewer)||i.viewer.updateScrollBars()}
1),30),this.chartType=!1)}},e.prototype.getUniqueListOrAbstractListId=function(e){if(e&&this.documentHelper.lists.length){var t=this.documentHelper.lists.slice().sort((function(e,t){return e.listId-t.listId}));return t[t.length-1].listId+1}if(this.documentHelper.abstractLists.length){var i=this.documentHelper.abstractLists.slice().sort((function(e,t){return e.abstractListId-t.abstractListId}));return i[i.length-1].abstractListId+1}return 0},e.prototype.checkSameLevelFormat=function(e,t,i){return t.levels[e].listLevelPattern===i.abstractList.levels[e].listLevelPattern&&t.levels[e].numberFormat===i.abstractList.levels[e].numberFormat&&("Bullet"===t.levels[e].listLevelPattern||t.levels[e].startAt===i.abstractList.levels[e].startAt)},e.prototype.listLevelPatternInCollection=function(e,t){var i=this;return this.documentHelper.lists.filter((function(r){return r.abstractList.levels[e].listLevelPattern===t.listLevelPattern&&r.abstractList.levels[e].numberFormat===t.numberFormat&&("Bullet"===t.listLevelPattern||r.abstractList.levels[e].startAt===t.startAt)&&i.isEqualParagraphFormat(r.abstractList.levels[e].paragraphFormat,t.paragraphFormat)}))[0]},e.prototype.isEqualParagraphFormat=function(e,t){return!((0,a.le)(t.leftIndent)&&0!==e.leftIndent||!(0,a.le)(t.leftIndent)&&Math.round(e.leftIndent)!==Math.round(t.leftIndent))&&(!((0,a.le)(t.rightIndent)&&0!==e.rightIndent||!(0,a.le)(t.rightIndent)&&Math.round(e.rightIndent)!==Math.round(t.rightIndent))&&(!((0,a.le)(t.firstLineIndent)&&0!==e.firstLineIndent||!(0,a.le)(t.firstLineIndent)&&Math.round(e.firstLineIndent)!==Math.round(t.firstLineIndent))&&(!((0,a.le)(t.beforeSpacing)&&0!==e.beforeSpacing||!(0,a.le)(t.beforeSpacing)&&Math.round(e.beforeSpacing)!==Math.round(t.beforeSpacing))&&(!((0,a.le)(t.afterSpacing)&&0!==e.afterSpacing||!(0,a.le)(t.afterSpacing)&&Math.round(e.afterSpacing)!==Math.round(t.afterSpacing))&&(!((0,a.le)(t.textAlignment)&&"Left"!==e.textAlignment||!(0,a.le)(t.textAlignment)&&e.textAlignment!==t.textAlignment)&&(!((0,a.le)(t.bidi)&&!1!==e.bidi||!(0,a.le)(t.bidi)&&e.bidi!==t.bidi)&&(!((0,a.le)(t.contextualSpacing)&&!1!==e.contextualSpacing||!(0,a.le)(t.contextualSpacing)&&e.contextualSpacing!==t.contextualSpacing)&&(!((0,a.le)(t.keepWithNext)&&!1!==e.keepWithNext||!(0,a.le)(t.keepWithNext)&&e.keepWithNext!==t.keepWithNext)&&(!((0,a.le)(t.keepLinesTogether)&&!1!==e.keepLinesTogether||!(0,a.le)(t.keepLinesTogether)&&e.keepLinesTogether!==t.keepLinesTogether)&&(!((0,a.le)(t.widowControl)&&!1!==e.widowControl||!(0,a.le)(t.widowControl)&&e.widowControl!==t.widowControl)&&(!((0,a.le)(t.outlineLevel)&&"BodyText"!==e.outlineLevel||!(0,a.le)(t.outlineLevel)&&e.outlineLevel!==t.outlineLevel)&&(!((0,a.le)(t.lineSpacing)&&1!==e.lineSpacing||!(0,a.le)(t.lineSpacing)&&Math.round(e.lineSpacing)!==Math.round(t.lineSpacing))&&!((0,a.le)(t.lineSpacingType)&&"Multiple"!==e.lineSpacingType||!(0,a.le)(t.lineSpacingType)&&e.lineSpacingType!==t.lineSpacingType)))))))))))))},e.prototype.getBlocksToUpdate=function(e){for(var t=[],i=0;i<e.length;i++){var r=e[i];if(r.paragraphFormat&&r.paragraphFormat.listFormat&&Object.keys(r.paragraphFormat.listFormat).length>0)t.push(r);else if(r.rows)for(var o=0;o<r.rows.length;o++)for(var n=r.rows[o],s=0;s<n.cells.length;s++){var a=n.cells[s];t=t.concat(this.getBlocksToUpdate(a.blocks))}}return t},e.prototype.updateListIdForBlocks=function(e,t,i,r,o){for(var n=!1,s=0;s<e.length;s++){var l=e[s];if(l.paragraphFormat&&l.paragraphFormat.listFormat&&Object.keys(l.paragraphFormat.listFormat).length>0){var d=l.paragraphFormat.listFormat,h=this.listLevelPatternInCollection(d.listLevelNumber,t.levels[d.listLevelNumber]);d.listId===r&&((0,a.le)(h)&&(!i||i&&!this.checkSameLevelFormat(d.listLevelNumber,t,i))?(n=!0,d.listId=o):!(0,a.le)(h)&&this.checkSameLevelFormat(d.listLevelNumber,t,h)&&(d.isUpdated||(d.listId=h.listId,d.isUpdated=!0),n=!1))}else if(l.rows)for(var c=0;c<l.rows.length;c++)for(var p=l.rows[c],g=0;g<p.cells.length;g++){var u=p.cells[g],m=this.updateListIdForBlocks(u.blocks,t,i,r,o);n||(n=m)}}return n},e.prototype.updatePasteContent=function(e,t){var i=this.getUniqueListOrAbstractListId(!0);if(e.lists.filter((function(e){return e.listId===i})).length>0){var r=e.lists.slice().sort((function(e,t){return e.listId-t.listId}));i=r[r.length-1].listId+1}var o=this.getUniqueListOrAbstractListId(!1);if(e.abstractLists.filter((function(e){return e.abstractListId===o})).length>0){var n=e.abstractLists.slice().sort((function(e,t){return e.abstractListId-t.abstractListId}));o=n[n.length-1].abstractListId+1}for(var s,l=function(r){var n=e.lists[r],l=e.abstractLists.filter((function(e){return e.abstractListId===n.abstractListId}))[0],h=d.documentHelper.lists.filter((function(e){return e.listId===n.listId}));if(!(0,a.le)(l)){var c=d.updateListIdForBlocks(e.sections[t].blocks,l,h[0],n.listId,i);c?(l.abstractListId=o,n.listId=i,n.abstractListId=o,i++,o++):(e.lists.splice(r,1),e.abstractLists.splice(e.abstractLists.indexOf(l),1),r--)}s=r},d=this,h=0;h<e.lists.length;h++)l(h),h=s;for(var c=this.getBlocksToUpdate(e.sections[t].blocks),p=0;p<c.length;p++){var g=c[p];delete g.paragraphFormat.listFormat.isUpdated}},e.prototype.getBlocks=function(e,t,i,r,n){var s=[];if("string"===typeof e){var d=this.selection.start.paragraph;this.selection.isForward||(d=this.selection.end.paragraph);var h=[],c=e;c=c.replace(/\r\n/g,"\r"),this.isInsertText&&(c=void 0!==navigator&&-1!==navigator.userAgent.indexOf("Firefox")?c.replace(/\r/g,"\n"):c.replace(/\n/g,"\r")),h=void 0!==navigator&&-1!==navigator.userAgent.indexOf("Firefox")?c.split("\n"):c.split("\r");var p=[],g=new o.VB;g.sectionFormat=new l.Z(g),g.childWidgets=p;for(var u=0;u<h.length;u++)if(u!==h.length-1||0!==h[u].length){var m=this.selection.start.currentWidget.getInline(this.selection.start.offset,0),f=this.selection.getPreviousValidElement(m.element);f!==m.element&&(f=this.selection.getNextValidElement(m.element));var v=void 0;d.isEmpty()?v=d.characterFormat:(0,a.le)(f)?this.copyInsertFormat(d.characterFormat,!1):v=f.characterFormat;var y=this.documentHelper.selection.copySelectionParagraphFormat();(0,a.le)(this.previousParaFormat)||(y=this.previousParaFormat);var F=new o.ZH;F.paragraphFormat.copyFormat(y);var H=new o.z7(F);if(h[u].length>0)for(var C=h[u].split(/(\s+)/),w=0;w<C.length;w++){var I=new o.a3;I.characterFormat.copyFormat(v),I.text=C[w],H.children.push(I),I.line=H}F.childWidgets.push(H),F.containerWidget=g,p.push(F)}s.push(g)}else{this.viewer.owner.parser.addCustomStyles(e),e.comments&&e.comments.length>0&&(this.documentHelper.owner.parser.commentsCollection=new x.X,this.documentHelper.owner.parser.commentStarts=new x.X,this.documentHelper.owner.parser.commentEnds=new x.X,this.documentHelper.owner.parser.parseComments(e,r||this.documentHelper.comments));g=void 0;this.selection.currentPasteAction="DefaultPaste";for(u=0;
1u<e.sections.length;u++){var b=this.documentHelper.owner.parser;if(b.isPaste=t,b.isHtmlPaste=this.isHtmlPaste,this.isPasteListUpdated||(0,a.le)(e.lists)||(this.documentHelper.lists.length>0&&this.updatePasteContent(e,u),this.isPasteListUpdated=!0,(0,a.le)(e.abstractLists)||b.parseAbstractList(e,this.documentHelper.abstractLists),(0,a.le)(e.lists)||b.parseList(e,this.documentHelper.lists)),!(0,a.le)(e.revisions))if(t){var W=this.viewer.owner.revisionsInternal.changes;(0,a.le)(b.revisionCollection)||(b.revisionCollection=void 0),b.revisionCollection=new x.X;var P=b.revisionCollection;if((!this.documentHelper.owner.sfdtExportModule.copyWithTrackChange||!b.isCutPerformed)&&e.revisions.length>=1)for(var R=0;R<e.revisions.length;R++){var k=!0;if(P.containsKey(e.revisions[R].revisionId)){if(W.length>0)for(var T=0;T<W.length;T++)W[T].revisionID===e.revisions[R].revisionId&&(k=!1);if(k){var S=P.get(e.revisions[R].revisionId);W.push(S)}}else b.parseRevisions(e,W)}this.documentHelper.owner.sfdtExportModule.copyWithTrackChange=!1}else b.revisionCollection=this.documentHelper.revisionsInternal,b.parseRevisions(e,n);g=new o.VB,g.sectionFormat=new l.Z(g),t?s.push(g):i.unshift(g),b.parseBody(e.sections[u].blocks,g.childWidgets),e.lastParagraphMarkCopied&&this.selection.start.paragraph.isEmpty()&&1==this.documentHelper.pages.length&&1==this.documentHelper.pages[0].bodyWidgets[0].childWidgets.length&&b.parseSectionFormat(e.sections[u].sectionFormat,g.sectionFormat),b.isPaste=!1,b.isHtmlPaste=!1}if(e.lastParagraphMarkCopied){var L=new o.ZH;g.childWidgets.push(L)}}return"MergeWithExistingFormatting"===this.currentPasteOptions&&this.applyMergeFormat(s),s},e.prototype.applyMergeFormat=function(e){for(var t=this.selection.start.paragraph,i=this.selection.start.currentWidget.getInline(this.selection.start.offset,0),r=this.selection.getPreviousValidElement(i.element),n=r?r.characterFormat:this.copyInsertFormat(t.characterFormat,!1),s=this.documentHelper.selection.copySelectionParagraphFormat(),a=0;a<e.length;a++)for(var l=e[a].childWidgets,d=0;d<l.length;d++){var h=l[d];if(h instanceof o.ZH)h.paragraphFormat.copyFormat(s),this.applyFormatInternal(h,n);else for(var c=0;c<h.childWidgets.length;c++)for(var p=h.childWidgets[c],g=0;g<p.childWidgets.length;g++)for(var u=p.childWidgets[g],m=0;m<u.childWidgets.length;m++)this.applyFormatInternal(u.childWidgets[m],n)}},e.prototype.applyFormatInternal=function(e,t){if(e instanceof o.ZH)for(var i=0;i<e.childWidgets.length;i++)for(var r=e.childWidgets[i],n=0;n<r.children.length;n++){var s=r.children[n].characterFormat,a=s.cloneFormat();a.bold&&(r.children[n].characterFormat.bold=a.bold),a.italic&&(r.children[n].characterFormat.italic=a.italic),"None"!==a.underline&&(r.children[n].characterFormat.underline=a.underline)}else for(i=0;i<e.childWidgets.length;i++){var l=e.childWidgets[i];for(n=0;n<l.childWidgets.length;n++)for(var d=l.childWidgets[n],h=0;h<d.childWidgets.length;h++)this.applyFormatInternal(d.childWidgets[h],t)}},e.prototype.applyPasteOptions=function(e,t){if(!(0,a.le)(this.copiedContent)&&""!==this.copiedTextContent&&!t){this.currentPasteOptions=e;var i=this.selection.isForward?this.selection.start:this.selection.end,r=i.paragraph.paragraphFormat,o=this.copiedContent,n=this.copiedTextContent;switch(this.editorHistory&&this.editorHistory.canUndo()&&(this.editorHistory.undo(),this.editorHistory.redoStack.pop()),this.copiedContent=o,this.copiedTextContent=n,this.selection.isViewPasteOptions=!0,e){case"KeepSourceFormatting":this.pasteContents(""!==this.copiedContent?this.copiedContent:this.copiedTextContent);break;case"MergeWithExistingFormatting":this.pasteContents(""!==this.copiedContent?this.copiedContent:this.copiedTextContent,r);break;case"KeepTextOnly":this.pasteContents(this.copiedTextContent);break}}},e.prototype.applyTablePasteOptions=function(e){if(!(0,a.le)(this.copiedContent)&&""!==this.copiedTextContent){this.isPaste=!0;var t=""!==this.copiedContent?this.copiedContent:this.copiedTextContent;this.editorHistory&&this.editorHistory.canUndo()&&(this.editorHistory.undo(),this.editorHistory.redoStack.pop());var i=this.getBlocks(t,!0),r=this.selection.start.paragraph.paragraphFormat;switch(e){case"NestTable":this.pasteAsNestedTable(i,r);break;case"InsertAsRows":this.pasteAsNewRow(i[0].childWidgets[0]);break;case"InsertAsColumns":this.pasteAsNewColumn(i[0].childWidgets[0]);break;case"OverwriteCells":this.pasteOverwriteCell(i[0].childWidgets[0]);break}this.isPaste=!1}},e.prototype.pasteContents=function(e,t){if("string"!==typeof e&&(this.copiedContent=e),"FormFieldsOnly"===this.documentHelper.protectionType&&this.documentHelper.selection.isInlineFormFillMode()){var i=this.selection.getCurrentFormField(),r=this.getFieldResultText(),o=i.formFieldData.maxLength,n=this.documentHelper.selection.text.length;if(o>0)if(0===n){var s=o-r.length;e=e.substring(0,s)}else n>0&&(e=e.substring(0,n))}this.pasteContentsInternal(this.getBlocks(e,!0),!0,t),e.comments&&e.comments.length>0&&this.documentHelper.layout.layoutComments(this.documentHelper.comments),this.isInsertField=!1},e.prototype.pasteContentsInternal=function(e,t,i){this.isPaste=t;var r,n=this.documentHelper.selection;if(n.start.paragraph.isInsideTable&&n.end.paragraph.isInsideTable){var s=!1;if(1===e.length){var a=e[0].childWidgets;a.length<3&&(1===a.length&&a[0]instanceof o.dm||2===a.length&&a[0]instanceof o.dm&&a[1].isEmpty())&&(s=!0)}if(s){var l=n.start.paragraph.associatedCell,d=n.end.paragraph.associatedCell,h=e[0].childWidgets[0];if(l.ownerTable.equals(d.ownerTable))return 0===n.start.paragraph.associatedCell.rowIndex&&0===n.end.paragraph.associatedCell.rowIndex&&l.equals(d)&&!this.selection.isCellSelected(l,n.start,n.end)?(this.selection.currentPasteAction="InsertAsColumns",this.pasteAsNewColumn(h)):(this.selection.currentPasteAction="OverwriteCells",this.pasteOverwriteCell(h)),void(this.isPaste=!1)}}r=this.checkAndRemoveComments(),this.defaultPaste(e,i),this.updateHistoryForComments(r)},e.prototype.defaultPaste=function(e,t){var i=this.documentHelper.selection,r=!0,o=!1;if(this.initComplexHistory("Paste"),this.documentHelper.isListTextSelected){var n=i.start.paragraph;n.paragraphFormat.listFormat&&-1!==n.paragraphFormat.listFormat.listId&&this.onApplyList(void 0)}this.initHistory("Paste"),i.isEmpty&&!this.documentHelper.isListTextSelected||(r=this.removeSelectedContentInternal(i,i.start,i.end)),r?o=this.pasteContent(e,t):this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo=void 0),this.editorHistory&&this.editorHistory.currentHistoryInfo?(this.editorHistory.updateHistory(),this.editorHistory.updateComplexHistory()):this.reLayout(i,i.isEmpty),o&&this.layoutWholeDocument(!0),this.isPaste=!1},e.prototype.pasteAsNewColumn=function(e){if(!this.owner.isReadOnlyMode&&this.canEditContentControl&&this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("PasteColumn");var t=this.getOwnerCell(this.selection.isForward),i=t.ownerRow.ownerTable.combineWidget(this.owner.viewer);if(this.editorHistory)this.cloneTableToHistoryInfo(i);this.selection.owner.isLayoutEnabled=!1;var r=e.clone(),o=r.childWidgets[0],n=r.childWidgets.length,s=o.childWidgets.length,l=t.columnIndex,d=void 0,h=void 0,c=s,p=[];n>i.childWidgets.length?(this.addRows(n-i.childWidgets.length,i),this.tableUpdate(i)):i.childWidgets.length>n&&(this.addRows(i.childWidgets.length-n,r,i),this.tableUpdate(i));for(var g=0;g<c;g++)for(var u=0;u<i.childWidgets.length;u++){var m=i.childWidgets[u],f=r.childWidgets[u],v=f.childWidgets[g],y=m.childWidgets[t.columnIndex];h=this.createColumn(this.selection.getLastParagraph(t)),h.index=u,h.rowIndex=m.index,h.containerWidget=m;var F=m.previousWidget,H=this.rowspannedCollection(m,p);if(null!=y)h.cellFormat.copyFormat(y.cellFormat),h.cellFormat.rowSpan=1;else if(H.length>0)for(var C=0;C<H.length;C++)F.rowIndex+(H[C].cellFormat.rowSpan-1)>=m.rowIndex&&(h.cellFormat.copyFormat(H[C].cellFormat),h.cellFormat.rowSpan=1);v.containerWidget=h.containerWidget,h.childWidgets=v.childWidgets,(0,a.le)(d)&&(d=this.selection.getFirstParagraph(h)),0===l?m.childWidgets.splice(g,0,h):this.insertSpannedCells(m,p,h,l)}this.tableReLayout(i,d,h)}},e.prototype.pasteAsNestedTable=function(e,t){var i=e[0].childWidgets[0];if(this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("PasteNested");var r=this.getOwnerCell(this.selection.isForward),n=r.ownerRow.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.cloneTableToHistoryInfo(n);var s=void 0,l=i.clone(),d=this.selection.end.paragraph.containerWidget,h=void 0;if(r!=d){var c=r.ownerRow;while(c!=d.ownerRow.nextRow){for(var p=r.columnIndex;p<=d.columnIndex;p++){h=c.childWidgets[p];var g=l.clone(),u=new o.ZH;h.childWidgets=[],h.childWidgets[0]=g,h.childWidgets[1]=u,u.containerWidget=h,g.containerWidget=h,g.index=0,u.index=1,c.childWidgets[p]=h,(0,a.le)(s)&&(s=this.selection.getFirstParagraph(h))}c=c.nextRow}this.tableReLayout(n,s,h)}else this.defaultPaste(e,t)}},e.prototype.pasteOverwriteCell=function(e){if(this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("PasteOverwrite");var t=this.getOwnerCell(this.selection.isForward),i=t.ownerRow.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.cloneTableToHistoryInfo(i);var r=e.clone(),o=r.childWidgets.length,n=this.getOwnerCell(!this.selection.isForward),s=(t.columnIndex,t.rowIndex),l=void 0,d=this.selection.start.paragraph.associatedCell.ownerRow,h=r.childWidgets[0],c=void 0,p=(h.childWidgets.length,t.ownerRow);if(t!=n){var g=0,u=void 0,m=void 0,f=void 0,v=void 0;while(p!=n.ownerRow.nextRow){h=r.childWidgets[g]||r.childWidgets[g=0];for(var y=h.childWidgets.length,F=0,H=t.columnIndex;H<=n.columnIndex;H++){h=r.childWidgets[g],u>1&&m===H&&(H++,u--,m=null),f>1&&F>=y-(f-1)&&(f=1,H+=f-1,F=0),c=h.childWidgets[F]||h.childWidgets[F=0],v=c.clone();for(var C=p.childWidgets[H],w=0;w<v.childWidgets.length;w++){var I=v.childWidgets[w];I.containerWidget=C,v.childWidgets[w]=I}C.childWidgets=v.childWidgets,c.cellFormat.rowSpan>1&&(u=c.cellFormat.rowSpan,m=H),c.cellFormat.columnSpan>1&&(f=c.cellFormat.columnSpan),p.childWidgets[H]=C,(0,a.le)(l)&&(l=this.selection.getFirstParagraph(v)),F++}p=p.nextRow,g++}this.tableReLayout(i,l,v)}else{var b=void 0;u=void 0,m=void 0,C=void 0;o>i.childWidgets.length-s&&(b=o-i.childWidgets.length+s,this.addRows(b,i));for(var W=0;W<o;W++){H=t.columnIndex;h=r.childWidgets[W];for(var x=h.childWidgets.length,P=0;P<x;P++){c=h.childWidgets[P];v=c.clone();u>1&&m===H&&(H++,u--,m=null),C=d.childWidgets[H],C||(C=v,C.containerWidget=d,C.index=H);for(var R=0;R<v.childWidgets.length;R++){I=v.childWidgets[R];I.containerWidget=C,v.childWidgets[R]=I}C.childWidgets=v.childWidgets,c.cellFormat.rowSpan>1&&(u=c.cellFormat.rowSpan,m=H),d.childWidgets.splice(H++,1,C),(0,a.le)(l)&&(l=this.selection.getFirstParagraph(C))}d=d.nextRow}this.tableReLayout(i,l,C)}}},e.prototype.pasteAsNewRow=function(e){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){this.checkIsNotRedoing()&&this.initHistory("PasteRow"),this.documentHelper.owner.isShiftingEnabled=!0;var t=this.getOwnerCell(this.selection.isForward).getSplitWidgets()[0],i=this.getOwnerCell(!this.selection.isForward).getSplitWidgets()[0],r=t.ownerTable.combineWidget(this.owner.viewer),n=i.ownerRow;this.editorHistory&&this.cloneTableToHistoryInfo(r);this.getRowCountToInsert(),this.getColumnCountToInsert();var s=[],a=n.rowIndex;a++;for(var l=e.childWidgets.length,d=0;d<l;d++){var h=e.childWidgets[d].clone();this.owner.enableTrackChanges&&this.insertRevision(h.rowFormat,"Insertion"),s.push(h)}r.insertTableRowsInternal(s,a,!1);var c=void 0,p=void 0;if(r.childWidgets[a]instanceof o.BC)c=r.childWidgets[a].firstChild,p=this.selection.getFirstParagraph(c);else{var g=void 0;while(!(g instanceof o.dm))g=r.nextRenderedWidget;p=this.documentHelper.getFirstParagraphInFirstCell(g)}this.documentHelper.layout.reLayoutTable(r),this.selection.selectParagraphInternal(p,!0),this.reLayout(this.selection,!0)}},e.prototype.tableUpdate=function(e){e.isGridUpdated=!1,e.calculateGrid(),e.buildTableColumns(),e.isGridUpdated=!0}
1,e.prototype.rowspannedCollection=function(e,t){for(var i=0;i<e.childWidgets.length;i++){var r=e.childWidgets[i];r.cellFormat.rowSpan>1&&t.push(r)}return t},e.prototype.insertSpannedCells=function(e,t,i,r){for(var o=!1,n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];if(s.cellFormat.rowSpan>1&&t.push(s),(s.columnIndex+s.cellFormat.columnSpan===r||r>s.columnIndex&&s.columnIndex+s.cellFormat.columnSpan>r&&r<s.columnIndex+s.cellFormat.columnSpan)&&(e.childWidgets.splice(s.cellIndex+1,0,i),o=!0),o)break}if(!o&&t.length>0)for(var a=0;a<t.length;a++){var l=t[a];if(l.ownerRow!==e&&e.rowIndex<=l.ownerRow.rowIndex+l.cellFormat.rowSpan-1&&(l.columnIndex+l.cellFormat.columnSpan===r?(l.cellIndex>e.childWidgets.length?e.childWidgets.push(i):e.childWidgets.splice(l.cellIndex,0,i),o=!0):r>l.columnIndex&&l.columnIndex+l.cellFormat.columnSpan>r&&r<l.columnIndex+l.cellFormat.columnSpan&&(e.childWidgets.splice(l.columnIndex,0,i),o=!0)),o)break}},e.prototype.addRows=function(e,t,i){var r="Below";if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var o=!1,n=this.selection.isForward?this.selection.start:this.selection.end,s=(this.selection.isForward?this.selection.end:this.selection.start,t.childWidgets.length),a=t.childWidgets[s-1],l=a.childWidgets.length;if(n.paragraph.isInsideTable){var d=this.getOwnerCell(this.selection.isForward).getSplitWidgets()[0],h=a.childWidgets[l-1],c=h.ownerRow;this.rowInsertion(e,r,d,h,c,t,o)}}},e.prototype.pasteContent=function(e,t){this.documentHelper.owner.isShiftingEnabled=!0;var i="";if(this.updateInsertPosition(),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo)i=this.editorHistory.currentBaseHistoryInfo.insertPosition;else{var o=this.selection.start;this.selection.isForward||(o=this.selection.end);var n=this.selection.getParagraphInfo(o);i=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString())}this.documentHelper.owner.isLayoutEnabled=!0,this.documentHelper.owner.isPastingContent=!0;var s=this.pasteCopiedData(e,t),a="";if(this.updateEndPosition(),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo)a=this.editorHistory.currentBaseHistoryInfo.endPosition;else{n=this.selection.getParagraphInfo(this.selection.start);a=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString())}var l=new r.JK(this.documentHelper.owner);this.setPositionForCurrentIndex(l,i);var d=new r.JK(this.documentHelper.owner);return this.setPositionForCurrentIndex(d,a),this.pasteTextPosition={startPosition:l,endPosition:d},this.documentHelper.owner.isPastingContent=!1,this.documentHelper.selection.fireSelectionChanged(!0),s},e.prototype.pasteCopiedData=function(e,t){var i=!1;if(this.documentHelper.layout.isBidiReLayout&&(this.documentHelper.layout.isBidiReLayout=!1),this.isPaste&&this.isSectionEmpty(this.selection)&&!this.selection.start.paragraph.isInHeaderFooter){if(this.previousSectionFormat=new l.Z,this.previousSectionFormat.copyFormat(this.selection.start.paragraph.bodyWidget.sectionFormat),this.selection.start.paragraph.bodyWidget.sectionFormat.copyFormat(e[0].sectionFormat),this.selection.start.paragraph.bodyWidget.sectionFormat.footerDistance=this.previousSectionFormat.footerDistance,this.selection.start.paragraph.bodyWidget.sectionFormat.headerDistance=this.previousSectionFormat.headerDistance,this.owner.viewer instanceof w._){var r=this.selection.start.paragraph.bodyWidget.page;this.owner.viewer.updatePageBoundingRectangle(this.selection.start.paragraph.bodyWidget,r,r.boundingRectangle.y),this.owner.viewer.updateClientArea(this.selection.start.paragraph.bodyWidget,r)}i=!0}for(var n=0;n<e.length;n++)for(var s=e[n].childWidgets,d=0;d<s.length;d++){var c=s[d];if(c instanceof o.ZH&&0===c.childWidgets.length&&(c.childWidgets[0]=new o.z7(c)),c instanceof o.ZH&&!(0,a.le)(t)){c.paragraphFormat.copyFormat(t);var p=this.copyInsertFormat(this.selection.start.paragraph.characterFormat,!1);c.characterFormat.mergeFormat(p)}if(d===s.length-1&&c instanceof o.ZH){var g=c;if(g.childWidgets.length>0&&g.childWidgets[0].children.length>0){var u=this.selection.start;if("Center"!==u.paragraph.paragraphFormat.textAlignment&&"Right"!==u.paragraph.paragraphFormat.textAlignment||-1!==u.paragraph.paragraphFormat.listFormat.listId||(u.paragraph.x=this.owner.viewer.clientActiveArea.x),"KeepTextOnly"===this.currentPasteOptions){var m=new h.h(this.selection.start.paragraph);this.selection.start.paragraph.paragraphFormat=m}this.insertElement(g.childWidgets[0].children,g.paragraphFormat)}}else if(c instanceof o.qc){var f=this.selection.start.paragraph,v=c instanceof o.dm;if(v){var y=c;if(this.generateTableRevision(y),f.isInsideTable){var F=f.getContainerWidth();y.fitCellsToClientArea(F)}if(f.isEmpty()&&f.previousWidget instanceof o.dm&&!this.isPaste)return this.insertTableRows(y,f.previousWidget),i}this.insertBlockInternal(c)}}return i},e.prototype.generateTableRevision=function(e){if(this.owner.enableTrackChanges&&!(0,a.le)(e))for(var t=0;t<e.childWidgets.length;t++){var i=e.childWidgets[t];this.insertRevision(i.rowFormat,"Insertion");for(var r=0;r<i.childWidgets.length;r++)for(var o=i.childWidgets[r],n=0;n<o.childWidgets.length;n++){var s=o.childWidgets[n];(0,a.le)(s)||this.insertRevisionForBlock(s,"Insertion")}}},e.prototype.isSectionEmpty=function(e){var t=e.start.paragraph;if(t){if(t.isInsideTable||t.isInHeaderFooter||t!==e.end.paragraph)return!1;var i=t.bodyWidget;if(i){var r=i.page;if(r&&((0,a.le)(r.previousPage)||r.previousPage.sectionIndex!==r.sectionIndex)&&(0,a.le)(r.nextPage)&&t.isEmpty()&&1===i.childWidgets.length){var n=!0,s=e.start.paragraph.bodyWidget.sectionIndex,l=this.documentHelper.headersFooters[s];if(l){for(var d in l){var h=l[d];if((0,a.le)(h))n=!1;else{var c=h.childWidgets[0];(c instanceof o.dm||c instanceof o.ZH&&!c.isEmpty())&&(n=!1)}if(!n)break}return n}}}}return!1},e.prototype.insertTableInternal=function(e,t,i){var r=e.getIndex();if(i)for(var o=0,n=0;o<e.childWidgets.length;o++,n++){var s=e.childWidgets[o];t.childWidgets.splice(n,0,s),s.containerWidget=t,e.childWidgets.splice(o,1),o--}var a=e.containerWidget;this.constructRevisionsForTable(e,!1),this.removeBlock(e,!0);var l=a.childWidgets;l.splice(r,0,t),t.index=e.index,e.containerWidget=void 0,t.containerWidget=
1a,this.documentHelper.layout.clearTableWidget(t,!0,!0,!0),t.buildTableColumns(),this.constructRevisionsForTable(t,!0),t.isGridUpdated=!0,this.updateNextBlocksIndex(t,!0),this.documentHelper.layout.linkFieldInTable(t),this.documentHelper.layout.layoutBodyWidgetCollection(t.index,a,t,!1)},e.prototype.canConstructRevision=function(e){return e.revisions.length>0&&0===e.revisions[0].range.length||e.removedIds.length>0},e.prototype.constructRevisionsForTable=function(e,t){for(var i=0;i<e.childWidgets.length;i++){var r=e.childWidgets[i];if(t){this.canConstructRevision(r.rowFormat)&&this.constructRevisionFromID(r.rowFormat,!0);for(var n=0;n<r.childWidgets.length;n++)for(var s=r.childWidgets[n],a=0;a<s.childWidgets.length;a++)s.childWidgets[a]instanceof o.ZH&&this.constructRevisionsForBlock(s.childWidgets[a],t)}else this.removeDeletedCellRevision(r)}},e.prototype.constructRevisionsForBlock=function(e,t){for(var i=0;i<e.childWidgets.length;i++)for(var r=e.childWidgets[i],n=0;n<r.children.length;n++)t&&r.children[n]instanceof o.nR&&this.canConstructRevision(r.children[n])&&this.constructRevisionFromID(r.children[n],!0);this.canConstructRevision(e.characterFormat)&&this.constructRevisionFromID(e.characterFormat,!0)},e.prototype.applyRevisionForCurrentPara=function(e,t,i,r,n){var s=e.getInline(t+1,0),l=s.element,d=!1;t===e.getLength()&&(d=!0);var h=e.getInline(i,0).element;if(i>e.getLength()&&(n=!0),(0,a.le)(l)||(0,a.le)(h))(0,a.le)(l)||d?(0,a.le)(h)||(h.removedIds.push(r),this.constructRevisionFromID(h,!0)):(l.removedIds.push(r),this.constructRevisionFromID(l,!0));else if(d||l!==h){while(!(0,a.le)(l)&&l!==h)d||(l.removedIds.push(r),this.constructRevisionFromID(l,!0)),(0,a.le)(l.nextNode)||(l=l.nextNode instanceof o.aQ?l.nextNode:l.nextNode.nextValidNodeForTracking),d=!1;(0,a.le)(l)||d||(l.removedIds.push(r),this.constructRevisionFromID(l,!0))}else l.removedIds.push(r),this.constructRevisionFromID(l,!0);n&&(e.characterFormat.removedIds.push(r),this.constructRevisionFromID(e.characterFormat,!0))},e.prototype.insertBlockTable=function(e,t,i){var r=e.start.offset;e.start.paragraph.childWidgets.indexOf(e.start.currentWidget);t instanceof o.ZH&&r>0&&(this.moveInlines(e.start.paragraph,t,0,0,e.start.paragraph.firstChild,r,e.start.currentWidget),e.selectParagraphInternal(e.start.paragraph,!0),this.checkInsertPosition(e)&&this.updateHistoryPosition(this.selection.getHierarchicalIndex(t,r.toString()),!0)),r>0&&this.checkInsertPosition(e)&&this.updateHistoryPosition(e.start,!0);var n=i.indexInOwner;if(i.containerWidget.childWidgets.splice(n,0,t),t.containerWidget=i.containerWidget,t.index=i.index,this.updateNextBlocksIndex(t,!0),this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1),this.checkInsertPosition(e)){var s=void 0;t instanceof o.ZH&&(s=t),t instanceof o.dm&&(s=this.documentHelper.getFirstParagraphInFirstCell(t)),this.updateHistoryPosition(this.selection.getHierarchicalIndex(s,"0"),!0)}},e.prototype.handleCut=function(e){var t=e.start,i=e.end;e.isForward||(t=e.end,i=e.start);if(t.paragraph===i.paragraph&&t.offset+1===i.offset){var o=0,n=t.paragraph.getInline(i.offset,o),s=n.element;s}var a=this.checkAndRemoveComments(),l=this.selection.getParagraphInfo(t);e.editPosition=this.selection.getHierarchicalIndex(l.paragraph,l.offset.toString()),this.initHistory("Cut"),e.owner.isShiftingEnabled=!0,this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.checkInsertPosition(e)&&this.updateHistoryPosition(e.editPosition,!0),this.deleteSelectedContent(i.paragraph,e,t,i,3);var d=new r.JK(e.owner);this.setPositionForCurrentIndex(d,e.editPosition),e.selectContent(d,!0),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.checkEndPosition(e)&&this.updateHistoryPosition(e.end,!1),this.reLayout(e),this.updateHistoryForComments(a)},e.prototype.insertInlineInternal=function(e,t){var i=this.selection,r=e.length,n=this.selection.getParagraphInfo(i.start);if(t=(0,a.le)(t)?"Insertion":t,i.start.paragraph.isEmpty()){var s=i.start.paragraph;"Center"!==s.paragraphFormat.textAlignment&&"Right"!==s.paragraphFormat.textAlignment||-1!==s.paragraphFormat.listFormat.listId||(s.x=this.owner.viewer.clientActiveArea.x);var l=!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing);s.childWidgets[0].children.push(e),e.line=s.childWidgets[0],this.owner.enableTrackChanges&&e.isValidNodeForTracking&&!l&&this.insertRevision(e,t),(e.removedIds.length>0||l)&&this.constructRevisionFromID(e,!0),e.linkFieldCharacter(this.documentHelper),e instanceof o.R5&&("Footnote"===e.footnoteType&&this.updateFootnoteCollection(e),"Endnote"===e.footnoteType&&this.updateEndnoteCollection(e)),this.documentHelper.layout.reLayoutParagraph(s,0,0,void 0,void 0)}else{var d=0,h=i.start.currentWidget.getInline(i.start.offset,d),c=h.element;d=h.index,this.insertElementInternal(c,e,d,t,!0)}this.setPositionParagraph(n.paragraph,n.offset+r,!0)},e.prototype.insertElement=function(e,t){var i=this.selection,r=0,n=void 0,s=-1,l=void 0,d=0,h=void 0,c=this.selection.getParagraphInfo(i.start),p=this.owner.enableTrackChanges,g=void 0,u=void 0,m=0;if(i.start.paragraph.isEmpty())n=i.start.paragraph,l=n.childWidgets[0],s=0;else{var f=i.start.currentWidget.getInline(i.start.offset,m);g=f.element,m=f.index,n=g.line.paragraph,s=n.childWidgets.indexOf(g.line),d=g.indexInOwner,l=g.line,m===g.length?(d++,h=!1):0===m?((0,a.le)(g.previousNode)&&(d=0),h=!0):(d++,u=new o.a3,u.characterFormat.copyFormat(g.characterFormat),u.text=g.text.substring(m),g.text=g.text.slice(0,m),g.revisions.length>0&&!this.owner.enableTrackChanges&&this.splitRevisionForSpittedElement(g,u),l.children.splice(d,0,u),u.line=g.line)}for(var v=0;v<e.length;v++){r+=e[v].length,e[v]instanceof o.a3&&e[v].text.indexOf(" ")>=0&&this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!0);var y=e[v].revisions.length;e[v].ischangeDetected=!0,l.children.splice(d,0,e[v]),e[v].line=l,e[v].linkFieldCharacter(this.documentHelper);var F=this.updateRevisionForElement(g,e[v],m,0===v,u,h);p&&!F&&e[v].revisions.length===y&&this.checkToCombineRevisionsinBlocks(e[v],y===e[v].revisions.length,v>0&&v===e.length-1,"Insertion"),g=e[v],d++}t&&((0,a.le)(n.paragraphFormat.listFormat.list)||!(0,a.le)(n.paragraphFormat.listFormat)&&-1===n.paragraphFormat.listFormat.listId)&&n.paragraphFormat.copyFormat(t),this.isPaste&&(this.viewer.updateClientAreaForBlock(n,!0),n.x=this.viewer.clientActiveArea.x),this.documentHelper.layout.reLayoutParagraph(n,s,0,this.isInsertField?void 0:n.paragraphFormat.bidi),this.setPositionParagraph(c.paragraph,c.offset+r,!0)},e.prototype.updateRevisionForElement=function(e,t,i,r,o,n){if(!this.owner.enableTrackChanges)return!1;if((0,a.le)(e)&&(0,a.le)(o))return!1;var s=!!(0,a.le)(n),l=t.revisions.length;if(!r)return this.insertRevisionAtEnd(e,t,"Insertion");if(!s)return n?this.insertRevisionAtBegining(e,t,"Insertion"):this.insertRevisionAtEnd(e,t,"Insertion");var d=this.checkToMapRevisionWithInlineText(e,i,t,!1,"Insertion");return d||t.revisions.length>l?this.copyElementRevision(e,o,!0):0===t.revisions.length&&(this.splitRevisionForSpittedElement(e,o),this.insertRevision(t,"Insertion")),!1},e.prototype.insertElementInternal=function(e,t,i,r,n){var s=e.line,l=s.paragraph,d=s.indexInOwner,h=e.indexInOwner,c=l.paragraphFormat.bidi&&e.isRightToLeft,p=!1;r=(0,a.le)(r)?"Insertion":r;var g=this.skipTracking(),u=this.owner.enableTrackChanges,m=!1,f=t.revisions.length;if(this.owner.editorHistory&&(this.owner.editorHistory.isUndoing||this.owner.editorHistory.isRedoing)&&t instanceof o.a3&&(p=e.characterFormat.isEqualFormat(t.characterFormat)&&this.documentHelper.textHelper.isRTLText(t.text)),p)e.text=e.text.substring(0,i)+t.text+e.text.substring(i);else if(i===e.length)h=this.incrementCommentIndex(c,e,h),t.removedIds.length>0||g?this.constructRevisionFromID(t,!0,e):!u||g||this.skipFieldDeleteTracking||(m=this.insertRevisionAtEnd(e,t,r)),s.children.splice(h,0,t);else if(0===i)t.removedIds.length>0?this.constructRevisionFromID(t,!1):!u||g||this.skipFieldDeleteTracking||(m=this.insertRevisionAtBegining(e,t,r)),(0,a.le)(e.previousNode)?(e.line.children.splice(0,0,t),h=0):e.line.children.splice(h,0,t);else{h=this.incrementCommentIndex(c,e,h);var v=new o.a3;if(v.characterFormat.copyFormat(e.characterFormat),v.text=e.text.substring(i),e.revisions.length>0&&!u&&!g&&0===t.removedIds.length&&this.splitRevisionForSpittedElement(e,v),e.text=e.text.substr(0,i),s.children.splice(h,0,v),v.line=e.line,m=!0,this.isTrackingFormField=e.previousElement instanceof o.V8,t.removedIds.length>0&&!this.isTrackingFormField)this.constructRevisionFromID(t,!1),this.copyElementRevision(e,v,!0);else if(this.owner.enableTrackChanges)if(t instanceof o.aQ||t instanceof o.Xw||t instanceof o.Cw||t instanceof o.jn)this.copyElementRevision(e,v,!1);else{var y=this.checkToMapRevisionWithInlineText(e,i,t,c,r);y||t.revisions.length>f?this.copyElementRevision(e,v,!0):t.revisions.length===f&&(this.splitRevisionForSpittedElement(e,v),this.insertRevision(t,r))}s.children.splice(h,0,t),h-=1}if(t.line=e.line,t instanceof o.aQ){var F=this.documentHelper.bookmarks;t.reference.reference=t,F.containsKey(t.name)||F.add(t.name,t)}!(0,a.le)(t.line.paragraph.containerWidget)&&!(0,a.le)(t.line.paragraph.containerWidget.containerWidget)&&t.line.paragraph.containerWidget.containerWidget instanceof o.tf&&(t.line.paragraph.containerWidget.containerWidget.height+=t.height),t.linkFieldCharacter(this.documentHelper),t instanceof o.h&&0===t.type&&this.documentHelper.contentControlCollection.push(t),(t instanceof o.XY&&"Inline"!==t.textWrappingStyle||t instanceof o.f7)&&(-1===l.floatingElements.indexOf(t)&&l.floatingElements.push(t),-1===l.bodyWidget.floatingElements.indexOf(t)&&"Inline"!==t.textWrappingStyle&&l.bodyWidget.floatingElements.push(t)),!u||m||g||this.skipFieldDeleteTracking||this.checkToCombineRevisionsinBlocks(t,f===t.revisions.length,i===e.length,r),t instanceof o.R5&&(g&&(t.isLayout=!1),"Footnote"===t.footnoteType&&this.updateFootnoteCollection(t),"Endnote"===t.footnoteType&&this.updateEndnoteCollection(t)),n&&this.documentHelper.layout.reLayoutParagraph(l,d,h,void 0,void 0)},e.prototype.incrementCommentIndex=function(e,t,i){return this.owner.editorHistory&&this.owner.editorHistory&&this.owner.editorHistory.currentHistoryInfo&&(!this.owner.editorHistory||
1!this.owner.editorHistory.currentHistoryInfo||"SkipCommentInline"===this.owner.editorHistory.currentHistoryInfo.action&&("SkipCommentInline"!==this.owner.editorHistory.currentHistoryInfo.action||this.owner.editorHistory.currentHistoryInfo.modifiedActions[0]!==this.editorHistory.currentBaseHistoryInfo&&(this.owner.editorHistory.currentHistoryInfo.modifiedActions[0]===this.editorHistory.currentBaseHistoryInfo||t instanceof o.Xw)))||i++,i},e.prototype.constructRevisionFromID=function(e,t,i){if(e.removedIds.length>0){for(var r=0;r<e.removedIds.length;r++){var o=void 0;if(this.documentHelper.revisionsInternal.containsKey(e.removedIds[r])){if(o=this.documentHelper.revisionsInternal.get(e.removedIds[r]),e.revisions.push(o),t=!!t||this.skipTracking(),t&&this.editorHistory.isRedoing&&this.owner.editorHistory.currentBaseHistoryInfo&&"BackSpace"===this.owner.editorHistory.currentBaseHistoryInfo.action&&(t=!1),(0,a.le)(i))o.range.splice(t?o.range.length:0,0,e);else{var n=o.range.indexOf(i);n>=0?o.range.splice(n+(t?1:0),0,e):o.range.splice(0,0,e)}this.updateRevisionCollection(o)}}e.removedIds=[]}else for(r=0;r<e.revisions.length;r++){var s=e.revisions[r];this.documentHelper.revisionsInternal.containsKey(s.revisionID)&&(s=this.documentHelper.revisionsInternal.get(s.revisionID),s.range.splice(t?s.range.length:0,0,e),this.updateRevisionCollection(s))}},e.prototype.insertBlock=function(e){var t=!0,i=this.selection;if(i.isEmpty||(t=this.removeSelectedContents(i)),t||i.selectContent(i.start,!1),this.insertBlockInternal(e),this.checkInsertPosition(i)){var r=void 0;r=e instanceof o.ZH?e:this.documentHelper.getFirstParagraphInFirstCell(e),this.updateHistoryPosition(this.selection.getHierarchicalIndex(r,"0"),!0)}this.fireContentChange()},e.prototype.insertBlockInternal=function(e){var t=this.selection,i=this.selection.start.paragraph;if(!t.start.isAtParagraphStart){if(e instanceof o.ZH){this.isInsertingTOC||!this.owner.enableTrackChanges||this.skipTracking()||this.insertRevisionForBlock(e,"Insertion");var r=t.start.clone();return this.isInsertingTOC||!this.owner.enableTrackChanges||this.skipTracking()||this.insertRevisionForBlock(e,"Insertion"),this.insertNewParagraphWidget(e,!1),void(this.isInsertingTOC||this.combineRevisions(e,r,this.selection.end))}this.updateInsertPosition(),i=i.combineWidget(this.owner.viewer),this.splitParagraph(i,i.firstChild,0,t.start.currentWidget,t.start.offset,!1),t.selectParagraphInternal(this.selection.start.paragraph,!0)}var n=t.start.paragraph.containerWidget,s=t.start.paragraph.index;if(!(0,a.le)(n)){var l=n.childWidgets.indexOf(t.start.paragraph);n.childWidgets.splice(l,0,e),e.containerWidget=n,e.index=s,e.height=0,e instanceof o.dm&&(e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0),this.updateNextBlocksIndex(e,!0),!this.isInsertingTOC&&this.owner.enableTrackChanges&&!this.skipTracking()&&e instanceof o.ZH?this.insertRevisionForBlock(e,"Insertion"):e instanceof o.ZH?this.constructRevisionsForBlock(e,!0):e instanceof o.dm&&this.constructRevisionsForTable(e,!0),this.documentHelper.layout.layoutBodyWidgetCollection(s,n,e,!1)}},e.prototype.insertImage=function(e,t,i){this.insertImageInternal(e,!1,t,i)},e.prototype.insertImageInternal=function(e,t,i,r){var n=this,s=this.selection.getCurrentFormField(),l="FormFieldsOnly"===this.documentHelper.protectionType&&!(0,a.le)(s)&&s.formFieldData instanceof o.$o;if(!this.owner.isReadOnlyMode&&this.canEditContentControl||l){if((0,a.le)(i)&&(0,a.le)(r)){var d=document.createElement("img"),h=this;d.addEventListener("load",(function(){h.insertPicture(e,this.width,this.height,!0)})),d.src=e}else this.insertPicture(e,i,r,t);setTimeout((function(){(0,a.le)(n.viewer)||n.viewer.updateScrollBars()}),30)}},e.prototype.insertTable=function(e,t){var i=this.selection.start;if(!this.owner.isReadOnlyMode&&this.canEditContentControl){e=e||1,t=t||1;var r=new a.E7("documenteditor",this.owner.defaultLocale);if(r.setLocale(this.documentHelper.owner.locale),t<1||t>63)R.hZ.alert(r.getConstant("Number of columns must be between 1 and 63."));else if(e<1||e>this.documentHelper.owner.documentEditorSettings.maximumRows)"en-US"==this.documentHelper.owner.locale?R.hZ.alert("Number of rows must be between 1 and "+this.documentHelper.owner.documentEditorSettings.maximumRows+"."):R.hZ.alert(r.getConstant("Number of rows must be between 1 and 32767."));else{var n,s=this.createTable(e,t),l=i.paragraph.getContainerWidth()-s.tableFormat.leftIndent;s.splitWidthToTableCells(l);var d=i.paragraph.previousWidget;if(i.currentWidget.isFirstLine()&&0===i.offset&&d instanceof o.dm)return this.insertTableRows(s,d),void s.destroy();n=this.checkAndRemoveComments(),this.initHistory("InsertTable"),this.documentHelper.owner.isShiftingEnabled=!0,this.insertBlock(s),!(0,a.le)(s.containerWidget)&&!(0,a.le)(s.containerWidget.containerWidget)&&s.containerWidget.containerWidget instanceof o.tf&&(s.containerWidget.containerWidget.height+=s.height,this.isTableInsert=!0);var h=this.documentHelper.getFirstParagraphInFirstCell(s).childWidgets[0];i.setPosition(h,!0),this.selection.end.setPositionInternal(i);var c=this.documentHelper.getLastParagraphInLastCell(s.getSplitWidgets().pop()),p=c.getLength()+1;this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.endPosition=this.selection.getHierarchicalIndex(c,p.toString())),this.reLayout(this.selection),this.isTableInsert=!1,this.updateHistoryForComments(n)}}},e.prototype.insertRow=function(e,t){var i=e?"Above":"Below";if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var r=!0,o=this.selection.isForward?this.selection.start:this.selection.end;this.selection.isForward?this.selection.end:this.selection.start;if(o.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("Above"===i?"InsertRowAbove":"InsertRowBelow"),this.documentHelper.owner.isShiftingEnabled=!0;var n=this.getOwnerCell(this.selection.isForward).getSplitWidgets()[0],s=this.getOwnerCell(!this.selection.isForward).getSplitWidgets()[0],a=n.ownerTable.combineWidget(this.owner.viewer),l="Below"===i?s.ownerRow:n.ownerRow;if(this.editorHistory)this.cloneTableToHistoryInfo(a);this.rowInsertion(t,i,n,s,l,a,r)}this.reLayout(this.selection,!0)}},e.prototype.rowInsertion=function(e,t,i,r,n,s,l){var d=e||this.getRowCountToInsert(),h=[],c=n.rowIndex;if("Below"===t){c++;var p=(0,a.le)(r.previousWidget)||r.columnIndex===r.previousWidget.columnIndex+1,g=r.cellIndex!==r.columnIndex&&p&&n.rowIndex+i.cellFormat.rowSpan-1===r.ownerRow.rowIndex;g||r.cellFormat.rowSpan>1&&!(0,a.le)(n.nextWidget)&&n.nextWidget instanceof o.BC&&(r.cellFormat.rowSpan+=d,n=n.nextWidget),n.bottomBorderWidth=0}for(var u=0;u<d;u++){var m=this.updateRowspan(n,"Below"===t?r:i,t),f=this.createRowAndColumn(m.count,u,c,s);f.rowFormat.copyFormat(n.rowFormat),this.owner.enableTrackChanges&&this.insertRevision(f.rowFormat,"Insertion"),this.updateCellFormatForInsertedRow(f,m.cellFormats),h.push(f)}s.insertTableRowsInternal(h,c,l);var v=void 0,y=void 0;if(s.childWidgets[c]instanceof o.BC)v=s.childWidgets[c].firstChild,y=this.selection.getFirstParagraph(v);else{var F=void 0;while(!(F instanceof o.dm))F=s.nextRenderedWidget;y=this.documentHelper.getFirstParagraphInFirstCell(F)}l&&this.documentHelper.layout.reLayoutTable(s),this.selection.selectParagraphInternal(y,!0)},e.prototype.autoFitTable=function(e){if(!this.documentHelper.owner.isReadOnlyMode&&this.canEditContentControl){var t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start);var r=this.selection.getTable(t,i);r=r.getSplitWidgets()[0];var o=this.documentHelper.layout.getParentTable(r);
1(0,a.le)(o)||(this.setOffsetValue(this.selection),o=o.combineWidget(this.owner.viewer),this.initHistory("FitToContents"===e?"TableAutoFitToContents":"FitToWindow"===e?"TableAutoFitToWindow":"TableFixedColumnWidth"),this.documentHelper.owner.editorHistoryModule&&this.cloneTableToHistoryInfo(o),o.updateProperties(!0,r,e),this.documentHelper.owner.isShiftingEnabled=!0,this.documentHelper.layout.reLayoutTable(r),this.reLayout(this.selection,!0))}},e.prototype.updateCellFormatForInsertedRow=function(e,t){for(var i=0;i<e.childWidgets.length;i++)e.childWidgets[i].cellFormat.copyFormat(t[i]),e.childWidgets[i].cellFormat.rowSpan=1},e.prototype.updateRowspan=function(e,t,i){for(var r=e.getPreviousRowSpannedCells(!0),o=0,n=[],s=0;s<e.childWidgets.length;s++){for(var l=e.childWidgets[s],d=!1,h=(0,a.le)(l.previousWidget)||l.columnIndex!==l.previousWidget.columnIndex+1,c=0;c<r.length;c++)if(h){var p=r[c],g=p.ownerRow.rowIndex+p.cellFormat.rowSpan-1;if(l.columnIndex<p.columnIndex&&l.cellIndex!==l.columnIndex&&(d=!0,o++,n.push(l.cellFormat)),1===t.cellFormat.rowSpan)if(g>l.ownerRow.rowIndex){if("Above"===i&&p.ownerRow===t.ownerRow)continue;p.cellFormat.rowSpan+=1,r.splice(c,1),c--}else l.cellIndex!==l.columnIndex&&h&&g===l.ownerRow.rowIndex&&("Above"===i?(p.cellFormat.rowSpan+=1,r.splice(c,1),c--):(o++,n.push(p.cellFormat),r.splice(c,1),c--));else if(p!==t){if("Above"===i&&(p.ownerRow===t.ownerRow||p.columnIndex===t.columnIndex))continue;p.columnIndex!==t.columnIndex&&p.ownerRow.rowIndex!==l.ownerRow.rowIndex&&(g>t.ownerRow.rowIndex||"Above"===i&&g===t.ownerRow.rowIndex)&&(p.cellFormat.rowSpan+=1,r.splice(c,1),c--)}}-1===r.indexOf(l)&&l.cellFormat.rowSpan>1&&(d=!0),d||(o++,n.push(l.cellFormat))}return{count:o,cellFormats:n}},e.prototype.insertTableRows=function(e,t){this.initHistory("InsertTableBelow"),e.containerWidget=t.containerWidget,t=t.combineWidget(this.owner.viewer);var i=t.childWidgets[t.childWidgets.length-1];t.insertTableRowsInternal(e.childWidgets,t.childWidgets.length,!0);var r=this.selection.getFirstParagraph(i.nextWidget.childWidgets[0]);this.checkInsertPosition(this.selection)&&this.updateHistoryPosition(this.selection.getHierarchicalIndex(r,"0"),!0),t.isDefaultFormatUpdated=!1,this.documentHelper.layout.reLayoutTable(t),this.selection.start.setPosition(r.firstChild,!0),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.updateHistoryPosition(this.selection.end,!1),this.selection.end.setPosition(r.firstChild,!0),this.reLayout(this.selection)},e.prototype.insertColumn=function(e,t){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var i=e?"Left":"Right";if(this.selection.start.paragraph.isInsideTable){this.checkIsNotRedoing()&&this.initHistory("Left"===i?"InsertColumnLeft":"InsertColumnRight"),this.selection.owner.isShiftingEnabled=!0;var r=this.getOwnerCell(this.selection.isForward),o=this.getOwnerCell(!this.selection.isForward),n=r.ownerRow.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.cloneTableToHistoryInfo(n),this.selection.owner.isLayoutEnabled=!1;var s=r.columnIndex;"Right"===i&&(s=o.columnIndex+o.cellFormat.columnSpan);for(var l=void 0,d=void 0,h=t||this.getColumnCountToInsert(),c=[],p=0;p<h;p++)for(var g=0;g<n.childWidgets.length;g++){var u=n.childWidgets[g];d=this.createColumn(this.selection.getLastParagraph(r)),d.index=g,d.rowIndex=u.rowIndex,d.containerWidget=u,d.cellFormat.copyFormat(r.cellFormat),d.cellFormat.rowSpan=1,(0,a.le)(l)&&(l=this.selection.getFirstParagraph(d)),0===s?u.childWidgets.splice(s,0,d):this.insertSpannedCells(u,c,d,s),this.copyCellFormats(u,s)}this.tableReLayout(n,l,d)}}},e.prototype.copyCellFormats=function(e,t){var i=e.childWidgets[t];if(!(0,a.le)(i)){var r=i.childWidgets[0];t==e.childWidgets.length-1?--t:++t;var o=e.childWidgets[t],n=o.childWidgets[0],s=void 0,l=void 0;n.childWidgets.length>0&&(s=n.childWidgets[0],s.children.length>0&&(l=s.children[0])),r.paragraphFormat.copyFormat(n.paragraphFormat),(0,a.le)(l)?r.characterFormat.copyFormat(n.characterFormat):r.characterFormat.copyFormat(l.characterFormat)}},e.prototype.tableReLayout=function(e,t,i){e.updateRowIndex(0);var r=this.documentHelper.layout.getParentTable(e);r?r.fitChildToClientArea():e.fitChildToClientArea(),this.selection.owner.isLayoutEnabled=!0,e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.skipScrollToPosition=!0,this.documentHelper.layout.reLayoutTable(e),this.selection.start.setPosition(t.firstChild,!0),this.selection.end.setPosition(this.selection.getLastParagraph(i).firstChild,!1),(this.checkIsNotRedoing()||(0,a.le)(this.editorHistory))&&this.reLayout(this.selection)},e.prototype.createTable=function(e,t){this.selection.start.paragraph;var i=new o.dm;i.tableFormat.preferredWidthType="Auto",i.tableFormat.leftIndent=this.selection.start.paragraph.leftIndent,i.tableFormat.initializeTableBorders();var r=0;while(r<e){var n=this.createRowAndColumn(t,r);n.rowFormat.heightType="Auto",this.owner.enableTrackChanges&&this.insertRevision(n.rowFormat,"Insertion"),n.containerWidget=i,i.childWidgets.push(n),r++}return i},e.prototype.createRowAndColumn=function(e,t,i,r){var n=r,s=this.selection.start.paragraph,l=new o.BC;l.rowFormat=new d.J(l),l.index=t;for(var h=0;h<e;h++){(0,a.le)(i)||(0,a.le)(n)||(i&&i>0&&n.childWidgets[i-1]&&n.childWidgets[i-1].childWidgets[h]?s=n.childWidgets[i-1].childWidgets[h].childWidgets[0]:0==i&&(s=n.childWidgets[i].childWidgets[h].childWidgets[0]));var c=this.createColumn(s,!0);c.index=h,c.rowIndex=t,c.containerWidget=l,l.childWidgets.push(c)}return l},e.prototype.createColumn=function(e,t){var i=new o.nb,r=new o.ZH;if(t){r.paragraphFormat.copyFormat(e.paragraphFormat),r.paragraphFormat.leftIndent=0,r.paragraphFormat.firstLineIndent=0;var n=e.childWidgets[0].children[0];(0,a.le)(n)?r.characterFormat.copyFormat(e.characterFormat):r.characterFormat.copyFormat(n.characterFormat)}return r.containerWidget=i,i.childWidgets.push(r),i.cellFormat=new c.D(i),i},e.prototype.getColumnCountToInsert=function(){var e=1,t=this.selection.start,i=this.selection.end;if(this.selection.isForward||(t=this.selection.end,i=this.selection.start),t&&i&&this.selection.getTable(t,i)){if(t.paragraph.associatedCell===i.paragraph.associatedCell)return 1;if(t.paragraph.associatedCell.ownerRow===i.paragraph.associatedCell.ownerRow)return e+i.paragraph.associatedCell.cellIndex-t.paragraph.associatedCell.cellIndex;e=0;for(var r=t.paragraph.associatedCell.ownerTable.getColumnCellsForSelection(t.paragraph.associatedCell,i.paragraph.associatedCell),o=0;o<r.length;o++)t.paragraph.associatedCell.ownerRow===r[o].ownerRow&&e++}return 0===e?1:e},e.prototype.getRowCountToInsert=function(){var e=1,t=this.selection.start,i=this.selection.end;return this.selection.isForward||(t=this.selection.end,i=this.selection.start),(0,a.le)(t)||(0,a.le)(i)||(0,a.le)(this.selection.getTable(t,i))?0===e?1:e:t.paragraph.associatedCell===i.paragraph.associatedCell||t.paragraph.associatedCell.ownerRow===i.paragraph.associatedCell.ownerRow?1:e+this.getOwnerRow(!this.selection.isForward).rowIndex-this.getOwnerRow(this.selection.isForward).rowIndex},e.prototype.getOwnerCell=function(e){var t=void 0,i=e?this.selection.start.paragraph.associatedCell:this.selection.end.paragraph.associatedCell,r=e?this.selection.end.paragraph.associatedCell:this.selection.start.paragraph.associatedCell;t=i;var n=t.ownerTable;while(!(0,a.le)(n)&&n.containerWidget instanceof o.nb&&n!==r.ownerTable)t=n.containerWidget,n=t.ownerTable;return t},e.prototype.getOwnerRow=function(e){var t,i=e?this.selection.start.paragraph.associatedCell.ownerRow:this.selection.end.paragraph.associatedCell.ownerRow,r=e?this.selection.end.paragraph.associatedCell.ownerRow:this.selection.start.paragraph.associatedCell.ownerRow;t=i;var n=t.ownerTable;while(!(0,a.le)(n)&&n.containerWidget instanceof o.nb&&n!==r.ownerTable)t=n.containerWidget.ownerRow,n=t.ownerTable;return t},e.prototype.getOwnerTable=function(e){var t=void 0,i=this.selection.start.paragraph.associatedCell.ownerTable,r=this.selection.end.paragraph.associatedCell.ownerTable;t=e?i:r;while(t.containerWidget instanceof o.nb&&t!==(e?r:i))t=t.containerWidget.ownerTable;return t},e.prototype.mergeSelectedCellsInTable=function(){if(this.canMergeCells())if(this.owner.enableTrackChanges){var e=new a.E7("documenteditor",this.owner.defaultLocale);e.setLocale(this.owner.locale),this.alertDialog=R.hZ.alert({title:e.getConstant("UnTrack"),
1content:e.getConstant("Merge Track"),showCloseIcon:!0,okButton:{text:"Ok",click:this.confirmCellMerge.bind(this)},closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"}}),this.alertDialog.enableRtl=this.owner.enableRtl}else this.confirmCellMerge()},e.prototype.confirmCellMerge=function(){this.checkIsNotRedoing()&&this.initHistory("MergeCells"),this.selection.owner.isShiftingEnabled=!0;var e=this.selection.start,t=this.selection.end;this.selection.isForward||(e=this.selection.end,t=this.selection.start);var i=this.getOwnerCell(this.selection.isForward),r=this.getOwnerCell(!this.selection.isForward),o=this.selection.getContainerCellOf(i,r);if(o.ownerTable.contains(r)&&!this.selection.containsCell(o,r)){var n=i.ownerTable.combineWidget(this.owner.viewer);i=this.selection.getSelectedCell(i,o),r=this.selection.getSelectedCell(r,o);var s=this.mergeSelectedCells(n,i,r),l=this.selection.getFirstParagraph(s);e.setPosition(l.firstChild,!0);var d=this.selection.getLastParagraph(s);t.setPosition(d.lastChild,!1),this.selection.fireSelectionChanged(!1)}(this.checkIsNotRedoing()||(0,a.le)(this.editorHistory))&&this.reLayout(this.selection,!1),(0,a.le)(this.alertDialog)||(this.alertDialog.close(),this.alertDialog=void 0)},e.prototype.mergeSelectedCells=function(e,t,i){this.cloneTableToHistoryInfo(e);this.selection.owner.isLayoutEnabled=!1;var r=this.selection.getCellLeft(t.ownerRow,t),n=r+t.cellFormat.cellWidth,l=this.selection.getCellLeft(i.ownerRow,i),d=l+i.cellFormat.cellWidth,h=this.updateSelectedCellsInTable(r,n,l,d);r=h.start,n=h.end;for(var c,p=e.childWidgets.indexOf(i.ownerRow),g=e.childWidgets.indexOf(t.ownerRow),u=void 0,m=g;m<=p;m++){for(var f=e.childWidgets[m],v=0;v<f.childWidgets.length;v++){var y=f.childWidgets[v],F=this.selection.getCellLeft(f,y);if(s.o_.round(r,2)<=s.o_.round(F,2)&&s.o_.round(F,2)<s.o_.round(n,2)){var H=y.lastChild;if(H instanceof o.ZH&&H.isEmpty()&&y.childWidgets.pop(),(0,a.le)(u))u=y,c=H;else{m===g&&(u.cellFormat.preferredWidth+=y.cellFormat.preferredWidth,u.cellFormat.columnSpan+=y.cellFormat.columnSpan,this.mergeBorders(u,y));for(var C=0;C<y.childWidgets.length;C++){var w=y.childWidgets[C],I=w.clone();I.containerWidget=u,u.childWidgets.push(I)}f.childWidgets.splice(v,1),y.destroy(),v--}}}if((0===u.childWidgets.length||1===u.childWidgets.length&&u.childWidgets[0]instanceof o.dm)&&c){I=c.clone();u.childWidgets.push(I),I.containerWidget=u}if(0===f.childWidgets.length){var b=e.childWidgets.indexOf(f);f.updateRowBySpannedCells(),e.childWidgets.splice(b,1),f.destroy(),p--,m--}}return!(0,a.le)(u)&&g<p&&(u.cellFormat.rowSpan=p-g+1),this.updateBlockIndexAfterMerge(u),e.updateRowIndex(0),e.calculateGrid(),e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.layout.reLayoutTable(e),this.selection.owner.isLayoutEnabled=!0,u},e.prototype.mergeBorders=function(e,t){var i=void 0,r=null;if((0,a.le)(e.cellFormat.borders)||(i=e.cellFormat.borders),(0,a.le)(t.cellFormat.borders)||(r=t.cellFormat.borders),!(0,a.le)(i)||!(0,a.le)(r))if((0,a.le)(i))i=new p.A(e.cellFormat),i.copyFormat(r);else{if((0,a.le)(r))return;e.ownerRow.rowIndex===t.ownerRow.rowIndex&&(i.top=e.getBorderBasedOnPriority(i.top,r.bottom),i.bottom=e.getBorderBasedOnPriority(i.bottom,r.bottom))}},e.prototype.updateBlockIndexAfterMerge=function(e){for(var t=0;t<e.childWidgets.length;t++)e.childWidgets[t].index=t},e.prototype.canMergeCells=function(){if(this.selection.isEmpty||!this.selection.start.paragraph.isInsideTable||!this.selection.end.paragraph.isInsideTable)return!1;this.selection.start,this.selection.end;this.selection.isForward||(this.selection.end,this.selection.start);var e=this.getOwnerCell(this.selection.isForward),t=this.getOwnerCell(!this.selection.isForward),i=this.selection.getContainerCellOf(e,t);if(i.ownerTable.contains(t)&&!this.selection.containsCell(i,t)){e=this.selection.getSelectedCell(e,i),t=this.selection.getSelectedCell(t,i);var r=1;if(e.ownerRow===t.ownerRow){for(var o=e.ownerRow.childWidgets.indexOf(e),n=o;n<=e.ownerRow.childWidgets.indexOf(t);n++){var s=e.ownerRow.childWidgets[n],l=s.previousWidget;if(n!==o){if(s.cellFormat.rowSpan!==r)return!1;if(!(0,a.le)(l)&&s.columnIndex!==l.cellFormat.columnSpan+l.columnIndex)return!1}r=s.cellFormat.rowSpan}return!0}return this.canMergeSelectedCellsInTable(e.ownerTable,e,t)}return!1},e.prototype.canMergeSelectedCellsInTable=function(e,t,i){var r=e.childWidgets.indexOf(i.ownerRow),o=e.childWidgets.indexOf(t.ownerRow),n=this.selection.getCellLeft(t.ownerRow,t),l=n+t.cellFormat.cellWidth,d=this.selection.getCellLeft(i.ownerRow,i),h=d+i.cellFormat.cellWidth,c=this.updateSelectedCellsInTable(n,l,d,h);n=c.start,l=c.end;for(var p=0,g=0,u=!1,m=!1,f=[],v=o;v<=r;v++){for(var y=e.childWidgets[v],F=0,H=0,C=!1,w=0;w<y.childWidgets.length;w++){var I=y.childWidgets[w],b=this.selection.getCellLeft(y,I);if(this.checkCellWithInSelection(n,l,b)){u=!1,m=!1,I.cellFormat.rowSpan>1&&f.push(I),C||(F=b,H=b,C=!0);var W=I.previousWidget;0!==H&&s.o_.round(H,0)!==s.o_.round(b,0)&&(H=b),H+=s.o_.convertPointToPixel(I.cellFormat.cellWidth);
1var x=this.checkPrevOrNextCellIsWithinSel(n,l,I,!0),P=this.checkPrevOrNextCellIsWithinSel(n,l,I,!1),R=0===f.length||1===f.length&&f[0]===I,k=this.checkCurrentCell(f,I,x,P);if(v===r&&!(0,a.le)(W)&&I.cellFormat.rowSpan>W.cellFormat.rowSpan&&!k)return!1;if(v!==o)for(var T=0;T<f.length;T++){var S=f[T].ownerRow.rowIndex+f[T].cellFormat.rowSpan-1;if(S>=y.rowIndex){if(f[T].columnIndex>I.columnIndex?m=!0:u=!0,v===r&&f[T]!==I&&S>I.ownerRow.rowIndex+I.cellFormat.rowSpan-1)return!1;S!==y.rowIndex||this.checkPrevOrNextCellIsWithinSel(n,l,I,!1)||f.splice(f.indexOf(f[T]),1)}}if(x&&!(0,a.le)(W)&&R&&I.columnIndex!==W.columnIndex+1&&this.checkCellWidth(I))return!1}}if(v===o)p=F,g=H;else{if(H>0&&F>0&&(!u&&Math.round(p)!==Math.round(F)||!m&&Math.round(g)!==Math.round(H)))return!1;if(v===r)return!0}}return!1},e.prototype.checkCellWidth=function(e){var t=e.previousWidget,i=this.documentHelper.selection.getCellLeft(e.ownerRow,e),r=this.documentHelper.selection.getCellLeft(e.ownerRow,t),o=r+s.o_.convertPointToPixel(t.cellFormat.cellWidth);return s.o_.round(o,2)!==s.o_.round(i,2)},e.prototype.checkCellWithInSelection=function(e,t,i){return s.o_.round(e,2)<=s.o_.round(i,2)&&s.o_.round(i,2)<s.o_.round(t,2)},e.prototype.checkPrevOrNextCellIsWithinSel=function(e,t,i,r){var o=r?i.previousWidget:i.nextWidget,n=0;return!(0,a.le)(o)&&(n=this.documentHelper.selection.getCellLeft(o.ownerRow,o),this.checkCellWithInSelection(e,t,n))},e.prototype.checkCurrentCell=function(e,t,i,r){var o=t.ownerRow;if(e.length>0)for(var n=0;n<e.length;n++){var s=e[n].ownerRow,a=s.rowIndex+e[n].cellFormat.rowSpan-1;if(e[n]===t&&(1===e.length||this.checkRowSpannedCells(e,t))&&!r&&!i)return!0;if(e[n]!==t&&s.rowIndex<o.rowIndex&&a===o.rowIndex+t.cellFormat.rowSpan-1)return!0}return!1},e.prototype.checkRowSpannedCells=function(e,t){for(var i=0;i<e.length;i++)if(e[i]!==t&&e[i].columnIndex===t.columnIndex)return!0;return!1},e.prototype.insertNewParagraphWidget=function(e,t){if(this.updateInsertPosition(),this.insertParagraph(e,t),!t){var i=void 0,r=e;do{i=this.selection.getNextParagraphBlock(r),r=i}while(i&&i.equals(e));(0,a.le)(i)?this.selection.selectParagraphInternal(e,!0):this.selection.selectParagraphInternal(i,!0)}this.fireContentChange()},e.prototype.insertParagraph=function(e,t){var i=this.selection.start.currentWidget,r=this.selection.start.offset;this.editorHistory&&this.editorHistory.isUndoing&&"InsertTextParaReplace"===this.editorHistory.currentBaseHistoryInfo.action&&(r=0);var o=this.selection.start.paragraph;if(o=o.combineWidget(this.owner.viewer),t){var n=this.selection.getLineLength(o.lastChild),s=e.firstChild?e.firstChild.children.length:0;this.moveInlines(o,e,s,r,i,n,o.lastChild)}else r>0&&this.moveInlines(o,e,0,0,o.firstChild,r,i);var a=o.getSplitWidgets();o=t?a[a.length-1]:a[0];var l=o.containerWidget.childWidgets.indexOf(o);t&&l++;var d=o.containerWidget;e.index=o.index,e.containerWidget=d,d.childWidgets.splice(l,0,e),this.constructRevisionsForBlock(e,!0),this.updateNextBlocksIndex(t?o:e,!0),e.height=0,this.documentHelper.layout.layoutBodyWidgetCollection(e.index,d,e,!1)},e.prototype.moveInlines=function(e,t,i,r,n,s,a){if(0===t.childWidgets.length){var l=new o.z7(t);t.childWidgets.push(l)}var d=!1;this.documentHelper.layout.clearListElementBox(e),this.documentHelper.layout.clearListElementBox(t);for(var h=0;h<e.childWidgets.length;h++){var c=e.childWidgets[h];if(n===c&&a===c){i=this.moveContent(c,r,s,i,t);break}if(a===c){i=this.moveContent(c,0,s,i,t);break}n===c?(d=!0,i=this.moveContent(c,r,this.documentHelper.selection.getLineLength(c),i,t)):d&&(i=this.moveContent(c,0,this.documentHelper.selection.getLineLength(c),i,t))}this.removeEmptyLine(e),e.isInsideTable||(this.viewer.updateClientArea(e.bodyWidget,e.bodyWidget.page),this.documentHelper.layout.reLayoutParagraph(e,0,0))},e.prototype.moveContent=function(e,t,i,r,n){for(var s=0,a=0;a<e.children.length;a++){var l=e.children[a];if(t>=s+l.length||l instanceof o.no)l instanceof o.no||(s+=l.length);else{var d=0;t>s&&(d=t-s);var h=i-s;if(h>l.length&&(h=l.length),d>0&&(s+=d),0===d&&h===l.length){if(l instanceof o.f7){var c=e.paragraph.floatingElements.indexOf(l);-1!==c&&e.paragraph.floatingElements.splice(c,1)}n.firstChild.children.splice(r,0,l),l.line=n.firstChild,r++,e.children.splice(a,1),a--}else if(l instanceof o.a3){var p=new o.a3;p.characterFormat.copyFormat(l.characterFormat),p.text=l.text.substr(d,h-d),l.ischangeDetected=!0,p.ischangeDetected=!0,n.firstChild.children.splice(r,0,p),p.line=n.firstChild,r++,this.updateRevisionForMovedContent(l,p),l.text=l.text.slice(0,d)+l.text.slice(h),l.ischangeDetected=!0}if(i<=s+h-d)break;s+=h-d}}return r},e.prototype.updateRevisionForMovedContent=function(e,t){for(var i=0;i<e.revisions.length;i++){var r=e.revisions[i],o=r.range.indexOf(e);t.revisions.splice(0,0,r),r.range.splice(o,0,t)}},e.prototype.updateComplexWithoutHistory=function(e,t,i){var o=this.documentHelper.selection;if(0===e){var n=new r.JK(o.owner);this.setPositionForCurrentIndex(n,t),this.documentHelper.layout.reLayoutParagraph(n.paragraph,0,0),this.setPositionForCurrentIndex(o.start,i),this.setPositionForCurrentIndex(o.end,i)}if(1===e){n=new r.JK(o.owner);this.setPositionForCurrentIndex(n,t);var s=new r.JK(o.owner);this.setPositionForCurrentIndex(s,i),this.documentHelper.layout.reLayoutParagraph(n.paragraph,0,0),s.paragraph!==n.paragraph&&this.documentHelper.layout.reLayoutParagraph(s.paragraph,0,0)}o.owner.isShiftingEnabled&&(this.documentHelper.layout.shiftLayoutedItems(!1),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget()),o.owner.isShiftingEnabled=!1,o.start.updatePhysicalPosition(!0),o.isEmpty?o.end.setPositionInternal(o.start):o.end.updatePhysicalPosition(!0),o.upDownSelectionLength=o.end.location.x,o.fireSelectionChanged(!0),this.documentHelper.updateFocus(),this.owner.viewer.updateScrollBars(),this.fireContentChange(),this.isHandledComplex=!0},e.prototype.reLayout=function(e,t,i){if(!(0,a.le)(this.previousBlockToLayout)){var r=this.previousBlockToLayout;this.documentHelper.layout.layoutBodyWidgetCollection(r.index,r.bodyWidget,r,!1,!1),this.previousBlockToLayout=void 0}if(!this.documentHelper.isComposingIME&&this.editorHistory&&this.editorHistory.isH
1andledComplexHistory())return this.editorHistory.currentHistoryInfo&&"ClearFormat"!==this.editorHistory.currentHistoryInfo.action&&"ApplyStyle"!==this.editorHistory.currentHistoryInfo.action&&(this.startParagraph=void 0,this.endParagraph=void 0),void(this.isHandledComplex=!1);(0,a.le)(e.editRegionHighlighters)||e.editRegionHighlighters.clear(),(0,a.le)(this.documentHelper.blockToShift)&&(this.documentHelper.removeEmptyPages(),this.documentHelper.layout.updateFieldElements(),this.owner.viewer.updateScrollBars(),e.owner.isShiftingEnabled||(e.fireSelectionChanged(!0),this.startParagraph=void 0,this.endParagraph=void 0)),(0,a.le)(t)&&(t=e.isEmpty),this.owner.showRevisions&&this.owner.trackChangesPane.isUpdateTrackChanges(this.owner.revisions.length)&&this.owner.trackChangesPane.updateTrackChanges(),e.owner.isShiftingEnabled?(e.owner.isShiftingEnabled=!1,e.owner.isLayoutEnabled=!0,this.documentHelper.layout.shiftLayoutedItems(!0),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.isRowOrCellResizing||((0,a.le)(e.start.paragraph)||!(0,a.le)(e.start.paragraph.bodyWidget.containerWidget)&&e.start.paragraph.bodyWidget.containerWidget instanceof o.tf&&("Footnote"===e.start.paragraph.bodyWidget.containerWidget.footNoteType?(this.documentHelper.layout.isRelayoutFootnote=!0,this.shiftFootnotePageContent(e.start.paragraph.bodyWidget.containerWidget)):(this.documentHelper.layout.isRelayoutFootnote=!1,this.shiftFootnotePageContent())),this.getOffsetValue(e),e.upDownSelectionLength=e.end.location.x,e.fireSelectionChanged(!0),this.documentHelper.updateFocus(),this.startParagraph=void 0,this.endParagraph=void 0)):this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&("RowResizing"!==this.editorHistory.currentBaseHistoryInfo.action&&"CellResizing"!==this.editorHistory.currentBaseHistoryInfo.action||this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&(this.editorHistory.currentBaseHistoryInfo.modifiedProperties.length>0&&this.editorHistory.currentBaseHistoryInfo.updateSelection(),this.editorHistory.undoStack&&this.editorHistory.undoStack.length>0&&this.editorHistory.undoStack[this.editorHistory.undoStack.length-1]instanceof b.d&&this.editorHistory.undoStack[this.editorHistory.undoStack.length-1].modifiedActions&&this.editorHistory.undoStack[this.editorHistory.undoStack.length-1].modifiedActions[this.editorHistory.undoStack[this.editorHistory.undoStack.length-1].modifiedActions.length-1]===this.editorHistory.currentBaseHistoryInfo?this.editorHistory.currentBaseHistoryInfo=void 0:this.editorHistory.updateHistory()),i||(this.fireContentChange(),this.owner.enableLockAndEdit&&this.owner.viewer.updateScrollBars(),this.owner.documentHelper.layout.isRelayout=!1)},e.prototype.updateHeaderFooterWidget=function(e){(0,a.le)(e)&&(e=this.selection.start.paragraph.bodyWidget),this.updateHeaderFooterWidgetToPage(e),this.shiftPageContent(e.headerFooterType,e.sectionFormat)},e.prototype.updateHeaderFooterWidgetToPage=function(e){e.page;for(var t="EvenHeader"===e.headerFooterType||"EvenFooter"===e.headerFooterType,i=0;i<this.documentHelper.pages.length;i++){var r=this.documentHelper.pages[i];if(i+1===1&&r.bodyWidgets[0].sectionFormat.differentFirstPage&&-1!==e.headerFooterType.indexOf("FirstPage"))return void this.updateHeaderFooterWidgetToPageInternal(r,e,-1!==e.headerFooterType.indexOf("Header"));0===r.index&&r.bodyWidgets[0].sectionFormat.differentFirstPage&&-1===e.headerFooterType.indexOf("FirstPage")||(r.bodyWidgets[0].sectionFormat.differentOddAndEvenPages?t&&(i+1)%2===0?this.updateHeaderFooterWidgetToPageInternal(r,e,-1!==e.headerFooterType.indexOf("Header")):t||(i+1)%2===0||(i>0||!r.bodyWidgets[0].sectionFormat.differentFirstPage)&&this.updateHeaderFooterWidgetToPageInternal(r,e,-1!==e.headerFooterType.indexOf("Header")):this.updateHeaderFooterWidgetToPageInternal(r,e,-1!==e.headerFooterType.indexOf("Header")))}},e.prototype.updateHeaderFooterWidgetToPageInternal=function(e,t,i){var r=!1;
1if(r=i?t!=e.headerWidgetIn:t!=e.footerWidgetIn,r){var o=t.clone();this.documentHelper.layout.clearBlockWidget(o.childWidgets,!0,!0,!0),o.page=e,o.parentHeaderFooter=t,this.owner.viewer.updateHFClientArea(o.sectionFormat,i),o=this.documentHelper.layout.layoutHeaderFooterItems(this.owner.viewer,o);var n=void 0;i?(n=e.headerWidgetIn,e.headerWidget=o):(n=e.footerWidgetIn,e.footerWidget=o),this.removeFieldInWidget(n),this.removeFieldInWidget(n,void 0,!0),n.destroy()}},e.prototype.removeFieldInWidget=function(e,t,i){(0,a.le)(t)&&(t=!1);for(var r=0;r<e.childWidgets.length;r++)this.removeFieldInBlock(e.childWidgets[r],t,i)},e.prototype.removeFieldInBlock=function(e,t,i){if(e instanceof o.dm){if(e.wrapTextAround&&!(0,a.le)(e.bodyWidget)){var r=e.bodyWidget.floatingElements.indexOf(e);-1!==r&&e.bodyWidget.floatingElements.splice(r,1)}this.removeFieldTable(e,t,i)}else if(e instanceof o.BC)for(var n=0;n<e.childWidgets.length;n++)this.removeFieldInWidget(e.childWidgets[n],t,i);else this.removeField(e,t,i)},e.prototype.removeFieldTable=function(e,t,i){for(var r=0;r<e.childWidgets.length;r++)for(var o=e.childWidgets[r],n=0;n<o.childWidgets.length;n++)this.removeFieldInWidget(o.childWidgets[n],t,i)},e.prototype.shiftFootnotePageContent=function(e){var t=this.documentHelper.pages[0].bodyWidgets[0];if(!(0,a.le)(e)){var i=this.documentHelper.pages.indexOf(e.page);t=this.documentHelper.pages[i].bodyWidgets[0]}(0,a.le)(t.page.footnoteWidget)||this.checkAndShiftFromBottom(t.page,t.page.footnoteWidget),(0,a.le)(t.page.endnoteWidget),this.documentHelper.blockToShift&&(this.documentHelper.renderedLists.clear(),this.documentHelper.renderedLevelOverrides=[],this.documentHelper.layout.shiftLayoutedItems(!1))},e.prototype.shiftPageContent=function(e,t){var i;if(-1!==e.indexOf("First"))i=0;else if(t.differentOddAndEvenPages){var r=-1!==e.indexOf("Even");i=t.differentFirstPage?r?1:2:r?1:0}else i=t.differentFirstPage?1:0,1===i&&1===this.documentHelper.pages.length&&(i=0);var n=this.documentHelper.pages[i].bodyWidgets[0];do{if(-1!==e.indexOf("Header")){var l=n.page.headerWidget,d=!l.isEmpty||l.isEmpty&&this.owner.enableHeaderAndFooter,h=n.firstChild,c=s.o_.convertPointToPixel(t.topMargin),p=s.o_.convertPointToPixel(t.headerDistance);if(d&&(c=Math.max(p+n.page.headerWidget.height,c)),h.y!==c){this.owner.viewer.updateClientArea(n,n.page),h=h.combineWidget(this.owner.viewer);var g=h.previousRenderedWidget;g&&(!h.containerWidget.equals(g.containerWidget)||g.containerWidget.lastChild instanceof o.ZH&&(g.containerWidget.lastChild.isEndsWithPageBreak||g.containerWidget.lastChild.isEndsWithColumnBreak)||(this.owner.viewer.cutFromTop(g.y+g.height),this.documentHelper.layout.updateContainerWidget(h,g.containerWidget,g.indexInOwner+1,!1))),this.documentHelper.blockToShift=h}}else this.checkAndShiftFromBottom(n.page,n.page.footerWidget);this.documentHelper.blockToShift&&(this.documentHelper.renderedLists.clear(),this.documentHelper.renderedLevelOverrides=[],this.documentHelper.layout.shiftLayoutedItems(!1));while(n){var u=n.getSplitWidgets();if(n=u[u.length-1].nextRenderedWidget,n){if(0===i)break;if(n.page.index+1===0&&1===i||n.page.index+1!==0&&2===i)break;var m=n.page.nextPage;if(!(0,a.le)(m)&&m.bodyWidgets[0].equals(n)){n=m.bodyWidgets[0];break}}}}while(n)},e.prototype.checkAndShiftFromBottom=function(e,t){var i,r=e.bodyWidgets[0];if(r.childWidgets.length>1){for(var n=0;n<r.childWidgets.length;n++){var s=r.childWidgets[n];if(s.y+s.height>t.y){i=s;break}if(!(t instanceof o.tf)&&r.childWidgets.length-1===n&&s.y+s.height<t.y){i=s;break}}(0,a.le)(i)||(this.owner.viewer.updateClientArea(r,e,!0),this.owner.viewer.cutFromTop(i.y),this.documentHelper.blockToShift=i)}},e.prototype.allowFormattingInFormFields=function(e){if("FormFieldsOnly"===this.documentHelper.protectionType&&this.selection.isInlineFormFillMode()&&!(0,a.le)(this.owner.documentEditorSettings.formFieldSettings.formattingExceptions))for(var t=0;t<this.owner.documentEditorSettings.formFieldSettings.formattingExceptions.length;t++)if(e.toLowerCase()===this.owner.documentEditorSettings.formFieldSettings.formattingExceptions[t].toLowerCase())return!0;return!1},e.prototype.getContentControl=function(){for(var e=0;e<this.documentHelper.contentControlCollection.length;e++){var t=this.documentHelper.contentControlCollection[e],i=this.selection.getPosition(t),r=i.startPosition,o=i.endPosition,n=this.selection.start,s=this.selection.end;if(this.selection.isForward||(n=this.selection.end,s=this.selection.start),(n.isExistAfter(r)||n.isAtSamePosition(r))&&(s.isExistBefore(o)||s.isAtSamePosition(o)))return t}},e.prototype.checkPlainTextContentControl=function(){var e=this.selection.start,t=this.selection.end;this.selection.isForward||(t=this.selection.start,e=this.selection.end);var i=0,o=0,n=e.currentWidget.getInline(e.offset,i),s=t.currentWidget.getInline(t.offset,o);i=n.index,o=s.index;var l,d,h=n.element,c=s.element;if(h&&h.contentControlProperties&&"Text"===h.contentControlProperties.type||c&&c.contentControlProperties&&"Text"===c.contentControlProperties.type){if(h=this.getContentControl(),h.contentControlProperties&&!(0,a.le)(h)){var p=h.line.getOffset(h,1);l=new r.JK(this.owner),l.setPositionParagraph(h.line,p)}else l=e;if(c.contentControlProperties&&h.reference){c=h.reference;var g=c.line.getOffset(c,c.length);d=new r.JK(this.owner),d.setPositionParagraph(c.line,g)}else d=t;this.selection.selectRange(l,d)}else e.paragraph.contentControlProperties&&"Text"===e.paragraph.contentControlProperties.type&&this.selection.selectParagraph()},e.prototype.onApplyCharacterFormat=function(e,t,i,r){var o=this.documentHelper.isFormFillProtectedMode&&this.documentHelper.selection.isInlineFormFillMode()&&this.allowFormattingInFormFields(e);if(!(this.restrictFormatting&&!o||this.selection.checkContentControl
1Locked(!0))){this.documentHelper.layout.isBidiReLayout=!0;var n=this.documentHelper.selection;if((!n.owner.isReadOnlyMode||o)&&n.owner.isDocumentLoaded){i=!(0,a.le)(i)&&i,r=!(0,a.le)(r)&&r;var s=e[0].toUpperCase()+e.slice(1),l=n.start.paragraph;l.childWidgets[l.childWidgets.length-1];if(this.checkPlainTextContentControl(),n.isEmpty&&"List"!==n.contextType&&!r)return n.skipFormatRetrieval=!0,n.end.isAtParagraphEnd?(this.initHistory(s),this.documentHelper.owner.isShiftingEnabled=!0,this.applyCharFormatValue(l.characterFormat,e,t,i),this.reLayout(this.documentHelper.selection),this.documentHelper.updateFocus()):n.fireSelectionChanged(!0),void(n.skipFormatRetrieval=!1);if("highlightColor"===e&&n.start.isInSameParagraph(n.end)){var d=n.start,h=n.end;if(this.selection.isForward||(h=n.start,d=n.end),h.offset===n.getLineLength(h.currentWidget)+1&&h.offset-1===d.offset)return}this.setOffsetValue(n),this.initHistory(s),"List"===n.contextType?this.applyCharacterFormatForListText(n,e,t,i):this.updateSelectionCharacterFormatting(e,t,i),this.documentHelper.layout.isBidiReLayout=!1}}},e.prototype.applyCharacterFormatForListText=function(e,t,i,r){var o=e.getListLevel(e.start.paragraph);if(!(0,a.le)(o)){var n=o.characterFormat;switch(t){case"bold":this.applyListCharacterFormatByValue(e,n,"bold",!n.bold);break;case"italic":this.applyListCharacterFormatByValue(e,n,"italic",!n.italic);break;case"fontColor":this.applyListCharacterFormatByValue(e,n,"fontColor",i);break;case"fontFamily":this.applyListCharacterFormatByValue(e,n,"fontFamily",i);break;case"fontSize":this.applyListCharacterFormatByValue(e,n,"fontSize",i);break;case"highlightColor":this.applyListCharacterFormatByValue(e,n,"highlightColor",i);break;case"baselineAlignment":n.baselineAlignment===i&&(i="Normal"),this.applyListCharacterFormatByValue(e,n,"baselineAlignment",i);break;case"strikethrough":n.strikethrough===i&&(i="None"),this.applyListCharacterFormatByValue(e,n,"strikethrough",i);break;case"underline":n.underline===i&&(i="None"),this.applyListCharacterFormatByValue(e,n,"underline",i);break;case"characterFormat":this.applyListCharacterFormatByValue(e,n,void 0,i);break}}},e.prototype.applyListCharacterFormatByValue=function(e,t,i,r){this.initHistory("ListCharacterFormat"),this.applyCharFormatValue(t,i,r,!1),this.editorHistory.updateHistory(),this.reLayout(e),this.fireContentChange()},e.prototype.updateListCharacterFormat=function(e,t,i){this.updateListTextSelRange(e,t,i,!1)},e.prototype.updateListTextSelRange=function(e,t,i,r){this.documentHelper.owner.isShiftingEnabled=!0;var o=e.start,n=e.end;e.isForward||(o=e.end,n=e.start),this.initHistoryPosition(e,o);var s=e.getListLevel(e.start.paragraph);this.applyCharFormatValue(s.characterFormat,t,i,r),this.startSelectionReLayouting(o.paragraph,e,o,n)},e.prototype.updateInsertPosition=function(){var e=this.documentHelper.selection,t=e.start;e.isForward||(t=e.end),!this.editorHistory||(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(0,a.le)(t)||(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)&&this.updateHistoryPosition(t,!0)},e.prototype.setOffsetValue=function(e){var t=this.selection.getParagraphInfo(e.start);this.startParagraph=t.paragraph,this.startOffset=t.offset,t=this.selection.getParagraphInfo(e.end),this.endParagraph=t.paragraph,this.endOffset=t.offset},e.prototype.toggleHighlightColor=function(e){var t=this.documentHelper.selection;((0,a.le)(e)||"NoColor"===e)&&(e="Yellow"),t.characterFormat.highlightColor===e&&(e="NoColor"),this.selection.characterFormat.highlightColor=e},e.prototype.toggleSubscript=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting){var e="Subscript"===this.selection.characterFormat.baselineAlignment?"Normal":"Subscript";this.selection.characterFormat.baselineAlignment=e}},e.prototype.toggleSuperscript=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting){var e="Superscript"===this.selection.characterFormat.baselineAlignment?"Normal":"Superscript";this.selection.characterFormat.baselineAlignment=e}},e.prototype.increaseIndent=function(){this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.onApplyParagraphFormat("leftIndent",this.documentHelper.defaultTabWidth,!0,!1)},e.prototype.decreaseIndent=function(){this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.onApplyParagraphFormat("leftIndent",-this.documentHelper.defaultTabWidth,!0,!1)},e.prototype.clearList=function(){this.selection.owner.editorModule.onApplyList(void 0)},e.prototype.applyBullet=function(e,t){this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.applyBulletOrNumbering(e,"Bullet",t)},e.prototype.applyNumbering=function(e,t){this.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||this.applyBulletOrNumbering(e,t,"Verdana")},e.prototype.toggleBaselineAlignment=function(e){this.updateProperty(2,e)},e.prototype.clearFormattingInternal=function(e){var t=this.documentHelper.selection;this.setPreviousBlockToLayout(),this.initComplexHistory("ClearFormat"),(t.isEmpty||!(0,a.le)(e)&&e)&&(t.start.moveToParagraphStartInternal(t,!1),t.end.moveToParagraphEndInternal(t,!1)),this.setOffsetValue(t),this.editorHistory&&this.editorHistory.initializeHistory("ClearCharacterFormat"),this.updateSelectionCharacterFormatting("ClearCharacterFormat",void 0,!1),this.getOffsetValue(t),this.editorHistory&&this.editorHistory.updateHistory(),this.setOffsetValue(t),this.editorHistory&&this.editorHistory.initializeHistory("ClearParagraphFormat"),this.updateParagraphFormatInternal("ClearParagraphFormat",void 0,!1),this.editorHistory&&this.editorHistory.updateHistory(),this.getOffsetValue(t),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&this.editorHistory.updateComplexHistory(),this.startParagraph=void 0,this.endParagraph=void 0},e.prototype.clearFormatting=function(){this.clearFormattingInternal()},e.prototype.updateProperty=function(e,t){var i=this.selection;if((!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode())&&i.owner.isDocumentLoaded){var r=i.start;i.end;i.isForward||(r=i.end,i.start);var o=0,n=r.currentWidget.getInline(r.offset,o),s=n.element;o=n.index;var l=r.paragraph;if((0,a.le)(s)||s.length!==o||this.selection.isEmpty||(s=s.nextNode),1===e){var d="None";(0,a.le)(s)?(0,a.le)(l)||(d=l.characterFormat.underline):d=s.characterFormat.underline,this.selection.characterFormat.underline=t===d?"None":t}else{var h="Normal";(0,a.le)(s)?(0,a.le)(l)||(h=l.characterFormat.baselineAlignment):h=s.characterFormat.baselineAlignment,h===t&&(t="Normal"),this.selection.characterFormat.baselineAlignment=t}}},e.prototype.getCompleteStyles=function(){for(var e='{"styles":[',t=0,i=this.documentHelper.preDefinedStyles.keys;t<i.length;t++){var r=i[t];e+=this.documentHelper.preDefinedStyles.get(r)+","}return e.slice(0,-1)+"]}"},e.prototype.intializeDefaultStyles=function(){for(var e=this.owner.getStyleNames("Paragraph"),t=["Normal","Heading 1","Heading 2","Heading 3","Heading 4","Heading 5","Heading 6"],i=t.filter((function(t){return-1===e.indexOf(t)})),r=0,o=i;r<o.length;r++){var n=o[r];this.createStyle(this.documentHelper.preDefinedStyles.get(n))}},e.prototype.createStyle=function(e){this.createStyleIn(e)},e.prototype.createStyleIn=function(e){var t=JSON.parse(e),i=this.documentHelper.styles.findByName(t.name);return void 0!==i&&(t.name=this.getUniqueStyleName(t.name)),this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),t,this.documentHelper.styles),this.owner.notify(H.PC,{}),this.documentHelper.styles.findByName(t.name)},e.prototype.getUniqueStyleName=function(e){var t=this.getUniqueName(e),i=this.documentHelper.styles.findByName(t);while(!(0,a.le)(i))t=this.getUniqueStyleName(i.name),i=this.documentHelper.styles.findByName(t);return t},e.prototype.getUniqueName=function(e){var t=e.match(/\d+$/);return!(0,a.le)(t)&&t.length>0?e.replace(t[0],(parseInt(t[0],10)+1).toString()):e+"_1"},e.prototype.updateSelectionCharacterFormatting=function(e,t,i){switch((0,a.le)(e)&&(e="CharacterFormat"),e){case"bold":this.updateCharacterFormat("bold",t);break;case"italic":this.updateCharacterFormat("italic",t);break;case"fontColor":this.updateCharacterFormat("fontColor",t);break;case"fontFamily":this.updateCharacterFormat("fontFamily",t);break;case"fontSize":this.documentHelper.layout.isBidiReLayout=!1,this.updateCharacterFormatWithUp
1date(this.documentHelper.selection,"fontSize",t,i);break;case"highlightColor":this.updateCharacterFormat("highlightColor",t);break;case"baselineAlignment":this.updateCharacterFormat("baselineAlignment",t);break;case"strikethrough":this.updateCharacterFormat("strikethrough",t);break;case"underline":this.updateCharacterFormat("underline",t);break;case"styleName":this.updateCharacterFormatWithUpdate(this.documentHelper.selection,"styleName",t,!0,!0);break;case"CharacterFormat":this.updateCharacterFormat(void 0,t);break;case"ClearCharacterFormat":this.updateCharacterFormat(void 0,t);break;case"allCaps":this.updateCharacterFormat("allCaps",t);break}this.reLayout(this.documentHelper.selection)},e.prototype.updateCharacterFormat=function(e,t){this.updateCharacterFormatWithUpdate(this.documentHelper.selection,e,t,!1)},e.prototype.updateCharacterFormatWithUpdate=function(e,t,i,r,o){o=!(0,a.le)(o)&&o,this.documentHelper.owner.isShiftingEnabled=!0;var n=e.start,s=e.end;if(e.isEmpty||e.isForward||(n=e.end,s=e.start),e.isEmpty&&o){var l=n.offset,d=n.clone(),h=s.clone();this.selection.selectCurrentWord(),l!==this.selection.start.offset&&l!==this.selection.end.offset-1||(this.selection.start=d,this.selection.end=h)}this.applyCharFormatSelectedContent(n.paragraph,e,n,s,t,i,r)},e.prototype.applyCharFormatSelectedContent=function(e,t,i,r,o,n,s){if(!i.paragraph.isInsideTable||r.paragraph.isInsideTable&&i.paragraph.associatedCell===r.paragraph.associatedCell&&!t.isCellSelected(i.paragraph.associatedCell,i,r))this.applyCharFormat(e,t,i,r,o,n,s);else{var a=void 0;i.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.checkInsertPosition(t)&&this.updateHistoryPosition(i,!0),a=i.paragraph.associatedCell,this.applyCharFormatCell(a,t,i,r,o,n,s);var l=a.ownerTable;this.documentHelper.layout.layoutBodyWidgetCollection(l.index,l.containerWidget,l,!1)}},e.prototype.applyCharFormatForSelectedPara=function(e,t,i,r,o){for(var n=0;n<e.childWidgets.length;n++)for(var s=e.childWidgets[n],a=0;a<s.children.length;a++){var l=s.children[a];this.applyCharFormatValue(l.characterFormat,i,r,o)}this.applyCharFormatValue(e.characterFormat,i,r,o)},e.prototype.splittedLastParagraph=function(e){var t=e.getSplitWidgets();return t[t.length-1]},e.prototype.getNextParagraphForCharacterFormatting=function(e,t,i,r,n,s){var l=e.getSplitWidgets();e=l[l.length-1],e=this.documentHelper.selection.getNextRenderedBlock(e),(0,a.le)(e)||(e instanceof o.ZH?this.applyCharFormat(e,this.documentHelper.selection,t,i,r,n,s):this.applyCharFormatForTable(0,e,this.documentHelper.selection,t,i,r,n,s))},e.prototype.applyCharFormat=function(e,t,i,r,n,s,l){e=e.combineWidget(this.owner.viewer);var d=0,h=t.getParagraphLength(e),c=-1!==e.childWidgets.indexOf(i.currentWidget)?e.childWidgets.indexOf(i.currentWidget):0,p=r.offset,g=-1!==e.childWidgets.indexOf(r.currentWidget)?e.childWidgets.indexOf(r.currentWidget):e.childWidgets.length-1;if((0,a.le)(t)||e===i.paragraph&&(d=i.offset),e.equals(r.paragraph)){u=e.childWidgets[e.childWidgets.length-1];t.isParagraphLastLine(u)&&r.currentWidget===u&&(p===t.getLineLength(u)+1||t.isEmpty&&t.end.isAtParagraphEnd)&&this.applyCharFormatValue(e.characterFormat,n,s,l)}else{var u=e.childWidgets[e.childWidgets.length-1];"highlightColor"===n&&t.isParagraphLastLine(u)&&i.currentWidget===u&&i.offset===t.getLineLength(u)||this.applyCharFormatValue(e.characterFormat,n,s,l),p=h}for(var m=c;m<=g;m++){var f=e.childWidgets[m];m!==c&&(d=t.getStartLineOffset(f)),p=f===r.currentWidget?r.offset:t.getLineLength(f);for(var v=0,y=void 0,F=-1,H=!0,C=0;C<f.children.length;H?C++:C--){var w=f.children[C];if(!1,!(w instanceof o.no))if(y===w&&(y=void 0,C=F,F=-1,H=!0),d>=v+w.length)v+=w.length;else{var I=0;d>v&&(I=d-v);var b=p-v,W=w.length;b>W&&(b=W);var x=this.applyCharFormatInline(w,t,I,b,n,s,l);if(C+=x,p<=v+W)break;v+=W}}}var P=r.paragraph;this.documentHelper.layout.reLayoutParagraph(e,c,0),e.equals(P)||this.getNextParagraphForCharacterFormatting(e,i,r,n,s,l)},e.prototype.toggleBold=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode()){var e=this.getCurrentSelectionValue("bold");this.selection.characterFormat.bold=e}},e.prototype.toggleItalic=function(){if(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode()){var e=this.getCurrentSelectionValue("italic");this.selection.characterFormat.italic=e}},e.prototype.changeCase=function(e){if(!this.selection.isEmpty&&(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode())){this.initHistory("Uppercase"),this.documentHelper.owner.isShiftingEnabled=!0;var t=this.selection,i=t.start,r=t.end;
1t.isForward||(i=t.end,r=t.start),this.changeSelectedTextCase(t,i,r,e),this.reLayout(t)}},e.prototype.changeSelectedTextCase=function(e,t,i,r,o){var n=this.selection.getParagraphInfo(t);e.editPosition=this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString()),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.checkInsertPosition(e)&&this.updateHistoryPosition(t,!0);var s=this.editorHistory.isUndoing;s&&!(0,a.le)(o)&&o.length>0&&(this.removedTextNodes=o);var l=i.selection.endOffset;this.changeTextCase(t.paragraph,e,t,i,r,s),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(i.selection.endOffset!==l&&(i=e.getTextPosBasedOnLogicalIndex(l)),this.checkEndPosition(e)&&this.updateHistoryPosition(i,!1),e.selectPosition(t,i))},e.prototype.changeTextCase=function(e,t,i,r,o,n){if(!i.paragraph.isInsideTable||r.paragraph.isInsideTable&&i.paragraph.associatedCell===r.paragraph.associatedCell&&!t.isCellSelected(i.paragraph.associatedCell,i,r))this.changeCaseParagraph(e,t,i,r,o,n);else{var s=void 0;i.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.checkInsertPosition(t)&&this.updateHistoryPosition(i,!0),s=i.paragraph.associatedCell,this.changeCaseParaFormatInCell(s,i,r,o,n);var a=s.ownerTable;this.documentHelper.layout.layoutBodyWidgetCollection(a.index,a.containerWidget,a,!1)}},e.prototype.changeCaseParagraph=function(e,t,i,r,n,s){e=e.combineWidget(this.owner.viewer);var l=0,d=t.getParagraphLength(e),h=-1!==e.childWidgets.indexOf(i.currentWidget)?e.childWidgets.indexOf(i.currentWidget):0,c=r.offset,p=-1!==e.childWidgets.indexOf(r.currentWidget)?e.childWidgets.indexOf(r.currentWidget):e.childWidgets.length-1;(0,a.le)(t)||e===i.paragraph&&(l=i.offset),e.equals(r.paragraph)||(c=d);for(var g=h;g<=p;g++){var u=e.childWidgets[g];g!==h&&(l=t.getStartLineOffset(u)),c=u===r.currentWidget?r.offset:t.getLineLength(u);for(var m=0,f=void 0,v=-1,y=!0,F=0;F<u.children.length;y?F++:F--){var H=u.children[F];if(!1,!(H instanceof o.no))if(f===H&&(f=void 0,F=v,v=-1,y=!0),l>=m+H.length)m+=H.length;else{var C=0;l>m&&(C=l-m);var w=c-m,I=H.length;w>I&&(w=I);var b=this.changeCaseInline(H,t,C,w,n,s);if(F+=b,c<=m+I)break;m+=I}}}var W=r.paragraph;this.documentHelper.layout.reLayoutParagraph(e,h,0),e.equals(W)||this.changeCaseNextBlock(e,i,r,n,s)},e.prototype.changeCaseInline=function(e,t,i,r,n,s){if(e instanceof o.a3){if(0!==i||r!==e.length)return this.changeCaseInlineInternal(e,t,i,r,n,s);this.changeCaseInlineInternal(e,t,i,r,n,s)}return 0},e.prototype.addRemovedTextNodes=function(e,t){if(e instanceof o.a3&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)){var i=this.editorHistory.currentBaseHistoryInfo.removedNodes[0];(0,a.le)(i)&&(i=new o.a3,i.text="",this.editorHistory.currentBaseHistoryInfo.removedNodes.push(i)),i.text+=t}},e.prototype.changeCaseInlineInternal=function(e,t,i,r,n,s){var a,l=0,d=e.line.children.indexOf(e),h=e.paragraph;h.childWidgets.indexOf(e.line);if(i>0){var c=e.text.substr(i,r-i);this.addRemovedTextNodes(e,c),a=new o.a3,a.characterFormat.copyFormat(e.characterFormat),a.line=e.line,a.text=this.getChangeCaseText(c,n,s),a.isRightToLeft=e.isRightToLeft,d++,e.line.children.splice(d,0,a),l++}r<e.length&&(a=new o.a3,a.characterFormat.copyFormat(e.characterFormat),a.text=e.text.substring(r),a.line=e.line,a.isRightToLeft=e.isRightToLeft,d++,e.line.children.splice(d,0,a),l++);var p=e;if(0===i){var g=p.text.substr(0,r);this.addRemovedTextNodes(e,g),p.text=this.getChangeCaseText(g,n,s)}else{var u=p.text.substr(0,i);p.text=u}return l},e.prototype.changeCaseNextBlock=function(e,t,i,r,n){e=this.getNextBlockForChangeCase(e,t,i,r,n),(0,a.le)(e)||(e instanceof o.ZH?this.changeCaseParagraph(e,this.documentHelper.selection,t,i,r,n):this.changeCaseForTable(0,e,this.documentHelper.selection,t,i,r,n))},e.prototype.getNextBlockForChangeCase=function(e,t,i,r,o){var n=e.getSplitWidgets();return e=n[n.length-1],e=this.documentHelper.selection.getNextRenderedBlock(e),e},e.prototype.getChangeCaseText=function(e,t,i){if(i){if(!(0,a.le)(this.removedTextNodes)&&this.removedTextNodes.length>0){var r=this.removedTextNodes[0],o=r.text.substr(0,e.length);r.text=r.text.substr(o.length,r.length-o.length),e=o,""===r.text&&this.removedTextNodes.splice(0,1)}}else switch(t){case"Uppercase":e=e.toUpperCase();break;default:break}return e},e.prototype.changeCaseForTable=function(e,t,i,r,o,n,s){t=t.combineWidget(this.owner.viewer);for(var a=e;a<t.childWidgets.length;a++){for(var l=t.childWidgets[a],d=0;d<l.childWidgets.length;d++)this.changeCaseForSelectedCell(l.childWidgets[d],i,n,s);if(o.paragraph.isInsideTable&&i.containsRow(l,o.paragraph.associatedCell))return void this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1)}this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1),this.changeCaseNextBlock(t,r,o,n,s)},e.prototype.changeCaseForSelectedCell=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];s instanceof o.ZH?this.changeCaseForSelectedPara(s,t,i,r):this.changeCaseForSelTable(s,t,i,r)}},e.prototype.changeCaseForSelectedPara=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++)for(var s=e.childWidgets[n],l=0;l<s.children.length;l++){var d=s.children[l];!(0,a.le)(d)&&d instanceof o.a3&&(this.addRemovedTextNodes(d,d.text),d.text=this.getChangeCaseText(d.text,i,r))}},e.prototype.changeCaseForSelTable=function(e,t,i,r){for(var o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++)this.changeCaseForSelectedCell(n.childWidgets[s],t,i,r)},e.prototype.changeCaseParaFormatInCell=function(e,t,i,r,o){var n=this.documentHelper.selection;if(i.paragraph.isInsideTable){var s=n.getContainerCellOf(e,i.paragraph.associatedCell);if(s.ownerTable.contains(i.paragraph.associatedCell)){var a=n.get
1SelectedCell(e,s),l=n.getSelectedCell(i.paragraph.associatedCell,s);n.containsCell(s,i.paragraph.associatedCell)?n.isCellSelected(s,t,i)?this.changeCaseParaForCellInternal(s,n,r,o):a===s?this.changeCaseParagraph(t.paragraph,n,t,i,r,o):this.changeCaseParaForRow(a.ownerRow,n,t,i,r,o):this.changeCaseParaForTableCell(s.ownerTable,s,l,r,o)}else this.changeCaseParaForRow(s.ownerRow,n,t,i,r,o)}else{var d=n.getContainerCell(e);this.changeCaseParaForRow(d.ownerRow,n,t,i,r,o)}},e.prototype.changeCaseParaForTableCell=function(e,t,i,r,o){var n=this.documentHelper.selection,s=n.getCellLeft(t.ownerRow,t),a=s+t.cellFormat.cellWidth,l=n.getCellLeft(i.ownerRow,i),d=l+i.cellFormat.cellWidth,h=this.updateSelectedCellsInTable(s,a,l,d);s=h.start,a=h.end;for(var c=e.childWidgets.indexOf(i.ownerRow),p=e.childWidgets.indexOf(t.ownerRow);p<=c;p++)for(var g=e.childWidgets[p],u=0;u<g.childWidgets.length;u++){var m=n.getCellLeft(g,g.childWidgets[u]);Math.round(s)<=Math.round(m)&&Math.round(m)<Math.round(a)&&this.changeCaseParaForCellInternal(g.childWidgets[u],n,r,o)}},e.prototype.changeCaseParaForCellInternal=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];s instanceof o.ZH?this.changeCaseForSelectedPara(s,t,i,r):this.changeCaseParaFormatTableInternal(s,t,i,r)}},e.prototype.changeCaseParaFormatTableInternal=function(e,t,i,r){for(var o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++)this.changeCaseParaForCellInternal(n.childWidgets[s],t,i,r)},e.prototype.changeCaseParaForRow=function(e,t,i,r,o,n){for(var s=e.rowIndex;s<e.ownerTable.childWidgets.length;s++){for(var a=e.ownerTable.childWidgets[s],l=0;l<a.childWidgets.length;l++)this.changeCaseParaForCellInternal(a.childWidgets[l],t,o,n);if(r.paragraph.isInsideTable&&this.documentHelper.selection.containsRow(a,r.paragraph.associatedCell))return}this.changeCaseNextBlock(e.ownerTable,i,r,o,n)},e.prototype.toggleAllCaps=function(){if(!this.documentHelper.owner.isReadOnlyMode||this.selection.isInlineFormFillMode()){var e=this.getCurrentSelectionValue("allCaps");this.selection.characterFormat.allCaps=e}},e.prototype.getCurrentSelectionValue=function(e){var t=!1;if("bold"===e||"italic"===e){var i=this.getSelectedCharacterFormat();"bold"===e&&(t=!i.bold),"italic"===e&&(t=!i.italic)}return t},e.prototype.getSelectedCharacterFormat=function(){var e=0,t=this.selection.start;this.selection.isForward||(t=this.selection.end);var i=t.currentWidget,r=i.getInline(t.offset,e),o=r.element;e=r.index;var n=i.paragraph.characterFormat;if(!(0,a.le)(o))if(this.selection.isEmpty&&"List"===this.selection.contextType){var s=this.selection.getListLevel(this.selection.start.paragraph);s.characterFormat.uniqueCharacterFormat&&(n=s.characterFormat)}else n=this.selection.isEmpty||e!==o.length?o.characterFormat:(0,a.le)(o.nextNode)?i.paragraph.characterFormat:o.nextNode.characterFormat;return n},e.prototype.toggleUnderline=function(e){(!this.owner.isReadOnlyMode&&!this.restrictFormatting||this.selection.isInlineFormFillMode())&&this.updateProperty(1,e)},e.prototype.toggleStrikethrough=function(e){if(!this.owner.isReadOnlyMode||this.selection.isInlineFormFillMode()){var t=void 0;t=(0,a.le)(e)?"SingleStrike"===this.selection.characterFormat.strikethrough?"None":"SingleStrike":e,this.selection.characterFormat.strikethrough=t}},e.prototype.updateFontSize=function(e,t){if("number"===typeof t&&!(t<0&&1===e.fontSize))return e.fontSize+t;var i=[8,9,10,11,12,14,16,18,20,24,26,28,36,48,72];if("string"===typeof t&&"increment"===t){if(e.fontSize<8)return e.fontSize+1;if(e.fontSize>=72&&e.fontSize<80)return 80;if(e.fontSize>=80)return e.fontSize+10;for(var r=0;r<i.length;r++)if(e.fontSize<i[r])return i[r]}else if("string"===typeof t&&"decrement"===t&&e.fontSize>1){if(e.fontSize<=8)return e.fontSize-1;if(e.fontSize>72&&e.fontSize<=80)return 72;if(e.fontSize>80)return e.fontSize-10;for(r=0;r<i.length;r++)if(e.fontSize<=i[r])return i[r-1]}return e.fontSize},e.prototype.applyCharFormatInline=function(e,t,i,r,n,s,a){return 0===i&&r===e.length?(this.applyCharFormatValue(e.characterFormat,n,s,a),0):e instanceof o.a3?this.formatInline(e,t,i,r,n,s,a):0},e.prototype.formatInline=function(e,t,i,r,n,s,a){var l,d=0,h=e,c=e.line.children.indexOf(h),p=(e.paragraph,0);return i>0&&(p+=1,l=new o.a3,l.characterFormat.copyFormat(e.characterFormat),l.line=e.line,l.text=e.text.substr(i,r-i),l.isRightToLeft=e.isRightToLeft,this.applyCharFormatValue(l.characterFormat,n,s,a),c++,h.line.children.splice(c,0,l),d++,this.updateRevisionForFormattedContent(e,l,p)),r<h.length&&(p+=1,l=new o.a3,l.characterFormat.copyFormat(e.characterFormat),l.text=h.text.substring(r),l.line=e.line,l.isRightToLeft=e.isRightToLeft,c++,h.line.children.splice(c,0,l),d++,this.updateRevisionForFormattedContent(e,l,p)),0===i?(e.text=e.text.substr(0,r),this.applyCharFormatValue(e.characterFormat,n,s,a)):e.text=e.text.substr(0,i),d},e.prototype.updateRevisionForFormattedContent=function(e,t,i){for(var r=0;r<e.revisions.length;r++){var o=e.revisions[r],n=o.range.indexOf(e)+i;t.revisions.splice(0,0,o),o.range.splice(n,0,t)}},e.prototype.applyCharFormatCell=function(e,t,i,r,o,n,s){if(r.paragraph.isInsideTable){var a=t.getContainerCellOf(e,r.paragraph.associatedCell);if(a.ownerTable.contains(r.paragraph.associatedCell)){var l=t.getSelectedCell(e,a),d=t.getSelectedCell(r.paragraph.associatedCell,a);t.containsCell(a,r.paragraph.associatedCell)?t.isCellSelected(a,i,r)?(n=this.getCharacterFormatValueOfCell(e,t,n,o),this.applyCharFormatForSelectedCell(a,t,o,n,s)):l===a?this.applyCharFormat(i.paragraph,t,i,r,o,n,s):this.applyCharFormatRow(l.ownerRow,t,i,r,o,n,s):this.applyCharFormatForTableCell(a.ownerTable,t,a,d,o,n,s)}else this.applyCharFormatRow(a.ownerRow,t,i,r,o,n,s)}else{var h=t.getContainerCell(e);this.applyCharFormatRow(h.ownerRow,t,i,r,o,n,s)}},e.prototype.applyCharFormatForSelectedCell=function(e,t,i,r,n){for(var s=0;s<e.childWidgets.length;s++){var a=e.childWidgets[s];a instanceof o.ZH?this.applyCharFormatForSelectedPara(a,t,i,r,n):this.applyCharFormatForSelTable(a,t,i,r,n)}},e.prototype.applyCharFormatRow=function(e,t,i,r,o,n,s){n=this.getCharacterFormatValueOfCell(e.childWidgets[0],t,n,o),this.applyCharFormatForTable(e.rowIndex,e.ownerTable,t,i,r,o,n,s)},e.prototype.applyCharFormatForTable=function(e,t,i,r,o,n,s,a){t=t.combineWidget(this.owner.viewer);for(var l=e;l<t.childWidgets.length;l++){for(var d=t.childWidgets[l],h=0;h<d.childWidgets.length;h++)this.applyCharFormatForSelectedCell(d.childWidgets[h],i,n,s,a);if(o.paragraph.isInsideTable&&i.containsRow(d,o.paragraph.associatedCell))return void this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1)}this.documentHelper.layout.layoutBodyWidgetCollection(t.index,t.containerWidget,t,!1),this.getNextParagraphForCharacterFormatting(t,r,o,n,s,a)},e.prototype.applyCharFormatForSelTable=function(e,t,i,r,o){for(var n=0;n<e.childWidgets.length;n++)for(var s=e.childWidgets[n],a=0;a<s.childWidgets.length;a++)this.applyCharFormatForSelectedCell(s.childWidgets[a],t,i,r,o)},e.prototype.applyCharFormatForTableCell=function(e,t,i,r,o,n,a){var l=t.getCellLeft(i.ownerRow,i),d=l+i.cellFormat.cellWidth,h=t.getCellLeft(r.ownerRow,r),c=h+r.cellFormat.cellWidth,p=this.updateSelectedCellsInTable(l,d,h,c);l=p.start,d=p.end;for(var g=e.childWidgets.indexOf(r.ownerRow),u=!1,m=e.childWidgets.indexOf(i.ownerRow);m<=g;m++)for(var f=e.childWidgets[m],v=0;v<f.childWidgets.length;v++){var y=t.getCellLeft(f,f.childWidgets[v]);s.o_.round(l,2)<=s.o_.round(y,2)&&s.o_.round(y,2)<s.o_.round(d,2)&&(u||(n=this.getCharacterFormatValueOfCell(f.childWidgets[v],t,n,o),u=!0),this.applyCharFormatForSelectedCell(f.childWidgets[v],t,o,n,a))}},e.prototype.updateSelectedCellsInTable=function(e,t,i,r){var o=this.documentHelper.selection;return e>i&&(e=i),t<r&&(t=r),e>o.upDownSelectionLength&&(e=o.upDownSelectionLength),t<o.upDownSelectionLength&&(t=o.upDownSelectionLength),{start:e,end:t}},e.prototype.getCharacterFormatValueOfCell=function(e,t,i,r){if("boolean"===typeof i||void 0===i&&("bold"===r||"italic"===r)){var o=t.getFirstParagraph(e),n=o.characterFormat;o.childWidgets.length>0&&o.childWidgets[0].children.length>0&&(n=o.childWidgets[0].children[0].characterFormat),i=!n.getPropertyValue(r)}return i},e.prototype.applyCharFormatValueInternal=function(e,t,i,r){this.applyCharFormatValue(t,i,r,!1)},e.prototype.copyInlineCharacterFormat=function(e,t){t.uniqueCharacterFormat=e.uniqueCharacterFormat,t.baseCharStyle=e.baseCharStyle},e.prototype.applyCharFormatValue=function(e,t,i,r){if(r&&"fontSize"===t&&(i=this.updateFontSize(e,i)),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(i=this.editorHistory.currentBaseHistoryInfo.addModifiedProperties(e,t,i)),i instanceof n.a)this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)?this.copyInlineCharacterFormat(i,e):e.copyFormat(i);else{if(this.isForHyperlinkFormat&&this.owner.enableTrackChanges&&e.ownerBase instanceof o.nR){var s=e.ownerBase,l=s.previousNode;if((0,a.le)(l)){var d=s.paragraph.previousWidget;if(!(0,a.le)(d)&&!d.isEmpty()){var h=d.lastChild;l=h.children[h.children.length-1]}}while(!(0,a.le)(l)&&!(l instanceof o.a3))l=l.previousNode;if(!(0,a.le)(l)&&l.revisions.length>0){var c=l.revisions[l.revisions.length-1];this.isRevisionAlreadyIn(s,c)||(s.revisions.push(c),c.range.push(s))}else this.insertRevision(s,"Insertion")}(0,a.le)(i)?e.clearFormat():"bold"===t?e.bold=i:"italic"===t?e.italic=i:"fontColor"===t?e.fontColor=i:"fontFamily"===t?(e.fontFamily=i,e.fontFamilyAscii=i,e.fontFamilyFarEast=i,e.fontFamilyNonFarEast=i,e.fontFamilyBidi=i):"fontSize"===t?e.fontSize=i:"highlightColor"===t?e.highlightColor=i:"baselineAlignment"===t?e.baselineAlignment=i:"strikethrough"===t?e.strikethrough=i:"underline"===t?e.underline=i:"styleName"===t?e.baseCharStyle=i:"allCaps"===t&&(e.allCaps=i)}},e.prototype.onImageFormat=function(e,t,i){var o=new r.AE(e);this.editorHistory&&(this.editorHistory.initializeHistory("ImageResizing"),this.editorHistory.currentBaseHistoryInfo.modifiedProperties.push(o)),this.setOffsetValue(this.selection),e.width=t,e.height=i,this.documentHelper.layout.reLayoutParagraph(e.line.paragraph,e.line.indexInOwner,0),this.reLayout(this.selection,!1),this.documentHelper.owner.imageResizerModule&&this.documentHelper.owner.imageResizerModule.positionImageResizer(e)},e.prototype.toggleTextAlignment=function(e){this.documentHelper.owner.isReadOnlyMode&&!this.selection.isInlineFormFillMode()||!this.documentHelper.owner.isDocumentLoaded||((0,a.le)(this.documentHelper.selection.paragraphFormat.textAlignment)||this.documentHelper.selection.paragraphFormat.textAlignment!==e?this.onApplyParagraphFormat("textAlignment",e,!1,!0):"Left"===e?this.onApplyParagraphFormat("textAlignment","Justify",!1,!0):this.onApplyParagraphFormat("textAlignment","Left",!1,!0))},e.prototype.setPreviousBlockToLayout=function(){var e=this.documentHelper.selection.start;this.documentHelper.selection.isForward||(e=this.documentHelper.selection.end);var t=e.paragraph;if(t.paragraphFormat.keepWithNext){var i=t.bodyWidget;if(!(0,a.le)(i)&&i instanceof o.VB&&i.page){var r=i.page.previousPage;r&&(this.previousBlockToLayout=r.bodyWidgets[0].lastChild)}}},e.prototype.applyParagraphBorders=function(e,t,i){var r=new g.V;switch(e){case"color":r.color=i;break;case"lineWidth":r.lineWidth=i;break;case"lineStyle":r.lineStyle=i;break;case"shadow":r.shadow=i;break;case"space":r.space=i;break}this.onApplyParagraphFormat(t,r,!1,!1)},e.prototype.onApplyParagraphFormat=function(e,t,i,r){var o=this.documentHelper.isFormFillProtectedMode&&this.documentHelper.selection.isInlineFormFillMode()&&this.allowFormattingInFormFields(e);if(!this.restrictFormatting||o){this.setPreviousBlockToLayout();var n="bidi"===e?"ParagraphBidi":e[0].toUpperCase()+e.slice(1);this.documentHelper.owner.isShiftingEnabled=!0;var l=this.documentHelper.selection,d=l.start.paragraph,h=!1;if(l.isForward||(d=l.end.paragraph),"leftIndent"==e&&(h=this.isFirstParaForList(l,d)),t<=0&&"leftIndent"==e){var c=s.o_.convertPointToPixel(t);if(d.x+c<this.viewer.clientArea.x)return}if(this.initHistory(n),(!this.owner.isReadOnlyMode||o)&&this.owner.isDocumentLoaded)if("leftIndent"!==e||(0,a.le)(l.paragraphFormat.listId)||-1===l.paragraphFormat.listId||!i){var p=!(t instanceof I.l2&&"styleName"==e&&l.isEmpty);if(p&&l.isEmpty){this.setOffsetValue(l);var g=l.paragraphFormat.bidi&&("listFormat"===e||-1!==l.paragraphFormat.listId);g||(this.documentHelper.layout.isBidiReLayout=!0),i&&"leftIndent"===e&&(t=this.getIndentIncrementValue(l.start.paragraph,t));var u=l.start.paragraph;this.documentHelper.layout;u=u.combineWidget(this.owner.viewer),this.applyParaFormatProperty(u,e,t,i),this.layoutItemBlock(u,!1)}else"ParagraphBidi"!==n&&this.setOffsetValue(l),this.updateSelectionParagraphFormatting(e,t,i);this.reLayout(l)}else h?this.updateListLevelIndent(t,d):this.updateListLevel(t>0)}},e.prototype.updateListLevelIndent=function(e,t){var i,r=this.documentHelper.getListById(t.paragraphFormat.listFormat.listId),o=this.documentHelper.getAbstractListById(r.abstractListId);if(this.initHistory("List"),e<0&&o.levels[0].paragraphFormat.leftIndent+e<=0&&(e=18-o.levels[0].paragraphFormat.leftIndent),0!=e){for(var n=0;n<o.levels.length;n++)this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForList(o.levels[n]),i=o.levels[n],i.paragraphFormat.leftIndent+=e;this.documentHelper.owner.isShiftingEnabled=!0,this.layoutWholeDocument(),this.documentHelper.owner.isShiftingEnabled=!1}},e.prototype.isFirstParaForList=function(e,t){var i=!1;if(!(0,a.le)(e.paragraphFormat.listId)&&-1!==e.paragraphFormat.listId&&0===t.paragraphFormat.listFormat.listLevelNumber){var r=this.updateWholeListItems(t,!0,e.paragraphFormat.listId);(0,a.le)(r)&&(i=!0)}return i},e.prototype.updateListLevel=function(e){var t,i=this.documentHelper,r=(this.documentHelper.selection.start.paragraph.paragraphFormat.listFormat,this.documentHelper.selection.start.paragraph.paragraphFormat),o=i.getListById(r.listFormat.listId);i.layout.getListLevel(o,r.listFormat.listLevelNumber);t=e?r.listFormat.listLevelNumber+1:r.listFormat.listLevelNumber-1;var n=i.layout.getListLevel(o,t);(0,a.le)(n)||(this.onApplyListInternal(o,t),i.selection.start.updatePhysicalPosition(!0),i.selection.end.updatePhysicalPosition(!0),i.selection.updateCaretPosition())},e.prototype.onApplyListInternal=function(e,t){var i=new u.s;!(0,a.le)(e)&&t>=0&&t<9&&(i.listId=e.listId,i.listLevelNumber=t),this.onApplyParagraphFormat("listFormat",i,!1,!1)},e.prototype.updateSelectionParagraphFormatting=function(e,t,i){var r=this.documentHelper.selection;"leftIndent"===e&&i&&(t=!(0,a.le)(r.start)&&r.start.isExistBefore(r.end)?this.getIndentIncrementValue(r.start.paragraph,t):this.getIndentIncrementValue(r.end.paragraph,t)),this.updateParagraphFormatInternal(e,t,i)},e.prototype.getIndentIncrementValue=function(e,t){var i=e.paragraphFormat.leftIndent;if(i<0){if(t<0||i+t>=0)return-i;var r=-this.getIndentIncrementValueInternal(-i,-t);return r%t===0?r:r+t}return this.getIndentIncrementValueInternal(i,t)},e.prototype.getIndentIncrementValueInternal=function(e,t){var i=Math.abs(t);if(0===e||0===i)return t>0?i:0;var r=100*Math.round(e)%(100*Math.round(i))/100,o=(Math.round(e)-r)/Math.round(i),n=o*i;return t>0&&(n+=i),n-e===0?t:n-e},e.prototype.updateParagraphFormatInternal=function(e,t,i){switch((0,a.le)(e)&&(e="ParagraphFormat"),e){case"afterSpacing":this.updateParagraphFormat("afterSpacing",t,!1);break;case"beforeSpacing":this.updateParagraphFormat("beforeSpacing",t,!1);break;case"spaceAfterAuto":this.updateParagraphFormat("spaceAfterAuto",t,!1);break;case"spaceBeforeAuto":this.updateParagraphFormat("spaceBeforeAuto",t,!1);break;case"rightIndent":this.updateParagraphFormat("rightIndent",t,!1);break;case"leftIndent":this.updateParagraphFormat("leftIndent",t,i);break;case"firstLineIndent":this.updateParagraphFormat("firstLineIndent",t,!1);break;case"lineSpacing":this.updateParagraphFormat("lineSpacing",t,!1);break;case"lineSpacingType":this.updateParagraphFormat("lineSpacingType",t,!1);break;case"textAlignment":this.updateParagraphFormat("textAlignment",t,!1);break;case"borders":case"topBorder":case"bottomBorder":case"leftBorder":case"rightBorder":case"horizontalBorder":case"vertic
1alBorder":this.updateParagraphFormat(e,t,!1);break;case"listFormat":this.updateParagraphFormat("listFormat",t,!1);break;case"ParagraphFormat":this.updateParagraphFormat(void 0,t,!1);break;case"styleName":this.updateParagraphFormat("styleName",t,!1);break;case"ClearParagraphFormat":this.updateParagraphFormat(void 0,t,!1);break;case"bidi":var r=-1!==this.selection.paragraphFormat.listId;r||(this.documentHelper.layout.isBidiReLayout=!0),this.updateParagraphFormat("bidi",t,!1),r||(this.documentHelper.layout.isBidiReLayout=!1);break;case"contextualSpacing":this.updateParagraphFormat("contextualSpacing",t,!1);break}},e.prototype.updateParagraphFormat=function(e,t,i){var r=this.documentHelper.selection,o=r.start,n=r.end;r.isForward||(o=r.end,n=r.start),this.applyParaFormatSelectedContent(o,n,e,t,i)},e.prototype.applyParaFormatSelectedContent=function(e,t,i,r,o){var n=this.documentHelper.selection;if(!e.paragraph.isInsideTable||t.paragraph.isInsideTable&&e.paragraph.associatedCell===t.paragraph.associatedCell&&!n.isCellSelected(e.paragraph.associatedCell,e,t)){if(!(0,a.le)(r)&&!this.selection.isEmpty&&"styleName"===i&&this.applyCharacterStyle(e.paragraph,e,t,i,r,o))return;this.applyParaFormat(e.paragraph,e,t,i,r,o)}else{var s=void 0;e.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.checkInsertPosition(n)&&this.updateHistoryPosition(e,!0),s=e.paragraph.associatedCell,this.applyParaFormatInCell(s,e,t,i,r,o);var l=s.ownerTable;this.documentHelper.layout.layoutBodyWidgetCollection(l.index,l.containerWidget,l,!1)}},e.prototype.applyParaFormatProperty=function(e,t,i,r){var o=e.paragraphFormat;if(r&&"leftIndent"===t&&(i=o.leftIndent+i),"listFormat"===t&&i instanceof u.s){var n=i;n.hasValue("listLevelNumber")||(n.listLevelNumber=o.listFormat.listLevelNumber)}if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(i=this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForParagraphFormat(o,t,i)),i instanceof h.h&&((0,a.le)(t)?this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)?this.copyParagraphFormat(i,o):o.copyFormat(i):"listFormat"===t&&(o.listFormat=i.listFormat,o.listFormat.ownerBase=o)),(0,a.le)(i))return o.clearFormat(),void this.documentHelper.layout.reLayoutParagraph(o.ownerBase,0,0);if("afterSpacing"===t)o.afterSpacing=i;else if("beforeSpacing"===t)o.beforeSpacing=i;else if("leftIndent"===t)o.leftIndent=i;else if("lineSpacingType"===t)o.lineSpacingType=i;else if("lineSpacing"===t)o.lineSpacing=i;else if("rightIndent"===t)o.rightIndent=i;else if("firstLineIndent"===t)o.firstLineIndent=i;else if("textAlignment"===t){var s=i;!o.bidi||this.editorHistory.isUndoing||this.editorHistory.isRedoing||("Left"===s?s="Right":"Right"===s&&(s="Left")),o.textAlignment=s}else if("topBorder"===t)this.applyBorder(o.borders.top,i);else if("bottomBorder"===t)this.applyBorder(o.borders.bottom,i);else if("leftBorder"===t)this.applyBorder(o.borders.left,i);else if("rightBorder"===t)this.applyBorder(o.borders.right,i);else if("horizontalBorder"===t)this.applyBorder(o.borders.horizontal,i);else if("verticalBorder"===t)this.applyBorder(o.borders.vertical,i);else if("borders"===t)o.borders.copyFormat(i);else if("styleName"===t)"string"===typeof i&&(i=this.documentHelper.styles.findByName(i)),o.applyStyle(i);else{if("listFormat"===t)return i instanceof h.h&&(i=i.listFormat),o.listFormat.copyFormat(i),this.documentHelper.layout.clearListElementBox(o.ownerBase),o.listFormat.listId>=0&&o.clearIndent(),void this.layoutItemBlock(o.ownerBase,!1);"bidi"===t?o.bidi=i:"keepWithNext"===t?o.keepWithNext=i:"keepLinesTogether"===t?o.keepLinesTogether=i:"widowControl"===t?o.widowControl=i:"contextualSpacing"===t?o.contextualSpacing=i:"spaceAfterAuto"===t?o.spaceAfterAuto=i:"spaceBeforeAuto"===t&&(o.spaceBeforeAuto=i)}},e.prototype.copyParagraphFormat=function(e,t){t.uniqueParagraphFormat=e.uniqueParagraphFormat,t.listFormat=e.listFormat,t.listFormat.ownerBase=t,t.baseStyle=e.baseStyle},e.prototype.copyFromListLevelParagraphFormat=function(e,t){(0,a.le)(t.leftIndent)||(e.leftIndent=t.leftIndent),(0,a.le)(t.firstLineIndent)||(e.firstLineIndent=t.firstLineIndent)},e.prototype.applyContinueNumbering=function(){var e=this.selection;this.editorHistory&&this.editorHistory.initializeHistory("ContinueNumbering"),this.applyContinueNumberingInternal(e)},e.prototype.applyContinueNumberingInternal=function(e){var t=e.start.paragraph,i=this.getContinueNumberingInfo(t),r=this.getParagraphFormat(t,i.listLevelNumber,i.listPattern);this.changeListId(i.currentList,t,r,i.listLevelNumber,i.listPattern),this.reLayout(e,!1),this.documentHelper.updateFocus()},e.prototype.getContinueNumberingInfo=function(e){var t=void 0,i=0,r="None";(0,a.le)(e.paragraphFormat)||(0,a.le)(e.paragraphFormat.listFormat)||(t=this.documentHelper.getListById(e.paragraphFormat.listFormat.listId),i=e.paragraphFormat.listFormat.listLevelNumber);var o=this.documentHelper;if(0!==i&&!(0,a.le)(t)&&!(0,a.le)(o.getAbstractListById(t.abstractListId))&&!(0,a.le)(o.getAbstractListById(t.abstractListId).levels[i])){var n=this.documentHelper.layout.getListLevel(t,i);(0,a.le)(n)||(r=n.listLevelPattern)}return{currentList:t,listLevelNumber:i,listPattern:r}},e.prototype.revertContinueNumbering=function(e,t){var i=e.start.paragraph,r=this.getContinueNumberingInfo(i);this.changeListId(r.currentList,i,t,r.listLevelNumber,r.listPattern),this.reLayout(e,!1),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.editorHistory.updateHistory()},e.prototype.changeListId=function(e,t,i,r,n){if(!(0,a.le)(t)){if(t instanceof o.ZH&&e.listId===t.paragraphFormat.listFormat.listId&&r===t.paragraphFormat.listFormat.listLevelNumber){if(this.editorHistory){var s=this.editorHistory.currentBaseHistoryInfo;(0,a.le)(s)||(i=s.addModifiedPropertiesForContinueNumbering(t.paragraphFormat,i))}t.paragraphFormat.copyFormat(i),this.documentHelper.layout.reLayoutParagraph(t,0,0)}return this.changeListId(e,t.nextRenderedWidget,i,r,n)}},e.prototype.getParagraphFormat=function(e,t,i){if(!(0,a.le)(e.previousRenderedWidget)&&e.previousRenderedWidget instanceof o.ZH){if((0,a.le)(e.previousRenderedWidget.paragraphFormat.listFormat)||-1===e.previousRenderedWidget.paragraphFormat.listFormat.listId)return this.getParagraphFormat(e.previousRenderedWidget,t,i);var r=this.selection.getListLevel(e.previousRenderedWidget);return 0===t||i===r.listLevelPattern||this.checkNumberArabic(i,r.listLevelPattern)?e.previousRenderedWidget.paragraphFormat:this.getParagraphFormat(e.previousRenderedWidget,t,i)}},e.prototype.checkNumberArabic=function(e,t){return"Number"===e&&"Arabic"===t||"Number"===t&&"Arabic"===e},e.prototype.applyRestartNumbering=function(e){this.editorHistory&&this.editorHistory.initializeHistory("RestartNumbering"),this.restartListAt(e)},e.prototype.restartListAt=function(e){var t=e.paragraphFormat.getList(),i=t.clone();i.listId=this.documentHelper.lists[this.documentHelper.lists.length-1].listId+1,this.documentHelper.lists.push(i);var r=t.abstractList.clone();r.abstractListId=this.documentHelper.abstractLists[this.documentHelper.abstractLists.length-1].abstractListId+1,i.abstractListId=r.abstractListId,i.abstractList=r,this.documentHelper.abstractLists.push(r),this.restartListAtInternal(e,i.listId)},e.prototype.restartListAtInternal=function(e,t){var i=this.getContinueNumberingInfo(e.start.paragraph);this.changeRestartNumbering(i.currentList,e.start.paragraph,t),this.reLayout(e,!1),this.documentHelper.updateFocus()},e.prototype.changeRestartNumbering=function(e,t,i){if(!(0,a.le)(t)){if(t instanceof o.ZH&&e.listId===t.paragraphFormat.listFormat.listId){if(this.editorHistory){var r=this.editorHistory.currentBaseHistoryInfo;(0,a.le)(r)||(i=r.addModifiedPropertiesForRestartNumbering(t.paragraphFormat.listFormat,i))}t.paragraphFormat.listFormat.listId=i,this.documentHelper.layout.reLayoutParagraph(t,0,0)}return this.changeRestartNumbering(e,t.nextRenderedWidget,i)}},e.prototype.applyParaFormat=function(e,t,i,r,o,n){this.setOffsetValue(this.selection),e=e.combineWidget(this.owner.viewer),this.applyParaFormatProperty(e,r,o,n),this.layoutItemBlock(e,!1),this.getOffsetValue(this.selection),e.equals(i.paragraph)||this.getNextParagraphForFormatting(e,t,i,r,o,n)},e.prototype.applyCharacterStyle=function(e,t,i,r,o,n){var s=e.getSplitWidgets(),a=i.owner.selection,l=i.currentWidget,d=0===t.offset&&(a.isParagraphLastLine(l)&&i.currentWidget===l&&i.offset===a.getLineLength(l)+1||i.isAtParagraphEnd);if(!d&&(i.paragraph===e||-1!==s.indexOf(i.paragraph))&&("Paragraph"===o.type&&o.link instanceof I.l2||"Character"===o.type)){var h="Character"===o.type?o:o.link;return this.updateSelectionCharacterFormatting(r,h,n),!0}return!1},e.prototype.applyParaFormatInCell=function(e,t,i,r,o,n){var s=this.documentHelper.selection;if(i.paragraph.isInsideTable){var a=s.getContainerCellOf(e,i.paragraph.associatedCell);if(a.ownerTable.contains(i.paragraph.associatedCell)){var l=s.getSelectedCell(e,a),d=s.get
1SelectedCell(i.paragraph.associatedCell,a);s.containsCell(a,i.paragraph.associatedCell)?s.isCellSelected(a,t,i)?(o=this.getParaFormatValueInCell(a,r,o),this.applyParaFormatCellInternal(a,r,o,n)):l===a?this.applyParaFormat(t.paragraph,t,i,r,o,n):this.applyParagraphFormatRow(l.ownerRow,t,i,r,o,n):this.applyParaFormatTableCell(a.ownerTable,a,d,r,o,n)}else this.applyParagraphFormatRow(a.ownerRow,t,i,r,o,n)}else{var h=s.getContainerCell(e);this.applyParagraphFormatRow(h.ownerRow,t,i,r,o,n)}},e.prototype.applyParaFormatCellInternal=function(e,t,i,r){for(var n=0;n<e.childWidgets.length;n++){var s=e.childWidgets[n];s instanceof o.ZH?this.applyParaFormatProperty(s,t,i,r):this.applyParagraphFormatTableInternal(s,t,i,r)}},e.prototype.getParaFormatValueInCell=function(e,t,i){if("boolean"===typeof i){var r=this.documentHelper.selection.getFirstParagraph(e);i=!r.paragraphFormat.getPropertyValue(t)}return i},e.prototype.applyParagraphFormatRow=function(e,t,i,r,o,n){o=this.getParaFormatValueInCell(e.childWidgets[0],r,o);for(var s=e.rowIndex;s<e.ownerTable.childWidgets.length;s++){for(var a=e.ownerTable.childWidgets[s],l=0;l<a.childWidgets.length;l++)this.applyParaFormatCellInternal(a.childWidgets[l],r,o,n);if(i.paragraph.isInsideTable&&this.documentHelper.selection.containsRow(a,i.paragraph.associatedCell))return}this.getNextParagraphForFormatting(e.ownerTable,t,i,r,o,n)},e.prototype.applyParaFormatTableCell=function(e,t,i,r,o,n){var s=this.documentHelper.selection,a=s.getCellLeft(t.ownerRow,t),l=a+t.cellFormat.cellWidth,d=s.getCellLeft(i.ownerRow,i),h=d+i.cellFormat.cellWidth,c=this.updateSelectedCellsInTable(a,l,d,h);a=c.start,l=c.end;for(var p=e.childWidgets.indexOf(i.ownerRow),g=!1,u=e.childWidgets.indexOf(t.ownerRow);u<=p;u++)for(var m=e.childWidgets[u],f=0;f<m.childWidgets.length;f++){var v=s.getCellLeft(m,m.childWidgets[f]);Math.round(a)<=Math.round(v)&&Math.round(v)<Math.round(l)&&(g||(o=this.getParaFormatValueInCell(m.childWidgets[f],r,o),g=!0),this.applyParaFormatCellInternal(m.childWidgets[f],r,o,n))}},e.prototype.applyParaFormatTable=function(e,t,i,r,o,n){e=e.combineWidget(this.owner.viewer);for(var s=this.documentHelper.selection,a=0;a<e.childWidgets.length;a++){for(var l=e.childWidgets[a],d=0;d<l.childWidgets.length;d++)this.applyParaFormatCellInternal(l.childWidgets[d],r,o,n);if(i.paragraph.isInsideTable&&s.containsRow(l,i.paragraph.associatedCell))return void this.documentHelper.layout.layoutBodyWidgetCollection(e.index,e.containerWidget,e,!1)}this.documentHelper.layout.layoutBodyWidgetCollection(e.index,e.containerWidget,e,!1),this.getNextParagraphForFormatting(e,t,i,r,o,n)},e.prototype.getNextParagraphForFormatting=function(e,t,i,r,n,s){var l=e.getSplitWidgets();e=l[l.length-1],e=this.documentHelper.selection.getNextRenderedBlock(e),(0,a.le)(e)||(e instanceof o.ZH?this.applyParaFormat(e,t,i,r,n,s):this.applyParaFormatTable(e,t,i,r,n,s))},e.prototype.applyParagraphFormatTableInternal=function(e,t,i,r){for(var o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++)this.applyParaFormatCellInternal(n.childWidgets[s],t,i,r)},e.prototype.onApplyColumnFormat=function(e,t){if(!this.restrictFormatting){this.initHistory("SectionFormat");var i=this.documentHelper.selection;i.owner.isShiftingEnabled=!0;var r,o,n=i.start,s=i.end;i.isForward||(n=i.end,s=i.start),this.documentHelper.clearContent();for(var a=n.paragraph.bodyWidget.sectionIndex,l=s.paragraph.bodyWidget.sectionIndex,d=!1,h=0;h<this.documentHelper.pages.length;h++)this.documentHelper.pages[h].bodyWidgets[0].index===a?r=h:d=!0;for(h=r;h<this.documentHelper.pages.length;h++){var c=this.documentHelper.pages[h].bodyWidgets[0];if(o=h,c.index!==a&&!(c.index>=a&&c.index<=l)){o=h-1;break}}d&&"differentOddAndEvenPages"==e&&n.paragraph.isInHeaderFooter&&(r=0,o=this.documentHelper.pages.length-1);var p=!0,g=0;for(h=r;h<=o;h++)g===this.documentHelper.pages[h].bodyWidgets[0].index||p||(p=!0),this.applyPropertyValueForSection(this.documentHelper.pages[h].bodyWidgets[0].sectionFormat,e,t,p),g=this.documentHelper.pages[h].bodyWidgets[0].index,p=!1;this.layoutWholeDocument(),this.fireContentChange()}},e.prototype.onApplySectionFormat=function(e,t){if(!this.restrictFormatting){if((0,a.le)(e))this.initHistory("SectionFormat");else{var i=e[0].toUpperCase()+e.slice(1);this.initHistory(i)}this.updateSectionFormat(e,t)}},e.prototype.updateSectionFormat=function(e,t){var i=this.documentHelper.selection;i.owner.isShiftingEnabled=!0;var r,o,n=i.start,s=i.end;i.isForward||(n=i.end,s=i.start),this.documentHelper.clearContent();for(var a=n.paragraph.bodyWidget.sectionIndex,l=s.paragraph.bodyWidget.sectionIndex,d=!1,h=0;h<this.documentHelper.pages.length;h++)this.documentHelper.pages[h].bodyWidgets[0].index===a?r=h:d=!0;for(h=r;h<this.documentHelper.pages.length;h++){var c=this.documentHelper.pages[h].bodyWidgets[0];if(o=h,c.index!==a&&!(c.index>=a&&c.index<=l)){o=h-1;break}}d&&"differentOddAndEvenPages"==e&&n.paragraph.isInHeaderFooter&&(r=0,o=this.documentHelper.pages.length-1);var p=!0,g=0;for(h=r;h<=o;h++)g===this.documentHelper.pages[h].bodyWidgets[0].index||p||(p=!0),this.applyPropertyValueForSection(this.documentHelper.pages[h].bodyWidgets[0].sectionFormat,e,t,p),g=this.documentHelper.pages[h].bodyWidgets[0].index,p=!1;this.layoutWholeDocument(),this.fireContentChange()},e.prototype.onApplyTableFormat=function(e,t){if(!this.restrictFormatting){var i=this.getTableFormatAction(e);this.viewer.owner.isShiftingEnabled=!0;var r=this.documentHelper.selection,o=r.start.paragraph.associatedCell.ownerTable;o=o.combineWidget(this.owner.viewer),r.isEmpty?(this.initHistory(i),this.applyTablePropertyValue(r,e,t,o)):this.updateSelectionTableFormat(this.selection,i,t),o.calculateGrid(),this.selection.owner.isLayoutEnabled=!0,this.documentHelper.layout.reLayoutTable(
1o),this.reLayout(r,!1)}},e.prototype.getTableFormatAction=function(e){switch(e){case"tableAlignment":return"TableAlignment";case"leftIndent":return"TableLeftIndent";case"leftMargin":return"DefaultCellLeftMargin";case"rightMargin":return"DefaultCellRightMargin";case"bottomMargin":return"DefaultCellBottomMargin";case"topMargin":return"DefaultCellTopMargin";case"preferredWidth":return"TablePreferredWidth";case"preferredWidthType":return"TablePreferredWidthType";case"shading":return"Shading";case"bidi":return"TableBidi";default:return"DefaultCellSpacing"}},e.prototype.onApplyTableRowFormat=function(e,t){if(!this.restrictFormatting){var i=this.getRowAction(e);this.documentHelper.owner.isShiftingEnabled=!0;var r=this.documentHelper.selection;if(r.isEmpty){this.initHistory(i);r.start.paragraph.associatedCell.ownerRow.ownerTable;this.applyRowPropertyValue(r,e,t,r.start.paragraph.associatedCell.ownerRow)}else this.updateSelectionTableFormat(this.selection,i,t);this.reLayout(r,!1)}},e.prototype.getRowAction=function(e){switch(e){case"height":return"RowHeight";case"heightType":return"RowHeightType";case"isHeader":return"RowHeader";default:return"AllowBreakAcrossPages"}},e.prototype.onApplyTableCellFormat=function(e,t){if(!this.restrictFormatting){var i=this.getTableCellAction(e);this.documentHelper.owner.isShiftingEnabled=!0;var r=this.documentHelper.selection,o=r.start.paragraph.associatedCell.ownerTable;o=o.combineWidget(this.owner.viewer),r.isEmpty?(this.initHistory(i),this.applyCellPropertyValue(r,e,t,r.start.paragraph.associatedCell.cellFormat),o.calculateGrid(),this.selection.owner.isLayoutEnabled=!0,this.documentHelper.layout.reLayoutTable(o)):this.updateSelectionTableFormat(this.selection,i,t),this.reLayout(r,!1)}},e.prototype.getTableCellAction=function(e){switch(e){case"verticalAlignment":return"CellContentVerticalAlignment";case"leftMargin":return"CellLeftMargin";case"rightMargin":return"CellRightMargin";case"bottomMargin":return"CellBottomMargin";case"topMargin":return"CellTopMargin";case"preferredWidth":return"CellPreferredWidth";case"shading":return"Shading";default:return"CellPreferredWidthType"}},e.prototype.applyPropertyValueForSection=function(e,t,i,r){r&&this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&("columns"===t&&(e.numberOfColumns=i.length),i=this.editorHistory.currentBaseHistoryInfo.addModifiedPropertiesForSection(e,t,i)),(0,a.le)(i)||(i instanceof l.Z?(0,a.le)(t)&&e.copyFormat(i,this.editorHistory):"pageHeight"===t?e.pageHeight=i:"pageWidth"===t?e.pageWidth=i:"leftMargin"===t?e.leftMargin=i:"rightMargin"===t?e.rightMargin=i:"topMargin"===t?e.topMargin=i:"bottomMargin"===t?e.bottomMargin=i:"differentFirstPage"===t?e.differentFirstPage=i:"differentOddAndEvenPages"===t?e.differentOddAndEvenPages=i:"headerDistance"===t?e.headerDistance=i:"footerDistance"===t?e.footerDistance=i:"pageStartingNumber"===t?e.pageStartingNumber=i:"restartPageNumbering"===t?e.restartPageNumbering=i:"endnoteNumberFormat"===t?e.endnoteNumberFormat=i:"footNoteNumberFormat"===t?e.footNoteNumberFormat=i:"restartIndexForEndnotes"===t?e.restartIndexForEndnotes=i:"restartIndexForFootnotes"===t?e.restartIndexForFootnotes=i:"initialFootNoteNumber"===t?e.initialFootNoteNumber=i:"initialEndNoteNumber"===t?e.initialEndNoteNumber=i:"numberOfColumns"==t?e.numberOfColumns=i:"equalWidth"==t?e.equalWidth=i:"lineBetweenColumns"==t?e.lineBetweenColumns=i:"columns"==t&&(e.columns=i))},e.prototype.layoutWholeDocument=function(e){this.documentHelper.layout.isLayoutWhole=!0;var t=this.documentHelper.selection.start,i=this.documentHelper.selection.end;t.isExistAfter(i)&&(t=this.documentHelper.selection.end,i=this.documentHelper.selection.start),"Continuous"==this.owner.layoutType&&(this.documentHelper.selection.isinEndnote||this.documentHelper.selection.isinFootnote)&&(this.documentHelper.selection.footnoteReferenceElement(t,i),t=i);var r=this.selection.getParagraphInfo(t),o=this.selection.getParagraphInfo(i),n=this.selection.getHierarchicalIndex(r.paragraph,r.offset.toString()),s=this.selection.getHierarchicalIndex(o.paragraph,o.offset.toString());this.documentHelper.renderedLists.clear(),this.documentHelper.renderedLevelOverrides=[];var a=this.combineSection();this.documentHelper.clearContent(),this.documentHelper.layout.layoutItems(a,!0),this.documentHelper.owner.isShiftingEnabled=!1,this.setPositionForCurrentIndex(t,n),this.setPositionForCurrentIndex(i,s),this.documentHelper.selection.selectPosition(t,i),this.reLayout(this.documentHelper.selection,void 0,e),this.documentHelper.layout.isLayoutWhole=!1},e.prototype.combineSection=function(){var e=[],t=this.documentHelper.pages[0].bodyWidgets[0];do{t=this.combineSectionChild(t,e,!1)}while(t);for(var i=0;i<this.documentHelper.pages.length;i++)this.documentHelper.pages[i].destroy(),i--;return e},e.prototype.combineSectionChild=function(e,t,i){var r=e,n=new o.VB,s=!1;n.sectionFormat=e.sectionFormat,n.index=r.index;do{s=!1,r=e,e.lastChild&&e.lastChild.combineWidget(this.owner.viewer),e=e.nextRenderedWidget;for(var a=0;a<r.childWidgets.length;a++){var l=r.childWidgets[a];l instanceof o.dm?this.documentHelper.layout.clearTableWidget(l,!0,!0,!0):(l.x=0,l.y=0,l.width=0,l.height=0),n.childWidgets.push(l),r.childWidgets.splice(a,1),a--,l.containerWidget=n}for(var d=0;d<r.page.bodyWidgets.length;d++){if(0!==r.page.bodyWidgets[d].childWidgets.length){s=!1;break}s=!0}s&&i&&r.page.destroy()}while(e&&r.index===e.index);return t.push(n),e},e.prototype.updateSelectionTableFormat=function(e,t,i){switch(t){case"TableAlignment":this.editorHistory.initializeHistory("TableAlignment"),this.updateTableFormat(e,"tableAlignment",i);break;case"TableLeftIndent":this.editorHistory.initializeHistory("TableLeftIndent"),this.updateTableFormat(e,"leftIndent",i);break;case"DefaultCellSpacing":this.editorHistory.initializeHistory("DefaultCellSpacing"),this.updateTableFormat(e,"cellSpacing",i);break;case"DefaultCellLeftMargin":this.editorHistory.initializeHistory("DefaultCellLeftMargin"),this.updateTableFormat(e,"leftMargin",i);break;case"DefaultCellRightMargin":this.editorHistory.initializeHistory("DefaultCellRightMargin"),this.updateTableFormat(e,"rightMargin",i);break;case"DefaultCellTopMargin":this.editorHistory.initializeHistory("DefaultCellTopMargin"),this.updateTableFormat(e,"topMargin",i);break;case"TablePreferredWidth":this.editorHistory.initializeHistory("TablePreferredWidth"),this.updateTableFormat(e,"preferredWidth",i);break;case"TablePreferredWidthType":this.editorHistory.initializeHistory("TablePreferredWidthType"),this.updateTableFormat(e,"preferredWidthType",i);break;case"DefaultCellBottomMargin":this.editorHistory.initializeHistory("DefaultCellBottomMargin"),this.updateTableFormat(e,"bottomMargin",i);break;case"CellContentVerticalAlignment":this.editorHistory.initializeHistory("CellContentVerticalAlignment"),this.updateCellFormat(e,"verticalAlignment",i);break;case"CellLeftMargin":this.editorHistory.initializeHistory("CellLeftMargin"),this.updateCellFormat(e,"leftMargin",i);break;case"CellRightMargin":this.editorHistory.initializeHistory("CellRightMargin"),this.updateCellFormat(e,"rightMargin",i);break;case"CellTopMargin":this.editorHistory.initializeHistory("CellTopMargin"),this.updateCellFormat(e,"topMargin",i);break;case"CellBottomMargin":this.editorHistory.initializeHistory("CellBottomMargin"),this.updateCellFormat(e,"bottomMargin",i);break;case"CellPreferredWidth":this.editorHistory.initializeHistory("CellPreferredWidth"),this.updateCellFormat(e,"preferredWidth",i);break;case"CellPreferredWidthType":this.editorHistory.initializeHistory("CellPreferredWidthType"),this.updateCellFormat(e,"preferredWidthType",i);break;case"Shading":this.editorHistory.initializeHistory("Shading"),this.updateCellFormat(e,"shading",i
1);break;case"RowHeight":this.editorHistory.initializeHistory("RowHeight"),this.updateRowFormat(e,"height",i);break;case"RowHeightType":this.editorHistory.initializeHistory("RowHeightType"),this.updateRowFormat(e,"heightType",i);break;case"RowHeader":this.editorHistory.initializeHistory("RowHeader"),this.updateRowFormat(e,"isHeader",i);break;case"AllowBreakAcrossPages":this.editorHistory.initializeHistory("AllowBreakAcrossPages"),this.updateRowFormat(e,"allowBreakAcrossPages",i);break;case"TableBidi":this.editorHistory.initializeHistory(t),this.updateTableFormat(e,"bidi",i);break}},e.prototype.updateTableFormat=function(e,t,i){var r=e.start;e.end;e.isForward||(r=e.end,e.start),this.initHistoryPosition(e,r),this.applyTablePropertyValue(e,t,i,r.paragraph.associatedCell.ownerTable),this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&this.documentHelper.layout.reLayoutTable(r.paragraph.associatedCell.ownerTable)},e.prototype.updateCellFormat=function(e,t,i){e.owner.isShiftingEnabled=!0;var r=e.start;e.end;e.isForward||(r=e.end,e.start),this.initHistoryPosition(e,r),this.updateFormatForCell(e,t,i)},e.prototype.updateRowFormat=function(e,t,i){var r=e.start,o=e.end;e.isForward||(r=e.end,o=e.start),this.initHistoryPosition(e,r),this.applyRowFormat(r.paragraph.associatedCell.ownerRow,r,o,t,i)},e.prototype.initHistoryPosition=function(e,t){this.documentHelper.owner.editorHistoryModule&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&((0,a.le)(t)?(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=e.start.getHierarchicalIndexInternal()):(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=t.getHierarchicalIndexInternal()))},e.prototype.startSelectionReLayouting=function(e,t,i,r){if(t.owner.isLayoutEnabled=!0,i.paragraph.isInsideTable){var o=i.paragraph.associatedCell.ownerTable;while(o.isInsideTable)o=o.associatedCell.ownerTable;this.reLayoutSelectionOfTable(o,t,i,r)}else this.reLayoutSelection(e,t,i,r)},e.prototype.reLayoutSelectionOfTable=function(e,t,i,r){var o=!1;if(this.documentHelper.layout.layoutBodyWidgetCollection(e.index,e.containerWidget,e,!1),!(0,a.le)(r.paragraph.associatedCell)&&e.contains(r.paragraph.associatedCell))return!0;var n=t.getNextRenderedBlock(e);return(0,a.le)(n)||(o=this.reLayoutSelectionOfBlock(n,t,i,r)),o},e.prototype.reLayoutSelection=function(e,t,i,r){if(i.paragraph===e){i.offset,t.getParagraphLength(e);var n=0,s=0,l=e.getInline(i.offset,n),d=l.element;n=l.index,(0,a.le)(d)||(n!==d.length||(0,a.le)(d.nextNode)||(d=d.nextNode),s=d.line.children.indexOf(d));var h=0;i.currentWidget.paragraph===e&&(h=e.childWidgets.indexOf(i.currentWidget),s=i.currentWidget.children.indexOf(d)),d instanceof o.a3&&!d.line&&s>0?this.documentHelper.layout.reLayoutParagraph(e,h,s-1):this.documentHelper.layout.reLayoutParagraph(e,h,s)}else this.documentHelper.layout.reLayoutParagraph(e,0,0);if(r.paragraph===e)return!0;var c=t.getNextRenderedBlock(e);return!(0,a.le)(c)&&this.reLayoutSelectionOfBlock(c,t,i,r)},e.prototype.reLayoutSelectionOfBlock=function(e,t,i,r){return e instanceof o.ZH?this.reLayoutSelection(e,t,i,r):void 0},e.prototype.layoutItemBlock=function(e,t){var i=void 0;if(e.containerWidget instanceof o.VW)!(0,a.le)(this.documentHelper.owner)&&this.documentHelper.owner.isLayoutEnabled&&(e=e.combineWidget(this.viewer),i=e.containerWidget,this.documentHelper.layout.layoutBodyWidgetCollection(e.index,i,e,!1));else if(e.containerWidget instanceof o.nb){var r=e.containerWidget;r=this.documentHelper.selection.getContainerCell(r),!(0,a.le)(this.documentHelper.owner)&&this.documentHelper.owner.isLayoutEnabled&&this.documentHelper.layout.reLayoutTable(e)}},e.prototype.removeSelectedContents=function(e){return this.removeSelectedContentInternal(e,e.start,e.end)},e.prototype.removeSelectedContentInternal=function(e,t,i){var n=t,s=i;if(t.isExistBefore(i)||(n=i,s=t),n.paragraph===s.paragraph&&n.paragraph.childWidgets.indexOf(n.currentWidget)===n.paragraph.childWidgets.length-1&&n.offset===e.getParagraphLength(n.paragraph)&&n.offset+1===s.offset)return e.owner.isShiftingEnabled=!0,e.selectContent(n,!0),!0;var a=this.selection.getParagraphInfo(n);e.editPosition=this.selection.getHierarchicalIndex(a.paragraph,a.offset.toString());var l=n.clone(),d=l.paragraph.containerWidget,h=l.currentWidget.isFirstLine(),c=this.checkMultipleSectionSelected(l,s),p=this.removeSelectedContent(s.paragraph,e,n,s),g=new r.JK(e.owner);if(c&&"DefaultPaste"==this.selection.currentPasteAction&&h&&l.offset<1){var u=l.paragraph,m=new o.ZH,f=new o.z7(m);f.paragraph=m,m.containerWidget=d,m.childWidgets.push(f),d.childWidgets.push(m),m.index=u.index,m.x=l.location.x,m.y=l.location.y}return this.setPositionForCurrentIndex(g,e.editPosition),e.selectContent(g,!0),p},e.prototype.checkMultipleSectionSelected=function(e,t){var i=this.getBodyWidgetIndex(e),r=this.getBodyWidgetIndex(t);return i!=r},e.prototype.getBodyWidgetIndex=function(e){var t=e.hierarchicalPosition,i=t.indexOf(";"),r=t.substring(0,i);t=t.substring(i).replace(";",""),i=t.indexOf(";"),r=t.substring(0,i);var o=parseInt(r,10);return o},e.prototype.removeSelectedContent=function(e,t,i,r){return!(r.paragraph.isInsideTable&&r.paragraph!==this.documentHelper.getLastParagraphInLastCell(r.paragraph.associatedCell.ownerTable)&&(!i.paragraph.isInsideTable||i.paragraph.associatedCell.ownerTable.index!==r.paragraph.associatedCell.ownerTable.index))&&(t.owner.isShiftingEnabled=!0,this.deleteSelectedContent(e,t,i,r,2),!0)},e.prototype.deleteSelectedContent=function(e,t,i,r,n){var s=0,a=i.currentWidget.getInline(i.offset,s);a.element;if(s=a.index,s=0,a=r.currentWidget.getInline(r.offset,s),a.element,s=a.index,r.paragraph===e)if(!r.paragraph.isInsideTable||i.paragraph.isInsideTable&&i.paragraph.associatedCell===r.paragraph.associatedCell&&!t.isCellSelected(r.paragraph.associatedCell,i,r)){if(this.deletePara(e,i,r,n),this.delBlockContinue&&this.delBlock){if(this.delSection){var l=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0;this.deleteSection(t,this.delSection,l,n),this.delSection=void 0}this.deleteBlock(this.delBlock,t,i,r,n),this.delBlockContinue=!1,this.delBlock=void 0}}else r.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer),this.deleteTableCell(r.paragraph.associatedCell,t,i,r,n);else this.deleteSelectedContent(r.paragraph,t,i,r,n)},e.prototype.mergeCells=function(){!this.owner.isReadOnlyMode&&this.canEditContentControl&&this.owner.isDocumentLoaded&&((0,a.le)(this.documentHelper)||this.selection.isEmpty||this.mergeSelectedCellsInTable())},e.prototype.deleteTable=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var e=this.selection.isForward?this.selection.start:this.selection.end;if(e.paragraph.isInsideTable){var t=this.getOwnerTable(this.selection.isForward).combineWidget(this.owner.viewer);this.selection.selectTable();var i=[];this.selection.owner.isShiftingEnabled=!0,this.checkIsNotRedoing()&&(i=this.checkAndRemoveComments(),this.initHistory("DeleteTable"),this.updateHistoryPosition(e,!0));var r=!0;if(!this.skipTracking()){for(var o=0,n=0;n<t.childWidgets.length;n++){var s=t.childWidgets[n];1===s.rowFormat.revisions.length&&"Insertion"===s.rowFormat.revisions[0].revisionType&&s.rowFormat.revisions[0].author===(""===this.owner.currentUser?"Guest user":this.owner.currentUser)&&(this.isRemoveRevision=!0,this.unlinkRangeFromRevision(s.rowFormat,!0),this.isRemoveRevision=!1,0===s.rowFormat.revisions[0].range.length&&s.rowFormat.revisions.splice(0,1),o++)}o===t.childWidgets.length&&(r=!1)}var l=this.getParagraphForSelection(t);
1if(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.currentBaseHistoryInfo.removedNodes.push(t.clone()),this.owner.enableTrackChanges&&r)for(n=0;n<t.childWidgets.length;n++){if(0===n){var d=t.childWidgets[0];l=this.selection.getFirstParagraph(d)}this.trackRowDeletion(t.childWidgets[n])}else this.removeBlock(t);this.selection.selectParagraphInternal(l,!0),(this.checkIsNotRedoing()||(0,a.le)(this.editorHistory))&&(this.reLayout(this.selection),this.updateHistoryForComments(i))}}},e.prototype.deleteColumn=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl)if(this.owner.enableTrackChanges){var e=new a.E7("documenteditor",this.owner.defaultLocale);e.setLocale(this.owner.locale),this.alertDialog=R.hZ.alert({title:e.getConstant("UnTrack"),content:e.getConstant("Merge Track"),showCloseIcon:!0,okButton:{text:"Ok",click:this.onDeleteColumnConfirmed.bind(this)},closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"}}),this.alertDialog.enableRtl=this.owner.enableRtl}else this.onDeleteColumnConfirmed()},e.prototype.onDeleteColumnConfirmed=function(){var e=this.selection.isForward?this.selection.start:this.selection.end;this.selection.isForward?this.selection.end:this.selection.start;if(e.paragraph.isInsideTable){this.selection.selectColumn();var t=[];this.selection.owner.isShiftingEnabled=!0,this.checkIsNotRedoing()&&(t=this.checkAndRemoveComments(),this.initHistory("DeleteColumn"));var i=this.getOwnerCell(this.selection.isForward),r=this.getOwnerCell(!this.selection.isForward),o=i.ownerTable.combineWidget(this.owner.viewer);this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.cloneTableToHistoryInfo(o);var n=void 0;if(r.nextWidget){var s=r.nextWidget;n=this.selection.getFirstParagraph(s)}else if(i.previousWidget){var l=i.previousWidget;n=this.selection.getFirstParagraph(l)}(0,a.le)(n)&&(n=this.getParagraphForSelection(o));for(var d=o.getColumnCellsForSelection(i,r),h=0;h<o.childWidgets.length;h++){var c=o.childWidgets[h];if(1===c.childWidgets.length)d.indexOf(c.childWidgets[0])>=0&&(o.childWidgets.splice(o.childWidgets.indexOf(c),1),c.destroy(),h--);else{for(var p=0;p<c.childWidgets.length;p++){var g=c.childWidgets[p];d.indexOf(g)>=0&&(c.childWidgets.splice(p,1),g.destroy(),p--)}0===c.childWidgets.length&&(o.childWidgets.splice(o.childWidgets.indexOf(c),1),c.destroy(),h--)}}0===o.childWidgets.length?(n=this.getParagraphForSelection(o),this.removeBlock(o),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.action="DeleteTable"),o.destroy()):this.updateTable(o),this.selection.selectParagraphInternal(n,!0),((0,a.le)(this.editorHistory)||this.checkIsNotRedoing())&&(this.reLayout(this.selection,!0),this.updateHistoryForComments(t)),(0,a.le)(this.alertDialog)||(this.alertDialog.close(),this.alertDialog=void 0)}},e.prototype.deleteRow=function(){if(!this.owner.isReadOnlyMode&&this.canEditContentControl){var e=this.selection.isForward?this.selection.start:this.selection.end,t=(this.selection.isForward?this.selection.end:this.selection.start,this.selection.getParagraphInfo(e)),i=this.selection.getHierarchicalIndex(t.paragraph,t.offset.toString());if(e.paragraph.isInsideTable){var r=this.getOwnerCell(this.selection.isForward),o=this.getOwnerCell(!this.selection.isForward);this.selection.selectRow();var n=[];this.checkIsNotRedoing()&&(n=this.checkAndRemoveComments(),this.initHistory("DeleteRow")),this.selection.owner.isShiftingEnabled=!0;var s=r.ownerTable.combineWidget(this.owner.viewer),l=this.getOwnerRow(!0);this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.cloneTableToHistoryInfo(s);var d=void 0;if(l.nextWidget){var h=l.nextWidget.childWidgets[0];d=this.selection.getFirstParagraph(h)}if((0,a.le)(d)&&(d=this.getParagraphForSelection(s)),e=e.clone(),this.selection.isEmpty)this.owner.enableTrackChanges?this.trackRowDeletion(l,!0,!1):this.removeRow(l);else{var c=this.selection.getContainerCellOf(r,o);if(c.ownerTable.contains(o))if(r=this.selection.getSelectedCell(r,c),o=this.selection.getSelectedCell(o,c),this.selection.containsCell(c,o))l=r.ownerRow,this.removeRow(l);else{l=r.ownerRow;var p=o.ownerRow;if(d=void 0,p.nextWidget){h=p.nextWidget.childWidgets[0];d=this.selection.getFirstParagraph(h)}(0,a.le)(d)&&(d=this.getParagraphForSelection(s));for(var g=0;g<s.childWidgets.length;g++){var u=s.childWidgets[g];u.rowIndex>=l.rowIndex&&u.rowIndex<=p.rowIndex&&(this.owner.enableTrackChanges&&this.checkIsNotRedoing()?this.trackRowDeletion(u,!0,!1):(s.childWidgets.splice(g,1),u.destroy(),g--))}0===s.childWidgets.length?(this.removeBlock(s),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.action="DeleteTable"),s.destroy()):this.updateTable(s)}}if(!this.owner.enableTrackChanges||(0,a.le)(s.childWidgets))this.selection.selectParagraphInternal(d,!0);else{var m=this.selection.getTextPosBasedOnLogicalIndex(i);this.selection.selectContent(m,!0)}((0,a.le)(this.editorHistory)||this.checkIsNotRedoing())&&(this.reLayout(this.selection,!0),this.updateHistoryForComments(n))}}},e.prototype.trackRowDeletion=function(e,t,i){var r=e.rowFormat;if(!(0,a.le)(r)){var n=!0;if(r.revisions.length>0){var s=this.retrieveRevisionInOder(r);if("Insertion"===s.revisionType){if(this.isRevisionMatched(r,void 0))return(0,a.le)(t)||t?this.removeRow(e):this.removeRevisionsInRow(e),!0}else"Deletion"===s.revisionType&&this.unlinkWholeRangeInRevision(r,s)}n&&(((0,a.le)(i)||i)&&this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.action="RemoveRowTrack"),this.insertRevision(r,"Deletion"));for(var l=0;l<e.childWidgets.length;l++)for(var d=e.childWidgets[l],h=0;h<d.childWidgets.length;h++)if(d.childWidgets[h]instanceof o.dm)this.trackInnerTable(d.childWidgets[l],t,i);else{var c=d.childWidgets[h];this.skipTableElements=!0,this.insertRevisionForBlock(c,"Deletion",void 0,void 0,!0),this.skipTableElements=!1}}return!1},e.prototype.trackInnerTable=function(e,t,i){for(var r=0;r<e.childWidgets.length;r++)this.trackRowDeletion(e.childWidgets[r],t,i)},e.prototype.returnDeleteRevision=function(e){for(var t=0;t<e.length;
1t++)if("Deletion"===e[t].revisionType)return e[t]},e.prototype.removeRow=function(e){var t=e.ownerTable;e.rowFormat.revisions.length>0&&this.removeRevisionsInRow(e),1===t.childWidgets.length?(this.removeBlock(t),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(this.editorHistory.currentBaseHistoryInfo.action="Delete"),t.destroy()):(t.childWidgets.splice(t.childWidgets.indexOf(e),1),e.destroy(),this.updateTable(t))},e.prototype.updateTable=function(e){e=e.combineWidget(this.viewer),e.updateRowIndex(0),e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.layout.reLayoutTable(e)},e.prototype.getParagraphForSelection=function(e){var t=void 0,i=e.nextWidget?e.nextWidget:e.nextRenderedWidget,r=e.previousWidget?e.previousWidget:e.previousRenderedWidget;return i?t=i instanceof o.ZH?i:this.documentHelper.getFirstParagraphInFirstCell(i):r&&(t=r instanceof o.ZH?r:this.documentHelper.getLastParagraphInLastCell(r)),t},e.prototype.deletePara=function(e,t,i,r){e=e.combineWidget(this.owner.viewer);var n=this.documentHelper.selection,s=n.getStartOffset(e),l=n.getStartOffset(i.paragraph),d=s,h=0,c=!1,p=(this.selection.getLineLength(e.lastChild),e),g=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0,u=void 0,m=void 0,f=this.combineLastBlock;e===t.paragraph?(d=t.offset,u=t.currentWidget,i.paragraph.isInsideTable&&(c=this.isEndInAdjacentTable(e,i.paragraph)),c||
1(c=this.combineLastBlock),this.combineLastBlock=!1):u=e.firstChild,e!==t.paragraph&&n.isSkipLayouting&&(n.isSkipLayouting=!1),e===i.paragraph?(m=i.currentWidget,h=i.offset):(m=e.lastChild,h=this.documentHelper.selection.getLineLength(e.lastChild));var v=(0,a.le)(e.previousRenderedWidget)||t.paragraph===e?void 0:e.previousRenderedWidget.combineWidget(this.documentHelper.viewer);(d>s&&(e===i.paragraph&&i.offset===d+1||e.nextRenderedWidget===i.paragraph&&i.offset===l)||this.editorHistory&&this.editorHistory.isUndoing&&this.editorHistory.currentHistoryInfo&&"PageBreak"===this.editorHistory.currentHistoryInfo.action&&v&&v.isPageBreak()&&(0===d&&!t.currentWidget.isFirstLine||d>0)||t.paragraph!==i.paragraph&&2===r&&t.paragraph===e&&t.paragraph.nextWidget===i.paragraph)&&(c=!0,f=!0);var y=i.clone();y.offset=y.offset-1;var F=t.paragraph===e&&t.isAtParagraphStart&&y.isAtParagraphEnd&&this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"Insert"===this.editorHistory.currentBaseHistoryInfo.action;F&&(this.editorHistory.currentBaseHistoryInfo.action="InsertTextParaReplace");var H=t.paragraph===e;
1if(i.paragraph===e&&i.currentWidget!==e.lastChild||i.currentWidget===e.lastChild&&i.offset<=n.getLineLength(e.lastChild)||F)if((i.currentWidget.isFirstLine()&&i.offset>s||!i.currentWidget.isFirstLine()||F)&&this.removeInlines(e,u,d,m,h,r),(0,a.le)(v)||H||F)this.delBlockContinue=!1,this.delBlock=void 0;else{this.delBlockContinue=!0,this.delBlock=v;var C=v.bodyWidget instanceof o.VB?v.bodyWidget:void 0;C&&!g.equals(C)&&g.index!==C.index?this.delSection=C:this.delSection=void 0}else{if(t.paragraph===e&&(t.currentWidget!==e.firstChild||t.currentWidget===e.firstChild&&d>s))return this.delBlockContinue=!1,this.delBlock=void 0,4===r?void 0:void(this.skipTracking()&&"ParaMarkTrack"===this.editorHistory.currentBaseHistoryInfo.action?(this.addRemovedNodes(e.characterFormat.cloneFormat()),e.characterFormat.revisions.length>0&&this.unlinkRangeFromRevision(e.characterFormat,!0),e.characterFormat.revisions=[]):this.owner.enableTrackChanges&&!this.skipTracking()&&"TOC"!==this.editorHistory.currentBaseHistoryInfo.action&&"Reject Change"!==this.editorHistory.currentBaseHistoryInfo.action?c?(p=this.splitParagraph(e,e.firstChild,0,u,d,!0),this.deleteParagraphMark(p,n,r,!0),this.addRemovedNodes(e)):this.removeInlines(e,u,d,m,h,r):(p=this.splitParagraph(e,e.firstChild,0,u,d,!0),this.insertParagraphPaste(e,p,t,i,c,r,f),this.removeRevisionForBlock(e,void 0,!1,!0),this.addRemovedNodes(e)));i.paragraph===e&&i.paragraph.isInsideTable&&(t.currentWidget.isFirstLine()&&t.offset>n.getStartOffset(t.paragraph)||!t.currentWidget.isFirstLine())&&i.offset>=n.getLineLength(i.paragraph.lastChild)&&i.paragraph.nextRenderedWidget&&(this.combineLastBlock=!0);var w=void 0,I=e.previousWidget,b=I instanceof o.ZH?I:void 0,W=e.nextRenderedWidget;if(r<4){if(this.owner.enableTrackChanges&&!this.skipTracking()&&this.editorHistory.currentBaseHistoryInfo&&"TOC"!==this.editorHistory.currentBaseHistoryInfo.action){var x=-1;if(this.editorHistory.currentBaseHistoryInfo&&(x=this.editorHistory.currentBaseHistoryInfo.removedNodes.length),this.insertRevisionForBlock(e,"Deletion"),!e.isEmpty()||i.paragraph.previousRenderedWidget instanceof o.dm?this.combineRevisionWithBlocks(e.firstChild.children[0]):(w=this.checkAndInsertBlock(e,t,i,r,b),this.removeBlock(e),-1===x?this.addRemovedNodes(e):this.editorHistory.currentBaseHistoryInfo.removedNodes.splice(x,0,e),this.removeRevisionForBlock(e,void 0,!1,!0)),e===i.paragraph&&"Delete"===this.editorHistory.currentBaseHistoryInfo.action&&!this.isInsertingTOC){var P=this.selection.getParagraphInfo(i);this.selection.editPosition=this.selection.getHierarchicalIndex(P.paragraph,P.offset.toString())}if(t.paragraph!==e&&!(0,a.le)(v))return this.delBlockContinue=!0,void(this.delBlock=v)}else{if(w=this.checkAndInsertBlock(e,t,i,r,b),this.removeRevisionForBlock(e,void 0,!1,!0),this.addRemovedNodes(e),!(0,a.le)(v)&&!H&&!F){this.delBlock=v;C=v.bodyWidget instanceof o.VB?v.bodyWidget:void 0;if(C&&g.index!==C.index){var R=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0;this.deleteSection(n,C,R,r)}}this.removeBlock(e)}if(this.documentHelper.blockToShift===e&&(this.documentHelper.blockToShift=void 0),(0,a.le)(w)){if(e===t.paragraph&&((0,a.le)(W)||!(0,a.le)(W)&&!(0,a.le)(g)&&g.index!==W.bodyWidget.index)&&!(0,a.le)(b)){k=this.selection.getParagraphLength(b);n.editPosition=this.selection.getHierarchicalIndex(b,k.toString()),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.updateHistoryPosition(n.editPosition,!0),this.editorHistory.currentBaseHistoryInfo.endPosition=n.editPosition)}}else{n.editPosition=this.selection.getHierarchicalIndex(w,"0");var k=n.getParagraphLength(w)+1;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.endPosition=this.selection.getHierarchicalIndex(w,k.toString()))}}t.paragraph===e||(0,a.le)(v)?(this.delBlockContinue=!1,this.delBlock=void 0):(this.delBlockContinue=!0,this.delBlock=v)}this.insertParagraphPaste(e,p,t,i,c,r,f)},e.prototype.deleteSection=function(e,t,i,r){r<4&&this.combineSectionInternal(e,t,i),r>2&&t.sectionFormat.copyFormat(i.sectionFormat)},e.prototype.combineSectionInternal=function(e,t,i){var r=t.getSplitWidgets()[0],o=[];this.combineSectionChild(r,o,!0),r=o[0];var n=r.lastChild.index;this.updateBlockIndex(n+1,i.firstChild);for(var s=0,a=i,l=0;l<r.childWidgets.length;l++){var d=r.childWidgets.splice(l,1)[0];
1a.childWidgets.splice(s,0,d),d.containerWidget=a,this.documentHelper.layout.layoutBodyWidgetCollection(d.index,d.bodyWidget,d,!1),d=d.getSplitWidgets().pop(),a=d.containerWidget,s=d.indexInOwner+1,l--}if(this.documentHelper.headersFooters[r.sectionIndex]){r.removedHeaderFooters=[];var h=this.documentHelper.headersFooters.splice(r.sectionIndex,1)[0],c=Object.keys(h);for(l=0;l<c.length;l++){var p=h[c[l]];this.removeFieldInWidget(p),this.removeFieldInWidget(p,!1,!0),p.page=void 0}r.removedHeaderFooters.push(h)}this.updateSectionIndex(void 0,i,!1),this.addRemovedNodes(r),this.documentHelper.removeEmptyPages(),this.editorHistory&&this.editorHistory.isUndoing&&(i.sectionFormat=t.sectionFormat)},e.prototype.checkAndInsertBlock=function(e,t,i,r,n){if(e instanceof o.ZH&&e===t.paragraph||e instanceof o.dm){var s=void 0;if((0,a.le)(e.nextWidget)&&((0,a.le)(n)||n.nextRenderedWidget instanceof o.dm)){if(s=new o.ZH,1===r&&e instanceof o.ZH&&!(0,a.le)(e.paragraphFormat.baseStyle)&&"Normal"===e.paragraphFormat.baseStyle.name&&(s.characterFormat.copyFormat(e.characterFormat),s.paragraphFormat.copyFormat(e.paragraphFormat)),s.index=e.index+1,s.containerWidget=e.containerWidget,e instanceof o.ZH){s.paragraphFormat.lineSpacing=e.paragraphFormat.lineSpacing,s.paragraphFormat.lineSpacingType=e.paragraphFormat.lineSpacingType;var l=this.documentHelper.styles.findByName("Normal");(0,a.le)(l)||(s.paragraphFormat.baseStyle=new I.wk,s.paragraphFormat.baseStyle.copyStyle(l))}this.documentHelper.layout.layoutBodyWidgetCollection(s.index,s.bodyWidget,s,!1),e.containerWidget instanceof o.$L&&e.containerWidget.childWidgets.push(s)}return s}},e.prototype.splitParagraph=function(e,t,i,r,s,a){var l=new o.ZH;l.paragraphFormat=new h.h(l),l.characterFormat=new n.a(l),l.paragraphFormat.copyFormat(e.paragraphFormat),l.characterFormat.copyFormat(e.characterFormat);var d=new o.z7(l);l.childWidgets.push(d);var c=e.index,p=e.indexInOwner;if(this.moveInlines(e,l,0,i,t,s,r),e.containerWidget.childWidgets[p])for(var g=e.containerWidget.childWidgets[p],u=0;u<g.childWidgets.length;u++)for(var m=g.childWidgets[u],f=0;f<m.children.length;f++){var v=m.children[f];v instanceof o.R5&&this.removeFootnote(v)}return e.containerWidget.childWidgets.splice(p,0,l),l.index=c,l.containerWidget=e.containerWidget,this.updateNextBlocksIndex(l,!0),a&&this.removeBlock(e),this.documentHelper.layout.layoutBodyWidgetCollection(c,l.containerWidget,l,!1),l},e.prototype.removeCommentsInBlock=function(e){if(e instanceof o.dm)for(var t=0;t<e.childWidgets.length;t++)for(var i=e.childWidgets[t],r=0;r<i.childWidgets.length;r++)for(var n=i.childWidgets[r],s=0;s<n.childWidgets.length;s++){var a=n.childWidgets[s];this.removeCommentsInBlock(a)}else this.removeCommentInPara(e)},e.prototype.removeCommentInPara=function(e){for(var t=0;t<e.childWidgets.length;t++)for(var i=e.childWidgets[t],r=0;r<i.children.length;r++)this.removeCommentsInline(i.children[r])},e.prototype.removeCommentsInline=function(e){e instanceof o.Xw&&(1===e.commentType||e.removeCommentMark())},e.prototype.removeBlock=function(e,t,i){var r,n;if(i||(this.removeFieldInBlock(e),this.removeFieldInBlock(e,!0),this.removeFieldInBlock(e,void 0,!0),this.removeCommentsInBlock(e)),e.isInsideTable)n=e.associatedCell,r=e.associatedCell.childWidgets.indexOf(e),e.associatedCell.childWidgets,this.updateNextBlocksIndex(e,!1),e.associatedCell.childWidgets.splice(r,1),e.containerWidget=void 0,this.documentHelper.layout.layoutBodyWidgetCollection(e.index,n,e,!1);else{n=e.containerWidget;for(var s=0;s<e.childWidgets.length;s++){var l=void 0;if(this.isPasteRevertAction()||(l=this.skipTracking()),e.childWidgets[s]instanceof o.BC&&!l){var d=e.childWidgets[s];this.removeDeletedCellRevision(d)}if(e.childWidgets[s]instanceof o.z7)for(var h=e.childWidgets[s],c=0;c<h.children.length;c++){var p=h.children[c];p instanceof o.R5&&!this.selection.isEmpty&&this.removeFootnote(p)}}r=n.childWidgets.indexOf(e),n.childWidgets,this.updateNextBlocksIndex(e,!1),n.childWidgets.splice(r,1),e.containerWidget=void 0,n.height-=e.height,!(0,a.le)(n.containerWidget)&&n.containerWidget instanceof o.tf&&(n.containerWidget.height-=e.he
1ight),this.documentHelper.layout.layoutBodyWidgetCollection(e.index,n,e,!1,t)}},e.prototype.removePrevParaMarkRevision=function(e,t){if(t=!(0,a.le)(t)&&t,this.owner.enableTrackChanges||0!=e.characterFormat.revisions.length){var i=e,r=-1,o=void 0,s=i;if(t||(0,a.le)(s.previousRenderedWidget)||(s=s.previousRenderedWidget),s.characterFormat.revisions.length>0&&(o=s.characterFormat.revisions[s.characterFormat.revisions.length-1],r=o.range.indexOf(s.characterFormat)),r>=0&&!(0,a.le)(o)){var l=o.range[r],d=l instanceof n.a;d&&(o.range.splice(r,1),s.characterFormat&&s.characterFormat.revisions.indexOf(o)>-1&&s.characterFormat.revisions.splice(s.characterFormat.revisions.indexOf(o),1),0==o.range.length&&this.owner.revisionsInternal.remove(o))}}},e.prototype.isPasteRevertAction=function(){return!((0,a.le)(this.editorHistory)||!this.editorHistory.currentBaseHistoryInfo||"Paste"!==this.editorHistory.currentBaseHistoryInfo.action)},e.prototype.toCheckForTrack=function(e){if(this.owner.enableTrackChanges&&!this.skipTracking()&&e instanceof o.dm&&e.childWidgets.length>0){var t=e.childWidgets[0].rowFormat;if(t.revisions.length>0&&"Insertion"!==t.revisions[0].revisionType&&t.revisions[0].author===(""===this.owner.currentUser?"Guest user":this.owner.currentUser)||0===t.revisions.length)return!0}return!1},e.prototype.removeFootnote=function(e,t){if(e.paragraph.bodyWidget.page.footnoteWidget){for(var i=e.paragraph.bodyWidget.page.footnoteWidget,r=0;r<i.bodyWidgets.length;r++)e===i.bodyWidgets[r].footNoteReference&&(i.height-=i.bodyWidgets[r].childWidgets[0].height,i.bodyWidgets.splice(r,1),r--);0===i.bodyWidgets.length&&(e.paragraph.bodyWidget.page.footnoteWidget=void 0)}this.documentHelper.footnoteCollection.splice(this.documentHelper.footnoteCollection.indexOf(e),1)},e.prototype.removeEndnote=function(e,t){if(e.paragraph.bodyWidget.page.endnoteWidget){for(var i=e.paragraph.bodyWidget.page.endnoteWidget,r=0;r<i.bodyWidgets.length;r++)e===i.bodyWidgets[r].footNoteReference&&(i.height-=i.bodyWidgets[r].childWidgets[0].height,i.bodyWidgets.splice(r,1),r--);0===i.bodyWidgets.length&&(e.paragraph.bodyWidget.page.endnoteWidget=void 0)}this.documentHelper.endnoteCollection.splice(this.documentHelper.endnoteCollection.indexOf(e),1)},e.prototype.removeAutoShape=function(e){var t=e.line.paragraph.floatingElements.indexOf(e),i=e.line.paragraph.bodyWidget.floatingElements.indexOf(e);i>-1&&e.line.paragraph.bodyWidget.floatingElements.splice(i,1),e.line.paragraph.floatingElements.splice(t,1)},e.prototype.removeField=function(e,t,i){var r=this.documentHelper.fields;if(t?r=this.documentHelper.bookmarks.keys:i&&(r=this.documentHelper.contentControlCollection),e.floatingElements.length>0)for(var o=0;o<e.floatingElements.length;o++){var n=e.floatingElements[o];this.removeAutoShape(n)}for(var s=0;s<r.length;s++){var a=t?this.documentHelper.bookmarks.get(r[s]):r[s];a.line.paragraph===e&&(t?this.documentHelper.bookmarks.remove(r[s]):i?this.documentHelper.contentControlCollection.splice(s,1):(this.documentHelper.fields.splice(s,1),-1!==this.documentHelper.formFields.indexOf(a)&&this.documentHelper.formFields.splice(this.documentHelper.formFields.indexOf(a),1)),s--)}if(this.documentHelper.footnoteCollection.length>0)for(s=0;s<this.documentHelper.footnoteCollection.length;s++){a=this.documentHelper.footnoteCollection[s];if(a.line.paragraph===e){if(a.paragraph.bodyWidget.page.footnoteWidget){for(var l=a.paragraph.bodyWidget.page.footnoteWidget,d=0;d<l.bodyWidgets.length;d++)a===l.bodyWidgets[d].footNoteReference&&(l.height-=l.bodyWidgets[d].height,l.bodyWidgets.splice(d,1),d--);0===l.bodyWidgets.length&&(a.paragraph.bodyWidget.page.footnoteWidget=void 0)}this.documentHelper.footnoteCollection.splice(s,1),s--}}if(this.documentHelper.endnoteCollection.length>0)for(s=0;s<this.documentHelper.endnoteCollection.length;s++){a=this.documentHelper.endnoteCollection[s];if(a.line.paragraph===e){if(a.paragraph.bodyWidget.page.endnoteWidget){var h=a.paragraph.bodyWidget.page.endnoteWidget;for(d=0;d<h.bodyWidgets.length;d++)a===h.bodyWidgets[d].footNoteReference&&(h.height-=h.bodyWidgets[d].height,h.bodyWidgets.splice(d,1),d--);0===h.bodyWidgets.length&&(a.paragraph.bodyWidget.page.endnoteWidget=void 0)}this.documentHelper.endnoteCollection.splice(s,1),s--}}},e.prototype.addRemovedNodes=function(e,t){e instanceof o.Xw&&0===e.commentType&&e.commentMark&&e.removeCommentMark(),e instanceof o.h&&0===e.type&&this.documentHelper.contentControlCollection.splice(this.documentHelper.contentControlCollection.indexOf(e),1),e instanceof o.V8&&0===e.fieldType&&(-1!==this.documentHelper.fields.indexOf(e)&&this.documentHelper.fields.splice(this.documentHelper.fields.indexOf(e),1),-1!==this.documentHelper.formFields.indexOf(e)&&this.documentHelper.formFields.splice(this.documentHelper.formFields.indexOf(e),1)),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)?t?this.editorHistory.currentBaseHistoryInfo.removedNodes.splice(0,0,e):this.editorHistory.currentBaseHistoryInfo.removedNodes.push(e):this.editHyperlinkInternal&&this.nodes.push(e)},e.prototype.deleteBlock=function(e,t,i,r,n){if(e instanceof o.ZH){if(this.deletePara(e,i,r,n),this.delBlockContinue&&this.delBlock){if(this.delSection){var s=e.bodyWidget instanceof o.VB?e.bodyWidget:void 0;this.deleteSection(t,this.delSection,s,n),this.delSection=void 0}-1!==this.delBlock.indexInOwner&&this.deleteBlock(this.delBlock,t,i,r,n),this.delBlockContinue=!1,this.delBlock=void 0}}else this.deleteTableBlock(e,t,i,r,n)},e.prototype.deleteTableCell=function(e,t,i,r,n){var s=!(i.paragraph.isInsideTable&&e.ownerTable.contains(i.paragraph.associatedCell)),l=e.ownerTable.previousRenderedWidget;if(i.paragraph.isInsideTable){var d=t.getContainerCellOf(e,i.paragraph.associatedCell);if(d.ownerTable.contains(i.paragraph.associatedCell)){var h=t.getSelectedCell(e,d);t.getSelectedCell(i.paragraph.associatedCell,d);if(t.containsCell(d,i.paragraph.associatedCell))if(t.isCellSelected(d,i,r))if(this.updateEditPosition(d,t),1===n)this.deleteCellsInTable(e.ownerRow.ownerTable,t,i,r,n);else{var c=this.deleteCell(d,t,n,!0);!c&&2!==n&&this.editorHistory?this.editorHistory.currentBaseHistoryInfo=void 0:c&&this.documentHelper.layout.reLayoutTable(d.ownerRow.ownerTable)}else if(h===d){if(this.deletePara(r.paragraph,i,r,n),this.delBlockContinue&&this.delBlock){if(this.delSection){var p=r.paragraph,g=p.bodyWidget instanceof o.VB?p.bodyWidget:void 0;this.deleteSection(t,this.delSection,g,n),this.delSection=void 0}this.deleteBlock(this.delBlock,t,i,r,n),this.delBlockContinue=!1,this.delBlock=void 0}}else this.deleteContainer(h,t,i,r,n);else 2===n?this.deleteCell(e,t,2,!1):this.deleteCellsInTable(d.ownerTable,t,i,r,n)}else this.deleteContainer(d,t,i,r,n)}else{var u=t.getContainerCell(e);this.deleteContainer(u,t,i,r,n)}if(s){l.bodyWidget instanceof o.VB&&l.bodyWidget;(0,a.le)(l)||this.deleteBlock(l,t,i,r,n)}},e.prototype.deleteCellsInTable=function(e,t,i,r,o,n){var s="Delete",l=!1,d=i.paragraph.associatedCell,h=r.paragraph.associatedCell;if((0,a.le)(n)||(h=n),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)){if(s=this.editorHistory.currentBaseHistoryInfo.action,l="BackSpace"===this.editorHistory.currentBaseHistoryInfo.action||"DeleteCells"===this.editorHistory.currentBaseHistoryInfo.action||"InsertTable"===this.editorHistory.currentBaseHistoryInfo.action||"RemoveRowTrack"===this.editorHistory.currentBaseHistoryInfo.action||(0,a.le)(d.ownerRow.previousWidget)&&(0,a.le)(h.ownerRow.nextWidget)&&"Cut"===this.editorHistory.currentBaseHistoryInfo.action,this.cloneTableToHistoryInfo(e),"RemoveRowTrack"===this.editorHistory.currentBaseHistoryInfo.action)return;this.editorHistory.currentBaseHistoryInfo.action=l?"DeleteCells":"ClearCells",t.owner.isLayoutEnabled=!1}var c=d.columnIndex,p=h.columnIndex+h.cellFormat.columnSpan-1,g=d.rowIndex,u=h.rowIndex,m=this.isWholeRowSelected(d.ownerRow,c,p);if(this.owner.enableTrackChanges&&!this.skipTracking())if(m)this.onConfirmedTableCellsDeletion(e,t,g,u,c,p,l,o,m,s);else{var f=new a.E7("documenteditor",this.owner.defaultLocale),v=f.getConstant("UnTrack"),y=f.getConstant("Merge Track");f.setLocale(this.owner.locale),this.alertDialog=R.hZ.alert({title:v,content:y,showCloseIcon:!0,okButton:{text:"Ok",click:this.onConfirmedTableCellsDeletion.bind(this,e,t,g,u,c,p,l,o,m,s)},closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"}}),this.alertDialog.enableRtl=this.owner.enableRtl}else this.onConfirmedTableCellsDeletion(e,t,g,u,c,p,l,o,m,s)}
1,e.prototype.removeDeletedCellRevision=function(e){e.rowFormat.revisions.length>0&&this.unlinkRangeFromRevision(e.rowFormat,!0);for(var t=0;t<e.childWidgets.length;t++)for(var i=e.childWidgets[t],r=0;r<i.childWidgets.length;r++){var n=i.childWidgets[r];if(!(0,a.le)(n)&&n instanceof o.ZH){for(var s=0;s<n.childWidgets.length;s++){var l=n.childWidgets[s];if(!(0,a.le)(l.children))for(var d=0;d<l.children.length;d++){var h=l.children[d];h.revisions.length>0&&this.unlinkRangeFromRevision(h,!0)}}this.unlinkRangeFromRevision(n.characterFormat,!0)}}},e.prototype.onConfirmedTableCellsDeletion=function(e,t,i,r,o,n,s,l,d,h){for(var c=0;c<e.childWidgets.length;c++){var p=e.childWidgets[c],g=!1;if(p.index>=i&&p.index<=r&&(this.owner.enableTrackChanges&&!this.skipTracking()&&d?(g=this.trackRowDeletion(p,!1),g&&this.onConfirmedCellDeletion(p,t,i,r,o,n,s,l)):this.onConfirmedCellDeletion(p,t,i,r,o,n,s,l)),!g&&0===p.childWidgets.length){var u=e.childWidgets[c],m=u.previousRenderedWidget;while(!(0,a.le)(m)){for(var f=0;f<m.childWidgets.length;f++){var v=m.childWidgets[f];u.rowIndex<v.ownerRow.rowIndex+v.cellFormat.rowSpan&&v.cellFormat.rowSpan--}m=m.previousRenderedWidget}this.updateNextBlocksIndex(u,!1),e.childWidgets.splice(c,1),c--,r--}}if(t.owner.isLayoutEnabled=!0,0===e.childWidgets.length?(t.editPosition=this.selection.getHierarchicalIndex(e,"0"),this.setActionInternal(t,h),this.removeBlock(e)):(e.isGridUpdated=!1,e.buildTableColumns(),e.isGridUpdated=!0,this.documentHelper.layout.reLayoutTable(e)),!(0,a.le)(this.alertDialog)){var y=t.getTextPosBasedOnLogicalIndex(t.editPosition);t.selectContent(y,!0),this.reLayout(t),this.alertDialog.close(),this.alertDialog=void 0}},e.prototype.onConfirmedCellDeletion=function(e,t,i,r,n,s,a,l){var d=!1;this.removeDeletedCellRevision(e);for(var h=0;h<e.childWidgets.length;h++){var c=e.childWidgets[h];if(c.columnIndex>=n&&c.columnIndex<=s)if(d||(this.updateEditPosition(c,t),d=!0),a){var p=e.childWidgets[h];this.updateNextBlocksIndex(p,!1);for(var g=0;g<p.childWidgets.length;g++)for(var u=p.childWidgets[g],m=0;m<u.childWidgets.length;m++){var f=u.childWidgets[m];if(f instanceof o.z7)for(var v=f,y=0;y<v.children.length;y++){var F=v.children[y];F instanceof o.R5&&this.removeFootnote(F)}}e.childWidgets.splice(h,1),h--}else l<4&&this.deleteCell(c,t,l,!1)}},e.prototype.removeRevisionForRow=function(e){e.rowFormat.revisions.length>0&&this.skipTracking()&&(this.unlinkRangeFromRevision(e.rowFormat,!0),this.addRemovedRevisionInfo(e.rowFormat,void 0))},e.prototype.removeRevisionsInRow=function(e){if(e.rowFormat.revisions.length>0)for(var t=0;t<e.rowFormat.revisions.length;t++){var i=e.rowFormat.revisions[t];this.unlinkWholeRangeInRevision(e.rowFormat,i)}},e.prototype.removeRevisionForCell=function(e,t){for(var i=0;i<e.childWidgets.length;i++)if(e.childWidgets[i]instanceof o.ZH)for(var r=e.childWidgets[i],n=0;n<r.childWidgets.length;n++)for(var s=r.childWidgets[n],l=0;l<s.children.length;l++){var d=s.children[l];!(0,a.le)(d)&&d.revisions.length>0&&(this.unlinkRangeFromRevision(d,t),this.addRemovedRevisionInfo(d,void 0))}else e.childWidgets[i]instanceof o.dm&&this.removeRevisionForInnerTable(e.childWidgets[i])},e.prototype.removeRevisionForInnerTable=function(e){if(e.childWidgets.length>0)for(var t=0;t<e.childWidgets.length;t++){var i=e.childWidgets[t];(0,a.le)(i)||this.removeRevisionForRow(i)}},e.prototype.removeRevisionForBlock=function(e,t,i,r){if(e.characterFormat.revisions.length>0&&!i&&(r&&this.addRemovedRevisionInfo(e.characterFormat,void 0,!1),(0,a.le)(t)?this.unlinkRangeFromRevision(e.characterFormat,!0):this.unlinkRangeByRevision(e.characterFormat,t),e.characterFormat.revisions=[]),!(0,a.le)(e))for(var o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.children.length;s++){var l=n.children[s];!(0,a.le)(l)&&l.revisions.length>0&&(r&&this.addRemovedRevisionInfo(l,void 0,!1),(0,a.le)(t)?this.unlinkRangeFromRevision(l,!0):this.unlinkRangeByRevision(l,t),l.revisions=[])}},e.prototype.unlinkRangeByRevision=function(e,t){for(var i=0;i<e.revisions.length;i++){var r=e.revisions[i];if(r.author===t.author&&r.revisionType===t.revisionType){e.revisions.splice(e.revisions.indexOf(t),1);var o=t.range.indexOf(e);t.range.splice(o,1)}}},e.prototype.isWholeRowSelected=function(e,t,i){var r=t+i;return 0===t&&e.childWidgets.length-1===r},e.prototype.deleteCell=function(e,t,i,r){var n=e.childWidgets[0];if(1===e.childWidgets.length&&n instanceof o.ZH&&n.isEmpty())return!1;for(var s=e.childWidgets.length-1,a=e.childWidgets.length-1;a>-1;a--)if(n=e.childWidgets[a],i<4){if(n instanceof o.ZH&&a===s){var l=n;if(this.checkClearCells(t))l.isEmpty()||this.removeInlines(l,l.firstChild,0,l.lastChild,l.lastChild.getEndOffset(),i);else for(var d=l.childWidgets.length-1;d>=0;d--){for(var h=l.childWidgets[d],c=h.children.length-1;c>=0;c--){var p=h.children[c];p instanceof o.R5?this.removeFootnote(p):p instanceof o.aQ&&0===p.bookmarkType&&this.documentHelper.bookmarks.containsKey(p.name)&&this.documentHelper.bookmarks.remove(p.name),this.unLinkFieldCharacter(p),h.children.splice(c,1)}l.childWidgets.length>1&&l.childWidgets.splice(d,1)}continue}this.removeBlock(n),this.checkClearCells(t)&&(this.addRemovedNodes(n),1===e.childWidgets.length&&(t.editPosition=this.selection.getHierarchicalIndex(e.childWidgets[0],"0"),this.updateHistoryPosition(t.editPosition,!0)))}return!0},e.prototype.paragrapghBookmarkCollection=function(e,t){for(var i=this.documentHelper.bookmarks,r=0;r<i.length;r++){var o=this.documentHelper.bookmarks.get(i.keys[r]);o.paragraph===e&&t.push(o)}return t},e.prototype.deleteContainer=function(e,t,i,r,o){var n=e.ownerTable;if(t.containsRow(n.lastChild,r.paragraph.associatedCell))this.deleteContent(n,t,o);else if(this.toCheckForTrack(n))for(var s=0;s<n.childWidgets.length;s++){var a=n.childWidgets[s];if(this.trackRowDeletion(a),r.paragraph.isInsideTable&&t.containsRow(a,r.paragraph.associatedCell))return void this.documentHelper.layout.reLayoutTable(n)}else for(s=0;s<n.childWidgets.length;s++){var l=n.childWidgets[s];if(o<4&&(this.updateNextBlocksIndex(l,!1),n.childWidgets.splice(s,1),this.addRemovedNodes(l),s--),r.paragraph.isInsideTable&&t.containsRow(l,r.paragraph.associatedCell))return void this.documentHelper.layout.reLayoutTable(n)}},e.prototype.deleteTableBlock=function(e,t,i,r,n){if(e=e.combineWidget(this.owner.viewer),i.paragraph.isInsideTable&&e.contains(i.paragraph.associatedCell)){var s=e.previousRenderedWidget,l=this.checkAndInsertBlock(e,i,r,n,s instanceof o.ZH?s:void 0);if(t.containsRow(e.firstChild,i.paragraph.associatedCell))this.deleteContent(e,t,n);else if(this.owner.enableTrackChanges){if((0,a.le)(r.paragraph.associatedCell)&&!r.paragraph.isInsideTable){var d=r.paragraph.previousRenderedWidget.lastChild,h=d.lastChild;this.deleteCellsInTable(e,t,i,r,n,h)}}else{var c=this.splitTable(e,i.paragraph.associatedCell.ownerRow);this.deleteContent(e,t,n),this.documentHelper.layout.layoutBodyWidgetCollection(c.index,c.containerWidget,c,!1)}(0,a.le)(l)||(t.editPosition=this.selection.getHierarchicalIndex(l,"0"),this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.endPosition=t.editPosition))}else{var p=e.previousRenderedWidget;e.bodyWidget instanceof o.VB&&e.bodyWidget;if(this.owner.enableTrackChanges)for(var g=0;g<e.childWidgets.length;g++)this.trackRowDeletion(e.childWidgets[g]);else this.deleteContent(e,t,n);(0,a.le)(p)||this.deleteBlock(p,t,i,r,n)}},e.prototype.splitTable=function(e,t){var i=new o.dm;i.tableFormat.copyFormat(e.tableFormat),i.index=e.index;for(var r=0;r<e.childWidgets.length;r++){var n=e.childWidgets[r];if(n===t)break;
1i.childWidgets.push(n),n.containerWidget=i,e.childWidgets.splice(r,1),r--}var s=e.getIndex();return e.containerWidget.childWidgets.splice(s,0,i),i.containerWidget=e.containerWidget,this.updateNextBlocksIndex(i,!0),i},e.prototype.updateEditPosition=function(e,t){var i=this.documentHelper.getFirstParagraphInCell(e);t.editPosition=this.selection.getHierarchicalIndex(i,"0")},e.prototype.deleteContent=function(e,t,i){i<4&&(this.removeBlock(e),this.addRemovedNodes(e))},e.prototype.setActionInternal=function(e,t){this.documentHelper.owner.enableHistoryMode&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.editorHistory.currentBaseHistoryInfo.action=t)},e.prototype.checkClearCells=function(e){return this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&"ClearCells"!==this.editorHistory.currentBaseHistoryInfo.action},e.prototype.isEndInAdjacentTable=function(e,t){var i=this.selection.getHierarchicalIndex(e,""),r=this.selection.getHierarchicalIndex(t,""),o=i.split(";"),n=r.split(";");return o.length<n.length},e.prototype.cloneTableToHistoryInfo=function(e){if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)){var t=e.clone();return this.editorHistory.currentBaseHistoryInfo.removedNodes.push(t),this.documentHelper.selection.start.paragraph.isInsideTable&&this.documentHelper.selection.start.paragraph.associatedCell.ownerTable===e&&this.updateHistoryPosition(this.selection.getHierarchicalIndex(e,"0"),!0),t}},e.prototype.insertParagraphPaste=function(e,t,i,r,o,n,s){if(this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&"Paste"===this.editorHistory.currentBaseHistoryInfo.action){var l=this.selection.getNextParagraphBlock(t);if(l&&i.offset>0&&l===r.paragraph&&e===i.paragraph&&"Paste"===this.editorHistory.currentBaseHistoryInfo.action){var d=0;this.removeBlock(t),this.documentHelper.layout.clearListElementBox(l),this.documentHelper.layout.clearListElementBox(t);for(var h=0;h<t.childWidgets.length;h++){var c=t.childWidgets[h];l.childWidgets.splice(d,0,c),t.childWidgets.splice(h,1),h--,d++,c.paragraph=l}this.documentHelper.layout.reLayoutParagraph(l,0,0),o=!1;var p=this.selection.editPosition.substring(this.selection.editPosition.lastIndexOf(";")+1);this.selection.editPosition=this.selection.getHierarchicalIndex(l,p)}}o&&this.deleteParagraphMark(t,this.selection,n,!1,s)},e.prototype.removeInlines=function(e,t,i,r,o,n){var s=!1;this.documentHelper.layout.clearListElementBox(e);e.childWidgets.indexOf(t);for(var a=this.selection.start.clone(),l=this.selection.end.clone(),d=this.selection.editPosition,h=e.childWidgets.length-1;h>=0;h--){var c=e.childWidgets[h];if(t===c&&r===c){this.removeContent(c,i,o,n),s=!0;break}if(r===c)s=!0,this.removeContent(c,0,o,n);else{if(t===c){this.removeContent(c,i,this.documentHelper.selection.getLineLength(c),n);break}s&&this.removeContent(c,0,this.documentHelper.selection.getLineLength(c),n)}}this.owner.enableTrackChanges&&!this.skipTracking()&&(this.selection.start.setPositionInternal(a),this.selection.end.setPositionInternal(l),this.skipReplace&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=void 0,this.updateInsertPosition()),this.selection.editPosition=d),s&&(this.removeEmptyLine(e),this.documentHelper.layout.reLayoutParagraph(e,0,0))},e.prototype.skipTracking=function(){return!((0,a.le)(this.editorHistory)||!this.editorHistory.isUndoing&&!this.editorHistory.isRedoing)||!((0,a.le)(this.editorHistory)||!this.editorHistory.currentBaseHistoryInfo||"Reject Change"!==this.editorHistory.currentBaseHistoryInfo.action&&"Accept Change"!==this.editorHistory.currentBaseHistoryInfo.action)},e.prototype.canHandleDeletion=function(){return!((0,a.le)(this.editorHistory)||!this.editorHistory.currentBaseHistoryInfo||"DeleteRow"!==this.editorHistory.currentBaseHistoryInfo.action)},e.prototype.deleteCommentInSelection=function(e){var t=this.editorHistory.currentBaseHistoryInfo;!this.editorHistory||!this.editorHistory.currentBaseHistoryInfo||this.editorHistory.currentHistoryInfo||this.editorHistory.isUndoing||this.editorHistory.isRedoing||this.initComplexHistory("DeleteCommentInline"),this.deleteCommentInternal(e),this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing||this.editorHistory.currentHistoryInfo.addModifiedAction(t),this.selection.editPosition=t.insertPosition,this.editorHistory.currentHistoryInfo.insertPosition=this.selection.editPosition,this.editorHistory.currentBaseHistoryInfo=t)},e.prototype.removeContent=function(e,t,i,r){for(var n=this.selection.getLineLength(e),s=void 0,l=0,d=void 0,h=e.children.length-1;h>=0;h--){var c=e.children[h];if((0,a.le)(r)||2!==r&&1!==r)for(var p=0;p<e.children.length;p++){var g=e.children[p];if(g instanceof o.a3){var u=g.text;u.length+l>t&&!(l>t)&&(s=u[t-l-1],(0,a.le)(s)&&t-l===0&&(s=d)),u.length+l>i&&(" "===u[i-l]&&0===t||" "===s&&" "===u[i-l])&&(i+=1),d=u[u.length-1]}l+=g.length}if(i<=n-c.length)n-=c.length;else{var m=c.length;n>i&&n-m<i&&(m=i-(n-c.length));var f=0;if(n-c.length<t&&(f=t-(n-c.length)),n>i&&(n-=c.length-m),0===f&&m===c.length){if((!this.owner.enableTrackChanges||this.owner.enableTrackChanges&&this.skipTracking())&&(this.editorHistory&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing)||c instanceof o.aQ&&this.removedBookmarkElements.push(c),c instanceof o.aQ&&this.documentHelper.bookmarks.containsKey(c.name)&&this.documentHelper.bookmarks.remove(c.name)),(c instanceof o.XY&&"Inline"!==c.textWrappingStyle||c instanceof o.f7)&&this.removeAutoShape(c),this.skipFieldDeleteTracking&&c.revisions.length>0){var v=c;v instanceof o.V8&&(1!==v.fieldType&&2!==v.fieldType||(v=v.fieldBegin),this.clearFieldElementRevisions(v,c.revisions))}
1this.canHandleDeletion()||this.owner.enableTrackChanges&&!this.skipTracking()&&!this.skipFieldDeleteTracking&&!this.isInsertingTOC?(this.skipTableElements||this.addRemovedNodes(c.clone()),this.handleDeleteTracking(c,t,i,h)):(c instanceof o.R5&&(c.isLayout=!1),this.unLinkFieldCharacter(c),this.unlinkRangeFromRevision(c,!0),this.addRemovedRevisionInfo(c,void 0),this.addRemovedNodes(c),e.children.splice(h,1))}else if(c instanceof o.a3){var y=this.handleDeleteTracking(c,f,m);(0,a.le)(y)||this.skipTableElements||(c.revisions.length>0&&this.addRemovedRevisionInfo(c,y),this.addRemovedNodes(y))}if(c instanceof o.R5&&("Footnote"===c.footnoteType?this.removeFootnote(c):this.removeEndnote(c)),t>=n-(m-f))break;n-=m-f,this.documentHelper.layout.clearListElementBox(e.paragraph)}}},e.prototype.deleteCommentWidgetInline=function(e){},e.prototype.clearFieldElementRevisions=function(e,t){for(var i=t,r=0;r<i.length;r++)for(var n=i[r],s=0;s<n.range.length;s++)if(n.range[s]===e)for(var a=s;a<n.range.length;a){if(n.range[s]instanceof o.V8&&1===n.range[s].fieldType&&n.range[s].fieldBegin===e){n.removeRangeRevisionForItem(n.range[s]),0===n.range.length&&this.owner.revisions.remove(n);break}n.removeRangeRevisionForItem(n.range[s])}},e.prototype.addRemovedRevisionInfo=function(e,t,i){for(var r=0;r<e.revisions.length;r++){var o=e.revisions[r].revisionID;(0,a.le)(t)?e.removedIds.push(o):t.removedIds.push(o)}(0,a.le)(t)&&((0,a.le)(i)||i)&&(e.revisions=[])},e.prototype.removeEmptyLine=function(e){if(e.childWidgets.length>1)for(var t=0;t<e.childWidgets.length;t++){var i=e.childWidgets[t];0===i.children.length&&e.childWidgets.length>1&&(e.childWidgets.splice(t,1),t--)}},e.prototype.cloneListLevel=function(e){var t=new y.q(void 0);return this.copyListLevel(t,e),t},e.prototype.copyListLevel=function(e,t){(0,a.le)(t.paragraphFormat)||(e.paragraphFormat=new h.h(e),e.paragraphFormat.copyFormat(t.paragraphFormat)),(0,a.le)(t.characterFormat)||(e.characterFormat=new n.a(e),e.characterFormat.copyFormat(t.characterFormat)),(0,a.le)(t.followCharacter)||(e.followCharacter=t.followCharacter),(0,a.le)(t.listLevelPattern)||(e.listLevelPattern=t.listLevelPattern),(0,a.le)(t.numberFormat)||(e.numberFormat=t.numberFormat),(0,a.le)(t.restartLevel)||(e.restartLevel=t.restartLevel),(0,a.le)(t.startAt)||(e.startAt=t.startAt)},e.prototype.cloneLevelOverride=function(e){var t=new F.J;return(0,a.le)(e.startAt)||(t.startAt=e.startAt),(0,a.le)(e.overrideListLevel)||(t.overrideListLevel=e.overrideListLevel),(0,a.le)(e.levelNumber)||(t.levelNumber=e.levelNumber),t},e.prototype.updateListParagraphs=function(){this.documentHelper.listParagraphs=[];for(var e=0;e<this.documentHelper.pages.length;e++)for(var t=this.documentHelper.pages[e].bodyWidgets[0],i=0;i<t.childWidgets.length;i++)this.updateListParagraphsInBlock(t.childWidgets[i])},e.prototype.updateListParagraphsInBlock=function(e){if(e instanceof o.ZH)(0,a.le)(e.paragraphFormat)||(0,a.le)(e.paragraphFormat.listFormat)||(0,a.le)(e.paragraphFormat.listFormat.listId)||(e.paragraphFormat.listFormat.listId>=0&&e.paragraphFormat.clearIndent(),(0,a.le)(this.documentHelper.listParagraphs)&&(this.documentHelper.listParagraphs=[]),this.documentHelper.listParagraphs.push(e));else if(e instanceof o.dm)for(var t=0;t<e.childWidgets.length;t++)for(var i=0;i<e.childWidgets[t].childWidgets.length;i++)for(var r=e.childWidgets[t].childWidgets[i],n=0;n<r.childWidgets.length;n++)this.updateListParagraphsInBlock(r.childWidgets[n])},e.prototype.onApplyList=function(e){var t=this.documentHelper.selection;this.setOffsetValue(this.documentHelper.selection),this.initHistory("ListFormat");var i=new u.s;(0,a.le)(e)||(i.listId=e.listId),this.documentHelper.owner.isShiftingEnabled=!0,t.isEmpty?(this.applyParaFormatProperty(t.start.paragraph,"listFormat",i,!1),this.layoutItemBlock(t.start.paragraph,!1)):this.updateSelectionParagraphFormatting("listFormat",i,!1),this.reLayout(t)},e.prototype.applyBulletOrNumbering=function(e,t,i){var r=this.documentHelper.selection,n=r.paragraphFormat.getList(),s=!1,l=r.start;r.isForward||(l=r.end);var d=l.paragraph;if((0,a.le)(n)){while(!(0,a.le)(d.previousWidget)&&d.previousWidget instanceof o.ZH&&d.previousWidget.isEmpty()&&-1===d.previousWidget.paragraphFormat.listFormat.listId)d=d.previousWidget;if(d.previousWidget&&d.previousWidget instanceof o.ZH&&-1!==d.previousWidget.paragraphFormat.listFormat.listId&&(d=d.previousWidget,n=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId),s=!0),!s){while(!(0,a.le)(d.nextWidget)&&d.nextWidget instanceof o.ZH&&d.nextWidget.isEmpty()&&-1===d.nextWidget.paragraphFormat.listFormat.listId)d=d.nextWidget;d.nextWidget&&d.nextWidget instanceof o.ZH&&-1!==d.nextWidget.paragraphFormat.listFormat.listId&&(d=d.nextWidget,n=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId),s=!0)}}var h=void 0,c=-1,p=void 0,g=!1;if(-1===d.paragraphFormat.listFormat.listId||(0,a.le)(d.paragraphFormat.listFormat.listLevel)||(this.listNumberFormat=d.paragraphFormat.listFormat.listLevel.numberFormat,this.listLevelPattern=d.paragraphFormat.listFormat.listLevel.listLevelPattern,this.listLevelNumber=d.paragraphFormat.listFormat.listLevelNumber),!(0,a.le)(n)){c=d.paragraphFormat.listFormat.listLevelNumber;var u=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId);h=this.documentHelper.layout.getListLevel(u,c),c>0&&(p=this.documentHelper.layout.getListLevel(u,0),g=!(0,a.le)(p)&&c>
10&&r.start.isInSameParagraph(r.end));var m=u.abstractList;if(m||(m=this.documentHelper.getAbstractListById(n.abstractListId)),0===m.levels.length&&(h=this.documentHelper.layout.getListLevel(u,d.paragraphFormat.listFormat.listLevelNumber)),s){if("Bullet"!==t&&h.listLevelPattern===t&&(h.numberFormat===e||-1!==h.numberFormat.indexOf(e)))return r.paragraphFormat.listId=n.listId,r.paragraphFormat.listLevelNumber=c,void r.paragraphFormat.setList(n);h=m.levels[0]}}if((0,a.le)(n)||!(0,a.le)(n)&&0===c&&(h.listLevelPattern!==t||h.numberFormat!==e||h.characterFormat.fontFamily!==i&&"Bullet"===h.listLevelPattern)){s=!1,n=new f.f,this.documentHelper.lists.length>0?n.listId=this.documentHelper.lists[this.documentHelper.lists.length-1].listId+1:n.listId=0;m=new v.S;if(this.documentHelper.abstractLists.length>0?m.abstractListId=this.documentHelper.abstractLists[this.documentHelper.abstractLists.length-1].abstractListId+1:m.abstractListId=0,n.abstractListId=m.abstractListId,n.abstractList=m,this.documentHelper.abstractLists.push(m),"bullet"===e||"multiLevel"===e||"numbering"===e)this.addListLevels(m,e,r);else{var F=new y.q(m);F.listLevelPattern=t,F.numberFormat=e,"Bullet"!==t?F.startAt=1:F.characterFormat.fontFamily=i,F.paragraphFormat.leftIndent=36,F.paragraphFormat.firstLineIndent=-18,m.levels.push(F),r.paragraphFormat.listLevelNumber=0}r.paragraphFormat.setList(n)}else if(g&&!(0,a.le)(n)){u=this.documentHelper.getListById(d.paragraphFormat.listFormat.listId),F=this.documentHelper.layout.getListLevel(u,c);if("Bullet"===t)F.numberFormat=e,F.characterFormat.fontFamily=i;else{F.listLevelPattern=t,F.characterFormat.fontFamily=i;var H=F.numberFormat.substring(F.numberFormat.length-1);F.numberFormat.length!==e.length&&c>0?F.numberFormat=e:e.substring(e.length-1)!==F.numberFormat.substring(F.numberFormat.length-1)&&(F.numberFormat=F.numberFormat.replace(H,e.substring(e.length-1)))}r.paragraphFormat.setList(u)}else!(0,a.le)(n)&&s?r.paragraphFormat.setList(n):r.paragraphFormat.setList(void 0)},e.prototype.addListLevels=function(e,t,i){for(var r=[String.fromCharCode(61558),String.fromCharCode(61656),String.fromCharCode(61607),String.fromCharCode(61623),String.fromCharCode(61608)],o=e.levels.length;o<9;o++){var n=new y.q(e);if(t.match("bullet"))n.listLevelPattern="Bullet",n.numberFormat=r[o<5?o%5:o%5+1],n.characterFormat.fontFamily=o<3||5===o?"Wingdings":"Symbol";else{if(t.match("multiLevel")){for(var s=0;s<o+1;s++)n.numberFormat+="%"+(s+1).toString()+".";n.listLevelPattern="Number"}else n.numberFormat="%"+(o+1).toString()+")",n.listLevelPattern=o%3===0?"Number":o%3===1?"LowLetter":"LowRoman";n.startAt=1,n.restartLevel=o}n.paragraphFormat.leftIndent=0===o?36:36*o,n.paragraphFormat.firstLineIndent=-18,e.levels.push(n),i.paragraphFormat.listLevelNumber=o}},e.prototype.insertPageBreak=function(){if(!this.owner.isReadOnlyMode){if(this.documentHelper.selection.start.paragraph.isInsideTable||this.documentHelper.selection.start.paragraph.isInHeaderFooter)return;this.initComplexHistory("PageBreak"),this.onEnter("PageBreak"),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&this.editorHistory.updateComplexHistory(),this.selection.checkForCursorVisibility()}},e.prototype.insertColumnBreak=function(){if(!this.owner.isReadOnlyMode){if(this.documentHelper.selection.start.paragraph.isInsideTable||this.documentHelper.selection.start.paragraph.isInHeaderFooter)return;this.initComplexHistory("ColumnBreak"),this.onEnter("ColumnBreak"),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&this.editorHistory.updateComplexHistory(),this.selection.checkForCursorVisibility()}},e.prototype.onEnter=function(e){var t,i=this.documentHelper.selection;if((0,a.le)(i.start.paragraph.paragraphFormat.baseStyle)||"Normal"===i.start.paragraph.paragraphFormat.baseStyle.name){t=new C.jP(void 0),t.cloneFormat(this.selection.characterFormat);var r=i.start.paragraph.lastChild.children[i.start.paragraph.lastChild.children.length-1];r instanceof o.R5&&(t.baselineAlignment="Normal")}if(!this.isXmlMapped){if(i.isEmpty){var n=i.getHyperlinkField(),s=!(0,a.le)(n);if(s)return void i.fireRequestNavigate(n);var l=i.start.paragraph;if(l.isEmpty()&&-1!==l.paragraphFormat.listFormat.listId)return void this.onApplyListInternal(this.documentHelper.getListById(l.paragraphFormat.listFormat.listId),l.paragraphFormat.listFormat.listLevelNumber-1)}var d=this.checkAndRemoveComments();this.initHistory("Enter");var h=!0;if(i.isEmpty||(h=this.removeSelectedContents(i)),h){i.owner.isShiftingEnabled=!0,this.updateInsertPosition();var c=this.selection.getParagraphInfo(i.start),p=this.selection.getHierarchicalIndex(c.paragraph,c.offset.toString());if(this.splitParagraphInternal(i,i.start.paragraph,i.start.currentWidget,i.start.offset),this.setPositionForCurrentIndex(i.start,p),!(0,a.le)(e)&&("PageBreak"===e||"ColumnBreak"===e)){var g=i.start.paragraph,u=new o.ZH;u.characterFormat.copyFormat(g.characterFormat),u.paragraphFormat.copyFormat(g.paragraphFormat);var m=new o.a3;switch(e){case"PageBreak":m.text="\f";break;case"ColumnBreak":m.text=String.fromCharCode(14);break}var f=new o.z7(u);if(f.children.push(m),m.line=f,u.childWidgets.push(f),this.owner.enableTrackChanges&&g.characterFormat.revisions.length>0){var v=this.retrieveRevisionInOder(g.characterFormat);v.range.push(u.characterFormat),u.characterFormat.revisions.push(v),u.characterFormat.removedIds=[]}this.insertParagraph(u,!0),i.selectParagraphInternal(u,!0)}var y=i.start.paragraph.nextWidget;(0,a.le)(y)&&(y=i.getNextRenderedBlock(i.start.paragraph)),i.selectParagraphInternal(y,!0),this.updateEndPosition(),!(0,a.le)(e)&&this.editorHistory&&this.owner.editorHistory.updateHistory(),this.reLayout(i);var F=this.selection.start.paragraph.containerWidget.firstChild;if(!(0,a.le)(F)){F.isChangeDetected=!1;var H=F.nextRenderedWidget;while(this.owner.isSpellCheck&&!(0,a.le)(H))F=H,F.isChangeDetected=!1,H=F.nextRenderedWidget}l=i.start.paragraph.previousWidget;!(0,a.le)(l)&&!l.isEmpty()&&l.lastChild.children[l.lastChild.children.length-1]instanceof o.a3&&this.checkAndConvertToHyperlink(i,!0,l)}(0,a.le)(t)||(0,a.le)(i.start.paragraph)||!i.start.paragraph.isEmpty()||(this.selection.isRetrieveFormatting=!0,this.selection.characterFormat.cloneFormat(t),this.selection.isRetrieveFormatting=!1),this.documentHelper.layout.islayoutFootnote=!1,this.updateHistoryForComments(d)}},e.prototype.splitParagraphInternal=function(e,t,i,r){var n=0,s=t.index,l=t;l.isChangeDetected=0===r;while(this.owner.isSpellCheck&&!(0,a.le)(l.nextRenderedWidget))l=l.nextRenderedWidget,l.isChangeDetected=!0;var d=new o.ZH,h=new o.z7(d);if(d.childWidgets.push(h),d.paragraphFormat.ownerBase=d,i===t.lastChild&&r===e.getLineLength(i)){if(t.paragraphFormat.baseStyle&&"Normal"!==t.paragraphFormat.baseStyle.name&&t.paragraphFormat.baseStyle.next instanceof I.wk?(t.paragraphFormat.baseStyle.name===t.paragraphFormat.baseStyle.next.name?(d.paragraphFormat.copyFormat(t.paragraphFormat),d.characterFormat.copyFormat(t.characterFormat)):d.paragraphFormat.baseStyle=t.paragraphFormat.baseStyle.next,this.selection.skipFormatRetrieval=!1):(d.paragraphFormat.copyFormat(t.paragraphFormat),d.characterFormat.copyFormat(t.characterFormat)),t.lastChild.children.length>0&&t.characterFormat.copyFormat(t.lastChild.children[t.lastChild.children.length-1].characterFormat),this.owner.enableTrackChanges){var c=t.lastChild;if(!(0,a.le)(c)&&c.children.length>0){var p=c.children[c.children.length-1].previousValidNodeForTracking;(0,a.le)(p)||this.checkParaMarkMatchedWithElement(p,t.characterFormat,!1,"Insertion")||this.insertParaRevision(t)}}n++,s++}else{if(d.paragraphFormat.copyFormat(t.paragraphFormat),d.characterFormat.copyFormat(t.characterFormat),r>0||!i.isFirstLine())t=t.combineWidget(this.owner.viewer),this.moveInlines(t,d,0,0,t.firstChild,r,i),this.owner.enableTrackChanges&&this.insertParaRevision(d,t.firstChild);else{var g=t.previousRenderedWidget,u=!1;if(!(0,a.le)(g)&&g instanceof o.ZH&&(u=g.characterFormat.revisions.length>0),this.owner.enableTrackChanges)if(u)this.checkToMatchEmptyParaMark(t,d)||this.insertParaRevision(t);else{var m=t.firstChild,f=m.children[0].previousValidNodeForTracking;(0,a.le)(f)||this.checkParaMarkMatchedWithElement(f,d.characterFormat,!0,"Insertion")?(0,a.le)(f)&&(n++,s++):this.insertParaRevision(d)}}t=t.getSplitWidgets()[0]}n+=t.getIndex();var v=t.containerWidget,y=v.childWidgets;if(y.splice(n,0,d),d.containerWidget=v,d.index=s,this.updateNextBlocksIndex(d,!0),!(0,a.le)(v.containerWidget)&&v.containerWidget instanceof o.tf||v instanceof o.nb&&!(0,a.le)(v.bodyWidget)&&v.bodyWidget.containerWidget instanceof o.tf){var F=this.documentHelper.textHelper.getParagraphMarkSize(d.characterFormat).Height;v instanceof o.nb?(v.bodyWidget.height+=F,v.bodyWidget.containerWidget.height+=F):(v.containerWidget.height+=F,v.height+=F)}this.owner.enableTrackChanges&&0===d.characterFormat.revisions.length&&0===t.characterFormat.revisions.length&&(this.checkToMatchEmptyParaMark(t)||this.insertParaRevision(t)),this.documentHelper.layout.layoutBodyWidgetCollection(s,v,d,!1)},e.prototype.insertParaRevision=function(e,t){if(this.owner.enableTrackChanges&&(0,a.le)(t)&&!this.isRevisionMatched(e.characterFormat,"Insertion")&&(e.characterFormat.revisions=[],this.insertRevision(e.characterFormat,"Insertion")),!(0,a.le)(t)){if(t.paragraph.isInsideTable)return void this.insertRevision(e.characterFormat,"Insertion");this.applyRevisionForParaMark(e,t,"Insertion",!0)}},e.prototype.applyRevisionForParaMark=function(e,t,i,r){var o=t.children[0];if(!(0,a.le)(o)){o=o.nextValidNodeForTracking;var n=e.lastChild,s=0===n.children.length?void 0:n.children[n.children.length-1].previousValidNodeForTracking,l=!1,d=e.characterFormat.revisions.length;if((0,a.le)(s)||(l=this.checkParaMarkMatchedWithElement(s,e.characterFormat,!1,i)),!(0,a.le)(o))if(e.characterFormat.revisions.length>d){if(this.isRevisionMatched(o,i))for(var h=e.characterFormat.revisions[0],c=this.getMatchedRevisionsToCombine(o.revisions,i),p=0;p<c.length;p++)c[p]!==h&&(l=!0,this.clearAndUpdateRevisons(c[p].range,h,h.range.indexOf(e.characterFormat)+1))}else l=this.checkParaMarkMatchedWithElement(o,e.characterFormat,!0,i);!l&&(this.owner.enableTrackChanges||t.paragraph.characterFormat.revisions.length>0)&&(this.insertRevision(e.characterFormat,i),r&&s.revisions.length>0&&o.revisions.length>0&&this.updateRevisionForSpittedTextElement(s,o))}},e.prototype.checkParaMarkMatchedWithElement=function(e,t,i,r){var o=this.getMatchedRevisionsToCombine(e.revisions,r);return o.length>0&&(this.mapMatchedRevisions(o,e,t,i),!0)},e.prototype.checkToMatchEmptyParaMark=function(e,t){var i=e.previousRenderedWidget;if(!(0,a.le)(i)&&i instanceof o.ZH&&i.characterFormat.revisions.length>0){var r=this.getMatchedRevisionsToCombine(i.characterFormat.revisions,"Insertion");if(r.length>0)return(0,a.le)(t)?this.mapMatchedRevisions(r,i.characterFormat,e.characterFormat,!1):this.mapMatchedRevisions(r,i.characterFormat,t.characterFormat,!1),!0}return!1},e.prototype.checkToMatchEmptyParaMarkBack=function(e){var t=e.nextRenderedWidget,i=t.childWidgets[0],r=i.children[0];if(!(0,a.le)(t)&&t instanceof o.ZH&&t.characterFormat.revisions.length>0){var n=this.getMatchedRevisionsToCombine(t.characterFormat.revisions,"Deletion");if(n.length>0)return void 0!=t&&void 0!=i&&void 0!=r&&1==r.revisions.length?(this.mapMatchedRevisions(n,r,e.characterFormat,!0),!0):(this.mapMatchedRevisions(n,t.characterFormat,e.characterFormat,!0),!0)}else if(void 0!=r&&1==r.revisions.length){n=this.getMatchedRevisionsToCombine(r.revisions,"Deletion");if(n.length>0)return this.mapMatchedRevisions(n,r,e.characterFormat,!0),!0}return!1},e.prototype.updateNextBlocksIndex=function(e,t){if(!((0,a.le)(e.nextRenderedWidget)||e.nextRenderedWidget instanceof o.ZH&&e.bodyWidget.index!==e.nextRenderedWidget.bodyWidget.index)){var i=e.containerWidget.childWidgets.indexOf(e)+1;if(e.containerWidget instanceof o.VB&&!(e.containerWidget.containerWidget instanceof o.tf))if(e.containerWidget.page.bodyWidgets.length>1)for(var r=e.containerWidget.indexInOwner,n=this.documentHelper.pages.indexOf(e.containerWidget.page);n<this.documentHelper.pages.length;n++){for(var s=this.documentHelper.pages[n],l=0;l<s.bodyWidgets.length;l++)if(s.bodyWidgets[l].indexInOwner===r){for(var d=i;d<s.bodyWidgets[l].childWidgets.length;d++){var h=s.bodyWidgets[l].childWidgets[d];this.updateIndex(h,t)}i=0,(0,a.le)(s.bodyWidgets[l].nextRenderedWidget)||"NoBreak"===s.bodyWidgets[l].nextRenderedWidget.sectionFormat.breakCode||r++}r!==e.containerWidget.indexInOwner&&!(0,a.le)(s.bodyWidgets[s.bodyWidgets.length-1].nextRenderedWidget)&&s.bodyWidgets[s.bodyWidgets.length-1].nextRenderedWidget.sectionFormat.columns.length>1&&(r=0)}else{var c=e.containerWidget.index;for(l=this.documentHelper.pages.indexOf(e.containerWidget.page);l<this.documentHelper.pages.length;l++){s=this.documentHelper.pages[l];if(s.bodyWidgets[0].index!==c)return;for(d=i;d<s.bodyWidgets[0].childWidgets.length;d++){h=s.bodyWidgets[0].childWidgets[d];this.updateIndex(h,t)}i=0}}else if(e.containerWidget instanceof o.nb)for(var p=e.containerWidget.getSplitWidgets(),g=p.indexOf(e.containerWidget),u=g;u<p.length;u++){for(var m=p[u].childWidgets,f=i;f<m.length;f++)this.updateIndex(m[f],t);g=0,i=0}else if(e.containerWidget instanceof o.BC)for(n=i;n<e.containerWidget.childWidgets.length;n++){var v=e.containerWidget.childWidgets[n];v.rowIndex===e.containerWidget.index&&this.updateIndex(v,t)}else if(e.containerWidget instanceof o.dm)for(n=i;n<e.containerWidget.childWidgets.length;n++){var y=e.containerWidget.childWidgets[n];this.updateIndex(y,t);for(l=0;l<y.childWidgets.length;l++)y.childWidgets[l].rowIndex=y.index}else if(e.containerWidget instanceof o.NB||e.containerWidget instanceof o.yw||!(0,a.le)(e.containerWidget)&&e.containerWidget.containerWidget instanceof o.tf)for(n=i;n<e.containerWidget.childWidgets.length;n++){var F=e.containerWidget.childWidgets[n];this.updateIndex(F,t)}}},e.prototype.updateIndex=function(e,t){t?e.index++:e.index--},e.prototype.updateEndPosition=function(){var e=this.documentHelper.selection;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&this.updateHistoryPosition(e.start,!1)},e.prototype.checkAndRemoveComments=function(){var e=this.selection;if(e.isEmpty||this.owner.enableTrackChanges)return[];var t=!1,i=this.getSelectedComments();if(i.commentEndInfo.length>0||i.commentStartInfo.length>0){t||(t=!0,this.initComplexHistory("RemoveComment"));var r=this.selection.start,o=this.selection.end;this.selection.isForward||(r=this.selection.end,o=this.selection.start);for(var n=this.selection.getParagraphInfo(r),s=this.selection.getParagraphInfo(o),l=0;l<i.commentEndInfo.length;l++){var d=i.commentEndInfo[l].comment,h=d.commentStart,c=d.commentEnd,p=this.selection.getParagraphInfoInternal(h.line,h.line.getOffset(h,0)),g=this.selection.getParagraphInfoInternal(c.line,c.line.getOffset(c,0));if(s.paragraph===g.paragraph){if(d.replyComments.length>0)for(var u=0;u<d.replyComments.length;u++){var m=d.replyComments[u];(0,a.le)(m.commentEnd)||s.offset--}s.offset--}if(n.paragraph===p.paragraph){var f=p.offset<n.offset;if(d.replyComments.length>0)for(u=0;
1u<d.replyComments.length;u++){m=d.replyComments[u];if(!(0,a.le)(m.commentStart)){var v=this.selection.getParagraphInfoInternal(m.commentStart.line,m.commentStart.line.getOffset(m.commentStart,0));v.offset<n.offset&&n.offset--,s.paragraph===p.paragraph&&s.offset--}}f&&n.offset--,s.paragraph===p.paragraph&&s.offset--}this.deleteCommentInternal(d)}if(i.commentStartInfo.length>0)for(var y=0;y<i.commentStartInfo.length;y++)i.commentStartInfo[y].line.paragraph.equals(s.paragraph)&&s.offset--,this.removeInline(i.commentStartInfo[y]);var F=e.getLineInfoBasedOnParagraph(n.paragraph,n.offset);e.start.setPositionFromLine(F.line,F.offset);var H=e.getLineInfoBasedOnParagraph(s.paragraph,s.offset);e.end.setPositionFromLine(H.line,H.offset)}return i.commentStartInfo},e.prototype.updateHistoryForComments=function(e){if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)&&"RemoveComment"===this.editorHistory.currentHistoryInfo.action){if(!(0,a.le)(e))for(var t=0;t<e.length;t++)this.initInsertInline(e[t],!1);this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory()}},e.prototype.onBackSpace=function(){this.removeEditRange=!0;var e=this.documentHelper.selection;if(this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!0),e.bookmarks.length>0&&this.extendSelectionToBookmarkStart(),e.isEmpty)this.singleBackspace(e,!1);else{var t=this.checkAndRemoveComments();this.initHistory("BackSpace");var i=this.deleteSelectedContents(e,!0);if(this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&(i?this.editorHistory.currentBaseHistoryInfo=void 0:(this.checkEndPosition(e)&&this.updateHistoryPosition(e.end,!1),this.reLayout(e),this.insertSpaceInFormField())),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)){for(var r=0;r<t.length;r++)this.initInsertInline(t[r],!1);this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory()}this.owner.isSpellCheck&&(this.documentHelper.triggerSpellCheck=!1)}this.removeEditRange=!1,this.documentHelper.layout.islayoutFootnote=!1,this.updateXmlMappedContentControl()},e.prototype.insertRemoveBookMarkElements=function(){for(var e=!1,t=0;t<this.removedBookmarkElements.length;t++){var i=this.removedBookmarkElements[t];if(0===i.bookmarkType){var r=i;if(r&&r.reference&&-1!==this.removedBookmarkElements.indexOf(r.reference)){var o=this.removedBookmarkElements.indexOf(r.reference),n=this.removedBookmarkElements.indexOf(r);this.removedBookmarkElements.splice(o,1),this.removedBookmarkElements.splice(n,1),t--}else this.editorHistory.currentBaseHistoryInfo&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(r.clone(),void 0,!0),this.editorHistory.currentHistoryInfo&&(this.editorHistory.updateComplexHistory(),e=!0)}else{var s=i;if(s&&s.reference&&-1!==this.removedBookmarkElements.indexOf(s.reference)){o=this.removedBookmarkElements.indexOf(s.reference),n=this.removedBookmarkElements.indexOf(s);this.removedBookmarkElements.splice(o,1),this.removedBookmarkElements.splice(n,1),t--}else this.editorHistory.currentBaseHistoryInfo&&(this.initComplexHistory(this.editorHistory.currentBaseHistoryInfo.action),this.editorHistory.updateHistory()),this.initInsertInline(s.clone(),void 0,!0),this.editorHistory.currentHistoryInfo&&(this.editorHistory.updateComplexHistory(),e=!0)}}return this.removedBookmarkElements=[],e},e.prototype.deleteSelectedContents=function(e,t){var i=this.deleteSelectedContentInternal(e,t,e.start,e.end),r=e.getTextPosBasedOnLogicalIndex(e.editPosition);return e.selectContent(r,!0),i},e.prototype.removeWholeElement=function(e){this.initHistory("BackSpace"),this.deleteSelectedContents(e,!0),this.checkEndPosition(e)&&this.updateHistoryPosition(e.end,!1),this.reLayout(e)},e.prototype.getSelectedComments=function(){for(var e=this.documentHelper.comments,t=[],i=[],r=0;r<e.length;r++){var o=e[r],n=o.commentEnd,s=o.commentStart;if(!(0,a.le)(n)&&this.selection.isElementInSelection(n,!1))t.push(n);else if(!(0,a.le)(s)&&this.selection.isElementInSelection(s,!0)){i.push(s);for(var l=0;l<o.replyComments.length;l++)o.replyComments[l].commentStart&&i.push(o.replyComments[l].commentStart)}}return{commentStartInfo:i,commentEndInfo:t}},e.prototype.singleBackspace=function(e,t){var i=this.editorHistory;
1if(i&&!t&&!i.canRedo()&&i.canUndo()){var r=i.undoStack[i.undoStack.length-1],n=this.selection.getParagraphInfo(e.start),l=this.selection.getParagraphInfo(e.end);if("AutoFormatHyperlink"===r.action&&r.insertPosition===this.selection.getHierarchicalIndex(n.paragraph,n.offset.toString())&&r.endPosition===this.selection.getHierarchicalIndex(l.paragraph,l.offset.toString()))return void i.undo()}var d,h=!1,c=e.start.paragraph,p=e.start.currentWidget,g=e.start.offset,u=0,m=p.getInline(g,u),f=m.element,v=!1,y=g,F=!1;while(f instanceof o.Xw){var H=f;if(f=f.previousNode,(0,a.le)(f)&&(f=d),(0,a.le)(f)||0!=f.commentType||(d=f.previousNode),f&&(y=f.length),!(0!==H.commentType||!(0,a.le)(f)&&f instanceof o.Xw)){(0,a.le)(f)?(f=H,y=0):y=f.length,F=!0;break}1===H.commentType&&(v||(this.initComplexHistory("RemoveComment"),v=!0),this.deleteCommentInternal(H.comment),F=!0)}if(F)if((0,a.le)(f)){var C=c.childWidgets[0];e.start.setPositionParagraph(C,0),e.end.setPositionParagraph(C,0)}else c=f.line.paragraph,g=f.line.getOffset(f,y),e.start.setPositionParagraph(f.line,g),e.end.setPositionParagraph(f.line,g);if(this.selection.isInlineFormFillMode()){if(f instanceof o.V8&&2===f.fieldType)return;var w=this.getFieldResultText();if(1===w.length)return this.selection.selectFieldInternal(this.selection.getCurrentFormField()),this.insertTextInternal(this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),!0),void this.selection.selectTextElementStartOfField(this.selection.getCurrentFormField())}u=m.index,f instanceof o.a3&&(f.ignoreOnceItems=[]),f instanceof o.a3&&(f.ignoreOnceItems=[]);if(f instanceof o.V8&&2===f.fieldType&&s.o_.isLinkedFieldCharacter(f)){var I=f.fieldBegin,b=f.fieldEnd;return I.nextNode instanceof o.aQ&&(b=I.nextNode.reference),e.start.setPositionParagraph(I.line,I.line.getOffset(I,0)),e.end.setPositionParagraph(b.line,b.line.getOffset(b,0)+1),void e.fireSelectionChanged(!0)}if(f instanceof o.R5&&("Footnote"===f.footnoteType?this.removeFootnote(f):this.removeEndnote(f)),f&&(f instanceof o.h||f.previousNode instanceof o.h)&&(f instanceof o.h&&f.previousNode&&!(f.previousElement instanceof o.no)&&(f=f.previousNode,c=f.line.paragraph,g=f.line.getOffset(f,f.length)),f&&1===f.length&&f.nextNode instanceof o.h&&f.previousNode instanceof o.h)){var W=f.previousNode;b=f.nextNode;if(!W.contentControlProperties.lockContentControl)return e.start.setPositionParagraph(W.line,W.line.getOffset(W,0)),e.end.setPositionParagraph(b.line,b.line.getOffset(b,0)+1),void this.removeWholeElement(e)}if(f&&(f instanceof o.aQ||f.previousNode instanceof o.aQ)){if(f instanceof o.aQ&&1===f.bookmarkType){if(f.previousNode)f=f.previousNode,c=f.line.paragraph,g=f.line.getOffset(f,f.length);else if(c.previousRenderedWidget instanceof o.ZH){var x=c.previousRenderedWidget,P=x.lastChild;return e.start.setPositionParagraph(f.line,f.line.getOffset(f,0)),e.end.setPositionParagraph(P,P.getEndOffset()),void this.removeWholeElement(e)}}else if(f.nextNode instanceof o.aQ&&f instanceof o.aQ&&0===f.bookmarkType&&f.reference===f.nextNode)return void this.deleteBookmark(f.name);if(1===f.length&&f.nextNode instanceof o.aQ&&f.previousNode instanceof o.aQ){I=f.previousNode,b=f.nextNode;return e.start.setPositionParagraph(I.line,I.line.getOffset(I,0)),e.end.setPositionParagraph(b.line,b.line.getOffset(b,0)+1),void this.removeWholeElement(e)}}if(f instanceof o.V8&&1===f.fieldType&&!this.selection.isInlineFormFillMode()){var R=e.getPreviousValidElement(f);if(R instanceof o.V8){if(f=R.fieldBegin,c=f.line.paragraph,g=f.line.getOffset(f,0),f.nextNode instanceof o.aQ){W=f.nextNode.reference;e.start.setPositionParagraph(W.line,W.line.getOffset(W,0))}return e.end.setPositionParagraph(f.line,g),void e.fireSelectionChanged(!0)}R!==f&&(f=R,c=f.line.paragraph,g=f.line.getOffset(f,f.length))}if(f instanceof o.Cw||f instanceof o.jn){if(f.nextNode instanceof o.jn&&f.editRangeEnd===f.nextNode||f.previousNode instanceof o.Cw&&f.editRangeStart===f.previousNode)return;if(f instanceof o.Cw&&!(f.previousNode instanceof o.jn))return;if(f instanceof o.jn&&((0,a.le)(f.previousNode)||(f=f.previousNode,c=f.line.paragraph,g=f.line.getOffset(f,f.length))),1===f.length&&f.nextNode instanceof o.jn&&f.previousNode instanceof o.Cw){W=f.previousNode,b=f.nextNode;return e.start.setPositionParagraph(W.line,W.line.getOffset(W,0)),e.end.setPositionParagraph(b.line,b.line.getOffset(b,0)+1),void this.removeWholeElement(e)}}if(t||this.initHistory("BackSpace"),g===e.getStartOffset(c)&&e.start.currentWidget.isFirstLine()){if(c.paragraphFormat.listFormat&&-1!==c.paragraphFormat.listFormat.listId)return void this.onApplyList(void 0);if(0!==c.paragraphFormat.firstLineIndent)return void this.onApplyParagraphFormat("firstLineIndent",0,!1,!1);if(0!==c.paragraphFormat.leftIndent)return void this.onApplyParagraphFormat("leftIndent",0,!1,!1);if(!c.paragraphFormat.bidi&&"Left"!==c.paragraphFormat.textAlignment)return void this.onApplyParagraphFormat("textAlignment","Left",!1,!0);if(c.previousRenderedWidget instanceof o.ZH){e.owner.isShiftingEnabled=!0;var k=c.previousRenderedWidget;if(this.owner.enableTrackChanges&&void 0!=c.previousRenderedWidget&&0==c.previousRenderedWidget.characterFormat.revisions.length)if(this.checkToMatchEmptyParaMarkBack(k)){T=this.documentHelper.selection.getLineLength(k.lastChild),S=k.childWidgets.length-1;this.documentHelper.layout.reLayoutParagraph(k,S,0),e.selects(k.childWidgets[S],T,!0),this.addRemovedNodes(c)}else{this.insertRevision(k.characterFormat,"Deletion");var T=this.documentHelper.selection.getLineLength(k.lastChild),S=k.childWidgets.length-1;this.documentHelper.layout.reLayoutParagraph(k,S,0),e.selects(k.childWidgets[S],T,!0),this.addRemovedNodes(c)}else if(k.isEmpty()&&!this.owner.enableTrackChanges)if(this.removePrevParaMarkRevision(c),c!==c.bodyWidget.lastChild||k.bodyWidget.index===c.bodyWidget.index)this.removeBlock(k),this.addRemovedNodes(k);else{T=this.documentHelper.selection.getLineLength(k.lastChild),S=k.childWidgets.length-1;e.selects(k.childWidgets[S],T,!0)}else if(this.owner.enableTrackChanges&&void 0!=k.characterFormat.revisions&&"Deletion"==k.characterFormat.revisions[0].revisionType){T=this.documentHelper.selection.getLineLength(k.lastChild),S=k.childWidgets.length-1;this.documentHelper.layout.reLayoutParagraph(k,S,0),e.selects(k.childWidgets[S],T,!0),this.addRemovedNodes(c)}else{this.removePrevParaMarkRevision(c);var L=!1;c===c.bodyWidget.lastChild&&k.bodyWidget.index!==c.bodyWidget.index||(this.removeBlock(c,!1,!0),L=!0);T=this.documentHelper.selection.getLineLength(k.lastChild),S=k.childWidgets.length-1,C=void 0;if(!c.isEmpty()&&L)for(var B=0;B<c.childWidgets.length;B++){C=c.childWidgets[B],k.childWidgets.push(C);for(var E=0;E<C.children.length;E++)if(C.children[E]instanceof o.R5){var O=this.documentHelper.footnoteCollection.indexOf(C.children[E]);if(-1===O){C.children[E].isLayout=!1;var N=parseInt(C.children[E].text);this.documentHelper.footnoteCollection.splice(N-1,0,C.children[E])}}c.childWidgets.splice(B,1),B--,C.paragraph=k}this.documentHelper.layout.reLayoutParagraph(k,S,0),e.selects(k.childWidgets[S],T,!0),L&&this.addRemovedNodes(c)}this.setPositionForHistory();var M=this.documentHelper.layout.getFootNoteWidgetsOf(c);if(M.length>0){var A=this.documentHelper.layout,D=c.bodyWidget;A.layoutfootNote(D.page.footnoteWidget)}this.reLayout(e)}else this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo=void 0)}else{t||(e.owner.isShiftingEnabled=!0);var V=this.selection.getParagraphInfo(e.start),U=(C=e.start.currentWidget,g-1);U<0&&(C=C.previousLine,U=this.documentHelper.selection.getLineLength(C)+U),this.removeAtOffset(C,e,U),this.setPositionParagraph(V.paragraph,V.offset-1,!1),this.setPositionForHistory(),t?this.fireContentChange():(this.reLayout(e),h&&(this.owner.editorHistory.undoStack[this.owner.editorHistory.undoStack.length-2].modifiedActions.push(this.owner.editorHistory.undoStack[this.owner.editorHistory.undoStack.length-1]),this.owner.editorHistory.undoStack.splice(this.owner.editorHistory.undoStack.length-1,1),h=!1))}v&&this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory())},e.prototype.setPositionForHistory=function(e){var t=this.documentHelper.selection;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&((0,a.le)(e)?(this.updateHistoryPosition(t.start,!0),this.editorHistory.currentBaseHistoryInfo.endPosition=this.editorHistory.currentBaseHistoryInfo.insertPosition):(this.editorHistory.currentBaseHistoryInfo.insertPosition=e,this.editorHistory.currentBaseHistoryInfo.endPosition=e))},e.prototype.removeAtOffset=function(e,t,i){for(var r=0,n=e.paragraph.childWidgets.indexOf(e),s=e.children.length,a=0;a<s;a++){var l=e.children[a];if(!(l instanceof o.no)){var d=this.removeCharacter(l,i,r,e,n,a);if(d)break;r+=l.length}}},e.prototype.removeCharacter=function(e,t,i,r,n,s,l){var d=!1;if(e instanceof o.aQ&&e.line!==e.reference.line&&!(r.children[s]instanceof o.aQ))return(0,a.le)(e.line.previousLine)?(0,a.le)(e.line.paragraph.previousRenderedWidget)?(0,a.le)(e.line.paragraph.nextRenderedWidget)||(e.line.paragraph.nextRenderedWidget.firstChild.children.splice(e.line.paragraph.nextRenderedWidget.firstChild.children.length,0,e),e.line=e.line.paragraph.nextRenderedWidget.firstChild):(e.line.paragraph.previousRenderedWidget.lastChild.children.splice(e.line.paragraph.previousRenderedWidget.lastChild.children.length,0,e),e.line=e.line.paragraph.previousRenderedWidget.lastChild):(e.line.previousLine.children.splice(e.line.previousLine.children.length,0,e),e.line=e.line.previousLine),r.children.splice(s,1),!0;if(t<i+e.length){var h=t-i;if(e.ischangeDetected=!0,this.owner.isSpellCheck&&(this.owner.spellChecker.removeErrorsFromCollection({element:e,text:e.text}),e.canTrigger||(this.documentHelper.triggerSpellCheck=!1)),t===i&&1===e.length)this.owner.enableTrackChanges&&!this.skipTracking()?(this.addRemovedNodes(e.clone()),this.handleDeleteTracking(e,h,1,s)):(this.unLinkFieldCharacter(e),this.unlinkRangeFromRevision(e,!0),this.addRemovedRevisionInfo(e,void 0),this.addRemovedNodes(e),r.children.splice(s,1)),this.documentHelper.layout.reLayoutParagraph(r.paragraph,n,s,void 0,l);else{var c=this.handleDeleteTracking(e,h,1);this.documentHelper.layout.reLayoutParagraph(r.paragraph,n,s,void 0,l),(0,a.le)(c)||(e.revisions.length>0&&this.addRemovedRevisionInfo(e,c),this.addRemovedNodes(c))}d=!0}return d},e.prototype.removeCharacterInLine=function(e,t,i){var r=new o.a3;if(e instanceof o.a3){r.characterFormat.copyFormat(e.characterFormat);var n=1===i?1:i-t;r.text=e.text.substr(t,n);var s=e.text;e.text=s.substring(0,t)+s.substring(t+n,s.length),e.contentControlProperties&&(r.contentControlProperties=e.contentControlProperties.clone())}return r},e.prototype.removeRevisionsInformation=function(e,t,i,r){var o,n=e.previousElement;o=this.retrieveRevisionInOder(n),"Insertion"===o.revisionType&&this.isRevisionMatched(n,void 0)&&e.line.children.splice(r,1)},e.prototype.handleDeleteTracking=function(e,t,i,r,n,s){var l=this.owner.enableTrackChanges,d=(!(0,a.le)(this.editorHistory)&&(this.editorHistory.isUndoing||this.editorHistory.isRedoing),void 0);
1if(this.canHandleDeletion()||l&&!this.skipTracking()){if(e instanceof o.aQ||e instanceof o.Xw||e instanceof o.Cw||e instanceof o.jn)return void(e instanceof o.aQ&&e.previousElement instanceof o.V8&&e.previousElement.formFieldData?e.previousElement.revisions.length>0&&this.removeRevisionsInformation(e,t,i,r):l&&e instanceof o.aQ?(this.checkToCombineRevisionsInSides(e,"Deletion")||this.insertRevision(e,"Deletion"),this.updateLastElementRevision(e)):e.line.children.splice(e.indexInOwner,1));var h=!1;if(this.owner.editorHistory&&(h=!(0,a.le)(this.owner.editorHistory.currentBaseHistoryInfo)&&"Delete"===this.owner.editorHistory.currentBaseHistoryInfo.action),this.skipTableElements||this.updateEndRevisionIndex(),e.revisions.length>0){var c=this.retrieveRevisionInOder(e),p=this.owner.revisions.changes.indexOf(c);if("Insertion"===c.revisionType)if(this.isRevisionMatched(e,void 0))if((0,a.le)(r))d=this.removeCharacterInLine(e,t,i);else{var g=c.range.indexOf(e);c.range.splice(g,1),0===c.range.length&&this.owner.revisionsInternal.remove(c),this.unLinkFieldCharacter(e),e.line.children.splice(r,1)}else if((0,a.le)(r)){var u=this.removeCharacterInLine(e,t,i);if(0===t){var m=e.previousElement;this.handleDeletionForInsertRevision(m,e,u,i,t,!0)}else if(e.length!==t)for(var f=e.revisions.length-1;f>=0;f--){var v=e.revisions[f],y=v.range.indexOf(e),F=new o.a3;F.characterFormat.copyFormat(e.characterFormat),F.line=e.line,F.text=e.text.substr(t),F.revisions.splice(0,0,v),v.range.splice(y+1,0,F),u.revisions.splice(0,0,v),u.line=e.line,v.range.splice(y+1,0,u),e.text=e.text.substr(0,t);var H=e.indexInOwner;e.line.children.splice(H+1,0,F),e.line.children.splice(H+1,0,u),this.addRemovedNodes(u.clone()),this.insertRevision(u,"Deletion"),this.updateLastElementRevision(u)}else if(e.length===t){var C=e.nextElement;this.handleDeletionForInsertRevision(C,e,u,i,t,!1)}else 1===i?h||(this.selection.start.movePreviousPosition(),this.selection.end.setPositionInternal(this.selection.start)):this.updateCursorForInsertRevision(e,t,i),this.addRemovedNodes(u.clone()),this.insertInlineInternal(u,"Deletion")}else this.checkToCombineRevisionsInSides(e,"Deletion")||this.insertRevision(e,"Deletion"),this.updateLastElementRevision(e);else if("Deletion"===c.revisionType){if(-1!==p&&c.author!==this.owner.currentUser){var w=c.range,I=w[0].line.getOffset(w[0],0),b=w[w.length-1],W=b.line.getOffset(b,b.length);I===t&&W===i&&(e.revisions.splice(e.revisions.indexOf(c),1),this.checkToCombineRevisionsInSides(e,"Deletion")?this.combineElementRevision(e.revisions,e.revisions):(this.insertRevision(e,"Deletion"),this.updateLastElementRevision(e)),e.line.getOffset(e,0)===I&&this.owner.revisions.changes.splice(p,1))}if(1===i)h?(this.selection.start.moveNextPosition(),this.selection.end.setPositionInternal(this.selection.start)):(this.selection.start.movePreviousPosition(),this.selection.end.setPositionInternal(this.selection.start));else if(this.isRevisionMatched(e,"Deletion"))this.updateCursorForInsertRevision(e,t,i);else{var x=c.range.indexOf(e);W=e.line.getOffset(e,e.length);W>=i&&c.range.length>x+1?(this.updateRevisionForSpittedTextElement(e,c.range[x+1]),c.range.splice(c.range.indexOf(e),1),this.toCombineOrInsertRevision(e,"Deletion")):1===c.range.length||0===t?(this.handleDeleteBySplitting(e,t,i),-1!==x&&1!==c.range.length&&(this.updateRevisionForSpittedTextElement(c.range[x-1],c.range[x]),c.range.splice(c.range.indexOf(e),1))):(c.range.splice(c.range.indexOf(e),1),this.toCombineOrInsertRevision(e,"Deletion"))}this.updateLastElementRevision(e)}}else(0,a.le)(r)?this.handleDeleteBySplitting(e,t,i):(this.checkToCombineRevisionsInSides(e,"Deletion")||this.insertRevision(e,"Deletion"),this.updateLastElementRevision(e))}else d=this.removeCharacterInLine(e,t,i);return d},e.prototype.toCombineOrInsertRevision=function(e,t){this.checkToCombineRevisionsInSides(e,t)?this.combineElementRevision(e.revisions,e.revisions):(this.insertRevision(e,t),this.updateLastElementRevision(e))},e.prototype.updateLastElementRevision=function(e){this.skipTableElements||!this.editorHistory||!this.editorHistory.currentBaseHistoryInfo||this.skipReplace||!(0,a.le)(this.owner.search)&&this.owner.search.isRepalceTracking||(0,a.le)(this.editorHistory.currentBaseHistoryInfo.lastElementRevision)&&(this.editorHistory.currentBaseHistoryInfo.lastElementRevision=e,e.isMarkedForRevision=!0)},e.prototype.updateEndRevisionIndex=function(){if(!(0,a.le)(this.editorHistory.undoStack)&&this.editorHistory.undoStack.length>0){var e=this.editorHistory.undoStack[this.editorHistory.undoStack.length-1];e.lastElementRevision&&(0,a.le)(e.endRevisionLogicalIndex)&&e.updateEndRevisionInfo()}},e.prototype.retrieveRevisionInOder=function(e){if(1===e.revisions.length)return e.revisions[0];for(var t=0;t<e.revisions.length;
1t++)if("Deletion"===e.revisions[t].revisionType)return e.revisions[t];return e.revisions[e.revisions.length-1]},e.prototype.handleDeletionForInsertRevision=function(e,t,i,r,o,n){if(!(0,a.le)(e)&&0===t.revisions.length&&this.isRevisionMatched(e,"Deletion"))this.addRemovedNodes(i.clone()),this.insertTextInline(e,this.selection,i.text,0);else{var s=t.revisions[t.revisions.length-1],l=s.range.indexOf(t);s.range.splice(n?l:l+1,0,i),i.revisions.splice(0,0,s);var d=!1;this.owner.editorHistory&&(d=!(0,a.le)(this.owner.editorHistory.currentBaseHistoryInfo)&&"Delete"===this.owner.editorHistory.currentBaseHistoryInfo.action),1!==r||d?this.updateCursorForInsertRevision(t,o,r):(this.selection.start.movePreviousPosition(),this.selection.end.setPositionInternal(this.selection.start)),this.addRemovedNodes(i.clone()),this.insertInlineInternal(i,"Deletion")}},e.prototype.handleDeleteBySplitting=function(e,t,i){var o=!1;if(this.owner.editorHistory&&(o=!(0,a.le)(this.owner.editorHistory.currentBaseHistoryInfo)&&"Delete"===this.owner.editorHistory.currentBaseHistoryInfo.action),1===i){var n=e.line.getOffset(e,0);if(n>0){var s=new r.JK(this.owner);s.setPositionForLineWidget(e.line,n+t),this.selection.start.setPositionInternal(s),this.selection.end.setPositionInternal(this.selection.start)}else o||(this.selection.start.movePreviousPosition(),this.selection.end.setPositionInternal(this.selection.start))}else this.updateCursorForInsertRevision(e,t,i);var l=this.removeCharacterInLine(e,t,i);this.addRemovedNodes(l.clone()),this.insertTextInternal(l.text,!1,"Deletion")},e.prototype.updateCursorForInsertRevision=function(e,t,i){var o=e.line.getOffset(e,0);o>0&&(t=o+t,i=o+i);var n=new r.JK(this.owner);n.setPositionFromLine(e.line,t);var s=new r.JK(this.owner);s.setPositionFromLine(e.line,i),n.isExistBefore(s)?(this.selection.end.setPositionInternal(n),this.selection.start.setPositionInternal(n)):(this.selection.start.setPositionInternal(s),this.selection.end.setPositionInternal(s))},e.prototype.checkToCombineRevisionsInSides=function(e,t){var i=e.previousNode,r=e.nextNode,n=!1;if(!(0,a.le)(i)&&(i instanceof o.aQ||(i=i.previousValidNodeForTracking),!(0,a.le)(i))){var s=this.getMatchedRevisionsToCombine(i.revisions,t);s.length>0&&(this.mapMatchedRevisions(s,i,e,!1),n=!0)}if(!(0,a.le)(r)&&(r instanceof o.aQ||(r=r.nextValidNodeForTracking),!(0,a.le)(r))){s=this.getMatchedRevisionsToCombine(r.revisions,t);s.length>0&&(n?this.combineElementRevision(e.revisions,r.revisions):this.mapMatchedRevisions(s,r,e,!0),n=!0)}return n},e.prototype.delete=function(){this.removeEditRange=!0;var e=this.documentHelper.selection;if(e.bookmarks.length>0&&this.extendSelectionToBookmarkStart(),e.isEmpty)this.singleDelete(e,!1);else{var t=this.checkAndRemoveComments();this.initHistory("Delete"),this.deleteSelectedContentInternal(e,!1,e.start,e.end);var i=new r.JK(e.owner);if(this.setPositionForCurrentIndex(i,e.editPosition),e.selectContent(i,!0),this.reLayout(e),this.insertSpaceInFormField(),this.editorHistory&&!(0,a.le)(this.editorHistory.currentHistoryInfo)){for(var o=0;o<t.length;o++)this.initInsertInline(t[o],!1);this.editorHistory.currentHistoryInfo.endPosition=this.selection.startOffset,this.editorHistory.updateComplexHistory()}}this.removeEditRange=!1,this.documentHelper.layout.islayoutFootnote=!1,this.updateXmlMappedContentControl()},e.prototype.deleteEditElement=function(e){this.initHistory("Delete"),this.deleteSelectedContentInternal(e,!1,e.start,e.end);var t=new r.JK(e.owner);this.setPositionForCurrentIndex(t,e.editPosition),e.selectContent(t,!0),this.reLayout(e)},e.prototype.removeContentControlMark=function(e,t){return!e.contentControlProperties.lockContentControl&&(this.selection.start.setPositionParagraph(e.line,e.line.getOffset(e,0)),this.selection.end.setPositionParagraph(t.line,t.line.getOffset(t,0)+1),this.deleteEditElement(this.selection),!0)},e.prototype.singleDelete=function(e,t){var i=e.start.currentWidget,r=e.start.paragraph,n=e.start.offset,s=0,l=i.getInline(e.start.offset,s),d=l.element;if(this.selection.isInlineFormFillMode()){if(d instanceof o.V8&&1===d.fieldType)return;var h=this.getFieldResultText();if(d instanceof o.a3||(d=d.nextElement),1===h.length&&d instanceof o.a3)return this.selection.selectFieldInternal(this.selection.getCurrentFormField()),this.insertTextInternal(this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),!0),void this.selection.selectTextElementStartOfField(this.selection.getCurrentFormField());if(d instanceof o.V8&&1===d.fieldType)return}if(s=l.index,r.paragraphFormat.listFormat&&-1!==r.paragraphFormat.listFormat.listId&&this.documentHelper.isListTextSelected&&"List"===e.contextType)this.onApplyList(void 0);else{if(!(0,a.le)(d)&&s===d.length&&!(0,a.le)(d.nextNode)){if(d=d.nextNode,d instanceof o.V8&&1===d.fieldType&&!(0,a.le)(d.fieldBegin.formFieldData))return;if(d instanceof o.R5)return;s=0}var c=d instanceof o.Xw;while(d instanceof o.Xw){if(!d.nextNode){s=1;break}d=d.nextNode,s=0}if(c&&(r=d.line.paragraph,n=d.line.getOffset(d,s),e.start.setPositionParagraph(d.line,n),e.end.setPositionParagraph(d.line,n)),d instanceof o.R5&&("Footnote"===d.footnoteType?this.removeFootnote(d):this.removeEndnote(d)),!(0,a.le)(d)){var p=void 0,g=e.getNextValidElement(d);if(g instanceof o.nR&&(p=g),!(0,a.le)(p)&&p instanceof o.V8&&0===p.fieldType)return d=p.fieldEnd,r=d.line.paragraph,n=d.line.getOffset(d,1),e.end.setPositionParagraph(d.line,n),void e.fireSelectionChanged(!0);d!==p&&(d=p,r=d.line.paragraph,n=d.line.getOffset(d,0),d instanceof o.V8&&1===d.fieldType&&n++)}if(d instanceof o.Cw||d instanceof o.jn){if(d.nextNode instanceof o.jn&&d.editRangeEnd===d.nextNode||d.previousNode instanceof o.Cw&&d.editRangeStart===d.previousNode)return;if(this.documentHelper.isDocumentProtected&&"ReadOnly"===this.documentHelper.protectionType){if(d instanceof o.Cw||d instanceof o.jn)return}else d instanceof o.Cw?(d=d.nextNode,n=d.line.getOffset(d,0),r=d.line.paragraph):d instanceof o.jn&&n++;if(1===d.length&&d.nextNode instanceof o.jn&&d.previousNode instanceof o.Cw){var u=d.previousNode,m=d.nextNode;return e.start.setPositionParagraph(u.line,u.line.getOffset(u,0)),e.end.setPositionParagraph(m.line,m.line.getOffset(m,0)+1),void this.deleteEditElement(e)}}
1if(d&&(d instanceof o.h||d.nextNode instanceof o.h)){if(d instanceof o.h&&d.nextNode)return d=d.nextNode,r=d.line.paragraph,n=d.line.getOffset(d,0),e.start.setPositionParagraph(d.line,n),void e.end.setPositionParagraph(d.line,n);if(d&&1===d.length&&d.nextNode instanceof o.h&&d.previousNode instanceof o.h&&this.removeContentControlMark(d.previousNode,d.nextNode))return;if(d instanceof o.h&&d.previousNode instanceof o.h&&d.previousNode.reference===d&&this.removeContentControlMark(d.previousNode,d))return}if(d&&(d instanceof o.aQ&&0===d.bookmarkType||d.nextNode instanceof o.aQ)){if(d.nextNode&&d instanceof o.aQ&&(d=d.nextNode,r=d.line.paragraph,n=d.line.getOffset(d,0),e.start.setPositionParagraph(d.line,n),e.end.setPositionParagraph(d.line,n)),1===d.length&&d.nextNode instanceof o.aQ&&d.previousNode instanceof o.aQ){var f=d.previousNode,v=d.nextNode;return e.start.setPositionParagraph(f.line,f.line.getOffset(f,0)),e.end.setPositionParagraph(v.line,v.line.getOffset(v,0)+1),void this.deleteEditElement(e)}d instanceof o.aQ&&(n=d.line.getOffset(d,1))}if(e.start.currentWidget.isLastLine()&&n===this.documentHelper.selection.getLineLength(e.start.currentWidget)){if(r.isInsideTable&&(0,a.le)(r.nextWidget))return;var y=void 0,F=void 0,H=e.getNextParagraphBlock(r);if((0,a.le)(H)){if(n>0)return;if(r.previousWidget instanceof o.ZH&&(y=r.previousWidget),r.previousWidget instanceof o.tf)return;if(r.previousWidget instanceof o.dm)return;if((0,a.le)(y))return}if(t||this.initHistory("Delete"),r.isEndsWithPageBreak||r.isEndsWithColumnBreak){var C=r.lastChild,w=C.children[C.children.length-1];this.selection.start.setPositionForSelection(C,w,0,this.selection.start.location)}var I=this.selection.getParagraphInfo(e.start);if(e.editPosition=this.selection.getHierarchicalIndex(I.paragraph,I.offset.toString()),this.checkInsertPosition(e)&&this.setPositionForHistory(e.editPosition),e.owner.isShiftingEnabled=!0,r.isEmpty())if(this.removePrevParaMarkRevision(r,!0),this.removeBlock(r,!1,!0),this.addRemovedNodes(r),(0,a.le)(H))if((0,a.le)(y)){var b=e.getParagraphLength(F)+1;this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(this.updateHistoryPosition(e.start,!0),this.editorHistory.currentBaseHistoryInfo.endPosition=this.selection.getHierarchicalIndex(F,b.toString()))}else e.selectParagraphInternal(y,!1),this.setPositionForHistory();else e.selectParagraphInternal(H,!0);else if(this.owner.enableTrackChanges&&r.nextRenderedWidget instanceof o.ZH){var W=r.nextRenderedWidget,x=0,P=W.childWidgets.length-1;r=r.combineWidget(this.owner.viewer);var R=this.splitParagraph(r,r.firstChild,0,e.start.currentWidget,e.start.offset,!0);void 0!=r&&0!=r.characterFormat.revisions.length&&"Insertion"==r.characterFormat.revisions[0].revisionType?(this.removePrevParaMarkRevision(r,!0),this.deleteParagraphMark(R,e,0),this.addRemovedNodes(r),this.setPositionForCurrentIndex(e.start,e.editPosition),e.selectContent(e.start,!0)):(this.removePrevParaMarkRevision(r,!0),this.deleteParagraphMark(R,e,0,!0),this.addRemovedNodes(r),this.setPositionForCurrentIndex(e.start,e.editPosition),e.selects(W.childWidgets[P],x,!0))}else{r=r.combineWidget(this.owner.viewer);R=this.splitParagraph(r,r.firstChild,0,e.start.currentWidget,e.start.offset,!0);this.removePrevParaMarkRevision(r,!0),this.deleteParagraphMark(R,e,0),this.addRemovedNodes(r),this.setPositionForCurrentIndex(e.start,e.editPosition),e.selectContent(e.start,!0)}this.reLayout(e)}else this.singleDeleteInternal(e,t,r);var k=e.start.currentWidget,T=k.getInline(e.start.offset+1,0);T.element instanceof o.aQ&&(e.start.offset++,e.end.offset++)}},e.prototype.singleDeleteInternal=function(e,t,i){t||(e.owner.isShiftingEnabled=!0,this.initHistory("Delete")),this.checkInsertPosition(e)&&(this.updateHistoryPosition(e.start,!0),this.editorHistory.currentBaseHistoryInfo.endPosition=this.editorHistory.currentBaseHistoryInfo.insertPosition);var r=this.selection.getParagraphInfo(e.start),o=e.start.currentWidget,n=e.start.offset,s=e.getLineLength(e.start.currentWidget);n>=s&&(o=o.nextLine,n-=s),this.removeAtOffset(o,e,n),this.owner.enableTrackChanges&&!(0,a.le)(this.editorHistory)&&this.editorHistory.currentBaseHistoryInfo&&"Delete"===this.editorHistory.currentBaseHistoryInfo.action&&s!==e.getLineLength(e.start.currentWidget)?this.setPositionParagraph(r.paragraph,r.offset,!1):this.owner.enableTrackChanges&&!this.skipTracking()?this.setPositionParagraph(r.paragraph,r.offset+1,!1):this.setPositionParagraph(r.paragraph,r.offset,!1),t?this.fireContentChange():this.reLayout(e)},e.prototype.deleteParagraphMark=function(e,t,i,r,n){if(!(0,a.le)(e.containerWidget)){e=e.combineWidget(this.owner.viewer);var s=t.getNextParagraphBlock(e);if(!(e.isInsideTable&&(0,a.le)(e.nextWidget)||(0,a.le)(s))){e.containerWidget instanceof o.VB&&e.containerWidget;var l=void 0;if(l=t.getNextRenderedBlock(e)instanceof o.dm?t.getNextRenderedBlock(e):void 0,s.isInsideTable&&!(0,a.le)(l)&&l.contains(s.associatedCell)){if(i<4){var d=0;this.removeBlock(e),this.documentHelper.layout.clearListElementBox(s),this.documentHelper.layout.clearListElementBox(e);for(var h=e.childWidgets.length-1;h>=0;h--)for(var c=e.childWidgets[h],p=c.children.length-1;p>=0;p--){var g=c.children[p];d+=g.length,s.firstChild.children.unshift(g),g.line=s.firstChild}this.documentHelper.layout.reLayoutParagraph(s,0,0),d>0&&(t.editPosition=this.selection.getHierarchicalIndex(s,d.toString()))}}else if(i<4){e.childWidgets.length;var u=s.getSplitWidgets();s=s.combineWidget(this.owner.viewer),this.documentHelper.layout.clearListElementBox(s),this.documentHelper.layout.clearListElementBox(e),this.updateEditPositionOnMerge(e,s);var m=!(!(0,a.le)(r)&&r)||this.handleDeleteParaMark(e,u[0]);if(m){var f=e.childWidgets.length-1;for(e.childWidgets[f].children.length,h=0;h<s.childWidgets.length;h++){var v=s.childWidgets[h];if(s.characterFormat.revisions.length>0)for(var y=0;y<s.characterFormat.revisions.length;y++){for(p=0;p<s.characterFormat.revisions[y].range.length;p++)s.characterFormat.revisions[y].range[p].ownerBase=e;e.characterFormat.revisions.push(s.characterFormat.revisions[y])}s.childWidgets.splice(h,1),e.childWidgets.push(v),v.paragraph=e,h--}s.bodyWidget.index!==e.bodyWidget.index&&this.deleteSection(t,e.bodyWidget,s.bodyWidget,i),0===s.childWidgets.length&&s.childWidgets.push(new o.z7(s)),this.documentHelper.layout.reLayoutParagraph(e,0,0),this.removeBlock(s),"Insert"!==this.editorHistory.currentBaseHistoryInfo.action&&this.addRemovedNodes(s,n)}}}}},e.prototype.handleDeleteParaMark=function(e,t){if(!this.owner.enableTrackChanges&&e.characterFormat.revisions.length>0)for(var i=0;i<e.characterFormat.revisions.length;i++){var r=e.characterFormat.revisions[i],o=r.range.indexOf(e.characterFormat);return r.range.splice(o,1),0===r.range.length&&this.owner.revisions.remove(r),!0}if(this.owner.enableTrackChanges){var n=!1;if(e.characterFormat.revisions.length>0){var s=this.retrieveRevisionByType(e.characterFormat,"Deletion");if(!(0,a.le)(s)&&this.isRevisionMatched(s,"Deletion")){var l=e.characterFormat.revisions.indexOf(s);e.characterFormat.revisions.splice(l,1),s.range.splice(s.range.indexOf(e.characterFormat),1),0===s.range.length&&this.owner.revisions.remove(s),n=!0}var d=this.retrieveRevisionByType(e.characterFormat,"Insertion");if(!(0,a.le)(d)&&this.isRevisionMatched(e.characterFormat,"Insertion")){o=d.range.indexOf(e.characterFormat);d.range.splice(o,1),0===d.range.length&&this.owner.revisions.remove(d),n=!0}return!!n||(this.applyRevisionForParaMark(e,t.firstChild,"Deletion",!1),!1)}return this.applyRevisionForParaMark(e,t.firstChild,"Deletion",!1),!1}return!0},e.prototype.insertDeleteParaMarkRevision=function(e,t){var i=e.lastChild,r=i.children.length>0?i.children[i.children.length-1].previousValidNodeForTracking:void 0;if(!(0,a.le)(r)){var o=this.getMatchedRevisionsToCombine(r.revisions,"Deletion");o.length>0&&this.mapMatchedRevisions(o,r,e.characterFormat,!1)}var n=t.firstChild;n.children[0].nextValidNodeForTracking},e.prototype.retrieveRevisionByType=function(e,t){for(var i=0;i<e.revisions.length;i++)if(e.revisions[i].revisionType===t)return e.revisions[i]},e.prototype.combineRevisionOnDeleteParaMark=function(e,t,i){var r=e.childWidgets[t],o=r.children[i],n=o.nextNode;n=n.nextValidNodeForTracking,o=o.nextValidNodeForTracking,n.revisions.length>0&&o.revisions.length>0&&this.combineElementRevisions(o,n)},e.prototype.updateEditPositionOnMerge=function(e,t){this.documentHelper.selection.editPosition===this.selection.getHierarchicalIndex(t,"0")&&void 0===t.nextRenderedWidget&&(this.documentHelper.selection.editPosition=this.selection.getHierarchicalIndex(e,this.documentHelper.selection.getLineLength(e.lastChild).toString()))},e.prototype.checkEndPosition=function(e){return this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo.endPosition)},e.prototype.checkInsertPosition=function(e){return this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo.insertPosition)},e.prototype.checkIsNotRedoing=function(){return this.documentHelper.owner.enableHistoryMode&&!this.editorHistory.isRedoing},e.prototype.deleteSelectedContentInternal=function(e,t,i,r){var n=i,s=r;i.isExistBefore(r)||(n=r,s=i);var l=this.selection.getParagraphInfo(n);e.editPosition=this.selection.getHierarchicalIndex(l.paragraph,l.offset.toString());var d=!1;if(t&&n.isInSameParagraph(s)){if(n.offset<s.offset&&n.offset===e.getParagraphLength(s.paragraph)){var h=e.getNextRenderedBlock(n.paragraph);d=h instanceof o.dm}!(1===s.offset&&s.offset>e.getParagraphLength(s.paragraph))||s.paragraph.isInsideTable&&(0,a.le)(s.paragraph.nextWidget)||(t=!1)}if(!d){e.owner.isShiftingEnabled=!0,this.checkInsertPosition(e)&&(this.editorHistory.currentBaseHistoryInfo.insertPosition=e.editPosition);var c=t?1:0;this.deleteSelectedContent(s.paragraph,e,n,s,c)}return d},e.prototype.initHistory=function(e){this.documentHelper.owner.enableHistoryMode&&this.editorHistory.initializeHistory(e)},e.prototype.initComplexHistory=function(e){this.documentHelper.owner.enableHistoryMode&&this.editorHistory.initComplexHistory(this.documentHelper.selection,e)},e.prototype.insertPicture=function(e,t,i,r){var n=new o.XY(!0);".svg"===s.o_.formatClippedString(e).extension?(n.metaFileImageString=e,n.isMetaFile=!0,this.generateFallBackImage(e,t,i,n)):(n.imageString=e,n.element.crossOrigin="Anonymous"),n.width=t,n.height=i,n.textWrappingStyle="Inline",this.insertPictureInternal(n,r)},e.prototype.generateFallBackImage=function(e,t,i,r){var o=new Image;o.onload=function(){var e=Math.max(1,window.devicePixelRatio||1),n=document.createElement("canvas");n.width=t*e,n.height=i*e;var s=n.getContext("2d");s.scale(e,e),s.drawImage(o,0,0,t,i),r.imageString=n.toDataURL("image/png",1)},o.src=e},e.prototype.insertPictureInternal=function(e,t){var i=this.documentHelper.selection,r=this.checkAndRemoveComments();this.initHistory("InsertInline"),t&&this.fitImageToPage(i,e),this.insertInlineInSelection(i,e),this.reLayout(i),this.updateHistoryForComments(r)},e.prototype.fitImageToPage=function(e,t){var i=e.start.paragraph.bodyWidget,r=i.sectionFormat.pageHeight-i.sectionFormat.topMargin-i.sectionFormat.topMargin,n=0;if(i instanceof o.VB&&i.sectionFormat.columns.length>1){var a=i.page.bodyWidgets.indexOf(i);n=i.sectionFormat.columns[a].width}else n=s.o_.convertPointToPixel(i.sectionFormat.pageWidth-i.sectionFormat.leftMargin-i.sectionFormat.rightMargin);t.width>n&&(t.height=t.height*n/t.width,t.width=n),t.height>r&&(t.width=t.width*r/t.height,t.height=r)},e.prototype.insertInlineInSelection=function(e,t){this.checkIsNotRedoing()&&(e.owner.isShiftingEnabled=!0),e.isEmpty||this.removeSelectedContents(e),this.updateInsertPosition(),this.insertInlineInternal(t),this.checkEndPosition(e)&&this.updateHistoryPosition(e.start,!1),this.fireContentChange()},e.prototype.onPortrait=function(){var e=new l.Z,t=this.documentHelper.selection.sectionFormat.pageWidth,i=this.documentHelper.selection.sectionFormat.pageHeight;t>i&&(e.pageWidth=i,e.pageHeight=t),this.onApplySectionFormat(void 0,e)},e.prototype.onLandscape=function(){var e=new l.Z,t=this.documentHelper.selection.sectionFormat.pageWidth,i=this.documentHelper.selection.sectionFormat.pageHeight;t<i&&(e.pageWidth=i,e.pageHeight=t),this.onApplySectionFormat(void 0,e)},e.prototype.copyValues=function(){var e=new l.Z;return e.bottomMargin=this.documentHelper.selection.sectionFormat.bottomMargin,e.topMargin=this.documentHelper.selection.sectionFormat.topMargin,e.leftMargin=this.documentHelper.selection.sectionFormat.leftMargin,e.rightMargin=this.documentHelper.selection.sectionFormat.rightMargin,e.pageHeight=this.documentHelper.selection.sectionFormat.pageHeight,e.pageWidth=this.documentHelper.selection.sectionFormat.pageWidth,e.footerDistance=this.documentHelper.selection.sectionFormat.footerDistance,e.headerDistance=this.documentHelper.selection.sectionFormat.headerDistance,e},e.prototype.changeMarginValue=function(e){var t=this.copyValues();"lastCustomSetting"===e||"normal"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=72,t.rightMargin=72):"narrow"===e?(t.topMargin=36,t.bottomMargin=36,t.leftMargin=36,t.rightMargin=36):"moderate"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=54,t.rightMargin=54):"wide"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=144,t.rightMargin=144):"mirrored"===e?(t.topMargin=72,t.bottomMargin=72,t.leftMargin=90,t.rightMargin=72):"office2003Default"===e&&(t.topMargin=72,t.bottomMargin=72,t.leftMargin=90,t.rightMargin=90),this.onApplySectionFormat(void 0,t)},e.prototype.onPaperSize=function(e){var t=this.copyValues(),i=this.documentHelper.selection.sectionFormat.pageWidth,r=this.documentHelper.selection.sectionFormat.pageHeight;"letter"===e?i<r?(t.pageWidth=612,t.pageHeight=792):(t.pageWidth=792,t.pageHeight=612):"tabloid"===e?i<r?(t.pageWidth=792,t.pageHeight=1224):(t.pageWidth=1224,t.pageHeight=792):"legal"===e?i<r?(t.pageWidth=612,t.pageHeight=1008):(t.pageWidth=1008,t.pageHeight=612):"statement"===e?i<r?(t.pageWidth=396,t.pageHeight=612):(t.pageWidth=612,t.pageHeight=396):"executive"===e?i<r?(t.pageWidth=522,t.pageHeight=756):(t.pageWidth=756,t.pageHeight=522):"a3"===e?i<r?(t.pageWidth=841.9,t.pageHeight=1190.55):(t.pageWidth=1190.55,t.pageHeight=841.9):"a4"===e?i<r?(t.pageWidth=595.3,t.pageHeight=841.9):(t.pageWidth=841.9,t.pageHeight=595.3):"a5"===e?i<r?(t.pageWidth=419.55,t.pageHeight=595.3):(t.pageWidth=595.3,t.pageHeight=419.55):"b4"===e?i<r?(t.pageWidth=728.5,t.pageHeight=1031.8):(t.pageWidth=1031.8,t.pageHeight=728.5):"b5"===e&&(i<r?(t.pageWidth=515.9,t.pageHeight=728.5):(t.pageWidth=728.5,t.pageHeight=515.9)),this.onApplySectionFormat(void 0,t)},e.prototype.updateListItemsTillEnd=function(e,t){var i=t?this.documentHelper.selection.getNextRenderedBlock(e):e;while(!(0,a.le)(i)&&!this.documentHelper.isTextInput)this.updateRenderedListItems(i),i=i.getSplitWidgets().pop().nextRenderedWidget},e.prototype.updateWholeListItems=function(e,t,i){this.documentHelper.renderedLists.clear(),this.documentHelper.renderedLevelOverrides=[];for(var r,o=e.bodyWidget.index,n=0;n<this.documentHelper.pages.length;n++){for(var s=this.documentHelper.pages[n],l=0;l<s.bodyWidgets.length;l++)if(s.bodyWidgets[l].index===o&&(r=this.getNextBlockForList(s.bodyWidgets[l].firstChild),!(0,a.le)(r)))break;if(!(0,a.le)(r))break}var d=!1;do{var h=null;if(t&&(h={paragraph:null,listId:i}),d=this.updateListItems(r,e,h),d){if(!(0,a.le)(h))return h.paragraph==e?null:h.paragraph;break}r=r.getSplitWidgets().pop().nextRenderedWidget,(0,a.le)(r)||(r=this.getNextBlockForList(r))}while(r);return null},e.prototype.getNextBlockForList=function(e){if(e instanceof o.ZH&&this.documentHelper.layout.isFirstElementWithPageBreak(e)){var t=e.nextRenderedWidget;if(!(0,a.le)(t)&&t.equals(e))return t}return e},e.prototype.updateListItems=function(e,t,i){var r=!1;return r=e instanceof o.ZH?this.updateListItemsForPara(e,t,i):this.updateListItemsForTable(e,t,i),r},e.prototype.updateListItemsForTable=function(e,t,i){if((0,a.le)(i)&&t instanceof o.dm&&e.equals(t))return!0;var r=e.firstChild;do{var n=this.updateListItemsForRow(r,t,i);if(n)return!0;r=r.getSplitWidgets().pop().nextRenderedWidget}while(r);return!1},e.prototype.updateListItemsForRow=function(e,t,i){if((0,a.le)(i)&&t.isInsideTable&&-1!==e.
1childWidgets.indexOf(this.documentHelper.selection.getContainerCell(t.associatedCell)))return!0;var r=e.firstChild;do{if(this.updateListItemsForCell(r,t,i),!(0,a.le)(i)&&!(0,a.le)(i.paragraph))return!0;r=r.nextRenderedWidget}while(r);return!1},e.prototype.updateListItemsForCell=function(e,t,i){if(0!==e.childWidgets.length){var r=e.firstChild;do{if(this.updateListItems(r,t,i),!(0,a.le)(i)&&!(0,a.le)(i.paragraph))break;r=r.getSplitWidgets().pop().nextRenderedWidget}while(r)}},e.prototype.updateRenderedListItems=function(e){e instanceof o.ZH?this.updateRenderedListItemsForPara(e):this.updateRenderedListItemsForTable(e)},e.prototype.updateRenderedListItemsForTable=function(e){var t=e.firstChild;do{this.updateRenderedListItemsForRow(t),t=t.getSplitWidgets().pop().nextRenderedWidget}while(t)},e.prototype.updateRenderedListItemsForRow=function(e){var t=e.firstChild;do{this.updateRenderedListItemsForCell(t),t=t.nextRenderedWidget}while(t)},e.prototype.updateRenderedListItemsForCell=function(e){if(0!==e.childWidgets.length){var t=e.firstChild;do{this.updateRenderedListItems(t),t=t.getSplitWidgets().pop().nextRenderedWidget}while(t)}},e.prototype.updateListItemsForPara=function(e,t,i){if(e.equals(t))return(0,a.le)(i)||(i.paragraph=e),!0;var r=void 0,o=0;if(!(0,a.le)(e.paragraphFormat)&&!(0,a.le)(e.paragraphFormat.listFormat)){if(!(0,a.le)(i)&&e.paragraphFormat.listFormat.listId===i.listId)return i.paragraph=e,!0;r=this.documentHelper.getListById(e.paragraphFormat.listFormat.listId),o=e.paragraphFormat.listFormat.listLevelNumber}if(!(0,a.le)(r)&&!(0,a.le)(this.documentHelper.getAbstractListById(r.abstractListId))&&!(0,a.le)(this.documentHelper.getAbstractListById(r.abstractListId).levels[o])){var n=this.documentHelper.layout.getListLevel(r,o);this.updateListNumber(n,e,!1)}return!1},e.prototype.updateRenderedListItemsForPara=function(e){if(!(0,a.le)(this.documentHelper.getListById(e.paragraphFormat.listFormat.listId))){var t=this.documentHelper.getListById(e.paragraphFormat.listFormat.listId),i=e.paragraphFormat.listFormat.listLevelNumber;if(!(0,a.le)(t)&&!(0,a.le)(this.documentHelper.getAbstractListById(t.abstractListId))&&!(0,a.le)(this.documentHelper.getAbstractListById(t.abstractListId).levels[e.paragraphFormat.listFormat.listLevelNumber])){var r=this.documentHelper.layout.getListLevel(t,i);this.updateListNumber(r,e,!0)}}},e.prototype.updateListNumber=function(e,t,i){if("Bullet"!==e.listLevelPattern){var r=void 0;if(t.childWidgets.length>0){var n=t.childWidgets[0];n.children.length>0&&(r=n.children[0])}var s=void 0;if(!(0,a.le)(r)&&r.nextElement instanceof o.no&&(s=r.width+r.nextElement.width),!(0,a.le)(r)&&r instanceof o.no){var l=this.documentHelper.layout.getListNumber(t.paragraphFormat.listFormat);if(i){var d=r.width;r.text=l;var h=this.documentHelper.textHelper.getTextSize(r,r.characterFormat);h>d&&(r.width=h),this.documentHelper.textHelper.updateTextSize(r,t),!(0,a.le)(s)&&r.width<s&&(r.nextElement.width=s-r.width)}}}},e.prototype.getOffsetValue=function(e){if(this.startParagraph){var t=e.getLineInfoBasedOnParagraph(this.startParagraph,this.startOffset);e.start.setPositionFromLine(t.line,t.offset)}if(e.start.updatePhysicalPosition(!0),e.isEmpty)e.end.setPositionInternal(e.start);else{if(this.endParagraph){t=e.getLineInfoBasedOnParagraph(this.endParagraph,this.endOffset);e.end.setPositionFromLine(t.line,t.offset)}e.end.updatePhysicalPosition(!0)}},e.prototype.setPositionParagraph=function(e,t,i){var r=this.documentHelper.selection,o=r.getLineInfoBasedOnParagraph(e,t);r.start.setPositionFromLine(o.line,o.offset),r.end.setPositionInternal(r.start),i||r.fireSelectionChanged(!0)},e.prototype.setPositionForCurrentIndex=function(e,t){var i=this.selection.getParagraph({index:t}),r=this.selection.getLineInfoBasedOnParagraph(i.paragraph,i.offset);e.setPositionForLineWidget(r.line,r.offset)},e.prototype.insertPageNumber=function(e){e=(0,a.le)(e)?"":" \\*"+e;var t="PAGE "+e+" \\* MERGEFORMAT";this.createFields(t)},e.prototype.insertPageCount=function(e){e=(0,a.le)(e)?"":" *"+e;var t="NUMPAGES "+e+" * MERGEFORMAT";this.createFields(t)},e.prototype.createFields=function(e){var t=new o.ZH,i=new o.z7(t),r=new o.V8(0);i.children.push(r);var n=new o.Un;n.fieldBegin=r,n.text="1";var s=new o.a3;s.text=e,i.children.push(s);var a=new o.V8(2);a.fieldBegin=r,r.fieldSeparator=a,i.children.push(a),i.children.push(n);var d=new o.V8(1);d.fieldBegin=r,d.fieldSeparator=a,a.fieldEnd=d,r.fieldEnd=d,i.children.push(d),r.line=i,t.childWidgets.push(i),this.documentHelper.fields.push(r);var h=new o.VB;h.sectionFormat=new l.Z(h),h.childWidgets.push(t),this.pasteContentsInternal([h],!1)},e.prototype.insertBookmark=function(e){if(this.documentHelper.bookmarks.containsKey(e)){var t=this.documentHelper.bookmarks.get(e);t.line.children.splice(t.line.children.indexOf(t),1),t.reference.line.children.splice(t.reference.line.children.indexOf(t.reference),1),this.documentHelper.bookmarks.remove(e)}var i=new o.aQ(0);i.name=e;var r=new o.aQ(1);r.name=e,i.reference=r,r.reference=i,this.initComplexHistory("InsertBookmark"),this.insertElements([r],[i]),this.editorHistory&&this.editorHistory.updateComplexHistoryInternal(),this.documentHelper.owner.enableHeaderAndFooter&&this.updateHeaderFooterWidget(),this.documentHelper.bookmarks.add(e,i),this.selection.start.setPositionForSelection(i.line,i,1,this.selection.start.location),this.selection.end.setPositionForSelection(r.line,r,0,this.selection.end.location),this.selection.fireSelectionChanged(!0),this.fireContentChange()},e.prototype.deleteBookmark=function(e){var t=this.documentHelper.bookmarks,i=t.get(e);if(i instanceof o.aQ){i.reference;this.initHistory("DeleteBookmark"),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.setBookmarkInfo(i),this.editorHistory.updateHistory()),this.deleteBookmarkInternal(i)}this.fireContentChange()},e.prototype.deleteBookmarkInternal=function(e){var t=e.previousNode;t instanceof o.V8&&0===t.fieldType&&!(0,a.le)(t.formFieldData)&&(t.formFieldData.name=""),this.documentHelper.bookmarks.remove(e.name),e.line.children.splice(e.indexInOwner,1),(0,a.le)(e.reference)||e.reference.line.children.splice(e.reference.indexInOwner,1);var i=e.line.paragraph;if(e.line.paragraph.isInHeaderFooter){var r=void 0;i.containerWidget instanceof o.nb?r=i.containerWidget.getContainerTable().containerWidget:i.containerWidget instanceof o.NB&&(r=i.containerWidget),this.updateHeaderFooterWidget(r)}},e.prototype.getSelectionInfo=function(){var e=this.selection.start,t=this.selection.end;this.selection.isForward||(e=this.selection.end,t=this.selection.start),t.offset===this.selection.getLineLength(t.currentWidget)+1&&this.selection.isParagraphLastLine(t.currentWidget)||(t.offset+=1);var i=this.selection.getParagraphInfo(e),r=this.selection.getHierarchicalIndex(i.paragraph,i.offset.toString());i=this.selection.getParagraphInfo(t);var o=this.selection.getHierarchicalIndex(i.paragraph,i.offset.toString());return{start:r,end:o}},e.prototype.insertElements=function(e,t){var i=this.getSelectionInfo();(0,a.le)(t)||this.insertElementsInternal(this.selection.getTextPosBasedOnLogicalIndex(i.start),t),(0,a.le)(e)||this.insertElementsInternal(this.selection.getTextPosBasedOnLogicalIndex(i.end),e)},e.prototype.insertElementsInternal=function(e,t,i){this.selection.selectPosition(e,e),this.initHistory("InsertElements"),this.updateInsertPosition();var r=0,o=this.selection.getParagraphInfo(this.selection.start);if(this.selection.start.paragraph.isEmpty()){var n=this.selection.start.paragraph;n.childWidgets[0].children.push(t[0]),t[0].line=n.childWidgets[0],t[0].linkFieldCharacter(this.documentHelper),this.documentHelper.layout.reLayoutParagraph(n,0,0),this.setPositionParagraph(o.paragraph,o.offset+length,!0),e.setPositionForSelection(t[0].line,t[0],t[0].length,this.selection.start.location),this.selection.selectPosition(e,e)}else{var s=this.selection.start.currentWidget.getInline(this.documentHelper.selection.start.offset,r),a=s.element;r=s.index;var l=t[0];this.insertElementInternal(a,l,r,void 0,!0);for(var d=l.indexInOwner,h=l,c=1;c<t.length;c++)h=t[c],l.line.children.splice(d+c,0,h);e.setPositionForSelection(h.line,h,h.length,this.selection.start.location),this.selection.selectPosition(e,e)}this.editorHistory&&(this.checkEndPosition()&&this.updateHistoryPosition(this.selection.start,!1),this.editorHistory.updateHistory())},e.prototype.getCommentElementBox=function(e){var t=e.split(";"),i=this.documentHelper.comments[parseInt(t[1],10)];return t.length>2&&""!==t[2]?i.replyComments[parseInt(t[2],10)]:i},e.prototype.getBlock=function(e){var t=this.selection.getBodyWidget(e);return this.getBlockInternal(t,e)},e.prototype.getBlockInternal=function(e,t){if(""!==t.index&&!(0,a.le)(t)){var i=t.index.indexOf(";"),r=t.index.substring(0,i);t.index=t.index.substring(i).replace(";","");var n=e;i=parseInt(r,10);var s=this.selection.getBlockByIndex(e,i);if(!s)return{node:n,position:t};var l=s;if(!(t.index.indexOf(";")>=0))return{node:l,position:t};if(l instanceof o.ZH)return t.index.indexOf(";")>=0&&(t.index="0"),{node:l,position:t};if(l instanceof o.$L){var d=this.getBlockInternal(l,t);return{node:(0,a.le)(d)?void 0:d.node,position:(0,a.le)(d)?void 0:d.position}}return{node:n,position:t}}},e.prototype.updateHistoryPosition=function(e,t){if(this.editorHistory&&!(0,a.le)(this.editorHistory.currentBaseHistoryInfo)){var i=void 0;if(e instanceof r.JK){var o=this.selection.getParagraphInfo(e);i=this.selection.getHierarchicalIndex(o.paragraph,o.offset.toString())}else i=e;t?this.editorHistory.currentBaseHistoryInfo.insertPosition=i:this.editorHistory.currentBaseHistoryInfo.endPosition=i}},e.prototype.applyBorders=function(e){this.initHistory("Borders");var t=this.selection.isForward?this.selection.start:this.selection.end,i=this.selection.isForward?this.selection.end:this.selection.start,r=t.paragraph.associatedCell.ownerTable;if(r=r.combineWidget(this.owner.viewer),this.editorHistory)this.cloneTableToHistoryInfo(r);t.paragraph.associatedCell;var o,n=i.paragraph.associatedCell,s=this.getBorder(e.borderColor,e.lineWidth,e.borderStyle);if(this.selection.isEmpty)"OutsideBorders"!==e.type&&"AllBorders"!==e.type&&"LeftBorder"!==e.type||n.cellFormat.borders.left.copyFormat(s),"OutsideBorders"!==e.type&&"AllBorders"!==e.type&&"TopBorder"!==e.type||n.cellFormat.borders.top.copyFormat(s),"OutsideBorders"!==e.type&&"AllBorders"!==e.type&&"RightBorder"!==e.type||n.cellFormat.borders.right.copyFormat(s),"OutsideBorders"!==e.type&&"AllBorders"!==e.type&&"BottomBorder"!==e.type||n.cellFormat.borders.bottom.copyFormat(s),"AllBorders"!==e.type&&"InsideBorders"!==e.type&&"InsideVerticalBorder"!==e.type||n.cellFormat.borders.vertical.copyFormat(s),"AllBorders"!==e.type&&"InsideBorders"!==e.type&&"InsideHorizontalBorder"!==e.type||n.cellFormat.borders.horizontal.copyFormat(s),"NoBorder"===e.type&&this.clearAllBorderValues(n.cellFormat.borders);else{if("OutsideBorders"===e.type||"TopBorder"===e.type)for(var a=this.getTopBorderCellsOnSelection(),l=0;l<a.length;l++)a[l].cellFormat.borders.top.copyFormat(s);if("OutsideBorders"===e.type||"LeftBorder"===e.type)for(a=this.getLeftBorderCellsOnSelection(),l=0;l<a.length;l++)a[l].cellFormat.borders.left.copyFormat(s);if("OutsideBorders"===e.type||"RightBorder"===e.type)for(a=this.getRightBorderCellsOnSelection(),l=0;l<a.length;l++)a[l].cellFormat.borders.right.copyFormat(s);if("OutsideBorders"===e.type||"BottomBorder"===e.type)for(a=this.getBottomBorderCellsOnSelection(),l=0;l<a.length;l++)a[l].cellFormat.borders.bottom.copyFormat(s)}if("BottomBorder"===e.type||"AllBorders"===e.type||"OutsideBorders"===e.type||"NoBorder"===e.type){o=this.getAdjacentCellToApplyBottomBorder();for(l=0;l<o.length;l++){var d=o[l];"NoBorder"===e.type?d.cellFormat.borders.top.copyFormat(this.clearBorder()):d.cellFormat.borders.top.copyFormat(s)}}if("AllBorders"===e.type||"OutsideBorders"===e.type||"RightBorder"===e.type||"NoBorder"===e.type){o=this.getAdjacentCellToApplyRightBorder();for(l=0;l<o.length;l++){d=o[l];"NoBorder"===e.type?d.cellFormat.borders.left.copyFormat(this.clearBorder()):d.cellFormat.borders.left.copyFormat(s)}}"AllBorders"!==e.type&&"NoBorder"!==e.type||this.applyAllBorders(s,e.type),"InsideBorders"!==e.type&&"InsideVerticalBorder"!==e.type&&"InsideHorizontalBorder"!==e.type&&"NoBorder"!==e.type||this.applyInsideBorders(s,e.type,r),this.updateGridForTableDialog(r,!1),this.reLayout(this.selection,!1),this.editorHistory.updateHistory()},e.prototype.applyAllBorders=function(e,t){for(var i=this.selection.getSelectedCells(),r=0;r<i.length;r++)"NoBorder"===t?(i[r].cellFormat.borders.left.copyFormat(this.clearBorder()),i[r].cellFormat.borders.right.copyFormat(this.clearBorder()),i[r].cellFormat.borders.top.copyFormat(this.clearBorder()),i[r].cellFormat.borders.bottom.copyFormat(this.clearBorder())):(i[r].cellFormat.borders.left.copyFormat(e),i[r].cellFormat.borders.right.copyFormat(e),i[r].cellFormat.borders.top.copyFormat(e),i[r].cellFormat.borders.bottom.copyFormat(e))},e.prototype.applyInsideBorders=function(e,t,i){for(var r=this.selection.getSelectedCells(),o=0;o<r.length;o++){var n=r[o],s=n.ownerRow===r[r.length-1].ownerRow,a=n.columnIndex+n.cellFormat.columnSpan-1===r[r.length-1].columnIndex;if("NoBorder"===t?(n.cellFormat.borders.right.copyFormat(this.clearBorder()),n.cellFormat.borders.bottom.copyFormat(this.clearBorder())):(a||"InsideHorizontalBorder"===t||n.cellFormat.borders.right.copyFormat(e),s||"InsideVerticalBorder"===t||n.cellFormat.borders.bottom.copyFormat(e)),!s&&"InsideVerticalBorder"!==t){var l=n.ownerRow.rowIndex+n.cellFormat.rowSpan,d=i.childWidgets[l];if(d)for(var h=this.getAdjacentBottomBorderOnEmptyCells(d,n,!0),c=0;c<h.length;c++)"NoBorder"===t?h[c].cellFormat.borders.top.copyFormat(this.clearBorder()):h[c].cellFormat.borders.top.copyFormat(e)}if(!a&&"InsideHorizontalBorder"!==t)for(var p=this.getSelectedCellsNextWidgets(n,i),g=0;g<p.length;g++)"NoBorder"===t?p[g].cellFormat.borders.left.copyFormat(this.clearBorder()):p[g].cellFormat.borders.left.copyFormat(e)}},e.prototype.getTopBorderCellsOnSelection=function(){for(var e=this.selection.isForward?this.selection.start:this.selection.end,t=e.paragraph.associatedCell,i=[],r=this.selection.getSelectedCells(),o=0;o<r.length;o++)r[o].ownerRow===t.ownerRow&&i.push(r[o]);return i},e.prototype.getLeftBorderCellsOnSelection=function(){for(var e=this.selection.isForward?this.selection.start:this.selection.end,t=e.paragraph.associatedCell,i=this.selection.getSelectedCells(),r=[],o=0;o<i.length;o++)i[o].columnIndex===t.columnIndex&&r.push(i[o]);return r},e.prototype.getRightBorderCellsOnSelection=function(){for(var e=this.selection.getSelectedCells(),t=[],i=0;i<e.length;i++)e[i].columnIndex+e[i].cellFormat.columnSpan-1===e[e.length-1].columnIndex&&t.push(e[i]);return t},e.prototype.getBottomBorderCellsOnSelection=function(){for(var e=this.selection.isForward?this.selection.end:this.selection.start,t=e.paragraph.associatedCell,i=this.selection.getSelectedCells(),r=[],o=0;o<i.length;o++)i[o].ownerRow===t.ownerRow&&r.push(i[o]);return r},e.prototype.clearAllBorderValues=function(e){var t=this.clearBorder();e.bottom.copyFormat(t),e.left.copyFormat(t),e.right.copyFormat(t),e.top.copyFormat(t),e.vertical.copyFormat(t),e.horizontal.copyFormat(t)},e.prototype.clearBorder=function(){var e=new g.V;return e.lineStyle="Cleared",e},e.prototype.getAdjacentCellToApplyBottomBorder=function(){var e=[],t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start);var r=t.paragraph.associatedCell.ownerTable;r=r.combineWidget(this.owner.viewer);var o=t.paragraph.associatedCell,n=i.paragraph.associatedCell,s=n.ownerRow.rowIndex+n.cellFormat.rowSpan,a=r.childWidgets[s];if(a)if(n.cellFormat.columnSpan>1)for(var l=n.columnIndex;l<n.columnIndex+n.cellFormat.columnSpan;l++)e.push(a.childWidgets[l]);else if(e=this.getAdjacentBottomBorderOnEmptyCells(a,n),!this.selection.isEmpty)for(l=0;l<a.childWidgets.length;l++){var d=a.childWidgets[l].columnIndex;d>
1=o.columnIndex&&d<=n.columnIndex&&e.push(a.childWidgets[l])}return e},e.prototype.getAdjacentBottomBorderOnEmptyCells=function(e,t,i){var r=[];if(t.cellFormat.columnSpan>1)for(var o=t.columnIndex;o<t.columnIndex+t.cellFormat.columnSpan;o++)r.push(e.childWidgets[o]);else if(this.selection.isEmpty||i)for(o=0;o<e.childWidgets.length;o++)e.childWidgets[o].columnIndex===t.columnIndex&&r.push(e.childWidgets[o]);return r},e.prototype.getAdjacentCellToApplyRightBorder=function(){var e=[],t=this.selection.start,i=this.selection.end;this.selection.isForward||(t=this.selection.end,i=this.selection.start);var r=t.paragraph.associatedCell.ownerTable;r=r.combineWidget(this.owner.viewer);t.paragraph.associatedCell,i.paragraph.associatedCell;if(this.selection.isEmpty){var o=t.paragraph.associatedCell;e=this.getSelectedCellsNextWidgets(o,r)}else for(var n=this.getRightBorderCellsOnSelection(),s=0;s<n.length;s++){var a=n[s];e=e.concat(this.getSelectedCellsNextWidgets(a,r))}return e},e.prototype.getSelectedCellsNextWidgets=function(e,t){var i=[];if(!(0,a.le)(e.nextWidget)&&(i.push(e.nextWidget),e.cellFormat.rowSpan>1))for(var r=e.ownerRow.rowIndex+e.cellFormat.rowSpan,o=e.ownerRow.rowIndex+1;o<r;o++){var n=t.childWidgets[o];if(n)for(var s=0;s<n.childWidgets.length;s++)n.childWidgets[s].columnIndex===e.nextWidget.columnIndex&&i.push(n.childWidgets[s])}return i},e.prototype.getBorder=function(e,t,i){var r=new g.V;return r.color=e||"#000000",r.lineWidth=t||1,r.lineStyle=i||"Single",r},e.prototype.applyBordersInternal=function(e,t){(0,a.le)(e)||(0,a.le)(e)||((0,a.le)(e.top)||this.applyBorder(e.top,t.top),(0,a.le)(e.bottom)||this.applyBorder(e.bottom,t.bottom),(0,a.le)(e.left)||this.applyBorder(e.left,t.left),(0,a.le)(e.right)||this.applyBorder(e.right,t.right),(0,a.le)(e.horizontal)||this.applyBorder(e.horizontal,t.horizontal),(0,a.le)(e.vertical)||this.applyBorder(e.vertical,t.vertical),(0,a.le)(e.diagonalUp)||this.applyBorder(e.diagonalUp,t.diagonalUp),(0,a.le)(e.diagonalDown)||this.applyBorder(e.diagonalDown,t.diagonalDown))},e.prototype.applyShading=function(e,t){(0,a.le)(t)||(0,a.le)(e)||((0,a.le)(t.backgroundColor)||e.backgroundColor===t.backgroundColor||(e.backgroundColor=t.backgroundColor),(0,a.le)(t.foregroundColor)||e.foregroundColor===t.foregroundColor||(e.foregroundColor=t.foregroundColor),(0,a.le)(t.textureStyle)||e.textureStyle===t.textureStyle||(e.textureStyle=t.textureStyle))},e.prototype.applyBorder=function(e,t){(0,a.le)(e)||(0,a.le)(t)||((0,a.le)(t.color)||e.color===t.color||(e.color=t.color),(0,a.le)(t.lineStyle)||e.lineStyle===t.lineStyle||(e.lineStyle=t.lineStyle),(0,a.le)(t.lineWidth)||e.lineWidth===t.lineWidth||(e.lineWidth=t.lineWidth),(0,a.le)(t.shadow)||e.shadow===t.shadow||(e.shadow=t.shadow),(0,a.le)(t.space)||e.space===t.space||(e.space=t.space))},e.prototype.onTableFormat=function(e,t){if(!(0,a.le)(this.selection.tableFormat)){(0,a.le)(t)&&(t=!1),this.documentHelper.owner.isShiftingEnabled=!0,this.editorHistory.initializeHistory("TableFormat");var i=this.selection.start.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer);if(t)for(var r=0;r<i.childWidgets.length;r++)for(var o=i.childWidgets[r],n=0;n<o.childWidgets.length;n++){var s=o.childWidgets[n];s.cellFormat.shading.copyFormat(e.shading)}if(!(0,a.le)(t))for(r=0;r<i.childWidgets.length;r++){o=i.childWidgets[r];o.rowFormat.borders.copyFormat(e.borders);for(n=0;n<o.childWidgets.length;n++){s=o.childWidgets[n];s.cellFormat.borders.copyFormat(e.borders)}}this.applyTableFormat(i,void 0,e),this.reLayout(this.selection,!1)}},e.prototype.applyTableFormat=function(e,t,i){this.applyTablePropertyValue(this.documentHelper.selection,void 0,i,e)},e.prototype.applyTablePropertyValue=function(e,t,i,r){var o=r.tableFormat;(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(i=this.editorHistory.currentBaseHistoryInfo.addModifiedTableProperties(o,t,i)),i instanceof m.M?(0,a.le)(t)&&this.handleTableFormat(o,i):("preferredWidth"===t?o.preferredWidth=i:"leftIndent"===t?o.leftIndent=i:"tableAlignment"===t?o.tableAlignment=i:"cellSpacing"===t?o.cellSpacing=i:"leftMargin"===t?o.leftMargin=i:"rightMargin"===t?o.rightMargin=i:"topMargin"===t?o.topMargin=i:"bottomMargin"===t?o.bottomMargin=i:"preferredWidthType"===t?o.preferredWidthType=i:"bidi"===t&&(o.bidi=i),"shading"===t?o.shading=i:"borders"===t&&(o.borders=i))},e.prototype.handleTableFormat=function(e,t){(this.isBordersAndShadingDialog||this.editorHistory.isUndoing||this.editorHistory.isRedoing)&&((0,a.le)(e.borders)||this.applyBordersInternal(e.borders,t.borders),(0,a.le)(e.shading)||this.applyShading(e.shading,t.shading)),this.isBordersAndShadingDialog||(t.hasValue("bidi")&&t.bidi!==e.bidi&&(e.bidi=t.bidi),t.hasValue("preferredWidth")&&t.preferredWidth!==e.preferredWidth&&(e.preferredWidth=t.preferredWidth),t.hasValue("preferredWidthType")&&t.preferredWidthType!==e.preferredWidthType&&(e.preferredWidthType=t.preferredWidthType),t.hasValue("tableAlignment")&&t.tableAlignment!==e.tableAlignment&&(e.tableAlignment=t.tableAlignment),t.hasValue("leftIndent")&&t.leftIndent!==e.leftIndent&&(e.leftIndent=t.leftIndent)),this.updateGridForTableDialog(e.ownerBase,!1)},e.prototype.updateGridForTableDialog=function(e,t){e.tableHolder&&(e.updateRowIndex(0),e.isGridUpdated=!1),this.documentHelper.layout.reLayoutTable(e)},e.prototype.onRowFormat=function(e){if(!(0,a.le)(this.selection)&&!(0,a.le)(e)){this.editorHistory.initializeHistory("RowFormat"),this.documentHelper.owner.isShiftingEnabled=!0;var t=this.selection.isForward?this.selection.start:this.selection.end,i=this.selection.isForward?this.selection.end:this.selection.start;t.paragraph.associatedCell.ownerTable.combineWidget(this.owner.viewer);this.applyRowFormat(t.paragraph.associatedCell.ownerRow,t,i,void 0,e),this.reLayout(this.selection,!1)}},e.prototype.applyRowFormat=function(e,t,i,r,o){if(this.applyRowPropertyValue(this.documentHelper.selection,r,o,e),i.paragraph.associatedCell.ownerRow!==e){var n=e.nextWidget;(0,a.le)(n)||this.applyRowFormat(n,t,i,r,o)}},e.prototype.applyRowPropertyValue=function(e,t,i,r){var o=r.rowFormat;(0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(i=this.editorHistory.currentBaseHistoryInfo.addModifiedRowProperties(o,t,i)),i instanceof d.J?(0,a.le)(t)&&this.handleRowFormat(i,o):("heightType"===t?o.heightType=i:"height"===t?o.height=i:"isHeader"===t?o.isHeader=i:"allowBreakAcrossPages"===t&&(o.allowBreakAcrossPages=i),(0,a.le)(r.ownerTable)||this.layoutItemBlock(r.ownerTable,!0))},e.prototype.handleRowFormat=function(e,t){e.hasValue("allowBreakAcrossPages")&&e.allowBreakAcrossPages!==t.allowBreakAcrossPages&&(t.allowBreakAcrossPages=e.allowBreakAcrossPages),e.hasValue("isHeader")&&e.isHeader!==t.isHeader&&(t.isHeader=e.isHeader),e.hasValue("heightType")&&e.heightType!==t.heightType&&(t.heightType=e.heightType),e.hasValue("height")&&e.height!==t.height&&(t.height=e.height),this.updateGridForTableDialog(t.ownerBase.ownerTable,!0)},e.prototype.onCellFormat=function(e){(0,a.le)(this.selection)||(0,a.le)(e)||(this.editorHistory.initializeHistory("CellFormat"),this.updateFormatForCell(this.selection,void 0,e),this.reLayout(this.selection,!1))},e.prototype.onParaFormat=function(e){(0,a.le)(this.selection)||(0,a.le)(e)||(this.editorHistory.initializeHistory("ParagraphFormat"),this.updateParagraphFormat(void 0,e,!1),this.reLayout(this.selection,!1))},e.prototype.updateCellMargins=function(e,t){var i=e.start,r=e.end;e.isForward||(i=e.end,r=e.start),this.initHistoryPosition(e,i),this.documentHelper.owner.cellOptionsDialogModule.applyCellMarginValue(i.paragraph.associatedCell.ownerRow,i,r,t)},e.prototype.updateFormatForCell=function(e,t,i){var r=e.start,o=e.end;e.isForward||(r=e.end,o=e.start);for(var n,s=r.paragraph.associatedCell,a=o.paragraph.associatedCell,l=s.ownerTable.combineWidget(this.owner.viewer),d=s.columnIndex;d<=a.columnIndex;d++){n=this.getSelectedCellInColumn(s.ownerTable,s.ownerRow.rowIndex,d,a.ownerRow.rowIndex);for(var h=0;h<n.length;h++)this.applyCellPropertyValue(this.documentHelper.selection,t,i,n[h].cellFormat)}this.updateGridForTableDialog(l,!1)},e.prototype.getSelectedCellInColumn=function(e,t,i,r){for(var o=[],n=t;n<=r;n++)for(var s=e.childWidgets[n],a=0;a<s.childWidgets.length;a++)s.childWidgets[a].columnIndex===i&&o.push(s.childWidgets[a]);return o},e.prototype.getColumnCells=function(e,t,i){for(var r=[],o=0;o<e.childWidgets.length;o++)for(var n=e.childWidgets[o],s=0;s<n.childWidgets.length;s++){var a=n.childWidgets[s];
1i?a.columnIndex+a.cellFormat.columnSpan===t&&r.push(a):a.columnIndex===t&&r.push(a)}return r},e.prototype.getTableWidth=function(e){return 0!==e.tableFormat.preferredWidth||"Percent"===e.tableFormat.preferredWidthType?"Auto"===e.tableFormat.preferredWidthType||"Point"===e.tableFormat.preferredWidthType?e.tableFormat.preferredWidth:0===e.tableFormat.preferredWidth?0:s.o_.convertPixelToPoint(this.owner.viewer.clientArea.width)/100*e.tableFormat.preferredWidth:s.o_.convertPixelToPoint(this.documentHelper.layout.getTableWidth(e))},e.prototype.applyCellPropertyValue=function(e,t,i,r){if((0,a.le)(this.editorHistory.currentBaseHistoryInfo)||(i=this.editorHistory.currentBaseHistoryInfo.addModifiedCellProperties(r,t,i)),i instanceof c.D)return(0,a.le)(t)&&this.handleCellFormat(i,r),i;"leftMargin"===t?r.leftMargin=i:"topMargin"===t?r.topMargin=i:"rightMargin"===t?r.rightMargin=i:"bottomMargin"===t?r.bottomMargin=i:"preferredWidth"===t?(r.preferredWidth=i,r.cellWidth=i):"cellWidth"===t?r.cellWidth=i:"columnSpan"===t?r.columnSpan=i:"rowSpan"===t?r.rowSpan=i:"preferredWidthType"===t?r.preferredWidthType=i:"verticalAlignment"===t&&(r.verticalAlignment=i),"shading"===t?r.shading=i:"borders"===t&&(r.borders=i)},e.prototype.handleCellFormat=function(e,t){(0,a.le)(e)||(0,a.le)(t)||(this.isBordersAndShadingDialog?((0,a.le)(e.borders)||this.applyBordersInternal(t.borders,e.borders),(0,a.le)(e.shading)||this.applyShading(t.shading,e.shading)):(e.hasValue("preferredWidth")&&t.preferredWidth!==e.preferredWidth&&(t.preferredWidth=e.preferredWidth),e.hasValue("preferredWidthType")&&t.preferredWidthType!==e.preferredWidthType&&(t.preferredWidthType=e.preferredWidthType),e.hasValue("verticalAlignment")&&t.verticalAlignment!==e.verticalAlignment&&(t.verticalAlignment=e.verticalAlignment)))},e.prototype.destroy=function(){this.tableResize&&(this.tableResize.destroy(),this.tableResize=void 0),this.previousCharFormat&&(this.previousCharFormat.destroy(),this.previousCharFormat=void 0),this.previousParaFormat&&(this.previousParaFormat.destroy(),this.previousParaFormat=void 0),this.alertDialog&&this.alertDialog.destroy(),this.alertDialog=void 0,this.base64&&this.base64.destroy(),this.base64=void 0,this.endParagraph=void 0,this.copiedData=void 0,this.copiedTextContent=void 0,this.listNumberFormat=void 0,this.nodes=[],this.removedTextNodes=[],this.removedBookmarkElements=[],this.editStartRangeCollection=[],this.documentHelper=void 0},e.prototype.updateToc=function(e){if((0,a.le)(e)&&(e=this.selection.getTocFieldInternal()),this.documentHelper.layout.isTocField(e)){var t=this.selection.getFieldCode(e);-1!==t.toLocaleLowerCase().indexOf("toc")&&this.insertTableOfContents(this.validateTocSettings(this.getTocSettings(t,e)))}},e.prototype.getTocSettings=function(e,t){var i={includePageNumber:!0,rightAlign:!0};if("toc \\mergeformat"===e.toLowerCase())i.startLevel=1,i.endLevel=3;else for(var r=e.split("\\"),o=0;o<r.length;o++){var n=r[o];if(0!==n.length)switch(n[0]){case"o":if((0,a.le)(n.match(/\d+/g)))i.startLevel=1,i.endLevel=9;else{var s=n.match(/\d+/g).map(Number);i.startLevel=s[0],i.endLevel=s[1]}break;case"h":i.includeHyperlink=!0;break;case"n":i.includePageNumber=!1;break;case"p":i.rightAlign=!1;break;case"u":i.includeOutlineLevels=!0;break;case"t":this.decodeTSwitch(i,n);break}}var l=t.paragraph.paragraphFormat.getUpdatedTabs();return l.length>0&&(i.tabLeader=l[l.length-1].tabLeader),i.rightAlign&&(0,a.le)(i.tabLeader)&&(i.tabLeader="Dot"),i},e.prototype.decodeTSwitch=function(e,t){e.levelSettings={},t=t.replace("t",""),t=t.replace('"',""),t=t.replace('"',""),t=t.trim();for(var i=t.split(","),r=0;r<i.length;r++)e.levelSettings[i[r]]=parseInt(i[r+1],10),r++},e.prototype.insertTableOfContents=function(e){this.isInsertingTOC=!0;var t=this.checkAndRemoveComments();this.initComplexHistory("TOC"),(0,a.le)(e)&&(e={},e.startLevel=1,e.endLevel=3,e.includeHyperlink=!0,e.includeOutlineLevels=!0,e.includePageNumber=!0,e.rightAlign=!0,e.tabLeader="Dot");var i=void 0,r=void 0;if("TableOfContents"===this.selection.contextType&&(i=this.selection.getTocFieldInternal()),i instanceof o.V8){this.selection.start.setPositionForSelection(i.line,i,0,this.selection.start.location);var n=2;i.fieldEnd.paragraph===i.fieldEnd.paragraph.bodyWidget.lastChild&&n--,this.selection.end.setPositionForSelection(i.fieldEnd.line,i.fieldEnd,n,this.selection.end.location),this.delete()}r=this.constructTocFieldCode(e);var s=this.selection.start.isAtParagraphStart,d=this.selection.getParagraphInfo(this.selection.start),h=this.selection.getHierarchicalIndex(d.paragraph,d.offset.toString()),c=this.buildToc(this.validateTocSettings(e),r,!0,s);if(c.length>0){var p=new o.ZH,g=new o.z7(p);p.childWidgets.push(g);var u=0;s||(u=1);var m=c[u].childWidgets[0],f=m.children[0];this.appendEndField(f,g),c.push(p),this.appendEmptyPara(c)}else{var v=new a.E7("documenteditor",this.owner.defaultLocale);v.setLocale(this.owner.locale),R.hZ.alert({title:v.getConstant("No Headings"),content:v.getConstant("Add Headings"),showCloseIcon:!0,closeOnEscape:!0,position:{X:"center",Y:"center"},animationSettings:{effect:"Zoom"}}).enableRtl=this.owner.enableRtl}this.setPositionForCurrentIndex(this.selection.start,h),this.selection.end.setPositionInternal(this.selection.start);var y=new o.VB;y.sectionFormat=new l.Z(y),y.childWidgets=c,this.pasteContentsInternal([y],!1),this.isInsertingTOC=!1,this.updatePageRef(),this.editorHistory&&(this.editorHistory.updateComplexHistoryInternal(),this.updateHistoryForComments(t)),0===c.length&&(this.owner.editorHistory.undo(),this.owner.editorHistory.redoStack.pop())},e.prototype.appendEmptyPara=function(e){var t=new o.ZH,i=new o.z7(t);t.childWidgets.push(i),e.push(t)},e.prototype.constructTocFieldCode=function(e){var t="TOC";(0,a.le)(e.startLevel)||0===e.startLevel||(0,a.le)(e.endLevel)||0===e.endLevel||(t=t+' \\o "'+e.startLevel+"-"+e.endLevel+'"'),e.includePageNumber&&!e.rightAlign&&(t+=' \\p " "'),e.includePageNumber||(t+=" \\n"),e.includeHyperlink&&(t+=" \\h \\z"),e.includeOutlineLevels&&(t+=" \\u");var i=this.constructTSwitch(e);return i.length>6&&(t+=i),t},e.prototype.constructTSwitch=function(e){var t="",i=" \\t ";if(!(0,a.le)(e.levelSettings))for(var r=0,o=Object.keys(e.levelSettings);r<o.length;r++){var n=o[r];t=t+n+","+e.levelSettings[n].toString()+","}return t=t.slice(0,-1),t=i+'"'+t+'"',t},e.prototype.appendEndField=function(e,t){var i=new o.V8(1);if(i.fieldSeparator=e.fieldSeparator,e.fieldSeparator.fieldEnd=i,i.fieldBegin=e,i.fieldBegin.fieldEnd=i,i.line=t,e.revisions.length>0){var r=e.revisions[e.revisions.length-1];r.range.push(i),i.revisions.push(r)}t.children.push(i)},e.prototype.validateTocSettings=function(e){return((0,a.le)(e.startLevel)||e.startLevel<1)&&(e.startLevel=1),((0,a.le)(e.endLevel)||e.endLevel<e.endLevel)&&(e.endLevel=e.startLevel>3?e.startLevel:3),(0,a.le)(e.includeHyperlink)&&(e.includeHyperlink=!1),(0,a.le)(e.includePageNumber)&&(e.includePageNumber=!1),(0,a.le)(e.rightAlign)&&(e.rightAlign=!1),(0,a.le)(e.levelSettings)&&(e.levelSettings={}),e},e.prototype.buildToc=function(e,t,i,r){var n=this.documentHelper.pages[0].bodyWidgets[0],s=[];this.createHeadingLevels(e),e.includeOutlineLevels&&this.createOutlineLevels(e);var a=this.selection.start.paragraph.bodyWidget.sectionFormat,l=n.childWidgets[0];while(void 0!==l){if(l instanceof o.ZH&&(this.isHeadingStyle(l)||e.includeOutlineLevels&&this.isOutlineLevelStyle(l))){var d=this.insertTocBookmark(l);this.createTOCWidgets(l,s,t,d,e,i,r,a),i=!1}l=this.selection.getNextParagraphBlock(l.getSplitWidgets().pop())}return this.tocStyles={},s},e.prototype.createOutlineLevels=function(e){for(var t=e.startLevel;t<=e.endLevel;t++){var i="Level"+t.toString();(0,a.le)(this.tocStyles[i])&&(this.tocStyles[i]=t)}},e.prototype.createHeadingLevels=function(e){for(var t=e.startLevel;t<=e.endLevel;t++){var i="Heading "+t.toString();(0,a.le)(this.tocStyles[i])&&(this.tocStyles[i]=t)}if(!(0,a.le)(e.levelSettings))for(var r=0,o=Object.keys(e.levelSettings);r<o.length;r++){var n=o[r];this.tocStyles[n]=e.levelSettings[n]}},e.prototype.isHeadingStyle=function(e){var t=e.paragraphFormat.baseStyle;return void 0!==t&&!(0,a.le)(this.tocStyles[t.name])},e.prototype.isOutlineLevelStyle=function(e){var t=e.paragraphFormat.outlineLevel;return!(0,a.le)(this.tocStyles[t])},e.prototype.createTocFieldElement=function(e,t,i){var r=new o.V8(0);r.hasFieldEnd=!0,r.line=e,e.children.push(r);var n=new o.a3;n.text=t,n.line=e,e.children.push(n);var s=new o.V8(2);return s.fieldBegin=r,s.fieldBegin.fieldSeparator=s,s.line=e,e.children.push(s),r},e.prototype.createTOCWidgets=function(e,t,i,r,n,s,l,d){var c=void 0,p=void 0,g=void 0,u=!1;if(1!==t.length||3!==t[0].childWidgets[0].children.length||(0,a.le)(s)||s){p=new o.ZH;var m=void 0,f=e.paragraphFormat.baseStyle.name;m=n.includeOutlineLevels&&(0,a.le)(this.tocStyles[f])?e.paragraphFormat.outlineLevel:f;var v="TOC "+this.tocStyles[m],y=this.documentHelper.styles.findByName(v,"Paragraph");if((0,a.le)(y)&&(this.documentHelper.owner.parser.parseStyle(JSON.parse(this.getCompleteStyles()),JSON.parse(this.documentHelper.preDefinedStyles.get(v)),this.documentHelper.styles),y=this.documentHelper.styles.findByName(v,"Paragraph")),p.paragraphFormat.applyStyle(y),n.rightAlign&&n.includePageNumber){var F=new h.t;F.position=d.pageWidth-(d.leftMargin+d.rightMargin),F.tabLeader=n.tabLeader,F.deletePosition=0,F.tabJustification="Right",p.paragraphFormat.tabs.push(F)}g=new o.z7(p),p.childWidgets.push(g)}else g=t[0].childWidgets[0];void 0!==s&&s&&((0,a.le)(l)||l||(this.appendEmptyPara(t),u=!0),this.createTocFieldElement(g,i));var H="",C=!1,w=e;while(w instanceof o.ZH){for(var I=0;I<w.childWidgets.length;I++)for(var b=w.childWidgets[I],W=0;W<b.children.length;W++){var x=b.children[W];if(!x.isPageBreak)if(x instanceof o.V8||x instanceof o.aQ||C)x instanceof o.V8&&(0===x.fieldType?C=!0:2===x.fieldType&&(C=!1));else if(x instanceof o.a3||x instanceof o.no){var P=x.text,R="\t";-1!==P.indexOf(R)&&(P=P.replace(new RegExp(R,"g")," ")),H+=P}}w=w.nextSplitWidget}if(""!==H){if(n.includeHyperlink&&void 0!==r)c=this.insertTocHyperlink(g,r,H);else{var k=new o.a3;k.text=H,k.line=g,g.children.push(k)}if(n.includePageNumber&&void 0!==r){if(n.rightAlign){var T=new o.u3;T.text="\t",T.line=g,g.children.push(T)}var S=this.insertTocPageNumber(r,g,n.rightAlign,e);this.appendEndField(S,g)}n.includeHyperlink&&void 0!==c&&this.appendEndField(c,g)}if((0,a.le)(p)||""===H&&!s||t.push(p),this.owner.enableTrackChanges&&!(0,a.le)(p))if(1===t.length||u)this.insertRevisionForBlock(p,"Insertion",!0);else{var L=this.owner.revisionsInternal.changes[0];this.insertRevisionForBlock(p,"Insertion",!0,L)}},e.prototype.insertTocHyperlink=function(e,t,i){var r=' HYPERLINK \\l "'+t+'" ',n=this.createTocFieldElement(e,r,!0),s=new o.a3;return s.text=i,s.line=e,e.children.push(s),n},e.prototype.getPageNumber=function(e){var t;return t=e.bodyWidget.sectionFormat.restartPageNumbering?e.bodyWidget.page.currentPageNum:this.documentHelper.pages.indexOf(e.bodyWidget.page)+1,t},e.prototype.insertTocPageNumber=function(e,t,i,r){var n=" PAGEREF"+e+" \\h ",s=this.createTocFieldElement(t,n,!0),a=this.getPageNumber(r).toString(),l=new o.Un;return l.fieldBegin=s,i||(a=" "+a),l.text=a,l.line=t,t.children.push(l),this.pageRefFields[e]=l,s},e.prototype.updatePageRef=function(){for(var e=0,t=Object.keys(this.pageRefFields);e<t.length;e++){var i=t[e];if(this.documentHelper.bookmarks.containsKey(i)){var r=this.documentHelper.bookmarks.get(i),o=this.getPageNumber(r.paragraph).toString(),n=this.pageRefFields[i];if(o!==n.text){n.text=o;var s=n.paragraph,a=s.childWidgets.indexOf(n.line),l=n.line.children.indexOf(n);this.documentHelper.layout.reLayoutParagraph(s,a,l)}}}},e.prototype.insertTocBookmark=function(e){var t=void 0,i=e.childWidgets.length;if(i>0){var r=e.getSplitWidgets(),n=r[0],s=r.pop(),l=n.childWidgets[0],d=s.childWidgets[s.childWidgets.length-1];if(void 0!==l&&void 0!==d){var h=l.children[0];if(h instanceof o.no||h instanceof o.Xw)do{h=h.nextNode}while(h instanceof o.no||h instanceof o.Xw);if(!(0,a.le)(h)&&h instanceof o.aQ&&0===h.bookmarkType&&h.name.toLowerCase().match("^_toc"))return h.name;var c=d.children[d.children.length-1];void 0!==h&&void 0!==c&&(this.selection.start.setPositionForSelection(l,h,0,this.selection.start.location),this.selection.end.setPositionForSelection(d,c,c.length,this.selection.end.location),t=this.generateBookmarkName(),this.insertBookmark(t))}}return t},e.prototype.generateBookmarkName=function(){this.tocBookmarkId++;var e=10-this.tocBookmarkId.toString().length,t="";while(e-1>0)t="0"+t,e--;var i="_Toc"+t+this.tocBookmarkId;return i},e.prototype.onCellContentAlignment=function(e,t){this.owner.isShiftingEnabled=!0;var i=this.owner.selection;if(i.isEmpty&&i.start.paragraph.isInsideTable){this.owner.editorHistory&&this.owner.editorHistory.initComplexHistory(i,"MultiSelection"),i.selectTableCell(),this.initHistory("CellContentVerticalAlignment");var r=i.start.paragraph.associatedCell.cellFormat;this.applyCellPropertyValue(i,"verticalAlignment",e,r),this.reLayout(i,!1),this.initHistory("TextAlignment"),this.updateParagraphFormat("textAlignment",t,!1),this.reLayout(this.owner.selection,!1),this.owner.editorHistory&&this.owner.editorHistory.updateComplexHistory()}else this.owner.editorHistory&&this.owner.editorHistory.initComplexHistory(i,"MultiSelection"),(0,a.le)(i.getTable(i.start,i.end))||(this.updateSelectionTableFormat(i,"CellContentVerticalAlignment",e),this.reLayout(this.owner.selection,!1),this.initHistory("TextAlignment"),this.updateSelectionParagraphFormatting("textAlignment",t,!1),this.reLayout(i,!1)),this.owner.editorHistory&&this.owner.editorHistory.updateComplexHistory()},e.prototype.insertEditRangeElement=function(e){if(!this.documentHelper.isDocumentProtected&&!this.documentHelper.selection.isEmpty){this.initComplexHistory("RestrictEditing"),this.selection.skipEditRangeRetrieval=!0;var t=this.documentHelper.selection;this.selection.start,this.selection.end;if(this.selection.isForward||(this.selection.end,this.selection.start),t.start.paragraph.isInsideTable&&t.end.paragraph.isInsideTable&&t.start.paragraph.associatedCell.ownerTable.contains(t.end.paragraph.associatedCell)){var i=this.getOwnerCell(this.selection.isForward),r=this.getOwnerCell(!this.selection.isForward);if(i.rowIndex===r.rowIndex){for(var o=i.ownerRow.childWidgets.indexOf(i),n=i.ownerRow.childWidgets.indexOf(r),s=[],a=[],l=o;l<=n;l++){var d=this.addEditElement(e);l==o&&this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.editRangeStart=d),d.columnFirst=l,d.columnLast=l,d.line=t.start.currentWidget;var h=d.editRangeEnd;h.line=t.end.currentWidget,s.push(d),a.push(h)}this.insertElements(a,s),this.editorHistory&&this.editorHistory.updateComplexHistoryInternal();var c=s[0].line.getOffset(s[0],1);this.selection.start.setPositionParagraph(s[0].line,c),c=a[0].line.getOffset(a[0],1),this.selection.end.setPositionParagraph(a[0].line,c),this.selection.fireSelectionChanged(!0),this.fireContentChange()}else{this.insertEditRangeInsideTable(i,r,e),this.editorHistory&&this.editorHistory.updateComplexHistoryInternal();var p=this.documentHelper.getFirstParagraphInCell(i).childWidgets[0],g=this.selection.getLastParagraph(r).childWidgets[0];c=p.getOffset(p.children[0],1);this.selection.start.setPositionParagraph(p,c),c=g.getOffset(g.children[0],1),this.selection.end.setPositionParagraph(g,c),this.selection.fireSelectionChanged(!0),this.fireContentChange()}}else this.addRestrictEditingForSelectedArea(e);this.selection.skipEditRangeRetrieval=!1}},e.prototype.insertEditRangeInsideTable=function(e,t,i){var r=e.ownerTable,o=r.childWidgets.indexOf(t.ownerRow),n=r.childWidgets.indexOf(e.ownerRow),s=this.selection.getCellLeft(e.ownerRow,e),a=s+e.cellFormat.cellWidth,l=this.selection.getCellLeft(t.ownerRow,t),d=l+t.cellFormat.cellWidth,h=this.updateSelectedCellsInTable(s,a,l,d);s=h.start,a=h.end;for(var c=[],p=n;p<=o;p++){for(var g=r.childWidgets[p],u=-1,m=-1,f=0;f<g.childWidgets.length;f++){var v=g.childWidgets[f],y=this.selection.getCellLeft(g,v);this.checkCellWithInSelection(s,a,y)&&(-1===u&&(u=f),m=f)}for(var F=[],H=u;H<=m;H++){var C=0,w=void 0,I=void 0;H===u&&(w=g.childWidgets[u],I=this.documentHelper.getFirstParagraphInCell(w).childWidgets[0]);var b=this.addEditElement(i);H===u&&this.editorHistory&&this.editorHi
1story.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.editRangeStart=b),b.columnFirst=H,b.columnLast=H,b.line=I,b.line.children.splice(C,0,b),C++;var W=b.editRangeEnd;if(F.push(W),c.length>0&&H===m){for(var x=0;x<c.length;x++)c[x].line=b.line,b.line.children.splice(C,0,c[x]),C++;c=[]}}if(c=F,p===o&&c.length>0){var P=g.childWidgets[m],R=this.selection.getLastParagraph(P).lastChild;for(C=R.children.length-1,x=0;x<c.length;x++)c[x].line=R,R.children.splice(C,0,c[x]),C++}}},e.prototype.addRestrictEditingForSelectedArea=function(e){var t=this.addEditElement(e),i=t.editRangeEnd;this.editorHistory&&this.editorHistory.currentHistoryInfo&&(this.editorHistory.currentHistoryInfo.editRangeStart=t),this.insertElements([i],[t]),this.editorHistory&&this.editorHistory.updateComplexHistoryInternal();var r=t.line.getOffset(t,1);this.selection.start.setPositionParagraph(t.line,r),r=i.line.getOffset(i,1),this.selection.end.setPositionParagraph(i.line,r),this.selection.fireSelectionChanged(!0),this.fireContentChange()},e.prototype.addEditElement=function(e){var t=new o.Cw;"everyone"===e.toLocaleLowerCase()?t.group=e:t.user=e;var i=new o.jn;return i.editRangeStart=t,t.editRangeEnd=i,this.editStartRangeCollection.push(t),this.addEditCollectionToDocument(),this.editStartRangeCollection=[],t},e.prototype.protect=function(e){this.documentHelper.isDocumentProtected=!0,this.documentHelper.protectionType=e,this.selection.highlightEditRegion(),this.editorHistory&&this.editorHistory.destroy()},e.prototype.addEditCollectionToDocument=function(){for(var e=0;e<this.editStartRangeCollection.length;e++){var t=this.editStartRangeCollection[e],i=""===t.user?t.group:t.user;if(this.documentHelper.editRanges.length>0&&this.documentHelper.editRanges.containsKey(i))this.documentHelper.editRanges.get(i).push(t);else{var r=[];r.push(t),this.documentHelper.editRanges.add(i,r)}}this.selection.updateEditRangeCollection()},e.prototype.updateRangeCollection=function(e,t){if(this.documentHelper.editRanges.length>0&&this.documentHelper.editRanges.containsKey(t))this.documentHelper.editRanges.get(t).push(e);else{var i=[];i.push(e),this.documentHelper.editRanges.add(t,i)}},e.prototype.removeUserRestrictions=function(e){if(this.selection.checkSelectionIsAtEditRegion()){this.selection.skipEditRangeRetrieval=!0;var t=this.selection.getEditRangeStartElement();this.initHistory("RemoveEditRange"),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.setEditRangeInfo(t),this.editorHistory.updateHistory()),t.user!==e&&t.group!==e||this.removeUserRestrictionsInternal(t,e),this.selection.updateEditRangeCollection(),this.fireContentChange(),this.selection.skipEditRangeRetrieval=!1}},e.prototype.removeUserRestrictionsInternal=function(e,t){var i=t;(0,a.le)(t)&&(i=""===e.user?e.group:e.user);var r=this.documentHelper.editRanges.get(i).indexOf(e);this.documentHelper.editRanges.get(i).splice(r,1),0===this.documentHelper.editRanges.get(i).length&&this.documentHelper.editRanges.remove(i),e.removeEditRangeMark(),e.editRangeEnd.line.children.splice(e.editRangeEnd.indexInOwner,1),e.line.children.splice(e.indexInOwner,1)},e.prototype.removeAllEditRestrictions=function(){this.selection.skipEditRangeRetrieval=!0;for(var e=this.selection.start,t=this.selection.end,i=[],r=this.documentHelper.editRanges.keys,o=0;o<r.length;o++){i=this.documentHelper.editRanges.get(r[o]);for(var n=0;n<i.length;n++)i[n].editRangeEnd.line.children.splice(i[n].editRangeEnd.indexInOwner,1),i[n].line.children.splice(i[n].indexInOwner,1)}this.documentHelper.editRanges.clear(),this.selection.updateEditRangeCollection(),this.selection.start.setPositionInternal(e),this.selection.end.setPositionInternal(t),this.selection.editRegionHighlighters.clear(),this.owner.viewer.updateScrollBars(),this.selection.fireSelectionChanged(!1),this.selection.skipEditRangeRetrieval=!1},e.prototype.insertFormField=function(e){if(!(0,a.le)(this.selection.start)&&!this.owner.enableHeaderAndFooter){this.initHistory("InsertHyperlink");var t=!0;this.selection.isEmpty||(t=this.removeSelectedContents(this.selection)),t&&this.insertFormFieldInternal(e)}},e.prototype.insertFormFieldInternal=function(e){this.updateInsertPosition();var t=[],i=this.getCharacterFormat(this.selection),r=new n.a(void 0);r.copyFormat(i);var s=new o.V8(0);s.formFieldData=this.getFormFieldData(e),s.characterFormat.copyFormat(r),t.push(s);var a=new o.aQ(0);
1a.characterFormat.copyFormat(r),s.formFieldData.name=this.getBookmarkName(e,"Insert",this.formFieldCounter),a.name=s.formFieldData.name,t.push(a);var l=new o.a3;l.text=this.getFormFieldCode(e),t.push(l);var d=new o.V8(2);t.push(d);var h=new o.a3;h.text="CheckBox"===e?String.fromCharCode(9744):this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),h.characterFormat.copyFormat(r),t.push(h);var c=new o.V8(1);c.characterFormat.copyFormat(r),t.push(c);var p=new o.aQ(1);p.characterFormat.copyFormat(r),p.name=s.formFieldData.name,p.reference=a,a.reference=p,t.push(p),this.insertElement(t);this.selection.start.paragraph;c.linkFieldCharacter(this.documentHelper),-1===this.documentHelper.fields.indexOf(s)&&this.documentHelper.fields.push(s),-1===this.documentHelper.formFields.indexOf(s)&&this.documentHelper.formFields.push(s);var g=p.line.getOffset(p,1);this.selection.selects(p.line,g,!0),this.updateEndPosition(),this.reLayout(this.selection,!0)},e.prototype.getFormFieldData=function(e){switch(e){case"Text":return new o.$o;case"CheckBox":return new o.rF;case"DropDown":return new o.CN}},e.prototype.setFormField=function(e,t){var i,r;(0,a.le)(t.format)?(0,a.le)(t.sizeType)?(0,a.le)(t.dropdownItems)||(i="DropDown",r=new o.CN):(i="CheckBox",r=new o.rF):(i="Text",r=new o.$o),(0,a.le)(i)||(0,a.le)(r)||(r.name=(0,a.le)(t.name)?e.formFieldData.name:t.name,r.copyFieldInfo(t),this.editFormField(i,r))},e.prototype.editFormField=function(e,t){var i,r,l=this.selection.getCurrentFormField();if((0,a.le)(l)||(0,a.le)(l.formFieldData))return!1;this.initComplexHistory("FormField"),""!==t.name&&(l.formFieldData.name!==t.name&&this.documentHelper.bookmarks.containsKey(t.name)&&this.deleteBookmark(t.name),i=new o.aQ(0),i.name=t.name,r=new o.aQ(1),r.name=t.name,i.reference=r,r.reference=i),this.initHistory("InsertHyperlink"),this.editHyperlinkInternal=(0,a.le)(this.editorHistory)||this.editorHistory&&(0,a.le)(this.editorHistory.currentBaseHistoryInfo);var d=l.characterFormat.cloneFormat(),h=new n.a;h.copyFormat(d);var c=l.fieldSeparator.nextElement.characterFormat.cloneFormat(),p=l.line.getOffset(l,0);this.selection.start.setPositionParagraph(l.line,p);var g=l.fieldEnd;l.nextNode&&l.nextNode instanceof o.aQ&&(g=l.nextNode.reference),p=g.line.getOffset(g,1),this.selection.end.setPositionParagraph(g.line,p),this.skipFieldDeleteTracking=!0,this.deleteSelectedContents(this.selection,!1),this.skipFieldDeleteTracking=!1,this.updateInsertPosition();var u=[],m=new o.V8(0);m.formFieldData=t,u.push(m),m.characterFormat.copyFormat(h),(0,a.le)(i)||u.push(i);var f=new o.a3;f.text=this.getFormFieldCode(e),u.push(f);var v=new o.V8(2);v.characterFormat.copyFormat(h),u.push(v),f=new o.a3,f.characterFormat.copyFormat(c),f.text=this.getDefaultText(t),"CheckBox"===e?(f.characterFormat.copyFormat(m.characterFormat),"Exactly"===t.sizeType&&(f.characterFormat.fontSize=t.size)):t instanceof o.$o&&""!==t.defaultValue&&("Text"===t.type?f.text=s.o_.formatText(t.format,t.defaultValue):"Number"===t.type?f.text=s.o_.formatNumber(t.format,t.defaultValue):f.text=s.o_.formatDate(t.format,t.defaultValue)),u.push(f);var y=new o.V8(1);y.characterFormat.copyFormat(h),u.push(y);var F=y;(0,a.le)(r)||(F=r,u.push(r)),this.insertElement(u);this.selection.start.paragraph;y.linkFieldCharacter(this.documentHelper),-1===this.documentHelper.fields.indexOf(m)&&this.documentHelper.fields.push(m);var H=F.line.getOffset(F,1);return this.selection.selects(F.line,H,!0),this.updateEndPosition(),this.editorHistory&&this.editorHistory.currentBaseHistoryInfo&&this.editorHistory.updateHistory(),this.editorHistory&&this.editorHistory.currentHistoryInfo&&this.editorHistory.updateComplexHistory(),this.reLayout(this.selection,!0),this.editHyperlinkInternal=!1,this.nodes=[],!0},e.prototype.getDefaultText=function(e){var t="";return e instanceof o.rF?t=e.defaultValue?String.fromCharCode(9745):String.fromCharCode(9744):e instanceof o.CN?t=e.dropdownItems.length>0?e.dropdownItems[0]:this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5):e instanceof o.$o&&(t=""!==e.defaultValue?e.defaultValue:this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5)),t},e.prototype.getFormFieldCode=function(e){switch(e){case"Text":return"FORMTEXT";case"CheckBox":return"FORMCHECKBOX";case"DropDown":return"FORMDROPDOWN"}},e.prototype.toggleCheckBoxFormField=function(e,t,i){var r=e.formFieldData;if(r instanceof o.rF&&r.enabled){if(this.initHistory("UpdateFormField"),this.editorHistory){var n=void 0;r instanceof o.rF&&(n=r.checked),this.editorHistory.currentBaseHistoryInfo.setFormFieldInfo(e,n),this.editorHistory.updateHistory()}r.checked=t?i:!r.checked;var s=e.fieldSeparator,a=s.nextNode;r.checked?a.text=String.fromCharCode(9745):a.text=String.fromCharCode(9744),this.owner.documentHelper.layout.reLayoutParagraph(e.line.paragraph,0,0),this.reLayout(this.selection,!1)}},e.prototype.updateFormField=function(e,t,i){var r=e.formFieldData;r&&this.updateFormFieldInternal(e,r,t,i)},e.prototype.updateFormFieldInternal=function(e,t,i,n){if(t instanceof o.$o){""===i&&(i=n?this.getDefaultText(t):this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5));var a=i,l=t.type;"Text"===l&&""!==t.format&&(a=s.o_.formatText(t.format,i)),this.updateFormFieldResult(e,a)}else if(t instanceof o.CN){var d=t.dropdownItems[i];t.selectedIndex=i,this.updateFormFieldResult(e,d)}var h=e.fieldEnd.line.getOffset(e.fieldEnd,1),c=new r.JK(this.owner);c.setPositionParagraph(e.fieldEnd.line,h),this.documentHelper.selection.selectRange(c,c),this.reLayout(this.selection,!1)},e.prototype.updateFormFieldResult=function(e,t){this.selection.selectFieldInternal(e,!1,!0),this.insertText(t)},e.prototype.checkBookmarkAvailability=function(e,t){for(var i=this.documentHelper.bookmarks,r=0;r<i.length;r++)if(i.containsKey(e))return!1;return!0},e.prototype.getBookmarkName=function(e,t,i){var r,o=!1;while(!1===o)r=e+i,o=this.checkBookmarkAvailability(r,t),i+=1;return r},e.prototype.applyFormTextFormat=function(e){if(!(0,a.le)(e)){var t=this.getFieldResultText(e),i=t;t=s.o_.formatText(e.formFieldData.format,t),void 0!=e.fieldSeparator&&this.applyTextFormatInternal(e,t),this.initHistory("FormTextFormat"),this.editorHistory&&(this.editorHistory.currentBaseHistoryInfo.setFormFieldInfo(e,i),this.editorHistory.updateHistory())}},e.prototype.insertSpaceInFormField=function(){if(this.documentHelper.isInlineFormFillProtectedMode&&this.selection.isInlineFormFillMode()){var e=this.getFieldResultText();0!==e.length&&"\r"!==e||(this.insertTextInternal(this.documentHelper.textHelper.repeatChar(this.documentHelper.textHelper.getEnSpaceCharacter(),5),!0),this.selection.selectTextElementStartOfField(this.selection.getCurrentFormField()))}},e.prototype.getFieldResultText=function(e){(0,a.le)(e)&&(e=this.selection.getCurrentFormField());var t=this.selection.startOffset,i=this.selection.endOffset;this.selection.isModifyingSelectionInternally=!0,this.selection.selectFieldInternal(e,!1,!0);var r=this.selection.getText(!1);return this.selection.select(t,i),this.selection.isModifyingSelectionInternally=!1,r},e.prototype.applyTextFormatInternal=function(e,t){var i=e.fieldSeparator.nextElement,r=0;t=t.replace(/\r/g,"");do{if(!(0,a.le)(i)&&i instanceof o.a3&&(i.text=t.slice(r,r+i.text.length),r+=i.length),(0,a.le)(i.nextElement))if((0,a.le)(i.line.nextLine)){this.documentHelper.layout.layoutBodyWidgetCollection(i.paragraph.index,i.paragraph.bodyWidget,i.paragraph,!0);var n=i.paragraph.nextRenderedWidget;if((0,a.le)(n))break;n instanceof o.dm&&(n=this.documentHelper.getFirstParagraphBlock(n));while(n.isEmpty())n=n.nextRenderedWidget;i=n.childWidgets[0].children[0]}else i=i.line.nextLine.children[0];else i=i.nextElement}while(!(i instanceof o.V8&&1===i.fieldType&&i.fieldBegin.formFieldData instanceof o.$o));this.documentHelper.layout.layoutBodyWidgetCollection(i.paragraph.index,i.paragraph.bodyWidget,i.paragraph,!0),this.selection.isFormatUpdated=!0,this.reLayout(this.selection,!1),this.selection.isFormatUpdated=!1},e.prototype.constructCommentInitial=function(e){for(var t=e.split(" "),i="",r=0;r<t.length;r++)t[r].length>0&&""!==t[r]&&(i+=t[r][0]);return i},e.prototype.insertFootnote=function(){if(!this.selection.isinFootnote&&!this.selection.isinEndnote){this.isFootNoteInsert=!0,this.isFootNote=!0;var e=new o.R5;e.characterFormat.baselineAlignment="Superscript",e.footnoteType="Footnote",e.text="s";var t=new o.ZH,i=new o.z7(t),r=new o.a3;r.characterFormat.baselineAlignment="Superscript",r.line=i,r.text="?",i.children.push(r);var n,s=new o.a3;if(s.text=" ",s.line=i,i.children.push(s),t.childWidgets.push(i),e.bodyWidget.childWidgets.push(t),this.selection.isEmpty||this.selection.handleRightKey(),this.initInsertInline(e),e.paragraph.bodyWidget.page.footnoteWidget)for(var a=0;a<e.paragraph.bodyWidget.page.footnoteWidget.bodyWidgets.length;a++)e.paragraph.bodyWidget.page.footnoteWidget.bodyWidgets[a].footNoteReference===e&&(n=e.paragraph.bodyWidget.page.footnoteWidget.bodyWidgets[a].childWidgets[0]);this.selection.start.setPositionForLineWidget(n.childWidgets[0],s.line.getOffset(s,e.text.length)),this.selection.end.setPositionInternal(this.selection.start),this.updateFootNoteIndex(),this.reLayout(this.selection,!1),this.separator("footnote"),this.continuationSeparator("footnote"),this.isFootNote=!1}},e.prototype.updateFootnoteCollection=function(e){if(-1===this.documentHelper.footnoteCollection.indexOf(e)){var t=!1;if(this.documentHelper.footnoteCollection.length>0)for(var i=this.selection.getElementPosition(e).startPosition,r=0;r<this.documentHelper.footnoteCollection.length;r++){var o=this.selection.getElementPosition(this.documentHelper.footnoteCollection[r]).startPosition;if(i.isExistBefore(o)){t=!0,this.documentHelper.footnoteCollection.splice(r,0,e);break}}t||this.documentHelper.footnoteCollection.push(e)}},e.prototype.insertEndnote=function(){if(!this.selection.isinFootnote&&!this.selection.isinEndnote){this.documentHelper.layout.isEndnoteContentChanged=!0;var e=new o.R5;e.characterFormat.baselineAlignment="Superscript",e.footnoteType="Endnote",e.text="s";var t=new o.ZH,i=new o.z7(t),r=new o.a3;r.characterFormat.baselineAlignment="Superscript",r.line=i,r.text="?",i.children.push(r);var n=new o.a3;n.text=" ",n.line=i,i.children.push(n),t.childWidgets.push(i),e.bodyWidget.childWidgets.push(t),this.selection.isEmpty||this.selection.handleRightKey(),this.initInsertInline(e);var s,a=this.documentHelper.pages.length,l=this.documentHelper.pages[a-1].bodyWidgets[0];if(l.page.endnoteWidget)for(var d=0;d<l.page.endnoteWidget.bodyWidgets.length;d++)l.page.endnoteWidget.bodyWidgets[d].footNoteReference===e&&(s=l.page.endnoteWidget.bodyWidgets[d].childWidgets[0]);this.selection.start.setPositionForLineWidget(s.childWidgets[0],r.line.getOffset(n,e.text.length)),this.selection.end.setPositionInternal(this.selection.start),this.updateEndNoteIndex(),this.documentHelper.layout.isLayoutWhole=!0,this.layoutWholeDocument(),this.documentHelper.layout.isLayoutWhole=!1,this.reLayout(this.selection,!1),this.owner.documentHelper.blockToShift=void 0,this.separator("endnote"),this.continuationSeparator("endnote"),this.documentHelper.layout.isEndnoteContentChanged=!1}},e.prototype.updateEndnoteCollection=function(e){if(-1===this.documentHelper.endnoteCollection.indexOf(e)){var t=!1;if(this.documentHelper.endnoteCollection.length>0)for(var i=this.selection.getElementPosition(e).startPosition,r=0;r<this.documentHelper.endnoteCollection.length;r++){var s=this.selection.getElementPosition(this.documentHelper.endnoteCollection[r]).startPosition;if(i.isExistBefore(s)){t=!0,this.documentHelper.endnoteCollection.splice(r,0,e);break}}t||this.documentHelper.endnoteCollection.push(e);var a=this.documentHelper.pages.length;if(this.documentHelper.endnoteCollection.length>0){var l=!1,d=void 0,c=void 0,p=this.documentHelper.endnoteCollection.indexOf(e),g=1,u=0,m=void 0,f=this.documentHelper.pages[a-1].bodyWidgets[0];if(f.page.endnoteWidget)for(var v=0;v<f.page.endnoteWidget.bodyWidgets.length;v++){var y=this.documentHelper.endnoteCollection.indexOf(f.page.endnoteWidget.bodyWidgets[v].footNoteReference);if(y>p&&y-p===1){g=v,l=!0;break}}if(d=e,f.page.endnoteWidget instanceof o.tf&&"Endnote"===f.page.endnoteWidget.footNoteType)c=f.page.endnoteWidget;else{m=!0,c=new o.tf,c.footNoteType="Endnote",c.page=f.page;var F=new o.ZH;F.characterFormat=new n.a,F.paragraphFormat=new h.h,F.index=0;var H=new o.z7(F);F.childWidgets.push(H),this.viewer.cutFromTop(this.viewer.clientActiveArea.y+18)}var C=d.bodyWidget;for(v=0;v<d.bodyWidget.childWidgets.length;v++){var w=d.bodyWidget.childWidgets[v];this.documentHelper.layout.isLayoutWhole?w.containerWidget=void 0:(w.containerWidget=C,C.page=f.page,C.sectionFormat=c.sectionFormat,w.containerWidget.containerWidget=c),l?c.bodyWidgets.splice(g,0,C):c.bodyWidgets.push(C)}g++,m&&(f.page.endnoteWidget=c),c.height+=u}}},e.prototype.updateEndNoteIndex=function(){for(var e=this.documentHelper.endnoteCollection,t=0;t<e.length;t++)e[t].text=this.documentHelper.layout.getFootEndNote(e[t].paragraph.bodyWidget.sectionFormat.endnoteNumberFormat,t+1),(0,a.le)(e[t].bodyWidget.childWidgets[0].childWidgets[0].children[0])||
1(e[t].bodyWidget.childWidgets[0].childWidgets[0].children[0].text=e[t].text)},e.prototype.separator=function(e){var t=new o.ZH,i=new o.z7(t),r=new o.a3;r.characterFormat.fontColor="#00000000",r.line=i,r.text=String.fromCharCode(3),i.children.push(r),t.childWidgets.push(i),"footnote"===e&&this.documentHelper.footnotes.separator.length<1?this.documentHelper.footnotes.separator.push(t):"endnote"===e&&this.documentHelper.endnotes.separator.length<1&&this.documentHelper.endnotes.separator.push(t)},e.prototype.continuationSeparator=function(e){var t=new o.ZH,i=new o.z7(t),r=new o.a3;r.characterFormat.fontColor="#00000000",r.line=i,r.text=String.fromCharCode(4),i.children.push(r),t.childWidgets.push(i),"footnote"===e&&this.documentHelper.footnotes.continuationSeparator.length<1?this.documentHelper.footnotes.continuationSeparator.push(t):"endnote"===e&&this.documentHelper.endnotes.continuationSeparator.length<1&&this.documentHelper.endnotes.continuationSeparator.push(t)},e.prototype.updateFootNoteIndex=function(){for(var e=this.documentHelper.footnoteCollection,t=0;t<e.length;t++)e[t].text=(t+1).toString(),(0,a.le)(e[t].bodyWidget.childWidgets[0].childWidgets[0].children[0])||(e[t].bodyWidget.childWidgets[0].childWidgets[0].children[0].text=(t+1).toString())},e.prototype.clear=function(){this.pageRefFields&&(this.pageRefFields={})},e}()}}]); 2//# sourceMappingURL=syncfusionComponents~9ba03a3a.561c657e.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.