UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

30 lines (27 loc) 245 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.mobile.scroller.min.js`),require(`kendo.toolbar.min.js`),require(`kendo.pager.min.js`),require(`kendo.combobox.min.js`),require(`kendo.textbox.min.js`),require(`kendo.core.min.js`),require(`kendo.drawing.min.js`),require(`kendo.upload.min.js`),require(`kendo.dialog.min.js`),require(`kendo.window.min.js`),require(`kendo.binder.min.js`),require(`kendo.numerictextbox.min.js`),require(`kendo.dropdownlist.min.js`),require(`kendo.icons.min.js`),require(`kendo.draganddrop.min.js`),require(`kendo.form.min.js`),require(`kendo.colorpicker.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.mobile.scroller.min`,`kendo.toolbar.min`,`kendo.pager.min`,`kendo.combobox.min`,`kendo.textbox.min`,`kendo.core.min`,`kendo.drawing.min`,`kendo.upload.min`,`kendo.dialog.min`,`kendo.window.min`,`kendo.binder.min`,`kendo.numerictextbox.min`,`kendo.dropdownlist.min`,`kendo.icons.min`,`kendo.draganddrop.min`,`kendo.form.min`,`kendo.colorpicker.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Pdfviewer={}),e.kendo._globals.MobileScroller,e.kendo._globals.Toolbar,e.kendo._globals.Pager,e.kendo._globals.Combobox,e.kendo._globals.Textbox,e.kendo._globals.Core,e.kendo._globals.Drawing,e.kendo._globals.Upload,e.kendo._globals.Dialog,e.kendo._globals.Window,e.kendo._globals.Binder,e.kendo._globals.Numerictextbox,e.kendo._globals.Dropdownlist,e.kendo._globals.Icons,e.kendo._globals.Draganddrop,e.kendo._globals.Form,e.kendo._globals.Colorpicker))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,ee,g){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),(function(e,t){var n=window.kendo,r=e.extend;r(n,{pdfviewer:{dpl:{processor:n.Class.extend({init:function(e,t){var n=this;n.options=e,n.read=e.read,n.upload=e.upload,n.download=e.download,n.viewer=t},fetchDocument:function(){var t=this,r=e.Deferred(),i=t.viewer.options.messages.errorMessages;return t.read?(e.ajax({type:t.read.type,url:t.read.url,dataType:t.read.dataType,success:function(e){typeof e!=`string`&&(e=n.stringify(e)),r.resolve(JSON.parse(e))},error:function(e){t.viewer._triggerError({error:e.responseText,message:i.parseError})}}),r):r.resolve()},fetchPageData:function(t){var n=this,r=e.Deferred(),i=n.viewer.document.pages[t-1],a={};return a[n.read.pageField]=t,i.geometries.length?r.resolve(i):e.ajax({type:n.read.type,url:n.read.url,data:a,success:function(e){r.resolve(JSON.parse(e))},error:function(e){n.viewer._triggerError({error:e.responseText,message:n.viewer.options.messages.errorMessages.parseError})}}),r},downloadFile:function(e){window.location=this.download.url+`?file=`+e},fromJSON:function(e){var t=this.viewer;t._clearPages(),t.document=e,t.document.total=t.document.pages.length,t._renderPages(),t.resize(!0),t.activatePage(1)}})}}})})(window.kendo.jQuery);function te(){return window.pdfjsLib?!window.pdfjsLib?.GlobalWorkerOptions?.workerSrc&&!window.pdfjsWorker?(console?.error(`The pdf.worker.mjs script is not loaded. The PDF.JS library will not work correctly. Either load the script: <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.6.82/pdf.worker.mjs" type="module"><\/script> Or set it to the GlobalWorkerOptions.workerSrc property: <script type="module"> pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.6.82/pdf.worker.mjs'; <\/script>`),!1):!0:(console?.error(`PDF.JS library is required. Make sure that it is properly loaded <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.6.82/pdf.mjs" type="module"><\/script>`),!1)}kendo.pdfviewer.pdfjs={lib:window.pdfjsLib},(function(e,t){var n=kendo.Class,r=e.extend,i=JSON.parse,a=kendo.ui.progress,n=kendo.Class,o=`open`,s=n.extend({init:function(e){this.viewer=e,this.errorMessages=this.viewer.options.messages.errorMessages,this.upload=this.viewer.processor&&this.viewer.processor.upload},_initUpload:function(t,n){var i=r({select:this._onSelect.bind(this),success:this._onSuccess.bind(this),error:this._onError.bind(this),complete:this._onComplete.bind(this),showFileList:!1,multiple:!1,validation:{allowedExtensions:[`.pdf`]}},n||{});return this.upload&&r(i,{async:{saveUrl:this.upload.url,autoUpload:!0,saveField:this.upload.saveField}}),(t||e(`<input name="files" accept=".pdf" type="file" />`)).kendoUpload(i).getKendoUpload()},_onComplete:function(){a(this.viewer.pageContainer,!1)},_onSuccess:function(t){var n=i(t.response);e.isPlainObject(n)?this.viewer.processor.fromJSON(n):this.viewer._triggerError({error:n,message:this.errorMessages.parseError})},_onError:function(e){this.viewer._triggerError({error:e.XMLHttpRequest.responseText,message:this.errorMessages.notSupported})},_onSelect:function(e){var t=this,n=e.files[0];if(a(t.viewer.pageContainer,!0),!(t.viewer.trigger(o,{file:n})||t.upload)){if(n.extension.toLowerCase()!==`.pdf`){t.viewer._triggerError({error:n,message:t.errorMessages.notSupported});return}var r=new FileReader;r.onload=function(e){var n=e.target.result;let r=t.viewer._isDPLProcessor()?n:{data:n};t.viewer.fromFile(r)},r.onerror=function(){t.viewer._triggerError({error:n,message:t.errorMessages.parseError})},r.readAsArrayBuffer(n.rawFile)}}});r(kendo.pdfviewer,{UploadHelper:s})})(window.kendo.jQuery),(function(e,t){var n=e.extend,r=e.noop,i=kendo.drawing,a=i.Group,o=i.Surface,s=`render`,c=kendo.Class,l=kendo.pdfviewer.UploadHelper,u={Path:`path`,MultiPath:`multipath`,Rect:`rect`,Image:`image`,Text:`text`},d=e=>`<div class="k-page k-blank-page"> <div id="${e}" class="k-external-dropzone"> <div class="k-dropzone-inner"> <span class="k-dropzone-icon k-icon k-svg-icon k-icon-xxxl k-svg-i-upload"> <svg aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path d="M32 384v96h448v-96H32zm192-64h64V192h96L256 32 128 192h96v128z"></path> </svg> </span> <span class="k-dropzone-hint">Drag and drop files here to upload</span> </div> </div> <input name="files" accept=".pdf" type="file" ref-pdfviewer-blank-page-upload> </div>`,f=c.extend({init:function(t,n){this.viewer=n,this.processor=t.processor,this.options=t,this.pageNumber=t.number,this.element=e(`<div class='k-page' />`),this.element.attr(kendo.attr(`number`),this.pageNumber),this._updatePageSize(t),this.width=t.width,this.height=t.height},resize:function(e){var t=this.element;this._updatePageSize({width:Math.min(t.width()*e,this.width),height:Math.min(t.height()*e,this.height)})},_updatePageSize:function(e){this.element.width(e.width).height(e.height)},destroy:function(){kendo.destroy(this.element)},render:r}),p=f.extend({init:function(t,n){this.viewer=n,this.options=t,this._externalDropZoneId=`${n.element.attr(`id`)}-external-dropzone`,this.element=e(d(this._externalDropZoneId)),this._uploadHelper=new l(n)},_initUpload:function(){this._upload=this._uploadHelper._initUpload(this.element.find(`input[ref-pdfviewer-blank-page-upload]`),{dropZone:`#${this._externalDropZoneId}`,showFileList:!1,async:{autoUpload:!1,saveUrl:`save`}})},resize:r,_updatePageSize:r,destroy:function(){this._upload&&this._upload.destroy(),kendo.destroy(this.element)},render:r}),m=f.extend({draw:function(){var e=this,t=e.options.geometries;e.group=new a,e.surface.draw(e.group),e._drawGeometries(t),e.viewer.trigger(s,{page:this}),kendo.ui.progress(e.element,!1)},load:function(){var e=this;e.loaded||!e.processor||(e.processor.fetchPageData(e.pageNumber).then(function(t){e.options=t,e._initSurface(),e.draw()}),e.loaded=!0)},_initSurface:function(){var e={width:this.element.width(),height:this.element.height()},t=n({width:this.width,height:this.height},this.viewer.options.view);this.surface=new o(this.element,t),this._updatePageSize(e)},_drawGeometries:function(e){var t=this,n;if(e)for(var r=0;r<=e.length;r++){var i=e[r];if(i){switch(i.type){case u.Path:case u.MultiPath:n=t._drawPath(i);break;case u.Rect:n=t._drawRect(i);break;case u.Image:n=t._drawImage(i);break;case u.Text:n=t._drawText(i);break;default:n=null;break}n&&t.group.append(n)}}},_drawRect:function(e){var t=new kendo.geometry.Rect(e.point,e.size);return new i.Rect(t,{transform:this._getMatrix(e.transform),fill:e.fillOptions,stroke:e.strokeOptions})},_drawImage:function(e){var t=new kendo.geometry.Rect(e.point,e.size);return new i.Image(e.src,t,{transform:this._getMatrix(e.transform)})},_drawText:function(e){var t={transform:this._getMatrix(e.transform),stroke:e.strokeOptions,fill:e.fillOptions,font:e.font};return new kendo.drawing.Text(e.content,e.point,t)},_drawPath:function(e){for(var t={transform:this._getMatrix(e.transform),stroke:e.strokeOptions,fill:e.fillOptions},n=new i.MultiPath(t),r=0;r<e.paths.length;r++){var a=e.paths[r];if(!a.segments)return;n.moveTo.apply(n,a.point);for(var o=0;o<a.segments.length;o++){var s=a.segments[o];(s.points.length===1?n.lineTo:n.curveTo).apply(n,s.points)}a.closed&&n.close()}return n},_getMatrix:function(e){return new kendo.geometry.Matrix(...e)}});n(kendo.pdfviewer.dpl,{geometryTypes:u,Page:m}),n(kendo.pdfviewer,{BlankPage:p})})(window.kendo.jQuery);let ne=e=>{e.deleteAnnotation()},re=(e,t)=>{e.setHighlightColor(t)},ie=(e,t)=>{e.setFreeTextColor(t)},ae=(e,t)=>{e.setFreeTextFontSize(t)},oe=(e,t)=>{e.interactionMode!==t.mode&&e.setInteractionMode({mode:t.mode}),e.setAnnotationEditorMode(t)},se=e=>{e.resetAnnotationEditorMode()},ce=(e,t)=>{e.setInteractionMode({mode:t})},le=(e,t)=>n=>t(e(n)),_=(e,t,n)=>e.addEventListener&&e.addEventListener(t,n),v=(e,t,n)=>e&&e.removeEventListener&&e.removeEventListener(t,n),ue=()=>{},de=e=>e.preventDefault(),fe=/touch/;function pe(e){return e.type.match(fe)?{pageX:e.changedTouches[0].pageX,pageY:e.changedTouches[0].pageY,clientX:e.changedTouches[0].clientX,clientY:e.changedTouches[0].clientY,type:e.type,originalEvent:e,isTouch:!0}:{pageX:e.pageX,pageY:e.pageY,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY,type:e.type,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,originalEvent:e}}var me=class e{static supportPointerEvent(){return typeof window<`u`&&window.PointerEvent}get document(){return this._element?this._element.ownerDocument:document}constructor({press:e=ue,drag:t=ue,release:n=ue,mouseOnly:r=!1}){this._pressHandler=le(pe,e),this._dragHandler=le(pe,t),this._releaseHandler=le(pe,n),this._ignoreMouse=!1,this._mouseOnly=r,this._touchstart=e=>{e.touches.length===1&&this._pressHandler(e)},this._touchmove=e=>{e.touches.length===1&&this._dragHandler(e)},this._touchend=e=>{e.touches.length===0&&e.changedTouches.length===1&&(this._releaseHandler(e),this._ignoreMouse=!0,setTimeout(this._restoreMouse,2e3))},this._restoreMouse=()=>{this._ignoreMouse=!1},this._mousedown=e=>{let{which:t}=e;t&&t>1||this._ignoreMouse||(_(this.document,`mousemove`,this._mousemove),_(this.document,`mouseup`,this._mouseup),this._pressHandler(e))},this._mousemove=e=>{this._dragHandler(e)},this._mouseup=e=>{v(this.document,`mousemove`,this._mousemove),v(this.document,`mouseup`,this._mouseup),this._releaseHandler(e)},this._pointerdown=e=>{e.isPrimary&&e.button===0&&(_(this.document,`pointermove`,this._pointermove),_(this.document,`pointerup`,this._pointerup),_(this.document,`pointercancel`,this._pointerup),_(this.document,`contextmenu`,de),this._pressHandler(e))},this._pointermove=e=>{e.isPrimary&&this._dragHandler(e)},this._pointerup=e=>{e.isPrimary&&(v(this.document,`pointermove`,this._pointermove),v(this.document,`pointerup`,this._pointerup),v(this.document,`pointercancel`,this._pointerup),v(this.document,`contextmenu`,de),this._releaseHandler(e))}}cancelDrag(){v(this.document,`pointermove`,this._pointermove),v(this.document,`pointerup`,this._pointerup),v(this.document,`pointercancel`,this._pointerup)}bindTo(e){e!==this._element&&(this._element&&this._unbindFromCurrent(),this._element=e,this._bindToCurrent())}_bindToCurrent(){let e=this._element;if(this._usePointers()){_(e,`pointerdown`,this._pointerdown);return}_(e,`mousedown`,this._mousedown),this._mouseOnly||(_(e,`touchstart`,this._touchstart),_(e,`touchmove`,this._touchmove),_(e,`touchend`,this._touchend))}_unbindFromCurrent(){let e=this._element;if(this._usePointers()){v(e,`pointerdown`,this._pointerdown),v(this.document,`pointermove`,this._pointermove),v(this.document,`pointerup`,this._pointerup),v(this.document,`contextmenu`,de),v(this.document,`pointercancel`,this._pointerup);return}v(e,`mousedown`,this._mousedown),this._mouseOnly||(v(e,`touchstart`,this._touchstart),v(e,`touchmove`,this._touchmove),v(e,`touchend`,this._touchend))}_usePointers(){return!this._mouseOnly&&e.supportPointerEvent()}update({press:e=ue,drag:t=ue,release:n=ue,mouseOnly:r=!1}){this._pressHandler=le(pe,e),this._dragHandler=le(pe,t),this._releaseHandler=le(pe,n),this._mouseOnly=r}destroy(){this._unbindFromCurrent(),this._element=null}};me.default=me;var he=me;let ge=(...e)=>Object.assign(...e),_e=e=>e&&typeof e==`object`&&!Array.isArray(e),ve=e=>e instanceof HTMLElement,ye=e=>e&&window&&window.DotNet&&window.DotNet.DotNetObject&&e instanceof DotNet.DotNetObject,be=(e,...t)=>{if(!t.length)return e;let n=t.shift();if(_e(e)&&_e(n))for(let t in n)t===`__proto__`||t===`constructor`||(n[t]instanceof Me||ve(n[t])||t===`dotNetInstance`||ye(n[t])||n[t]&&n[t].buffer&&n[t].buffer instanceof ArrayBuffer||_e(n[t])&&Object.getPrototypeOf(n[t])!==Object.prototype?e[t]=n[t]:_e(n[t])?((!e[t]||!_e(e[t]))&&ge(e,{[t]:{}}),be(e[t],n[t])):ge(e,{[t]:n[t]}));return be(e,...t)},xe=e=>typeof e==`function`,Se=e=>typeof e==`string`,Ce=e=>Array.from(e),we=e=>e!==void 0,Te=e=>e!==null,Ee=e=>we(e)&&Te(e),De=function(){},Oe=(e,t)=>{let n=(t||document).createElement(`template`);n.innerHTML=e.trim();let r=n.content;return r.childNodes.length>1?r.childNodes:r.firstChild},ke=e=>e?.startsWith(`.`)?e:`.${e}`,Ae=e=>{let t=0;return e.wheelDelta?t=-e.wheelDelta/120:e.detail&&(t=e.detail/3),t=t>0?Math.ceil(t):Math.floor(t),t},je=()=>{let e,t,n=new Promise(function(n,r){e=n,t=r});return n.resolve=e,n.reject=t,n};var Me=class{constructor(e,t){this.options={events:{}},this.element=e,this.options=t}destroy(){this.element=null}extendOptions(e){this.options=be(this.options,e)}setOptions(e){this.options=e}trigger(e,t={}){let n={defaultPrevented:!1,preventDefault:()=>{n.defaultPrevented=!0}};return this.options.events&&xe(this.options.events[e])&&this.options.events[e](ge(n,t,{sender:this})),n.defaultPrevented}};let Ne=function(e,t,n={}){let r,i,a,o,s=0,c=function(){s=n.leading===!1?0:new Date().getTime(),r=void 0,o=e.apply(i,a),r||(i=a=null)};return function(){let l=new Date().getTime();!s&&n.leading===!1&&(s=l);let u=t-(l-s);return i=void 0,a=arguments,u<=0||u>t?(r&&=(clearTimeout(r),void 0),s=l,o=e.apply(i,a),r||(i=a=null)):!r&&n.trailing!==!1&&(r=window.setTimeout(c,u)),o}},Pe=e=>{e.preventDefault&&e.preventDefault(),e.originalEvent&&e.originalEvent.preventDefault()},Fe=(e,t)=>!e||!t?!1:e.closest(t),Ie=1e3/60,Le=`scroll`;var Re=class extends Me{constructor(e,t){super(e,t),this.options={events:{[Le]:De},filter:``,panScrollThrottleDelay:Ie,scrollDirectionModifier:-1,scrollThrottleDelay:Ie},this.onElementScroll=e=>{let t=this.element;this.shouldTrackScrollEvents()&&(this.state.trackNextElementScroll?this.scrollTo(t.scrollLeft,t.scrollTop):this.state.trackNextElementScroll=!0,this.trigger(Le,{originalEvent:e}))},this.onDragStart=e=>{if(this.state.dragStarted=!1,!this.shouldTrackPanEvents())return;let t=e.target||(e.originalEvent||{}).target;this.options.filter&&!Fe(t,this.options.filter)||(Pe(e),this.setState({dragStarted:!0,location:{pageX:e.pageX,pageY:e.pageY},locationDelta:{x:0,y:0}}))},this.onDrag=e=>{if(!this.shouldTrackPanEvents()||!this.state.dragStarted)return;this.calculateEventLocationDelta(e),this.setState({location:{pageX:e.pageX,pageY:e.pageY}});let t=this.options.scrollDirectionModifier,n=this.element.scrollLeft+t*this.state.locationDelta.x,r=this.element.scrollTop+t*this.state.locationDelta.y;this.scrollTo(n,r)},this.onDragEnd=()=>{},this.extendOptions(t),this.resetState(),this.bindEvents()}destroy(){this.unbindEvents()}initDraggable(){this.destroyDraggable(),this.options.panScrollThrottleDelay>0?this.throttledOnDrag=Ne(this.onDrag,this.options.panScrollThrottleDelay):this.throttledOnDrag=this.onDrag,this.draggable=new he({mouseOnly:!1,press:this.onDragStart,drag:this.throttledOnDrag,release:this.onDragEnd}),this.draggable.bindTo(this.element)}destroyDraggable(){this.draggable&&this.draggable.destroy&&(this.draggable.destroy(),this.throttledOnDrag&&this.throttledOnDrag.cancel&&(this.throttledOnDrag.cancel(),this.throttledOnDrag=null))}bindEvents(){this.bindDraggableEvents(),this.bindElementScroll()}bindDraggableEvents(){this.initDraggable()}bindElementScroll(){this.options.scrollThrottleDelay>0?this.throttledOnElementScroll=Ne(this.onElementScroll,this.options.scrollThrottleDelay):this.throttledOnElementScroll=this.onElementScroll,this.element.addEventListener(Le,this.throttledOnElementScroll)}unbindEvents(){this.unbindElementScroll(),this.unbindDraggableEvents()}unbindDraggableEvents(){this.destroyDraggable()}unbindElementScroll(){this.throttledOnElementScroll&&this.throttledOnElementScroll.cancel&&(this.throttledOnElementScroll.cancel(),this.throttledOnElementScroll=null),this.element.removeEventListener(Le,this.throttledOnElementScroll)}setState(e){this.state=Object.assign({},this.state||{},e)}resetState(){this.setState({trackPanEvents:!1,trackScrollEvents:!1,trackNextElementScroll:!1,location:{pageX:0,pageY:0},locationDelta:{x:0,y:0}})}enablePanEventsTracking(){this.state.trackPanEvents=!0,this.bindDraggableEvents()}disablePanEventsTracking(){this.unbindDraggableEvents(),this.state.trackPanEvents=!1}shouldTrackPanEvents(){return this.state.trackPanEvents}enableScrollEventsTracking(){this.state.trackScrollEvents=!0,this.unbindElementScroll(),this.bindElementScroll()}disableScrollEventsTracking(){this.unbindElementScroll(),this.state.trackScrollEvents=!1}shouldTrackScrollEvents(){return this.state.trackScrollEvents}calculateEventLocationDelta(e){this.state.locationDelta={x:e.pageX-this.state.location.pageX,y:e.pageY-this.state.location.pageY}}scrollTo(e,t,n={trackScrollEvent:!0}){n.trackScrollEvent||(this.state.trackNextElementScroll=!1),this.element.scrollLeft=e,this.element.scrollTop=t}};let ze=e=>{let t=e.parentElement;!e||!t||t.replaceWith(...Array.from(t.childNodes))},Be=e=>{if(!(!e||!e.length||e.length<=0))for(let t=0;t<e.length;t++)ze(e[t])},Ve=(e,t)=>{e.parentNode&&(e.parentNode.insertBefore(t,e),t.appendChild(e))},He=(e,t)=>{if(!(!e||!e.parentNode||!t))for(e.appendChild(t);e.firstChild&&e.firstChild!==t;)t.appendChild(e.firstChild)},Ue=(e,t)=>{t.classList.add(e)},We=(e,t)=>{t.classList.remove(e)},Ge=e=>`.${e}`,Ke=`data-char-index`,qe=`data-match-index`;var Je=class{constructor(e){this.options={highlightClass:`k-search-highlight`,highlightMarkClass:`k-search-highlight-mark`,charClass:`k-text-char`,textContainers:[]},this.extendOptions(e),this.resetState()}destroy(){this.clearSearch(),this.resetState()}extendOptions(e){this.options=Object.assign({},this.options,e)}setState(e){this.state=Object.assign({},this.state||{},e)}resetState(){this.setState({text:``,textNodes:[],charIndex:0,activeMatchIndex:0,matches:[]})}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}search({text:e,matchCase:t}){let n=this.escapeRegExp(e),r=new RegExp(n,t?`g`:`ig`),i;if(this.shouldTransformText()&&this.transformTextForSearch(),this.state.matches=[],this.state.activeMatchIndex=0,this.removeIndicators(),n===``)return[];for(i=r.exec(this.state.text);i;)this.state.matches.push({startOffset:i.index,endOffset:i.index+i[0].length}),i=r.exec(this.state.text);return this.highlightAllMatches(),this.addActiveMatchMark(),this.state.matches}clearSearch(){this.removeIndicators(),this.restoreOriginalText()}restoreOriginalText(){this.forEachTextContainer(e=>{Array.from(e.querySelectorAll(`span:not(.`+this.options.charClass+`)`)).forEach(e=>{let t=e.textContent;Ce(e.childNodes).forEach(t=>{e.removeChild(t)});let n=e.ownerDocument.createTextNode(t);e.appendChild(n)})})}shouldTransformText(){return!this.state.text}transformTextForSearch(){this.state.textNodes=[],this.state.charIndex=0,this.state.text=``,this.forEachTextContainer(e=>{this.extractTextNodes(e)}),this.transformTextNodesForSearch(this.state.textNodes)}extractTextNodes(e){if(e.nodeType===Node.TEXT_NODE)this.state.textNodes.push(e);else for(let t=0;t<e.childNodes.length;t++)this.extractTextNodes(e.childNodes[t])}transformTextNodesForSearch(e){for(let t=0;t<e.length;t++)this.transformTextNodeForSearch(e[t])}transformTextNodeForSearch(e){let t=e.textContent;if(t.length<=0)return;this.state.text=this.state.text+t;let n=document.createElement(`span`);Ve(e,n),e.textContent=``,this.splitTextByChars(t).forEach(e=>{n.appendChild(e)}),ze(n.childNodes[0])}splitTextByChars(e){let t=[];for(let n=0;n<e.length;n++){let r=document.createElement(`span`);Ue(this.options.charClass,r),r.setAttribute(`${Ke}`,`${this.state.charIndex}`),r.textContent=e[n],t.push(r),this.state.charIndex++}return t}forEachTextContainer(e){for(let t=0;t<this.options.textContainers.length;t++){let n=this.options.textContainers[t];e(n,t)}}highlightAllMatches(){this.state.matches.forEach((e,t)=>{this.addMatchHighlight(e.startOffset,e.endOffset,t)})}addMatchHighlight(e,t,n){for(let r=e;r<t;r++)this.forEachTextContainer(e=>{Array.from(e.querySelectorAll(Ge(`${this.options.charClass}[${Ke}='${r}']`))).forEach(e=>{Ue(this.options.highlightClass,e),e.setAttribute(qe,n)})})}removeMatchHighlights(){this.forEachTextContainer(e=>{Array.from(e.querySelectorAll(Ge(this.options.highlightClass))).forEach(e=>{We(this.options.highlightClass,e),e.removeAttribute(qe)})})}addActiveMatchMark(){!this.state.activeMatchIndex&&this.state.activeMatchIndex!==0?this.state.activeMatchIndex=0:this.state.activeMatchIndex>this.state.matches.length?this.state.activeMatchIndex=this.state.matches.length:this.removeActiveMatchMark();let e=document.createElement(`span`);e.classList.add(this.options.highlightMarkClass),this.forEachTextContainer(t=>{Array.from(t.querySelectorAll(Ge(this.options.charClass+`[data-match-index='`+this.state.activeMatchIndex+`']`))).forEach(t=>{He(t,e.cloneNode(!0))})})}removeActiveMatchMark(){this.forEachTextContainer(e=>{Be(Array.from(e.querySelectorAll(Ge(this.options.highlightMarkClass))).flatMap(e=>Array.from(e.childNodes)))})}removeIndicators(){this.removeActiveMatchMark(),this.removeMatchHighlights()}markNextMatch(){this.markNextMatchIndex(),this.addActiveMatchMark()}markPreviousMatch(){this.markPreviousMatchIndex(),this.addActiveMatchMark()}markNextMatchIndex(){this.moveActiveMatchIndex(1)}markPreviousMatchIndex(){this.moveActiveMatchIndex(-1)}moveActiveMatchIndex(e){this.state.activeMatchIndex+=e,this.state.activeMatchIndex<0?this.state.activeMatchIndex=Math.max(this.state.matches.length-1,0):this.state.activeMatchIndex>this.state.matches.length-1&&(this.state.activeMatchIndex=0)}getActiveMatchElement(){let e;return this.forEachTextContainer(t=>{let n=t.querySelector(Ge(this.options.highlightMarkClass));n&&(e=n)}),e}};function Ye(e,t,n={}){let r=et;if(n.forceProxy&&!n.proxyURL)throw Error(`No proxyURL is set, but forceProxy is true`);n.forceProxy||(Ze()&&(r=$e),navigator.msSaveBlob&&(r=Qe)),r(e,t,n)}let Xe=()=>document.createElement(`a`),Ze=()=>`download`in Xe();function Qe(e,t){let n=e;if(typeof e==`string`){let t=e.split(`;base64,`),r=t[0],i=atob(t[1]),a=new Uint8Array(i.length);for(let e=0;e<i.length;e++)a[e]=i.charCodeAt(e);n=new Blob([a.buffer],{type:r})}navigator.msSaveBlob(n,t)}function $e(e,t){let n=e;window.Blob&&e instanceof Blob&&(n=URL.createObjectURL(e));let r=Xe();r.download=t,r.href=n;let i=document.createEvent(`MouseEvents`);i.initMouseEvent(`click`,!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),r.dispatchEvent(i),setTimeout(()=>URL.revokeObjectURL(n))}function et(e,t,n){if(!n.proxyURL)return;let r=document.createElement(`form`);r.setAttribute(`action`,n.proxyURL),r.setAttribute(`method`,`POST`),r.setAttribute(`target`,n.proxyTarget||`_self`);let i=n.proxyData||{};i.fileName=t;let a=e.split(`;base64,`);for(let e in i.contentType=a[0].replace(`data:`,``),i.base64=a[1],i)if(i.hasOwnProperty(e)){let t=document.createElement(`input`);t.setAttribute(`type`,`hidden`),t.setAttribute(`name`,e),t.setAttribute(`value`,i[e]),r.appendChild(t)}document.body.appendChild(r),r.submit(),document.body.removeChild(r)}String.fromCharCode;let tt=()=>typeof window<`u`,nt={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)(\.(\d+(\.\d+)?))?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[\._]([\d\._]+)/,ipad:/(iPad).*OS\s+(\d+)[\._]([\d_]+)/,meego:/(MeeGo).+NokiaBrowser\/(\d+)\.([\d\._]+)/,webos:/(webOS)\/(\d+)\.(\d+(\.\d+)?)/,blackberry:/(BlackBerry|BB10).*?Version\/(\d+)\.(\d+(\.\d+)?)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i,ffos:/(Mobile).*rv:(\d+)\.(\d+(\.\d+)?).*Firefox/},rt={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,blackberry:/^blackberry|playbook/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i,meego:/meego/},it={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i},at={omini:/Opera\sMini/i,omobile:/Opera\sMobi/i,firefox:/Firefox|Fennec/i,mobilesafari:/version\/.*safari/i,ie:/MSIE|Windows\sPhone/i,chrome:/chrome|crios/i,webkit:/webkit/i},ot=(e,t,n)=>{for(let n in t)if(t.hasOwnProperty(n)&&t[n].test(e))return n;return n===void 0?e:n},st=e=>{let t,n=[];for(let r in nt)if(nt.hasOwnProperty(r)){if(n=e.match(nt[r]),!n)continue;if(r===`windows`&&`plugins`in window.navigator)return null;let i={};return i.device=r,i.browser=ot(e,at,`default`),i.name=ot(r,rt),i[i.name]=!0,i.majorVersion=n[2],i.minorVersion=n[3]?n[3].replace(`_`,`.`):`.0`,t=i.minorVersion.replace(`.`,``).substr(0,2),i.flatVersion=i.majorVersion+t+Array(3-(t.length<3?t.length:2)).join(`0`),i.cordova=!0,i.appMode=window.navigator.standalone||/file|local|wmapp/.test(window.location.protocol)||i.cordova,i}return null},ct=e=>{let t=null,n=[];for(let r in it)if(it.hasOwnProperty(r)&&(n=e.match(it[r]),n)){t={},t[r]=!0,t[n[1].toLowerCase().split(` `)[0].split(`/`)[0]]=!0,t.version=parseInt(document.documentMode||n[2],10);break}return t},lt=tt()&&window.navigator?window.navigator.userAgent:null,ut=lt?ct(lt):null;lt&&st(lt),tt()&&`ontouchstart`in window,ut&&!ut.chrome&&window.MSPointerEvent,ut&&!ut.chrome&&window.PointerEvent;let dt={};dt.undefined=e=>e;let ft={};ft.undefined=e=>e;let{shadow:pt,AnnotationEditorType:y,FeatureTest:mt,setLayerDimensions:ht,AnnotationEditorParamsType:b,PixelsPerInch:gt,DOMSVGFactory:_t,PDFDateString:vt,Util:yt,XfaLayer:bt,getDocument:xt,AnnotationMode:St,AbortException:Ct,TextLayer:wt,fetchData:Tt,noContextMenu:Et,PDFDocumentProxy:Dt}=window.pdfjsLib||{AnnotationEditorType:{DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15}},Ot=65535,kt=268435456,At=32767,jt=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/i.test(navigator.userAgent),Mt=e=>ct(e).safari||st(e)&&st(e).browser===`mobilesafari`,Nt=e=>{let t=ct(e),n=st(e);return t&&t.mozilla||n&&n.browser===`firefox`},Pt=1.25,Ft=(e=3)=>jt()?devicePixelRatio:devicePixelRatio*(e||3),It=e=>atob(e.replace(/^(data:application\/pdf;base64,)/gi,``)),Lt=function(e,t,n){let r=document.createElement(e);return t&&(r.className=t),Object.keys(n).forEach(e=>r.style[e]=n[e]),r},Rt=(e,t)=>{let n=e.querySelectorAll(`.k-page`),r=n[0];if(r instanceof HTMLDivElement){let e=(r.offsetHeight+r.offsetTop)*Math.max(0,Math.min(t,n.length-1)),i=r.closest(`.k-pdf-viewer-canvas`);i&&i.scrollTo({top:e,behavior:`auto`})}},zt=e=>{let t=e.querySelector(`.k-pdf-viewer-canvas`),n=e.querySelector(`.k-page:not(.k-blank-page)`);return t&&n?Math.floor(Math.round(t.scrollTop)/Math.max(1,n.offsetHeight+n.offsetTop)+.01):0},Bt=(e,t)=>{let{maxWidth:n,maxHeight:r,maxArea:i}=Nt(navigator.userAgent)?{maxWidth:At,maxHeight:At,maxArea:124992400}:Mt(navigator.userAgent)?{maxWidth:4194303,maxHeight:8388607,maxArea:kt}:{maxWidth:Ot,maxHeight:Ot,maxArea:kt},a=e,o=t,s=e/t;if(e>n&&(a=n,o=t-(e-n)/s),o>r){let e=(o-r)*s;o=r,a-=e}let c=a*o;if(c>i){let e=Math.sqrt(i/c);a*=e,o*=e}let l=a/e;return{adjustedWidth:a===e?e:Math.floor(a/2),adjustedHeight:o===t?t:Math.floor(o/2),adjustRatio:l===1?1:l/2}},Vt=e=>{let t=`.kendo-pdfviewer-common`,n=!1,r=new CSSStyleSheet;r.replaceSync(t+` { } .hiddenCanvasElement { position: absolute; top: 0; left: 0; width: 0; height: 0; display: none; }`),!(!e||!e.adoptedStyleSheets)&&(e.adoptedStyleSheets.forEach(e=>{if(e.cssRules.length>0){let r=e.cssRules[0];r instanceof CSSStyleRule&&r.selectorText.indexOf(t)===0&&(n=!0)}}),n||e.adoptedStyleSheets.push(r))};var Ht=function(e,t){return Ht=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ht(e,t)},Ut=function(){return Ut=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ut.apply(this,arguments)};function x(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}Object.create;function Wt(e){return this instanceof Wt?(this.v=e,this):new Wt(e)}Object.create;var Gt=function(e){return Gt=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Gt(e)};function S(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function C(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}let Kt=(e,t)=>{t.classList.add(e)},qt=(e,t)=>{t.classList.remove(e)},Jt=(e,t,n)=>Math.min(n,Math.max(t,e)),Yt=1.35;.35/Yt;let Xt={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Zt=`pdfjs_internal_editor_`,Qt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},$t={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},en={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};function tn(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}function nn(e){let t=Object.create(null);for(let[n,r]of e)t[n]=r;return t}let rn=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`));var an=class{static makeHexColor(e,t,n){return`${rn[e]}${rn[t]}${rn[n]}`}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}};let on=`pdfjs_internal_id_`;var sn,cn=class{constructor(e=Zt){sn.set(this,0),this.idPrefix=Zt,Object.defineProperty(this,`reset`,{value:()=>C(this,sn,0,`f`)}),this.idPrefix=e}get id(){var e,t;return`${this.idPrefix}${C(this,sn,(t=S(this,sn,`f`),e=t++,t),`f`),e}`}};sn=new WeakMap;var w,ln,un,T,dn=class{constructor(e=128){w.set(this,[]),ln.set(this,!1),un.set(this,void 0),T.set(this,-1),C(this,un,e,`f`)}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),S(this,ln,`f`))return;let s={cmd:e,undo:t,post:n,type:i};if(S(this,T,`f`)===-1){S(this,w,`f`).length>0&&(S(this,w,`f`).length=0),C(this,T,0,`f`),S(this,w,`f`).push(s);return}if(a&&S(this,w,`f`)[S(this,T,`f`)].type===i){o&&(s.undo=S(this,w,`f`)[S(this,T,`f`)].undo),S(this,w,`f`)[S(this,T,`f`)]=s;return}let c=S(this,T,`f`)+1;c===S(this,un,`f`)?S(this,w,`f`).splice(0,1):(C(this,T,c,`f`),c<S(this,w,`f`).length&&S(this,w,`f`).splice(c)),S(this,w,`f`).push(s)}undo(){if(S(this,T,`f`)===-1)return;C(this,ln,!0,`f`);let{undo:e,post:t}=S(this,w,`f`)[S(this,T,`f`)];e(),t?.(),C(this,ln,!1,`f`),C(this,T,S(this,T,`f`)-1,`f`)}redo(){if(S(this,T,`f`)<S(this,w,`f`).length-1){C(this,T,S(this,T,`f`)+1,`f`),C(this,ln,!0,`f`);let{cmd:e,post:t}=S(this,w,`f`)[S(this,T,`f`)];e(),t?.(),C(this,ln,!1,`f`)}}hasSomethingToUndo(){return S(this,T,`f`)!==-1}hasSomethingToRedo(){return S(this,T,`f`)<S(this,w,`f`).length-1}destroy(){C(this,w,null,`f`)}};w=new WeakMap,ln=new WeakMap,un=new WeakMap,T=new WeakMap;var E,fn,D,O,k,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,A,j,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,M,Zn,Qn,$n,er,tr,nr,rr,ir=class{constructor({container:e=null,viewer:t,pdfViewer:n,eventBus:r,pdfDocument:i,highlightColors:a=``}){E.add(this),this.pdfViewer=null,this.annotationEditorMode=y.NONE,this.viewParameters={},this.isShiftKeyDown=!1,this._eventBus=null,fn.set(this,new AbortController),D.set(this,null),O.set(this,new Map),k.set(this,new Map),pn.set(this,null),mn.set(this,null),hn.set(this,new dn),gn.set(this,0),_n.set(this,new Set),vn.set(this,null),yn.set(this,null),bn.set(this,new Set),xn.set(this,!0),Sn.set(this,null),Cn.set(this,null),wn.set(this,``),Tn.set(this,!1),En.set(this,null),Dn.set(this,new cn),On.set(this,!1),kn.set(this,!1),An.set(this,null),A.set(this,y.NONE),j.set(this,new Set),jn.set(this,null),Mn.set(this,null),Nn.set(this,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),Pn.set(this,[0,0]),Fn.set(this,null),In.set(this,null),Ln.set(this,null);let o=this._signal=S(this,fn,`f`).signal;C(this,In,e,`f`),C(this,Ln,t,`f`),this.pdfViewer=n,this._eventBus=r,this._eventBus._on(`editingaction`,this.onEditingAction.bind(this),{signal:o}),this._eventBus._on(`pagechanging`,this.onPageChanging.bind(this),{signal:o}),this._eventBus._on(`scalechanging`,this.onScaleChanging.bind(this),{signal:o}),this._eventBus._on(`rotationchanging`,this.onRotationChanging.bind(this),{signal:o}),this._eventBus._on(`setpreference`,this.onSetPreference.bind(this),{signal:o}),this._eventBus._on(`namedaction`,this.onNamedAction.bind(this),{signal:o}),S(this,E,`m`,Un).call(this),S(this,E,`m`,Xn).call(this),S(this,E,`m`,Kn).call(this),C(this,pn,i.annotationStorage,`f`),C(this,wn,a||``,`f`),this.viewParameters={realScale:gt.PDF_TO_CSS_UNITS,rotation:0}}destroy(){S(this,fn,`f`)?.abort(),C(this,fn,null,`f`),this._signal=null;for(let e of S(this,k,`f`).values())e.destroy();S(this,k,`f`).clear(),S(this,O,`f`).clear(),S(this,bn,`f`).clear(),C(this,D,null,`f`),S(this,j,`f`).clear(),S(this,hn,`f`).destroy(),S(this,Sn,`f`)&&(clearTimeout(S(this,Sn,`f`)),C(this,Sn,null,`f`)),S(this,Fn,`f`)&&(clearTimeout(S(this,Fn,`f`)),C(this,Fn,null,`f`))}getTextLayerForAnchor(e){return e?e.closest(`.textLayer`)||e.closest(`.k-text-layer`):null}combinedSignal(e){return AbortSignal&&AbortSignal.any?AbortSignal.any([this._signal,e.signal]):this._signal||e.signal}get direction(){return pt(this,`direction`,getComputedStyle(S(this,In,`f`)).direction)}get highlightColors(){return pt(this,`highlightColors`,S(this,wn,`f`)?new Map:null)}get highlightColorNames(){return pt(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal,mode:e}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e}){switch(e){case`enableNewAltTextWhenAddingImage`:break;default:break}}onNamedAction(e){switch(e.action){case`Print`:this.triggerPrinting();break;case`SaveAs`:this.downloadOrSave();break}}onPageChanging({pageNumber:e}){C(this,gn,e-1,`f`)}focusMainContainer(){S(this,In,`f`)?.focus()}findParent(e,t){for(let n of S(this,k,`f`).values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}triggerPrinting(){this.pdfViewer?.printFile()}downloadOrSave(){this.pdfViewer?.downloadFile({fileName:this.pdfViewer?.options.downloadFileName})}disableUserSelect(e=!1){S(this,Ln,`f`)?.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){S(this,bn,`f`).add(e)}removeShouldRescale(e){S(this,bn,`f`).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*gt.PDF_TO_CSS_UNITS;for(let e of S(this,bn,`f`))e.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=``){let t=document.getSelection();if(!t||t.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t,o=t.toString(),s=S(this,E,`m`,Rn).call(this,t),c=this.getTextLayerForAnchor(s),l=this.getSelectionBoxes(c);if(!l)return;t.empty();let u=S(this,E,`m`,zn).call(this,c),d=S(this,A,`f`)===y.NONE,f=()=>{u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a,text:o}),d&&this.showAllEditors(`highlight`,!0)};if(d){this.switchToMode(y.HIGHLIGHT,f);return}f()}showEditorToolBar(e){if(!e)return;let t=this.getMode();t!==y.HIGHLIGHT&&t!==y.FREETEXT||this._eventBus.dispatch(`kendoAnnotationEditorToolBarShow`,{source:this,anchor:e})}hideEditorToolBar(){this._eventBus.dispatch(`kendoAnnotationEditorToolBarHide`,{source:this})}addToAnnotationStorage(e){!e.isEmpty()&&S(this,pn,`f`)&&!S(this,pn,`f`).has(e.id)&&S(this,pn,`f`).setValue(e.id,e)}blur(){if(this.isShiftKeyDown=!1,S(this,Tn,`f`)&&(C(this,Tn,!1,`f`),S(this,E,`m`,Hn).call(this,`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of S(this,j,`f`))if(t.div.contains(e)){C(this,An,[t,e],`f`),t._focusEventsAllowed=!1;break}}focus(){if(!S(this,An,`f`))return;let[e,t]=S(this,An,`f`);C(this,An,null,`f`),t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){S(this,E,`m`,Kn).call(this),S(this,E,`m`,Jn).call(this)}removeEditListeners(){S(this,E,`m`,qn).call(this),S(this,E,`m`,Yn).call(this)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of S(this,yn,`f`))if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of S(this,yn,`f`))if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),S(this,D,`f`)?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of S(this,j,`f`)){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of S(this,yn,`f`))if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch{return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)S(this,E,`m`,er).call(this,t);S(this,E,`m`,rr).call(this,e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch{}}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break;default:break}}setEditingState(e){e?(S(this,E,`m`,Wn).call(this),S(this,E,`m`,Jn).call(this),S(this,E,`m`,M).call(this,{isEditing:S(this,A,`f`)!==y.NONE,isEmpty:S(this,E,`m`,nr).call(this),hasSomethingToUndo:S(this,hn,`f`).hasSomethingToUndo(),hasSomethingToRedo:S(this,hn,`f`).hasSomethingToRedo(),hasSelectedEditor:!1})):(S(this,E,`m`,Gn).call(this),S(this,E,`m`,Yn).call(this),S(this,E,`m`,M).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!S(this,yn,`f`)){C(this,yn,e,`f`);for(let e of S(this,yn,`f`))S(this,E,`m`,Zn).call(this,e.defaultPropertiesToUpdate)}}getId(){return S(this,Dn,`f`).id}get currentLayer(){return S(this,k,`f`).get(S(this,gn,`f`))}getLayer(e){return S(this,k,`f`).get(e)}get currentPageIndex(){return S(this,gn,`f`)}addLayer(e){S(this,k,`f`).set(e.pageIndex,e),S(this,On,`f`)?e.enable():e.disable()}removeLayer(e){S(this,k,`f`).delete(e.pageIndex)}updateMode(e,t=null,n=!1){if(S(this,A,`f`)!==e){if(C(this,A,e,`f`),e===y.NONE){this.setEditingState(!1),S(this,E,`m`,$n).call(this);return}this.setEditingState(!0),S(this,E,`m`,Qn).call(this),this.unselectAll();for(let t of S(this,k,`f`).values())t.updateMode(e);if(!t&&n){this.addNewEditorFromKeyboard();return}if(t){for(let e of S(this,O,`f`).values())if(e.annotationElementId===t){this.setSelected(e),e.enterInEditMode();break}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==S(this,A,`f`)&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,mode:e})}updateParams(e,t){if(S(this,yn,`f`)){switch(e){case b.CREATE:this.currentLayer.addNewEditor();return;case b.HIGHLIGHT_DEFAULT_COLOR:break;case b.HIGHLIGHT_SHOW_ALL:C(this,Mn,S(this,Mn,`f`)||new Map,`f`).set(e,t),this.showAllEditors(`highlight`,t);break;default:break}for(let n of S(this,j,`f`))n.updateParams(e,t);for(let n of S(this,yn,`f`))n.updateDefaultParams(e,t)}}showAllEditors(e,t){for(let n of S(this,O,`f`).values())n.editorType===e&&n.show(t);(S(this,Mn,`f`)?.get(b.HIGHLIGHT_SHOW_ALL)??!0)!==t&&S(this,E,`m`,Zn).call(this,[[b.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(S(this,kn,`f`)!==e){C(this,kn,e,`f`);for(let t of S(this,k,`f`).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}getEditors(e){let t=[];for(let n of S(this,O,`f`).values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return S(this,O,`f`).get(e)}addEditor(e){S(this,O,`f`).set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(S(this,Sn,`f`)&&clearTimeout(S(this,Sn,`f`)),C(this,Sn,setTimeout(()=>{this.focusMainContainer(),C(this,Sn,null,`f`)},0),`f`)),S(this,O,`f`).delete(e.id),this.unselect(e),(!e.annotationElementId||!S(this,_n,`f`).has(e.annotationElementId))&&S(this,pn,`f`)?.remove(e.id)}addDeletedAnnotationElement(e){S(this,_n,`f`).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return S(this,_n,`f`).has(e)}removeDeletedAnnotationElement(e){S(this,_n,`f`).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){S(this,D,`f`)!==e&&(C(this,D,e,`f`),e&&S(this,E,`m`,Zn).call(this,e.propertiesToUpdate))}updateUI(e){S(this,E,`a`,tr)===e&&S(this,E,`m`,Zn).call(this,e.propertiesToUpdate)}toggleSelected(e){if(S(this,j,`f`).has(e)){S(this,j,`f`).delete(e),e.unselect(),S(this,E,`m`,M).call(this,{hasSelectedEditor:this.hasSelection});return}S(this,j,`f`).add(e),e.select(),S(this,E,`m`,Zn).call(this,e.propertiesToUpdate),S(this,E,`m`,M).call(this,{hasSelectedEditor:!0})}setSelected(e){for(let t of S(this,j,`f`))t!==e&&t.unselect();S(this,j,`f`).clear(),S(this,j,`f`).add(e),e.select(),S(this,E,`m`,Zn).call(this,e.propertiesToUpdate),S(this,E,`m`,M).call(this,{hasSelectedEditor:!0})}isSelected(e){return S(this,j,`f`).has(e)}get firstSelectedEditor(){return S(this,j,`f`).values().next().value}unselect(e){e.unselect(),S(this,j,`f`).delete(e),S(this,E,`m`,M).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return S(this,j,`f`).size!==0}get isEnterHandled(){return S(this,j,`f`).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){S(this,hn,`f`).undo(),S(this,E,`m`,M).call(this,{hasSomethingToUndo:S(this,hn,`f`).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:S(this,E,`m`,nr).call(this)})}redo(){S(this,hn,`f`).redo(),S(this,E,`m`,M).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:S(this,hn,`f`).hasSomethingToRedo(),isEmpty:S(this,E,`m`,nr).call(this)})}addCommands(e){S(this,hn,`f`).add(e),S(this,E,`m`,M).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:S(this,E,`m`,nr).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...S(this,j,`f`)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)S(this,E,`m`,er).call(this,t)},mustExec:!0})}commitOrRemove(){S(this,D,`f`)?.commitOrRemove()}hasSomethingToControl(){return S(this,D,`f`)||this.hasSelection}selectAll(){for(let e of S(this,j,`f`))e.commit();S(this,E,`m`,rr).call(this,S(this,O,`f`).values())}unselectAll(){if(!(S(this,D,`f`)&&(S(this,D,`f`).commitOrRemove(),S(this,A,`f`)!==y.NONE))&&this.hasSelection){for(let e of S(this,j,`f`))e.unselect();S(this,j,`f`).clear(),S(this,E,`m`,M).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;S(this,Pn,`f`)[0]+=e,S(this,Pn,`f`)[1]+=t;let[r,i]=S(this,Pn,`f`),a=[...S(this,j,`f`)];S(this,Fn,`f`)&&clearTimeout(S(this,Fn,`f`)),C(this,Fn,setTimeout(()=>{C(this,Fn,null,`f`),S(this,Pn,`f`)[0]=S(this,Pn,`f`)[1]=0,this.addCommands({cmd:()=>{for(let e of a)S(this,O,`f`).has(e.id)&&e.translateInPage(r,i)},undo:()=>{for(let e of a)S(this,O,`f`).has(e.id)&&e.translateInPage(-r,-i)},mustExec:!1})},1e3),`f`);for(let n of a)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),C(this,vn,new Map,`f`);for(let e of S(this,j,`f`))S(this,vn,`f`).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!S(this,vn,`f`))return!1;this.disableUserSelect(!1);let e=S(this,vn,`f`);C(this,vn,null,`f`);let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(S(this,O,`f`).has(e.id)){let i=S(this,k,`f`).get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(S(this,vn,`f`))for(let n of S(this,vn,`f`).keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}isActive(e){return S(this,D,`f`)===e}getActive(){return S(this,D,`f`)}getActiveEditor(){return S(this,D,`f`)}getMode(){return S(this,A,`f`)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a});break}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r===0||i===0||s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){C(this,mn,S(this,mn,`f`)||new Map,`f`).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){S(this,mn,`f`)?.delete(e)}renderAnnotationElement(e){let t=S(this,mn,`f`)?.get(e.data.id);if(!t)return;let n=S(this,pn,`f`).getRawValue(t);n&&(S(this,A,`f`)===y.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}};fn=new WeakMap,D=new WeakMap,O=new WeakMap,k=new WeakMap,pn=new WeakMap,mn=new WeakMap,hn=new WeakMap,gn=new WeakMap,_n=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,xn=new WeakMap,Sn=new WeakMap,Cn=new WeakMap,wn=new WeakMap,Tn=new WeakMap,En=new WeakMap,Dn=new WeakMap,On=new WeakMap,kn=new WeakMap,An=new WeakMap,A=new WeakMap,j=new WeakMap,jn=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,Pn=new WeakMap,Fn=new WeakMap,In=new WeakMap,Ln=new WeakMap,E=new WeakSet,Rn=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},zn=function(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of S(this,k,`f`).values())if(t.hasTextLayer(e))return t;return null},Bn=function(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=S(this,E,`m`,Rn).call(this,e),n=this.getTextLayerForAnchor(t);this.getSelectionBoxes(n)&&this.showEditorToolBar(t)},Vn=function(){let e=document.getSelection();if(!e||e.isCollapsed){S(this,jn,`f`)&&(C(this,jn,null,`f`),S(this,E,`m`,M).call(this,{hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===S(this,jn,`f`))return;let n=S(this,E,`m`,Rn).call(this,e),r=this.getTextLayerForAnchor(n);if(!r){S(this,jn,`f`)&&(S(this,En,`f`)?.hide(),C(this,jn,null,`f`),S(this,E,`m`,M).call(this,{hasSelectedText:!1}));return}if(S(this,En,`f`)?.hide(),C(this,jn,t,`f`)