@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 138 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("kendo.draggable.cmn.chunk.js"),require("kendo.file-saver.cmn.chunk.js"),require("kendo.common.cmn.chunk.js"),require("kendo.pdfjs.loader.js"),require("kendo.dateinputs-common.cmn.chunk.js")):"function"==typeof define&&define.amd?define(["exports","kendo.draggable.cmn.chunk","kendo.file-saver.cmn.chunk","kendo.common.cmn.chunk","kendo.pdfjs.loader","kendo.dateinputs-common.cmn.chunk"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).kendo=t.kendo||{},t.kendo._globals=t.kendo._globals||{},t.kendo._globals.PdfviewerCommonCmnChunk={}),t.kendo._globals.DraggableCmnChunk,t.kendo._globals.FileSaverCmnChunk,t.kendo._globals.CommonCmnChunk,t.kendo._globals.PdfjsLoader,t.kendo._globals.DateinputsCommonCmnChunk)}(this,(function(t,e,i,s,a,n){const o=(...t)=>Object.assign(...t),r=t=>t&&"object"==typeof t&&!Array.isArray(t),h=(t,...e)=>{if(!e.length)return t;const i=e.shift();if(r(t)&&r(i))for(const e in i)i[e]instanceof d?t[e]=i[e]:i[e]instanceof HTMLElement||"dotNetInstance"===e||(s=i[e])&&window&&window.DotNet&&window.DotNet.DotNetObject&&s instanceof DotNet.DotNetObject||i[e]&&i[e].buffer&&i[e].buffer instanceof ArrayBuffer||r(i[e])&&Object.getPrototypeOf(i[e])!==Object.prototype?t[e]=i[e]:r(i[e])?(t[e]&&r(t[e])||o(t,{[e]:{}}),h(t[e],i[e])):o(t,{[e]:i[e]});var s;return h(t,...e)},l=function(){};class d{constructor(t,e){this.options={events:{}},this.element=t,this.options=e}destroy(){this.element=null}extendOptions(t){this.options=h(this.options,t)}setOptions(t){this.options=t}trigger(t,e={}){const i={defaultPrevented:!1,preventDefault:()=>{i.defaultPrevented=!0}};return"function"==typeof this.options.events[t]&&this.options.events[t](o(i,e,{sender:this})),i.defaultPrevented}}const c=function(t,e,i={}){let s,a,n,o,r=0;const h=function(){r=!1===i.leading?0:(new Date).getTime(),s=void 0,o=t.apply(a,n),s||(a=n=null)};return function(){const l=(new Date).getTime();r||!1!==i.leading||(r=l);const d=e-(l-r);return a=void 0,n=arguments,d<=0||d>e?(s&&(clearTimeout(s),s=void 0),r=l,o=t.apply(a,n),s||(a=n=null)):s||!1===i.trailing||(s=window.setTimeout(h,d)),o}},f=1e3/60,u="scroll";class p extends d{constructor(t,e){super(t,e),this.options={events:{[u]:l},filter:"",panScrollThrottleDelay:f,scrollDirectionModifier:-1,scrollThrottleDelay:f},this.onElementScroll=t=>{const e=this.element;this.shouldTrackScrollEvents()&&(this.state.trackNextElementScroll?this.scrollTo(e.scrollLeft,e.scrollTop):this.state.trackNextElementScroll=!0,this.trigger(u,{originalEvent:t}))},this.onDragStart=t=>{if(this.state.dragStarted=!1,!this.shouldTrackPanEvents())return;const e=t.target||(t.originalEvent||{}).target;this.options.filter&&!((t,e)=>!(!t||!e)&&t.closest(e))(e,this.options.filter)||((t=>{t.preventDefault&&t.preventDefault(),t.originalEvent&&t.originalEvent.preventDefault()})(t),this.setState({dragStarted:!0,location:{pageX:t.pageX,pageY:t.pageY},locationDelta:{x:0,y:0}}))},this.onDrag=t=>{if(!this.shouldTrackPanEvents()||!this.state.dragStarted)return;this.calculateEventLocationDelta(t),this.setState({location:{pageX:t.pageX,pageY:t.pageY}});const e=this.options.scrollDirectionModifier,i=this.element.scrollLeft+e*this.state.locationDelta.x,s=this.element.scrollTop+e*this.state.locationDelta.y;this.scrollTo(i,s)},this.onDragEnd=()=>{this.shouldTrackPanEvents()},this.extendOptions(e),this.resetState(),this.bindEvents()}destroy(){this.unbindEvents()}initDraggable(){this.destroyDraggable(),this.options.panScrollThrottleDelay>0?this.throttledOnDrag=c(this.onDrag,this.options.panScrollThrottleDelay):this.throttledOnDrag=this.onDrag,this.draggable=new e.D({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=c(this.onElementScroll,this.options.scrollThrottleDelay):this.throttledOnElementScroll=this.onElementScroll,this.element.addEventListener(u,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(u,this.throttledOnElementScroll)}setState(t){this.state=Object.assign({},this.state||{},t)}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(t){this.state.locationDelta={x:t.pageX-this.state.location.pageX,y:t.pageY-this.state.location.pageY}}scrollTo(t,e,i={trackScrollEvent:!0}){i.trackScrollEvent||(this.state.trackNextElementScroll=!1),this.element.scrollLeft=t,this.element.scrollTop=e}}const g=t=>{const e=t.parentElement;t&&e&&e.replaceWith(...Array.from(e.childNodes))},m=t=>`.${t}`,v="data-char-index",E="data-match-index";class w{constructor(t){this.options={highlightClass:"k-search-highlight",highlightMarkClass:"k-search-highlight-mark",charClass:"k-text-char",textContainers:[]},this.extendOptions(t),this.resetState()}destroy(){this.clearSearch()}extendOptions(t){this.options=Object.assign({},this.options,t)}setState(t){this.state=Object.assign({},this.state||{},t)}resetState(){this.setState({text:"",textNodes:[],charIndex:0,activeMatchIndex:0,matches:[]})}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}search({text:t,matchCase:e}){const i=this.escapeRegExp(t),s=new RegExp(i,e?"g":"ig");let a;if(this.shouldTransformText()&&this.transformTextForSearch(),this.state.matches=[],this.state.activeMatchIndex=0,this.removeIndicators(),""===i)return[];for(a=s.exec(this.state.text);a;)this.state.matches.push({startOffset:a.index,endOffset:a.index+a[0].length}),a=s.exec(this.state.text);return this.highlightAllMatches(),this.addActiveMatchMark(),this.state.matches}clearSearch(){this.removeIndicators(),this.restoreOriginalText()}restoreOriginalText(){this.forEachTextContainer((t=>{Array.from(t.querySelectorAll("span:not(."+this.options.charClass+")")).forEach((t=>{t.innerHTML=t.textContent}))}))}shouldTransformText(){return!this.state.text}transformTextForSearch(){this.state.textNodes=[],this.state.charIndex=0,this.state.text="",this.forEachTextContainer((t=>{this.extractTextNodes(t)})),this.transformTextNodesForSearch(this.state.textNodes)}extractTextNodes(t){if(t.nodeType===Node.TEXT_NODE)this.state.textNodes.push(t);else for(let e=0;e<t.childNodes.length;e++)this.extractTextNodes(t.childNodes[e])}transformTextNodesForSearch(t){for(let e=0;e<t.length;e++)this.transformTextNodeForSearch(t[e])}transformTextNodeForSearch(t){const e=t.textContent;if(e.length<=0)return;this.state.text=this.state.text+e;const i=document.createElement("span");var s,a;a=i,(s=t).parentNode&&(s.parentNode.insertBefore(a,s),a.appendChild(s));const n=this.splitTextByChars(e);i.innerHTML=n,g(i.childNodes[0])}splitTextByChars(t){let e="";for(let i=0;i<t.length;i++)e+=`<span class='${this.options.charClass}' ${v}=${this.state.charIndex}>${t[i]}</span>`,this.state.charIndex++;return e}forEachTextContainer(t){for(let e=0;e<this.options.textContainers.length;e++){t(this.options.textContainers[e],e)}}highlightAllMatches(){this.state.matches.forEach(((t,e)=>{this.addMatchHighlight(t.startOffset,t.endOffset,e)}))}addMatchHighlight(t,e,i){for(let s=t;s<e;s++)this.forEachTextContainer((t=>{Array.from(t.querySelectorAll(m(`${this.options.charClass}[${v}='${s}']`))).forEach((t=>{var e;e=this.options.highlightClass,t.classList.add(e),t.setAttribute(E,i)}))}))}removeMatchHighlights(){this.forEachTextContainer((t=>{Array.from(t.querySelectorAll(m(this.options.highlightClass))).forEach((t=>{var e;e=this.options.highlightClass,t.classList.remove(e),t.removeAttribute(E)}))}))}addActiveMatchMark(){this.state.activeMatchIndex||0===this.state.activeMatchIndex?this.state.activeMatchIndex>this.state.matches.length?this.state.activeMatchIndex=this.state.matches.length:this.removeActiveMatchMark():this.state.activeMatchIndex=0;const t=document.createElement("span");t.classList.add(this.options.highlightMarkClass),this.forEachTextContainer((e=>{Array.from(e.querySelectorAll(m(this.options.charClass+"["+E+"='"+this.state.activeMatchIndex+"']"))).forEach((e=>{((t,e)=>{if(t&&t.parentNode&&e)for(t.appendChild(e);t.firstChild&&t.firstChild!==e;)e.appendChild(t.firstChild)})(e,t.cloneNode(!0))}))}))}removeActiveMatchMark(){this.forEachTextContainer((t=>{(t=>{if(t&&t.length&&!(t.length<=0))for(let e=0;e<t.length;e++)g(t[e])})(Array.from(t.querySelectorAll(m(this.options.highlightMarkClass))).flatMap((t=>Array.from(t.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(t){this.state.activeMatchIndex+=t,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 t;return this.forEachTextContainer((e=>{const i=e.querySelector(m(this.options.highlightMarkClass));i&&(t=i)})),t}}class b{constructor(t,e,i,s,a,n){this.container=t,this.viewport=e,this.zoom=a,this.annotation=i,this.pdfDoc=s,this.rootElement=n}destroy(){}}class y extends b{constructor(t,e,i,s,a,n){super(t,e,i,s,a,n),this.onLinkClick=t=>{const e=t.target.getAttribute("href");e&&0===e.indexOf("#")&&(this.navigateToDestination(e),t.preventDefault())},this.linkElement=null,this.renderAnnotation(),this.bindEvents()}destroy(){this.unbindEvents()}bindEvents(){this.linkElement.addEventListener("click",this.onLinkClick)}unbindEvents(){this.linkElement.removeEventListener("click",this.onLinkClick)}navigateToDestination(t){const e=t.split("#")[1];this.pdfDoc.getDestination(e).then((t=>{this.pdfDoc.getPageIndex(t[0]).then((t=>this.goToPage(t)))}))}goToPage(t){L(this.rootElement,t)}renderAnnotation(){const t=this.annotation,e=this.viewport,i=t.rect,s=[[i[0],i[1]],[i[2],i[3]]],a=e.rawDims.pageHeight,n=Math.min(s[0][0],s[1][0])*this.zoom,o=(a-Math.max(s[0][1],s[1][1]))*this.zoom,r=(s[1][0]-s[0][0])*this.zoom,h=(s[1][1]-s[0][1])*this.zoom,l=t.url||t.dest&&`#${encodeURI(t.dest)}`,d=C("span","",{position:"absolute",left:n+"pt",top:o+"pt"}),c=this.linkElement=C("a","",{width:r+"pt",height:h+"pt",display:"inline-block",pointerEvents:"auto"});c.setAttribute("href",l),d.append(c),this.container.append(d)}}const _=268435456,x=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/i.test(navigator.userAgent)?devicePixelRatio:3*devicePixelRatio,M=t=>atob(t.replace(/^(data:application\/pdf;base64,)/gi,"")),k=(t,e,i)=>{0===i&&(t=>{for(;t.firstChild;)t.removeChild(t.firstChild)})(t),t.appendChild(e)},T=(t,e,i,s,a)=>{const n=window.open("","","innerWidth="+e+",innerHeight="+i+"location=no,titlebar=no,toolbar=no");if(n&&n.document){if(n){n.document.body.style.margin="0",n.document.body.appendChild(t),n.focus(),setTimeout((()=>{n.print(),s()}));const e=()=>{n.removeEventListener("afterprint",e),n.close()};n.addEventListener("afterprint",e)}}else a()},A=(t,e,i,s)=>{const{canvasContext:a,viewport:n,pageElement:o,styles:r}=O(t,e,"k-page");return{canvasContext:a,viewport:n,pageElement:o,styles:r,zoom:e,pdfDoc:i,rootElement:s}},S=(t,e,i)=>{const{canvasContext:s,viewport:a,scaleNum:n,canvas:o,pageElement:r}=O(t);return t.render({canvasContext:s,viewport:a}).promise.then((()=>{const t=new Image(Math.floor(a.width/n),Math.floor(a.height/n));t.src=o.toDataURL();const i=()=>{t.removeEventListener("load",i),e(r)};t.addEventListener("load",i)})).catch(i),a},C=function(t,e,i){const s=document.createElement(t);return e&&(s.className=e),Object.keys(i).forEach((t=>s.style[t]=i[t])),s},N={0:"",90:"rotate(90deg) translateY(-100%)",180:"rotate(180deg) translate(-100%, -100%)",270:"rotate(270deg) translateX(-100%)"},D=(t,e,i)=>{const{canvasContext:s,viewport:n,pageElement:o,styles:r,zoom:h,pdfDoc:l,rootElement:d}=e;return t._pageInfo.renderInProgress=!0,t.render({canvasContext:s,viewport:n}).promise.then((()=>{t.getTextContent().then((t=>{const e=C("div","k-text-layer",r);new a.TextLayer({textContentSource:t,container:e,viewport:n}).render().then((()=>{e.style.width=e.style.width.replace(/px/g,"pt"),e.style.height=e.style.height.replace(/px/g,"pt");const t=e.getAttribute("data-main-rotation")||"0";N[t]&&(e.style.transform=N[t],e.style.transformOrigin="top left"),e.querySelectorAll("span").forEach((t=>{t.style.fontSize&&(t.style.fontSize=t.style.fontSize.replace(/px/g,"pt"))})),o.prepend(e)})).catch(i)})),t.getAnnotations({intent:"display"}).then((t=>{const e=C("div","k-annotations-layer",{position:"absolute",top:"0",left:"0",overflow:"hidden",height:r.height,width:r.width,pointerEvents:"none"});o.appendChild(e);for(const i of t)if("Link"===i.subtype)new y(e,n,i,l,h,d)}))})).then((()=>{t._pageInfo.rendered=!0,t._pageInfo.renderInProgress=!1})).catch(i),o},I=(t,e)=>{if(!t)return;const i=t.closest(".k-text-char"),s=i?i.closest('span[role="presentation"]'):null;if(!s)return;const a=s.closest(".k-page");if(!a)return;const n=a.offsetLeft+-1*e.scroller.element.offsetLeft+s.offsetLeft+0,o=a.offsetTop+-1*e.scroller.element.offsetTop+s.offsetTop+-64;e.scroller.scrollTo(n,o,{trackScrollEvent:!1})},L=(t,e)=>{const i=t.querySelectorAll(".k-page"),s=i[0];if(s instanceof HTMLDivElement){const t=(s.offsetHeight+s.offsetTop)*Math.max(0,Math.min(e,i.length-1)),a=s.closest(".k-pdf-viewer-canvas");a&&a.scrollTo({top:t,behavior:"auto"})}},P=t=>{const e=t.querySelector(".k-pdf-viewer-canvas"),i=t.querySelector(".k-page");return e&&i?Math.floor(Math.round(e.scrollTop)/(i.offsetHeight+i.offsetTop)+.01):0},W=(t,e)=>{const{maxWidth:i,maxHeight:a,maxArea:n}=(t=>{const e=s.d(t),i=s.a(t);return e&&e.mozilla||i&&"firefox"===i.browser})(navigator.userAgent)?{maxWidth:32767,maxHeight:32767,maxArea:124992400}:(o=navigator.userAgent,s.d(o).safari||s.a(o)&&"mobilesafari"===s.a(o).browser?{maxWidth:4194303,maxHeight:8388607,maxArea:_}:{maxWidth:65535,maxHeight:65535,maxArea:_});var o;let r=t,h=e;const l=t/e;if(t>i){r=i;h=e-(t-i)/l}if(h>a){const t=h-a;h=a,r-=t*l}const d=r*h;if(d>n){const t=Math.sqrt(n/d);r*=t,h*=t}const c=r/t;return{adjustedWidth:r!==t?Math.floor(r/2):t,adjustedHeight:h!==e?Math.floor(h/2):e,adjustRatio:1!==c?c/2:1}},O=(t,e=1,i="")=>{const s=x(),a=t.getViewport({scale:s}),{adjustedWidth:n,adjustedHeight:o,adjustRatio:r}=W(a.width,a.height),h={width:Math.floor(a.width/s)*e+"pt",height:Math.floor(a.height/s)*e+"pt"},l=C("div",i,h),d=C("canvas","",{width:"100%",height:"100%"});d.height=o,d.width=n;const c=d.getContext("2d");l.appendChild(d);const f=r*s;return a.width=n,a.height=o,a.scale=f,{canvasContext:c,viewport:a,scaleNum:s,canvas:d,pageElement:l,styles:h}},H=(t,e)=>{e.classList.add(t)},R=1.35,F="pdfjs_internal_editor_",$=3,B=9,z=1,G=2,V=3,j=4,U=5;function X(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const K=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class q{static makeHexColor(t,e,i){return`${K[t]}${K[e]}${K[i]}`}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}}const Y="pdfjs_internal_id_";var Z,J,Q,tt,et,it,st,at,nt,ot,rt,ht,lt,dt,ct,ft,ut,pt,gt,mt,vt,Et,wt,bt,yt,_t,xt,Mt,kt,Tt,At,St,Ct,Nt,Dt,It,Lt,Pt,Wt,Ot,Ht,Rt,Ft,$t,Bt,zt,Gt,Vt,jt,Ut,Xt,Kt,qt,Yt,Zt,Jt,Qt,te;class ee{constructor(t=F){Z.set(this,0),this.idPrefix=F,Object.defineProperty(this,"reset",{value:()=>n._(this,Z,0,"f")}),this.idPrefix=t}get id(){var t,e;return`${this.idPrefix}${n._(this,Z,(e=n.a(this,Z,"f"),t=e++,e),"f"),t}`}}Z=new WeakMap;class ie{constructor(t=128){J.set(this,[]),Q.set(this,!1),tt.set(this,void 0),et.set(this,-1),n._(this,tt,t,"f")}add({cmd:t,undo:e,post:i,mustExec:s,type:a=NaN,overwriteIfSameType:o=!1,keepUndo:r=!1}){if(s&&t(),n.a(this,Q,"f"))return;const h={cmd:t,undo:e,post:i,type:a};if(-1===n.a(this,et,"f"))return n.a(this,J,"f").length>0&&(n.a(this,J,"f").length=0),n._(this,et,0,"f"),void n.a(this,J,"f").push(h);if(o&&n.a(this,J,"f")[n.a(this,et,"f")].type===a)return r&&(h.undo=n.a(this,J,"f")[n.a(this,et,"f")].undo),void(n.a(this,J,"f")[n.a(this,et,"f")]=h);const l=n.a(this,et,"f")+1;l===n.a(this,tt,"f")?n.a(this,J,"f").splice(0,1):(n._(this,et,l,"f"),l<n.a(this,J,"f").length&&n.a(this,J,"f").splice(l)),n.a(this,J,"f").push(h)}undo(){if(-1===n.a(this,et,"f"))return;n._(this,Q,!0,"f");const{undo:t,post:e}=n.a(this,J,"f")[n.a(this,et,"f")];t(),null==e||e(),n._(this,Q,!1,"f"),n._(this,et,n.a(this,et,"f")-1,"f")}redo(){if(n.a(this,et,"f")<n.a(this,J,"f").length-1){n._(this,et,n.a(this,et,"f")+1,"f"),n._(this,Q,!0,"f");const{cmd:t,post:e}=n.a(this,J,"f")[n.a(this,et,"f")];t(),null==e||e(),n._(this,Q,!1,"f")}}hasSomethingToUndo(){return-1!==n.a(this,et,"f")}hasSomethingToRedo(){return n.a(this,et,"f")<n.a(this,J,"f").length-1}destroy(){n._(this,J,null,"f")}}J=new WeakMap,Q=new WeakMap,tt=new WeakMap,et=new WeakMap;class se{constructor({container:t=null,viewer:e,pdfViewer:i,eventBus:s,pdfDocument:o,highlightColors:r=""}){it.add(this),this.pdfViewer=null,this.annotationEditorMode=a.AnnotationEditorType.NONE,this.viewParameters={},this.isShiftKeyDown=!1,this._eventBus=null,st.set(this,new AbortController),at.set(this,null),nt.set(this,new Map),ot.set(this,new Map),rt.set(this,null),ht.set(this,null),lt.set(this,new ie),dt.set(this,0),ct.set(this,new Set),ft.set(this,null),ut.set(this,null),pt.set(this,new Set),gt.set(this,!0),mt.set(this,null),vt.set(this,null),Et.set(this,""),wt.set(this,!1),bt.set(this,null),yt.set(this,new ee),_t.set(this,!1),xt.set(this,!1),Mt.set(this,null),kt.set(this,a.AnnotationEditorType.NONE),Tt.set(this,new Set),At.set(this,null),St.set(this,null),Ct.set(this,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),Nt.set(this,[0,0]),Dt.set(this,null),It.set(this,null),Lt.set(this,null);const h=this._signal=n.a(this,st,"f").signal;n._(this,It,t,"f"),n._(this,Lt,e,"f"),this.pdfViewer=i,this._eventBus=s,this._eventBus._on("editingaction",this.onEditingAction.bind(this),{signal:h}),this._eventBus._on("pagechanging",this.onPageChanging.bind(this),{signal:h}),this._eventBus._on("scalechanging",this.onScaleChanging.bind(this),{signal:h}),this._eventBus._on("rotationchanging",this.onRotationChanging.bind(this),{signal:h}),this._eventBus._on("setpreference",this.onSetPreference.bind(this),{signal:h}),n.a(this,it,"m",Ft).call(this),n.a(this,it,"m",Ut).call(this),n.a(this,it,"m",zt).call(this),n._(this,rt,o.annotationStorage,"f"),n._(this,Et,r||"","f"),this.viewParameters={realScale:a.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}destroy(){var t;null===(t=n.a(this,st,"f"))||void 0===t||t.abort(),n._(this,st,null,"f"),this._signal=null;for(const t of n.a(this,ot,"f").values())t.destroy();n.a(this,ot,"f").clear(),n.a(this,nt,"f").clear(),n.a(this,pt,"f").clear(),n._(this,at,null,"f"),n.a(this,Tt,"f").clear(),n.a(this,lt,"f").destroy(),n.a(this,mt,"f")&&(clearTimeout(n.a(this,mt,"f")),n._(this,mt,null,"f")),n.a(this,Dt,"f")&&(clearTimeout(n.a(this,Dt,"f")),n._(this,Dt,null,"f"))}getTextLayerForAnchor(t){return t?t.closest(".textLayer")||t.closest(".k-text-layer"):null}combinedSignal(t){return AbortSignal&&AbortSignal.any?AbortSignal.any([this._signal,t.signal]):this._signal||t.signal}get direction(){return a.shadow(this,"direction",getComputedStyle(n.a(this,It,"f")).direction)}get highlightColors(){return a.shadow(this,"highlightColors",n.a(this,Et,"f")?new Map:null)}get highlightColorNames(){return a.shadow(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,mode:t}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t}){t}onPageChanging({pageNumber:t}){n._(this,dt,t-1,"f")}focusMainContainer(){var t;null===(t=n.a(this,It,"f"))||void 0===t||t.focus()}findParent(t,e){for(const i of n.a(this,ot,"f").values()){const{x:s,y:a,width:n,height:o}=i.div.getBoundingClientRect();if(t>=s&&t<=s+n&&e>=a&&e<=a+o)return i}return null}disableUserSelect(t=!1){var e;null===(e=n.a(this,Lt,"f"))||void 0===e||e.classList.toggle("noUserSelect",t)}addShouldRescale(t){n.a(this,pt,"f").add(t)}removeShouldRescale(t){n.a(this,pt,"f").delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*a.PixelsPerInch.PDF_TO_CSS_UNITS;for(const t of n.a(this,pt,"f"))t.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:r}=e,h=e.toString(),l=n.a(this,it,"m",Pt).call(this,e),d=this.getTextLayerForAnchor(l),c=this.getSelectionBoxes(d);if(!c)return;e.empty();const f=n.a(this,it,"m",Wt).call(this,d),u=n.a(this,kt,"f")===a.AnnotationEditorType.NONE,p=()=>{null==f||f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:i,anchorOffset:s,focusNode:o,focusOffset:r,text:h}),u&&this.showAllEditors("highlight",!0)};u?this.switchToMode(a.AnnotationEditorType.HIGHLIGHT,p):p()}showEditorToolBar(t){if(!t)return;const e=this.getMode();if(e===a.AnnotationEditorType.HIGHLIGHT){if(!t.closest(".highlightEditor"))return}if(e===a.AnnotationEditorType.FREETEXT){if(!t.closest(".freeTextEditor"))return}e!==a.AnnotationEditorType.HIGHLIGHT&&e!==a.AnnotationEditorType.FREETEXT||this._eventBus.dispatch("kendoAnnotationEditorToolBarShow",{source:this,anchor:t})}hideEditorToolBar(){this._eventBus.dispatch("kendoAnnotationEditorToolBarHide",{source:this})}addToAnnotationStorage(t){t.isEmpty()||!n.a(this,rt,"f")||n.a(this,rt,"f").has(t.id)||n.a(this,rt,"f").setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,n.a(this,wt,"f")&&(n._(this,wt,!1,"f"),n.a(this,it,"m",Rt).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n.a(this,Tt,"f"))if(e.div.contains(t)){n._(this,Mt,[e,t],"f"),e._focusEventsAllowed=!1;break}}focus(){if(!n.a(this,Mt,"f"))return;const[t,e]=n.a(this,Mt,"f");n._(this,Mt,null,"f"),e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}addEditListeners(){n.a(this,it,"m",zt).call(this),n.a(this,it,"m",Vt).call(this)}removeEditListeners(){n.a(this,it,"m",Gt).call(this),n.a(this,it,"m",jt).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of n.a(this,ut,"f"))if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of n.a(this,ut,"f"))if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null===(e=n.a(this,at,"f"))||void 0===e||e.commitOrRemove(),!this.hasSelection)return;const i=[];for(const t of n.a(this,Tt,"f")){const e=t.serialize(!0);e&&i.push(e)}0!==i.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(t){this.copy(t),this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of n.a(this,ut,"f"))if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)n.a(this,it,"m",Zt).call(this,e);n.a(this,it,"m",te).call(this,t)},a=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:a,mustExec:!0})}catch(t){}}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(n.a(this,it,"m",$t).call(this),n.a(this,it,"m",Vt).call(this),n.a(this,it,"m",Xt).call(this,{isEditing:n.a(this,kt,"f")!==a.AnnotationEditorType.NONE,isEmpty:n.a(this,it,"m",Qt).call(this),hasSomethingToUndo:n.a(this,lt,"f").hasSomethingToUndo(),hasSomethingToRedo:n.a(this,lt,"f").hasSomethingToRedo(),hasSelectedEditor:!1})):(n.a(this,it,"m",Bt).call(this),n.a(this,it,"m",jt).call(this),n.a(this,it,"m",Xt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n.a(this,ut,"f")){n._(this,ut,t,"f");for(const t of n.a(this,ut,"f"))n.a(this,it,"m",Kt).call(this,t.defaultPropertiesToUpdate)}}getId(){return n.a(this,yt,"f").id}get currentLayer(){return n.a(this,ot,"f").get(n.a(this,dt,"f"))}getLayer(t){return n.a(this,ot,"f").get(t)}get currentPageIndex(){return n.a(this,dt,"f")}addLayer(t){n.a(this,ot,"f").set(t.pageIndex,t),n.a(this,_t,"f")?t.enable():t.disable()}removeLayer(t){n.a(this,ot,"f").delete(t.pageIndex)}updateMode(t,e=null,i=!1){if(n.a(this,kt,"f")!==t){if(n._(this,kt,t,"f"),t===a.AnnotationEditorType.NONE)return this.setEditingState(!1),void n.a(this,it,"m",Yt).call(this);this.setEditingState(!0),n.a(this,it,"m",qt).call(this),this.unselectAll();for(const e of n.a(this,ot,"f").values())e.updateMode(t);if(e||!i){if(e)for(const t of n.a(this,nt,"f").values())if(t.annotationElementId===e){this.setSelected(t),t.enterInEditMode();break}}else this.addNewEditorFromKeyboard()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==n.a(this,kt,"f")&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(n.a(this,ut,"f")){switch(t){case a.AnnotationEditorParamsType.CREATE:return void this.currentLayer.addNewEditor();case a.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:break;case a.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:n._(this,St,n.a(this,St,"f")||new Map,"f").set(t,e),this.showAllEditors("highlight",e)}for(const i of n.a(this,Tt,"f"))i.updateParams(t,e);for(const i of n.a(this,ut,"f"))i.updateDefaultParams(t,e)}}showAllEditors(t,e){var i,s;for(const i of n.a(this,nt,"f").values())i.editorType===t&&i.show(e);(null===(s=null===(i=n.a(this,St,"f"))||void 0===i?void 0:i.get(a.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL))||void 0===s||s)!==e&&n.a(this,it,"m",Kt).call(this,[[a.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n.a(this,xt,"f")!==t){n._(this,xt,t,"f");for(const e of n.a(this,ot,"f").values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const i of n.a(this,nt,"f").values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return n.a(this,nt,"f").get(t)}addEditor(t){n.a(this,nt,"f").set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(n.a(this,mt,"f")&&clearTimeout(n.a(this,mt,"f")),n._(this,mt,setTimeout((()=>{this.focusMainContainer(),n._(this,mt,null,"f")}),0),"f")),n.a(this,nt,"f").delete(t.id),this.unselect(t),t.annotationElementId&&n.a(this,ct,"f").has(t.annotationElementId)||null===(e=n.a(this,rt,"f"))||void 0===e||e.remove(t.id)}addDeletedAnnotationElement(t){n.a(this,ct,"f").add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n.a(this,ct,"f").has(t)}removeDeletedAnnotationElement(t){n.a(this,ct,"f").delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n.a(this,at,"f")!==t&&(n._(this,at,t,"f"),t&&n.a(this,it,"m",Kt).call(this,t.propertiesToUpdate))}updateUI(t){n.a(this,it,"a",Jt)===t&&n.a(this,it,"m",Kt).call(this,t.propertiesToUpdate)}toggleSelected(t){if(n.a(this,Tt,"f").has(t))return n.a(this,Tt,"f").delete(t),t.unselect(),void n.a(this,it,"m",Xt).call(this,{hasSelectedEditor:this.hasSelection});n.a(this,Tt,"f").add(t),t.select(),n.a(this,it,"m",Kt).call(this,t.propertiesToUpdate),n.a(this,it,"m",Xt).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of n.a(this,Tt,"f"))e!==t&&e.unselect();n.a(this,Tt,"f").clear(),n.a(this,Tt,"f").add(t),t.select(),n.a(this,it,"m",Kt).call(this,t.propertiesToUpdate),n.a(this,it,"m",Xt).call(this,{hasSelectedEditor:!0})}isSelected(t){return n.a(this,Tt,"f").has(t)}get firstSelectedEditor(){return n.a(this,Tt,"f").values().next().value}unselect(t){t.unselect(),n.a(this,Tt,"f").delete(t),n.a(this,it,"m",Xt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==n.a(this,Tt,"f").size}get isEnterHandled(){return 1===n.a(this,Tt,"f").size&&this.firstSelectedEditor.isEnterHandled}undo(){n.a(this,lt,"f").undo(),n.a(this,it,"m",Xt).call(this,{hasSomethingToUndo:n.a(this,lt,"f").hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:n.a(this,it,"m",Qt).call(this)})}redo(){n.a(this,lt,"f").redo(),n.a(this,it,"m",Xt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n.a(this,lt,"f").hasSomethingToRedo(),isEmpty:n.a(this,it,"m",Qt).call(this)})}addCommands(t){n.a(this,lt,"f").add(t),n.a(this,it,"m",Xt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:n.a(this,it,"m",Qt).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...n.a(this,Tt,"f")];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)n.a(this,it,"m",Zt).call(this,e)},mustExec:!0})}commitOrRemove(){var t;null===(t=n.a(this,at,"f"))||void 0===t||t.commitOrRemove()}hasSomethingToControl(){return n.a(this,at,"f")||this.hasSelection}selectAll(){for(const t of n.a(this,Tt,"f"))t.commit();n.a(this,it,"m",te).call(this,n.a(this,nt,"f").values())}unselectAll(){if((!n.a(this,at,"f")||(n.a(this,at,"f").commitOrRemove(),n.a(this,kt,"f")===a.AnnotationEditorType.NONE))&&this.hasSelection){for(const t of n.a(this,Tt,"f"))t.unselect();n.a(this,Tt,"f").clear(),n.a(this,it,"m",Xt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;n.a(this,Nt,"f")[0]+=t,n.a(this,Nt,"f")[1]+=e;const[s,a]=n.a(this,Nt,"f"),o=[...n.a(this,Tt,"f")];n.a(this,Dt,"f")&&clearTimeout(n.a(this,Dt,"f")),n._(this,Dt,setTimeout((()=>{n._(this,Dt,null,"f"),n.a(this,Nt,"f")[0]=n.a(this,Nt,"f")[1]=0,this.addCommands({cmd:()=>{for(const t of o)n.a(this,nt,"f").has(t.id)&&t.translateInPage(s,a)},undo:()=>{for(const t of o)n.a(this,nt,"f").has(t.id)&&t.translateInPage(-s,-a)},mustExec:!1})}),1e3),"f");for(const i of o)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),n._(this,ft,new Map,"f");for(const t of n.a(this,Tt,"f"))n.a(this,ft,"f").set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n.a(this,ft,"f"))return!1;this.disableUserSelect(!1);const t=n.a(this,ft,"f");n._(this,ft,null,"f");let e=!1;for(const[{x:i,y:s,pageIndex:a},n]of t)n.newX=i,n.newY=s,n.newPageIndex=a,e||(e=i!==n.savedX||s!==n.savedY||a!==n.savedPageIndex);if(!e)return!1;const i=(t,e,i,s)=>{if(n.a(this,nt,"f").has(t.id)){const a=n.a(this,ot,"f").get(s);a?t._setParentAndPosition(a,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:a,newPageIndex:n}]of t)i(e,s,a,n)},undo:()=>{for(const[e,{savedX:s,savedY:a,savedPageIndex:n}]of t)i(e,s,a,n)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n.a(this,ft,"f"))for(const i of n.a(this,ft,"f").keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}isActive(t){return n.a(this,at,"f")===t}getActive(){return n.a(this,at,"f")}getActiveEditor(){return n.a(this,at,"f")}getMode(){return n.a(this,kt,"f")}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:a,height:n}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(t,e,o,r)=>({x:(e-s)/n,y:1-(t+o-i)/a,width:r/n,height:o/a});break;case"180":o=(t,e,o,r)=>({x:1-(t+o-i)/a,y:1-(e+r-s)/n,width:o/a,height:r/n});break;case"270":o=(t,e,o,r)=>({x:1-(e+r-s)/n,y:(t-i)/a,width:r/n,height:o/a});break;default:o=(t,e,o,r)=>({x:(t-i)/a,y:(e-s)/n,width:o/a,height:r/n})}const r=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:a}of i.getClientRects())0!==s&&0!==a&&r.push(o(t,e,s,a))}return 0===r.length?null:r}addChangedExistingAnnotation({annotationElementId:t,id:e}){n._(this,ht,n.a(this,ht,"f")||new Map,"f").set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null===(e=n.a(this,ht,"f"))||void 0===e||e.delete(t)}renderAnnotationElement(t){var e;const i=null===(e=n.a(this,ht,"f"))||void 0===e?void 0:e.get(t.data.id);if(!i)return;const s=n.a(this,rt,"f").getRawValue(i);s&&(n.a(this,kt,"f")!==a.AnnotationEditorType.NONE||s.hasBeenModified)&&s.renderAnnotationElement(t)}}st=new WeakMap,at=new WeakMap,nt=new WeakMap,ot=new WeakMap,rt=new WeakMap,ht=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ft=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,vt=new WeakMap,Et=new WeakMap,wt=new WeakMap,bt=new WeakMap,yt=new WeakMap,_t=new WeakMap,xt=new WeakMap,Mt=new WeakMap,kt=new WeakMap,Tt=new WeakMap,At=new WeakMap,St=new WeakMap,Ct=new WeakMap,Nt=new WeakMap,Dt=new WeakMap,It=new WeakMap,Lt=new WeakMap,it=new WeakSet,Pt=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Wt=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of n.a(this,ot,"f").values())if(e.hasTextLayer(t))return e;return null},Ot=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=n.a(this,it,"m",Pt).call(this,t),i=this.getTextLayerForAnchor(e);this.getSelectionBoxes(i)&&this.showEditorToolBar(e)},Ht=function(){var t,e;const i=document.getSelection();if(!i||i.isCollapsed)return void(n.a(this,At,"f")&&(n._(this,At,null,"f"),n.a(this,it,"m",Xt).call(this,{hasSelectedText:!1})));const{anchorNode:s}=i;if(s===n.a(this,At,"f"))return;const o=n.a(this,it,"m",Pt).call(this,i),r=this.getTextLayerForAnchor(o);if(r){if(null===(e=n.a(this,bt,"f"))||void 0===e||e.hide(),n._(this,At,s,"f"),n.a(this,it,"m",Xt).call(this,{hasSelectedText:!0}),(n.a(this,kt,"f")===a.AnnotationEditorType.HIGHLIGHT||n.a(this,kt,"f")===a.AnnotationEditorType.NONE)&&(n.a(this,kt,"f")===a.AnnotationEditorType.HIGHLIGHT&&this.showAllEditors("highlight",!0),!this.isShiftKeyDown)){const t=n.a(this,kt,"f")===a.AnnotationEditorType.HIGHLIGHT?n.a(this,it,"m",Wt).call(this,r):null;null==t||t.toggleDrawing();const e=new AbortController,i=this.combinedSignal(e),s=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),null==t||t.toggleDrawing(!0),"pointerup"===i.type&&n.a(this,it,"m",Rt).call(this,"main_toolbar"))};window.removeEventListener("pointerup",s),window.addEventListener("pointerup",s,{signal:i}),window.removeEventListener("blur",s),window.addEventListener("blur",s,{signal:i})}}else n.a(this,At,"f")&&(null===(t=n.a(this,bt,"f"))||void 0===t||t.hide(),n._(this,At,null,"f"),n.a(this,it,"m",Xt).call(this,{hasSelectedText:!1}))},Rt=function(t=""){n.a(this,kt,"f")===a.AnnotationEditorType.HIGHLIGHT?this.highlightSelection(t):n.a(this,gt,"f")&&n.a(this,it,"m",Ot).call(this)},Ft=function(){document.addEventListener("selectionchange",n.a(this,it,"m",Ht).bind(this),{signal:this._signal})},$t=function(){if(n.a(this,vt,"f"))return;n._(this,vt,new AbortController,"f");const t=this.combinedSignal(n.a(this,vt,"f"));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Bt=function(){var t;null===(t=n.a(this,vt,"f"))||void 0===t||t.abort(),n._(this,vt,null,"f")},zt=function(){},Gt=function(){},Vt=function(){},jt=function(){},Ut=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Xt=function(t){if(!t)return;Object.entries(t).some((([t,e])=>n.a(this,Ct,"f")[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(n.a(this,Ct,"f"),t)}),n.a(this,kt,"f")===a.AnnotationEditorType.HIGHLIGHT&&!1===t.hasSelectedEditor&&n.a(this,it,"m",Kt).call(this,[[a.AnnotationEditorParamsType.HIGHLIGHT_FREE,!0]]))},Kt=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},qt=function(){if(!n.a(this,_t,"f")){n._(this,_t,!0,"f");for(const t of n.a(this,ot,"f").values())t.enable();for(const t of n.a(this,nt,"f").values())t.enable()}},Yt=function(){if(this.unselectAll(),n.a(this,_t,"f")){n._(this,_t,!1,"f");for(const t of n.a(this,ot,"f").values())t.disable();for(const t of n.a(this,nt,"f").values())t.disable()}},Zt=function(t){const e=n.a(this,ot,"f").get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Jt=function(){let t=null;for(t of n.a(this,Tt,"f"));return t},Qt=function(){if(0===n.a(this,nt,"f").size)return!0;if(1===n.a(this,nt,"f").size)for(const t of n.a(this,nt,"f").values())return t.isEmpty();return!1},te=function(t){for(const t of n.a(this,Tt,"f"))t.unselect();n.a(this,Tt,"f").clear();for(const e of t)e.isEmpty()||(n.a(this,Tt,"f").add(e),e.select());n.a(this,it,"m",Xt).call(this,{hasSelectedEditor:this.hasSelection})},se.TRANSLATE_SMALL=1,se.TRANSLATE_BIG=10;new WeakMap;const ae=1,ne=3,oe=1;function re(t,e,i=0){let s=i,a=t.length-1;if(a<0||!e(t[a]))return t.length;if(e(t[s]))return s;for(;s<a;){const i=s+a>>1;e(t[i])?a=i:s=i+1}return s}var he,le,de,ce,fe,ue,pe,ge,me,ve,Ee,we,be,ye,_e,xe,Me,ke,Te,Ae,Se,Ce,Ne,De,Ie,Le,Pe,We,Oe,He,Re,Fe,$e,Be,ze,Ge,Ve,je,Ue,Xe,Ke,qe,Ye,Ze,Je,Qe,ti,ei,ii,si,ai,ni,oi,ri,hi;class li{constructor(){he.add(this),de.set(this,!1),ce.set(this,null),fe.set(this,new Map),ue.set(this,new Map)}setTextMapping(t){n._(this,ce,t,"f")}enable(){if(n.a(this,de,"f"),!n.a(this,ce,"f"))throw new Error("Text divs and strings have not been set.");if(n._(this,de,!0,"f"),n._(this,ce,n.a(this,ce,"f").slice(),"f"),n.a(this,ce,"f").sort(n.a(le,le,"m",pe)),n.a(this,fe,"f").size>0){const t=n.a(this,ce,"f");for(const[e,i]of n.a(this,fe,"f")){document.getElementById(e)?n.a(this,he,"m",ge).call(this,e,t[i]):n.a(this,fe,"f").delete(e)}}for(const[t,e]of n.a(this,ue,"f"))this.addPointerInTextLayer(t,e);n.a(this,ue,"f").clear()}disable(){n.a(this,de,"f")&&(n.a(this,ue,"f").clear(),n._(this,ce,null,"f"),n._(this,de,!1,"f"))}removePointerInTextLayer(t){if(!n.a(this,de,"f"))return void n.a(this,ue,"f").delete(t);const e=n.a(this,ce,"f");if(!e||0===e.length)return;const{id:i}=t,s=n.a(this,fe,"f").get(i);if(void 0===s)return;const a=e[s];n.a(this,fe,"f").delete(i);let o=a.getAttribute("aria-owns");(null==o?void 0:o.includes(i))&&(o=o.split(" ").filter((t=>t!==i)).join(" "),o?a.setAttribute("aria-owns",o):(a.removeAttribute("aria-owns"),a.setAttribute("role","presentation")))}addPointerInTextLayer(t,e){if(!t)return void console.warn("no element");const{id:i}=t;if(!i)return null;if(!n.a(this,de,"f"))return n.a(this,ue,"f").set(t,e),null;e&&this.removePointerInTextLayer(t);const s=n.a(this,ce,"f");if(!s||0===s.length)return null;const a=re(s,(e=>n.a(le,le,"m",pe).call(le,t,e)<0)),o=Math.max(0,a-1),r=s[o];n.a(this,he,"m",ge).call(this,i,r),n.a(this,fe,"f").set(i,o);const h=r.parentNode;return(null==h?void 0:h.classList.contains("markedContent"))||(null==h?void 0:h.classList.contains("k-marked-content"))?h.id:null}moveElementInDOM(t,e,i,s){const a=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),a;const o=Array.from(t.children).filter((t=>t!==e));if(0===o.length)return a;const r=i||e,h=re(o,(t=>n.a(le,le,"m",pe).call(le,r,t)<0));return 0===h?o[0].before(e):o[h-1].after(e),a}}le=li,de=new WeakMap,ce=new WeakMap,fe=new WeakMap,ue=new WeakMap,he=new WeakSet,pe=function(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return-1;const a=i.y,n=i.y+i.height,o=i.y+i.height/2,r=s.y,h=s.y+s.height,l=s.y+s.height/2;if(o<=r&&l>=n)return-1;if(l<=a&&o>=h)return 1;return i.x+i.width/2-(s.x+s.width/2)},ge=function(t,e){const i=e.getAttribute("aria-owns");(null==i?void 0:i.includes(t))||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")};class di{constructor({pdfPage:t,accessibilityManager:e,styles:i,onAppend:s=null}){me.add(this),this.pdfPage=null,this.div=null,this.accessibilityManager=null,Ee.set(this,null),we.set(this,null),this.pdfPage=t,this.accessibilityManager=e,n._(this,Ee,s,"f"),this.div=document.createElement("div"),this.div.tabIndex=0,this.div.classList.add("k-text-layer"),Object.keys(i).forEach((t=>this.div.style[t]=i[t]))}render(t){return n.b(this,arguments,void 0,(function*(t,e=null){var i,s,o;if(n.a(this,we,"f"))return n.a(this,we,"f").update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),n._(this,we,new a.TextLayer({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!1,disableNormalization:!0}),container:this.div,viewport:t}),"f");const{textDivs:r}=n.a(this,we,"f");null===(i=this.accessibilityManager)||void 0===i||i.setTextMapping(r),yield n.a(this,we,"f").render();const h=Array.from(this.div.querySelectorAll(".markedContent")||[])||[];if(h.forEach((t=>H("k-marked-content",t))),h&&h.length>0){const t=document.createElement("div");t.className="endOfContent",this.div.append(t),n.a(this,me,"m",_e).call(this,t)}null===(s=n.a(this,Ee,"f"))||void 0===s||s.call(this,this.div),null===(o=this.accessibilityManager)||void 0===o||o.enable()}))}hide(){this.div.hidden||(this.div.hidden=!0)}show(){this.div.hidden&&(this.div.hidden=!1)}cancel(){var t,e;null===(t=n.a(this,we,"f"))||void 0===t||t.cancel(),n._(this,we,null,"f"),null===(e=this.accessibilityManager)||void 0===e||e.disable(),n.a(ve,ve,"m",xe).call(ve,this.div)}}function ci(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function fi(t){return Math.max(0,Math.min(255,255*t))}ve=di,Ee=new WeakMap,we=new WeakMap,me=new WeakSet,_e=function(t){const{div:e}=this;n.a(ve,ve,"f",be).set(e,t),n.a(ve,ve,"m",Me).call(ve)},xe=function(t){var e;n.a(this,ve,"f",be).delete(t),0===n.a(this,ve,"f",be).size&&(null===(e=n.a(this,ve,"f",ye))||void 0===e||e.abort(),n._(this,ve,null,"f",ye))},Me=function(){},be={value:new Map},ye={value:null};class ui{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=fi(t),t,t]}static G_HTML([t]){const e=ci(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(fi)}static RGB_HTML(t){return`#${t.map(ci).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[fi(1-Math.min(1,t+s)),fi(1-Math.min(1,i+s)),fi(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,a=1-e,n=1-i;return["CMYK",s,a,n,Math.min(s,a,n)]}}const pi=new WeakSet;function gi(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class mi{constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){ke.add(this),this.isRenderable=null,this.data=null,this.layer=null,this.linkService=null,this.downloadManager=null,this.imageResourcesPath=null,this.renderForms=null,this.svgFactory=null,this.annotationStorage=null,this.enableScripting=null,this.hasJSActions=null,this._fieldObjects=null,this.parent=null,this.container=null,this.popup=null,this.annotationEditorType=null,Te.set(this,null),Ae.set(this,!1),Se.set(this,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!((null==t?void 0:t.str)||(null==e?void 0:e.str)||(null==i?void 0:i.str))}get _isEditable(){return this.data.isEditable}get hasPopupData(){return mi._hasPopupData(this.data)}updateEdited(t){var e;if(!this.container)return;n._(this,Te,n.a(this,Te,"f")||{rect:this.data.rect.slice(0)},"f");const{rect:i}=t;i&&n.a(this,ke,"m",Ce).call(this,i),null===(e=n.a(this,Se,"f"))||void 0===e||e.popup.updateEdited(t)}resetEdited(){var t;n.a(this,Te,"f")&&(n.a(this,ke,"m",Ce).call(this,n.a(this,Te,"f").rect),null===(t=n.a(this,Se,"f"))||void 0===t||t.popup.resetEdited(),n._(this,Te,null,"f"))}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,o=document.createElement("section");o.setAttribute("data-annotation-id",e.id),this instanceof vi||(o.tabIndex=0);const{style:r}=o;if(r.zIndex=(this.parent.zIndex++).toString(),e.popupRef&&o.setAttribute("aria-haspopup","dialog"),e.alternativeText&&(o.title=e.alternativeText),e.noRotate,!e.rect||this instanceof wi){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,o),o}const{width:h,height:l}=gi(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.borderRadius=e}else if(this instanceof Ei){const t=`calc(${h}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case z:r.borderStyle="solid";break;case G:r.borderStyle="dashed";break;case V:case j:break;case U:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(n._(this,Ae,!0,"f"),r.borderColor=a.Util.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=(0).toString()}const d=a.Util.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:c,pageHeight:f,pageX:u,pageY:p}=s.rawDims;r.left=100*(d[0]-u)/c+"%",r.top=100*(d[1]-p)/f+"%";const{rotation:g}=e;return e.hasOwnCanvas||0===g?(r.width=100*h/c+"%",r.height=100*l/f+"%"):this.setRotation(g,o),o}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:a,height:n}=gi(this.data.rect);let o,r;t%180==0?(o=100*a/i,r=100*n/s):(o=100*n/i,r=100*a/s),e.style.width=`${o}%`,e.style.height=`${r}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],a=s[0],n=s.slice(1);i.target.style[e]=ui[`${a}_HTML`](n),this.annotationStorage.setValue(this.data.id,{[e]:ui[`${a}_rgb`](n)})};return a.shadow(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const a=t[s]||i[s];null==a||a(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,a]of Object.entries(e)){const n=i[s];if(n){n({detail:{[s]:a},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,a]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[n,o,r,h]=t.subarray(2,6);if(s===n&&a===o&&e===r&&i===h)return}const{style:o}=this.container;let r;if(n.a(this,Ae,"f"