3d-pro-flipbook 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,159 @@
1
+ (function(nt,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(nt=typeof globalThis<"u"?globalThis:nt||self,g(nt.ProFlipbook={}))})(this,function(exports){"use strict";var Ge=Object.defineProperty;var ze=(nt,g,U)=>g in nt?Ge(nt,g,{enumerable:!0,configurable:!0,writable:!0,value:U}):nt[g]=U;var Mt=(nt,g,U)=>(ze(nt,typeof g!="symbol"?g+"":g,U),U),re=(nt,g,U)=>{if(!g.has(nt))throw TypeError("Cannot "+U)};var C=(nt,g,U)=>(re(nt,g,"read from private field"),U?U.call(nt):g.get(nt)),at=(nt,g,U)=>{if(g.has(nt))throw TypeError("Cannot add the same private member more than once");g instanceof WeakSet?g.add(nt):g.set(nt,U)},mt=(nt,g,U,_)=>(re(nt,g,"write to private field"),_?_.call(nt,U):g.set(nt,U),U);var ae=(nt,g,U,_)=>({set _(v){mt(nt,g,v,U)},get _(){return C(nt,g,_)}}),ct=(nt,g,U)=>(re(nt,g,"access private method"),U);var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function getAugmentedNamespace(nt){if(nt.__esModule)return nt;var g=nt.default;if(typeof g=="function"){var U=function _(){return this instanceof _?Reflect.construct(g,arguments,this.constructor):g.apply(this,arguments)};U.prototype=g.prototype}else U={};return Object.defineProperty(U,"__esModule",{value:!0}),Object.keys(nt).forEach(function(_){var v=Object.getOwnPropertyDescriptor(nt,_);Object.defineProperty(U,_,v.get?v:{enumerable:!0,get:function(){return nt[_]}})}),U}var pageFlip_browser={exports:{}};(function(nt,g){(function(U,_){_(g)})(commonjsGlobal,function(U){class _{constructor(t,e){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=e,this.nowDrawingDensity=this.createdDensity,this.render=t}setDensity(t){this.createdDensity=t,this.nowDrawingDensity=t}setDrawingDensity(t){this.nowDrawingDensity=t}setPosition(t){this.state.position=t}setAngle(t){this.state.angle=t}setArea(t){this.state.area=t}setHardDrawingAngle(t){this.state.hardDrawingAngle=t}setHardAngle(t){this.state.hardAngle=t,this.state.hardDrawingAngle=t}setOrientation(t){this.orientation=t}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class v extends _{constructor(t,e,i){super(t,i),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=e}draw(t){const e=this.render.getContext(),i=this.render.convertToGlobal(this.state.position),a=this.render.getRect().pageWidth,u=this.render.getRect().height;e.save(),e.translate(i.x,i.y),e.beginPath();for(let d of this.state.area)d!==null&&(d=this.render.convertToGlobal(d),e.lineTo(d.x-i.x,d.y-i.y));e.rotate(this.state.angle),e.clip(),this.isLoad?e.drawImage(this.image,0,0,a,u):this.drawLoader(e,{x:0,y:0},a,u),e.restore()}simpleDraw(t){const e=this.render.getRect(),i=this.render.getContext(),a=e.pageWidth,u=e.height,d=t===1?e.left+e.pageWidth:e.left,c=e.top;this.isLoad?i.drawImage(this.image,d,c,a,u):this.drawLoader(i,{x:d,y:c},a,u)}drawLoader(t,e,i,a){t.beginPath(),t.strokeStyle="rgb(200, 200, 200)",t.fillStyle="rgb(255, 255, 255)",t.lineWidth=1,t.rect(e.x+1,e.y+1,i-1,a-1),t.stroke(),t.fill();const u={x:e.x+i/2,y:e.y+a/2};t.beginPath(),t.lineWidth=10,t.arc(u.x,u.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),t.stroke(),t.closePath(),this.loadingAngle+=.07,this.loadingAngle>=2*Math.PI&&(this.loadingAngle=0)}load(){this.isLoad||(this.image.onload=()=>{this.isLoad=!0})}newTemporaryCopy(){return this}getTemporaryCopy(){return this}hideTemporaryCopy(){}}class V{constructor(t,e){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=e,this.app=t,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let e=0;e<this.pages.length;e++)this.portraitSpread.push([e]);let t=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([t]),t++);for(let e=t;e<this.pages.length;e+=2)e<this.pages.length-1?this.landscapeSpread.push([e,e+1]):(this.landscapeSpread.push([e]),this.pages[e].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(t){const e=this.getSpread();for(let i=0;i<e.length;i++)if(t===e[i][0]||t===e[i][1])return i;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(t){if(t>=0&&t<this.pages.length)return this.pages[t];throw new Error("Invalid page number")}nextBy(t){const e=this.pages.indexOf(t);return e<this.pages.length-1?this.pages[e+1]:null}prevBy(t){const e=this.pages.indexOf(t);return e>0?this.pages[e-1]:null}getFlippingPage(t){const e=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return t===0?this.pages[e].newTemporaryCopy():this.pages[e-1];{const i=t===0?this.getSpread()[e+1]:this.getSpread()[e-1];return i.length===1||t===0?this.pages[i[0]]:this.pages[i[1]]}}getBottomPage(t){const e=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return t===0?this.pages[e+1]:this.pages[e-1];{const i=t===0?this.getSpread()[e+1]:this.getSpread()[e-1];return i.length===1?this.pages[i[0]]:t===0?this.pages[i[1]]:this.pages[i[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(t=null){if(t===null&&(t=this.currentPageIndex),t<0||t>=this.pages.length)return;const e=this.getSpreadIndexByPage(t);e!==null&&(this.currentSpreadIndex=e,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(t){if(!(t>=0&&t<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=t}showSpread(){const t=this.getSpread()[this.currentSpreadIndex];t.length===2?(this.render.setLeftPage(this.pages[t[0]]),this.render.setRightPage(this.pages[t[1]])):this.render.getOrientation()==="landscape"&&t[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[t[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[t[0]])),this.currentPageIndex=t[0],this.app.updatePageIndex(this.currentPageIndex)}}class H extends V{constructor(t,e,i){super(t,e),this.imagesHref=i}load(){for(const t of this.imagesHref){const e=new v(this.render,t,"soft");e.load(),this.pages.push(e)}this.createSpread()}}class Q{static GetDistanceBetweenTwoPoint(t,e){return t===null||e===null?1/0:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}static GetSegmentLength(t){return Q.GetDistanceBetweenTwoPoint(t[0],t[1])}static GetAngleBetweenTwoLine(t,e){const i=t[0].y-t[1].y,a=e[0].y-e[1].y,u=t[1].x-t[0].x,d=e[1].x-e[0].x;return Math.acos((i*a+u*d)/(Math.sqrt(i*i+u*u)*Math.sqrt(a*a+d*d)))}static PointInRect(t,e){return e===null?null:e.x>=t.left&&e.x<=t.width+t.left&&e.y>=t.top&&e.y<=t.top+t.height?e:null}static GetRotatedPoint(t,e,i){return{x:t.x*Math.cos(i)+t.y*Math.sin(i)+e.x,y:t.y*Math.cos(i)-t.x*Math.sin(i)+e.y}}static LimitPointToCircle(t,e,i){if(Q.GetDistanceBetweenTwoPoint(t,i)<=e)return i;const a=t.x,u=t.y,d=i.x,c=i.y;let S=Math.sqrt(Math.pow(e,2)*Math.pow(a-d,2)/(Math.pow(a-d,2)+Math.pow(u-c,2)))+a;i.x<0&&(S*=-1);let X=(S-a)*(u-c)/(a-d)+u;return a-d+u===0&&(X=e),{x:S,y:X}}static GetIntersectBetweenTwoSegment(t,e,i){return Q.PointInRect(t,Q.GetIntersectBeetwenTwoLine(e,i))}static GetIntersectBeetwenTwoLine(t,e){const i=t[0].y-t[1].y,a=e[0].y-e[1].y,u=t[1].x-t[0].x,d=e[1].x-e[0].x,c=t[0].x*t[1].y-t[1].x*t[0].y,S=e[0].x*e[1].y-e[1].x*e[0].y,X=i*S-a*c,tt=u*S-d*c,K=-(c*d-S*u)/(i*d-a*u),Y=-(i*S-a*c)/(i*d-a*u);if(isFinite(K)&&isFinite(Y))return{x:K,y:Y};if(Math.abs(X-tt)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(t,e){const i=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y),u=Math.max(i,a),d=[t];function c(S,X,tt,K,Y){return X>S?S+Y*(tt/K):X<S?S-Y*(tt/K):S}for(let S=1;S<=u;S+=1)d.push({x:c(t.x,e.x,i,u,S),y:c(t.y,e.y,a,u,S)});return d}}class N extends _{constructor(t,e,i){super(t,i),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=e,this.element.classList.add("stf__item"),this.element.classList.add("--"+i)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new N(this.render,this.copiedElement,this.nowDrawingDensity)),this.getTemporaryCopy())}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){this.temporaryCopy!==null&&(this.copiedElement.remove(),this.copiedElement=null,this.temporaryCopy=null)}draw(t){const e=t||this.nowDrawingDensity,i=this.render.convertToGlobal(this.state.position),a=this.render.getRect().pageWidth,u=this.render.getRect().height;this.element.classList.remove("--simple");const d=`
2
+ display: block;
3
+ z-index: ${this.element.style.zIndex};
4
+ left: 0;
5
+ top: 0;
6
+ width: ${a}px;
7
+ height: ${u}px;
8
+ `;e==="hard"?this.drawHard(d):this.drawSoft(i,d)}drawHard(t=""){const e=this.render.getRect().left+this.render.getRect().width/2,i=this.state.hardDrawingAngle,a=t+`
9
+ backface-visibility: hidden;
10
+ -webkit-backface-visibility: hidden;
11
+ clip-path: none;
12
+ -webkit-clip-path: none;
13
+ `+(this.orientation===0?`transform-origin: ${this.render.getRect().pageWidth}px 0;
14
+ transform: translate3d(0, 0, 0) rotateY(${i}deg);`:`transform-origin: 0 0;
15
+ transform: translate3d(${e}px, 0, 0) rotateY(${i}deg);`);this.element.style.cssText=a}drawSoft(t,e=""){let i="polygon( ";for(const u of this.state.area)if(u!==null){let d=this.render.getDirection()===1?{x:-u.x+this.state.position.x,y:u.y-this.state.position.y}:{x:u.x-this.state.position.x,y:u.y-this.state.position.y};d=Q.GetRotatedPoint(d,{x:0,y:0},this.state.angle),i+=d.x+"px "+d.y+"px, "}i=i.slice(0,-2),i+=")";const a=e+`transform-origin: 0 0; clip-path: ${i}; -webkit-clip-path: ${i};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${t.x}px, ${t.y}px);`:`transform: translate3d(${t.x}px, ${t.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=a}simpleDraw(t){const e=this.render.getRect(),i=e.pageWidth,a=e.height,u=t===1?e.left+e.pageWidth:e.left,d=e.top;this.element.classList.add("--simple"),this.element.style.cssText=`
16
+ position: absolute;
17
+ display: block;
18
+ height: ${a}px;
19
+ left: ${u}px;
20
+ top: ${d}px;
21
+ width: ${i}px;
22
+ z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(t){super.setOrientation(t),this.element.classList.remove("--left","--right"),this.element.classList.add(t===1?"--right":"--left")}setDrawingDensity(t){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+t),super.setDrawingDensity(t)}}class A extends V{constructor(t,e,i,a){super(t,e),this.element=i,this.pagesElement=a}load(){for(const t of this.pagesElement){const e=new N(this.render,t,t.dataset.density==="hard"?"hard":"soft");e.load(),this.pages.push(e)}this.createSpread()}}class k{constructor(t,e,i,a){this.direction=t,this.corner=e,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(i,10),this.pageHeight=parseInt(a,10)}calc(t){try{return this.position=this.calcAngleAndPosition(t),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const t=[];let e=!1;return t.push(this.rect.topLeft),t.push(this.topIntersectPoint),this.sideIntersectPoint===null?e=!0:(t.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(e=!1)),t.push(this.bottomIntersectPoint),(e||this.corner==="bottom")&&t.push(this.rect.bottomLeft),t}getBottomClipArea(){const t=[];return t.push(this.topIntersectPoint),this.corner==="top"?t.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&t.push({x:this.pageWidth,y:0}),t.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?Q.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&t.push(this.sideIntersectPoint):this.corner==="top"&&t.push({x:this.pageWidth,y:this.pageHeight}),t.push(this.bottomIntersectPoint),t.push(this.topIntersectPoint),t}getAngle(){return this.direction===0?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return this.direction===0?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return this.direction===1?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return this.corner==="top"?this.topIntersectPoint:this.sideIntersectPoint!==null?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const t=Q.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?t:Math.PI-t}calcAngleAndPosition(t){let e=t;if(this.updateAngleAndGeometry(e),e=this.corner==="top"?this.checkPositionAtCenterLine(e,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(e,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(e.x-this.pageWidth)<1&&Math.abs(e.y)<1)throw new Error("Point is too small");return e}updateAngleAndGeometry(t){this.angle=this.calculateAngle(t),this.rect=this.getPageRect(t)}calculateAngle(t){const e=this.pageWidth-t.x+1,i=this.corner==="bottom"?this.pageHeight-t.y:t.y;let a=2*Math.acos(e/Math.sqrt(i*i+e*e));i<0&&(a=-a);const u=Math.PI-a;if(!isFinite(a)||u>=0&&u<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(a=-a),a}getPageRect(t){return this.corner==="top"?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],t):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],t)}getRectFromBasePoint(t,e){return{topLeft:this.getRotatedPoint(t[0],e),topRight:this.getRotatedPoint(t[1],e),bottomLeft:this.getRotatedPoint(t[2],e),bottomRight:this.getRotatedPoint(t[3],e)}}getRotatedPoint(t,e){return{x:t.x*Math.cos(this.angle)+t.y*Math.sin(this.angle)+e.x,y:t.y*Math.cos(this.angle)-t.x*Math.sin(this.angle)+e.y}}calculateIntersectPoint(t){const e={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=Q.GetIntersectBetweenTwoSegment(e,[t,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=Q.GetIntersectBetweenTwoSegment(e,[t,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=Q.GetIntersectBetweenTwoSegment(e,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=Q.GetIntersectBetweenTwoSegment(e,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=Q.GetIntersectBetweenTwoSegment(e,[t,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=Q.GetIntersectBetweenTwoSegment(e,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(t,e,i){let a=t;const u=Q.LimitPointToCircle(e,this.pageWidth,a);a!==u&&(a=u,this.updateAngleAndGeometry(a));const d=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let c=this.rect.bottomRight,S=this.rect.topLeft;if(this.corner==="bottom"&&(c=this.rect.topRight,S=this.rect.bottomLeft),c.x<=0){const X=Q.LimitPointToCircle(i,d,S);X!==a&&(a=X,this.updateAngleAndGeometry(a))}return a}getSegmentToShadowLine(){const t=this.getShadowStartPoint();return[t,t!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class M{constructor(t,e){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=t,this.app=e}fold(t){this.setState("user_fold"),this.calc===null&&this.start(t),this.do(this.render.convertToPage(t))}flip(t){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(t)||(this.calc!==null&&this.render.finishAnimation(),!this.start(t)))return;const e=this.getBoundsRect();this.setState("flipping");const i=e.height/10,a=this.calc.getCorner()==="bottom"?e.height-i:i,u=this.calc.getCorner()==="bottom"?e.height:0;this.calc.calc({x:e.pageWidth-i,y:a}),this.animateFlippingTo({x:e.pageWidth-i,y:a},{x:-e.pageWidth,y:u},!0)}start(t){this.reset();const e=this.render.convertToBook(t),i=this.getBoundsRect(),a=this.getDirectionByPoint(e),u=e.y>=i.height/2?"bottom":"top";if(!this.checkDirection(a))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(a),this.bottomPage=this.app.getPageCollection().getBottomPage(a),this.render.getOrientation()==="landscape")if(a===1){const d=this.app.getPageCollection().nextBy(this.flippingPage);d!==null&&this.flippingPage.getDensity()!==d.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),d.setDrawingDensity("hard"))}else{const d=this.app.getPageCollection().prevBy(this.flippingPage);d!==null&&this.flippingPage.getDensity()!==d.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),d.setDrawingDensity("hard"))}return this.render.setDirection(a),this.calc=new k(a,u,i.pageWidth.toString(10),i.height.toString(10)),!0}catch{return!1}}do(t){if(this.calc!==null&&this.calc.calc(t)){const e=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea()),this.bottomPage.setPosition(this.calc.getBottomPagePosition()),this.bottomPage.setAngle(0),this.bottomPage.setHardAngle(0),this.flippingPage.setArea(this.calc.getFlippingClipArea()),this.flippingPage.setPosition(this.calc.getActiveCorner()),this.flippingPage.setAngle(this.calc.getAngle()),this.calc.getDirection()===0?this.flippingPage.setHardAngle(90*(200-2*e)/100):this.flippingPage.setHardAngle(-90*(200-2*e)/100),this.render.setPageRect(this.calc.getRect()),this.render.setBottomPage(this.bottomPage),this.render.setFlippingPage(this.flippingPage),this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),e,this.calc.getDirection())}}flipToPage(t,e){const i=this.app.getPageCollection().getCurrentSpreadIndex(),a=this.app.getPageCollection().getSpreadIndexByPage(t);try{a>i&&(this.app.getPageCollection().setCurrentSpreadIndex(a-1),this.flipNext(e)),a<i&&(this.app.getPageCollection().setCurrentSpreadIndex(a+1),this.flipPrev(e))}catch{}}flipNext(t){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:t==="top"?1:this.render.getRect().height-2})}flipPrev(t){this.flip({x:10,y:t==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const t=this.calc.getPosition(),e=this.getBoundsRect(),i=this.calc.getCorner()==="bottom"?e.height:0;t.x<=0?this.animateFlippingTo(t,{x:-e.pageWidth,y:i},!0):this.animateFlippingTo(t,{x:e.pageWidth,y:i},!1)}showCorner(t){if(!this.checkState("read","fold_corner"))return;const e=this.getBoundsRect(),i=e.pageWidth;if(this.isPointOnCorners(t))if(this.calc===null){if(!this.start(t))return;this.setState("fold_corner"),this.calc.calc({x:i-1,y:1});const a=50,u=this.calc.getCorner()==="bottom"?e.height-1:1,d=this.calc.getCorner()==="bottom"?e.height-a:a;this.animateFlippingTo({x:i-1,y:u},{x:i-a,y:d},!1,!1)}else this.do(this.render.convertToPage(t));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(t,e,i,a=!0){const u=Q.GetCordsFromTwoPoint(t,e),d=[];for(const S of u)d.push(()=>this.do(S));const c=this.getAnimationDuration(u.length);this.render.startAnimation(d,c,()=>{this.calc&&(i&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),a&&(this.render.setBottomPage(null),this.render.setFlippingPage(null),this.render.clearShadow(),this.setState("read"),this.reset()))})}getCalculation(){return this.calc}getState(){return this.state}setState(t){this.state!==t&&(this.app.updateState(t),this.state=t)}getDirectionByPoint(t){const e=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(t.x-e.pageWidth<=e.width/5)return 1}else if(t.x<e.width/2)return 1;return 0}getAnimationDuration(t){const e=this.app.getSettings().flippingTime;return t>=1e3?e:t/1e3*e}checkDirection(t){return t===0?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null,this.flippingPage=null,this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...t){for(const e of t)if(this.state===e)return!0;return!1}isPointOnCorners(t){const e=this.getBoundsRect(),i=e.pageWidth,a=Math.sqrt(Math.pow(i,2)+Math.pow(e.height,2))/5,u=this.render.convertToBook(t);return u.x>0&&u.y>0&&u.x<e.width&&u.y<e.height&&(u.x<a||u.x>e.width-a)&&(u.y<a||u.y>e.height-a)}}class P{constructor(t,e){this.leftPage=null,this.rightPage=null,this.flippingPage=null,this.bottomPage=null,this.direction=null,this.orientation=null,this.shadow=null,this.animation=null,this.pageRect=null,this.boundsRect=null,this.timer=0,this.safari=!1,this.setting=e,this.app=t;const i=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=i.exec(window.navigator.userAgent)!==null}render(t){if(this.animation!==null){const e=Math.round((t-this.animation.startedAt)/this.animation.durationFrame);e<this.animation.frames.length?this.animation.frames[e]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=t,this.drawFrame()}start(){this.update();const t=e=>{this.render(e),requestAnimationFrame(t)};requestAnimationFrame(t)}startAnimation(t,e,i){this.finishAnimation(),this.animation={frames:t,duration:e,durationFrame:e/t.length,onAnimateEnd:i,startedAt:this.timer}}finishAnimation(){this.animation!==null&&(this.animation.frames[this.animation.frames.length-1](),this.animation.onAnimateEnd!==null&&this.animation.onAnimateEnd()),this.animation=null}update(){this.boundsRect=null;const t=this.calculateBoundsRect();this.orientation!==t&&(this.orientation=t,this.app.updateOrientation(t))}calculateBoundsRect(){let t="landscape";const e=this.getBlockWidth(),i=e/2,a=this.getBlockHeight()/2,u=this.setting.width/this.setting.height;let d=this.setting.width,c=this.setting.height,S=i-d;return this.setting.size==="stretch"?(e<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(t="portrait"),d=t==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,d>this.setting.maxWidth&&(d=this.setting.maxWidth),c=d/u,c>this.getBlockHeight()&&(c=this.getBlockHeight(),d=c*u),S=t==="portrait"?i-d/2-d:i-d):e<2*d&&this.app.getSettings().usePortrait&&(t="portrait",S=i-d/2-d),this.boundsRect={left:S,top:a-c/2,width:2*d,height:c,pageWidth:d},t}setShadowData(t,e,i,a){if(!this.app.getSettings().drawShadow)return;const u=100*this.getSettings().maxShadowOpacity;this.shadow={pos:t,angle:e,width:3*this.getRect().pageWidth/4*i/100,opacity:(100-i)*u/100/100,direction:a,progress:2*i}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){return this.boundsRect===null&&this.calculateBoundsRect(),this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(t){this.pageRect=t}setDirection(t){this.direction=t}setRightPage(t){t!==null&&t.setOrientation(1),this.rightPage=t}setLeftPage(t){t!==null&&t.setOrientation(0),this.leftPage=t}setBottomPage(t){t!==null&&t.setOrientation(this.direction===1?0:1),this.bottomPage=t}setFlippingPage(t){t!==null&&t.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=t}convertToBook(t){const e=this.getRect();return{x:t.x-e.left,y:t.y-e.top}}isSafari(){return this.safari}convertToPage(t,e){e||(e=this.direction);const i=this.getRect();return{x:e===0?t.x-i.left-i.width/2:i.width/2-t.x+i.left,y:t.y-i.top}}convertToGlobal(t,e){if(e||(e=this.direction),t==null)return null;const i=this.getRect();return{x:e===0?t.x+i.left+i.width/2:i.width/2-t.x+i.left,y:t.y+i.top}}convertRectToGlobal(t,e){return e||(e=this.direction),{topLeft:this.convertToGlobal(t.topLeft,e),topRight:this.convertToGlobal(t.topRight,e),bottomLeft:this.convertToGlobal(t.bottomLeft,e),bottomRight:this.convertToGlobal(t.bottomRight,e)}}}class w extends P{constructor(t,e,i){super(t,e),this.canvas=i,this.ctx=i.getContext("2d")}getContext(){return this.ctx}reload(){}drawFrame(){this.clear(),this.orientation!=="portrait"&&this.leftPage!=null&&this.leftPage.simpleDraw(0),this.rightPage!=null&&this.rightPage.simpleDraw(1),this.bottomPage!=null&&this.bottomPage.draw(),this.drawBookShadow(),this.flippingPage!=null&&this.flippingPage.draw(),this.shadow!=null&&(this.drawOuterShadow(),this.drawInnerShadow());const t=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(t.left+t.pageWidth,t.top,t.width,t.height),this.ctx.clip())}drawBookShadow(){const t=this.getRect();this.ctx.save(),this.ctx.beginPath();const e=t.width/20;this.ctx.rect(t.left,t.top,t.width,t.height);const i={x:t.left+t.width/2-e/2,y:0};this.ctx.translate(i.x,i.y);const a=this.ctx.createLinearGradient(0,0,e,0);a.addColorStop(0,"rgba(0, 0, 0, 0)"),a.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),a.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),a.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),a.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),a.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=a,this.ctx.fillRect(0,0,e,2*t.height),this.ctx.restore()}drawOuterShadow(){const t=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(t.left,t.top,t.width,t.height);const e=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(e.x,e.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const i=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),i.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),i.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),i.addColorStop(0,"rgba(0, 0, 0, 0)"),i.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=i,this.ctx.fillRect(0,0,this.shadow.width,2*t.height),this.ctx.restore()}drawInnerShadow(){const t=this.getRect();this.ctx.save(),this.ctx.beginPath();const e=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),i=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(i.topLeft.x,i.topLeft.y),this.ctx.lineTo(i.topRight.x,i.topRight.y),this.ctx.lineTo(i.bottomRight.x,i.bottomRight.y),this.ctx.lineTo(i.bottomLeft.x,i.bottomLeft.y),this.ctx.translate(e.x,e.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const a=3*this.shadow.width/4,u=this.ctx.createLinearGradient(0,0,a,0);this.shadow.direction===0?(this.ctx.translate(-a,-100),u.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")"),u.addColorStop(.9,"rgba(0, 0, 0, 0.05)"),u.addColorStop(.7,"rgba(0, 0, 0, "+this.shadow.opacity+")"),u.addColorStop(0,"rgba(0, 0, 0, 0)")):(this.ctx.translate(0,-100),u.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),u.addColorStop(.1,"rgba(0, 0, 0, 0.05)"),u.addColorStop(.3,"rgba(0, 0, 0, "+this.shadow.opacity+")"),u.addColorStop(1,"rgba(0, 0, 0, 0)")),this.ctx.clip(),this.ctx.fillStyle=u,this.ctx.fillRect(0,0,a,2*t.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class l{constructor(t,e,i){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=u=>{if(this.checkTarget(u.target)){const d=this.getMousePos(u.clientX,u.clientY);this.app.startUserTouch(d),u.preventDefault()}},this.onTouchStart=u=>{if(this.checkTarget(u.target)&&u.changedTouches.length>0){const d=u.changedTouches[0],c=this.getMousePos(d.clientX,d.clientY);this.touchPoint={point:c,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(c)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||u.preventDefault()}},this.onMouseUp=u=>{const d=this.getMousePos(u.clientX,u.clientY);this.app.userStop(d)},this.onMouseMove=u=>{const d=this.getMousePos(u.clientX,u.clientY);this.app.userMove(d,!1)},this.onTouchMove=u=>{if(u.changedTouches.length>0){const d=u.changedTouches[0],c=this.getMousePos(d.clientX,d.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-c.x)>10||this.app.getState()!=="read")&&u.cancelable&&this.app.userMove(c,!0),this.app.getState()!=="read"&&u.preventDefault()):this.app.userMove(c,!0)}},this.onTouchEnd=u=>{if(u.changedTouches.length>0){const d=u.changedTouches[0],c=this.getMousePos(d.clientX,d.clientY);let S=!1;if(this.touchPoint!==null){const X=c.x-this.touchPoint.point.x,tt=Math.abs(c.y-this.touchPoint.point.y);Math.abs(X)>this.swipeDistance&&tt<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(X>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"),S=!0),this.touchPoint=null}this.app.userStop(c,S)}},this.parentElement=t,t.classList.add("stf__parent"),t.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=t.querySelector(".stf__wrapper"),this.app=e;const a=this.app.getSettings().usePortrait?1:2;t.style.minWidth=i.minWidth*a+"px",t.style.minHeight=i.minHeight+"px",i.size==="fixed"&&(t.style.minWidth=i.width*a+"px",t.style.minHeight=i.height+"px"),i.autoSize&&(t.style.width="100%",t.style.maxWidth=2*i.maxWidth+"px"),t.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=i.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(t){this.wrapper.classList.remove("--portrait","--landscape"),t==="portrait"?(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%"),this.wrapper.classList.add("--portrait")):(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%"),this.wrapper.classList.add("--landscape")),this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize),this.distElement.removeEventListener("mousedown",this.onMouseDown),this.distElement.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1),this.app.getSettings().useMouseEvents&&(this.distElement.addEventListener("mousedown",this.onMouseDown),this.distElement.addEventListener("touchstart",this.onTouchStart),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onTouchEnd))}getMousePos(t,e){const i=this.distElement.getBoundingClientRect();return{x:t-i.left,y:e-i.top}}checkTarget(t){return!this.app.getSettings().clickEventForward||!["a","button"].includes(t.tagName.toLowerCase())}}class s extends l{constructor(t,e,i,a){super(t,e,i),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=t.querySelector(".stf__block"),this.items=a;for(const u of a)this.distElement.appendChild(u);this.setHandlers()}clear(){for(const t of this.items)this.parentElement.appendChild(t)}updateItems(t){this.removeHandlers(),this.distElement.innerHTML="";for(const e of t)this.distElement.appendChild(e);this.items=t,this.setHandlers()}update(){this.app.getRender().update()}}class n extends l{constructor(t,e,i){super(t,e,i),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=t.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const t=getComputedStyle(this.canvas),e=parseInt(t.getPropertyValue("width"),10),i=parseInt(t.getPropertyValue("height"),10);this.canvas.width=e,this.canvas.height=i}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class o extends P{constructor(t,e,i){super(t,e),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=i,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div>
23
+ <div class="stf__innerShadow"></div>
24
+ <div class="stf__hardShadow"></div>
25
+ <div class="stf__hardInnerShadow"></div>`),this.outerShadow=this.element.querySelector(".stf__outerShadow"),this.innerShadow=this.element.querySelector(".stf__innerShadow"),this.hardShadow=this.element.querySelector(".stf__hardShadow"),this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow(),this.outerShadow.style.cssText="display: none",this.innerShadow.style.cssText="display: none",this.hardShadow.style.cssText="display: none",this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const t=this.getRect(),e=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let i=(100-e)*(2.5*t.pageWidth)/100+20;i>t.pageWidth&&(i=t.pageWidth);let a=`
26
+ display: block;
27
+ z-index: ${(this.getSettings().startZIndex+5).toString(10)};
28
+ width: ${i}px;
29
+ height: ${t.height}px;
30
+ background: linear-gradient(to right,
31
+ rgba(0, 0, 0, ${this.shadow.opacity*e/100}) 5%,
32
+ rgba(0, 0, 0, 0) 100%);
33
+ left: ${t.left+t.width/2}px;
34
+ transform-origin: 0 0;
35
+ `;a+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);",this.hardInnerShadow.style.cssText=a}drawHardOuterShadow(){const t=this.getRect();let e=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*t.pageWidth)/100+20;e>t.pageWidth&&(e=t.pageWidth);let i=`
36
+ display: block;
37
+ z-index: ${(this.getSettings().startZIndex+4).toString(10)};
38
+ width: ${e}px;
39
+ height: ${t.height}px;
40
+ background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
41
+ left: ${t.left+t.width/2}px;
42
+ transform-origin: 0 0;
43
+ `;i+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);",this.hardShadow.style.cssText=i}drawInnerShadow(){const t=this.getRect(),e=3*this.shadow.width/4,i=this.getDirection()===0?e:0,a=this.getDirection()===0?"to left":"to right",u=this.convertToGlobal(this.shadow.pos),d=this.shadow.angle+3*Math.PI/2,c=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let S="polygon( ";for(const tt of c){let K=this.getDirection()===1?{x:-tt.x+this.shadow.pos.x,y:tt.y-this.shadow.pos.y}:{x:tt.x-this.shadow.pos.x,y:tt.y-this.shadow.pos.y};K=Q.GetRotatedPoint(K,{x:i,y:100},d),S+=K.x+"px "+K.y+"px, "}S=S.slice(0,-2),S+=")";const X=`
44
+ display: block;
45
+ z-index: ${(this.getSettings().startZIndex+10).toString(10)};
46
+ width: ${e}px;
47
+ height: ${2*t.height}px;
48
+ background: linear-gradient(${a},
49
+ rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
50
+ rgba(0, 0, 0, 0.05) 15%,
51
+ rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
52
+ rgba(0, 0, 0, 0) 100%);
53
+ transform-origin: ${i}px 100px;
54
+ transform: translate3d(${u.x-i}px, ${u.y-100}px, 0) rotate(${d}rad);
55
+ clip-path: ${S};
56
+ -webkit-clip-path: ${S};
57
+ `;this.innerShadow.style.cssText=X}drawOuterShadow(){const t=this.getRect(),e=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),i=this.shadow.angle+3*Math.PI/2,a=this.getDirection()===1?this.shadow.width:0,u=this.getDirection()===0?"to right":"to left",d=[{x:0,y:0},{x:t.pageWidth,y:0},{x:t.pageWidth,y:t.height},{x:0,y:t.height}];let c="polygon( ";for(const X of d)if(X!==null){let tt=this.getDirection()===1?{x:-X.x+this.shadow.pos.x,y:X.y-this.shadow.pos.y}:{x:X.x-this.shadow.pos.x,y:X.y-this.shadow.pos.y};tt=Q.GetRotatedPoint(tt,{x:a,y:100},i),c+=tt.x+"px "+tt.y+"px, "}c=c.slice(0,-2),c+=")";const S=`
58
+ display: block;
59
+ z-index: ${(this.getSettings().startZIndex+10).toString(10)};
60
+ width: ${this.shadow.width}px;
61
+ height: ${2*t.height}px;
62
+ background: linear-gradient(${u}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
63
+ transform-origin: ${a}px 100px;
64
+ transform: translate3d(${e.x-a}px, ${e.y-100}px, 0) rotate(${i}rad);
65
+ clip-path: ${c};
66
+ -webkit-clip-path: ${c};
67
+ `;this.outerShadow.style.cssText=S}drawLeftPage(){this.orientation!=="portrait"&&this.leftPage!==null&&(this.direction===1&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.leftPage.draw(this.flippingPage.getDrawingDensity())):this.leftPage.simpleDraw(0))}drawRightPage(){this.rightPage!==null&&(this.direction===0&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.rightPage.draw(this.flippingPage.getDrawingDensity())):this.rightPage.simpleDraw(1))}drawBottomPage(){if(this.bottomPage===null)return;const t=this.flippingPage!=null?this.flippingPage.getDrawingDensity():null;this.orientation==="portrait"&&this.direction===1||(this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10),this.bottomPage.draw(t))}drawFrame(){this.clear(),this.drawLeftPage(),this.drawRightPage(),this.drawBottomPage(),this.flippingPage!=null&&(this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.flippingPage.draw()),this.shadow!=null&&this.flippingPage!==null&&(this.flippingPage.getDrawingDensity()==="soft"?(this.drawOuterShadow(),this.drawInnerShadow()):(this.drawHardOuterShadow(),this.drawHardInnerShadow()))}clear(){for(const t of this.app.getPageCollection().getPages())t!==this.leftPage&&t!==this.rightPage&&t!==this.flippingPage&&t!==this.bottomPage&&(t.getElement().style.cssText="display: none"),t.getTemporaryCopy()!==this.flippingPage&&t.hideTemporaryCopy()}update(){super.update(),this.rightPage!==null&&this.rightPage.setOrientation(1),this.leftPage!==null&&this.leftPage.setOrientation(0)}}class y{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1}}getSettings(t){const e=this._default;if(Object.assign(e,t),e.size!=="stretch"&&e.size!=="fixed")throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(e.width<=0||e.height<=0)throw new Error("Invalid width or height");if(e.flippingTime<=0)throw new Error("Invalid flipping time");return e.size==="stretch"?(e.minWidth<=0&&(e.minWidth=100),e.maxWidth<e.minWidth&&(e.maxWidth=2e3),e.minHeight<=0&&(e.minHeight=100),e.maxHeight<e.minHeight&&(e.maxHeight=2e3)):(e.minWidth=e.width,e.maxWidth=e.width,e.minHeight=e.height,e.maxHeight=e.height),e}}(function(p,t){t===void 0&&(t={});var e=t.insertAt;if(p&&typeof document<"u"){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",e==="top"&&i.firstChild?i.insertBefore(a,i.firstChild):i.appendChild(a),a.styleSheet?a.styleSheet.cssText=p:a.appendChild(document.createTextNode(p))}})(`.stf__parent {
68
+ position: relative;
69
+ display: block;
70
+ box-sizing: border-box;
71
+ transform: translateZ(0);
72
+
73
+ -ms-touch-action: pan-y;
74
+ touch-action: pan-y;
75
+ }
76
+
77
+ .sft__wrapper {
78
+ position: relative;
79
+ width: 100%;
80
+ box-sizing: border-box;
81
+ }
82
+
83
+ .stf__parent canvas {
84
+ position: absolute;
85
+ width: 100%;
86
+ height: 100%;
87
+ left: 0;
88
+ top: 0;
89
+ }
90
+
91
+ .stf__block {
92
+ position: absolute;
93
+ width: 100%;
94
+ height: 100%;
95
+ box-sizing: border-box;
96
+ perspective: 2000px;
97
+ }
98
+
99
+ .stf__item {
100
+ display: none;
101
+ position: absolute;
102
+ transform-style: preserve-3d;
103
+ }
104
+
105
+ .stf__outerShadow {
106
+ position: absolute;
107
+ left: 0;
108
+ top: 0;
109
+ }
110
+
111
+ .stf__innerShadow {
112
+ position: absolute;
113
+ left: 0;
114
+ top: 0;
115
+ }
116
+
117
+ .stf__hardShadow {
118
+ position: absolute;
119
+ left: 0;
120
+ top: 0;
121
+ }
122
+
123
+ .stf__hardInnerShadow {
124
+ position: absolute;
125
+ left: 0;
126
+ top: 0;
127
+ }`),U.PageFlip=class extends class{constructor(){this.events=new Map}on(p,t){return this.events.has(p)?this.events.get(p).push(t):this.events.set(p,[t]),this}off(p){this.events.delete(p)}trigger(p,t,e=null){if(this.events.has(p))for(const i of this.events.get(p))i({data:e,object:t})}}{constructor(p,t){super(),this.isUserTouch=!1,this.isUserMove=!1,this.setting=null,this.pages=null,this.setting=new y().getSettings(t),this.block=p}destroy(){this.ui.destroy(),this.block.remove()}update(){this.render.update(),this.pages.show()}loadFromImages(p){this.ui=new n(this.block,this,this.setting);const t=this.ui.getCanvas();this.render=new w(this,this.setting,t),this.flipController=new M(this.render,this),this.pages=new H(this,this.render,p),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}loadFromHTML(p){this.ui=new s(this.block,this,this.setting,p),this.render=new o(this,this.setting,this.ui.getDistElement()),this.flipController=new M(this.render,this),this.pages=new A(this,this.render,this.ui.getDistElement(),p),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromImages(p){const t=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new H(this,this.render,p),this.pages.load(),this.pages.show(t),this.trigger("update",this,{page:t,mode:this.render.getOrientation()})}updateFromHtml(p){const t=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new A(this,this.render,this.ui.getDistElement(),p),this.pages.load(),this.ui.updateItems(p),this.render.reload(),this.pages.show(t),this.trigger("update",this,{page:t,mode:this.render.getOrientation()})}clear(){this.pages.destroy(),this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(p){this.pages.show(p)}flipNext(p="top"){this.flipController.flipNext(p)}flipPrev(p="top"){this.flipController.flipPrev(p)}flip(p,t="top"){this.flipController.flipToPage(p,t)}updateState(p){this.trigger("changeState",this,p)}updatePageIndex(p){this.trigger("flip",this,p)}updateOrientation(p){this.ui.setOrientationStyle(p),this.update(),this.trigger("changeOrientation",this,p)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(p){return this.pages.getPage(p)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(p){this.mousePosition=p,this.isUserTouch=!0,this.isUserMove=!1}userMove(p,t){this.isUserTouch||t||!this.setting.showPageCorners?this.isUserTouch&&Q.GetDistanceBetweenTwoPoint(this.mousePosition,p)>5&&(this.isUserMove=!0,this.flipController.fold(p)):this.flipController.showCorner(p)}userStop(p,t=!1){this.isUserTouch&&(this.isUserTouch=!1,t||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(p)))}},Object.defineProperty(U,"__esModule",{value:!0})})})(pageFlip_browser,pageFlip_browser.exports);var pageFlip_browserExports=pageFlip_browser.exports;function commonjsRequire(nt){throw new Error('Could not dynamically require "'+nt+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pdf={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$5=getAugmentedNamespace(__viteBrowserExternal$1);(function(module,exports){(function(g,U){module.exports=U()})(globalThis,()=>(()=>{var __webpack_modules__=[,(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.VerbosityLevel=g.Util=g.UnknownErrorException=g.UnexpectedResponseException=g.UNSUPPORTED_FEATURES=g.TextRenderingMode=g.StreamType=g.RenderingIntentFlag=g.PermissionFlag=g.PasswordResponses=g.PasswordException=g.PageActionEventType=g.OPS=g.MissingPDFException=g.LINE_FACTOR=g.LINE_DESCENT_FACTOR=g.InvalidPDFException=g.ImageKind=g.IDENTITY_MATRIX=g.FormatError=g.FontType=g.FeatureTest=g.FONT_IDENTITY_MATRIX=g.DocumentActionEventType=g.CMapCompressionType=g.BaseException=g.AnnotationType=g.AnnotationStateModelType=g.AnnotationReviewState=g.AnnotationReplyType=g.AnnotationMode=g.AnnotationMarkedState=g.AnnotationFlag=g.AnnotationFieldFlag=g.AnnotationEditorType=g.AnnotationEditorPrefix=g.AnnotationEditorParamsType=g.AnnotationBorderStyleType=g.AnnotationActionEventType=g.AbortException=void 0,g.arrayByteLength=st,g.arraysToBytes=dt,g.assert=f,g.bytesToString=T,g.createPromiseCapability=ft,g.createValidAbsoluteUrl=E,g.escapeString=Et,g.getModificationDate=rt,g.getVerbosityLevel=it,g.info=ht,g.isArrayBuffer=Dt,g.isArrayEqual=Zt,g.isAscii=Ft,g.objectFromMap=et,g.objectSize=ot,g.setVerbosityLevel=$,g.shadow=F,g.string32=Z,g.stringToBytes=L,g.stringToPDFString=xt,g.stringToUTF16BEString=Rt,g.stringToUTF8String=zt,g.unreachable=O,g.utf8StringToString=wt,g.warn=yt,U(2);const _=[1,0,0,1,0,0];g.IDENTITY_MATRIX=_;const v=[.001,0,0,.001,0,0];g.FONT_IDENTITY_MATRIX=v;const V=1.35;g.LINE_FACTOR=V;const H=.35;g.LINE_DESCENT_FACTOR=H;const Q={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};g.RenderingIntentFlag=Q;const N={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};g.AnnotationMode=N;const A="pdfjs_internal_editor_";g.AnnotationEditorPrefix=A;const k={DISABLE:-1,NONE:0,FREETEXT:3,INK:15};g.AnnotationEditorType=k;const M={FREETEXT_SIZE:1,FREETEXT_COLOR:2,FREETEXT_OPACITY:3,INK_COLOR:11,INK_THICKNESS:12,INK_OPACITY:13};g.AnnotationEditorParamsType=M;const P={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};g.PermissionFlag=P;const w={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};g.TextRenderingMode=w;const l={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};g.ImageKind=l;const s={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};g.AnnotationType=s;const n={MARKED:"Marked",REVIEW:"Review"};g.AnnotationStateModelType=n;const o={MARKED:"Marked",UNMARKED:"Unmarked"};g.AnnotationMarkedState=o;const y={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"};g.AnnotationReviewState=y;const p={GROUP:"Group",REPLY:"R"};g.AnnotationReplyType=p;const t={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};g.AnnotationFlag=t;const e={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};g.AnnotationFieldFlag=e;const i={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};g.AnnotationBorderStyleType=i;const a={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};g.AnnotationActionEventType=a;const u={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};g.DocumentActionEventType=u;const d={O:"PageOpen",C:"PageClose"};g.PageActionEventType=d;const c={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"};g.StreamType=c;const S={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1STANDARD:"TYPE1STANDARD",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};g.FontType=S;const X={ERRORS:0,WARNINGS:1,INFOS:5};g.VerbosityLevel=X;const tt={NONE:0,BINARY:1,STREAM:2};g.CMapCompressionType=tt;const K={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};g.OPS=K;const Y={unknown:"unknown",forms:"forms",javaScript:"javaScript",signatures:"signatures",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"};g.UNSUPPORTED_FEATURES=Y;const B={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};g.PasswordResponses=B;let q=X.WARNINGS;function $(J){Number.isInteger(J)&&(q=J)}function it(){return q}function ht(J){q>=X.INFOS&&console.log(`Info: ${J}`)}function yt(J){q>=X.WARNINGS&&console.log(`Warning: ${J}`)}function O(J){throw new Error(J)}function f(J,j){J||O(j)}function h(J){if(!J)return!1;switch(J.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function E(J,j=null,W=null){if(!J)return null;try{if(W&&typeof J=="string"){if(W.addDefaultProtocol&&J.startsWith("www.")){const bt=J.match(/\./g);bt&&bt.length>=2&&(J=`http://${J}`)}if(W.tryConvertEncoding)try{J=zt(J)}catch{}}const gt=j?new URL(J,j):new URL(J);if(h(gt))return gt}catch{}return null}function F(J,j,W){return Object.defineProperty(J,j,{value:W,enumerable:!0,configurable:!0,writable:!1}),W}const D=function(){function j(W,gt){this.constructor===j&&O("Cannot initialize BaseException."),this.message=W,this.name=gt}return j.prototype=new Error,j.constructor=j,j}();g.BaseException=D;class I extends D{constructor(j,W){super(j,"PasswordException"),this.code=W}}g.PasswordException=I;class G extends D{constructor(j,W){super(j,"UnknownErrorException"),this.details=W}}g.UnknownErrorException=G;class z extends D{constructor(j){super(j,"InvalidPDFException")}}g.InvalidPDFException=z;class r extends D{constructor(j){super(j,"MissingPDFException")}}g.MissingPDFException=r;class m extends D{constructor(j,W){super(j,"UnexpectedResponseException"),this.status=W}}g.UnexpectedResponseException=m;class b extends D{constructor(j){super(j,"FormatError")}}g.FormatError=b;class x extends D{constructor(j){super(j,"AbortException")}}g.AbortException=x;function T(J){(typeof J!="object"||J===null||J.length===void 0)&&O("Invalid argument for bytesToString");const j=J.length,W=8192;if(j<W)return String.fromCharCode.apply(null,J);const gt=[];for(let bt=0;bt<j;bt+=W){const At=Math.min(bt+W,j),vt=J.subarray(bt,At);gt.push(String.fromCharCode.apply(null,vt))}return gt.join("")}function L(J){typeof J!="string"&&O("Invalid argument for stringToBytes");const j=J.length,W=new Uint8Array(j);for(let gt=0;gt<j;++gt)W[gt]=J.charCodeAt(gt)&255;return W}function st(J){if(J.length!==void 0)return J.length;if(J.byteLength!==void 0)return J.byteLength;O("Invalid argument for arrayByteLength")}function dt(J){const j=J.length;if(j===1&&J[0]instanceof Uint8Array)return J[0];let W=0;for(let At=0;At<j;At++)W+=st(J[At]);let gt=0;const bt=new Uint8Array(W);for(let At=0;At<j;At++){let vt=J[At];vt instanceof Uint8Array||(typeof vt=="string"?vt=L(vt):vt=new Uint8Array(vt));const Ct=vt.byteLength;bt.set(vt,gt),gt+=Ct}return bt}function Z(J){return String.fromCharCode(J>>24&255,J>>16&255,J>>8&255,J&255)}function ot(J){return Object.keys(J).length}function et(J){const j=Object.create(null);for(const[W,gt]of J)j[W]=gt;return j}function lt(){const J=new Uint8Array(4);return J[0]=1,new Uint32Array(J.buffer,0,1)[0]===1}function pt(){try{return new Function(""),!0}catch{return!1}}class R{static get isLittleEndian(){return F(this,"isLittleEndian",lt())}static get isEvalSupported(){return F(this,"isEvalSupported",pt())}static get isOffscreenCanvasSupported(){return F(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}}g.FeatureTest=R;const ut=[...Array(256).keys()].map(J=>J.toString(16).padStart(2,"0"));class _t{static makeHexColor(j,W,gt){return`#${ut[j]}${ut[W]}${ut[gt]}`}static scaleMinMax(j,W){let gt;j[0]?(j[0]<0&&(gt=W[0],W[0]=W[1],W[1]=gt),W[0]*=j[0],W[1]*=j[0],j[3]<0&&(gt=W[2],W[2]=W[3],W[3]=gt),W[2]*=j[3],W[3]*=j[3]):(gt=W[0],W[0]=W[2],W[2]=gt,gt=W[1],W[1]=W[3],W[3]=gt,j[1]<0&&(gt=W[2],W[2]=W[3],W[3]=gt),W[2]*=j[1],W[3]*=j[1],j[2]<0&&(gt=W[0],W[0]=W[1],W[1]=gt),W[0]*=j[2],W[1]*=j[2]),W[0]+=j[4],W[1]+=j[4],W[2]+=j[5],W[3]+=j[5]}static transform(j,W){return[j[0]*W[0]+j[2]*W[1],j[1]*W[0]+j[3]*W[1],j[0]*W[2]+j[2]*W[3],j[1]*W[2]+j[3]*W[3],j[0]*W[4]+j[2]*W[5]+j[4],j[1]*W[4]+j[3]*W[5]+j[5]]}static applyTransform(j,W){const gt=j[0]*W[0]+j[1]*W[2]+W[4],bt=j[0]*W[1]+j[1]*W[3]+W[5];return[gt,bt]}static applyInverseTransform(j,W){const gt=W[0]*W[3]-W[1]*W[2],bt=(j[0]*W[3]-j[1]*W[2]+W[2]*W[5]-W[4]*W[3])/gt,At=(-j[0]*W[1]+j[1]*W[0]+W[4]*W[1]-W[5]*W[0])/gt;return[bt,At]}static getAxialAlignedBoundingBox(j,W){const gt=_t.applyTransform(j,W),bt=_t.applyTransform(j.slice(2,4),W),At=_t.applyTransform([j[0],j[3]],W),vt=_t.applyTransform([j[2],j[1]],W);return[Math.min(gt[0],bt[0],At[0],vt[0]),Math.min(gt[1],bt[1],At[1],vt[1]),Math.max(gt[0],bt[0],At[0],vt[0]),Math.max(gt[1],bt[1],At[1],vt[1])]}static inverseTransform(j){const W=j[0]*j[3]-j[1]*j[2];return[j[3]/W,-j[1]/W,-j[2]/W,j[0]/W,(j[2]*j[5]-j[4]*j[3])/W,(j[4]*j[1]-j[5]*j[0])/W]}static apply3dTransform(j,W){return[j[0]*W[0]+j[1]*W[1]+j[2]*W[2],j[3]*W[0]+j[4]*W[1]+j[5]*W[2],j[6]*W[0]+j[7]*W[1]+j[8]*W[2]]}static singularValueDecompose2dScale(j){const W=[j[0],j[2],j[1],j[3]],gt=j[0]*W[0]+j[1]*W[2],bt=j[0]*W[1]+j[1]*W[3],At=j[2]*W[0]+j[3]*W[2],vt=j[2]*W[1]+j[3]*W[3],Ct=(gt+vt)/2,It=Math.sqrt((gt+vt)**2-4*(gt*vt-At*bt))/2,kt=Ct+It||1,Pt=Ct-It||1;return[Math.sqrt(kt),Math.sqrt(Pt)]}static normalizeRect(j){const W=j.slice(0);return j[0]>j[2]&&(W[0]=j[2],W[2]=j[0]),j[1]>j[3]&&(W[1]=j[3],W[3]=j[1]),W}static intersect(j,W){const gt=Math.max(Math.min(j[0],j[2]),Math.min(W[0],W[2])),bt=Math.min(Math.max(j[0],j[2]),Math.max(W[0],W[2]));if(gt>bt)return null;const At=Math.max(Math.min(j[1],j[3]),Math.min(W[1],W[3])),vt=Math.min(Math.max(j[1],j[3]),Math.max(W[1],W[3]));return At>vt?null:[gt,At,bt,vt]}static bezierBoundingBox(j,W,gt,bt,At,vt,Ct,It){const kt=[],Pt=[[],[]];let Lt,Ot,Ut,Tt,Nt,Wt,$t,Xt;for(let Vt=0;Vt<2;++Vt){if(Vt===0?(Ot=6*j-12*gt+6*At,Lt=-3*j+9*gt-9*At+3*Ct,Ut=3*gt-3*j):(Ot=6*W-12*bt+6*vt,Lt=-3*W+9*bt-9*vt+3*It,Ut=3*bt-3*W),Math.abs(Lt)<1e-12){if(Math.abs(Ot)<1e-12)continue;Tt=-Ut/Ot,0<Tt&&Tt<1&&kt.push(Tt);continue}$t=Ot*Ot-4*Ut*Lt,Xt=Math.sqrt($t),!($t<0)&&(Nt=(-Ot+Xt)/(2*Lt),0<Nt&&Nt<1&&kt.push(Nt),Wt=(-Ot-Xt)/(2*Lt),0<Wt&&Wt<1&&kt.push(Wt))}let qt=kt.length,Bt;const Ht=qt;for(;qt--;)Tt=kt[qt],Bt=1-Tt,Pt[0][qt]=Bt*Bt*Bt*j+3*Bt*Bt*Tt*gt+3*Bt*Tt*Tt*At+Tt*Tt*Tt*Ct,Pt[1][qt]=Bt*Bt*Bt*W+3*Bt*Bt*Tt*bt+3*Bt*Tt*Tt*vt+Tt*Tt*Tt*It;return Pt[0][Ht]=j,Pt[1][Ht]=W,Pt[0][Ht+1]=Ct,Pt[1][Ht+1]=It,Pt[0].length=Pt[1].length=Ht+2,[Math.min(...Pt[0]),Math.min(...Pt[1]),Math.max(...Pt[0]),Math.max(...Pt[1])]}}g.Util=_t;const St=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function xt(J){if(J[0]>="ï"){let W;if(J[0]==="þ"&&J[1]==="ÿ"?W="utf-16be":J[0]==="ÿ"&&J[1]==="þ"?W="utf-16le":J[0]==="ï"&&J[1]==="»"&&J[2]==="¿"&&(W="utf-8"),W)try{const gt=new TextDecoder(W,{fatal:!0}),bt=L(J);return gt.decode(bt)}catch(gt){yt(`stringToPDFString: "${gt}".`)}}const j=[];for(let W=0,gt=J.length;W<gt;W++){const bt=St[J.charCodeAt(W)];j.push(bt?String.fromCharCode(bt):J.charAt(W))}return j.join("")}function Et(J){return J.replace(/([()\\\n\r])/g,j=>j===`
128
+ `?"\\n":j==="\r"?"\\r":`\\${j}`)}function Ft(J){return/^[\x00-\x7F]*$/.test(J)}function Rt(J){const j=["þÿ"];for(let W=0,gt=J.length;W<gt;W++){const bt=J.charCodeAt(W);j.push(String.fromCharCode(bt>>8&255),String.fromCharCode(bt&255))}return j.join("")}function zt(J){return decodeURIComponent(escape(J))}function wt(J){return unescape(encodeURIComponent(J))}function Dt(J){return typeof J=="object"&&J!==null&&J.byteLength!==void 0}function Zt(J,j){if(J.length!==j.length)return!1;for(let W=0,gt=J.length;W<gt;W++)if(J[W]!==j[W])return!1;return!0}function rt(J=new Date){return[J.getUTCFullYear().toString(),(J.getUTCMonth()+1).toString().padStart(2,"0"),J.getUTCDate().toString().padStart(2,"0"),J.getUTCHours().toString().padStart(2,"0"),J.getUTCMinutes().toString().padStart(2,"0"),J.getUTCSeconds().toString().padStart(2,"0")].join("")}function ft(){const J=Object.create(null);let j=!1;return Object.defineProperty(J,"settled",{get(){return j}}),J.promise=new Promise(function(W,gt){J.resolve=function(bt){j=!0,W(bt)},J.reject=function(bt){j=!0,gt(bt)}}),J}},(nt,g,U)=>{U(3)},(nt,g)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.isNodeJS=void 0;const U=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser");g.isNodeJS=U},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var nt,U,_,v,V,H,Q,N,A,oe,M,P;Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,exports.getDocument=getDocument,exports.setPDFNetworkStreamFactory=setPDFNetworkStreamFactory,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(5),_display_utils=__w_pdfjs_require__(8),_font_loader=__w_pdfjs_require__(11),_canvas=__w_pdfjs_require__(12),_worker_options=__w_pdfjs_require__(15),_is_node=__w_pdfjs_require__(3),_message_handler=__w_pdfjs_require__(16),_metadata=__w_pdfjs_require__(17),_optional_content_config=__w_pdfjs_require__(18),_transport_stream=__w_pdfjs_require__(19),_xfa_text=__w_pdfjs_require__(20);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100;let DefaultCanvasFactory=_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;let DefaultCMapReaderFactory=_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;let DefaultStandardFontDataFactory=_display_utils.DOMStandardFontDataFactory;if(exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory,_is_node.isNodeJS){const{NodeCanvasFactory:l,NodeCMapReaderFactory:s,NodeStandardFontDataFactory:n}=__w_pdfjs_require__(21);exports.DefaultCanvasFactory=DefaultCanvasFactory=l,exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory=s,exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory=n}let createPDFNetworkStream;function setPDFNetworkStreamFactory(l){createPDFNetworkStream=l}function getDocument(l){const s=new PDFDocumentLoadingTask;let n;if(typeof l=="string"||l instanceof URL)n={url:l};else if((0,_util.isArrayBuffer)(l))n={data:l};else if(l instanceof PDFDataRangeTransport)n={range:l};else{if(typeof l!="object")throw new Error("Invalid parameter in getDocument, need either string, URL, TypedArray, or parameter object.");if(!l.url&&!l.data&&!l.range)throw new Error("Invalid parameter object: need either .data, .range or .url");n=l}const o=Object.create(null);let y=null,p=null;for(const e in n){const i=n[e];switch(e){case"url":if(typeof window<"u")try{o[e]=new URL(i,window.location).href;continue}catch(a){(0,_util.warn)(`Cannot create valid URL: "${a}".`)}else if(typeof i=="string"||i instanceof URL){o[e]=i.toString();continue}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.");case"range":y=i;continue;case"worker":p=i;continue;case"data":if(_is_node.isNodeJS&&typeof Buffer<"u"&&i instanceof Buffer)o[e]=new Uint8Array(i);else{if(i instanceof Uint8Array)break;if(typeof i=="string")o[e]=(0,_util.stringToBytes)(i);else if(typeof i=="object"&&i!==null&&!isNaN(i.length))o[e]=new Uint8Array(i);else if((0,_util.isArrayBuffer)(i))o[e]=new Uint8Array(i);else throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}continue}o[e]=i}if(o.CMapReaderFactory=o.CMapReaderFactory||DefaultCMapReaderFactory,o.StandardFontDataFactory=o.StandardFontDataFactory||DefaultStandardFontDataFactory,o.ignoreErrors=o.stopAtErrors!==!0,o.fontExtraProperties=o.fontExtraProperties===!0,o.pdfBug=o.pdfBug===!0,o.enableXfa=o.enableXfa===!0,(!Number.isInteger(o.rangeChunkSize)||o.rangeChunkSize<1)&&(o.rangeChunkSize=DEFAULT_RANGE_CHUNK_SIZE),(typeof o.docBaseUrl!="string"||(0,_display_utils.isDataScheme)(o.docBaseUrl))&&(o.docBaseUrl=null),(!Number.isInteger(o.maxImageSize)||o.maxImageSize<-1)&&(o.maxImageSize=-1),typeof o.cMapUrl!="string"&&(o.cMapUrl=null),typeof o.standardFontDataUrl!="string"&&(o.standardFontDataUrl=null),typeof o.useWorkerFetch!="boolean"&&(o.useWorkerFetch=o.CMapReaderFactory===_display_utils.DOMCMapReaderFactory&&o.StandardFontDataFactory===_display_utils.DOMStandardFontDataFactory),typeof o.isEvalSupported!="boolean"&&(o.isEvalSupported=!0),typeof o.disableFontFace!="boolean"&&(o.disableFontFace=_is_node.isNodeJS),typeof o.useSystemFonts!="boolean"&&(o.useSystemFonts=!_is_node.isNodeJS&&!o.disableFontFace),(typeof o.ownerDocument!="object"||o.ownerDocument===null)&&(o.ownerDocument=globalThis.document),typeof o.disableRange!="boolean"&&(o.disableRange=!1),typeof o.disableStream!="boolean"&&(o.disableStream=!1),typeof o.disableAutoFetch!="boolean"&&(o.disableAutoFetch=!1),(0,_util.setVerbosityLevel)(o.verbosity),!p){const e={verbosity:o.verbosity,port:_worker_options.GlobalWorkerOptions.workerPort};p=e.port?PDFWorker.fromPort(e):new PDFWorker(e),s._worker=p}const t=s.docId;return p.promise.then(function(){if(s.destroyed)throw new Error("Loading aborted");const e=_fetchDocument(p,o,y,t),i=new Promise(function(a){let u;y?u=new _transport_stream.PDFDataTransportStream({length:o.length,initialData:o.initialData,progressiveDone:o.progressiveDone,contentDispositionFilename:o.contentDispositionFilename,disableRange:o.disableRange,disableStream:o.disableStream},y):o.data||(u=createPDFNetworkStream({url:o.url,length:o.length,httpHeaders:o.httpHeaders,withCredentials:o.withCredentials,rangeChunkSize:o.rangeChunkSize,disableRange:o.disableRange,disableStream:o.disableStream})),a(u)});return Promise.all([e,i]).then(function([a,u]){if(s.destroyed)throw new Error("Loading aborted");const d=new _message_handler.MessageHandler(t,a,p.port),c=new WorkerTransport(d,s,u,o);s._transport=c,d.send("Ready",null)})}).catch(s._capability.reject),s}async function _fetchDocument(l,s,n,o){if(l.destroyed)throw new Error("Worker was destroyed");n&&(s.length=n.length,s.initialData=n.initialData,s.progressiveDone=n.progressiveDone,s.contentDispositionFilename=n.contentDispositionFilename);const y=await l.messageHandler.sendWithPromise("GetDocRequest",{docId:o,apiVersion:"2.16.105",source:{data:s.data,url:s.url,password:s.password,disableAutoFetch:s.disableAutoFetch,rangeChunkSize:s.rangeChunkSize,length:s.length},maxImageSize:s.maxImageSize,disableFontFace:s.disableFontFace,docBaseUrl:s.docBaseUrl,ignoreErrors:s.ignoreErrors,isEvalSupported:s.isEvalSupported,fontExtraProperties:s.fontExtraProperties,enableXfa:s.enableXfa,useSystemFonts:s.useSystemFonts,cMapUrl:s.useWorkerFetch?s.cMapUrl:null,standardFontDataUrl:s.useWorkerFetch?s.standardFontDataUrl:null});if(s.data&&(s.data=null),l.destroyed)throw new Error("Worker was destroyed");return y}const g=class g{constructor(){this._capability=(0,_util.createPromiseCapability)(),this._transport=null,this._worker=null,this.docId=`d${ae(g,nt)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null,this.onUnsupportedFeature=null}get promise(){return this._capability.promise}async destroy(){var s;this.destroyed=!0,await((s=this._transport)==null?void 0:s.destroy()),this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};nt=new WeakMap,at(g,nt,0);let PDFDocumentLoadingTask=g;exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(s,n,o=!1,y=null){this.length=s,this.initialData=n,this.progressiveDone=o,this.contentDispositionFilename=y,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(s){this._rangeListeners.push(s)}addProgressListener(s){this._progressListeners.push(s)}addProgressiveReadListener(s){this._progressiveReadListeners.push(s)}addProgressiveDoneListener(s){this._progressiveDoneListeners.push(s)}onDataRange(s,n){for(const o of this._rangeListeners)o(s,n)}onDataProgress(s,n){this._readyCapability.promise.then(()=>{for(const o of this._progressListeners)o(s,n)})}onDataProgressiveRead(s){this._readyCapability.promise.then(()=>{for(const n of this._progressiveReadListeners)n(s)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const s of this._progressiveDoneListeners)s()})}transportReady(){this._readyCapability.resolve()}requestDataRange(s,n){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(s,n){this._pdfInfo=s,this._transport=n,Object.defineProperty(this,"fingerprint",{get(){return(0,_display_utils.deprecated)("`PDFDocumentProxy.fingerprint`, please use `PDFDocumentProxy.fingerprints` instead."),this.fingerprints[0]}}),Object.defineProperty(this,"getStats",{value:async()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getStats`, please use the `PDFDocumentProxy.stats`-getter instead."),this.stats||{streamTypes:{},fontTypes:{}})})}get annotationStorage(){return this._transport.annotationStorage}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get stats(){return this._transport.stats}get isPureXfa(){return!!this._transport._htmlForXfa}get allXfaHtml(){return this._transport._htmlForXfa}getPage(s){return this._transport.getPage(s)}getPageIndex(s){return this._transport.getPageIndex(s)}getDestinations(){return this._transport.getDestinations()}getDestination(s){return this._transport.getDestination(s)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(s=!1){return this._transport.startCleanup(s||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}saveDocument(){return this._transport.annotationStorage.size<=0&&(0,_display_utils.deprecated)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead."),this._transport.saveDocument()}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(s,n,o,y,p=!1){this._pageIndex=s,this._pageInfo=n,this._ownerDocument=y,this._transport=o,this._stats=p?new _display_utils.StatTimer:null,this._pdfBug=p,this.commonObjs=o.commonObjs,this.objs=new PDFObjects,this._bitmaps=new Set,this.cleanupAfterRender=!1,this.pendingCleanup=!1,this._intentStates=new Map,this._annotationPromises=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:s,rotation:n=this.rotate,offsetX:o=0,offsetY:y=0,dontFlip:p=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:s,rotation:n,offsetX:o,offsetY:y,dontFlip:p})}getAnnotations({intent:s="display"}={}){const n=this._transport.getRenderingIntent(s);let o=this._annotationPromises.get(n.cacheKey);return o||(o=this._transport.getAnnotations(this._pageIndex,n.renderingIntent),this._annotationPromises.set(n.cacheKey,o),o=o.then(y=>{for(const p of y)p.titleObj!==void 0&&Object.defineProperty(p,"title",{get(){return(0,_display_utils.deprecated)("`title`-property on annotation, please use `titleObj` instead."),p.titleObj.str}}),p.contentsObj!==void 0&&Object.defineProperty(p,"contents",{get(){return(0,_display_utils.deprecated)("`contents`-property on annotation, please use `contentsObj` instead."),p.contentsObj.str}});return y})),o}getJSActions(){return this._jsActionsPromise||(this._jsActionsPromise=this._transport.getPageJSActions(this._pageIndex))}async getXfa(){var s;return((s=this._transport._htmlForXfa)==null?void 0:s.children[this._pageIndex])||null}render({canvasContext:s,viewport:n,intent:o="display",annotationMode:y=_util.AnnotationMode.ENABLE,transform:p=null,imageLayer:t=null,canvasFactory:e=null,background:i=null,optionalContentConfigPromise:a=null,annotationCanvasMap:u=null,pageColors:d=null,printAnnotationStorage:c=null}){var $,it;(($=arguments[0])==null?void 0:$.renderInteractiveForms)!==void 0&&((0,_display_utils.deprecated)("render no longer accepts the `renderInteractiveForms`-option, please use the `annotationMode`-option instead."),arguments[0].renderInteractiveForms===!0&&y===_util.AnnotationMode.ENABLE&&(y=_util.AnnotationMode.ENABLE_FORMS)),((it=arguments[0])==null?void 0:it.includeAnnotationStorage)!==void 0&&((0,_display_utils.deprecated)("render no longer accepts the `includeAnnotationStorage`-option, please use the `annotationMode`-option instead."),arguments[0].includeAnnotationStorage===!0&&y===_util.AnnotationMode.ENABLE&&(y=_util.AnnotationMode.ENABLE_STORAGE)),this._stats&&this._stats.time("Overall");const S=this._transport.getRenderingIntent(o,y,c);this.pendingCleanup=!1,a||(a=this._transport.getOptionalContentConfig());let X=this._intentStates.get(S.cacheKey);X||(X=Object.create(null),this._intentStates.set(S.cacheKey,X)),X.streamReaderCancelTimeout&&(clearTimeout(X.streamReaderCancelTimeout),X.streamReaderCancelTimeout=null);const tt=e||new DefaultCanvasFactory({ownerDocument:this._ownerDocument}),K=!!(S.renderingIntent&_util.RenderingIntentFlag.PRINT);X.displayReadyCapability||(X.displayReadyCapability=(0,_util.createPromiseCapability)(),X.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(S));const Y=ht=>{X.renderTasks.delete(B),(this.cleanupAfterRender||K)&&(this.pendingCleanup=!0),this._tryCleanup(),ht?(B.capability.reject(ht),this._abortOperatorList({intentState:X,reason:ht instanceof Error?ht:new Error(ht)})):B.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"))},B=new InternalRenderTask({callback:Y,params:{canvasContext:s,viewport:n,transform:p,imageLayer:t,background:i},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:u,operatorList:X.operatorList,pageIndex:this._pageIndex,canvasFactory:tt,useRequestAnimationFrame:!K,pdfBug:this._pdfBug,pageColors:d});(X.renderTasks||(X.renderTasks=new Set)).add(B);const q=B.task;return Promise.all([X.displayReadyCapability.promise,a]).then(([ht,yt])=>{if(this.pendingCleanup){Y();return}this._stats&&this._stats.time("Rendering"),B.initializeGraphics({transparency:ht,optionalContentConfig:yt}),B.operatorListChanged()}).catch(Y),q}getOperatorList({intent:s="display",annotationMode:n=_util.AnnotationMode.ENABLE,printAnnotationStorage:o=null}={}){function y(){t.operatorList.lastChunk&&(t.opListReadCapability.resolve(t.operatorList),t.renderTasks.delete(e))}const p=this._transport.getRenderingIntent(s,n,o,!0);let t=this._intentStates.get(p.cacheKey);t||(t=Object.create(null),this._intentStates.set(p.cacheKey,t));let e;return t.opListReadCapability||(e=Object.create(null),e.operatorListChanged=y,t.opListReadCapability=(0,_util.createPromiseCapability)(),(t.renderTasks||(t.renderTasks=new Set)).add(e),t.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList(p)),t.opListReadCapability.promise}streamTextContent({disableCombineTextItems:s=!1,includeMarkedContent:n=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,combineTextItems:s!==!0,includeMarkedContent:n===!0},{highWaterMark:100,size(y){return y.items.length}})}getTextContent(s={}){if(this._transport._htmlForXfa)return this.getXfa().then(o=>_xfa_text.XfaText.textContent(o));const n=this.streamTextContent(s);return new Promise(function(o,y){function p(){t.read().then(function({value:i,done:a}){if(a){o(e);return}Object.assign(e.styles,i.styles),e.items.push(...i.items),p()},y)}const t=n.getReader(),e={items:[],styles:Object.create(null)};p()})}getStructTree(){return this._structTreePromise||(this._structTreePromise=this._transport.getStructTree(this._pageIndex))}_destroy(){this.destroyed=!0;const s=[];for(const n of this._intentStates.values())if(this._abortOperatorList({intentState:n,reason:new Error("Page was destroyed."),force:!0}),!n.opListReadCapability)for(const o of n.renderTasks)s.push(o.completed),o.cancel();this.objs.clear();for(const n of this._bitmaps)n.close();return this._bitmaps.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,this.pendingCleanup=!1,Promise.all(s)}cleanup(s=!1){return this.pendingCleanup=!0,this._tryCleanup(s)}_tryCleanup(s=!1){if(!this.pendingCleanup)return!1;for(const{renderTasks:n,operatorList:o}of this._intentStates.values())if(n.size>0||!o.lastChunk)return!1;this._intentStates.clear(),this.objs.clear(),this._annotationPromises.clear(),this._jsActionsPromise=null,this._structTreePromise=null,s&&this._stats&&(this._stats=new _display_utils.StatTimer);for(const n of this._bitmaps)n.close();return this._bitmaps.clear(),this.pendingCleanup=!1,!0}_startRenderPage(s,n){const o=this._intentStates.get(n);o&&(this._stats&&this._stats.timeEnd("Page Request"),o.displayReadyCapability&&o.displayReadyCapability.resolve(s))}_renderPageChunk(s,n){for(let o=0,y=s.length;o<y;o++)n.operatorList.fnArray.push(s.fnArray[o]),n.operatorList.argsArray.push(s.argsArray[o]);n.operatorList.lastChunk=s.lastChunk,n.operatorList.separateAnnots=s.separateAnnots;for(const o of n.renderTasks)o.operatorListChanged();s.lastChunk&&this._tryCleanup()}_pumpOperatorList({renderingIntent:s,cacheKey:n,annotationStorageMap:o}){const p=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:s,cacheKey:n,annotationStorage:o}).getReader(),t=this._intentStates.get(n);t.streamReader=p;const e=()=>{p.read().then(({value:i,done:a})=>{if(a){t.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(i,t),e())},i=>{if(t.streamReader=null,!this._transport.destroyed){if(t.operatorList){t.operatorList.lastChunk=!0;for(const a of t.renderTasks)a.operatorListChanged();this._tryCleanup()}if(t.displayReadyCapability)t.displayReadyCapability.reject(i);else if(t.opListReadCapability)t.opListReadCapability.reject(i);else throw i}})};e()}_abortOperatorList({intentState:s,reason:n,force:o=!1}){if(s.streamReader){if(!o){if(s.renderTasks.size>0)return;if(n instanceof _display_utils.RenderingCancelledException){s.streamReaderCancelTimeout=setTimeout(()=>{this._abortOperatorList({intentState:s,reason:n,force:!0}),s.streamReaderCancelTimeout=null},RENDERING_CANCELLED_TIMEOUT);return}}if(s.streamReader.cancel(new _util.AbortException(n.message)).catch(()=>{}),s.streamReader=null,!this._transport.destroyed){for(const[y,p]of this._intentStates)if(p===s){this._intentStates.delete(y);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){this._listeners=[],this._deferred=Promise.resolve()}postMessage(s,n){const o={data:structuredClone(s,n)};this._deferred.then(()=>{for(const y of this._listeners)y.call(this,o)})}addEventListener(s,n){this._listeners.push(n)}removeEventListener(s,n){const o=this._listeners.indexOf(n);this._listeners.splice(o,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;{if(_is_node.isNodeJS&&typeof commonjsRequire=="function")PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if(typeof document=="object"){const l=(U=document==null?void 0:document.currentScript)==null?void 0:U.src;l&&(PDFWorkerUtil.fallbackWorkerSrc=l.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(l,s){let n;try{if(n=new URL(l),!n.origin||n.origin==="null")return!1}catch{return!1}const o=new URL(s,n);return n.origin===o.origin},PDFWorkerUtil.createCDNWrapper=function(l){const s=`importScripts("${l}");`;return URL.createObjectURL(new Blob([s]))}}const _PDFWorker=class _PDFWorker{constructor({name:l=null,port:s=null,verbosity:n=(0,_util.getVerbosityLevel)()}={}){if(s&&C(_PDFWorker,_).has(s))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=l,this.destroyed=!1,this.verbosity=n,this._readyCapability=(0,_util.createPromiseCapability)(),this._port=null,this._webWorker=null,this._messageHandler=null,s){C(_PDFWorker,_).set(s,this),this._initializeFromPort(s);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(l){this._port=l,this._messageHandler=new _message_handler.MessageHandler("main","worker",l),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve()}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:l}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,l)||(l=PDFWorkerUtil.createCDNWrapper(new URL(l,window.location).href));const s=new Worker(l),n=new _message_handler.MessageHandler("main","worker",s),o=()=>{s.removeEventListener("error",y),n.destroy(),s.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},y=()=>{this._webWorker||o()};s.addEventListener("error",y),n.on("test",t=>{if(s.removeEventListener("error",y),this.destroyed){o();return}t?(this._messageHandler=n,this._port=s,this._webWorker=s,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),n.destroy(),s.terminate())}),n.on("ready",t=>{if(s.removeEventListener("error",y),this.destroyed){o();return}try{p()}catch{this._setupFakeWorker()}});const p=()=>{const t=new Uint8Array;n.send("test",t,[t.buffer])};p();return}catch{(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then(l=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const s=new LoopbackPort;this._port=s;const n=`fake${PDFWorkerUtil.fakeWorkerId++}`,o=new _message_handler.MessageHandler(n+"_worker",n,s);l.setup(o,s);const y=new _message_handler.MessageHandler(n,n+"_worker",s);this._messageHandler=y,this._readyCapability.resolve(),y.send("configure",{verbosity:this.verbosity})}).catch(l=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${l.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),C(_PDFWorker,_).delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(l){if(!(l!=null&&l.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return C(this,_).has(l.port)?C(this,_).get(l.port):new _PDFWorker(l)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(PDFWorkerUtil.fallbackWorkerSrc!==null)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var l;try{return((l=globalThis.pdfjsWorker)==null?void 0:l.WorkerMessageHandler)||null}catch{return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&typeof commonjsRequire=="function"){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}};_=new WeakMap,at(_PDFWorker,_,new WeakMap);let PDFWorker=_PDFWorker;exports.PDFWorker=PDFWorker,PDFWorker.getWorkerSrc=function(){return(0,_display_utils.deprecated)("`PDFWorker.getWorkerSrc()`, please use `PDFWorker.workerSrc` instead."),this.workerSrc};class WorkerTransport{constructor(s,n,o,y){at(this,v,null);at(this,V,new Map);at(this,H,new Map);at(this,Q,null);this.messageHandler=s,this.loadingTask=n,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({docId:n.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),ownerDocument:y.ownerDocument,styleElement:y.styleElement}),this._params=y,y.useWorkerFetch||(this.CMapReaderFactory=new y.CMapReaderFactory({baseUrl:y.cMapUrl,isCompressed:y.cMapPacked}),this.StandardFontDataFactory=new y.StandardFontDataFactory({baseUrl:y.standardFontDataUrl})),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=o,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=(0,_util.createPromiseCapability)(),this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}get stats(){return C(this,v)}getRenderingIntent(s,n=_util.AnnotationMode.ENABLE,o=null,y=!1){let p=_util.RenderingIntentFlag.DISPLAY,t=null;switch(s){case"any":p=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":p=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${s}`)}switch(n){case _util.AnnotationMode.DISABLE:p+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:p+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:p+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,t=(p&_util.RenderingIntentFlag.PRINT&&o instanceof _annotation_storage.PrintAnnotationStorage?o:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${n}`)}return y&&(p+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:p,cacheKey:`${p}_${_annotation_storage.AnnotationStorage.getHash(t)}`,annotationStorageMap:t}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=(0,_util.createPromiseCapability)(),this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));const s=[];for(const o of C(this,V).values())s.push(o._destroy());C(this,V).clear(),C(this,H).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return s.push(n),Promise.all(s).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),mt(this,Q,null),this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null,this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:s,loadingTask:n}=this;s.on("GetReader",(o,y)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=p=>{this._lastProgress={loaded:p.loaded,total:p.total}},y.onPull=()=>{this._fullReader.read().then(function({value:p,done:t}){if(t){y.close();return}(0,_util.assert)((0,_util.isArrayBuffer)(p),"GetReader - expected an ArrayBuffer."),y.enqueue(new Uint8Array(p),1,[p])}).catch(p=>{y.error(p)})},y.onCancel=p=>{this._fullReader.cancel(p),y.ready.catch(t=>{if(!this.destroyed)throw t})}}),s.on("ReaderHeadersReady",o=>{const y=(0,_util.createPromiseCapability)(),p=this._fullReader;return p.headersReady.then(()=>{var t;(!p.isStreamingSupported||!p.isRangeSupported)&&(this._lastProgress&&((t=n.onProgress)==null||t.call(n,this._lastProgress)),p.onProgress=e=>{var i;(i=n.onProgress)==null||i.call(n,{loaded:e.loaded,total:e.total})}),y.resolve({isStreamingSupported:p.isStreamingSupported,isRangeSupported:p.isRangeSupported,contentLength:p.contentLength})},y.reject),y.promise}),s.on("GetRangeReader",(o,y)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const p=this._networkStream.getRangeReader(o.begin,o.end);if(!p){y.close();return}y.onPull=()=>{p.read().then(function({value:t,done:e}){if(e){y.close();return}(0,_util.assert)((0,_util.isArrayBuffer)(t),"GetRangeReader - expected an ArrayBuffer."),y.enqueue(new Uint8Array(t),1,[t])}).catch(t=>{y.error(t)})},y.onCancel=t=>{p.cancel(t),y.ready.catch(e=>{if(!this.destroyed)throw e})}}),s.on("GetDoc",({pdfInfo:o})=>{this._numPages=o.numPages,this._htmlForXfa=o.htmlForXfa,delete o.htmlForXfa,n._capability.resolve(new PDFDocumentProxy(o,this))}),s.on("DocException",function(o){let y;switch(o.name){case"PasswordException":y=new _util.PasswordException(o.message,o.code);break;case"InvalidPDFException":y=new _util.InvalidPDFException(o.message);break;case"MissingPDFException":y=new _util.MissingPDFException(o.message);break;case"UnexpectedResponseException":y=new _util.UnexpectedResponseException(o.message,o.status);break;case"UnknownErrorException":y=new _util.UnknownErrorException(o.message,o.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}n._capability.reject(y)}),s.on("PasswordRequest",o=>{if(this._passwordCapability=(0,_util.createPromiseCapability)(),n.onPassword){const y=p=>{p instanceof Error?this._passwordCapability.reject(p):this._passwordCapability.resolve({password:p})};try{n.onPassword(y,o.code)}catch(p){this._passwordCapability.reject(p)}}else this._passwordCapability.reject(new _util.PasswordException(o.message,o.code));return this._passwordCapability.promise}),s.on("DataLoaded",o=>{var y;(y=n.onProgress)==null||y.call(n,{loaded:o.length,total:o.length}),this.downloadInfoCapability.resolve(o)}),s.on("StartRenderPage",o=>{if(this.destroyed)return;C(this,V).get(o.pageIndex)._startRenderPage(o.transparency,o.cacheKey)}),s.on("commonobj",([o,y,p])=>{var t;if(!this.destroyed&&!this.commonObjs.has(o))switch(y){case"Font":const e=this._params;if("error"in p){const u=p.error;(0,_util.warn)(`Error during font loading: ${u}`),this.commonObjs.resolve(o,u);break}let i=null;e.pdfBug&&((t=globalThis.FontInspector)!=null&&t.enabled)&&(i={registerFont(u,d){globalThis.FontInspector.fontAdded(u,d)}});const a=new _font_loader.FontFaceObject(p,{isEvalSupported:e.isEvalSupported,disableFontFace:e.disableFontFace,ignoreErrors:e.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:i});this.fontLoader.bind(a).catch(u=>s.sendWithPromise("FontFallback",{id:o})).finally(()=>{!e.fontExtraProperties&&a.data&&(a.data=null),this.commonObjs.resolve(o,a)});break;case"FontPath":case"Image":this.commonObjs.resolve(o,p);break;default:throw new Error(`Got unknown common object type ${y}`)}}),s.on("obj",([o,y,p,t])=>{var i;if(this.destroyed)return;const e=C(this,V).get(y);if(!e.objs.has(o))switch(p){case"Image":e.objs.resolve(o,t);const a=8e6;if(t){let u;if(t.bitmap){const{bitmap:d,width:c,height:S}=t;u=c*S*4,e._bitmaps.add(d)}else u=((i=t.data)==null?void 0:i.length)||0;u>a&&(e.cleanupAfterRender=!0)}break;case"Pattern":e.objs.resolve(o,t);break;default:throw new Error(`Got unknown object type ${p}`)}}),s.on("DocProgress",o=>{var y;this.destroyed||(y=n.onProgress)==null||y.call(n,{loaded:o.loaded,total:o.total})}),s.on("DocStats",o=>{this.destroyed||mt(this,v,Object.freeze({streamTypes:Object.freeze(o.streamTypes),fontTypes:Object.freeze(o.fontTypes)}))}),s.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this)),s.on("FetchBuiltInCMap",o=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.CMapReaderFactory?this.CMapReaderFactory.fetch(o):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),s.on("FetchStandardFontData",o=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.StandardFontDataFactory?this.StandardFontDataFactory.fetch(o):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}_onUnsupportedFeature({featureId:s}){var n,o;this.destroyed||(o=(n=this.loadingTask).onUnsupportedFeature)==null||o.call(n,s)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(s){if(!Number.isInteger(s)||s<=0||s>this._numPages)return Promise.reject(new Error("Invalid page request."));const n=s-1,o=C(this,H).get(n);if(o)return o;const y=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(p=>{if(this.destroyed)throw new Error("Transport destroyed");const t=new PDFPageProxy(n,p,this,this._params.ownerDocument,this._params.pdfBug);return C(this,V).set(n,t),t});return C(this,H).set(n,y),y}getPageIndex(s){return typeof s!="object"||s===null||!Number.isInteger(s.num)||s.num<0||!Number.isInteger(s.gen)||s.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:s.num,gen:s.gen})}getAnnotations(s,n){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:s,intent:n})}saveDocument(){var s;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:this.annotationStorage.serializable,filename:((s=this._fullReader)==null?void 0:s.filename)??null}).finally(()=>{this.annotationStorage.resetModified()})}getFieldObjects(){return this._getFieldObjectsPromise||(this._getFieldObjectsPromise=this.messageHandler.sendWithPromise("GetFieldObjects",null))}hasJSActions(){return this._hasJSActionsPromise||(this._hasJSActionsPromise=this.messageHandler.sendWithPromise("HasJSActions",null))}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(s){return typeof s!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:s})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(s){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:s})}getStructTree(s){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:s})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then(s=>new _optional_content_config.OptionalContentConfig(s))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return C(this,Q)||mt(this,Q,this.messageHandler.sendWithPromise("GetMetadata",null).then(s=>{var n,o;return{info:s[0],metadata:s[1]?new _metadata.Metadata(s[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(s=!1){if(await this.messageHandler.sendWithPromise("Cleanup",null),!this.destroyed){for(const n of C(this,V).values())if(!n.cleanup())throw new Error(`startCleanup: Page ${n.pageNumber} is currently rendering.`);this.commonObjs.clear(),s||this.fontLoader.clear(),mt(this,Q,null),this._getFieldObjectsPromise=null,this._hasJSActionsPromise=null}}get loadingParams(){const s=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:s.disableAutoFetch,enableXfa:s.enableXfa})}}v=new WeakMap,V=new WeakMap,H=new WeakMap,Q=new WeakMap;class PDFObjects{constructor(){at(this,A);at(this,N,Object.create(null))}get(s,n=null){if(n){const y=ct(this,A,oe).call(this,s);return y.capability.promise.then(()=>n(y.data)),null}const o=C(this,N)[s];if(!(o!=null&&o.capability.settled))throw new Error(`Requesting object that isn't resolved yet ${s}.`);return o.data}has(s){const n=C(this,N)[s];return(n==null?void 0:n.capability.settled)||!1}resolve(s,n=null){const o=ct(this,A,oe).call(this,s);o.data=n,o.capability.resolve()}clear(){mt(this,N,Object.create(null))}}N=new WeakMap,A=new WeakSet,oe=function(s){const n=C(this,N)[s];return n||(C(this,N)[s]={capability:(0,_util.createPromiseCapability)(),data:null})};class RenderTask{constructor(s){at(this,M,null);mt(this,M,s),this.onContinue=null}get promise(){return C(this,M).capability.promise}cancel(){C(this,M).cancel()}get separateAnnots(){const{separateAnnots:s}=C(this,M).operatorList;if(!s)return!1;const{annotationCanvasMap:n}=C(this,M);return s.form||s.canvas&&(n==null?void 0:n.size)>0}}M=new WeakMap,exports.RenderTask=RenderTask;const w=class w{constructor({callback:s,params:n,objs:o,commonObjs:y,annotationCanvasMap:p,operatorList:t,pageIndex:e,canvasFactory:i,useRequestAnimationFrame:a=!1,pdfBug:u=!1,pageColors:d=null}){this.callback=s,this.params=n,this.objs=o,this.commonObjs=y,this.annotationCanvasMap=p,this.operatorListIdx=null,this.operatorList=t,this._pageIndex=e,this.canvasFactory=i,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=a===!0&&typeof window<"u",this.cancelled=!1,this.capability=(0,_util.createPromiseCapability)(),this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=n.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:s=!1,optionalContentConfig:n}){var i;if(this.cancelled)return;if(this._canvas){if(C(w,P).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");C(w,P).add(this._canvas)}this._pdfBug&&((i=globalThis.StepperManager)!=null&&i.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:o,viewport:y,transform:p,imageLayer:t,background:e}=this.params;this.gfx=new _canvas.CanvasGraphics(o,this.commonObjs,this.objs,this.canvasFactory,t,n,this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:p,viewport:y,transparency:s,background:e}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback&&this.graphicsReadyCallback()}cancel(s=null){this.running=!1,this.cancelled=!0,this.gfx&&this.gfx.endDrawing(),this._canvas&&C(w,P).delete(this._canvas),this.callback(s||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,"canvas"))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}this.stepper&&this.stepper.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame(()=>{this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),this._canvas&&C(w,P).delete(this._canvas),this.callback())))}};P=new WeakMap,at(w,P,new WeakSet);let InternalRenderTask=w;const version="2.16.105";exports.version=version;const build="172ccdbe5";exports.build=build},(nt,g,U)=>{var N,we,k;Object.defineProperty(g,"__esModule",{value:!0}),g.PrintAnnotationStorage=g.AnnotationStorage=void 0;var _=U(1),v=U(6),V=U(10);class H{constructor(){at(this,N);this._storage=new Map,this._modified=!1,this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(P,w){const l=this._storage.get(P);return l===void 0?w:Object.assign(w,l)}getRawValue(P){return this._storage.get(P)}remove(P){if(this._storage.delete(P),this._storage.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const w of this._storage.values())if(w instanceof v.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(P,w){const l=this._storage.get(P);let s=!1;if(l!==void 0)for(const[n,o]of Object.entries(w))l[n]!==o&&(s=!0,l[n]=o);else s=!0,this._storage.set(P,w);s&&ct(this,N,we).call(this),w instanceof v.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(w.constructor._type)}has(P){return this._storage.has(P)}getAll(){return this._storage.size>0?(0,_.objectFromMap)(this._storage):null}get size(){return this._storage.size}resetModified(){this._modified&&(this._modified=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Q(this)}get serializable(){if(this._storage.size===0)return null;const P=new Map;for(const[w,l]of this._storage){const s=l instanceof v.AnnotationEditor?l.serialize():l;s&&P.set(w,s)}return P}static getHash(P){if(!P)return"";const w=new V.MurmurHash3_64;for(const[l,s]of P)w.update(`${l}:${JSON.stringify(s)}`);return w.hexdigest()}}N=new WeakSet,we=function(){this._modified||(this._modified=!0,typeof this.onSetModified=="function"&&this.onSetModified())},g.AnnotationStorage=H;class Q extends H{constructor(w){super();at(this,k,null);mt(this,k,structuredClone(w.serializable))}get print(){(0,_.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return C(this,k)}}k=new WeakMap,g.PrintAnnotationStorage=Q},(nt,g,U)=>{var H,Q,N,A,k,M;Object.defineProperty(g,"__esModule",{value:!0}),g.AnnotationEditor=void 0;var _=U(7),v=U(1);const P=class P{constructor(l){at(this,H,this.focusin.bind(this));at(this,Q,this.focusout.bind(this));at(this,N,!1);at(this,A,!1);at(this,k,!1);at(this,M,P._zIndex++);this.constructor===P&&(0,v.unreachable)("Cannot initialize AnnotationEditor."),this.parent=l.parent,this.id=l.id,this.width=this.height=null,this.pageIndex=l.parent.pageIndex,this.name=l.name,this.div=null;const[s,n]=this.parent.viewportBaseDimensions;this.x=l.x/s,this.y=l.y/n,this.rotation=this.parent.viewport.rotation,this.isAttachedToDOM=!1}static get _defaultLineColor(){return(0,v.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=C(this,M)}focusin(l){C(this,N)?mt(this,N,!1):this.parent.setSelected(this)}focusout(l){if(!this.isAttachedToDOM)return;const s=l.relatedTarget;s!=null&&s.closest(`#${this.id}`)||(l.preventDefault(),this.parent.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.parent.addToAnnotationStorage(this)}dragstart(l){const s=this.parent.div.getBoundingClientRect();this.startX=l.clientX-s.x,this.startY=l.clientY-s.y,l.dataTransfer.setData("text/plain",this.id),l.dataTransfer.effectAllowed="move"}setAt(l,s,n,o){const[y,p]=this.parent.viewportBaseDimensions;[n,o]=this.screenToPageTranslation(n,o),this.x=(l+n)/y,this.y=(s+o)/p,this.div.style.left=`${100*this.x}%`,this.div.style.top=`${100*this.y}%`}translate(l,s){const[n,o]=this.parent.viewportBaseDimensions;[l,s]=this.screenToPageTranslation(l,s),this.x+=l/n,this.y+=s/o,this.div.style.left=`${100*this.x}%`,this.div.style.top=`${100*this.y}%`}screenToPageTranslation(l,s){const{rotation:n}=this.parent.viewport;switch(n){case 90:return[s,-l];case 180:return[-l,-s];case 270:return[-s,l];default:return[l,s]}}setDims(l,s){const[n,o]=this.parent.viewportBaseDimensions;this.div.style.width=`${100*l/n}%`,this.div.style.height=`${100*s/o}%`}getInitialTranslation(){return[0,0]}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",C(this,H)),this.div.addEventListener("focusout",C(this,Q));const[l,s]=this.getInitialTranslation();return this.translate(l,s),(0,_.bindEvents)(this,this.div,["dragstart","pointerdown"]),this.div}pointerdown(l){const s=_.KeyboardManager.platform.isMac;if(l.button!==0||l.ctrlKey&&s){l.preventDefault();return}l.ctrlKey&&!s||l.shiftKey||l.metaKey&&s?this.parent.toggleSelected(this):this.parent.setSelected(this),mt(this,N,!0)}getRect(l,s){const[n,o]=this.parent.viewportBaseDimensions,[y,p]=this.parent.pageDimensions,t=y*l/n,e=p*s/o,i=this.x*y,a=this.y*p,u=this.width*y,d=this.height*p;switch(this.rotation){case 0:return[i+t,p-a-e-d,i+t+u,p-a-e];case 90:return[i+e,p-a+t,i+e+d,p-a+t+u];case 180:return[i-t-u,p-a+e,i-t,p-a+e+d];case 270:return[i-e-d,p-a-t-u,i-e,p-a-t];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(l,s){const[n,o,y,p]=l,t=y-n,e=p-o;switch(this.rotation){case 0:return[n,s-p,t,e];case 90:return[n,s-o,e,t];case 180:return[y,s-o,t,e];case 270:return[y,s-p,e,t];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){mt(this,k,!0)}disableEditMode(){mt(this,k,!1)}isInEditMode(){return C(this,k)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var l;(l=this.div)==null||l.addEventListener("focusin",C(this,H))}serialize(){(0,v.unreachable)("An editor must be serializable")}static deserialize(l,s){const n=new this.prototype.constructor({parent:s,id:s.getNextId()});n.rotation=l.rotation;const[o,y]=s.pageDimensions,[p,t,e,i]=n.getRectInCurrentCoords(l.rect,y);return n.x=p/o,n.y=t/y,n.width=e/o,n.height=i/y,n}remove(){this.div.removeEventListener("focusin",C(this,H)),this.div.removeEventListener("focusout",C(this,Q)),this.isEmpty()||this.commit(),this.parent.remove(this)}select(){var l;(l=this.div)==null||l.classList.add("selectedEditor")}unselect(){var l;(l=this.div)==null||l.classList.remove("selectedEditor")}updateParams(l,s){}disableEditing(){}enableEditing(){}get propertiesToUpdate(){return{}}get contentDiv(){return this.div}get isEditing(){return C(this,A)}set isEditing(l){mt(this,A,l),l?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}};H=new WeakMap,Q=new WeakMap,N=new WeakMap,A=new WeakMap,k=new WeakMap,M=new WeakMap,Mt(P,"_colorManager",new _.ColorManager),Mt(P,"_zIndex",1);let V=P;g.AnnotationEditor=V},(nt,g,U)=>{var w,l,s,n,o,y,Pe,e,a,u,d,c,S,X,tt,K,Y,B,q,$,it,ht,yt,O,f,h,Ee,F,le,I,jt,z,Jt,m,Ce,x,Te,L,he,dt,Qt,ot,te;Object.defineProperty(g,"__esModule",{value:!0}),g.KeyboardManager=g.CommandManager=g.ColorManager=g.AnnotationEditorUIManager=void 0,g.bindEvents=V,g.opacityToHex=H;var _=U(1),v=U(8);function V(pt,R,ut){for(const _t of ut)R.addEventListener(_t,pt[_t].bind(pt))}function H(pt){return Math.round(Math.min(255,Math.max(1,255*pt))).toString(16).padStart(2,"0")}class Q{constructor(){at(this,w,0)}getId(){return`${_.AnnotationEditorPrefix}${ae(this,w)._++}`}}w=new WeakMap;class N{constructor(R=128){at(this,l,[]);at(this,s,!1);at(this,n,void 0);at(this,o,-1);mt(this,n,R)}add({cmd:R,undo:ut,mustExec:_t,type:St=NaN,overwriteIfSameType:xt=!1,keepUndo:Et=!1}){if(_t&&R(),C(this,s))return;const Ft={cmd:R,undo:ut,type:St};if(C(this,o)===-1){C(this,l).length>0&&(C(this,l).length=0),mt(this,o,0),C(this,l).push(Ft);return}if(xt&&C(this,l)[C(this,o)].type===St){Et&&(Ft.undo=C(this,l)[C(this,o)].undo),C(this,l)[C(this,o)]=Ft;return}const Rt=C(this,o)+1;Rt===C(this,n)?C(this,l).splice(0,1):(mt(this,o,Rt),Rt<C(this,l).length&&C(this,l).splice(Rt)),C(this,l).push(Ft)}undo(){C(this,o)!==-1&&(mt(this,s,!0),C(this,l)[C(this,o)].undo(),mt(this,s,!1),mt(this,o,C(this,o)-1))}redo(){C(this,o)<C(this,l).length-1&&(mt(this,o,C(this,o)+1),mt(this,s,!0),C(this,l)[C(this,o)].cmd(),mt(this,s,!1))}hasSomethingToUndo(){return C(this,o)!==-1}hasSomethingToRedo(){return C(this,o)<C(this,l).length-1}destroy(){mt(this,l,null)}}l=new WeakMap,s=new WeakMap,n=new WeakMap,o=new WeakMap,g.CommandManager=N;const t=class t{constructor(R){at(this,y);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const ut=t.platform.isMac;for(const[_t,St]of R)for(const xt of _t){const Et=xt.startsWith("mac+");ut&&Et?(this.callbacks.set(xt.slice(4),St),this.allKeys.add(xt.split("+").at(-1))):!ut&&!Et&&(this.callbacks.set(xt,St),this.allKeys.add(xt.split("+").at(-1)))}}static get platform(){const R=typeof navigator<"u"?navigator.platform:"";return(0,_.shadow)(this,"platform",{isWin:R.includes("Win"),isMac:R.includes("Mac")})}exec(R,ut){if(!this.allKeys.has(ut.key))return;const _t=this.callbacks.get(ct(this,y,Pe).call(this,ut));_t&&(_t.bind(R)(),ut.stopPropagation(),ut.preventDefault())}};y=new WeakSet,Pe=function(R){R.altKey&&this.buffer.push("alt"),R.ctrlKey&&this.buffer.push("ctrl"),R.metaKey&&this.buffer.push("meta"),R.shiftKey&&this.buffer.push("shift"),this.buffer.push(R.key);const ut=this.buffer.join("+");return this.buffer.length=0,ut};let A=t;g.KeyboardManager=A;class k{constructor(){at(this,e,null)}copy(R){R&&(Array.isArray(R)?mt(this,e,R.map(ut=>ut.serialize())):mt(this,e,[R.serialize()]),mt(this,e,C(this,e).filter(ut=>!!ut)),C(this,e).length===0&&mt(this,e,null))}paste(){return C(this,e)}isEmpty(){return C(this,e)===null}destroy(){mt(this,e,null)}}e=new WeakMap;const i=class i{get _colors(){const R=new Map([["CanvasText",null],["Canvas",null]]);return(0,v.getColorValues)(R),(0,_.shadow)(this,"_colors",R)}convert(R){const ut=(0,v.getRGB)(R);if(!window.matchMedia("(forced-colors: active)").matches)return ut;for(const[_t,St]of this._colors)if(St.every((xt,Et)=>xt===ut[Et]))return i._colorsMapping.get(_t);return ut}getHexCode(R){const ut=this._colors.get(R);return ut?_.Util.makeHexColor(...ut):R}};Mt(i,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let M=i;g.ColorManager=M;const lt=class lt{constructor(R,ut){at(this,h);at(this,F);at(this,I);at(this,z);at(this,m);at(this,x);at(this,L);at(this,dt);at(this,ot);at(this,a,null);at(this,u,new Map);at(this,d,new Map);at(this,c,new k);at(this,S,new N);at(this,X,0);at(this,tt,null);at(this,K,null);at(this,Y,new Q);at(this,B,!1);at(this,q,_.AnnotationEditorType.NONE);at(this,$,new Set);at(this,it,this.keydown.bind(this));at(this,ht,this.onEditingAction.bind(this));at(this,yt,this.onPageChanging.bind(this));at(this,O,{isEditing:!1,isEmpty:!0,hasEmptyClipboard:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1});at(this,f,null);mt(this,f,R),mt(this,K,ut),C(this,K)._on("editingaction",C(this,ht)),C(this,K)._on("pagechanging",C(this,yt))}destroy(){ct(this,F,le).call(this),C(this,K)._off("editingaction",C(this,ht)),C(this,K)._off("pagechanging",C(this,yt));for(const R of C(this,d).values())R.destroy();C(this,d).clear(),C(this,u).clear(),mt(this,a,null),C(this,$).clear(),C(this,c).destroy(),C(this,S).destroy()}onPageChanging({pageNumber:R}){mt(this,X,R-1)}focusMainContainer(){C(this,f).focus()}keydown(R){var ut;(ut=this.getActive())!=null&&ut.shouldGetKeyboardEvents()||lt._keyboardManager.exec(this,R)}onEditingAction(R){["undo","redo","cut","copy","paste","delete","selectAll"].includes(R.name)&&this[R.name]()}setEditingState(R){R?(ct(this,h,Ee).call(this),ct(this,I,jt).call(this,{isEditing:C(this,q)!==_.AnnotationEditorType.NONE,isEmpty:ct(this,dt,Qt).call(this),hasSomethingToUndo:C(this,S).hasSomethingToUndo(),hasSomethingToRedo:C(this,S).hasSomethingToRedo(),hasSelectedEditor:!1,hasEmptyClipboard:C(this,c).isEmpty()})):(ct(this,F,le).call(this),ct(this,I,jt).call(this,{isEditing:!1}))}registerEditorTypes(R){mt(this,tt,R);for(const ut of C(this,tt))ct(this,z,Jt).call(this,ut.defaultPropertiesToUpdate)}getId(){return C(this,Y).getId()}addLayer(R){C(this,d).set(R.pageIndex,R),C(this,B)?R.enable():R.disable()}removeLayer(R){C(this,d).delete(R.pageIndex)}updateMode(R){if(mt(this,q,R),R===_.AnnotationEditorType.NONE)this.setEditingState(!1),ct(this,x,Te).call(this);else{this.setEditingState(!0),ct(this,m,Ce).call(this);for(const ut of C(this,d).values())ut.updateMode(R)}}updateToolbar(R){R!==C(this,q)&&C(this,K).dispatch("switchannotationeditormode",{source:this,mode:R})}updateParams(R,ut){for(const _t of C(this,$))_t.updateParams(R,ut);for(const _t of C(this,tt))_t.updateDefaultParams(R,ut)}getEditors(R){const ut=[];for(const _t of C(this,u).values())_t.pageIndex===R&&ut.push(_t);return ut}getEditor(R){return C(this,u).get(R)}addEditor(R){C(this,u).set(R.id,R)}removeEditor(R){C(this,u).delete(R.id),this.unselect(R)}setActiveEditor(R){C(this,a)!==R&&(mt(this,a,R),R&&ct(this,z,Jt).call(this,R.propertiesToUpdate))}toggleSelected(R){if(C(this,$).has(R)){C(this,$).delete(R),R.unselect(),ct(this,I,jt).call(this,{hasSelectedEditor:this.hasSelection});return}C(this,$).add(R),R.select(),ct(this,z,Jt).call(this,R.propertiesToUpdate),ct(this,I,jt).call(this,{hasSelectedEditor:!0})}setSelected(R){for(const ut of C(this,$))ut!==R&&ut.unselect();C(this,$).clear(),C(this,$).add(R),R.select(),ct(this,z,Jt).call(this,R.propertiesToUpdate),ct(this,I,jt).call(this,{hasSelectedEditor:!0})}isSelected(R){return C(this,$).has(R)}unselect(R){R.unselect(),C(this,$).delete(R),ct(this,I,jt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return C(this,$).size!==0}undo(){C(this,S).undo(),ct(this,I,jt).call(this,{hasSomethingToUndo:C(this,S).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:ct(this,dt,Qt).call(this)})}redo(){C(this,S).redo(),ct(this,I,jt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:C(this,S).hasSomethingToRedo(),isEmpty:ct(this,dt,Qt).call(this)})}addCommands(R){C(this,S).add(R),ct(this,I,jt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:ct(this,dt,Qt).call(this)})}delete(){if(C(this,a)&&C(this,a).commitOrRemove(),!this.hasSelection)return;const R=[...C(this,$)],ut=()=>{for(const St of R)St.remove()},_t=()=>{for(const St of R)ct(this,L,he).call(this,St)};this.addCommands({cmd:ut,undo:_t,mustExec:!0})}copy(){if(C(this,a)&&C(this,a).commitOrRemove(),this.hasSelection){const R=[];for(const ut of C(this,$))ut.isEmpty()||R.push(ut);if(R.length===0)return;C(this,c).copy(R),ct(this,I,jt).call(this,{hasEmptyClipboard:!1})}}cut(){this.copy(),this.delete()}paste(){if(C(this,c).isEmpty())return;this.unselectAll();const R=C(this,d).get(C(this,X)),ut=C(this,c).paste().map(xt=>R.deserialize(xt)),_t=()=>{for(const xt of ut)ct(this,L,he).call(this,xt);ct(this,ot,te).call(this,ut)},St=()=>{for(const xt of ut)xt.remove()};this.addCommands({cmd:_t,undo:St,mustExec:!0})}selectAll(){for(const R of C(this,$))R.commit();ct(this,ot,te).call(this,C(this,u).values())}unselectAll(){if(C(this,a)){C(this,a).commitOrRemove();return}if(ct(this,ot,te).size!==0){for(const R of C(this,$))R.unselect();C(this,$).clear(),ct(this,I,jt).call(this,{hasSelectedEditor:!1})}}isActive(R){return C(this,a)===R}getActive(){return C(this,a)}getMode(){return C(this,q)}};a=new WeakMap,u=new WeakMap,d=new WeakMap,c=new WeakMap,S=new WeakMap,X=new WeakMap,tt=new WeakMap,K=new WeakMap,Y=new WeakMap,B=new WeakMap,q=new WeakMap,$=new WeakMap,it=new WeakMap,ht=new WeakMap,yt=new WeakMap,O=new WeakMap,f=new WeakMap,h=new WeakSet,Ee=function(){C(this,f).addEventListener("keydown",C(this,it))},F=new WeakSet,le=function(){C(this,f).removeEventListener("keydown",C(this,it))},I=new WeakSet,jt=function(R){Object.entries(R).some(([_t,St])=>C(this,O)[_t]!==St)&&C(this,K).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(C(this,O),R)})},z=new WeakSet,Jt=function(R){C(this,K).dispatch("annotationeditorparamschanged",{source:this,details:R})},m=new WeakSet,Ce=function(){if(!C(this,B)){mt(this,B,!0);for(const R of C(this,d).values())R.enable()}},x=new WeakSet,Te=function(){if(this.unselectAll(),C(this,B)){mt(this,B,!1);for(const R of C(this,d).values())R.disable()}},L=new WeakSet,he=function(R){const ut=C(this,d).get(R.pageIndex);ut?ut.addOrRebuild(R):this.addEditor(R)},dt=new WeakSet,Qt=function(){if(C(this,u).size===0)return!0;if(C(this,u).size===1)for(const R of C(this,u).values())return R.isEmpty();return!1},ot=new WeakSet,te=function(R){C(this,$).clear();for(const ut of R)ut.isEmpty()||(C(this,$).add(ut),ut.select());ct(this,I,jt).call(this,{hasSelectedEditor:!0})},Mt(lt,"_keyboardManager",new A([[["ctrl+a","mac+meta+a"],lt.prototype.selectAll],[["ctrl+c","mac+meta+c"],lt.prototype.copy],[["ctrl+v","mac+meta+v"],lt.prototype.paste],[["ctrl+x","mac+meta+x"],lt.prototype.cut],[["ctrl+z","mac+meta+z"],lt.prototype.undo],[["ctrl+y","ctrl+shift+Z","mac+meta+shift+Z"],lt.prototype.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete"],lt.prototype.delete],[["Escape","mac+Escape"],lt.prototype.unselectAll]]));let P=lt;g.AnnotationEditorUIManager=P},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.StatTimer=g.RenderingCancelledException=g.PixelsPerInch=g.PageViewport=g.PDFDateString=g.DOMStandardFontDataFactory=g.DOMSVGFactory=g.DOMCanvasFactory=g.DOMCMapReaderFactory=g.AnnotationPrefix=void 0,g.deprecated=i,g.getColorValues=S,g.getCurrentTransform=X,g.getCurrentTransformInverse=tt,g.getFilenameFromUrl=o,g.getPdfFilenameFromUrl=y,g.getRGB=c,g.getXfaPageViewport=d,g.isDataScheme=s,g.isPdfFile=n,g.isValidFetchUrl=t,g.loadScript=e;var _=U(9),v=U(1);const V="http://www.w3.org/2000/svg",H="pdfjs_internal_id_";g.AnnotationPrefix=H;const K=class K{};Mt(K,"CSS",96),Mt(K,"PDF",72),Mt(K,"PDF_TO_CSS_UNITS",K.CSS/K.PDF);let Q=K;g.PixelsPerInch=Q;class N extends _.BaseCanvasFactory{constructor({ownerDocument:B=globalThis.document}={}){super(),this._document=B}_createCanvas(B,q){const $=this._document.createElement("canvas");return $.width=B,$.height=q,$}}g.DOMCanvasFactory=N;async function A(Y,B=!1){if(t(Y,document.baseURI)){const q=await fetch(Y);if(!q.ok)throw new Error(q.statusText);return B?new Uint8Array(await q.arrayBuffer()):(0,v.stringToBytes)(await q.text())}return new Promise((q,$)=>{const it=new XMLHttpRequest;it.open("GET",Y,!0),B&&(it.responseType="arraybuffer"),it.onreadystatechange=()=>{if(it.readyState===XMLHttpRequest.DONE){if(it.status===200||it.status===0){let ht;if(B&&it.response?ht=new Uint8Array(it.response):!B&&it.responseText&&(ht=(0,v.stringToBytes)(it.responseText)),ht){q(ht);return}}$(new Error(it.statusText))}},it.send(null)})}class k extends _.BaseCMapReaderFactory{_fetchData(B,q){return A(B,this.isCompressed).then($=>({cMapData:$,compressionType:q}))}}g.DOMCMapReaderFactory=k;class M extends _.BaseStandardFontDataFactory{_fetchData(B){return A(B,!0)}}g.DOMStandardFontDataFactory=M;class P extends _.BaseSVGFactory{_createSVG(B){return document.createElementNS(V,B)}}g.DOMSVGFactory=P;class w{constructor({viewBox:B,scale:q,rotation:$,offsetX:it=0,offsetY:ht=0,dontFlip:yt=!1}){this.viewBox=B,this.scale=q,this.rotation=$,this.offsetX=it,this.offsetY=ht;const O=(B[2]+B[0])/2,f=(B[3]+B[1])/2;let h,E,F,D;switch($%=360,$<0&&($+=360),$){case 180:h=-1,E=0,F=0,D=1;break;case 90:h=0,E=1,F=1,D=0;break;case 270:h=0,E=-1,F=-1,D=0;break;case 0:h=1,E=0,F=0,D=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}yt&&(F=-F,D=-D);let I,G,z,r;h===0?(I=Math.abs(f-B[1])*q+it,G=Math.abs(O-B[0])*q+ht,z=Math.abs(B[3]-B[1])*q,r=Math.abs(B[2]-B[0])*q):(I=Math.abs(O-B[0])*q+it,G=Math.abs(f-B[1])*q+ht,z=Math.abs(B[2]-B[0])*q,r=Math.abs(B[3]-B[1])*q),this.transform=[h*q,E*q,F*q,D*q,I-h*q*O-F*q*f,G-E*q*O-D*q*f],this.width=z,this.height=r}clone({scale:B=this.scale,rotation:q=this.rotation,offsetX:$=this.offsetX,offsetY:it=this.offsetY,dontFlip:ht=!1}={}){return new w({viewBox:this.viewBox.slice(),scale:B,rotation:q,offsetX:$,offsetY:it,dontFlip:ht})}convertToViewportPoint(B,q){return v.Util.applyTransform([B,q],this.transform)}convertToViewportRectangle(B){const q=v.Util.applyTransform([B[0],B[1]],this.transform),$=v.Util.applyTransform([B[2],B[3]],this.transform);return[q[0],q[1],$[0],$[1]]}convertToPdfPoint(B,q){return v.Util.applyInverseTransform([B,q],this.transform)}}g.PageViewport=w;class l extends v.BaseException{constructor(B,q){super(B,"RenderingCancelledException"),this.type=q}}g.RenderingCancelledException=l;function s(Y){const B=Y.length;let q=0;for(;q<B&&Y[q].trim()==="";)q++;return Y.substring(q,q+5).toLowerCase()==="data:"}function n(Y){return typeof Y=="string"&&/\.pdf$/i.test(Y)}function o(Y){const B=Y.indexOf("#"),q=Y.indexOf("?"),$=Math.min(B>0?B:Y.length,q>0?q:Y.length);return Y.substring(Y.lastIndexOf("/",$)+1,$)}function y(Y,B="document.pdf"){if(typeof Y!="string")return B;if(s(Y))return(0,v.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),B;const q=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,$=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,it=q.exec(Y);let ht=$.exec(it[1])||$.exec(it[2])||$.exec(it[3]);if(ht&&(ht=ht[0],ht.includes("%")))try{ht=$.exec(decodeURIComponent(ht))[0]}catch{}return ht||B}class p{constructor(){this.started=Object.create(null),this.times=[]}time(B){B in this.started&&(0,v.warn)(`Timer is already running for ${B}`),this.started[B]=Date.now()}timeEnd(B){B in this.started||(0,v.warn)(`Timer has not been started for ${B}`),this.times.push({name:B,start:this.started[B],end:Date.now()}),delete this.started[B]}toString(){const B=[];let q=0;for(const $ of this.times){const it=$.name;it.length>q&&(q=it.length)}for(const $ of this.times){const it=$.end-$.start;B.push(`${$.name.padEnd(q)} ${it}ms
129
+ `)}return B.join("")}}g.StatTimer=p;function t(Y,B){try{const{protocol:q}=B?new URL(Y,B):new URL(Y);return q==="http:"||q==="https:"}catch{return!1}}function e(Y,B=!1){return new Promise((q,$)=>{const it=document.createElement("script");it.src=Y,it.onload=function(ht){B&&it.remove(),q(ht)},it.onerror=function(){$(new Error(`Cannot load script at: ${it.src}`))},(document.head||document.documentElement).append(it)})}function i(Y){console.log("Deprecated API usage: "+Y)}let a;class u{static toDateObject(B){if(!B||typeof B!="string")return null;a||(a=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const q=a.exec(B);if(!q)return null;const $=parseInt(q[1],10);let it=parseInt(q[2],10);it=it>=1&&it<=12?it-1:0;let ht=parseInt(q[3],10);ht=ht>=1&&ht<=31?ht:1;let yt=parseInt(q[4],10);yt=yt>=0&&yt<=23?yt:0;let O=parseInt(q[5],10);O=O>=0&&O<=59?O:0;let f=parseInt(q[6],10);f=f>=0&&f<=59?f:0;const h=q[7]||"Z";let E=parseInt(q[8],10);E=E>=0&&E<=23?E:0;let F=parseInt(q[9],10)||0;return F=F>=0&&F<=59?F:0,h==="-"?(yt+=E,O+=F):h==="+"&&(yt-=E,O-=F),new Date(Date.UTC($,it,ht,yt,O,f))}}g.PDFDateString=u;function d(Y,{scale:B=1,rotation:q=0}){const{width:$,height:it}=Y.attributes.style,ht=[0,0,parseInt($),parseInt(it)];return new w({viewBox:ht,scale:B,rotation:q})}function c(Y){if(Y.startsWith("#")){const B=parseInt(Y.slice(1),16);return[(B&16711680)>>16,(B&65280)>>8,B&255]}return Y.startsWith("rgb(")?Y.slice(4,-1).split(",").map(B=>parseInt(B)):Y.startsWith("rgba(")?Y.slice(5,-1).split(",").map(B=>parseInt(B)).slice(0,3):((0,v.warn)(`Not a valid color format: "${Y}"`),[0,0,0])}function S(Y){const B=document.createElement("span");B.style.visibility="hidden",document.body.append(B);for(const q of Y.keys()){B.style.color=q;const $=window.getComputedStyle(B).color;Y.set(q,c($))}B.remove()}function X(Y){const{a:B,b:q,c:$,d:it,e:ht,f:yt}=Y.getTransform();return[B,q,$,it,ht,yt]}function tt(Y){const{a:B,b:q,c:$,d:it,e:ht,f:yt}=Y.getTransform().invertSelf();return[B,q,$,it,ht,yt]}},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.BaseStandardFontDataFactory=g.BaseSVGFactory=g.BaseCanvasFactory=g.BaseCMapReaderFactory=void 0;var _=U(1);class v{constructor(){this.constructor===v&&(0,_.unreachable)("Cannot initialize BaseCanvasFactory.")}create(A,k){if(A<=0||k<=0)throw new Error("Invalid canvas size");const M=this._createCanvas(A,k);return{canvas:M,context:M.getContext("2d")}}reset(A,k,M){if(!A.canvas)throw new Error("Canvas is not specified");if(k<=0||M<=0)throw new Error("Invalid canvas size");A.canvas.width=k,A.canvas.height=M}destroy(A){if(!A.canvas)throw new Error("Canvas is not specified");A.canvas.width=0,A.canvas.height=0,A.canvas=null,A.context=null}_createCanvas(A,k){(0,_.unreachable)("Abstract method `_createCanvas` called.")}}g.BaseCanvasFactory=v;class V{constructor({baseUrl:A=null,isCompressed:k=!1}){this.constructor===V&&(0,_.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=A,this.isCompressed=k}async fetch({name:A}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!A)throw new Error("CMap name must be specified.");const k=this.baseUrl+A+(this.isCompressed?".bcmap":""),M=this.isCompressed?_.CMapCompressionType.BINARY:_.CMapCompressionType.NONE;return this._fetchData(k,M).catch(P=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${k}`)})}_fetchData(A,k){(0,_.unreachable)("Abstract method `_fetchData` called.")}}g.BaseCMapReaderFactory=V;class H{constructor({baseUrl:A=null}){this.constructor===H&&(0,_.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=A}async fetch({filename:A}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!A)throw new Error("Font filename must be specified.");const k=`${this.baseUrl}${A}`;return this._fetchData(k).catch(M=>{throw new Error(`Unable to load font data at: ${k}`)})}_fetchData(A){(0,_.unreachable)("Abstract method `_fetchData` called.")}}g.BaseStandardFontDataFactory=H;class Q{constructor(){this.constructor===Q&&(0,_.unreachable)("Cannot initialize BaseSVGFactory.")}create(A,k,M=!1){if(A<=0||k<=0)throw new Error("Invalid SVG dimensions");const P=this._createSVG("svg:svg");return P.setAttribute("version","1.1"),M||(P.setAttribute("width",`${A}px`),P.setAttribute("height",`${k}px`)),P.setAttribute("preserveAspectRatio","none"),P.setAttribute("viewBox",`0 0 ${A} ${k}`),P}createElement(A){if(typeof A!="string")throw new Error("Invalid SVG element type");return this._createSVG(A)}_createSVG(A){(0,_.unreachable)("Abstract method `_createSVG` called.")}}g.BaseSVGFactory=Q},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.MurmurHash3_64=void 0;var _=U(1);const v=3285377520,V=4294901760,H=65535;class Q{constructor(A){this.h1=A?A&4294967295:v,this.h2=A?A&4294967295:v}update(A){let k,M;if(typeof A=="string"){k=new Uint8Array(A.length*2),M=0;for(let a=0,u=A.length;a<u;a++){const d=A.charCodeAt(a);d<=255?k[M++]=d:(k[M++]=d>>>8,k[M++]=d&255)}}else if((0,_.isArrayBuffer)(A))k=A.slice(),M=k.byteLength;else throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");const P=M>>2,w=M-P*4,l=new Uint32Array(k.buffer,0,P);let s=0,n=0,o=this.h1,y=this.h2;const p=3432918353,t=461845907,e=p&H,i=t&H;for(let a=0;a<P;a++)a&1?(s=l[a],s=s*p&V|s*e&H,s=s<<15|s>>>17,s=s*t&V|s*i&H,o^=s,o=o<<13|o>>>19,o=o*5+3864292196):(n=l[a],n=n*p&V|n*e&H,n=n<<15|n>>>17,n=n*t&V|n*i&H,y^=n,y=y<<13|y>>>19,y=y*5+3864292196);switch(s=0,w){case 3:s^=k[P*4+2]<<16;case 2:s^=k[P*4+1]<<8;case 1:s^=k[P*4],s=s*p&V|s*e&H,s=s<<15|s>>>17,s=s*t&V|s*i&H,P&1?o^=s:y^=s}this.h1=o,this.h2=y}hexdigest(){let A=this.h1,k=this.h2;A^=k>>>1,A=A*3981806797&V|A*36045&H,k=k*4283543511&V|((k<<16|A>>>16)*2950163797&V)>>>16,A^=k>>>1,A=A*444984403&V|A*60499&H,k=k*3301882366&V|((k<<16|A>>>16)*3120437893&V)>>>16,A^=k>>>1;const M=(A>>>0).toString(16),P=(k>>>0).toString(16);return M.padStart(8,"0")+P.padStart(8,"0")}}g.MurmurHash3_64=Q},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.FontLoader=g.FontFaceObject=void 0;var _=U(1);class v{constructor({docId:N,onUnsupportedFeature:A,ownerDocument:k=globalThis.document,styleElement:M=null}){this.constructor===v&&(0,_.unreachable)("Cannot initialize BaseFontLoader."),this.docId=N,this._onUnsupportedFeature=A,this._document=k,this.nativeFontFaces=[],this.styleElement=null}addNativeFontFace(N){this.nativeFontFaces.push(N),this._document.fonts.add(N)}insertRule(N){let A=this.styleElement;A||(A=this.styleElement=this._document.createElement("style"),A.id=`PDFJS_FONT_STYLE_TAG_${this.docId}`,this._document.documentElement.getElementsByTagName("head")[0].append(A));const k=A.sheet;k.insertRule(N,k.cssRules.length)}clear(){for(const N of this.nativeFontFaces)this._document.fonts.delete(N);this.nativeFontFaces.length=0,this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async bind(N){if(N.attached||N.missingFile)return;if(N.attached=!0,this.isFontLoadingAPISupported){const k=N.createNativeFontFace();if(k){this.addNativeFontFace(k);try{await k.loaded}catch(M){throw this._onUnsupportedFeature({featureId:_.UNSUPPORTED_FEATURES.errorFontLoadNative}),(0,_.warn)(`Failed to load font '${k.family}': '${M}'.`),N.disableFontFace=!0,M}}return}const A=N.createFontFaceRule();if(A){if(this.insertRule(A),this.isSyncFontLoadingSupported)return;await new Promise(k=>{const M=this._queueLoadingCallback(k);this._prepareFontLoadEvent([A],[N],M)})}}_queueLoadingCallback(N){(0,_.unreachable)("Abstract method `_queueLoadingCallback`.")}get isFontLoadingAPISupported(){var A;const N=!!((A=this._document)!=null&&A.fonts);return(0,_.shadow)(this,"isFontLoadingAPISupported",N)}get isSyncFontLoadingSupported(){(0,_.unreachable)("Abstract method `isSyncFontLoadingSupported`.")}get _loadTestFont(){(0,_.unreachable)("Abstract method `_loadTestFont`.")}_prepareFontLoadEvent(N,A,k){(0,_.unreachable)("Abstract method `_prepareFontLoadEvent`.")}}let V;g.FontLoader=V,g.FontLoader=V=class extends v{constructor(N){super(N),this.loadingContext={requests:[],nextRequestId:0},this.loadTestFontId=0}get isSyncFontLoadingSupported(){let N=!1;if(typeof navigator>"u")N=!0;else{const A=/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);(A==null?void 0:A[1])>=14&&(N=!0)}return(0,_.shadow)(this,"isSyncFontLoadingSupported",N)}_queueLoadingCallback(N){function A(){for((0,_.assert)(!M.done,"completeRequest() cannot be called twice."),M.done=!0;k.requests.length>0&&k.requests[0].done;){const P=k.requests.shift();setTimeout(P.callback,0)}}const k=this.loadingContext,M={id:`pdfjs-font-loading-${k.nextRequestId++}`,done:!1,complete:A,callback:N};return k.requests.push(M),M}get _loadTestFont(){const N=function(){return atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==")};return(0,_.shadow)(this,"_loadTestFont",N())}_prepareFontLoadEvent(N,A,k){function M(tt,K){return tt.charCodeAt(K)<<24|tt.charCodeAt(K+1)<<16|tt.charCodeAt(K+2)<<8|tt.charCodeAt(K+3)&255}function P(tt,K,Y,B){const q=tt.substring(0,K),$=tt.substring(K+Y);return q+B+$}let w,l;const s=this._document.createElement("canvas");s.width=1,s.height=1;const n=s.getContext("2d");let o=0;function y(tt,K){if(o++,o>30){(0,_.warn)("Load test font never loaded."),K();return}if(n.font="30px "+tt,n.fillText(".",0,20),n.getImageData(0,0,1,1).data[3]>0){K();return}setTimeout(y.bind(null,tt,K))}const p=`lt${Date.now()}${this.loadTestFontId++}`;let t=this._loadTestFont;t=P(t,976,p.length,p);const i=16,a=1482184792;let u=M(t,i);for(w=0,l=p.length-3;w<l;w+=4)u=u-a+M(p,w)|0;w<p.length&&(u=u-a+M(p+"XXX",w)|0),t=P(t,i,4,(0,_.string32)(u));const d=`url(data:font/opentype;base64,${btoa(t)});`,c=`@font-face {font-family:"${p}";src:${d}}`;this.insertRule(c);const S=[];for(const tt of A)S.push(tt.loadedName);S.push(p);const X=this._document.createElement("div");X.style.visibility="hidden",X.style.width=X.style.height="10px",X.style.position="absolute",X.style.top=X.style.left="0px";for(const tt of S){const K=this._document.createElement("span");K.textContent="Hi",K.style.fontFamily=tt,X.append(K)}this._document.body.append(X),y(p,()=>{X.remove(),k.complete()})}};class H{constructor(N,{isEvalSupported:A=!0,disableFontFace:k=!1,ignoreErrors:M=!1,onUnsupportedFeature:P,fontRegistry:w=null}){this.compiledGlyphs=Object.create(null);for(const l in N)this[l]=N[l];this.isEvalSupported=A!==!1,this.disableFontFace=k===!0,this.ignoreErrors=M===!0,this._onUnsupportedFeature=P,this.fontRegistry=w}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let N;if(!this.cssFontInfo)N=new FontFace(this.loadedName,this.data,{});else{const A={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(A.style=`oblique ${this.cssFontInfo.italicAngle}deg`),N=new FontFace(this.cssFontInfo.fontFamily,this.data,A)}return this.fontRegistry&&this.fontRegistry.registerFont(this),N}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const N=(0,_.bytesToString)(this.data),A=`url(data:${this.mimetype};base64,${btoa(N)});`;let k;if(!this.cssFontInfo)k=`@font-face {font-family:"${this.loadedName}";src:${A}}`;else{let M=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(M+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),k=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${M}src:${A}}`}return this.fontRegistry&&this.fontRegistry.registerFont(this,A),k}getPathGenerator(N,A){if(this.compiledGlyphs[A]!==void 0)return this.compiledGlyphs[A];let k;try{k=N.get(this.loadedName+"_path_"+A)}catch(M){if(!this.ignoreErrors)throw M;return this._onUnsupportedFeature({featureId:_.UNSUPPORTED_FEATURES.errorFontGetPath}),(0,_.warn)(`getPathGenerator - ignoring character: "${M}".`),this.compiledGlyphs[A]=function(P,w){}}if(this.isEvalSupported&&_.FeatureTest.isEvalSupported){const M=[];for(const P of k){const w=P.args!==void 0?P.args.join(","):"";M.push("c.",P.cmd,"(",w,`);
130
+ `)}return this.compiledGlyphs[A]=new Function("c","size",M.join(""))}return this.compiledGlyphs[A]=function(M,P){for(const w of k)w.cmd==="scale"&&(w.args=[P,-P]),M[w.cmd].apply(M,w.args)}}}g.FontFaceObject=H},(nt,g,U)=>{var it,ce;Object.defineProperty(g,"__esModule",{value:!0}),g.CanvasGraphics=void 0;var _=U(8),v=U(1),V=U(13),H=U(14),Q=U(3);const N=16,A=100,k=4096,M=15,P=10,w=Q.isNodeJS&&typeof Path2D>"u"?-1:1e3,l=16;function s(O,f){if(O._removeMirroring)throw new Error("Context is already forwarding operations.");O.__originalSave=O.save,O.__originalRestore=O.restore,O.__originalRotate=O.rotate,O.__originalScale=O.scale,O.__originalTranslate=O.translate,O.__originalTransform=O.transform,O.__originalSetTransform=O.setTransform,O.__originalResetTransform=O.resetTransform,O.__originalClip=O.clip,O.__originalMoveTo=O.moveTo,O.__originalLineTo=O.lineTo,O.__originalBezierCurveTo=O.bezierCurveTo,O.__originalRect=O.rect,O.__originalClosePath=O.closePath,O.__originalBeginPath=O.beginPath,O._removeMirroring=()=>{O.save=O.__originalSave,O.restore=O.__originalRestore,O.rotate=O.__originalRotate,O.scale=O.__originalScale,O.translate=O.__originalTranslate,O.transform=O.__originalTransform,O.setTransform=O.__originalSetTransform,O.resetTransform=O.__originalResetTransform,O.clip=O.__originalClip,O.moveTo=O.__originalMoveTo,O.lineTo=O.__originalLineTo,O.bezierCurveTo=O.__originalBezierCurveTo,O.rect=O.__originalRect,O.closePath=O.__originalClosePath,O.beginPath=O.__originalBeginPath,delete O._removeMirroring},O.save=function(){f.save(),this.__originalSave()},O.restore=function(){f.restore(),this.__originalRestore()},O.translate=function(E,F){f.translate(E,F),this.__originalTranslate(E,F)},O.scale=function(E,F){f.scale(E,F),this.__originalScale(E,F)},O.transform=function(E,F,D,I,G,z){f.transform(E,F,D,I,G,z),this.__originalTransform(E,F,D,I,G,z)},O.setTransform=function(E,F,D,I,G,z){f.setTransform(E,F,D,I,G,z),this.__originalSetTransform(E,F,D,I,G,z)},O.resetTransform=function(){f.resetTransform(),this.__originalResetTransform()},O.rotate=function(E){f.rotate(E),this.__originalRotate(E)},O.clip=function(E){f.clip(E),this.__originalClip(E)},O.moveTo=function(h,E){f.moveTo(h,E),this.__originalMoveTo(h,E)},O.lineTo=function(h,E){f.lineTo(h,E),this.__originalLineTo(h,E)},O.bezierCurveTo=function(h,E,F,D,I,G){f.bezierCurveTo(h,E,F,D,I,G),this.__originalBezierCurveTo(h,E,F,D,I,G)},O.rect=function(h,E,F,D){f.rect(h,E,F,D),this.__originalRect(h,E,F,D)},O.closePath=function(){f.closePath(),this.__originalClosePath()},O.beginPath=function(){f.beginPath(),this.__originalBeginPath()}}class n{constructor(f){this.canvasFactory=f,this.cache=Object.create(null)}getCanvas(f,h,E){let F;return this.cache[f]!==void 0?(F=this.cache[f],this.canvasFactory.reset(F,h,E)):(F=this.canvasFactory.create(h,E),this.cache[f]=F),F}delete(f){delete this.cache[f]}clear(){for(const f in this.cache){const h=this.cache[f];this.canvasFactory.destroy(h),delete this.cache[f]}}}function o(O,f,h,E,F,D,I,G,z,r){const[m,b,x,T,L,st]=(0,_.getCurrentTransform)(O);if(b===0&&x===0){const ot=I*m+L,et=Math.round(ot),lt=G*T+st,pt=Math.round(lt),R=(I+z)*m+L,ut=Math.abs(Math.round(R)-et)||1,_t=(G+r)*T+st,St=Math.abs(Math.round(_t)-pt)||1;return O.setTransform(Math.sign(m),0,0,Math.sign(T),et,pt),O.drawImage(f,h,E,F,D,0,0,ut,St),O.setTransform(m,b,x,T,L,st),[ut,St]}if(m===0&&T===0){const ot=G*x+L,et=Math.round(ot),lt=I*b+st,pt=Math.round(lt),R=(G+r)*x+L,ut=Math.abs(Math.round(R)-et)||1,_t=(I+z)*b+st,St=Math.abs(Math.round(_t)-pt)||1;return O.setTransform(0,Math.sign(b),Math.sign(x),0,et,pt),O.drawImage(f,h,E,F,D,0,0,St,ut),O.setTransform(m,b,x,T,L,st),[St,ut]}O.drawImage(f,h,E,F,D,I,G,z,r);const dt=Math.hypot(m,b),Z=Math.hypot(x,T);return[dt*z,Z*r]}function y(O){const{width:f,height:h}=O;if(f>w||h>w)return null;const E=1e3,F=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),D=f+1;let I=new Uint8Array(D*(h+1)),G,z,r;const m=f+7&-8;let b=new Uint8Array(m*h),x=0;for(const Z of O.data){let ot=128;for(;ot>0;)b[x++]=Z&ot?0:255,ot>>=1}let T=0;for(x=0,b[x]!==0&&(I[0]=1,++T),z=1;z<f;z++)b[x]!==b[x+1]&&(I[z]=b[x]?2:1,++T),x++;for(b[x]!==0&&(I[z]=2,++T),G=1;G<h;G++){x=G*m,r=G*D,b[x-m]!==b[x]&&(I[r]=b[x]?1:8,++T);let Z=(b[x]?4:0)+(b[x-m]?8:0);for(z=1;z<f;z++)Z=(Z>>2)+(b[x+1]?4:0)+(b[x-m+1]?8:0),F[Z]&&(I[r+z]=F[Z],++T),x++;if(b[x-m]!==b[x]&&(I[r+z]=b[x]?2:4,++T),T>E)return null}for(x=m*(h-1),r=G*D,b[x]!==0&&(I[r]=8,++T),z=1;z<f;z++)b[x]!==b[x+1]&&(I[r+z]=b[x]?4:8,++T),x++;if(b[x]!==0&&(I[r+z]=4,++T),T>E)return null;const L=new Int32Array([0,D,-1,0,-D,0,0,0,1]),st=new Path2D;for(G=0;T&&G<=h;G++){let Z=G*D;const ot=Z+f;for(;Z<ot&&!I[Z];)Z++;if(Z===ot)continue;st.moveTo(Z%D,G);const et=Z;let lt=I[Z];do{const pt=L[lt];do Z+=pt;while(!I[Z]);const R=I[Z];R!==5&&R!==10?(lt=R,I[Z]=0):(lt=R&51*lt>>4,I[Z]&=lt>>2|lt<<2),st.lineTo(Z%D,Z/D|0),I[Z]||--T}while(et!==Z);--G}return b=null,I=null,function(Z){Z.save(),Z.scale(1/f,-1/h),Z.translate(0,-h),Z.fill(st),Z.beginPath(),Z.restore()}}class p{constructor(f,h){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=v.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=v.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=v.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps=null,this.startNewPathAndClipBox([0,0,f,h])}clone(){const f=Object.create(this);return f.clipBox=this.clipBox.slice(),f}setCurrentPoint(f,h){this.x=f,this.y=h}updatePathMinMax(f,h,E){[h,E]=v.Util.applyTransform([h,E],f),this.minX=Math.min(this.minX,h),this.minY=Math.min(this.minY,E),this.maxX=Math.max(this.maxX,h),this.maxY=Math.max(this.maxY,E)}updateRectMinMax(f,h){const E=v.Util.applyTransform(h,f),F=v.Util.applyTransform(h.slice(2),f);this.minX=Math.min(this.minX,E[0],F[0]),this.minY=Math.min(this.minY,E[1],F[1]),this.maxX=Math.max(this.maxX,E[0],F[0]),this.maxY=Math.max(this.maxY,E[1],F[1])}updateScalingPathMinMax(f,h){v.Util.scaleMinMax(f,h),this.minX=Math.min(this.minX,h[0]),this.maxX=Math.max(this.maxX,h[1]),this.minY=Math.min(this.minY,h[2]),this.maxY=Math.max(this.maxY,h[3])}updateCurvePathMinMax(f,h,E,F,D,I,G,z,r,m){const b=v.Util.bezierBoundingBox(h,E,F,D,I,G,z,r);if(m){m[0]=Math.min(m[0],b[0],b[2]),m[1]=Math.max(m[1],b[0],b[2]),m[2]=Math.min(m[2],b[1],b[3]),m[3]=Math.max(m[3],b[1],b[3]);return}this.updateRectMinMax(f,b)}getPathBoundingBox(f=V.PathType.FILL,h=null){const E=[this.minX,this.minY,this.maxX,this.maxY];if(f===V.PathType.STROKE){h||(0,v.unreachable)("Stroke bounding box must include transform.");const F=v.Util.singularValueDecompose2dScale(h),D=F[0]*this.lineWidth/2,I=F[1]*this.lineWidth/2;E[0]-=D,E[1]-=I,E[2]+=D,E[3]+=I}return E}updateClipFromPath(){const f=v.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(f||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(f){this.clipBox=f,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(f=V.PathType.FILL,h=null){return v.Util.intersect(this.clipBox,this.getPathBoundingBox(f,h))}}function t(O,f,h=null){if(typeof ImageData<"u"&&f instanceof ImageData){O.putImageData(f,0,0);return}const E=f.height,F=f.width,D=E%l,I=(E-D)/l,G=D===0?I:I+1,z=O.createImageData(F,l);let r=0,m;const b=f.data,x=z.data;let T,L,st,dt,Z,ot,et,lt;if(h)switch(h.length){case 1:Z=h[0],ot=h[0],et=h[0],lt=h[0];break;case 4:Z=h[0],ot=h[1],et=h[2],lt=h[3];break}if(f.kind===v.ImageKind.GRAYSCALE_1BPP){const pt=b.byteLength,R=new Uint32Array(x.buffer,0,x.byteLength>>2),ut=R.length,_t=F+7>>3;let St=4294967295,xt=v.FeatureTest.isLittleEndian?4278190080:255;for(lt&&lt[0]===255&&lt[255]===0&&([St,xt]=[xt,St]),T=0;T<G;T++){for(st=T<I?l:D,m=0,L=0;L<st;L++){const Et=pt-r;let Ft=0;const Rt=Et>_t?F:Et*8-7,zt=Rt&-8;let wt=0,Dt=0;for(;Ft<zt;Ft+=8)Dt=b[r++],R[m++]=Dt&128?St:xt,R[m++]=Dt&64?St:xt,R[m++]=Dt&32?St:xt,R[m++]=Dt&16?St:xt,R[m++]=Dt&8?St:xt,R[m++]=Dt&4?St:xt,R[m++]=Dt&2?St:xt,R[m++]=Dt&1?St:xt;for(;Ft<Rt;Ft++)wt===0&&(Dt=b[r++],wt=128),R[m++]=Dt&wt?St:xt,wt>>=1}for(;m<ut;)R[m++]=0;O.putImageData(z,0,T*l)}}else if(f.kind===v.ImageKind.RGBA_32BPP){const pt=!!(Z||ot||et);for(L=0,dt=F*l*4,T=0;T<I;T++){if(x.set(b.subarray(r,r+dt)),r+=dt,pt)for(let R=0;R<dt;R+=4)Z&&(x[R+0]=Z[x[R+0]]),ot&&(x[R+1]=ot[x[R+1]]),et&&(x[R+2]=et[x[R+2]]);O.putImageData(z,0,L),L+=l}if(T<G){if(dt=F*D*4,x.set(b.subarray(r,r+dt)),pt)for(let R=0;R<dt;R+=4)Z&&(x[R+0]=Z[x[R+0]]),ot&&(x[R+1]=ot[x[R+1]]),et&&(x[R+2]=et[x[R+2]]);O.putImageData(z,0,L)}}else if(f.kind===v.ImageKind.RGB_24BPP){const pt=!!(Z||ot||et);for(st=l,dt=F*st,T=0;T<G;T++){for(T>=I&&(st=D,dt=F*st),m=0,L=dt;L--;)x[m++]=b[r++],x[m++]=b[r++],x[m++]=b[r++],x[m++]=255;if(pt)for(let R=0;R<m;R+=4)Z&&(x[R+0]=Z[x[R+0]]),ot&&(x[R+1]=ot[x[R+1]]),et&&(x[R+2]=et[x[R+2]]);O.putImageData(z,0,T*l)}}else throw new Error(`bad image kind: ${f.kind}`)}function e(O,f){if(f.bitmap){O.drawImage(f.bitmap,0,0);return}const h=f.height,E=f.width,F=h%l,D=(h-F)/l,I=F===0?D:D+1,G=O.createImageData(E,l);let z=0;const r=f.data,m=G.data;for(let b=0;b<I;b++){const x=b<D?l:F;({srcPos:z}=(0,H.applyMaskImageData)({src:r,srcPos:z,dest:m,width:E,height:x})),O.putImageData(G,0,b*l)}}function i(O,f){const h=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"];for(let E=0,F=h.length;E<F;E++){const D=h[E];O[D]!==void 0&&(f[D]=O[D])}O.setLineDash!==void 0&&(f.setLineDash(O.getLineDash()),f.lineDashOffset=O.lineDashOffset)}function a(O,f){O.strokeStyle=O.fillStyle=f||"#000000",O.fillRule="nonzero",O.globalAlpha=1,O.lineWidth=1,O.lineCap="butt",O.lineJoin="miter",O.miterLimit=10,O.globalCompositeOperation="source-over",O.font="10px sans-serif",O.setLineDash!==void 0&&(O.setLineDash([]),O.lineDashOffset=0)}function u(O,f,h,E){const F=O.length;for(let D=3;D<F;D+=4){const I=O[D];if(I===0)O[D-3]=f,O[D-2]=h,O[D-1]=E;else if(I<255){const G=255-I;O[D-3]=O[D-3]*I+f*G>>8,O[D-2]=O[D-2]*I+h*G>>8,O[D-1]=O[D-1]*I+E*G>>8}}}function d(O,f,h){const E=O.length,F=1/255;for(let D=3;D<E;D+=4){const I=h?h[O[D]]:O[D];f[D]=f[D]*I*F|0}}function c(O,f,h){const E=O.length;for(let F=3;F<E;F+=4){const D=O[F-3]*77+O[F-2]*152+O[F-1]*28;f[F]=h?f[F]*h[D>>8]>>8:f[F]*D>>16}}function S(O,f,h,E,F,D,I,G,z,r,m){const b=!!D,x=b?D[0]:0,T=b?D[1]:0,L=b?D[2]:0;let st;F==="Luminosity"?st=c:st=d;const Z=Math.min(E,Math.ceil(1048576/h));for(let ot=0;ot<E;ot+=Z){const et=Math.min(Z,E-ot),lt=O.getImageData(G-r,ot+(z-m),h,et),pt=f.getImageData(G,ot+z,h,et);b&&u(lt.data,x,T,L),st(lt.data,pt.data,I),f.putImageData(pt,G,ot+z)}}function X(O,f,h,E){const F=E[0],D=E[1],I=E[2]-F,G=E[3]-D;I===0||G===0||(S(f.context,h,I,G,f.subtype,f.backdrop,f.transferMap,F,D,f.offsetX,f.offsetY),O.save(),O.globalAlpha=1,O.globalCompositeOperation="source-over",O.setTransform(1,0,0,1,0,0),O.drawImage(h.canvas,0,0),O.restore())}function tt(O,f){const h=v.Util.singularValueDecompose2dScale(O);h[0]=Math.fround(h[0]),h[1]=Math.fround(h[1]);const E=Math.fround((globalThis.devicePixelRatio||1)*_.PixelsPerInch.PDF_TO_CSS_UNITS);return f!==void 0?f:h[0]<=E||h[1]<=E}const K=["butt","round","square"],Y=["miter","round","bevel"],B={},q={},yt=class yt{constructor(f,h,E,F,D,I,G,z){at(this,it);this.ctx=f,this.current=new p(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=h,this.objs=E,this.canvasFactory=F,this.imageLayer=D,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=[],this.optionalContentConfig=I,this.cachedCanvases=new n(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=G,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.backgroundColor=(z==null?void 0:z.background)||null,this.foregroundColor=(z==null?void 0:z.foreground)||null,this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(f,h=null){return typeof f=="string"?f.startsWith("g_")?this.commonObjs.get(f):this.objs.get(f):h}beginDrawing({transform:f,viewport:h,transparency:E=!1,background:F=null}){const D=this.ctx.canvas.width,I=this.ctx.canvas.height,G=F||"#ffffff";if(this.ctx.save(),this.foregroundColor&&this.backgroundColor){this.ctx.fillStyle=this.foregroundColor;const z=this.foregroundColor=this.ctx.fillStyle;this.ctx.fillStyle=this.backgroundColor;const r=this.backgroundColor=this.ctx.fillStyle;let m=!0,b=G;if(this.ctx.fillStyle=G,b=this.ctx.fillStyle,m=typeof b=="string"&&/^#[0-9A-Fa-f]{6}$/.test(b),z==="#000000"&&r==="#ffffff"||z===r||!m)this.foregroundColor=this.backgroundColor=null;else{const[x,T,L]=(0,_.getRGB)(b),st=Z=>(Z/=255,Z<=.03928?Z/12.92:((Z+.055)/1.055)**2.4),dt=Math.round(.2126*st(x)+.7152*st(T)+.0722*st(L));this.selectColor=(Z,ot,et)=>{const lt=.2126*st(Z)+.7152*st(ot)+.0722*st(et);return Math.round(lt)===dt?r:z}}}if(this.ctx.fillStyle=this.backgroundColor||G,this.ctx.fillRect(0,0,D,I),this.ctx.restore(),E){const z=this.cachedCanvases.getCanvas("transparent",D,I);this.compositeCtx=this.ctx,this.transparentCanvas=z.canvas,this.ctx=z.context,this.ctx.save(),this.ctx.transform(...(0,_.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),a(this.ctx,this.foregroundColor),f&&(this.ctx.transform(...f),this.outputScaleX=f[0],this.outputScaleY=f[0]),this.ctx.transform(...h.transform),this.viewportScale=h.scale,this.baseTransform=(0,_.getCurrentTransform)(this.ctx),this.imageLayer&&((0,_.deprecated)("The `imageLayer` functionality will be removed in the future."),this.imageLayer.beginLayout())}executeOperatorList(f,h,E,F){const D=f.argsArray,I=f.fnArray;let G=h||0;const z=D.length;if(z===G)return G;const r=z-G>P&&typeof E=="function",m=r?Date.now()+M:0;let b=0;const x=this.commonObjs,T=this.objs;let L;for(;;){if(F!==void 0&&G===F.nextBreakPoint)return F.breakIt(G,E),G;if(L=I[G],L!==v.OPS.dependency)this[L].apply(this,D[G]);else for(const st of D[G]){const dt=st.startsWith("g_")?x:T;if(!dt.has(st))return dt.get(st,E),G}if(G++,G===z)return G;if(r&&++b>P){if(Date.now()>m)return E(),G;b=0}}}endDrawing(){ct(this,it,ce).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const f of this._cachedBitmapsMap.values()){for(const h of f.values())typeof HTMLCanvasElement<"u"&&h instanceof HTMLCanvasElement&&(h.width=h.height=0);f.clear()}this._cachedBitmapsMap.clear(),this.imageLayer&&this.imageLayer.endLayout()}_scaleImage(f,h){const E=f.width,F=f.height;let D=Math.max(Math.hypot(h[0],h[1]),1),I=Math.max(Math.hypot(h[2],h[3]),1),G=E,z=F,r="prescale1",m,b;for(;D>2&&G>1||I>2&&z>1;){let x=G,T=z;D>2&&G>1&&(x=Math.ceil(G/2),D/=G/x),I>2&&z>1&&(T=Math.ceil(z/2),I/=z/T),m=this.cachedCanvases.getCanvas(r,x,T),b=m.context,b.clearRect(0,0,x,T),b.drawImage(f,0,0,G,z,0,0,x,T),f=m.canvas,G=x,z=T,r=r==="prescale1"?"prescale2":"prescale1"}return{img:f,paintWidth:G,paintHeight:z}}_createMaskCanvas(f){const h=this.ctx,{width:E,height:F}=f,D=this.current.fillColor,I=this.current.patternFill,G=(0,_.getCurrentTransform)(h);let z,r,m,b;if((f.bitmap||f.data)&&f.count>1){const ut=f.bitmap||f.data.buffer,_t=G.slice(0,4);r=JSON.stringify(I?_t:[_t,D]),z=this._cachedBitmapsMap.get(ut),z||(z=new Map,this._cachedBitmapsMap.set(ut,z));const St=z.get(r);if(St&&!I){const xt=Math.round(Math.min(G[0],G[2])+G[4]),Et=Math.round(Math.min(G[1],G[3])+G[5]);return{canvas:St,offsetX:xt,offsetY:Et}}m=St}m||(b=this.cachedCanvases.getCanvas("maskCanvas",E,F),e(b.context,f));let x=v.Util.transform(G,[1/E,0,0,-1/F,0,0]);x=v.Util.transform(x,[1,0,0,1,0,-F]);const T=v.Util.applyTransform([0,0],x),L=v.Util.applyTransform([E,F],x),st=v.Util.normalizeRect([T[0],T[1],L[0],L[1]]),dt=Math.round(st[2]-st[0])||1,Z=Math.round(st[3]-st[1])||1,ot=this.cachedCanvases.getCanvas("fillCanvas",dt,Z),et=ot.context,lt=Math.min(T[0],L[0]),pt=Math.min(T[1],L[1]);et.translate(-lt,-pt),et.transform(...x),m||(m=this._scaleImage(b.canvas,(0,_.getCurrentTransformInverse)(et)),m=m.img,z&&I&&z.set(r,m)),et.imageSmoothingEnabled=tt((0,_.getCurrentTransform)(et),f.interpolate),o(et,m,0,0,m.width,m.height,0,0,E,F),et.globalCompositeOperation="source-in";const R=v.Util.transform((0,_.getCurrentTransformInverse)(et),[1,0,0,1,-lt,-pt]);return et.fillStyle=I?D.getPattern(h,this,R,V.PathType.FILL):D,et.fillRect(0,0,E,F),z&&!I&&(this.cachedCanvases.delete("fillCanvas"),z.set(r,ot.canvas)),{canvas:ot.canvas,offsetX:Math.round(lt),offsetY:Math.round(pt)}}setLineWidth(f){f!==this.current.lineWidth&&(this._cachedScaleForStroking=null),this.current.lineWidth=f,this.ctx.lineWidth=f}setLineCap(f){this.ctx.lineCap=K[f]}setLineJoin(f){this.ctx.lineJoin=Y[f]}setMiterLimit(f){this.ctx.miterLimit=f}setDash(f,h){const E=this.ctx;E.setLineDash!==void 0&&(E.setLineDash(f),E.lineDashOffset=h)}setRenderingIntent(f){}setFlatness(f){}setGState(f){for(let h=0,E=f.length;h<E;h++){const F=f[h],D=F[0],I=F[1];switch(D){case"LW":this.setLineWidth(I);break;case"LC":this.setLineCap(I);break;case"LJ":this.setLineJoin(I);break;case"ML":this.setMiterLimit(I);break;case"D":this.setDash(I[0],I[1]);break;case"RI":this.setRenderingIntent(I);break;case"FL":this.setFlatness(I);break;case"Font":this.setFont(I[0],I[1]);break;case"CA":this.current.strokeAlpha=F[1];break;case"ca":this.current.fillAlpha=F[1],this.ctx.globalAlpha=F[1];break;case"BM":this.ctx.globalCompositeOperation=I;break;case"SMask":this.current.activeSMask=I?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.current.transferMaps=I}}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const f=this.inSMaskMode;this.current.activeSMask&&!f?this.beginSMaskMode():!this.current.activeSMask&&f&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const f=this.ctx.canvas.width,h=this.ctx.canvas.height,E="smaskGroupAt"+this.groupLevel,F=this.cachedCanvases.getCanvas(E,f,h);this.suspendedCtx=this.ctx,this.ctx=F.context;const D=this.ctx;D.setTransform(...(0,_.getCurrentTransform)(this.suspendedCtx)),i(this.suspendedCtx,D),s(D,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),i(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(f){if(!this.current.activeSMask)return;f?(f[0]=Math.floor(f[0]),f[1]=Math.floor(f[1]),f[2]=Math.ceil(f[2]),f[3]=Math.ceil(f[3])):f=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const h=this.current.activeSMask,E=this.suspendedCtx;X(E,h,this.ctx,f),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}save(){this.inSMaskMode?(i(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const f=this.current;this.stateStack.push(f),this.current=f.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),i(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null)}transform(f,h,E,F,D,I){this.ctx.transform(f,h,E,F,D,I),this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null}constructPath(f,h,E){const F=this.ctx,D=this.current;let I=D.x,G=D.y,z,r;const m=(0,_.getCurrentTransform)(F),b=m[0]===0&&m[3]===0||m[1]===0&&m[2]===0,x=b?E.slice(0):null;for(let T=0,L=0,st=f.length;T<st;T++)switch(f[T]|0){case v.OPS.rectangle:I=h[L++],G=h[L++];const dt=h[L++],Z=h[L++],ot=I+dt,et=G+Z;F.moveTo(I,G),dt===0||Z===0?F.lineTo(ot,et):(F.lineTo(ot,G),F.lineTo(ot,et),F.lineTo(I,et)),b||D.updateRectMinMax(m,[I,G,ot,et]),F.closePath();break;case v.OPS.moveTo:I=h[L++],G=h[L++],F.moveTo(I,G),b||D.updatePathMinMax(m,I,G);break;case v.OPS.lineTo:I=h[L++],G=h[L++],F.lineTo(I,G),b||D.updatePathMinMax(m,I,G);break;case v.OPS.curveTo:z=I,r=G,I=h[L+4],G=h[L+5],F.bezierCurveTo(h[L],h[L+1],h[L+2],h[L+3],I,G),D.updateCurvePathMinMax(m,z,r,h[L],h[L+1],h[L+2],h[L+3],I,G,x),L+=6;break;case v.OPS.curveTo2:z=I,r=G,F.bezierCurveTo(I,G,h[L],h[L+1],h[L+2],h[L+3]),D.updateCurvePathMinMax(m,z,r,I,G,h[L],h[L+1],h[L+2],h[L+3],x),I=h[L+2],G=h[L+3],L+=4;break;case v.OPS.curveTo3:z=I,r=G,I=h[L+2],G=h[L+3],F.bezierCurveTo(h[L],h[L+1],I,G,I,G),D.updateCurvePathMinMax(m,z,r,h[L],h[L+1],I,G,I,G,x),L+=4;break;case v.OPS.closePath:F.closePath();break}b&&D.updateScalingPathMinMax(m,x),D.setCurrentPoint(I,G)}closePath(){this.ctx.closePath()}stroke(f){f=typeof f<"u"?f:!0;const h=this.ctx,E=this.current.strokeColor;h.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof E=="object"&&(E!=null&&E.getPattern)?(h.save(),h.strokeStyle=E.getPattern(h,this,(0,_.getCurrentTransformInverse)(h),V.PathType.STROKE),this.rescaleAndStroke(!1),h.restore()):this.rescaleAndStroke(!0)),f&&this.consumePath(this.current.getClippedPathBoundingBox()),h.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(f){f=typeof f<"u"?f:!0;const h=this.ctx,E=this.current.fillColor,F=this.current.patternFill;let D=!1;F&&(h.save(),h.fillStyle=E.getPattern(h,this,(0,_.getCurrentTransformInverse)(h),V.PathType.FILL),D=!0);const I=this.current.getClippedPathBoundingBox();this.contentVisible&&I!==null&&(this.pendingEOFill?(h.fill("evenodd"),this.pendingEOFill=!1):h.fill()),D&&h.restore(),f&&this.consumePath(I)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=B}eoClip(){this.pendingClip=q}beginText(){this.current.textMatrix=v.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const f=this.pendingTextPaths,h=this.ctx;if(f===void 0){h.beginPath();return}h.save(),h.beginPath();for(const E of f)h.setTransform(...E.transform),h.translate(E.x,E.y),E.addToPath(h,E.fontSize);h.restore(),h.clip(),h.beginPath(),delete this.pendingTextPaths}setCharSpacing(f){this.current.charSpacing=f}setWordSpacing(f){this.current.wordSpacing=f}setHScale(f){this.current.textHScale=f/100}setLeading(f){this.current.leading=-f}setFont(f,h){const E=this.commonObjs.get(f),F=this.current;if(!E)throw new Error(`Can't find font for ${f}`);if(F.fontMatrix=E.fontMatrix||v.FONT_IDENTITY_MATRIX,(F.fontMatrix[0]===0||F.fontMatrix[3]===0)&&(0,v.warn)("Invalid font matrix for font "+f),h<0?(h=-h,F.fontDirection=-1):F.fontDirection=1,this.current.font=E,this.current.fontSize=h,E.isType3Font)return;const D=E.loadedName||"sans-serif";let I="normal";E.black?I="900":E.bold&&(I="bold");const G=E.italic?"italic":"normal",z=`"${D}", ${E.fallbackName}`;let r=h;h<N?r=N:h>A&&(r=A),this.current.fontSizeScale=h/r,this.ctx.font=`${G} ${I} ${r}px ${z}`}setTextRenderingMode(f){this.current.textRenderingMode=f}setTextRise(f){this.current.textRise=f}moveText(f,h){this.current.x=this.current.lineX+=f,this.current.y=this.current.lineY+=h}setLeadingMoveText(f,h){this.setLeading(-h),this.moveText(f,h)}setTextMatrix(f,h,E,F,D,I){this.current.textMatrix=[f,h,E,F,D,I],this.current.textMatrixScale=Math.hypot(f,h),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(f,h,E,F){const D=this.ctx,I=this.current,G=I.font,z=I.textRenderingMode,r=I.fontSize/I.fontSizeScale,m=z&v.TextRenderingMode.FILL_STROKE_MASK,b=!!(z&v.TextRenderingMode.ADD_TO_PATH_FLAG),x=I.patternFill&&!G.missingFile;let T;(G.disableFontFace||b||x)&&(T=G.getPathGenerator(this.commonObjs,f)),G.disableFontFace||x?(D.save(),D.translate(h,E),D.beginPath(),T(D,r),F&&D.setTransform(...F),(m===v.TextRenderingMode.FILL||m===v.TextRenderingMode.FILL_STROKE)&&D.fill(),(m===v.TextRenderingMode.STROKE||m===v.TextRenderingMode.FILL_STROKE)&&D.stroke(),D.restore()):((m===v.TextRenderingMode.FILL||m===v.TextRenderingMode.FILL_STROKE)&&D.fillText(f,h,E),(m===v.TextRenderingMode.STROKE||m===v.TextRenderingMode.FILL_STROKE)&&D.strokeText(f,h,E)),b&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,_.getCurrentTransform)(D),x:h,y:E,fontSize:r,addToPath:T})}get isFontSubpixelAAEnabled(){const{context:f}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);f.scale(1.5,1),f.fillText("I",0,10);const h=f.getImageData(0,0,10,10).data;let E=!1;for(let F=3;F<h.length;F+=4)if(h[F]>0&&h[F]<255){E=!0;break}return(0,v.shadow)(this,"isFontSubpixelAAEnabled",E)}showText(f){const h=this.current,E=h.font;if(E.isType3Font)return this.showType3Text(f);const F=h.fontSize;if(F===0)return;const D=this.ctx,I=h.fontSizeScale,G=h.charSpacing,z=h.wordSpacing,r=h.fontDirection,m=h.textHScale*r,b=f.length,x=E.vertical,T=x?1:-1,L=E.defaultVMetrics,st=F*h.fontMatrix[0],dt=h.textRenderingMode===v.TextRenderingMode.FILL&&!E.disableFontFace&&!h.patternFill;D.save(),D.transform(...h.textMatrix),D.translate(h.x,h.y+h.textRise),r>0?D.scale(m,-1):D.scale(m,1);let Z;if(h.patternFill){D.save();const R=h.fillColor.getPattern(D,this,(0,_.getCurrentTransformInverse)(D),V.PathType.FILL);Z=(0,_.getCurrentTransform)(D),D.restore(),D.fillStyle=R}let ot=h.lineWidth;const et=h.textMatrixScale;if(et===0||ot===0){const R=h.textRenderingMode&v.TextRenderingMode.FILL_STROKE_MASK;(R===v.TextRenderingMode.STROKE||R===v.TextRenderingMode.FILL_STROKE)&&(ot=this.getSinglePixelWidth())}else ot/=et;I!==1&&(D.scale(I,I),ot/=I),D.lineWidth=ot;let lt=0,pt;for(pt=0;pt<b;++pt){const R=f[pt];if(typeof R=="number"){lt+=T*R*F/1e3;continue}let ut=!1;const _t=(R.isSpace?z:0)+G,St=R.fontChar,xt=R.accent;let Et,Ft,Rt=R.width;if(x){const wt=R.vmetric||L,Dt=-(R.vmetric?wt[1]:Rt*.5)*st,Zt=wt[2]*st;Rt=wt?-wt[0]:Rt,Et=Dt/I,Ft=(lt+Zt)/I}else Et=lt/I,Ft=0;if(E.remeasure&&Rt>0){const wt=D.measureText(St).width*1e3/F*I;if(Rt<wt&&this.isFontSubpixelAAEnabled){const Dt=Rt/wt;ut=!0,D.save(),D.scale(Dt,1),Et/=Dt}else Rt!==wt&&(Et+=(Rt-wt)/2e3*F/I)}if(this.contentVisible&&(R.isInFont||E.missingFile)){if(dt&&!xt)D.fillText(St,Et,Ft);else if(this.paintChar(St,Et,Ft,Z),xt){const wt=Et+F*xt.offset.x/I,Dt=Ft-F*xt.offset.y/I;this.paintChar(xt.fontChar,wt,Dt,Z)}}let zt;x?zt=Rt*st-_t*r:zt=Rt*st+_t*r,lt+=zt,ut&&D.restore()}x?h.y-=lt:h.x+=lt*m,D.restore(),this.compose()}showType3Text(f){const h=this.ctx,E=this.current,F=E.font,D=E.fontSize,I=E.fontDirection,G=F.vertical?1:-1,z=E.charSpacing,r=E.wordSpacing,m=E.textHScale*I,b=E.fontMatrix||v.FONT_IDENTITY_MATRIX,x=f.length,T=E.textRenderingMode===v.TextRenderingMode.INVISIBLE;let L,st,dt,Z;if(!(T||D===0)){for(this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null,h.save(),h.transform(...E.textMatrix),h.translate(E.x,E.y),h.scale(m,I),L=0;L<x;++L){if(st=f[L],typeof st=="number"){Z=G*st*D/1e3,this.ctx.translate(Z,0),E.x+=Z*m;continue}const ot=(st.isSpace?r:0)+z,et=F.charProcOperatorList[st.operatorListId];if(!et){(0,v.warn)(`Type3 character "${st.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=st,this.save(),h.scale(D,D),h.transform(...b),this.executeOperatorList(et),this.restore()),dt=v.Util.applyTransform([st.width,0],b)[0]*D+ot,h.translate(dt,0),E.x+=dt*m}h.restore(),this.processingType3=null}}setCharWidth(f,h){}setCharWidthAndBounds(f,h,E,F,D,I){this.ctx.rect(E,F,D-E,I-F),this.ctx.clip(),this.endPath()}getColorN_Pattern(f){let h;if(f[0]==="TilingPattern"){const E=f[1],F=this.baseTransform||(0,_.getCurrentTransform)(this.ctx),D={createCanvasGraphics:I=>new yt(I,this.commonObjs,this.objs,this.canvasFactory)};h=new V.TilingPattern(f,E,this.ctx,D,F)}else h=this._getPattern(f[1],f[2]);return h}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(f,h,E){var D;const F=((D=this.selectColor)==null?void 0:D.call(this,f,h,E))||v.Util.makeHexColor(f,h,E);this.ctx.strokeStyle=F,this.current.strokeColor=F}setFillRGBColor(f,h,E){var D;const F=((D=this.selectColor)==null?void 0:D.call(this,f,h,E))||v.Util.makeHexColor(f,h,E);this.ctx.fillStyle=F,this.current.fillColor=F,this.current.patternFill=!1}_getPattern(f,h=null){let E;return this.cachedPatterns.has(f)?E=this.cachedPatterns.get(f):(E=(0,V.getShadingPattern)(this.objs.get(f)),this.cachedPatterns.set(f,E)),h&&(E.matrix=h),E}shadingFill(f){if(!this.contentVisible)return;const h=this.ctx;this.save();const E=this._getPattern(f);h.fillStyle=E.getPattern(h,this,(0,_.getCurrentTransformInverse)(h),V.PathType.SHADING);const F=(0,_.getCurrentTransformInverse)(h);if(F){const D=h.canvas,I=D.width,G=D.height,z=v.Util.applyTransform([0,0],F),r=v.Util.applyTransform([0,G],F),m=v.Util.applyTransform([I,0],F),b=v.Util.applyTransform([I,G],F),x=Math.min(z[0],r[0],m[0],b[0]),T=Math.min(z[1],r[1],m[1],b[1]),L=Math.max(z[0],r[0],m[0],b[0]),st=Math.max(z[1],r[1],m[1],b[1]);this.ctx.fillRect(x,T,L-x,st-T)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,v.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,v.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(f,h){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(f)&&f.length===6&&this.transform(...f),this.baseTransform=(0,_.getCurrentTransform)(this.ctx),h)){const E=h[2]-h[0],F=h[3]-h[1];this.ctx.rect(h[0],h[1],E,F),this.current.updateRectMinMax((0,_.getCurrentTransform)(this.ctx),h),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(f){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const h=this.ctx;f.isolated||(0,v.info)("TODO: Support non-isolated groups."),f.knockout&&(0,v.warn)("Knockout groups not supported.");const E=(0,_.getCurrentTransform)(h);if(f.matrix&&h.transform(...f.matrix),!f.bbox)throw new Error("Bounding box is required.");let F=v.Util.getAxialAlignedBoundingBox(f.bbox,(0,_.getCurrentTransform)(h));const D=[0,0,h.canvas.width,h.canvas.height];F=v.Util.intersect(F,D)||[0,0,0,0];const I=Math.floor(F[0]),G=Math.floor(F[1]);let z=Math.max(Math.ceil(F[2])-I,1),r=Math.max(Math.ceil(F[3])-G,1),m=1,b=1;z>k&&(m=z/k,z=k),r>k&&(b=r/k,r=k),this.current.startNewPathAndClipBox([0,0,z,r]);let x="groupAt"+this.groupLevel;f.smask&&(x+="_smask_"+this.smaskCounter++%2);const T=this.cachedCanvases.getCanvas(x,z,r),L=T.context;L.scale(1/m,1/b),L.translate(-I,-G),L.transform(...E),f.smask?this.smaskStack.push({canvas:T.canvas,context:L,offsetX:I,offsetY:G,scaleX:m,scaleY:b,subtype:f.smask.subtype,backdrop:f.smask.backdrop,transferMap:f.smask.transferMap||null,startTransformInverse:null}):(h.setTransform(1,0,0,1,0,0),h.translate(I,G),h.scale(m,b),h.save()),i(h,L),this.ctx=L,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(h),this.groupLevel++}endGroup(f){if(!this.contentVisible)return;this.groupLevel--;const h=this.ctx,E=this.groupStack.pop();if(this.ctx=E,this.ctx.imageSmoothingEnabled=!1,f.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const F=(0,_.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...F);const D=v.Util.getAxialAlignedBoundingBox([0,0,h.canvas.width,h.canvas.height],F);this.ctx.drawImage(h.canvas,0,0),this.ctx.restore(),this.compose(D)}}beginAnnotation(f,h,E,F,D){if(ct(this,it,ce).call(this),a(this.ctx,this.foregroundColor),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(h)&&h.length===4){const I=h[2]-h[0],G=h[3]-h[1];if(D&&this.annotationCanvasMap){E=E.slice(),E[4]-=h[0],E[5]-=h[1],h=h.slice(),h[0]=h[1]=0,h[2]=I,h[3]=G;const[z,r]=v.Util.singularValueDecompose2dScale((0,_.getCurrentTransform)(this.ctx)),{viewportScale:m}=this,b=Math.ceil(I*this.outputScaleX*m),x=Math.ceil(G*this.outputScaleY*m);this.annotationCanvas=this.canvasFactory.create(b,x);const{canvas:T,context:L}=this.annotationCanvas;this.annotationCanvasMap.set(f,T),this.annotationCanvas.savedCtx=this.ctx,this.ctx=L,this.ctx.setTransform(z,0,0,-r,0,G*r),a(this.ctx,this.foregroundColor)}else a(this.ctx,this.foregroundColor),this.ctx.rect(h[0],h[1],I,G),this.ctx.clip(),this.endPath()}this.current=new p(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...E),this.transform(...F)}endAnnotation(){this.annotationCanvas&&(this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(f){if(!this.contentVisible)return;const h=f.count;f=this.getObject(f.data,f),f.count=h;const E=this.ctx,F=this.processingType3;if(F&&(F.compiled===void 0&&(F.compiled=y(f)),F.compiled)){F.compiled(E);return}const D=this._createMaskCanvas(f),I=D.canvas;E.save(),E.setTransform(1,0,0,1,0,0),E.drawImage(I,D.offsetX,D.offsetY),E.restore(),this.compose()}paintImageMaskXObjectRepeat(f,h,E=0,F=0,D,I){if(!this.contentVisible)return;f=this.getObject(f.data,f);const G=this.ctx;G.save();const z=(0,_.getCurrentTransform)(G);G.transform(h,E,F,D,0,0);const r=this._createMaskCanvas(f);G.setTransform(1,0,0,1,0,0);for(let m=0,b=I.length;m<b;m+=2){const x=v.Util.transform(z,[h,E,F,D,I[m],I[m+1]]),[T,L]=v.Util.applyTransform([0,0],x);G.drawImage(r.canvas,T,L)}G.restore(),this.compose()}paintImageMaskXObjectGroup(f){if(!this.contentVisible)return;const h=this.ctx,E=this.current.fillColor,F=this.current.patternFill;for(const D of f){const{data:I,width:G,height:z,transform:r}=D,m=this.cachedCanvases.getCanvas("maskCanvas",G,z),b=m.context;b.save();const x=this.getObject(I,D);e(b,x),b.globalCompositeOperation="source-in",b.fillStyle=F?E.getPattern(b,this,(0,_.getCurrentTransformInverse)(h),V.PathType.FILL):E,b.fillRect(0,0,G,z),b.restore(),h.save(),h.transform(...r),h.scale(1,-1),o(h,m.canvas,0,0,G,z,0,-1,1,1),h.restore()}this.compose()}paintImageXObject(f){if(!this.contentVisible)return;const h=this.getObject(f);if(!h){(0,v.warn)("Dependent image isn't ready yet");return}this.paintInlineImageXObject(h)}paintImageXObjectRepeat(f,h,E,F){if(!this.contentVisible)return;const D=this.getObject(f);if(!D){(0,v.warn)("Dependent image isn't ready yet");return}const I=D.width,G=D.height,z=[];for(let r=0,m=F.length;r<m;r+=2)z.push({transform:[h,0,0,E,F[r],F[r+1]],x:0,y:0,w:I,h:G});this.paintInlineImageXObjectGroup(D,z)}paintInlineImageXObject(f){if(!this.contentVisible)return;const h=f.width,E=f.height,F=this.ctx;this.save(),F.scale(1/h,-1/E);let D;if(typeof HTMLElement=="function"&&f instanceof HTMLElement||!f.data)D=f;else{const r=this.cachedCanvases.getCanvas("inlineImage",h,E),m=r.context;t(m,f,this.current.transferMaps),D=r.canvas}const I=this._scaleImage(D,(0,_.getCurrentTransformInverse)(F));F.imageSmoothingEnabled=tt((0,_.getCurrentTransform)(F),f.interpolate);const[G,z]=o(F,I.img,0,0,I.paintWidth,I.paintHeight,0,-E,h,E);if(this.imageLayer){const[r,m]=v.Util.applyTransform([0,-E],(0,_.getCurrentTransform)(this.ctx));this.imageLayer.appendImage({imgData:f,left:r,top:m,width:G,height:z})}this.compose(),this.restore()}paintInlineImageXObjectGroup(f,h){if(!this.contentVisible)return;const E=this.ctx,F=f.width,D=f.height,I=this.cachedCanvases.getCanvas("inlineImage",F,D),G=I.context;t(G,f,this.current.transferMaps);for(const z of h){if(E.save(),E.transform(...z.transform),E.scale(1,-1),o(E,I.canvas,z.x,z.y,z.w,z.h,0,-1,1,1),this.imageLayer){const[r,m]=v.Util.applyTransform([z.x,z.y],(0,_.getCurrentTransform)(this.ctx));this.imageLayer.appendImage({imgData:f,left:r,top:m,width:F,height:D})}E.restore()}this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(f){}markPointProps(f,h){}beginMarkedContent(f){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(f,h){f==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(h)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(f){const h=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(f);const E=this.ctx;this.pendingClip&&(h||(this.pendingClip===q?E.clip("evenodd"):E.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),E.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const f=(0,_.getCurrentTransform)(this.ctx);if(f[1]===0&&f[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(f[0]),Math.abs(f[3]));else{const h=Math.abs(f[0]*f[3]-f[2]*f[1]),E=Math.hypot(f[0],f[2]),F=Math.hypot(f[1],f[3]);this._cachedGetSinglePixelWidth=Math.max(E,F)/h}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(!this._cachedScaleForStroking){const{lineWidth:f}=this.current,h=(0,_.getCurrentTransform)(this.ctx);let E,F;if(h[1]===0&&h[2]===0){const D=Math.abs(h[0]),I=Math.abs(h[3]);if(f===0)E=1/D,F=1/I;else{const G=D*f,z=I*f;E=G<1?1/G:1,F=z<1?1/z:1}}else{const D=Math.abs(h[0]*h[3]-h[2]*h[1]),I=Math.hypot(h[0],h[1]),G=Math.hypot(h[2],h[3]);if(f===0)E=G/D,F=I/D;else{const z=f*D;E=G>z?G/z:1,F=I>z?I/z:1}}this._cachedScaleForStroking=[E,F]}return this._cachedScaleForStroking}rescaleAndStroke(f){const{ctx:h}=this,{lineWidth:E}=this.current,[F,D]=this.getScaleForStroking();if(h.lineWidth=E||1,F===1&&D===1){h.stroke();return}let I,G,z;f&&(I=(0,_.getCurrentTransform)(h),G=h.getLineDash().slice(),z=h.lineDashOffset),h.scale(F,D);const r=Math.max(F,D);h.setLineDash(h.getLineDash().map(m=>m/r)),h.lineDashOffset/=r,h.stroke(),f&&(h.setTransform(...I),h.setLineDash(G),h.lineDashOffset=z)}isContentVisible(){for(let f=this.markedContentStack.length-1;f>=0;f--)if(!this.markedContentStack[f].visible)return!1;return!0}};it=new WeakSet,ce=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)};let $=yt;g.CanvasGraphics=$;for(const O in v.OPS)$.prototype[O]!==void 0&&($.prototype[v.OPS[O]]=$.prototype[O])},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.TilingPattern=g.PathType=void 0,g.getShadingPattern=l;var _=U(1),v=U(8),V=U(3);const H={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};g.PathType=H;function Q(o,y){if(!y||V.isNodeJS)return;const p=y[2]-y[0],t=y[3]-y[1],e=new Path2D;e.rect(y[0],y[1],p,t),o.clip(e)}class N{constructor(){this.constructor===N&&(0,_.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,_.unreachable)("Abstract method `getPattern` called.")}}class A extends N{constructor(y){super(),this._type=y[1],this._bbox=y[2],this._colorStops=y[3],this._p0=y[4],this._p1=y[5],this._r0=y[6],this._r1=y[7],this.matrix=null}_createGradient(y){let p;this._type==="axial"?p=y.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(p=y.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)p.addColorStop(t[0],t[1]);return p}getPattern(y,p,t,e){let i;if(e===H.STROKE||e===H.FILL){const a=p.current.getClippedPathBoundingBox(e,(0,v.getCurrentTransform)(y))||[0,0,0,0],u=Math.ceil(a[2]-a[0])||1,d=Math.ceil(a[3]-a[1])||1,c=p.cachedCanvases.getCanvas("pattern",u,d,!0),S=c.context;S.clearRect(0,0,S.canvas.width,S.canvas.height),S.beginPath(),S.rect(0,0,S.canvas.width,S.canvas.height),S.translate(-a[0],-a[1]),t=_.Util.transform(t,[1,0,0,1,a[0],a[1]]),S.transform(...p.baseTransform),this.matrix&&S.transform(...this.matrix),Q(S,this._bbox),S.fillStyle=this._createGradient(S),S.fill(),i=y.createPattern(c.canvas,"no-repeat");const X=new DOMMatrix(t);try{i.setTransform(X)}catch(tt){(0,_.warn)(`RadialAxialShadingPattern.getPattern: "${tt==null?void 0:tt.message}".`)}}else Q(y,this._bbox),i=this._createGradient(y);return i}}function k(o,y,p,t,e,i,a,u){const d=y.coords,c=y.colors,S=o.data,X=o.width*4;let tt;d[p+1]>d[t+1]&&(tt=p,p=t,t=tt,tt=i,i=a,a=tt),d[t+1]>d[e+1]&&(tt=t,t=e,e=tt,tt=a,a=u,u=tt),d[p+1]>d[t+1]&&(tt=p,p=t,t=tt,tt=i,i=a,a=tt);const K=(d[p]+y.offsetX)*y.scaleX,Y=(d[p+1]+y.offsetY)*y.scaleY,B=(d[t]+y.offsetX)*y.scaleX,q=(d[t+1]+y.offsetY)*y.scaleY,$=(d[e]+y.offsetX)*y.scaleX,it=(d[e+1]+y.offsetY)*y.scaleY;if(Y>=it)return;const ht=c[i],yt=c[i+1],O=c[i+2],f=c[a],h=c[a+1],E=c[a+2],F=c[u],D=c[u+1],I=c[u+2],G=Math.round(Y),z=Math.round(it);let r,m,b,x,T,L,st,dt;for(let Z=G;Z<=z;Z++){if(Z<q){let R;Z<Y?R=0:R=(Y-Z)/(Y-q),r=K-(K-B)*R,m=ht-(ht-f)*R,b=yt-(yt-h)*R,x=O-(O-E)*R}else{let R;Z>it?R=1:q===it?R=0:R=(q-Z)/(q-it),r=B-(B-$)*R,m=f-(f-F)*R,b=h-(h-D)*R,x=E-(E-I)*R}let ot;Z<Y?ot=0:Z>it?ot=1:ot=(Y-Z)/(Y-it),T=K-(K-$)*ot,L=ht-(ht-F)*ot,st=yt-(yt-D)*ot,dt=O-(O-I)*ot;const et=Math.round(Math.min(r,T)),lt=Math.round(Math.max(r,T));let pt=X*Z+et*4;for(let R=et;R<=lt;R++)ot=(r-R)/(r-T),ot<0?ot=0:ot>1&&(ot=1),S[pt++]=m-(m-L)*ot|0,S[pt++]=b-(b-st)*ot|0,S[pt++]=x-(x-dt)*ot|0,S[pt++]=255}}function M(o,y,p){const t=y.coords,e=y.colors;let i,a;switch(y.type){case"lattice":const u=y.verticesPerRow,d=Math.floor(t.length/u)-1,c=u-1;for(i=0;i<d;i++){let S=i*u;for(let X=0;X<c;X++,S++)k(o,p,t[S],t[S+1],t[S+u],e[S],e[S+1],e[S+u]),k(o,p,t[S+u+1],t[S+1],t[S+u],e[S+u+1],e[S+1],e[S+u])}break;case"triangles":for(i=0,a=t.length;i<a;i+=3)k(o,p,t[i],t[i+1],t[i+2],e[i],e[i+1],e[i+2]);break;default:throw new Error("illegal figure")}}class P extends N{constructor(y){super(),this._coords=y[2],this._colors=y[3],this._figures=y[4],this._bounds=y[5],this._bbox=y[7],this._background=y[8],this.matrix=null}_createMeshCanvas(y,p,t){const u=Math.floor(this._bounds[0]),d=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-u,S=Math.ceil(this._bounds[3])-d,X=Math.min(Math.ceil(Math.abs(c*y[0]*1.1)),3e3),tt=Math.min(Math.ceil(Math.abs(S*y[1]*1.1)),3e3),K=c/X,Y=S/tt,B={coords:this._coords,colors:this._colors,offsetX:-u,offsetY:-d,scaleX:1/K,scaleY:1/Y},q=X+2*2,$=tt+2*2,it=t.getCanvas("mesh",q,$,!1),ht=it.context,yt=ht.createImageData(X,tt);if(p){const f=yt.data;for(let h=0,E=f.length;h<E;h+=4)f[h]=p[0],f[h+1]=p[1],f[h+2]=p[2],f[h+3]=255}for(const f of this._figures)M(yt,f,B);return ht.putImageData(yt,2,2),{canvas:it.canvas,offsetX:u-2*K,offsetY:d-2*Y,scaleX:K,scaleY:Y}}getPattern(y,p,t,e){Q(y,this._bbox);let i;if(e===H.SHADING)i=_.Util.singularValueDecompose2dScale((0,v.getCurrentTransform)(y));else if(i=_.Util.singularValueDecompose2dScale(p.baseTransform),this.matrix){const u=_.Util.singularValueDecompose2dScale(this.matrix);i=[i[0]*u[0],i[1]*u[1]]}const a=this._createMeshCanvas(i,e===H.SHADING?null:this._background,p.cachedCanvases);return e!==H.SHADING&&(y.setTransform(...p.baseTransform),this.matrix&&y.transform(...this.matrix)),y.translate(a.offsetX,a.offsetY),y.scale(a.scaleX,a.scaleY),y.createPattern(a.canvas,"no-repeat")}}class w extends N{getPattern(){return"hotpink"}}function l(o){switch(o[0]){case"RadialAxial":return new A(o);case"Mesh":return new P(o);case"Dummy":return new w}throw new Error(`Unknown IR type: ${o[0]}`)}const s={COLORED:1,UNCOLORED:2};class n{static get MAX_PATTERN_SIZE(){return(0,_.shadow)(this,"MAX_PATTERN_SIZE",3e3)}constructor(y,p,t,e,i){this.operatorList=y[2],this.matrix=y[3]||[1,0,0,1,0,0],this.bbox=y[4],this.xstep=y[5],this.ystep=y[6],this.paintType=y[7],this.tilingType=y[8],this.color=p,this.ctx=t,this.canvasGraphicsFactory=e,this.baseTransform=i}createPatternCanvas(y){const p=this.operatorList,t=this.bbox,e=this.xstep,i=this.ystep,a=this.paintType,u=this.tilingType,d=this.color,c=this.canvasGraphicsFactory;(0,_.info)("TilingType: "+u);const S=t[0],X=t[1],tt=t[2],K=t[3],Y=_.Util.singularValueDecompose2dScale(this.matrix),B=_.Util.singularValueDecompose2dScale(this.baseTransform),q=[Y[0]*B[0],Y[1]*B[1]],$=this.getSizeAndScale(e,this.ctx.canvas.width,q[0]),it=this.getSizeAndScale(i,this.ctx.canvas.height,q[1]),ht=y.cachedCanvases.getCanvas("pattern",$.size,it.size,!0),yt=ht.context,O=c.createCanvasGraphics(yt);O.groupLevel=y.groupLevel,this.setFillAndStrokeStyleToContext(O,a,d);let f=S,h=X,E=tt,F=K;return S<0&&(f=0,E+=Math.abs(S)),X<0&&(h=0,F+=Math.abs(X)),yt.translate(-($.scale*f),-(it.scale*h)),O.transform($.scale,0,0,it.scale,0,0),yt.save(),this.clipBbox(O,f,h,E,F),O.baseTransform=(0,v.getCurrentTransform)(O.ctx),O.executeOperatorList(p),O.endDrawing(),{canvas:ht.canvas,scaleX:$.scale,scaleY:it.scale,offsetX:f,offsetY:h}}getSizeAndScale(y,p,t){y=Math.abs(y);const e=Math.max(n.MAX_PATTERN_SIZE,p);let i=Math.ceil(y*t);return i>=e?i=e:t=i/y,{scale:t,size:i}}clipBbox(y,p,t,e,i){const a=e-p,u=i-t;y.ctx.rect(p,t,a,u),y.current.updateRectMinMax((0,v.getCurrentTransform)(y.ctx),[p,t,e,i]),y.clip(),y.endPath()}setFillAndStrokeStyleToContext(y,p,t){const e=y.ctx,i=y.current;switch(p){case s.COLORED:const a=this.ctx;e.fillStyle=a.fillStyle,e.strokeStyle=a.strokeStyle,i.fillColor=a.fillStyle,i.strokeColor=a.strokeStyle;break;case s.UNCOLORED:const u=_.Util.makeHexColor(t[0],t[1],t[2]);e.fillStyle=u,e.strokeStyle=u,i.fillColor=u,i.strokeColor=u;break;default:throw new _.FormatError(`Unsupported paint type: ${p}`)}}getPattern(y,p,t,e){let i=t;e!==H.SHADING&&(i=_.Util.transform(i,p.baseTransform),this.matrix&&(i=_.Util.transform(i,this.matrix)));const a=this.createPatternCanvas(p);let u=new DOMMatrix(i);u=u.translate(a.offsetX,a.offsetY),u=u.scale(1/a.scaleX,1/a.scaleY);const d=y.createPattern(a.canvas,"repeat");try{d.setTransform(u)}catch(c){(0,_.warn)(`TilingPattern.getPattern: "${c==null?void 0:c.message}".`)}return d}}g.TilingPattern=n},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.applyMaskImageData=v;var _=U(1);function v({src:V,srcPos:H=0,dest:Q,destPos:N=0,width:A,height:k,inverseDecode:M=!1}){const P=_.FeatureTest.isLittleEndian?4278190080:255,[w,l]=M?[0,P]:[P,0],s=A>>3,n=A&7,o=V.length;Q=new Uint32Array(Q.buffer);for(let y=0;y<k;y++){for(const t=H+s;H<t;H++){const e=H<o?V[H]:255;Q[N++]=e&128?l:w,Q[N++]=e&64?l:w,Q[N++]=e&32?l:w,Q[N++]=e&16?l:w,Q[N++]=e&8?l:w,Q[N++]=e&4?l:w,Q[N++]=e&2?l:w,Q[N++]=e&1?l:w}if(n===0)continue;const p=H<o?V[H++]:255;for(let t=0;t<n;t++)Q[N++]=p&1<<7-t?l:w}return{srcPos:H,destPos:N}}},(nt,g)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.GlobalWorkerOptions=void 0;const U=Object.create(null);g.GlobalWorkerOptions=U,U.workerPort=U.workerPort===void 0?null:U.workerPort,U.workerSrc=U.workerSrc===void 0?"":U.workerSrc},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.MessageHandler=void 0;var _=U(1);const v={UNKNOWN:0,DATA:1,ERROR:2},V={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function H(N){switch(N instanceof Error||typeof N=="object"&&N!==null||(0,_.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),N.name){case"AbortException":return new _.AbortException(N.message);case"MissingPDFException":return new _.MissingPDFException(N.message);case"PasswordException":return new _.PasswordException(N.message,N.code);case"UnexpectedResponseException":return new _.UnexpectedResponseException(N.message,N.status);case"UnknownErrorException":return new _.UnknownErrorException(N.message,N.details);default:return new _.UnknownErrorException(N.message,N.toString())}}class Q{constructor(A,k,M){this.sourceName=A,this.targetName=k,this.comObj=M,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=P=>{const w=P.data;if(w.targetName!==this.sourceName)return;if(w.stream){this._processStreamMessage(w);return}if(w.callback){const s=w.callbackId,n=this.callbackCapabilities[s];if(!n)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],w.callback===v.DATA)n.resolve(w.data);else if(w.callback===v.ERROR)n.reject(H(w.reason));else throw new Error("Unexpected callback case");return}const l=this.actionHandler[w.action];if(!l)throw new Error(`Unknown action from worker: ${w.action}`);if(w.callbackId){const s=this.sourceName,n=w.sourceName;new Promise(function(o){o(l(w.data))}).then(function(o){M.postMessage({sourceName:s,targetName:n,callback:v.DATA,callbackId:w.callbackId,data:o})},function(o){M.postMessage({sourceName:s,targetName:n,callback:v.ERROR,callbackId:w.callbackId,reason:H(o)})});return}if(w.streamId){this._createStreamSink(w);return}l(w.data)},M.addEventListener("message",this._onComObjOnMessage)}on(A,k){const M=this.actionHandler;if(M[A])throw new Error(`There is already an actionName called "${A}"`);M[A]=k}send(A,k,M){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:A,data:k},M)}sendWithPromise(A,k,M){const P=this.callbackId++,w=(0,_.createPromiseCapability)();this.callbackCapabilities[P]=w;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:A,callbackId:P,data:k},M)}catch(l){w.reject(l)}return w.promise}sendWithStream(A,k,M,P){const w=this.streamId++,l=this.sourceName,s=this.targetName,n=this.comObj;return new ReadableStream({start:o=>{const y=(0,_.createPromiseCapability)();return this.streamControllers[w]={controller:o,startCall:y,pullCall:null,cancelCall:null,isClosed:!1},n.postMessage({sourceName:l,targetName:s,action:A,streamId:w,data:k,desiredSize:o.desiredSize},P),y.promise},pull:o=>{const y=(0,_.createPromiseCapability)();return this.streamControllers[w].pullCall=y,n.postMessage({sourceName:l,targetName:s,stream:V.PULL,streamId:w,desiredSize:o.desiredSize}),y.promise},cancel:o=>{(0,_.assert)(o instanceof Error,"cancel must have a valid reason");const y=(0,_.createPromiseCapability)();return this.streamControllers[w].cancelCall=y,this.streamControllers[w].isClosed=!0,n.postMessage({sourceName:l,targetName:s,stream:V.CANCEL,streamId:w,reason:H(o)}),y.promise}},M)}_createStreamSink(A){const k=A.streamId,M=this.sourceName,P=A.sourceName,w=this.comObj,l=this,s=this.actionHandler[A.action],n={enqueue(o,y=1,p){if(this.isCancelled)return;const t=this.desiredSize;this.desiredSize-=y,t>0&&this.desiredSize<=0&&(this.sinkCapability=(0,_.createPromiseCapability)(),this.ready=this.sinkCapability.promise),w.postMessage({sourceName:M,targetName:P,stream:V.ENQUEUE,streamId:k,chunk:o},p)},close(){this.isCancelled||(this.isCancelled=!0,w.postMessage({sourceName:M,targetName:P,stream:V.CLOSE,streamId:k}),delete l.streamSinks[k])},error(o){(0,_.assert)(o instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,w.postMessage({sourceName:M,targetName:P,stream:V.ERROR,streamId:k,reason:H(o)}))},sinkCapability:(0,_.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:A.desiredSize,ready:null};n.sinkCapability.resolve(),n.ready=n.sinkCapability.promise,this.streamSinks[k]=n,new Promise(function(o){o(s(A.data,n))}).then(function(){w.postMessage({sourceName:M,targetName:P,stream:V.START_COMPLETE,streamId:k,success:!0})},function(o){w.postMessage({sourceName:M,targetName:P,stream:V.START_COMPLETE,streamId:k,reason:H(o)})})}_processStreamMessage(A){const k=A.streamId,M=this.sourceName,P=A.sourceName,w=this.comObj,l=this.streamControllers[k],s=this.streamSinks[k];switch(A.stream){case V.START_COMPLETE:A.success?l.startCall.resolve():l.startCall.reject(H(A.reason));break;case V.PULL_COMPLETE:A.success?l.pullCall.resolve():l.pullCall.reject(H(A.reason));break;case V.PULL:if(!s){w.postMessage({sourceName:M,targetName:P,stream:V.PULL_COMPLETE,streamId:k,success:!0});break}s.desiredSize<=0&&A.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=A.desiredSize,new Promise(function(n){n(s.onPull&&s.onPull())}).then(function(){w.postMessage({sourceName:M,targetName:P,stream:V.PULL_COMPLETE,streamId:k,success:!0})},function(n){w.postMessage({sourceName:M,targetName:P,stream:V.PULL_COMPLETE,streamId:k,reason:H(n)})});break;case V.ENQUEUE:if((0,_.assert)(l,"enqueue should have stream controller"),l.isClosed)break;l.controller.enqueue(A.chunk);break;case V.CLOSE:if((0,_.assert)(l,"close should have stream controller"),l.isClosed)break;l.isClosed=!0,l.controller.close(),this._deleteStreamController(l,k);break;case V.ERROR:(0,_.assert)(l,"error should have stream controller"),l.controller.error(H(A.reason)),this._deleteStreamController(l,k);break;case V.CANCEL_COMPLETE:A.success?l.cancelCall.resolve():l.cancelCall.reject(H(A.reason)),this._deleteStreamController(l,k);break;case V.CANCEL:if(!s)break;new Promise(function(n){n(s.onCancel&&s.onCancel(H(A.reason)))}).then(function(){w.postMessage({sourceName:M,targetName:P,stream:V.CANCEL_COMPLETE,streamId:k,success:!0})},function(n){w.postMessage({sourceName:M,targetName:P,stream:V.CANCEL_COMPLETE,streamId:k,reason:H(n)})}),s.sinkCapability.reject(H(A.reason)),s.isCancelled=!0,delete this.streamSinks[k];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(A,k){await Promise.allSettled([A.startCall&&A.startCall.promise,A.pullCall&&A.pullCall.promise,A.cancelCall&&A.cancelCall.promise]),delete this.streamControllers[k]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}g.MessageHandler=Q},(nt,g,U)=>{var V,H;Object.defineProperty(g,"__esModule",{value:!0}),g.Metadata=void 0;var _=U(1);class v{constructor({parsedData:N,rawData:A}){at(this,V,void 0);at(this,H,void 0);mt(this,V,N),mt(this,H,A)}getRaw(){return C(this,H)}get(N){return C(this,V).get(N)??null}getAll(){return(0,_.objectFromMap)(C(this,V))}has(N){return C(this,V).has(N)}}V=new WeakMap,H=new WeakMap,g.Metadata=v},(nt,g,U)=>{var Q,N,A,k,M,P,de;Object.defineProperty(g,"__esModule",{value:!0}),g.OptionalContentConfig=void 0;var _=U(1);const v=Symbol("INTERNAL");class V{constructor(s,n){at(this,Q,!0);this.name=s,this.intent=n}get visible(){return C(this,Q)}_setVisible(s,n){s!==v&&(0,_.unreachable)("Internal method `_setVisible` called."),mt(this,Q,n)}}Q=new WeakMap;class H{constructor(s){at(this,P);at(this,N,!0);at(this,A,new Map);at(this,k,null);at(this,M,null);if(this.name=null,this.creator=null,s!==null){this.name=s.name,this.creator=s.creator,mt(this,M,s.order);for(const n of s.groups)C(this,A).set(n.id,new V(n.name,n.intent));if(s.baseState==="OFF")for(const n of C(this,A).values())n._setVisible(v,!1);for(const n of s.on)C(this,A).get(n)._setVisible(v,!0);for(const n of s.off)C(this,A).get(n)._setVisible(v,!1);mt(this,k,new Map);for(const[n,o]of C(this,A))C(this,k).set(n,o.visible)}}isVisible(s){if(C(this,A).size===0)return!0;if(!s)return(0,_.warn)("Optional content group not defined."),!0;if(s.type==="OCG")return C(this,A).has(s.id)?C(this,A).get(s.id).visible:((0,_.warn)(`Optional content group not found: ${s.id}`),!0);if(s.type==="OCMD"){if(s.expression)return ct(this,P,de).call(this,s.expression);if(!s.policy||s.policy==="AnyOn"){for(const n of s.ids){if(!C(this,A).has(n))return(0,_.warn)(`Optional content group not found: ${n}`),!0;if(C(this,A).get(n).visible)return!0}return!1}else if(s.policy==="AllOn"){for(const n of s.ids){if(!C(this,A).has(n))return(0,_.warn)(`Optional content group not found: ${n}`),!0;if(!C(this,A).get(n).visible)return!1}return!0}else if(s.policy==="AnyOff"){for(const n of s.ids){if(!C(this,A).has(n))return(0,_.warn)(`Optional content group not found: ${n}`),!0;if(!C(this,A).get(n).visible)return!0}return!1}else if(s.policy==="AllOff"){for(const n of s.ids){if(!C(this,A).has(n))return(0,_.warn)(`Optional content group not found: ${n}`),!0;if(C(this,A).get(n).visible)return!1}return!0}return(0,_.warn)(`Unknown optional content policy ${s.policy}.`),!0}return(0,_.warn)(`Unknown group type ${s.type}.`),!0}setVisibility(s,n=!0){if(!C(this,A).has(s)){(0,_.warn)(`Optional content group not found: ${s}`);return}C(this,A).get(s)._setVisible(v,!!n),mt(this,N,null)}get hasInitialVisibility(){if(C(this,N)!==null)return C(this,N);for(const[s,n]of C(this,A)){const o=C(this,k).get(s);if(n.visible!==o)return mt(this,N,!1)}return mt(this,N,!0)}getOrder(){return C(this,A).size?C(this,M)?C(this,M).slice():[...C(this,A).keys()]:null}getGroups(){return C(this,A).size>0?(0,_.objectFromMap)(C(this,A)):null}getGroup(s){return C(this,A).get(s)||null}}N=new WeakMap,A=new WeakMap,k=new WeakMap,M=new WeakMap,P=new WeakSet,de=function(s){const n=s.length;if(n<2)return!0;const o=s[0];for(let y=1;y<n;y++){const p=s[y];let t;if(Array.isArray(p))t=ct(this,P,de).call(this,p);else if(C(this,A).has(p))t=C(this,A).get(p).visible;else return(0,_.warn)(`Optional content group not found: ${p}`),!0;switch(o){case"And":if(!t)return!1;break;case"Or":if(t)return!0;break;case"Not":return!t;default:return!0}}return o==="And"},g.OptionalContentConfig=H},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.PDFDataTransportStream=void 0;var _=U(1),v=U(8);class V{constructor(A,k){(0,_.assert)(k,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=A.progressiveDone||!1,this._contentDispositionFilename=A.contentDispositionFilename||null;const M=A.initialData;if((M==null?void 0:M.length)>0){const P=new Uint8Array(M).buffer;this._queuedChunks.push(P)}this._pdfDataRangeTransport=k,this._isStreamingSupported=!A.disableStream,this._isRangeSupported=!A.disableRange,this._contentLength=A.length,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener((P,w)=>{this._onReceiveData({begin:P,chunk:w})}),this._pdfDataRangeTransport.addProgressListener((P,w)=>{this._onProgress({loaded:P,total:w})}),this._pdfDataRangeTransport.addProgressiveReadListener(P=>{this._onReceiveData({chunk:P})}),this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),this._pdfDataRangeTransport.transportReady()}_onReceiveData(A){const k=new Uint8Array(A.chunk).buffer;if(A.begin===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(k):this._queuedChunks.push(k);else{const M=this._rangeReaders.some(function(P){return P._begin!==A.begin?!1:(P._enqueue(k),!0)});(0,_.assert)(M,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var A;return((A=this._fullRequestReader)==null?void 0:A._loaded)??0}_onProgress(A){if(A.total===void 0){const k=this._rangeReaders[0];k!=null&&k.onProgress&&k.onProgress({loaded:A.loaded})}else{const k=this._fullRequestReader;k!=null&&k.onProgress&&k.onProgress({loaded:A.loaded,total:A.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(A){const k=this._rangeReaders.indexOf(A);k>=0&&this._rangeReaders.splice(k,1)}getFullReader(){(0,_.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const A=this._queuedChunks;return this._queuedChunks=null,new H(this,A,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(A,k){if(k<=this._progressiveDataLength)return null;const M=new Q(this,A,k);return this._pdfDataRangeTransport.requestDataRange(A,k),this._rangeReaders.push(M),M}cancelAllRequests(A){this._fullRequestReader&&this._fullRequestReader.cancel(A);for(const k of this._rangeReaders.slice(0))k.cancel(A);this._pdfDataRangeTransport.abort()}}g.PDFDataTransportStream=V;class H{constructor(A,k,M=!1,P=null){this._stream=A,this._done=M||!1,this._filename=(0,v.isPdfFile)(P)?P:null,this._queuedChunks=k||[],this._loaded=0;for(const w of this._queuedChunks)this._loaded+=w.byteLength;this._requests=[],this._headersReady=Promise.resolve(),A._fullRequestReader=this,this.onProgress=null}_enqueue(A){this._done||(this._requests.length>0?this._requests.shift().resolve({value:A,done:!1}):this._queuedChunks.push(A),this._loaded+=A.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const A=(0,_.createPromiseCapability)();return this._requests.push(A),A.promise}cancel(A){this._done=!0;for(const k of this._requests)k.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Q{constructor(A,k,M){this._stream=A,this._begin=k,this._end=M,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(A){if(!this._done){if(this._requests.length===0)this._queuedChunk=A;else{this._requests.shift().resolve({value:A,done:!1});for(const M of this._requests)M.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const k=this._queuedChunk;return this._queuedChunk=null,{value:k,done:!1}}if(this._done)return{value:void 0,done:!0};const A=(0,_.createPromiseCapability)();return this._requests.push(A),A.promise}cancel(A){this._done=!0;for(const k of this._requests)k.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(nt,g)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.XfaText=void 0;class U{static textContent(v){const V=[],H={items:V,styles:Object.create(null)};function Q(N){var M;if(!N)return;let A=null;const k=N.name;if(k==="#text")A=N.value;else if(U.shouldBuildText(k))(M=N==null?void 0:N.attributes)!=null&&M.textContent?A=N.attributes.textContent:N.value&&(A=N.value);else return;if(A!==null&&V.push({str:A}),!!N.children)for(const P of N.children)Q(P)}return Q(v),H}static shouldBuildText(v){return!(v==="textarea"||v==="input"||v==="option"||v==="select")}}g.XfaText=U},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.NodeStandardFontDataFactory=g.NodeCanvasFactory=g.NodeCMapReaderFactory=void 0;var _=U(9);const v=function(N){return new Promise((A,k)=>{require$$5.readFile(N,(P,w)=>{if(P||!w){k(new Error(P));return}A(new Uint8Array(w))})})};class V extends _.BaseCanvasFactory{_createCanvas(A,k){return require$$5.createCanvas(A,k)}}g.NodeCanvasFactory=V;class H extends _.BaseCMapReaderFactory{_fetchData(A,k){return v(A).then(M=>({cMapData:M,compressionType:k}))}}g.NodeCMapReaderFactory=H;class Q extends _.BaseStandardFontDataFactory{_fetchData(A){return v(A)}}g.NodeStandardFontDataFactory=Q},(nt,g,U)=>{var N,A,k,M,P,w,l,s,n,ue,y,ke,t,pe,i,Re;Object.defineProperty(g,"__esModule",{value:!0}),g.AnnotationEditorLayer=void 0;var _=U(7),v=U(1),V=U(23),H=U(24);const u=class u{constructor(c){at(this,n);at(this,y);at(this,t);at(this,i);at(this,N,void 0);at(this,A,!1);at(this,k,this.pointerup.bind(this));at(this,M,this.pointerdown.bind(this));at(this,P,new Map);at(this,w,!1);at(this,l,!1);at(this,s,void 0);u._initialized||(u._initialized=!0,V.FreeTextEditor.initialize(c.l10n),H.InkEditor.initialize(c.l10n),c.uiManager.registerEditorTypes([V.FreeTextEditor,H.InkEditor])),mt(this,s,c.uiManager),this.annotationStorage=c.annotationStorage,this.pageIndex=c.pageIndex,this.div=c.div,mt(this,N,c.accessibilityManager),C(this,s).addLayer(this)}updateToolbar(c){C(this,s).updateToolbar(c)}updateMode(c=C(this,s).getMode()){ct(this,i,Re).call(this),c===v.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),C(this,s).unselectAll()}addInkEditorIfNeeded(c){if(!c&&C(this,s).getMode()!==v.AnnotationEditorType.INK)return;if(!c){for(const X of C(this,P).values())if(X.isEmpty()){X.setInBackground();return}}ct(this,t,pe).call(this,{offsetX:0,offsetY:0}).setInBackground()}setEditingState(c){C(this,s).setEditingState(c)}addCommands(c){C(this,s).addCommands(c)}enable(){this.div.style.pointerEvents="auto";for(const c of C(this,P).values())c.enableEditing()}disable(){this.div.style.pointerEvents="none";for(const c of C(this,P).values())c.disableEditing()}setActiveEditor(c){C(this,s).getActive()!==c&&C(this,s).setActiveEditor(c)}enableClick(){this.div.addEventListener("pointerdown",C(this,M)),this.div.addEventListener("pointerup",C(this,k))}disableClick(){this.div.removeEventListener("pointerdown",C(this,M)),this.div.removeEventListener("pointerup",C(this,k))}attach(c){C(this,P).set(c.id,c)}detach(c){var S;C(this,P).delete(c.id),(S=C(this,N))==null||S.removePointerInTextLayer(c.contentDiv)}remove(c){C(this,s).removeEditor(c),this.detach(c),this.annotationStorage.remove(c.id),c.div.style.display="none",setTimeout(()=>{c.div.style.display="",c.div.remove(),c.isAttachedToDOM=!1,document.activeElement===document.body&&C(this,s).focusMainContainer()},0),C(this,l)||this.addInkEditorIfNeeded(!1)}add(c){if(ct(this,n,ue).call(this,c),C(this,s).addEditor(c),this.attach(c),!c.isAttachedToDOM){const S=c.render();this.div.append(S),c.isAttachedToDOM=!0}this.moveEditorInDOM(c),c.onceAdded(),this.addToAnnotationStorage(c)}moveEditorInDOM(c){var S;(S=C(this,N))==null||S.moveElementInDOM(this.div,c.div,c.contentDiv,!0)}addToAnnotationStorage(c){!c.isEmpty()&&!this.annotationStorage.has(c.id)&&this.annotationStorage.setValue(c.id,c)}addOrRebuild(c){c.needsToBeRebuilt()?c.rebuild():this.add(c)}addANewEditor(c){const S=()=>{this.addOrRebuild(c)},X=()=>{c.remove()};this.addCommands({cmd:S,undo:X,mustExec:!0})}addUndoableEditor(c){const S=()=>{this.addOrRebuild(c)},X=()=>{c.remove()};this.addCommands({cmd:S,undo:X,mustExec:!1})}getNextId(){return C(this,s).getId()}deserialize(c){switch(c.annotationType){case v.AnnotationEditorType.FREETEXT:return V.FreeTextEditor.deserialize(c,this);case v.AnnotationEditorType.INK:return H.InkEditor.deserialize(c,this)}return null}setSelected(c){C(this,s).setSelected(c)}toggleSelected(c){C(this,s).toggleSelected(c)}isSelected(c){return C(this,s).isSelected(c)}unselect(c){C(this,s).unselect(c)}pointerup(c){const S=_.KeyboardManager.platform.isMac;if(!(c.button!==0||c.ctrlKey&&S)&&c.target===this.div&&C(this,w)){if(mt(this,w,!1),!C(this,A)){mt(this,A,!0);return}ct(this,t,pe).call(this,c)}}pointerdown(c){const S=_.KeyboardManager.platform.isMac;if(c.button!==0||c.ctrlKey&&S||c.target!==this.div)return;mt(this,w,!0);const X=C(this,s).getActive();mt(this,A,!X||X.isEmpty())}drop(c){const S=c.dataTransfer.getData("text/plain"),X=C(this,s).getEditor(S);if(!X)return;c.preventDefault(),c.dataTransfer.dropEffect="move",ct(this,n,ue).call(this,X);const tt=this.div.getBoundingClientRect(),K=c.clientX-tt.x,Y=c.clientY-tt.y;X.translate(K-X.startX,Y-X.startY),this.moveEditorInDOM(X),X.div.focus()}dragover(c){c.preventDefault()}destroy(){var c,S;((c=C(this,s).getActive())==null?void 0:c.parent)===this&&C(this,s).setActiveEditor(null);for(const X of C(this,P).values())(S=C(this,N))==null||S.removePointerInTextLayer(X.contentDiv),X.isAttachedToDOM=!1,X.div.remove(),X.parent=null;this.div=null,C(this,P).clear(),C(this,s).removeLayer(this)}render(c){this.viewport=c.viewport,(0,_.bindEvents)(this,this.div,["dragover","drop"]),this.setDimensions();for(const S of C(this,s).getEditors(this.pageIndex))this.add(S);this.updateMode()}update(c){this.viewport=c.viewport,this.setDimensions(),this.updateMode()}get scaleFactor(){return this.viewport.scale}get pageDimensions(){const[c,S,X,tt]=this.viewport.viewBox,K=X-c,Y=tt-S;return[K,Y]}get viewportBaseDimensions(){const{width:c,height:S,rotation:X}=this.viewport;return X%180===0?[c,S]:[S,c]}setDimensions(){const{width:c,height:S,rotation:X}=this.viewport,tt=X%180!==0,K=Math.floor(c)+"px",Y=Math.floor(S)+"px";this.div.style.width=tt?Y:K,this.div.style.height=tt?K:Y,this.div.setAttribute("data-main-rotation",X)}};N=new WeakMap,A=new WeakMap,k=new WeakMap,M=new WeakMap,P=new WeakMap,w=new WeakMap,l=new WeakMap,s=new WeakMap,n=new WeakSet,ue=function(c){var S;c.parent!==this&&(this.attach(c),c.pageIndex=this.pageIndex,(S=c.parent)==null||S.detach(c),c.parent=this,c.div&&c.isAttachedToDOM&&(c.div.remove(),this.div.append(c.div)))},y=new WeakSet,ke=function(c){switch(C(this,s).getMode()){case v.AnnotationEditorType.FREETEXT:return new V.FreeTextEditor(c);case v.AnnotationEditorType.INK:return new H.InkEditor(c)}return null},t=new WeakSet,pe=function(c){const S=this.getNextId(),X=ct(this,y,ke).call(this,{parent:this,id:S,x:c.offsetX,y:c.offsetY});return X&&this.add(X),X},i=new WeakSet,Re=function(){mt(this,l,!0);for(const c of C(this,P).values())c.isEmpty()&&c.remove();mt(this,l,!1)},Mt(u,"_initialized",!1);let Q=u;g.AnnotationEditorLayer=Q},(nt,g,U)=>{var Q,N,A,k,M,P,w,l,Fe,n,Me,y,De,t,fe;Object.defineProperty(g,"__esModule",{value:!0}),g.FreeTextEditor=void 0;var _=U(1),v=U(7),V=U(6);const i=class i extends V.AnnotationEditor{constructor(d){super({...d,name:"freeTextEditor"});at(this,l);at(this,n);at(this,y);at(this,t);at(this,Q,this.editorDivBlur.bind(this));at(this,N,this.editorDivFocus.bind(this));at(this,A,this.editorDivKeydown.bind(this));at(this,k,void 0);at(this,M,"");at(this,P,!1);at(this,w,void 0);mt(this,k,d.color||i._defaultColor||V.AnnotationEditor._defaultLineColor),mt(this,w,d.fontSize||i._defaultFontSize)}static initialize(d){this._l10nPromise=new Map(["free_text_default_content","editor_free_text_aria_label"].map(S=>[S,d.get(S)]));const c=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(c.getPropertyValue("--freetext-padding"))}static updateDefaultParams(d,c){switch(d){case _.AnnotationEditorParamsType.FREETEXT_SIZE:i._defaultFontSize=c;break;case _.AnnotationEditorParamsType.FREETEXT_COLOR:i._defaultColor=c;break}}updateParams(d,c){switch(d){case _.AnnotationEditorParamsType.FREETEXT_SIZE:ct(this,l,Fe).call(this,c);break;case _.AnnotationEditorParamsType.FREETEXT_COLOR:ct(this,n,Me).call(this,c);break}}static get defaultPropertiesToUpdate(){return[[_.AnnotationEditorParamsType.FREETEXT_SIZE,i._defaultFontSize],[_.AnnotationEditorParamsType.FREETEXT_COLOR,i._defaultColor||V.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[_.AnnotationEditorParamsType.FREETEXT_SIZE,C(this,w)],[_.AnnotationEditorParamsType.FREETEXT_COLOR,C(this,k)]]}getInitialTranslation(){return[-i._internalPadding*this.parent.scaleFactor,-(i._internalPadding+C(this,w))*this.parent.scaleFactor]}rebuild(){super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(_.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.enableEditing(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this.div.draggable=!1,this.editorDiv.addEventListener("keydown",C(this,A)),this.editorDiv.addEventListener("focus",C(this,N)),this.editorDiv.addEventListener("blur",C(this,Q)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.disableEditing(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.draggable=!0,this.editorDiv.removeEventListener("keydown",C(this,A)),this.editorDiv.removeEventListener("focus",C(this,N)),this.editorDiv.removeEventListener("blur",C(this,Q)),this.div.focus(),this.isEditing=!1)}focusin(d){super.focusin(d),d.target!==this.editorDiv&&this.editorDiv.focus()}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus())}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent.setEditingState(!0),super.remove()}commit(){super.commit(),C(this,P)||(mt(this,P,!0),this.parent.addUndoableEditor(this)),this.disableEditMode(),mt(this,M,ct(this,y,De).call(this).trimEnd()),ct(this,t,fe).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}dblclick(d){this.enableEditMode(),this.editorDiv.focus()}keydown(d){d.target===this.div&&d.key==="Enter"&&(this.enableEditMode(),this.editorDiv.focus())}editorDivKeydown(d){i._keyboardManager.exec(this,d)}editorDivFocus(d){this.isEditing=!0}editorDivBlur(d){this.isEditing=!1}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let d,c;this.width&&(d=this.x,c=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",`${this.id}-editor`),this.enableEditing(),i._l10nPromise.get("editor_free_text_aria_label").then(X=>{var tt;return(tt=this.editorDiv)==null?void 0:tt.setAttribute("aria-label",X)}),i._l10nPromise.get("free_text_default_content").then(X=>{var tt;return(tt=this.editorDiv)==null?void 0:tt.setAttribute("default-content",X)}),this.editorDiv.contentEditable=!0;const{style:S}=this.editorDiv;if(S.fontSize=`calc(${C(this,w)}px * var(--scale-factor))`,S.color=C(this,k),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,v.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){const[X,tt]=this.parent.viewportBaseDimensions;this.setAt(d*X,c*tt,this.width*X,this.height*tt);for(const K of C(this,M).split(`
131
+ `)){const Y=document.createElement("div");Y.append(K?document.createTextNode(K):document.createElement("br")),this.editorDiv.append(Y)}this.div.draggable=!0,this.editorDiv.contentEditable=!1}else this.div.draggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(d,c){const S=super.deserialize(d,c);return mt(S,w,d.fontSize),mt(S,k,_.Util.makeHexColor(...d.color)),mt(S,M,d.value),S}serialize(){if(this.isEmpty())return null;const d=i._internalPadding*this.parent.scaleFactor,c=this.getRect(d,d),S=V.AnnotationEditor._colorManager.convert(getComputedStyle(this.editorDiv).color);return{annotationType:_.AnnotationEditorType.FREETEXT,color:S,fontSize:C(this,w),value:C(this,M),pageIndex:this.parent.pageIndex,rect:c,rotation:this.rotation}}};Q=new WeakMap,N=new WeakMap,A=new WeakMap,k=new WeakMap,M=new WeakMap,P=new WeakMap,w=new WeakMap,l=new WeakSet,Fe=function(d){const c=X=>{this.editorDiv.style.fontSize=`calc(${X}px * var(--scale-factor))`,this.translate(0,-(X-C(this,w))*this.parent.scaleFactor),mt(this,w,X),ct(this,t,fe).call(this)},S=C(this,w);this.parent.addCommands({cmd:()=>{c(d)},undo:()=>{c(S)},mustExec:!0,type:_.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},n=new WeakSet,Me=function(d){const c=C(this,k);this.parent.addCommands({cmd:()=>{mt(this,k,d),this.editorDiv.style.color=d},undo:()=>{mt(this,k,c),this.editorDiv.style.color=c},mustExec:!0,type:_.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},y=new WeakSet,De=function(){const d=this.editorDiv.getElementsByTagName("div");if(d.length===0)return this.editorDiv.innerText;const c=[];for(let S=0,X=d.length;S<X;S++){const K=d[S].firstChild;(K==null?void 0:K.nodeName)==="#text"?c.push(K.data):c.push("")}return c.join(`
132
+ `)},t=new WeakSet,fe=function(){const[d,c]=this.parent.viewportBaseDimensions,S=this.div.getBoundingClientRect();this.width=S.width/d,this.height=S.height/c},Mt(i,"_freeTextDefaultContent",""),Mt(i,"_l10nPromise"),Mt(i,"_internalPadding",0),Mt(i,"_defaultColor",null),Mt(i,"_defaultFontSize",10),Mt(i,"_keyboardManager",new v.KeyboardManager([[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],i.prototype.commitOrRemove]])),Mt(i,"_type","freetext");let H=i;g.FreeTextEditor=H},(nt,g,U)=>{var A,k,M,P,w,l,s,n,o,y,p,t,e,i,a,Ie,d,Oe,S,Le,tt,Ne,Y,ge,q,Be,it,Ue,yt,je,f,Gt,E,me,D,ee,G,ie,r,Yt,b,be,T,se,st,ye,Z,We,et,He,pt,qe,ut,_e,St,ne,Et,Kt,Rt,Ae;Object.defineProperty(g,"__esModule",{value:!0}),g.InkEditor=void 0,Object.defineProperty(g,"fitCurve",{enumerable:!0,get:function(){return V.fitCurve}});var _=U(1),v=U(6),V=U(25),H=U(7);const Q=16,wt=class wt extends v.AnnotationEditor{constructor(rt){super({...rt,name:"inkEditor"});at(this,a);at(this,d);at(this,S);at(this,tt);at(this,Y);at(this,q);at(this,it);at(this,yt);at(this,f);at(this,E);at(this,D);at(this,G);at(this,r);at(this,b);at(this,T);at(this,Z);at(this,et);at(this,pt);at(this,ut);at(this,St);at(this,Et);at(this,Rt);at(this,A,0);at(this,k,0);at(this,M,0);at(this,P,this.canvasPointermove.bind(this));at(this,w,this.canvasPointerleave.bind(this));at(this,l,this.canvasPointerup.bind(this));at(this,s,this.canvasPointerdown.bind(this));at(this,n,!1);at(this,o,!1);at(this,y,null);at(this,p,null);at(this,t,0);at(this,e,0);at(this,i,null);this.color=rt.color||null,this.thickness=rt.thickness||null,this.opacity=rt.opacity||null,this.paths=[],this.bezierPath2D=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0}static initialize(rt){this._l10nPromise=new Map(["editor_ink_canvas_aria_label","editor_ink_aria_label"].map(ft=>[ft,rt.get(ft)]))}static updateDefaultParams(rt,ft){switch(rt){case _.AnnotationEditorParamsType.INK_THICKNESS:wt._defaultThickness=ft;break;case _.AnnotationEditorParamsType.INK_COLOR:wt._defaultColor=ft;break;case _.AnnotationEditorParamsType.INK_OPACITY:wt._defaultOpacity=ft/100;break}}updateParams(rt,ft){switch(rt){case _.AnnotationEditorParamsType.INK_THICKNESS:ct(this,a,Ie).call(this,ft);break;case _.AnnotationEditorParamsType.INK_COLOR:ct(this,d,Oe).call(this,ft);break;case _.AnnotationEditorParamsType.INK_OPACITY:ct(this,S,Le).call(this,ft);break}}static get defaultPropertiesToUpdate(){return[[_.AnnotationEditorParamsType.INK_THICKNESS,wt._defaultThickness],[_.AnnotationEditorParamsType.INK_COLOR,wt._defaultColor||v.AnnotationEditor._defaultLineColor],[_.AnnotationEditorParamsType.INK_OPACITY,Math.round(wt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[_.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||wt._defaultThickness],[_.AnnotationEditorParamsType.INK_COLOR,this.color||wt._defaultColor||v.AnnotationEditor._defaultLineColor],[_.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(this.opacity??wt._defaultOpacity))]]}rebuild(){super.rebuild(),this.div!==null&&(this.canvas||(ct(this,D,ee).call(this),ct(this,G,ie).call(this)),this.isAttachedToDOM||(this.parent.add(this),ct(this,r,Yt).call(this)),ct(this,Et,Kt).call(this))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,C(this,p).disconnect(),mt(this,p,null),super.remove())}enableEditMode(){C(this,n)||this.canvas===null||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",C(this,s)),this.canvas.addEventListener("pointerup",C(this,l)))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",C(this,s)),this.canvas.removeEventListener("pointerup",C(this,l)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){C(this,n)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),mt(this,n,!0),this.div.classList.add("disabled"),ct(this,Et,Kt).call(this,!0),this.parent.addInkEditorIfNeeded(!0),this.parent.moveEditorInDOM(this),this.div.focus())}focusin(rt){super.focusin(rt),this.enableEditMode()}canvasPointerdown(rt){rt.button!==0||!this.isInEditMode()||C(this,n)||(this.setInForeground(),rt.type!=="mouse"&&this.div.focus(),rt.stopPropagation(),this.canvas.addEventListener("pointerleave",C(this,w)),this.canvas.addEventListener("pointermove",C(this,P)),ct(this,q,Be).call(this,rt.offsetX,rt.offsetY))}canvasPointermove(rt){rt.stopPropagation(),ct(this,it,Ue).call(this,rt.offsetX,rt.offsetY)}canvasPointerup(rt){rt.button===0&&this.isInEditMode()&&this.currentPath.length!==0&&(rt.stopPropagation(),ct(this,E,me).call(this,rt),this.setInBackground())}canvasPointerleave(rt){ct(this,E,me).call(this,rt),this.setInBackground()}render(){if(this.div)return this.div;let rt,ft;this.width&&(rt=this.x,ft=this.y),super.render(),wt._l10nPromise.get("editor_ink_aria_label").then(bt=>{var At;return(At=this.div)==null?void 0:At.setAttribute("aria-label",bt)});const[J,j,W,gt]=ct(this,tt,Ne).call(this);if(this.setAt(J,j,0,0),this.setDims(W,gt),ct(this,D,ee).call(this),this.width){const[bt,At]=this.parent.viewportBaseDimensions;this.setAt(rt*bt,ft*At,this.width*bt,this.height*At),mt(this,o,!0),ct(this,r,Yt).call(this),this.setDims(this.width*bt,this.height*At),ct(this,f,Gt).call(this),ct(this,Rt,Ae).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return ct(this,G,ie).call(this),this.div}setDimensions(rt,ft){const J=Math.round(rt),j=Math.round(ft);if(C(this,t)===J&&C(this,e)===j)return;mt(this,t,J),mt(this,e,j),this.canvas.style.visibility="hidden",C(this,A)&&Math.abs(C(this,A)-rt/ft)>.01&&(ft=Math.ceil(rt/C(this,A)),this.setDims(rt,ft));const[W,gt]=this.parent.viewportBaseDimensions;this.width=rt/W,this.height=ft/gt,C(this,n)&&ct(this,b,be).call(this,rt,ft),ct(this,r,Yt).call(this),ct(this,f,Gt).call(this),this.canvas.style.visibility="visible"}static deserialize(rt,ft){var It,kt;const J=super.deserialize(rt,ft);J.thickness=rt.thickness,J.color=_.Util.makeHexColor(...rt.color),J.opacity=rt.opacity;const[j,W]=ft.pageDimensions,gt=J.width*j,bt=J.height*W,At=ft.scaleFactor,vt=rt.thickness/2;mt(J,A,gt/bt),mt(J,n,!0),mt(J,t,Math.round(gt)),mt(J,e,Math.round(bt));for(const{bezier:Pt}of rt.paths){const Lt=[];J.paths.push(Lt);let Ot=At*(Pt[0]-vt),Ut=At*(bt-Pt[1]-vt);for(let Nt=2,Wt=Pt.length;Nt<Wt;Nt+=6){const $t=At*(Pt[Nt]-vt),Xt=At*(bt-Pt[Nt+1]-vt),qt=At*(Pt[Nt+2]-vt),Bt=At*(bt-Pt[Nt+3]-vt),Ht=At*(Pt[Nt+4]-vt),Vt=At*(bt-Pt[Nt+5]-vt);Lt.push([[Ot,Ut],[$t,Xt],[qt,Bt],[Ht,Vt]]),Ot=Ht,Ut=Vt}const Tt=ct(this,st,ye).call(this,Lt);J.bezierPath2D.push(Tt)}const Ct=ct(It=J,ut,_e).call(It);return mt(J,M,Math.max(Q,Ct[2]-Ct[0])),mt(J,k,Math.max(Q,Ct[3]-Ct[1])),ct(kt=J,b,be).call(kt,gt,bt),J}serialize(){if(this.isEmpty())return null;const rt=this.getRect(0,0),ft=this.rotation%180===0?rt[3]-rt[1]:rt[2]-rt[0],J=v.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);return{annotationType:_.AnnotationEditorType.INK,color:J,thickness:this.thickness,opacity:this.opacity,paths:ct(this,Z,We).call(this,this.scaleFactor/this.parent.scaleFactor,this.translationX,this.translationY,ft),pageIndex:this.parent.pageIndex,rect:rt,rotation:this.rotation}}};A=new WeakMap,k=new WeakMap,M=new WeakMap,P=new WeakMap,w=new WeakMap,l=new WeakMap,s=new WeakMap,n=new WeakMap,o=new WeakMap,y=new WeakMap,p=new WeakMap,t=new WeakMap,e=new WeakMap,i=new WeakMap,a=new WeakSet,Ie=function(rt){const ft=this.thickness;this.parent.addCommands({cmd:()=>{this.thickness=rt,ct(this,Et,Kt).call(this)},undo:()=>{this.thickness=ft,ct(this,Et,Kt).call(this)},mustExec:!0,type:_.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},d=new WeakSet,Oe=function(rt){const ft=this.color;this.parent.addCommands({cmd:()=>{this.color=rt,ct(this,f,Gt).call(this)},undo:()=>{this.color=ft,ct(this,f,Gt).call(this)},mustExec:!0,type:_.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},S=new WeakSet,Le=function(rt){rt/=100;const ft=this.opacity;this.parent.addCommands({cmd:()=>{this.opacity=rt,ct(this,f,Gt).call(this)},undo:()=>{this.opacity=ft,ct(this,f,Gt).call(this)},mustExec:!0,type:_.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},tt=new WeakSet,Ne=function(){const{width:rt,height:ft,rotation:J}=this.parent.viewport;switch(J){case 90:return[0,rt,rt,ft];case 180:return[rt,ft,rt,ft];case 270:return[ft,0,rt,ft];default:return[0,0,rt,ft]}},Y=new WeakSet,ge=function(){this.ctx.lineWidth=this.thickness*this.parent.scaleFactor/this.scaleFactor,this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.miterLimit=10,this.ctx.strokeStyle=`${this.color}${(0,H.opacityToHex)(this.opacity)}`},q=new WeakSet,Be=function(rt,ft){this.isEditing=!0,C(this,o)||(mt(this,o,!0),ct(this,r,Yt).call(this),this.thickness||(this.thickness=wt._defaultThickness),this.color||(this.color=wt._defaultColor||v.AnnotationEditor._defaultLineColor),this.opacity??(this.opacity=wt._defaultOpacity)),this.currentPath.push([rt,ft]),mt(this,y,null),ct(this,Y,ge).call(this),this.ctx.beginPath(),this.ctx.moveTo(rt,ft),mt(this,i,()=>{C(this,i)&&(C(this,y)&&(this.isEmpty()?(this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)):ct(this,f,Gt).call(this),this.ctx.lineTo(...C(this,y)),mt(this,y,null),this.ctx.stroke()),window.requestAnimationFrame(C(this,i)))}),window.requestAnimationFrame(C(this,i))},it=new WeakSet,Ue=function(rt,ft){const[J,j]=this.currentPath.at(-1);rt===J&&ft===j||(this.currentPath.push([rt,ft]),mt(this,y,[rt,ft]))},yt=new WeakSet,je=function(rt,ft){var vt;this.ctx.closePath(),mt(this,i,null),rt=Math.min(Math.max(rt,0),this.canvas.width),ft=Math.min(Math.max(ft,0),this.canvas.height);const[J,j]=this.currentPath.at(-1);(rt!==J||ft!==j)&&this.currentPath.push([rt,ft]);let W;if(this.currentPath.length!==1)W=(0,V.fitCurve)(this.currentPath,30,null);else{const Ct=[rt,ft];W=[[Ct,Ct.slice(),Ct.slice(),Ct]]}const gt=ct(vt=wt,st,ye).call(vt,W);this.currentPath.length=0;const bt=()=>{this.paths.push(W),this.bezierPath2D.push(gt),this.rebuild()},At=()=>{this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(ct(this,D,ee).call(this),ct(this,G,ie).call(this)),ct(this,Et,Kt).call(this))};this.parent.addCommands({cmd:bt,undo:At,mustExec:!0})},f=new WeakSet,Gt=function(){if(this.isEmpty()){ct(this,T,se).call(this);return}ct(this,Y,ge).call(this);const{canvas:rt,ctx:ft}=this;ft.setTransform(1,0,0,1,0,0),ft.clearRect(0,0,rt.width,rt.height),ct(this,T,se).call(this);for(const J of this.bezierPath2D)ft.stroke(J)},E=new WeakSet,me=function(rt){ct(this,yt,je).call(this,rt.offsetX,rt.offsetY),this.canvas.removeEventListener("pointerleave",C(this,w)),this.canvas.removeEventListener("pointermove",C(this,P)),this.parent.addToAnnotationStorage(this)},D=new WeakSet,ee=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",wt._l10nPromise.get("editor_ink_canvas_aria_label").then(rt=>{var ft;return(ft=this.canvas)==null?void 0:ft.setAttribute("aria-label",rt)}),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},G=new WeakSet,ie=function(){mt(this,p,new ResizeObserver(rt=>{const ft=rt[0].contentRect;ft.width&&ft.height&&this.setDimensions(ft.width,ft.height)})),C(this,p).observe(this.div)},r=new WeakSet,Yt=function(){if(!C(this,o))return;const[rt,ft]=this.parent.viewportBaseDimensions;this.canvas.width=Math.ceil(this.width*rt),this.canvas.height=Math.ceil(this.height*ft),ct(this,T,se).call(this)},b=new WeakSet,be=function(rt,ft){const J=ct(this,St,ne).call(this),j=(rt-J)/C(this,M),W=(ft-J)/C(this,k);this.scaleFactor=Math.min(j,W)},T=new WeakSet,se=function(){const rt=ct(this,St,ne).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+rt,this.translationY*this.scaleFactor+rt)},st=new WeakSet,ye=function(rt){const ft=new Path2D;for(let J=0,j=rt.length;J<j;J++){const[W,gt,bt,At]=rt[J];J===0&&ft.moveTo(...W),ft.bezierCurveTo(gt[0],gt[1],bt[0],bt[1],At[0],At[1])}return ft},Z=new WeakSet,We=function(rt,ft,J,j){const gt=[],bt=this.thickness/2;let At,vt;for(const Ct of this.paths){At=[],vt=[];for(let It=0,kt=Ct.length;It<kt;It++){const[Pt,Lt,Ot,Ut]=Ct[It],Tt=rt*(Pt[0]+ft)+bt,Nt=j-rt*(Pt[1]+J)-bt,Wt=rt*(Lt[0]+ft)+bt,$t=j-rt*(Lt[1]+J)-bt,Xt=rt*(Ot[0]+ft)+bt,qt=j-rt*(Ot[1]+J)-bt,Bt=rt*(Ut[0]+ft)+bt,Ht=j-rt*(Ut[1]+J)-bt;It===0&&(At.push(Tt,Nt),vt.push(Tt,Nt)),At.push(Wt,$t,Xt,qt,Bt,Ht),ct(this,et,He).call(this,Tt,Nt,Wt,$t,Xt,qt,Bt,Ht,4,vt)}gt.push({bezier:At,points:vt})}return gt},et=new WeakSet,He=function(rt,ft,J,j,W,gt,bt,At,vt,Ct){if(ct(this,pt,qe).call(this,rt,ft,J,j,W,gt,bt,At)){Ct.push(bt,At);return}for(let It=1;It<vt-1;It++){const kt=It/vt,Pt=1-kt;let Lt=kt*rt+Pt*J,Ot=kt*ft+Pt*j,Ut=kt*J+Pt*W,Tt=kt*j+Pt*gt;const Nt=kt*W+Pt*bt,Wt=kt*gt+Pt*At;Lt=kt*Lt+Pt*Ut,Ot=kt*Ot+Pt*Tt,Ut=kt*Ut+Pt*Nt,Tt=kt*Tt+Pt*Wt,Lt=kt*Lt+Pt*Ut,Ot=kt*Ot+Pt*Tt,Ct.push(Lt,Ot)}Ct.push(bt,At)},pt=new WeakSet,qe=function(rt,ft,J,j,W,gt,bt,At){const Ct=(3*J-2*rt-bt)**2,It=(3*j-2*ft-At)**2,kt=(3*W-rt-2*bt)**2,Pt=(3*gt-ft-2*At)**2;return Math.max(Ct,kt)+Math.max(It,Pt)<=10},ut=new WeakSet,_e=function(){let rt=1/0,ft=-1/0,J=1/0,j=-1/0;for(const W of this.paths)for(const[gt,bt,At,vt]of W){const Ct=_.Util.bezierBoundingBox(...gt,...bt,...At,...vt);rt=Math.min(rt,Ct[0]),J=Math.min(J,Ct[1]),ft=Math.max(ft,Ct[2]),j=Math.max(j,Ct[3])}return[rt,J,ft,j]},St=new WeakSet,ne=function(){return C(this,n)?Math.ceil(this.thickness*this.parent.scaleFactor):0},Et=new WeakSet,Kt=function(rt=!1){if(this.isEmpty())return;if(!C(this,n)){ct(this,f,Gt).call(this);return}const ft=ct(this,ut,_e).call(this),J=ct(this,St,ne).call(this);mt(this,M,Math.max(Q,ft[2]-ft[0])),mt(this,k,Math.max(Q,ft[3]-ft[1]));const j=Math.ceil(J+C(this,M)*this.scaleFactor),W=Math.ceil(J+C(this,k)*this.scaleFactor),[gt,bt]=this.parent.viewportBaseDimensions;this.width=j/gt,this.height=W/bt,mt(this,A,j/W),ct(this,Rt,Ae).call(this);const At=this.translationX,vt=this.translationY;this.translationX=-ft[0],this.translationY=-ft[1],ct(this,r,Yt).call(this),ct(this,f,Gt).call(this),mt(this,t,j),mt(this,e,W),this.setDims(j,W);const Ct=rt?J/this.scaleFactor/2:0;this.translate(At-this.translationX-Ct,vt-this.translationY-Ct)},Rt=new WeakSet,Ae=function(){const{style:rt}=this.div;C(this,A)>=1?(rt.minHeight=`${Q}px`,rt.minWidth=`${Math.round(C(this,A)*Q)}px`):(rt.minWidth=`${Q}px`,rt.minHeight=`${Math.round(Q/C(this,A))}px`)},at(wt,st),Mt(wt,"_defaultColor",null),Mt(wt,"_defaultOpacity",1),Mt(wt,"_defaultThickness",1),Mt(wt,"_l10nPromise"),Mt(wt,"_type","ink");let N=wt;g.InkEditor=N},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.fitCurve=void 0;const _=U(26);g.fitCurve=_},nt=>{function g(l,s,n){if(!Array.isArray(l))throw new TypeError("First argument should be an array");if(l.forEach(t=>{if(!Array.isArray(t)||t.some(e=>typeof e!="number")||t.length!==l[0].length)throw Error("Each point should be an array of numbers. Each point should have the same amount of numbers.")}),l=l.filter((t,e)=>e===0||!t.every((i,a)=>i===l[e-1][a])),l.length<2)return[];const o=l.length,y=M(l[1],l[0]),p=M(l[o-2],l[o-1]);return U(l,y,p,s,n)}function U(l,s,n,o,y){var t,e,i,a,u,d,c,S,X,tt,K,Y,B;if(l.length===2)return Y=P.vectorLen(P.subtract(l[0],l[1]))/3,t=[l[0],P.addArrays(l[0],P.mulItems(s,Y)),P.addArrays(l[1],P.mulItems(n,Y)),l[1]],[t];if(e=Q(l),[t,a,d]=_(l,e,e,s,n,y),a===0||a<o)return[t];if(a<o*o)for(i=e,u=a,c=d,B=0;B<20;B++){if(i=V(t,l,i),[t,a,d]=_(l,e,i,s,n,y),a<o)return[t];if(d===c){let q=a/u;if(q>.9999&&q<1.0001)break}u=a,c=d}return K=[],S=P.subtract(l[d-1],l[d+1]),S.every(q=>q===0)&&(S=P.subtract(l[d-1],l[d]),[S[0],S[1]]=[-S[1],S[0]]),X=P.normalize(S),tt=P.mulItems(X,-1),K=K.concat(U(l.slice(0,d+1),s,X,o,y)),K=K.concat(U(l.slice(d),tt,n,o,y)),K}function _(l,s,n,o,y,p){var t,e,i;return t=v(l,n,o,y),[e,i]=N(l,t,s),p&&p({bez:t,points:l,params:s,maxErr:e,maxPoint:i}),[t,e,i]}function v(l,s,n,o){var y,p,t,e,i,a,u,d,c,S,X,tt,K,Y,B,q,$,it=l[0],ht=l[l.length-1];for(y=[it,null,null,ht],p=P.zeros_Xx2x2(s.length),K=0,Y=s.length;K<Y;K++)q=s[K],$=1-q,t=p[K],t[0]=P.mulItems(n,3*q*($*$)),t[1]=P.mulItems(o,3*$*(q*q));for(e=[[0,0],[0,0]],i=[0,0],K=0,Y=l.length;K<Y;K++)q=s[K],t=p[K],e[0][0]+=P.dot(t[0],t[0]),e[0][1]+=P.dot(t[0],t[1]),e[1][0]+=P.dot(t[0],t[1]),e[1][1]+=P.dot(t[1],t[1]),B=P.subtract(l[K],w.q([it,it,ht,ht],q)),i[0]+=P.dot(t[0],B),i[1]+=P.dot(t[1],B);return a=e[0][0]*e[1][1]-e[1][0]*e[0][1],u=e[0][0]*i[1]-e[1][0]*i[0],d=i[0]*e[1][1]-i[1]*e[0][1],c=a===0?0:d/a,S=a===0?0:u/a,tt=P.vectorLen(P.subtract(it,ht)),X=1e-6*tt,c<X||S<X?(y[1]=P.addArrays(it,P.mulItems(n,tt/3)),y[2]=P.addArrays(ht,P.mulItems(o,tt/3))):(y[1]=P.addArrays(it,P.mulItems(n,c)),y[2]=P.addArrays(ht,P.mulItems(o,S))),y}function V(l,s,n){return n.map((o,y)=>H(l,s[y],o))}function H(l,s,n){var o=P.subtract(w.q(l,n),s),y=w.qprime(l,n),p=P.mulMatrix(o,y),t=P.sum(P.squareItems(y))+2*P.mulMatrix(o,w.qprimeprime(l,n));return t===0?n:n-p/t}function Q(l){var s=[],n,o,y;return l.forEach((p,t)=>{n=t?o+P.vectorLen(P.subtract(p,y)):0,s.push(n),o=n,y=p}),s=s.map(p=>p/o),s}function N(l,s,n){var o,y,p,t,e,i,a,u;y=0,p=Math.floor(l.length/2);const d=A(s,10);for(e=0,i=l.length;e<i;e++)a=l[e],u=k(s,n[e],d,10),t=P.subtract(w.q(s,u),a),o=t[0]*t[0]+t[1]*t[1],o>y&&(y=o,p=e);return[y,p]}var A=function(l,s){for(var n,o=[0],y=l[0],p=0,t=1;t<=s;t++)n=w.q(l,t/s),p+=P.vectorLen(P.subtract(n,y)),o.push(p),y=n;return o=o.map(e=>e/p),o};function k(l,s,n,o){if(s<0)return 0;if(s>1)return 1;for(var y,p,t,e,i,a=1;a<=o;a++)if(s<=n[a]){e=(a-1)/o,t=a/o,p=n[a-1],y=n[a],i=(s-p)/(y-p)*(t-e)+e;break}return i}function M(l,s){return P.normalize(P.subtract(l,s))}class P{static zeros_Xx2x2(s){for(var n=[];s--;)n.push([0,0]);return n}static mulItems(s,n){return s.map(o=>o*n)}static mulMatrix(s,n){return s.reduce((o,y,p)=>o+y*n[p],0)}static subtract(s,n){return s.map((o,y)=>o-n[y])}static addArrays(s,n){return s.map((o,y)=>o+n[y])}static addItems(s,n){return s.map(o=>o+n)}static sum(s){return s.reduce((n,o)=>n+o)}static dot(s,n){return P.mulMatrix(s,n)}static vectorLen(s){return Math.hypot(...s)}static divItems(s,n){return s.map(o=>o/n)}static squareItems(s){return s.map(n=>n*n)}static normalize(s){return this.divItems(s,this.vectorLen(s))}}class w{static q(s,n){var o=1-n,y=P.mulItems(s[0],o*o*o),p=P.mulItems(s[1],3*o*o*n),t=P.mulItems(s[2],3*o*n*n),e=P.mulItems(s[3],n*n*n);return P.addArrays(P.addArrays(y,p),P.addArrays(t,e))}static qprime(s,n){var o=1-n,y=P.mulItems(P.subtract(s[1],s[0]),3*o*o),p=P.mulItems(P.subtract(s[2],s[1]),6*o*n),t=P.mulItems(P.subtract(s[3],s[2]),3*n*n);return P.addArrays(P.addArrays(y,p),t)}static qprimeprime(s,n){return P.addArrays(P.mulItems(P.addArrays(P.subtract(s[2],P.mulItems(s[1],2)),s[0]),6*(1-n)),P.mulItems(P.addArrays(P.subtract(s[3],P.mulItems(s[2],2)),s[1]),6*n))}}nt.exports=g,nt.exports.fitCubic=U,nt.exports.createTangent=M},(nt,g,U)=>{var f,Se,E,ve,D,xe;Object.defineProperty(g,"__esModule",{value:!0}),g.AnnotationLayer=void 0;var _=U(1),v=U(8),V=U(5),H=U(28),Q=U(29);const N=1e3,A=9,k=new WeakSet;function M(z){return{width:z[2]-z[0],height:z[3]-z[1]}}class P{static create(r){switch(r.data.annotationType){case _.AnnotationType.LINK:return new l(r);case _.AnnotationType.TEXT:return new s(r);case _.AnnotationType.WIDGET:switch(r.data.fieldType){case"Tx":return new o(r);case"Btn":return r.data.radioButton?new p(r):r.data.checkBox?new y(r):new t(r);case"Ch":return new e(r)}return new n(r);case _.AnnotationType.POPUP:return new i(r);case _.AnnotationType.FREETEXT:return new u(r);case _.AnnotationType.LINE:return new d(r);case _.AnnotationType.SQUARE:return new c(r);case _.AnnotationType.CIRCLE:return new S(r);case _.AnnotationType.POLYLINE:return new X(r);case _.AnnotationType.CARET:return new K(r);case _.AnnotationType.INK:return new Y(r);case _.AnnotationType.POLYGON:return new tt(r);case _.AnnotationType.HIGHLIGHT:return new B(r);case _.AnnotationType.UNDERLINE:return new q(r);case _.AnnotationType.SQUIGGLY:return new $(r);case _.AnnotationType.STRIKEOUT:return new it(r);case _.AnnotationType.STAMP:return new ht(r);case _.AnnotationType.FILEATTACHMENT:return new yt(r);default:return new w(r)}}}class w{constructor(r,{isRenderable:m=!1,ignoreBorder:b=!1,createQuadrilaterals:x=!1}={}){this.isRenderable=m,this.data=r.data,this.layer=r.layer,this.page=r.page,this.viewport=r.viewport,this.linkService=r.linkService,this.downloadManager=r.downloadManager,this.imageResourcesPath=r.imageResourcesPath,this.renderForms=r.renderForms,this.svgFactory=r.svgFactory,this.annotationStorage=r.annotationStorage,this.enableScripting=r.enableScripting,this.hasJSActions=r.hasJSActions,this._fieldObjects=r.fieldObjects,this._mouseState=r.mouseState,m&&(this.container=this._createContainer(b)),x&&(this.quadrilaterals=this._createQuadrilaterals(b))}_createContainer(r=!1){const m=this.data,b=this.page,x=this.viewport,T=document.createElement("section"),{width:L,height:st}=M(m.rect),[dt,Z,ot,et]=x.viewBox,lt=ot-dt,pt=et-Z;T.setAttribute("data-annotation-id",m.id);const R=_.Util.normalizeRect([m.rect[0],b.view[3]-m.rect[1]+b.view[1],m.rect[2],b.view[3]-m.rect[3]+b.view[1]]);if(!r&&m.borderStyle.width>0){T.style.borderWidth=`${m.borderStyle.width}px`;const _t=m.borderStyle.horizontalCornerRadius,St=m.borderStyle.verticalCornerRadius;if(_t>0||St>0){const Et=`calc(${_t}px * var(--scale-factor)) / calc(${St}px * var(--scale-factor))`;T.style.borderRadius=Et}else if(this instanceof p){const Et=`calc(${L}px * var(--scale-factor)) / calc(${st}px * var(--scale-factor))`;T.style.borderRadius=Et}switch(m.borderStyle.style){case _.AnnotationBorderStyleType.SOLID:T.style.borderStyle="solid";break;case _.AnnotationBorderStyleType.DASHED:T.style.borderStyle="dashed";break;case _.AnnotationBorderStyleType.BEVELED:(0,_.warn)("Unimplemented border style: beveled");break;case _.AnnotationBorderStyleType.INSET:(0,_.warn)("Unimplemented border style: inset");break;case _.AnnotationBorderStyleType.UNDERLINE:T.style.borderBottomStyle="solid";break}const xt=m.borderColor||null;xt?T.style.borderColor=_.Util.makeHexColor(xt[0]|0,xt[1]|0,xt[2]|0):T.style.borderWidth=0}T.style.left=`${100*(R[0]-dt)/lt}%`,T.style.top=`${100*(R[1]-Z)/pt}%`;const{rotation:ut}=m;return m.hasOwnCanvas||ut===0?(T.style.width=`${100*L/lt}%`,T.style.height=`${100*st/pt}%`):this.setRotation(ut,T),T}setRotation(r,m=this.container){const[b,x,T,L]=this.viewport.viewBox,st=T-b,dt=L-x,{width:Z,height:ot}=M(this.data.rect);let et,lt;r%180===0?(et=100*Z/st,lt=100*ot/dt):(et=100*ot/st,lt=100*Z/dt),m.style.width=`${et}%`,m.style.height=`${lt}%`,m.setAttribute("data-main-rotation",(360-r)%360)}get _commonActions(){const r=(m,b,x)=>{const T=x.detail[m];x.target.style[b]=H.ColorConverters[`${T[0]}_HTML`](T.slice(1))};return(0,_.shadow)(this,"_commonActions",{display:m=>{const b=m.detail.display%2===1;this.container.style.visibility=b?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:b,print:m.detail.display===0||m.detail.display===3})},print:m=>{this.annotationStorage.setValue(this.data.id,{print:m.detail.print})},hidden:m=>{this.container.style.visibility=m.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:m.detail.hidden})},focus:m=>{setTimeout(()=>m.target.focus({preventScroll:!1}),0)},userName:m=>{m.target.title=m.detail.userName},readonly:m=>{m.detail.readonly?m.target.setAttribute("readonly",""):m.target.removeAttribute("readonly")},required:m=>{this._setRequired(m.target,m.detail.required)},bgColor:m=>{r("bgColor","backgroundColor",m)},fillColor:m=>{r("fillColor","backgroundColor",m)},fgColor:m=>{r("fgColor","color",m)},textColor:m=>{r("textColor","color",m)},borderColor:m=>{r("borderColor","borderColor",m)},strokeColor:m=>{r("strokeColor","borderColor",m)},rotation:m=>{const b=m.detail.rotation;this.setRotation(b),this.annotationStorage.setValue(this.data.id,{rotation:b})}})}_dispatchEventFromSandbox(r,m){const b=this._commonActions;for(const x of Object.keys(m.detail)){const T=r[x]||b[x];T&&T(m)}}_setDefaultPropertiesFromJS(r){if(!this.enableScripting)return;const m=this.annotationStorage.getRawValue(this.data.id);if(!m)return;const b=this._commonActions;for(const[x,T]of Object.entries(m)){const L=b[x];if(L){const st={detail:{[x]:T},target:r};L(st),delete m[x]}}}_createQuadrilaterals(r=!1){if(!this.data.quadPoints)return null;const m=[],b=this.data.rect;for(const x of this.data.quadPoints)this.data.rect=[x[2].x,x[2].y,x[1].x,x[1].y],m.push(this._createContainer(r));return this.data.rect=b,m}_createPopup(r,m){let b=this.container;this.quadrilaterals&&(r=r||this.quadrilaterals,b=this.quadrilaterals[0]),r||(r=document.createElement("div"),r.className="popupTriggerArea",b.append(r));const T=new a({container:b,trigger:r,color:m.color,titleObj:m.titleObj,modificationDate:m.modificationDate,contentsObj:m.contentsObj,richText:m.richText,hideWrapper:!0}).render();T.style.left="100%",b.append(T)}_renderQuadrilaterals(r){for(const m of this.quadrilaterals)m.className=r;return this.quadrilaterals}render(){(0,_.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(r,m=null){const b=[];if(this._fieldObjects){const x=this._fieldObjects[r];if(x)for(const{page:T,id:L,exportValues:st}of x){if(T===-1||L===m)continue;const dt=typeof st=="string"?st:null,Z=document.querySelector(`[data-element-id="${L}"]`);if(Z&&!k.has(Z)){(0,_.warn)(`_getElementsByName - element not allowed: ${L}`);continue}b.push({id:L,exportValue:dt,domElement:Z})}return b}for(const x of document.getElementsByName(r)){const{id:T,exportValue:L}=x;T!==m&&k.has(x)&&b.push({id:T,exportValue:L,domElement:x})}return b}static get platform(){const r=typeof navigator<"u"?navigator.platform:"";return(0,_.shadow)(this,"platform",{isWin:r.includes("Win"),isMac:r.includes("Mac")})}}class l extends w{constructor(r,m=null){super(r,{isRenderable:!0,ignoreBorder:!!(m!=null&&m.ignoreBorder),createQuadrilaterals:!0}),this.isTooltipOnly=r.data.isTooltipOnly}render(){const{data:r,linkService:m}=this,b=document.createElement("a");b.setAttribute("data-element-id",r.id);let x=!1;return r.url?(m.addLinkAttributes(b,r.url,r.newWindow),x=!0):r.action?(this._bindNamedAction(b,r.action),x=!0):r.dest?(this._bindLink(b,r.dest),x=!0):(r.actions&&(r.actions.Action||r.actions["Mouse Up"]||r.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(b,r),x=!0),r.resetForm?(this._bindResetFormAction(b,r.resetForm),x=!0):this.isTooltipOnly&&!x&&(this._bindLink(b,""),x=!0)),this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map((T,L)=>{const st=L===0?b:b.cloneNode();return T.append(st),T}):(this.container.className="linkAnnotation",x&&this.container.append(b),this.container)}_bindLink(r,m){r.href=this.linkService.getDestinationHash(m),r.onclick=()=>(m&&this.linkService.goToDestination(m),!1),(m||m==="")&&(r.className="internalLink")}_bindNamedAction(r,m){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(m),!1),r.className="internalLink"}_bindJSAction(r,m){r.href=this.linkService.getAnchorUrl("");const b=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const x of Object.keys(m.actions)){const T=b.get(x);T&&(r[T]=()=>{var L;return(L=this.linkService.eventBus)==null||L.dispatch("dispatcheventinsandbox",{source:this,detail:{id:m.id,name:x}}),!1})}r.onclick||(r.onclick=()=>!1),r.className="internalLink"}_bindResetFormAction(r,m){const b=r.onclick;if(b||(r.href=this.linkService.getAnchorUrl("")),r.className="internalLink",!this._fieldObjects){(0,_.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),b||(r.onclick=()=>!1);return}r.onclick=()=>{var ot;b&&b();const{fields:x,refs:T,include:L}=m,st=[];if(x.length!==0||T.length!==0){const et=new Set(T);for(const lt of x){const pt=this._fieldObjects[lt]||[];for(const{id:R}of pt)et.add(R)}for(const lt of Object.values(this._fieldObjects))for(const pt of lt)et.has(pt.id)===L&&st.push(pt)}else for(const et of Object.values(this._fieldObjects))st.push(...et);const dt=this.annotationStorage,Z=[];for(const et of st){const{id:lt}=et;switch(Z.push(lt),et.type){case"text":{const R=et.defaultValue||"";dt.setValue(lt,{value:R});break}case"checkbox":case"radiobutton":{const R=et.defaultValue===et.exportValues;dt.setValue(lt,{value:R});break}case"combobox":case"listbox":{const R=et.defaultValue||"";dt.setValue(lt,{value:R});break}default:continue}const pt=document.querySelector(`[data-element-id="${lt}"]`);if(pt){if(!k.has(pt)){(0,_.warn)(`_bindResetFormAction - element not allowed: ${lt}`);continue}}else continue;pt.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((ot=this.linkService.eventBus)==null||ot.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:Z,name:"ResetForm"}})),!1}}}class s extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m})}render(){this.container.className="textAnnotation";const r=document.createElement("img");return r.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",r.alt="[{{type}} Annotation]",r.dataset.l10nId="text_annotation_type",r.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.hasPopup||this._createPopup(r,this.data),this.container.append(r),this.container}}class n extends w{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}_getKeyModifier(r){const{isWin:m,isMac:b}=w.platform;return m&&r.ctrlKey||b&&r.metaKey}_setEventListener(r,m,b,x){m.includes("mouse")?r.addEventListener(m,T=>{var L;(L=this.linkService.eventBus)==null||L.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:b,value:x(T),shift:T.shiftKey,modifier:this._getKeyModifier(T)}})}):r.addEventListener(m,T=>{var L;(L=this.linkService.eventBus)==null||L.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:b,value:x(T)}})})}_setEventListeners(r,m,b){var x;for(const[T,L]of m)(L==="Action"||(x=this.data.actions)!=null&&x[L])&&this._setEventListener(r,T,L,b)}_setBackgroundColor(r){const m=this.data.backgroundColor||null;r.style.backgroundColor=m===null?"transparent":_.Util.makeHexColor(m[0],m[1],m[2])}_setTextStyle(r){const m=["left","center","right"],{fontColor:b}=this.data.defaultAppearanceData,x=this.data.defaultAppearanceData.fontSize||A,T=r.style;let L;if(this.data.multiLine){const st=Math.abs(this.data.rect[3]-this.data.rect[1]),dt=Math.round(st/(_.LINE_FACTOR*x))||1,Z=st/dt;L=Math.min(x,Math.round(Z/_.LINE_FACTOR))}else{const st=Math.abs(this.data.rect[3]-this.data.rect[1]);L=Math.min(x,Math.round(st/_.LINE_FACTOR))}T.fontSize=`calc(${L}px * var(--scale-factor))`,T.color=_.Util.makeHexColor(b[0],b[1],b[2]),this.data.textAlignment!==null&&(T.textAlign=m[this.data.textAlignment])}_setRequired(r,m){m?r.setAttribute("required",!0):r.removeAttribute("required"),r.setAttribute("aria-required",m)}}class o extends n{constructor(r){const m=r.renderForms||!r.data.hasAppearance&&!!r.data.fieldValue;super(r,{isRenderable:m})}setPropertyOnSiblings(r,m,b,x){const T=this.annotationStorage;for(const L of this._getElementsByName(r.name,r.id))L.domElement&&(L.domElement[m]=b),T.setValue(L.id,{[x]:b})}render(){var x;const r=this.annotationStorage,m=this.data.id;this.container.className="textWidgetAnnotation";let b=null;if(this.renderForms){const T=r.getValue(m,{value:this.data.fieldValue});let L=T.formattedValue||T.value||"";const st=r.getValue(m,{charLimit:this.data.maxLen}).charLimit;st&&L.length>st&&(L=L.slice(0,st));const dt={userValue:L,formattedValue:null,valueOnFocus:""};this.data.multiLine?(b=document.createElement("textarea"),b.textContent=L,this.data.doNotScroll&&(b.style.overflowY="hidden")):(b=document.createElement("input"),b.type="text",b.setAttribute("value",L),this.data.doNotScroll&&(b.style.overflowX="hidden")),k.add(b),b.setAttribute("data-element-id",m),b.disabled=this.data.readOnly,b.name=this.data.fieldName,b.tabIndex=N,this._setRequired(b,this.data.required),st&&(b.maxLength=st),b.addEventListener("input",ot=>{r.setValue(m,{value:ot.target.value}),this.setPropertyOnSiblings(b,"value",ot.target.value,"value")}),b.addEventListener("resetform",ot=>{const et=this.data.defaultFieldValue??"";b.value=dt.userValue=et,dt.formattedValue=null});let Z=ot=>{const{formattedValue:et}=dt;et!=null&&(ot.target.value=et),ot.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){b.addEventListener("focus",et=>{dt.userValue&&(et.target.value=dt.userValue),dt.valueOnFocus=et.target.value}),b.addEventListener("updatefromsandbox",et=>{const lt={value(pt){dt.userValue=pt.detail.value??"",r.setValue(m,{value:dt.userValue.toString()}),pt.target.value=dt.userValue},formattedValue(pt){const{formattedValue:R}=pt.detail;dt.formattedValue=R,R!=null&&pt.target!==document.activeElement&&(pt.target.value=R),r.setValue(m,{formattedValue:R})},selRange(pt){pt.target.setSelectionRange(...pt.detail.selRange)},charLimit:pt=>{var St;const{charLimit:R}=pt.detail,{target:ut}=pt;if(R===0){ut.removeAttribute("maxLength");return}ut.setAttribute("maxLength",R);let _t=dt.userValue;!_t||_t.length<=R||(_t=_t.slice(0,R),ut.value=dt.userValue=_t,r.setValue(m,{value:_t}),(St=this.linkService.eventBus)==null||St.dispatch("dispatcheventinsandbox",{source:this,detail:{id:m,name:"Keystroke",value:_t,willCommit:!0,commitKey:1,selStart:ut.selectionStart,selEnd:ut.selectionEnd}}))}};this._dispatchEventFromSandbox(lt,et)}),b.addEventListener("keydown",et=>{var R;let lt=-1;if(et.key==="Escape"?lt=0:et.key==="Enter"?lt=2:et.key==="Tab"&&(lt=3),lt===-1)return;const{value:pt}=et.target;dt.valueOnFocus!==pt&&(dt.userValue=pt,(R=this.linkService.eventBus)==null||R.dispatch("dispatcheventinsandbox",{source:this,detail:{id:m,name:"Keystroke",value:pt,willCommit:!0,commitKey:lt,selStart:et.target.selectionStart,selEnd:et.target.selectionEnd}}))});const ot=Z;Z=null,b.addEventListener("blur",et=>{var pt;const{value:lt}=et.target;dt.userValue=lt,this._mouseState.isDown&&dt.valueOnFocus!==lt&&((pt=this.linkService.eventBus)==null||pt.dispatch("dispatcheventinsandbox",{source:this,detail:{id:m,name:"Keystroke",value:lt,willCommit:!0,commitKey:1,selStart:et.target.selectionStart,selEnd:et.target.selectionEnd}})),ot(et)}),(x=this.data.actions)!=null&&x.Keystroke&&b.addEventListener("beforeinput",et=>{var Et;const{data:lt,target:pt}=et,{value:R,selectionStart:ut,selectionEnd:_t}=pt;let St=ut,xt=_t;switch(et.inputType){case"deleteWordBackward":{const Ft=R.substring(0,ut).match(/\w*[^\w]*$/);Ft&&(St-=Ft[0].length);break}case"deleteWordForward":{const Ft=R.substring(ut).match(/^[^\w]*\w*/);Ft&&(xt+=Ft[0].length);break}case"deleteContentBackward":ut===_t&&(St-=1);break;case"deleteContentForward":ut===_t&&(xt+=1);break}et.preventDefault(),(Et=this.linkService.eventBus)==null||Et.dispatch("dispatcheventinsandbox",{source:this,detail:{id:m,name:"Keystroke",value:R,change:lt||"",willCommit:!1,selStart:St,selEnd:xt}})}),this._setEventListeners(b,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],et=>et.target.value)}if(Z&&b.addEventListener("blur",Z),this.data.comb){const et=(this.data.rect[2]-this.data.rect[0])/st;b.classList.add("comb"),b.style.letterSpacing=`calc(${et}px * var(--scale-factor) - 1ch)`}}else b=document.createElement("div"),b.textContent=this.data.fieldValue,b.style.verticalAlign="middle",b.style.display="table-cell";return this._setTextStyle(b),this._setBackgroundColor(b),this._setDefaultPropertiesFromJS(b),this.container.append(b),this.container}}class y extends n{constructor(r){super(r,{isRenderable:r.renderForms})}render(){const r=this.annotationStorage,m=this.data,b=m.id;let x=r.getValue(b,{value:m.exportValue===m.fieldValue}).value;typeof x=="string"&&(x=x!=="Off",r.setValue(b,{value:x})),this.container.className="buttonWidgetAnnotation checkBox";const T=document.createElement("input");return k.add(T),T.setAttribute("data-element-id",b),T.disabled=m.readOnly,this._setRequired(T,this.data.required),T.type="checkbox",T.name=m.fieldName,x&&T.setAttribute("checked",!0),T.setAttribute("exportValue",m.exportValue),T.tabIndex=N,T.addEventListener("change",L=>{const{name:st,checked:dt}=L.target;for(const Z of this._getElementsByName(st,b)){const ot=dt&&Z.exportValue===m.exportValue;Z.domElement&&(Z.domElement.checked=ot),r.setValue(Z.id,{value:ot})}r.setValue(b,{value:dt})}),T.addEventListener("resetform",L=>{const st=m.defaultFieldValue||"Off";L.target.checked=st===m.exportValue}),this.enableScripting&&this.hasJSActions&&(T.addEventListener("updatefromsandbox",L=>{const st={value(dt){dt.target.checked=dt.detail.value!=="Off",r.setValue(b,{value:dt.target.checked})}};this._dispatchEventFromSandbox(st,L)}),this._setEventListeners(T,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],L=>L.target.checked)),this._setBackgroundColor(T),this._setDefaultPropertiesFromJS(T),this.container.append(T),this.container}}class p extends n{constructor(r){super(r,{isRenderable:r.renderForms})}render(){this.container.className="buttonWidgetAnnotation radioButton";const r=this.annotationStorage,m=this.data,b=m.id;let x=r.getValue(b,{value:m.fieldValue===m.buttonValue}).value;typeof x=="string"&&(x=x!==m.buttonValue,r.setValue(b,{value:x}));const T=document.createElement("input");if(k.add(T),T.setAttribute("data-element-id",b),T.disabled=m.readOnly,this._setRequired(T,this.data.required),T.type="radio",T.name=m.fieldName,x&&T.setAttribute("checked",!0),T.tabIndex=N,T.addEventListener("change",L=>{const{name:st,checked:dt}=L.target;for(const Z of this._getElementsByName(st,b))r.setValue(Z.id,{value:!1});r.setValue(b,{value:dt})}),T.addEventListener("resetform",L=>{const st=m.defaultFieldValue;L.target.checked=st!=null&&st===m.buttonValue}),this.enableScripting&&this.hasJSActions){const L=m.buttonValue;T.addEventListener("updatefromsandbox",st=>{const dt={value:Z=>{const ot=L===Z.detail.value;for(const et of this._getElementsByName(Z.target.name)){const lt=ot&&et.id===b;et.domElement&&(et.domElement.checked=lt),r.setValue(et.id,{value:lt})}}};this._dispatchEventFromSandbox(dt,st)}),this._setEventListeners(T,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],st=>st.target.checked)}return this._setBackgroundColor(T),this._setDefaultPropertiesFromJS(T),this.container.append(T),this.container}}class t extends l{constructor(r){super(r,{ignoreBorder:r.data.hasAppearance})}render(){const r=super.render();r.className="buttonWidgetAnnotation pushButton",this.data.alternativeText&&(r.title=this.data.alternativeText);const m=r.lastChild;return this.enableScripting&&this.hasJSActions&&m&&(this._setDefaultPropertiesFromJS(m),m.addEventListener("updatefromsandbox",b=>{this._dispatchEventFromSandbox({},b)})),r}}class e extends n{constructor(r){super(r,{isRenderable:r.renderForms})}render(){this.container.className="choiceWidgetAnnotation";const r=this.annotationStorage,m=this.data.id,b=r.getValue(m,{value:this.data.fieldValue}),x=document.createElement("select");k.add(x),x.setAttribute("data-element-id",m),x.disabled=this.data.readOnly,this._setRequired(x,this.data.required),x.name=this.data.fieldName,x.tabIndex=N;let T=this.data.combo&&this.data.options.length>0;this.data.combo||(x.size=this.data.options.length,this.data.multiSelect&&(x.multiple=!0)),x.addEventListener("resetform",Z=>{const ot=this.data.defaultFieldValue;for(const et of x.options)et.selected=et.value===ot});for(const Z of this.data.options){const ot=document.createElement("option");ot.textContent=Z.displayValue,ot.value=Z.exportValue,b.value.includes(Z.exportValue)&&(ot.setAttribute("selected",!0),T=!1),x.append(ot)}let L=null;if(T){const Z=document.createElement("option");Z.value=" ",Z.setAttribute("hidden",!0),Z.setAttribute("selected",!0),x.prepend(Z),L=()=>{Z.remove(),x.removeEventListener("input",L),L=null},x.addEventListener("input",L)}const st=(Z,ot)=>{const et=ot?"value":"textContent",lt=Z.target.options;return Z.target.multiple?Array.prototype.filter.call(lt,pt=>pt.selected).map(pt=>pt[et]):lt.selectedIndex===-1?null:lt[lt.selectedIndex][et]},dt=Z=>{const ot=Z.target.options;return Array.prototype.map.call(ot,et=>({displayValue:et.textContent,exportValue:et.value}))};return this.enableScripting&&this.hasJSActions?(x.addEventListener("updatefromsandbox",Z=>{const ot={value(et){L==null||L();const lt=et.detail.value,pt=new Set(Array.isArray(lt)?lt:[lt]);for(const R of x.options)R.selected=pt.has(R.value);r.setValue(m,{value:st(et,!0)})},multipleSelection(et){x.multiple=!0},remove(et){const lt=x.options,pt=et.detail.remove;lt[pt].selected=!1,x.remove(pt),lt.length>0&&Array.prototype.findIndex.call(lt,ut=>ut.selected)===-1&&(lt[0].selected=!0),r.setValue(m,{value:st(et,!0),items:dt(et)})},clear(et){for(;x.length!==0;)x.remove(0);r.setValue(m,{value:null,items:[]})},insert(et){const{index:lt,displayValue:pt,exportValue:R}=et.detail.insert,ut=x.children[lt],_t=document.createElement("option");_t.textContent=pt,_t.value=R,ut?ut.before(_t):x.append(_t),r.setValue(m,{value:st(et,!0),items:dt(et)})},items(et){const{items:lt}=et.detail;for(;x.length!==0;)x.remove(0);for(const pt of lt){const{displayValue:R,exportValue:ut}=pt,_t=document.createElement("option");_t.textContent=R,_t.value=ut,x.append(_t)}x.options.length>0&&(x.options[0].selected=!0),r.setValue(m,{value:st(et,!0),items:dt(et)})},indices(et){const lt=new Set(et.detail.indices);for(const pt of et.target.options)pt.selected=lt.has(pt.index);r.setValue(m,{value:st(et,!0)})},editable(et){et.target.disabled=!et.detail.editable}};this._dispatchEventFromSandbox(ot,Z)}),x.addEventListener("input",Z=>{var lt;const ot=st(Z,!0),et=st(Z,!1);r.setValue(m,{value:ot}),(lt=this.linkService.eventBus)==null||lt.dispatch("dispatcheventinsandbox",{source:this,detail:{id:m,name:"Keystroke",value:et,changeEx:ot,willCommit:!0,commitKey:1,keyDown:!1}})}),this._setEventListeners(x,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"]],Z=>Z.target.checked)):x.addEventListener("input",function(Z){r.setValue(m,{value:st(Z,!0)})}),this.data.combo&&this._setTextStyle(x),this._setBackgroundColor(x),this._setDefaultPropertiesFromJS(x),this.container.append(x),this.container}}class i extends w{constructor(r){var b,x,T;const m=!!((b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m})}render(){const r=["Line","Square","Circle","PolyLine","Polygon","Ink"];if(this.container.className="popupAnnotation",r.includes(this.data.parentType))return this.container;const m=`[data-annotation-id="${this.data.parentId}"]`,b=this.layer.querySelectorAll(m);if(b.length===0)return this.container;const x=new a({container:this.container,trigger:Array.from(b),color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText}),T=this.page,L=_.Util.normalizeRect([this.data.parentRect[0],T.view[3]-this.data.parentRect[1]+T.view[1],this.data.parentRect[2],T.view[3]-this.data.parentRect[3]+T.view[1]]),st=L[0]+this.data.parentRect[2]-this.data.parentRect[0],dt=L[1],[Z,ot,et,lt]=this.viewport.viewBox,pt=et-Z,R=lt-ot;return this.container.style.left=`${100*(st-Z)/pt}%`,this.container.style.top=`${100*(dt-ot)/R}%`,this.container.append(x.render()),this.container}}class a{constructor(r){this.container=r.container,this.trigger=r.trigger,this.color=r.color,this.titleObj=r.titleObj,this.modificationDate=r.modificationDate,this.contentsObj=r.contentsObj,this.richText=r.richText,this.hideWrapper=r.hideWrapper||!1,this.pinned=!1}render(){var st,dt;const m=document.createElement("div");m.className="popupWrapper",this.hideElement=this.hideWrapper?m:this.container,this.hideElement.hidden=!0;const b=document.createElement("div");b.className="popup";const x=this.color;if(x){const Z=.7*(255-x[0])+x[0],ot=.7*(255-x[1])+x[1],et=.7*(255-x[2])+x[2];b.style.backgroundColor=_.Util.makeHexColor(Z|0,ot|0,et|0)}const T=document.createElement("h1");T.dir=this.titleObj.dir,T.textContent=this.titleObj.str,b.append(T);const L=v.PDFDateString.toDateObject(this.modificationDate);if(L){const Z=document.createElement("span");Z.className="popupDate",Z.textContent="{{date}}, {{time}}",Z.dataset.l10nId="annotation_date_string",Z.dataset.l10nArgs=JSON.stringify({date:L.toLocaleDateString(),time:L.toLocaleTimeString()}),b.append(Z)}if((st=this.richText)!=null&&st.str&&(!((dt=this.contentsObj)!=null&&dt.str)||this.contentsObj.str===this.richText.str))Q.XfaLayer.render({xfaHtml:this.richText.html,intent:"richText",div:b}),b.lastChild.className="richText popupContent";else{const Z=this._formatContents(this.contentsObj);b.append(Z)}Array.isArray(this.trigger)||(this.trigger=[this.trigger]);for(const Z of this.trigger)Z.addEventListener("click",this._toggle.bind(this)),Z.addEventListener("mouseover",this._show.bind(this,!1)),Z.addEventListener("mouseout",this._hide.bind(this,!1));return b.addEventListener("click",this._hide.bind(this,!0)),m.append(b),m}_formatContents({str:r,dir:m}){const b=document.createElement("p");b.className="popupContent",b.dir=m;const x=r.split(/(?:\r\n?|\n)/);for(let T=0,L=x.length;T<L;++T){const st=x[T];b.append(document.createTextNode(st)),T<L-1&&b.append(document.createElement("br"))}return b}_toggle(){this.pinned?this._hide(!0):this._show(!0)}_show(r=!1){r&&(this.pinned=!0),this.hideElement.hidden&&(this.hideElement.hidden=!1,this.container.style.zIndex=parseInt(this.container.style.zIndex)+1e3)}_hide(r=!0){r&&(this.pinned=!1),!this.hideElement.hidden&&!this.pinned&&(this.hideElement.hidden=!0,this.container.style.zIndex=parseInt(this.container.style.zIndex)-1e3)}}class u extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0}),this.textContent=r.data.textContent}render(){if(this.container.className="freeTextAnnotation",this.textContent){const r=document.createElement("div");r.className="annotationTextContent",r.setAttribute("role","comment");for(const m of this.textContent){const b=document.createElement("span");b.textContent=m,r.append(b)}this.container.append(r)}return this.data.hasPopup||this._createPopup(null,this.data),this.container}}class d extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0})}render(){this.container.className="lineAnnotation";const r=this.data,{width:m,height:b}=M(r.rect),x=this.svgFactory.create(m,b,!0),T=this.svgFactory.createElement("svg:line");return T.setAttribute("x1",r.rect[2]-r.lineCoordinates[0]),T.setAttribute("y1",r.rect[3]-r.lineCoordinates[1]),T.setAttribute("x2",r.rect[2]-r.lineCoordinates[2]),T.setAttribute("y2",r.rect[3]-r.lineCoordinates[3]),T.setAttribute("stroke-width",r.borderStyle.width||1),T.setAttribute("stroke","transparent"),T.setAttribute("fill","transparent"),x.append(T),this.container.append(x),this._createPopup(T,r),this.container}}class c extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0})}render(){this.container.className="squareAnnotation";const r=this.data,{width:m,height:b}=M(r.rect),x=this.svgFactory.create(m,b,!0),T=r.borderStyle.width,L=this.svgFactory.createElement("svg:rect");return L.setAttribute("x",T/2),L.setAttribute("y",T/2),L.setAttribute("width",m-T),L.setAttribute("height",b-T),L.setAttribute("stroke-width",T||1),L.setAttribute("stroke","transparent"),L.setAttribute("fill","transparent"),x.append(L),this.container.append(x),this._createPopup(L,r),this.container}}class S extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0})}render(){this.container.className="circleAnnotation";const r=this.data,{width:m,height:b}=M(r.rect),x=this.svgFactory.create(m,b,!0),T=r.borderStyle.width,L=this.svgFactory.createElement("svg:ellipse");return L.setAttribute("cx",m/2),L.setAttribute("cy",b/2),L.setAttribute("rx",m/2-T/2),L.setAttribute("ry",b/2-T/2),L.setAttribute("stroke-width",T||1),L.setAttribute("stroke","transparent"),L.setAttribute("fill","transparent"),x.append(L),this.container.append(x),this._createPopup(L,r),this.container}}class X extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const r=this.data,{width:m,height:b}=M(r.rect),x=this.svgFactory.create(m,b,!0);let T=[];for(const st of r.vertices){const dt=st.x-r.rect[0],Z=r.rect[3]-st.y;T.push(dt+","+Z)}T=T.join(" ");const L=this.svgFactory.createElement(this.svgElementName);return L.setAttribute("points",T),L.setAttribute("stroke-width",r.borderStyle.width||1),L.setAttribute("stroke","transparent"),L.setAttribute("fill","transparent"),x.append(L),this.container.append(x),this._createPopup(L,r),this.container}}class tt extends X{constructor(r){super(r),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class K extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0})}render(){return this.container.className="caretAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class Y extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const r=this.data,{width:m,height:b}=M(r.rect),x=this.svgFactory.create(m,b,!0);for(const T of r.inkLists){let L=[];for(const dt of T){const Z=dt.x-r.rect[0],ot=r.rect[3]-dt.y;L.push(`${Z},${ot}`)}L=L.join(" ");const st=this.svgFactory.createElement(this.svgElementName);st.setAttribute("points",L),st.setAttribute("stroke-width",r.borderStyle.width||1),st.setAttribute("stroke","transparent"),st.setAttribute("fill","transparent"),this._createPopup(st,r),x.append(st)}return this.container.append(x),this.container}}class B extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("highlightAnnotation"):(this.container.className="highlightAnnotation",this.container)}}class q extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("underlineAnnotation"):(this.container.className="underlineAnnotation",this.container)}}class $ extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("squigglyAnnotation"):(this.container.className="squigglyAnnotation",this.container)}}class it extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.hasPopup||this._createPopup(null,this.data),this.quadrilaterals?this._renderQuadrilaterals("strikeoutAnnotation"):(this.container.className="strikeoutAnnotation",this.container)}}class ht extends w{constructor(r){var b,x,T;const m=!!(r.data.hasPopup||(b=r.data.titleObj)!=null&&b.str||(x=r.data.contentsObj)!=null&&x.str||(T=r.data.richText)!=null&&T.str);super(r,{isRenderable:m,ignoreBorder:!0})}render(){return this.container.className="stampAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class yt extends w{constructor(r){var x;super(r,{isRenderable:!0});const{filename:m,content:b}=this.data.file;this.filename=(0,v.getFilenameFromUrl)(m),this.content=b,(x=this.linkService.eventBus)==null||x.dispatch("fileattachmentannotation",{source:this,filename:m,content:b})}render(){var m,b;this.container.className="fileAttachmentAnnotation";const r=document.createElement("div");return r.className="popupTriggerArea",r.addEventListener("dblclick",this._download.bind(this)),!this.data.hasPopup&&((m=this.data.titleObj)!=null&&m.str||(b=this.data.contentsObj)!=null&&b.str||this.data.richText)&&this._createPopup(r,this.data),this.container.append(r),this.container}_download(){var r;(r=this.downloadManager)==null||r.openOrDownloadData(this.container,this.content,this.filename)}}const G=class G{static render(r){var st,dt;const{annotations:m,div:b,viewport:x,accessibilityManager:T}=r;ct(this,E,ve).call(this,b,x);let L=0;for(const Z of m){if(Z.annotationType!==_.AnnotationType.POPUP){const{width:et,height:lt}=M(Z.rect);if(et<=0||lt<=0)continue}const ot=P.create({data:Z,layer:b,page:r.page,viewport:x,linkService:r.linkService,downloadManager:r.downloadManager,imageResourcesPath:r.imageResourcesPath||"",renderForms:r.renderForms!==!1,svgFactory:new v.DOMSVGFactory,annotationStorage:r.annotationStorage||new V.AnnotationStorage,enableScripting:r.enableScripting,hasJSActions:r.hasJSActions,fieldObjects:r.fieldObjects,mouseState:r.mouseState||{isDown:!1}});if(ot.isRenderable){const et=ot.render();if(Z.hidden&&(et.style.visibility="hidden"),Array.isArray(et))for(const lt of et)lt.style.zIndex=L++,ct(st=G,f,Se).call(st,lt,Z.id,b,T);else et.style.zIndex=L++,ot instanceof i?b.prepend(et):ct(dt=G,f,Se).call(dt,et,Z.id,b,T)}}ct(this,D,xe).call(this,b,r.annotationCanvasMap)}static update(r){const{annotationCanvasMap:m,div:b,viewport:x}=r;ct(this,E,ve).call(this,b,x),ct(this,D,xe).call(this,b,m),b.hidden=!1}};f=new WeakSet,Se=function(r,m,b,x){const T=r.firstChild||r;T.id=`${v.AnnotationPrefix}${m}`,b.append(r),x==null||x.moveElementInDOM(b,r,T,!1)},E=new WeakSet,ve=function(r,{width:m,height:b,rotation:x}){const{style:T}=r,L=x%180!==0,st=Math.floor(m)+"px",dt=Math.floor(b)+"px";T.width=L?dt:st,T.height=L?st:dt,r.setAttribute("data-main-rotation",x)},D=new WeakSet,xe=function(r,m){if(m){for(const[b,x]of m){const T=r.querySelector(`[data-annotation-id="${b}"]`);if(!T)continue;const{firstChild:L}=T;L?L.nodeName==="CANVAS"?L.replaceWith(x):L.before(x):T.append(x)}m.clear()}},at(G,f),at(G,E),at(G,D);let O=G;g.AnnotationLayer=O},(nt,g)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.ColorConverters=void 0;function U(v){return Math.floor(Math.max(0,Math.min(1,v))*255).toString(16).padStart(2,"0")}class _{static CMYK_G([V,H,Q,N]){return["G",1-Math.min(1,.3*V+.59*Q+.11*H+N)]}static G_CMYK([V]){return["CMYK",0,0,0,1-V]}static G_RGB([V]){return["RGB",V,V,V]}static G_HTML([V]){const H=U(V);return`#${H}${H}${H}`}static RGB_G([V,H,Q]){return["G",.3*V+.59*H+.11*Q]}static RGB_HTML([V,H,Q]){const N=U(V),A=U(H),k=U(Q);return`#${N}${A}${k}`}static T_HTML(){return"#00000000"}static CMYK_RGB([V,H,Q,N]){return["RGB",1-Math.min(1,V+N),1-Math.min(1,Q+N),1-Math.min(1,H+N)]}static CMYK_HTML(V){const H=this.CMYK_RGB(V).slice(1);return this.RGB_HTML(H)}static RGB_CMYK([V,H,Q]){const N=1-V,A=1-H,k=1-Q,M=Math.min(N,A,k);return["CMYK",N,A,k,M]}}g.ColorConverters=_},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.XfaLayer=void 0;var _=U(20);class v{static setupStorage(H,Q,N,A,k){const M=A.getValue(Q,{value:null});switch(N.name){case"textarea":if(M.value!==null&&(H.textContent=M.value),k==="print")break;H.addEventListener("input",P=>{A.setValue(Q,{value:P.target.value})});break;case"input":if(N.attributes.type==="radio"||N.attributes.type==="checkbox"){if(M.value===N.attributes.xfaOn?H.setAttribute("checked",!0):M.value===N.attributes.xfaOff&&H.removeAttribute("checked"),k==="print")break;H.addEventListener("change",P=>{A.setValue(Q,{value:P.target.checked?P.target.getAttribute("xfaOn"):P.target.getAttribute("xfaOff")})})}else{if(M.value!==null&&H.setAttribute("value",M.value),k==="print")break;H.addEventListener("input",P=>{A.setValue(Q,{value:P.target.value})})}break;case"select":if(M.value!==null)for(const P of N.children)P.attributes.value===M.value&&(P.attributes.selected=!0);H.addEventListener("input",P=>{const w=P.target.options,l=w.selectedIndex===-1?"":w[w.selectedIndex].value;A.setValue(Q,{value:l})});break}}static setAttributes({html:H,element:Q,storage:N=null,intent:A,linkService:k}){const{attributes:M}=Q,P=H instanceof HTMLAnchorElement;M.type==="radio"&&(M.name=`${M.name}-${A}`);for(const[w,l]of Object.entries(M))if(l!=null)switch(w){case"class":l.length&&H.setAttribute(w,l.join(" "));break;case"dataId":break;case"id":H.setAttribute("data-element-id",l);break;case"style":Object.assign(H.style,l);break;case"textContent":H.textContent=l;break;default:(!P||w!=="href"&&w!=="newWindow")&&H.setAttribute(w,l)}P&&k.addLinkAttributes(H,M.href,M.newWindow),N&&M.dataId&&this.setupStorage(H,M.dataId,Q,N)}static render(H){var s;const Q=H.annotationStorage,N=H.linkService,A=H.xfaHtml,k=H.intent||"display",M=document.createElement(A.name);A.attributes&&this.setAttributes({html:M,element:A,intent:k,linkService:N});const P=[[A,-1,M]],w=H.div;if(w.append(M),H.viewport){const n=`matrix(${H.viewport.transform.join(",")})`;w.style.transform=n}k!=="richText"&&w.setAttribute("class","xfaLayer xfaFont");const l=[];for(;P.length>0;){const[n,o,y]=P.at(-1);if(o+1===n.children.length){P.pop();continue}const p=n.children[++P.at(-1)[1]];if(p===null)continue;const{name:t}=p;if(t==="#text"){const i=document.createTextNode(p.value);l.push(i),y.append(i);continue}let e;if((s=p==null?void 0:p.attributes)!=null&&s.xmlns?e=document.createElementNS(p.attributes.xmlns,t):e=document.createElement(t),y.append(e),p.attributes&&this.setAttributes({html:e,element:p,storage:Q,intent:k,linkService:N}),p.children&&p.children.length>0)P.push([p,-1,e]);else if(p.value){const i=document.createTextNode(p.value);_.XfaText.shouldBuildText(t)&&l.push(i),e.append(i)}}for(const n of w.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))n.setAttribute("readOnly",!0);return{textDivs:l}}static update(H){const Q=`matrix(${H.viewport.transform.join(",")})`;H.div.style.transform=Q,H.div.hidden=!1}}g.XfaLayer=v},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.TextLayerRenderTask=void 0,g.renderTextLayer=y;var _=U(1),v=U(8);const V=1e5,H=30,Q=.8,N=new Map,A=/^\s+$/g;function k(p,t){const e=N.get(p);if(e)return e;t.save(),t.font=`${H}px ${p}`;const i=t.measureText("");let a=i.fontBoundingBoxAscent,u=Math.abs(i.fontBoundingBoxDescent);if(a){t.restore();const c=a/(a+u);return N.set(p,c),c}t.strokeStyle="red",t.clearRect(0,0,H,H),t.strokeText("g",0,0);let d=t.getImageData(0,0,H,H).data;u=0;for(let c=d.length-1-3;c>=0;c-=4)if(d[c]>0){u=Math.ceil(c/4/H);break}t.clearRect(0,0,H,H),t.strokeText("A",0,H),d=t.getImageData(0,0,H,H).data,a=0;for(let c=0,S=d.length;c<S;c+=4)if(d[c]>0){a=H-Math.floor(c/4/H);break}if(t.restore(),a){const c=a/(a+u);return N.set(p,c),c}return N.set(p,Q),Q}function M(p,t,e,i){const a=document.createElement("span"),u=p._enhanceTextSelection?{angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,originalTransform:null,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,scale:1,fontSize:0}:{angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};p._textDivs.push(a);const d=_.Util.transform(p._viewport.transform,t.transform);let c=Math.atan2(d[1],d[0]);const S=e[t.fontName];S.vertical&&(c+=Math.PI/2);const X=Math.hypot(d[2],d[3]),tt=X*k(S.fontFamily,i);let K,Y;c===0?(K=d[4],Y=d[5]-tt):(K=d[4]+tt*Math.sin(c),Y=d[5]-tt*Math.cos(c)),a.style.left=`${K}px`,a.style.top=`${Y}px`,a.style.fontSize=`${X}px`,a.style.fontFamily=S.fontFamily,u.fontSize=X,a.setAttribute("role","presentation"),a.textContent=t.str,a.dir=t.dir,p._fontInspectorEnabled&&(a.dataset.fontName=t.fontName),c!==0&&(u.angle=c*(180/Math.PI));let B=!1;if(t.str.length>1||p._enhanceTextSelection&&A.test(t.str))B=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const q=Math.abs(t.transform[0]),$=Math.abs(t.transform[3]);q!==$&&Math.max(q,$)/Math.min(q,$)>1.5&&(B=!0)}if(B&&(S.vertical?u.canvasWidth=t.height*p._viewport.scale:u.canvasWidth=t.width*p._viewport.scale),p._textDivProperties.set(a,u),p._textContentStream&&p._layoutText(a),p._enhanceTextSelection&&u.hasText){let q=1,$=0;c!==0&&(q=Math.cos(c),$=Math.sin(c));const it=(S.vertical?t.height:t.width)*p._viewport.scale,ht=X;let yt,O;c!==0?(yt=[q,$,-$,q,K,Y],O=_.Util.getAxialAlignedBoundingBox([0,0,it,ht],yt)):O=[K,Y,K+it,Y+ht],p._bounds.push({left:O[0],top:O[1],right:O[2],bottom:O[3],div:a,size:[it,ht],m:yt})}}function P(p){if(p._canceled)return;const t=p._textDivs,e=p._capability,i=t.length;if(i>V){p._renderingDone=!0,e.resolve();return}if(!p._textContentStream)for(let a=0;a<i;a++)p._layoutText(t[a]);p._renderingDone=!0,e.resolve()}function w(p,t,e){let i=0;for(let a=0;a<e;a++){const u=p[t++];u>0&&(i=i?Math.min(u,i):u)}return i}function l(p){const t=p._bounds,e=p._viewport,i=s(e.width,e.height,t);for(let a=0;a<i.length;a++){const u=t[a].div,d=p._textDivProperties.get(u);if(d.angle===0){d.paddingLeft=t[a].left-i[a].left,d.paddingTop=t[a].top-i[a].top,d.paddingRight=i[a].right-t[a].right,d.paddingBottom=i[a].bottom-t[a].bottom,p._textDivProperties.set(u,d);continue}const c=i[a],S=t[a],X=S.m,tt=X[0],K=X[1],Y=[[0,0],[0,S.size[1]],[S.size[0],0],S.size],B=new Float64Array(64);for(let $=0,it=Y.length;$<it;$++){const ht=_.Util.applyTransform(Y[$],X);B[$+0]=tt&&(c.left-ht[0])/tt,B[$+4]=K&&(c.top-ht[1])/K,B[$+8]=tt&&(c.right-ht[0])/tt,B[$+12]=K&&(c.bottom-ht[1])/K,B[$+16]=K&&(c.left-ht[0])/-K,B[$+20]=tt&&(c.top-ht[1])/tt,B[$+24]=K&&(c.right-ht[0])/-K,B[$+28]=tt&&(c.bottom-ht[1])/tt,B[$+32]=tt&&(c.left-ht[0])/-tt,B[$+36]=K&&(c.top-ht[1])/-K,B[$+40]=tt&&(c.right-ht[0])/-tt,B[$+44]=K&&(c.bottom-ht[1])/-K,B[$+48]=K&&(c.left-ht[0])/K,B[$+52]=tt&&(c.top-ht[1])/-tt,B[$+56]=K&&(c.right-ht[0])/K,B[$+60]=tt&&(c.bottom-ht[1])/-tt}const q=1+Math.min(Math.abs(tt),Math.abs(K));d.paddingLeft=w(B,32,16)/q,d.paddingTop=w(B,48,16)/q,d.paddingRight=w(B,0,16)/q,d.paddingBottom=w(B,16,16)/q,p._textDivProperties.set(u,d)}}function s(p,t,e){const i=e.map(function(u,d){return{x1:u.left,y1:u.top,x2:u.right,y2:u.bottom,index:d,x1New:void 0,x2New:void 0}});n(p,i);const a=new Array(e.length);for(const u of i){const d=u.index;a[d]={left:u.x1New,top:0,right:u.x2New,bottom:0}}e.map(function(u,d){const c=a[d],S=i[d];S.x1=u.top,S.y1=p-c.right,S.x2=u.bottom,S.y2=p-c.left,S.index=d,S.x1New=void 0,S.x2New=void 0}),n(t,i);for(const u of i){const d=u.index;a[d].top=u.x1New,a[d].bottom=u.x2New}return a}function n(p,t){t.sort(function(a,u){return a.x1-u.x1||a.index-u.index});const i=[{start:-1/0,end:1/0,boundary:{x1:-1/0,y1:-1/0,x2:0,y2:1/0,index:-1,x1New:0,x2New:0}}];for(const a of t){let u=0;for(;u<i.length&&i[u].end<=a.y1;)u++;let d=i.length-1;for(;d>=0&&i[d].start>=a.y2;)d--;let c,S,X,tt,K=-1/0;for(X=u;X<=d;X++){c=i[X],S=c.boundary;let q;S.x2>a.x1?q=S.index>a.index?S.x1New:a.x1:S.x2New===void 0?q=(S.x2+a.x1)/2:q=S.x2New,q>K&&(K=q)}for(a.x1New=K,X=u;X<=d;X++)c=i[X],S=c.boundary,S.x2New===void 0?S.x2>a.x1?S.index>a.index&&(S.x2New=S.x2):S.x2New=K:S.x2New>K&&(S.x2New=Math.max(K,S.x2));const Y=[];let B=null;for(X=u;X<=d;X++){c=i[X],S=c.boundary;const q=S.x2>a.x2?S:a;B===q?Y.at(-1).end=c.end:(Y.push({start:c.start,end:c.end,boundary:q}),B=q)}for(i[u].start<a.y1&&(Y[0].start=a.y1,Y.unshift({start:i[u].start,end:a.y1,boundary:i[u].boundary})),a.y2<i[d].end&&(Y.at(-1).end=a.y2,Y.push({start:a.y2,end:i[d].end,boundary:i[d].boundary})),X=u;X<=d;X++){if(c=i[X],S=c.boundary,S.x2New!==void 0)continue;let q=!1;for(tt=u-1;!q&&tt>=0&&i[tt].start>=S.y1;tt--)q=i[tt].boundary===S;for(tt=d+1;!q&&tt<i.length&&i[tt].end<=S.y2;tt++)q=i[tt].boundary===S;for(tt=0;!q&&tt<Y.length;tt++)q=Y[tt].boundary===S;q||(S.x2New=K)}Array.prototype.splice.apply(i,[u,d-u+1,...Y])}for(const a of i){const u=a.boundary;u.x2New===void 0&&(u.x2New=Math.max(p,u.x2))}}class o{constructor({textContent:t,textContentStream:e,container:i,viewport:a,textDivs:u,textContentItemsStr:d,enhanceTextSelection:c}){var S;c&&(0,v.deprecated)("The `enhanceTextSelection` functionality will be removed in the future."),this._textContent=t,this._textContentStream=e,this._container=i,this._document=i.ownerDocument,this._viewport=a,this._textDivs=u||[],this._textContentItemsStr=d||[],this._enhanceTextSelection=!!c,this._fontInspectorEnabled=!!((S=globalThis.FontInspector)!=null&&S.enabled),this._reader=null,this._layoutTextLastFontSize=null,this._layoutTextLastFontFamily=null,this._layoutTextCtx=null,this._textDivProperties=new WeakMap,this._renderingDone=!1,this._canceled=!1,this._capability=(0,_.createPromiseCapability)(),this._renderTimer=null,this._bounds=[],this._devicePixelRatio=globalThis.devicePixelRatio||1,this._capability.promise.finally(()=>{this._enhanceTextSelection||(this._textDivProperties=null),this._layoutTextCtx&&(this._layoutTextCtx.canvas.width=0,this._layoutTextCtx.canvas.height=0,this._layoutTextCtx=null)}).catch(()=>{})}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new _.AbortException("TextLayer task cancelled.")).catch(()=>{}),this._reader=null),this._renderTimer!==null&&(clearTimeout(this._renderTimer),this._renderTimer=null),this._capability.reject(new Error("TextLayer task cancelled."))}_processItems(t,e){for(let i=0,a=t.length;i<a;i++){if(t[i].str===void 0){if(t[i].type==="beginMarkedContentProps"||t[i].type==="beginMarkedContent"){const u=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),t[i].id!==null&&this._container.setAttribute("id",`${t[i].id}`),u.append(this._container)}else t[i].type==="endMarkedContent"&&(this._container=this._container.parentNode);continue}this._textContentItemsStr.push(t[i].str),M(this,t[i],e,this._layoutTextCtx)}}_layoutText(t){const e=this._textDivProperties.get(t);let i="";if(e.canvasWidth!==0&&e.hasText){const{fontFamily:a}=t.style,{fontSize:u}=e;(u!==this._layoutTextLastFontSize||a!==this._layoutTextLastFontFamily)&&(this._layoutTextCtx.font=`${u*this._devicePixelRatio}px ${a}`,this._layoutTextLastFontSize=u,this._layoutTextLastFontFamily=a);const{width:d}=this._layoutTextCtx.measureText(t.textContent);if(d>0){const c=this._devicePixelRatio*e.canvasWidth/d;this._enhanceTextSelection&&(e.scale=c),i=`scaleX(${c})`}}if(e.angle!==0&&(i=`rotate(${e.angle}deg) ${i}`),i.length>0&&(this._enhanceTextSelection&&(e.originalTransform=i),t.style.transform=i),e.hasText&&this._container.append(t),e.hasEOL){const a=document.createElement("br");a.setAttribute("role","presentation"),this._container.append(a)}}_render(t=0){const e=(0,_.createPromiseCapability)();let i=Object.create(null);const a=this._document.createElement("canvas");if(a.height=a.width=H,this._layoutTextCtx=a.getContext("2d",{alpha:!1}),this._textContent){const u=this._textContent.items,d=this._textContent.styles;this._processItems(u,d),e.resolve()}else if(this._textContentStream){const u=()=>{this._reader.read().then(({value:d,done:c})=>{if(c){e.resolve();return}Object.assign(i,d.styles),this._processItems(d.items,i),u()},e.reject)};this._reader=this._textContentStream.getReader(),u()}else throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');e.promise.then(()=>{i=null,t?this._renderTimer=setTimeout(()=>{P(this),this._renderTimer=null},t):P(this)},this._capability.reject)}expandTextDivs(t=!1){if(!this._enhanceTextSelection||!this._renderingDone)return;this._bounds!==null&&(l(this),this._bounds=null);const e=[],i=[];for(let a=0,u=this._textDivs.length;a<u;a++){const d=this._textDivs[a],c=this._textDivProperties.get(d);c.hasText&&(t?(e.length=0,i.length=0,c.originalTransform&&e.push(c.originalTransform),c.paddingTop>0?(i.push(`${c.paddingTop}px`),e.push(`translateY(${-c.paddingTop}px)`)):i.push(0),c.paddingRight>0?i.push(`${c.paddingRight/c.scale}px`):i.push(0),c.paddingBottom>0?i.push(`${c.paddingBottom}px`):i.push(0),c.paddingLeft>0?(i.push(`${c.paddingLeft/c.scale}px`),e.push(`translateX(${-c.paddingLeft/c.scale}px)`)):i.push(0),d.style.padding=i.join(" "),e.length&&(d.style.transform=e.join(" "))):(d.style.padding=null,d.style.transform=c.originalTransform))}}}g.TextLayerRenderTask=o;function y(p){const t=new o({textContent:p.textContent,textContentStream:p.textContentStream,container:p.container,viewport:p.viewport,textDivs:p.textDivs,textContentItemsStr:p.textContentItemsStr,enhanceTextSelection:p.enhanceTextSelection});return t._render(p.timeout),t}},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.SVGGraphics=void 0;var _=U(8),v=U(1),V=U(3);let H=class{constructor(){(0,v.unreachable)("Not implemented: SVGGraphics")}};g.SVGGraphics=H;{let s=function(e){let i=[];const a=[];for(const u of e){if(u.fn==="save"){i.push({fnId:92,fn:"group",items:[]}),a.push(i),i=i.at(-1).items;continue}u.fn==="restore"?i=a.pop():i.push(u)}return i},n=function(e){if(Number.isInteger(e))return e.toString();const i=e.toFixed(10);let a=i.length-1;if(i[a]!=="0")return i;do a--;while(i[a]==="0");return i.substring(0,i[a]==="."?a:a+1)},o=function(e){if(e[4]===0&&e[5]===0){if(e[1]===0&&e[2]===0)return e[0]===1&&e[3]===1?"":`scale(${n(e[0])} ${n(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2]){const i=Math.acos(e[0])*180/Math.PI;return`rotate(${n(i)})`}}else if(e[0]===1&&e[1]===0&&e[2]===0&&e[3]===1)return`translate(${n(e[4])} ${n(e[5])})`;return`matrix(${n(e[0])} ${n(e[1])} ${n(e[2])} ${n(e[3])} ${n(e[4])} ${n(e[5])})`};const Q={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},N="http://www.w3.org/XML/1998/namespace",A="http://www.w3.org/1999/xlink",k=["butt","round","square"],M=["miter","round","bevel"],P=function(e,i="",a=!1){if(URL.createObjectURL&&typeof Blob<"u"&&!a)return URL.createObjectURL(new Blob([e],{type:i}));const u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let d=`data:${i};base64,`;for(let c=0,S=e.length;c<S;c+=3){const X=e[c]&255,tt=e[c+1]&255,K=e[c+2]&255,Y=X>>2,B=(X&3)<<4|tt>>4,q=c+1<S?(tt&15)<<2|K>>6:64,$=c+2<S?K&63:64;d+=u[Y]+u[B]+u[q]+u[$]}return d},w=function(){const e=new Uint8Array([137,80,78,71,13,10,26,10]),i=12,a=new Int32Array(256);for(let K=0;K<256;K++){let Y=K;for(let B=0;B<8;B++)Y&1?Y=3988292384^Y>>1&2147483647:Y=Y>>1&2147483647;a[K]=Y}function u(K,Y,B){let q=-1;for(let $=Y;$<B;$++){const it=(q^K[$])&255,ht=a[it];q=q>>>8^ht}return q^-1}function d(K,Y,B,q){let $=q;const it=Y.length;B[$]=it>>24&255,B[$+1]=it>>16&255,B[$+2]=it>>8&255,B[$+3]=it&255,$+=4,B[$]=K.charCodeAt(0)&255,B[$+1]=K.charCodeAt(1)&255,B[$+2]=K.charCodeAt(2)&255,B[$+3]=K.charCodeAt(3)&255,$+=4,B.set(Y,$),$+=Y.length;const ht=u(B,q+4,$);B[$]=ht>>24&255,B[$+1]=ht>>16&255,B[$+2]=ht>>8&255,B[$+3]=ht&255}function c(K,Y,B){let q=1,$=0;for(let it=Y;it<B;++it)q=(q+(K[it]&255))%65521,$=($+q)%65521;return $<<16|q}function S(K){if(!V.isNodeJS)return X(K);try{let Y;parseInt(process.versions.node)>=8?Y=K:Y=Buffer.from(K);const B=require$$5.deflateSync(Y,{level:9});return B instanceof Uint8Array?B:new Uint8Array(B)}catch(Y){(0,v.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+Y)}return X(K)}function X(K){let Y=K.length;const B=65535,q=Math.ceil(Y/B),$=new Uint8Array(2+Y+q*5+4);let it=0;$[it++]=120,$[it++]=156;let ht=0;for(;Y>B;)$[it++]=0,$[it++]=255,$[it++]=255,$[it++]=0,$[it++]=0,$.set(K.subarray(ht,ht+B),it),it+=B,ht+=B,Y-=B;$[it++]=1,$[it++]=Y&255,$[it++]=Y>>8&255,$[it++]=~Y&65535&255,$[it++]=(~Y&65535)>>8&255,$.set(K.subarray(ht),it),it+=K.length-ht;const yt=c(K,0,K.length);return $[it++]=yt>>24&255,$[it++]=yt>>16&255,$[it++]=yt>>8&255,$[it++]=yt&255,$}function tt(K,Y,B,q){const $=K.width,it=K.height;let ht,yt,O;const f=K.data;switch(Y){case v.ImageKind.GRAYSCALE_1BPP:yt=0,ht=1,O=$+7>>3;break;case v.ImageKind.RGB_24BPP:yt=2,ht=8,O=$*3;break;case v.ImageKind.RGBA_32BPP:yt=6,ht=8,O=$*4;break;default:throw new Error("invalid format")}const h=new Uint8Array((1+O)*it);let E=0,F=0;for(let m=0;m<it;++m)h[E++]=0,h.set(f.subarray(F,F+O),E),F+=O,E+=O;if(Y===v.ImageKind.GRAYSCALE_1BPP&&q){E=0;for(let m=0;m<it;m++){E++;for(let b=0;b<O;b++)h[E++]^=255}}const D=new Uint8Array([$>>24&255,$>>16&255,$>>8&255,$&255,it>>24&255,it>>16&255,it>>8&255,it&255,ht,yt,0,0,0]),I=S(h),G=e.length+i*3+D.length+I.length,z=new Uint8Array(G);let r=0;return z.set(e,r),r+=e.length,d("IHDR",D,z,r),r+=i+D.length,d("IDATA",I,z,r),r+=i+I.length,d("IEND",new Uint8Array(0),z,r),P(z,"image/png",B)}return function(Y,B,q){const $=Y.kind===void 0?v.ImageKind.GRAYSCALE_1BPP:Y.kind;return tt(Y,$,B,q)}}();class l{constructor(){this.fontSizeScale=1,this.fontWeight=Q.fontWeight,this.fontSize=0,this.textMatrix=v.IDENTITY_MATRIX,this.fontMatrix=v.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=v.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=Q.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(i,a){this.x=i,this.y=a}}let y=0,p=0,t=0;g.SVGGraphics=H=class{constructor(e,i,a=!1){(0,_.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new _.DOMSVGFactory,this.current=new l,this.transformMatrix=v.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=e,this.objs=i,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!a,this._operatorIdMapping=[];for(const u in v.OPS)this._operatorIdMapping[v.OPS[u]]=u}save(){this.transformStack.push(this.transformMatrix);const e=this.current;this.extraStack.push(e),this.current=e.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(e){this.save(),this.executeOpTree(e),this.restore()}loadDependencies(e){const i=e.fnArray,a=e.argsArray;for(let u=0,d=i.length;u<d;u++)if(i[u]===v.OPS.dependency)for(const c of a[u]){const S=c.startsWith("g_")?this.commonObjs:this.objs,X=new Promise(tt=>{S.get(c,tt)});this.current.dependencies.push(X)}return Promise.all(this.current.dependencies)}transform(e,i,a,u,d,c){const S=[e,i,a,u,d,c];this.transformMatrix=v.Util.transform(this.transformMatrix,S),this.tgrp=null}getSVG(e,i){this.viewport=i;const a=this._initialize(i);return this.loadDependencies(e).then(()=>(this.transformMatrix=v.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(e)),a))}convertOpList(e){const i=this._operatorIdMapping,a=e.argsArray,u=e.fnArray,d=[];for(let c=0,S=u.length;c<S;c++){const X=u[c];d.push({fnId:X,fn:i[X],args:a[c]})}return s(d)}executeOpTree(e){for(const i of e){const a=i.fn,u=i.fnId,d=i.args;switch(u|0){case v.OPS.beginText:this.beginText();break;case v.OPS.dependency:break;case v.OPS.setLeading:this.setLeading(d);break;case v.OPS.setLeadingMoveText:this.setLeadingMoveText(d[0],d[1]);break;case v.OPS.setFont:this.setFont(d);break;case v.OPS.showText:this.showText(d[0]);break;case v.OPS.showSpacedText:this.showText(d[0]);break;case v.OPS.endText:this.endText();break;case v.OPS.moveText:this.moveText(d[0],d[1]);break;case v.OPS.setCharSpacing:this.setCharSpacing(d[0]);break;case v.OPS.setWordSpacing:this.setWordSpacing(d[0]);break;case v.OPS.setHScale:this.setHScale(d[0]);break;case v.OPS.setTextMatrix:this.setTextMatrix(d[0],d[1],d[2],d[3],d[4],d[5]);break;case v.OPS.setTextRise:this.setTextRise(d[0]);break;case v.OPS.setTextRenderingMode:this.setTextRenderingMode(d[0]);break;case v.OPS.setLineWidth:this.setLineWidth(d[0]);break;case v.OPS.setLineJoin:this.setLineJoin(d[0]);break;case v.OPS.setLineCap:this.setLineCap(d[0]);break;case v.OPS.setMiterLimit:this.setMiterLimit(d[0]);break;case v.OPS.setFillRGBColor:this.setFillRGBColor(d[0],d[1],d[2]);break;case v.OPS.setStrokeRGBColor:this.setStrokeRGBColor(d[0],d[1],d[2]);break;case v.OPS.setStrokeColorN:this.setStrokeColorN(d);break;case v.OPS.setFillColorN:this.setFillColorN(d);break;case v.OPS.shadingFill:this.shadingFill(d[0]);break;case v.OPS.setDash:this.setDash(d[0],d[1]);break;case v.OPS.setRenderingIntent:this.setRenderingIntent(d[0]);break;case v.OPS.setFlatness:this.setFlatness(d[0]);break;case v.OPS.setGState:this.setGState(d[0]);break;case v.OPS.fill:this.fill();break;case v.OPS.eoFill:this.eoFill();break;case v.OPS.stroke:this.stroke();break;case v.OPS.fillStroke:this.fillStroke();break;case v.OPS.eoFillStroke:this.eoFillStroke();break;case v.OPS.clip:this.clip("nonzero");break;case v.OPS.eoClip:this.clip("evenodd");break;case v.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case v.OPS.paintImageXObject:this.paintImageXObject(d[0]);break;case v.OPS.paintInlineImageXObject:this.paintInlineImageXObject(d[0]);break;case v.OPS.paintImageMaskXObject:this.paintImageMaskXObject(d[0]);break;case v.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(d[0],d[1]);break;case v.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case v.OPS.closePath:this.closePath();break;case v.OPS.closeStroke:this.closeStroke();break;case v.OPS.closeFillStroke:this.closeFillStroke();break;case v.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case v.OPS.nextLine:this.nextLine();break;case v.OPS.transform:this.transform(d[0],d[1],d[2],d[3],d[4],d[5]);break;case v.OPS.constructPath:this.constructPath(d[0],d[1]);break;case v.OPS.endPath:this.endPath();break;case 92:this.group(i.items);break;default:(0,v.warn)(`Unimplemented operator ${a}`);break}}}setWordSpacing(e){this.current.wordSpacing=e}setCharSpacing(e){this.current.charSpacing=e}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(e,i,a,u,d,c){const S=this.current;S.textMatrix=S.lineMatrix=[e,i,a,u,d,c],S.textMatrixScale=Math.hypot(e,i),S.x=S.lineX=0,S.y=S.lineY=0,S.xcoords=[],S.ycoords=[],S.tspan=this.svgFactory.createElement("svg:tspan"),S.tspan.setAttributeNS(null,"font-family",S.fontFamily),S.tspan.setAttributeNS(null,"font-size",`${n(S.fontSize)}px`),S.tspan.setAttributeNS(null,"y",n(-S.y)),S.txtElement=this.svgFactory.createElement("svg:text"),S.txtElement.append(S.tspan)}beginText(){const e=this.current;e.x=e.lineX=0,e.y=e.lineY=0,e.textMatrix=v.IDENTITY_MATRIX,e.lineMatrix=v.IDENTITY_MATRIX,e.textMatrixScale=1,e.tspan=this.svgFactory.createElement("svg:tspan"),e.txtElement=this.svgFactory.createElement("svg:text"),e.txtgrp=this.svgFactory.createElement("svg:g"),e.xcoords=[],e.ycoords=[]}moveText(e,i){const a=this.current;a.x=a.lineX+=e,a.y=a.lineY+=i,a.xcoords=[],a.ycoords=[],a.tspan=this.svgFactory.createElement("svg:tspan"),a.tspan.setAttributeNS(null,"font-family",a.fontFamily),a.tspan.setAttributeNS(null,"font-size",`${n(a.fontSize)}px`),a.tspan.setAttributeNS(null,"y",n(-a.y))}showText(e){const i=this.current,a=i.font,u=i.fontSize;if(u===0)return;const d=i.fontSizeScale,c=i.charSpacing,S=i.wordSpacing,X=i.fontDirection,tt=i.textHScale*X,K=a.vertical,Y=K?1:-1,B=a.defaultVMetrics,q=u*i.fontMatrix[0];let $=0;for(const yt of e){if(yt===null){$+=X*S;continue}else if(typeof yt=="number"){$+=Y*yt*u/1e3;continue}const O=(yt.isSpace?S:0)+c,f=yt.fontChar;let h,E,F=yt.width;if(K){let I;const G=yt.vmetric||B;I=yt.vmetric?G[1]:F*.5,I=-I*q;const z=G[2]*q;F=G?-G[0]:F,h=I/d,E=($+z)/d}else h=$/d,E=0;(yt.isInFont||a.missingFile)&&(i.xcoords.push(i.x+h),K&&i.ycoords.push(-i.y+E),i.tspan.textContent+=f);let D;K?D=F*q-O*X:D=F*q+O*X,$+=D}i.tspan.setAttributeNS(null,"x",i.xcoords.map(n).join(" ")),K?i.tspan.setAttributeNS(null,"y",i.ycoords.map(n).join(" ")):i.tspan.setAttributeNS(null,"y",n(-i.y)),K?i.y-=$:i.x+=$*tt,i.tspan.setAttributeNS(null,"font-family",i.fontFamily),i.tspan.setAttributeNS(null,"font-size",`${n(i.fontSize)}px`),i.fontStyle!==Q.fontStyle&&i.tspan.setAttributeNS(null,"font-style",i.fontStyle),i.fontWeight!==Q.fontWeight&&i.tspan.setAttributeNS(null,"font-weight",i.fontWeight);const it=i.textRenderingMode&v.TextRenderingMode.FILL_STROKE_MASK;if(it===v.TextRenderingMode.FILL||it===v.TextRenderingMode.FILL_STROKE?(i.fillColor!==Q.fillColor&&i.tspan.setAttributeNS(null,"fill",i.fillColor),i.fillAlpha<1&&i.tspan.setAttributeNS(null,"fill-opacity",i.fillAlpha)):i.textRenderingMode===v.TextRenderingMode.ADD_TO_PATH?i.tspan.setAttributeNS(null,"fill","transparent"):i.tspan.setAttributeNS(null,"fill","none"),it===v.TextRenderingMode.STROKE||it===v.TextRenderingMode.FILL_STROKE){const yt=1/(i.textMatrixScale||1);this._setStrokeAttributes(i.tspan,yt)}let ht=i.textMatrix;i.textRise!==0&&(ht=ht.slice(),ht[5]+=i.textRise),i.txtElement.setAttributeNS(null,"transform",`${o(ht)} scale(${n(tt)}, -1)`),i.txtElement.setAttributeNS(N,"xml:space","preserve"),i.txtElement.append(i.tspan),i.txtgrp.append(i.txtElement),this._ensureTransformGroup().append(i.txtElement)}setLeadingMoveText(e,i){this.setLeading(-i),this.moveText(e,i)}addFontStyle(e){if(!e.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.append(this.cssStyle));const i=P(e.data,e.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${e.loadedName}"; src: url(${i}); }
133
+ `}setFont(e){const i=this.current,a=this.commonObjs.get(e[0]);let u=e[1];i.font=a,this.embedFonts&&!a.missingFile&&!this.embeddedFonts[a.loadedName]&&(this.addFontStyle(a),this.embeddedFonts[a.loadedName]=a),i.fontMatrix=a.fontMatrix||v.FONT_IDENTITY_MATRIX;let d="normal";a.black?d="900":a.bold&&(d="bold");const c=a.italic?"italic":"normal";u<0?(u=-u,i.fontDirection=-1):i.fontDirection=1,i.fontSize=u,i.fontFamily=a.loadedName,i.fontWeight=d,i.fontStyle=c,i.tspan=this.svgFactory.createElement("svg:tspan"),i.tspan.setAttributeNS(null,"y",n(-i.y)),i.xcoords=[],i.ycoords=[]}endText(){var i;const e=this.current;e.textRenderingMode&v.TextRenderingMode.ADD_TO_PATH_FLAG&&((i=e.txtElement)!=null&&i.hasChildNodes())&&(e.element=e.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(e){e>0&&(this.current.lineWidth=e)}setLineCap(e){this.current.lineCap=k[e]}setLineJoin(e){this.current.lineJoin=M[e]}setMiterLimit(e){this.current.miterLimit=e}setStrokeAlpha(e){this.current.strokeAlpha=e}setStrokeRGBColor(e,i,a){this.current.strokeColor=v.Util.makeHexColor(e,i,a)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,i,a){this.current.fillColor=v.Util.makeHexColor(e,i,a),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(e){this.current.strokeColor=this._makeColorN_Pattern(e)}setFillColorN(e){this.current.fillColor=this._makeColorN_Pattern(e)}shadingFill(e){const i=this.viewport.width,a=this.viewport.height,u=v.Util.inverseTransform(this.transformMatrix),d=v.Util.applyTransform([0,0],u),c=v.Util.applyTransform([0,a],u),S=v.Util.applyTransform([i,0],u),X=v.Util.applyTransform([i,a],u),tt=Math.min(d[0],c[0],S[0],X[0]),K=Math.min(d[1],c[1],S[1],X[1]),Y=Math.max(d[0],c[0],S[0],X[0]),B=Math.max(d[1],c[1],S[1],X[1]),q=this.svgFactory.createElement("svg:rect");q.setAttributeNS(null,"x",tt),q.setAttributeNS(null,"y",K),q.setAttributeNS(null,"width",Y-tt),q.setAttributeNS(null,"height",B-K),q.setAttributeNS(null,"fill",this._makeShadingPattern(e)),this.current.fillAlpha<1&&q.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(q)}_makeColorN_Pattern(e){return e[0]==="TilingPattern"?this._makeTilingPattern(e):this._makeShadingPattern(e)}_makeTilingPattern(e){const i=e[1],a=e[2],u=e[3]||v.IDENTITY_MATRIX,[d,c,S,X]=e[4],tt=e[5],K=e[6],Y=e[7],B=`shading${t++}`,[q,$,it,ht]=v.Util.normalizeRect([...v.Util.applyTransform([d,c],u),...v.Util.applyTransform([S,X],u)]),[yt,O]=v.Util.singularValueDecompose2dScale(u),f=tt*yt,h=K*O,E=this.svgFactory.createElement("svg:pattern");E.setAttributeNS(null,"id",B),E.setAttributeNS(null,"patternUnits","userSpaceOnUse"),E.setAttributeNS(null,"width",f),E.setAttributeNS(null,"height",h),E.setAttributeNS(null,"x",`${q}`),E.setAttributeNS(null,"y",`${$}`);const F=this.svg,D=this.transformMatrix,I=this.current.fillColor,G=this.current.strokeColor,z=this.svgFactory.create(it-q,ht-$);if(this.svg=z,this.transformMatrix=u,Y===2){const r=v.Util.makeHexColor(...i);this.current.fillColor=r,this.current.strokeColor=r}return this.executeOpTree(this.convertOpList(a)),this.svg=F,this.transformMatrix=D,this.current.fillColor=I,this.current.strokeColor=G,E.append(z.childNodes[0]),this.defs.append(E),`url(#${B})`}_makeShadingPattern(e){switch(typeof e=="string"&&(e=this.objs.get(e)),e[0]){case"RadialAxial":const i=`shading${t++}`,a=e[3];let u;switch(e[1]){case"axial":const d=e[4],c=e[5];u=this.svgFactory.createElement("svg:linearGradient"),u.setAttributeNS(null,"id",i),u.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),u.setAttributeNS(null,"x1",d[0]),u.setAttributeNS(null,"y1",d[1]),u.setAttributeNS(null,"x2",c[0]),u.setAttributeNS(null,"y2",c[1]);break;case"radial":const S=e[4],X=e[5],tt=e[6],K=e[7];u=this.svgFactory.createElement("svg:radialGradient"),u.setAttributeNS(null,"id",i),u.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),u.setAttributeNS(null,"cx",X[0]),u.setAttributeNS(null,"cy",X[1]),u.setAttributeNS(null,"r",K),u.setAttributeNS(null,"fx",S[0]),u.setAttributeNS(null,"fy",S[1]),u.setAttributeNS(null,"fr",tt);break;default:throw new Error(`Unknown RadialAxial type: ${e[1]}`)}for(const d of a){const c=this.svgFactory.createElement("svg:stop");c.setAttributeNS(null,"offset",d[0]),c.setAttributeNS(null,"stop-color",d[1]),u.append(c)}return this.defs.append(u),`url(#${i})`;case"Mesh":return(0,v.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${e[0]}`)}}setDash(e,i){this.current.dashArray=e,this.current.dashPhase=i}constructPath(e,i){const a=this.current;let u=a.x,d=a.y,c=[],S=0;for(const X of e)switch(X|0){case v.OPS.rectangle:u=i[S++],d=i[S++];const tt=i[S++],K=i[S++],Y=u+tt,B=d+K;c.push("M",n(u),n(d),"L",n(Y),n(d),"L",n(Y),n(B),"L",n(u),n(B),"Z");break;case v.OPS.moveTo:u=i[S++],d=i[S++],c.push("M",n(u),n(d));break;case v.OPS.lineTo:u=i[S++],d=i[S++],c.push("L",n(u),n(d));break;case v.OPS.curveTo:u=i[S+4],d=i[S+5],c.push("C",n(i[S]),n(i[S+1]),n(i[S+2]),n(i[S+3]),n(u),n(d)),S+=6;break;case v.OPS.curveTo2:c.push("C",n(u),n(d),n(i[S]),n(i[S+1]),n(i[S+2]),n(i[S+3])),u=i[S+2],d=i[S+3],S+=4;break;case v.OPS.curveTo3:u=i[S+2],d=i[S+3],c.push("C",n(i[S]),n(i[S+1]),n(u),n(d),n(u),n(d)),S+=4;break;case v.OPS.closePath:c.push("Z");break}c=c.join(" "),a.path&&e.length>0&&e[0]!==v.OPS.rectangle&&e[0]!==v.OPS.moveTo?c=a.path.getAttributeNS(null,"d")+c:(a.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(a.path)),a.path.setAttributeNS(null,"d",c),a.path.setAttributeNS(null,"fill","none"),a.element=a.path,a.setCurrentPoint(u,d)}endPath(){const e=this.current;if(e.path=null,!this.pendingClip)return;if(!e.element){this.pendingClip=null;return}const i=`clippath${y++}`,a=this.svgFactory.createElement("svg:clipPath");a.setAttributeNS(null,"id",i),a.setAttributeNS(null,"transform",o(this.transformMatrix));const u=e.element.cloneNode(!0);if(this.pendingClip==="evenodd"?u.setAttributeNS(null,"clip-rule","evenodd"):u.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,a.append(u),this.defs.append(a),e.activeClipUrl){e.clipGroup=null;for(const d of this.extraStack)d.clipGroup=null;a.setAttributeNS(null,"clip-path",e.activeClipUrl)}e.activeClipUrl=`url(#${i})`,this.tgrp=null}clip(e){this.pendingClip=e}closePath(){const e=this.current;if(e.path){const i=`${e.path.getAttributeNS(null,"d")}Z`;e.path.setAttributeNS(null,"d",i)}}setLeading(e){this.current.leading=-e}setTextRise(e){this.current.textRise=e}setTextRenderingMode(e){this.current.textRenderingMode=e}setHScale(e){this.current.textHScale=e/100}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[i,a]of e)switch(i){case"LW":this.setLineWidth(a);break;case"LC":this.setLineCap(a);break;case"LJ":this.setLineJoin(a);break;case"ML":this.setMiterLimit(a);break;case"D":this.setDash(a[0],a[1]);break;case"RI":this.setRenderingIntent(a);break;case"FL":this.setFlatness(a);break;case"Font":this.setFont(a);break;case"CA":this.setStrokeAlpha(a);break;case"ca":this.setFillAlpha(a);break;default:(0,v.warn)(`Unimplemented graphic state operator ${i}`);break}}fill(){const e=this.current;e.element&&(e.element.setAttributeNS(null,"fill",e.fillColor),e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha),this.endPath())}stroke(){const e=this.current;e.element&&(this._setStrokeAttributes(e.element),e.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(e,i=1){const a=this.current;let u=a.dashArray;i!==1&&u.length>0&&(u=u.map(function(d){return i*d})),e.setAttributeNS(null,"stroke",a.strokeColor),e.setAttributeNS(null,"stroke-opacity",a.strokeAlpha),e.setAttributeNS(null,"stroke-miterlimit",n(a.miterLimit)),e.setAttributeNS(null,"stroke-linecap",a.lineCap),e.setAttributeNS(null,"stroke-linejoin",a.lineJoin),e.setAttributeNS(null,"stroke-width",n(i*a.lineWidth)+"px"),e.setAttributeNS(null,"stroke-dasharray",u.map(n).join(" ")),e.setAttributeNS(null,"stroke-dashoffset",n(i*a.dashPhase)+"px")}eoFill(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){const e=this.svgFactory.createElement("svg:rect");e.setAttributeNS(null,"x","0"),e.setAttributeNS(null,"y","0"),e.setAttributeNS(null,"width","1px"),e.setAttributeNS(null,"height","1px"),e.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().append(e)}paintImageXObject(e){const i=e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e);if(!i){(0,v.warn)(`Dependent image with object ID ${e} is not ready yet`);return}this.paintInlineImageXObject(i)}paintInlineImageXObject(e,i){const a=e.width,u=e.height,d=w(e,this.forceDataSchema,!!i),c=this.svgFactory.createElement("svg:rect");c.setAttributeNS(null,"x","0"),c.setAttributeNS(null,"y","0"),c.setAttributeNS(null,"width",n(a)),c.setAttributeNS(null,"height",n(u)),this.current.element=c,this.clip("nonzero");const S=this.svgFactory.createElement("svg:image");S.setAttributeNS(A,"xlink:href",d),S.setAttributeNS(null,"x","0"),S.setAttributeNS(null,"y",n(-u)),S.setAttributeNS(null,"width",n(a)+"px"),S.setAttributeNS(null,"height",n(u)+"px"),S.setAttributeNS(null,"transform",`scale(${n(1/a)} ${n(-1/u)})`),i?i.append(S):this._ensureTransformGroup().append(S)}paintImageMaskXObject(e){const i=this.current,a=e.width,u=e.height,d=i.fillColor;i.maskId=`mask${p++}`;const c=this.svgFactory.createElement("svg:mask");c.setAttributeNS(null,"id",i.maskId);const S=this.svgFactory.createElement("svg:rect");S.setAttributeNS(null,"x","0"),S.setAttributeNS(null,"y","0"),S.setAttributeNS(null,"width",n(a)),S.setAttributeNS(null,"height",n(u)),S.setAttributeNS(null,"fill",d),S.setAttributeNS(null,"mask",`url(#${i.maskId})`),this.defs.append(c),this._ensureTransformGroup().append(S),this.paintInlineImageXObject(e,c)}paintFormXObjectBegin(e,i){if(Array.isArray(e)&&e.length===6&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]),i){const a=i[2]-i[0],u=i[3]-i[1],d=this.svgFactory.createElement("svg:rect");d.setAttributeNS(null,"x",i[0]),d.setAttributeNS(null,"y",i[1]),d.setAttributeNS(null,"width",n(a)),d.setAttributeNS(null,"height",n(u)),this.current.element=d,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(e){const i=this.svgFactory.create(e.width,e.height),a=this.svgFactory.createElement("svg:defs");i.append(a),this.defs=a;const u=this.svgFactory.createElement("svg:g");return u.setAttributeNS(null,"transform",o(e.transform)),i.append(u),this.svg=u,i}_ensureClipGroup(){if(!this.current.clipGroup){const e=this.svgFactory.createElement("svg:g");e.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.append(e),this.current.clipGroup=e}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",o(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}}},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.PDFNodeStream=void 0;var _=U(1),v=U(33);const V=require$$5,H=require$$5,Q=require$$5,N=require$$5,A=/^file:\/\/\/[a-zA-Z]:\//;function k(p){const t=N.parse(p);return t.protocol==="file:"||t.host?t:/^[a-z]:[/\\]/i.test(p)?N.parse(`file:///${p}`):(t.host||(t.protocol="file:"),t)}class M{constructor(t){this.source=t,this.url=k(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&t.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return(0,_.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new o(this):new s(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=this.isFsUrl?new y(this,t,e):new n(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}g.PDFNodeStream=M;class P{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=(0,_.createPromiseCapability)(),this._headersCapability=(0,_.createPromiseCapability)()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=(0,_.createPromiseCapability)(),this.read()):(this._loaded+=t.length,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new _.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class w{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=(0,_.createPromiseCapability)();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=(0,_.createPromiseCapability)(),this.read()):(this._loaded+=t.length,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function l(p,t){return{protocol:p.protocol,auth:p.auth,host:p.hostname,port:p.port,path:p.path,method:"GET",headers:t}}class s extends P{constructor(t){super(t);const e=i=>{if(i.statusCode===404){const c=new _.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=c,this._headersCapability.reject(c);return}this._headersCapability.resolve(),this._setReadableStream(i);const a=c=>this._readableStream.headers[c.toLowerCase()],{allowRangeRequests:u,suggestedLength:d}=(0,v.validateRangeRequestCapabilities)({getResponseHeader:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=u,this._contentLength=d||this._contentLength,this._filename=(0,v.extractFilenameFromHeader)(a)};this._request=null,this._url.protocol==="http:"?this._request=H.request(l(this._url,t.httpHeaders),e):this._request=Q.request(l(this._url,t.httpHeaders),e),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class n extends w{constructor(t,e,i){super(t),this._httpHeaders={};for(const u in t.httpHeaders){const d=t.httpHeaders[u];typeof d>"u"||(this._httpHeaders[u]=d)}this._httpHeaders.Range=`bytes=${e}-${i-1}`;const a=u=>{if(u.statusCode===404){const d=new _.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=d;return}this._setReadableStream(u)};this._request=null,this._url.protocol==="http:"?this._request=H.request(l(this._url,this._httpHeaders),a):this._request=Q.request(l(this._url,this._httpHeaders),a),this._request.on("error",u=>{this._storedError=u}),this._request.end()}}class o extends P{constructor(t){super(t);let e=decodeURIComponent(this._url.path);A.test(this._url.href)&&(e=e.replace(/^\//,"")),V.lstat(e,(i,a)=>{if(i){i.code==="ENOENT"&&(i=new _.MissingPDFException(`Missing PDF "${e}".`)),this._storedError=i,this._headersCapability.reject(i);return}this._contentLength=a.size,this._setReadableStream(V.createReadStream(e)),this._headersCapability.resolve()})}}class y extends w{constructor(t,e,i){super(t);let a=decodeURIComponent(this._url.path);A.test(this._url.href)&&(a=a.replace(/^\//,"")),this._setReadableStream(V.createReadStream(a,{start:e,end:i-1}))}}},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.createResponseStatusError=N,g.extractFilenameFromHeader=Q,g.validateRangeRequestCapabilities=H,g.validateResponseStatus=A;var _=U(1),v=U(34),V=U(8);function H({getResponseHeader:k,isHttp:M,rangeChunkSize:P,disableRange:w}){const l={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(k("Content-Length"),10);return!Number.isInteger(s)||(l.suggestedLength=s,s<=2*P)||w||!M||k("Accept-Ranges")!=="bytes"||(k("Content-Encoding")||"identity")!=="identity"||(l.allowRangeRequests=!0),l}function Q(k){const M=k("Content-Disposition");if(M){let P=(0,v.getFilenameFromContentDispositionHeader)(M);if(P.includes("%"))try{P=decodeURIComponent(P)}catch{}if((0,V.isPdfFile)(P))return P}return null}function N(k,M){return k===404||k===0&&M.startsWith("file:")?new _.MissingPDFException('Missing PDF "'+M+'".'):new _.UnexpectedResponseException(`Unexpected server response (${k}) while retrieving PDF "${M}".`,k)}function A(k){return k===200||k===206}},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.getFilenameFromContentDispositionHeader=v;var _=U(1);function v(V){let H=!0,Q=N("filename\\*","i").exec(V);if(Q){Q=Q[1];let s=P(Q);return s=unescape(s),s=w(s),s=l(s),k(s)}if(Q=M(V),Q){const s=l(Q);return k(s)}if(Q=N("filename","i").exec(V),Q){Q=Q[1];let s=P(Q);return s=l(s),k(s)}function N(s,n){return new RegExp("(?:^|;)\\s*"+s+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',n)}function A(s,n){if(s){if(!/^[\x00-\xFF]+$/.test(n))return n;try{const o=new TextDecoder(s,{fatal:!0}),y=(0,_.stringToBytes)(n);n=o.decode(y),H=!1}catch{}}return n}function k(s){return H&&/[\x80-\xff]/.test(s)&&(s=A("utf-8",s),H&&(s=A("iso-8859-1",s))),s}function M(s){const n=[];let o;const y=N("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(o=y.exec(s))!==null;){let[,t,e,i]=o;if(t=parseInt(t,10),t in n){if(t===0)break;continue}n[t]=[e,i]}const p=[];for(let t=0;t<n.length&&t in n;++t){let[e,i]=n[t];i=P(i),e&&(i=unescape(i),t===0&&(i=w(i))),p.push(i)}return p.join("")}function P(s){if(s.startsWith('"')){const n=s.slice(1).split('\\"');for(let o=0;o<n.length;++o){const y=n[o].indexOf('"');y!==-1&&(n[o]=n[o].slice(0,y),n.length=o+1),n[o]=n[o].replace(/\\(.)/g,"$1")}s=n.join('"')}return s}function w(s){const n=s.indexOf("'");if(n===-1)return s;const o=s.slice(0,n),p=s.slice(n+1).replace(/^[^']*'/,"");return A(o,p)}function l(s){return!s.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(s)?s:s.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(n,o,y,p){if(y==="q"||y==="Q")return p=p.replace(/_/g," "),p=p.replace(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}),A(o,p);try{p=atob(p)}catch{}return A(o,p)})}return""}},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.PDFNetworkStream=void 0;var _=U(1),v=U(33);const V=200,H=206;function Q(P){const w=P.response;return typeof w!="string"?w:(0,_.stringToBytes)(w).buffer}class N{constructor(w,l={}){this.url=w,this.isHttp=/^https?:/i.test(w),this.httpHeaders=this.isHttp&&l.httpHeaders||Object.create(null),this.withCredentials=l.withCredentials||!1,this.getXhr=l.getXhr||function(){return new XMLHttpRequest},this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(w,l,s){const n={begin:w,end:l};for(const o in s)n[o]=s[o];return this.request(n)}requestFull(w){return this.request(w)}request(w){const l=this.getXhr(),s=this.currXhrId++,n=this.pendingRequests[s]={xhr:l};l.open("GET",this.url),l.withCredentials=this.withCredentials;for(const o in this.httpHeaders){const y=this.httpHeaders[o];typeof y>"u"||l.setRequestHeader(o,y)}return this.isHttp&&"begin"in w&&"end"in w?(l.setRequestHeader("Range",`bytes=${w.begin}-${w.end-1}`),n.expectedStatus=H):n.expectedStatus=V,l.responseType="arraybuffer",w.onError&&(l.onerror=function(o){w.onError(l.status)}),l.onreadystatechange=this.onStateChange.bind(this,s),l.onprogress=this.onProgress.bind(this,s),n.onHeadersReceived=w.onHeadersReceived,n.onDone=w.onDone,n.onError=w.onError,n.onProgress=w.onProgress,l.send(null),s}onProgress(w,l){var n;const s=this.pendingRequests[w];s&&((n=s.onProgress)==null||n.call(s,l))}onStateChange(w,l){var t,e,i;const s=this.pendingRequests[w];if(!s)return;const n=s.xhr;if(n.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),n.readyState!==4||!(w in this.pendingRequests))return;if(delete this.pendingRequests[w],n.status===0&&this.isHttp){(t=s.onError)==null||t.call(s,n.status);return}const o=n.status||V;if(!(o===V&&s.expectedStatus===H)&&o!==s.expectedStatus){(e=s.onError)==null||e.call(s,n.status);return}const p=Q(n);if(o===H){const a=n.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(a);s.onDone({begin:parseInt(u[1],10),chunk:p})}else p?s.onDone({begin:0,chunk:p}):(i=s.onError)==null||i.call(s,n.status)}getRequestXhr(w){return this.pendingRequests[w].xhr}isPendingRequest(w){return w in this.pendingRequests}abortRequest(w){const l=this.pendingRequests[w].xhr;delete this.pendingRequests[w],l.abort()}}class A{constructor(w){this._source=w,this._manager=new N(w.url,{httpHeaders:w.httpHeaders,withCredentials:w.withCredentials}),this._rangeChunkSize=w.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(w){const l=this._rangeRequestReaders.indexOf(w);l>=0&&this._rangeRequestReaders.splice(l,1)}getFullReader(){return(0,_.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new k(this._manager,this._source),this._fullRequestReader}getRangeReader(w,l){const s=new M(this._manager,w,l);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(w){var l;(l=this._fullRequestReader)==null||l.cancel(w);for(const s of this._rangeRequestReaders.slice(0))s.cancel(w)}}g.PDFNetworkStream=A;class k{constructor(w,l){this._manager=w;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=l.url,this._fullRequestId=w.requestFull(s),this._headersReceivedCapability=(0,_.createPromiseCapability)(),this._disableRange=l.disableRange||!1,this._contentLength=l.length,this._rangeChunkSize=l.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const w=this._fullRequestId,l=this._manager.getRequestXhr(w),s=y=>l.getResponseHeader(y),{allowRangeRequests:n,suggestedLength:o}=(0,v.validateRangeRequestCapabilities)({getResponseHeader:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=(0,v.extractFilenameFromHeader)(s),this._isRangeSupported&&this._manager.abortRequest(w),this._headersReceivedCapability.resolve()}_onDone(w){if(w&&(this._requests.length>0?this._requests.shift().resolve({value:w.chunk,done:!1}):this._cachedChunks.push(w.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const l of this._requests)l.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(w){this._storedError=(0,v.createResponseStatusError)(w,this._url),this._headersReceivedCapability.reject(this._storedError);for(const l of this._requests)l.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(w){var l;(l=this.onProgress)==null||l.call(this,{loaded:w.loaded,total:w.lengthComputable?w.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const w=(0,_.createPromiseCapability)();return this._requests.push(w),w.promise}cancel(w){this._done=!0,this._headersReceivedCapability.reject(w);for(const l of this._requests)l.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class M{constructor(w,l,s){this._manager=w;const n={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=w.url,this._requestId=w.requestRange(l,s,n),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var w;(w=this.onClosed)==null||w.call(this,this)}_onDone(w){const l=w.chunk;this._requests.length>0?this._requests.shift().resolve({value:l,done:!1}):this._queuedChunk=l,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(w){this._storedError=(0,v.createResponseStatusError)(w,this._url);for(const l of this._requests)l.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(w){var l;this.isStreamingSupported||(l=this.onProgress)==null||l.call(this,{loaded:w.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const l=this._queuedChunk;return this._queuedChunk=null,{value:l,done:!1}}if(this._done)return{value:void 0,done:!0};const w=(0,_.createPromiseCapability)();return this._requests.push(w),w.promise}cancel(w){this._done=!0;for(const l of this._requests)l.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(nt,g,U)=>{Object.defineProperty(g,"__esModule",{value:!0}),g.PDFFetchStream=void 0;var _=U(1),v=U(33);function V(k,M,P){return{method:"GET",headers:k,signal:P.signal,mode:"cors",credentials:M?"include":"same-origin",redirect:"follow"}}function H(k){const M=new Headers;for(const P in k){const w=k[P];typeof w>"u"||M.append(P,w)}return M}class Q{constructor(M){this.source=M,this.isHttp=/^https?:/i.test(M.url),this.httpHeaders=this.isHttp&&M.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var M;return((M=this._fullRequestReader)==null?void 0:M._loaded)??0}getFullReader(){return(0,_.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new N(this),this._fullRequestReader}getRangeReader(M,P){if(P<=this._progressiveDataLength)return null;const w=new A(this,M,P);return this._rangeRequestReaders.push(w),w}cancelAllRequests(M){this._fullRequestReader&&this._fullRequestReader.cancel(M);for(const P of this._rangeRequestReaders.slice(0))P.cancel(M)}}g.PDFFetchStream=Q;class N{constructor(M){this._stream=M,this._reader=null,this._loaded=0,this._filename=null;const P=M.source;this._withCredentials=P.withCredentials||!1,this._contentLength=P.length,this._headersCapability=(0,_.createPromiseCapability)(),this._disableRange=P.disableRange||!1,this._rangeChunkSize=P.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!P.disableStream,this._isRangeSupported=!P.disableRange,this._headers=H(this._stream.httpHeaders);const w=P.url;fetch(w,V(this._headers,this._withCredentials,this._abortController)).then(l=>{if(!(0,v.validateResponseStatus)(l.status))throw(0,v.createResponseStatusError)(l.status,w);this._reader=l.body.getReader(),this._headersCapability.resolve();const s=y=>l.headers.get(y),{allowRangeRequests:n,suggestedLength:o}=(0,v.validateRangeRequestCapabilities)({getResponseHeader:s,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=o||this._contentLength,this._filename=(0,v.extractFilenameFromHeader)(s),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new _.AbortException("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:M,done:P}=await this._reader.read();return P?{value:M,done:P}:(this._loaded+=M.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(M).buffer,done:!1})}cancel(M){this._reader&&this._reader.cancel(M),this._abortController.abort()}}class A{constructor(M,P,w){this._stream=M,this._reader=null,this._loaded=0;const l=M.source;this._withCredentials=l.withCredentials||!1,this._readCapability=(0,_.createPromiseCapability)(),this._isStreamingSupported=!l.disableStream,this._abortController=new AbortController,this._headers=H(this._stream.httpHeaders),this._headers.append("Range",`bytes=${P}-${w-1}`);const s=l.url;fetch(s,V(this._headers,this._withCredentials,this._abortController)).then(n=>{if(!(0,v.validateResponseStatus)(n.status))throw(0,v.createResponseStatusError)(n.status,s);this._readCapability.resolve(),this._reader=n.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:M,done:P}=await this._reader.read();return P?{value:M,done:P}:(this._loaded+=M.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(M).buffer,done:!1})}cancel(M){this._reader&&this._reader.cancel(M),this._abortController.abort()}}}],__webpack_module_cache__={};function __w_pdfjs_require__(nt){var g=__webpack_module_cache__[nt];if(g!==void 0)return g.exports;var U=__webpack_module_cache__[nt]={exports:{}};return __webpack_modules__[nt](U,U.exports,__w_pdfjs_require__),U.exports}var __webpack_exports__={};return(()=>{var nt=__webpack_exports__;Object.defineProperty(nt,"__esModule",{value:!0}),Object.defineProperty(nt,"AnnotationEditorLayer",{enumerable:!0,get:function(){return v.AnnotationEditorLayer}}),Object.defineProperty(nt,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return g.AnnotationEditorParamsType}}),Object.defineProperty(nt,"AnnotationEditorType",{enumerable:!0,get:function(){return g.AnnotationEditorType}}),Object.defineProperty(nt,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return V.AnnotationEditorUIManager}}),Object.defineProperty(nt,"AnnotationLayer",{enumerable:!0,get:function(){return H.AnnotationLayer}}),Object.defineProperty(nt,"AnnotationMode",{enumerable:!0,get:function(){return g.AnnotationMode}}),Object.defineProperty(nt,"CMapCompressionType",{enumerable:!0,get:function(){return g.CMapCompressionType}}),Object.defineProperty(nt,"GlobalWorkerOptions",{enumerable:!0,get:function(){return Q.GlobalWorkerOptions}}),Object.defineProperty(nt,"InvalidPDFException",{enumerable:!0,get:function(){return g.InvalidPDFException}}),Object.defineProperty(nt,"LoopbackPort",{enumerable:!0,get:function(){return U.LoopbackPort}}),Object.defineProperty(nt,"MissingPDFException",{enumerable:!0,get:function(){return g.MissingPDFException}}),Object.defineProperty(nt,"OPS",{enumerable:!0,get:function(){return g.OPS}}),Object.defineProperty(nt,"PDFDataRangeTransport",{enumerable:!0,get:function(){return U.PDFDataRangeTransport}}),Object.defineProperty(nt,"PDFDateString",{enumerable:!0,get:function(){return _.PDFDateString}}),Object.defineProperty(nt,"PDFWorker",{enumerable:!0,get:function(){return U.PDFWorker}}),Object.defineProperty(nt,"PasswordResponses",{enumerable:!0,get:function(){return g.PasswordResponses}}),Object.defineProperty(nt,"PermissionFlag",{enumerable:!0,get:function(){return g.PermissionFlag}}),Object.defineProperty(nt,"PixelsPerInch",{enumerable:!0,get:function(){return _.PixelsPerInch}}),Object.defineProperty(nt,"RenderingCancelledException",{enumerable:!0,get:function(){return _.RenderingCancelledException}}),Object.defineProperty(nt,"SVGGraphics",{enumerable:!0,get:function(){return k.SVGGraphics}}),Object.defineProperty(nt,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return g.UNSUPPORTED_FEATURES}}),Object.defineProperty(nt,"UnexpectedResponseException",{enumerable:!0,get:function(){return g.UnexpectedResponseException}}),Object.defineProperty(nt,"Util",{enumerable:!0,get:function(){return g.Util}}),Object.defineProperty(nt,"VerbosityLevel",{enumerable:!0,get:function(){return g.VerbosityLevel}}),Object.defineProperty(nt,"XfaLayer",{enumerable:!0,get:function(){return M.XfaLayer}}),Object.defineProperty(nt,"build",{enumerable:!0,get:function(){return U.build}}),Object.defineProperty(nt,"createPromiseCapability",{enumerable:!0,get:function(){return g.createPromiseCapability}}),Object.defineProperty(nt,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return g.createValidAbsoluteUrl}}),Object.defineProperty(nt,"getDocument",{enumerable:!0,get:function(){return U.getDocument}}),Object.defineProperty(nt,"getFilenameFromUrl",{enumerable:!0,get:function(){return _.getFilenameFromUrl}}),Object.defineProperty(nt,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return _.getPdfFilenameFromUrl}}),Object.defineProperty(nt,"getXfaPageViewport",{enumerable:!0,get:function(){return _.getXfaPageViewport}}),Object.defineProperty(nt,"isPdfFile",{enumerable:!0,get:function(){return _.isPdfFile}}),Object.defineProperty(nt,"loadScript",{enumerable:!0,get:function(){return _.loadScript}}),Object.defineProperty(nt,"renderTextLayer",{enumerable:!0,get:function(){return A.renderTextLayer}}),Object.defineProperty(nt,"shadow",{enumerable:!0,get:function(){return g.shadow}}),Object.defineProperty(nt,"version",{enumerable:!0,get:function(){return U.version}});var g=__w_pdfjs_require__(1),U=__w_pdfjs_require__(4),_=__w_pdfjs_require__(8),v=__w_pdfjs_require__(22),V=__w_pdfjs_require__(7),H=__w_pdfjs_require__(27),Q=__w_pdfjs_require__(15),N=__w_pdfjs_require__(3),A=__w_pdfjs_require__(30),k=__w_pdfjs_require__(31),M=__w_pdfjs_require__(29);if(N.isNodeJS){const{PDFNodeStream:P}=__w_pdfjs_require__(32);(0,U.setPDFNetworkStreamFactory)(w=>new P(w))}else{const{PDFNetworkStream:P}=__w_pdfjs_require__(35),{PDFFetchStream:w}=__w_pdfjs_require__(36);(0,U.setPDFNetworkStreamFactory)(l=>(0,_.isValidFetchUrl)(l.url)?new w(l):new P(l))}})(),__webpack_exports__})())})(pdf);var pdfExports=pdf.exports;const style="";class ProFlipbook{constructor(g,U,_={}){if(this.container=document.querySelector(g),!this.container){console.error(`ProFlipbook: Element ${g} not found.`);return}this.pdfUrl=U,this.options={brandText:"Pro Flipbook",backgroundColor:"#333",workerUrl:"https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.16.105/pdf.worker.min.js",..._},this.pageFlip=null,this.pdfDoc=null,this.totalPDFPages=0,this.currentZoom=1,this.currentTranslateX=0,this._injectHTML(),this._initElements(),this._initBook()}_injectHTML(){if(!document.querySelector("#pfb-fa")){const g=document.createElement("link");g.id="pfb-fa",g.rel="stylesheet",g.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css",document.head.appendChild(g)}this.container.innerHTML=`
134
+ <div class="pfb-container" style="background-color: ${this.options.backgroundColor}">
135
+ <div class="pfb-toolbar">
136
+ <button class="pfb-btn pfb-prev" title="Previous"><i class="fas fa-chevron-left"></i></button>
137
+ <div class="pfb-page-control">
138
+ <input type="text" class="pfb-page-input" value="1">
139
+ <span class="pfb-page-total">/ --</span>
140
+ </div>
141
+ <button class="pfb-btn pfb-next" title="Next"><i class="fas fa-chevron-right"></i></button>
142
+ <span style="border-left: 1px solid #555; height: 20px; margin: 0 10px;"></span>
143
+ <button class="pfb-btn pfb-zoom-in" title="Zoom In"><i class="fas fa-search-plus"></i></button>
144
+ <button class="pfb-btn pfb-zoom-out" title="Zoom Out"><i class="fas fa-search-minus"></i></button>
145
+ </div>
146
+ <div class="pfb-book-wrapper">
147
+ <div class="pfb-book"></div>
148
+ </div>
149
+ <div class="pfb-loader">
150
+ <div class="pfb-spinner"></div>
151
+ <div class="pfb-loading-text">Preparing Book...</div>
152
+ </div>
153
+ </div>
154
+ `}_initElements(){this.bookEl=this.container.querySelector(".pfb-book"),this.loader=this.container.querySelector(".pfb-loader"),this.loadingText=this.container.querySelector(".pfb-loading-text"),this.pageInput=this.container.querySelector(".pfb-page-input"),this.pageTotal=this.container.querySelector(".pfb-page-total"),this.wrapper=this.container.querySelector(".pfb-book-wrapper"),this.container.querySelector(".pfb-prev").onclick=()=>{var U;return(U=this.pageFlip)==null?void 0:U.flipPrev()},this.container.querySelector(".pfb-next").onclick=()=>{var U;return(U=this.pageFlip)==null?void 0:U.flipNext()},this.container.querySelector(".pfb-zoom-in").onclick=()=>this._handleZoom(.2),this.container.querySelector(".pfb-zoom-out").onclick=()=>this._handleZoom(-.2),this.pageInput.addEventListener("keypress",U=>{U.key==="Enter"&&(this._handleGoToPage(U.target.value),U.target.blur())});let g=0;this.bookEl.addEventListener("wheel",U=>{if(!this.pageFlip)return;U.preventDefault();const _=Date.now();_-g<800||(U.deltaY>0?this.pageFlip.flipNext():this.pageFlip.flipPrev(),g=_)},{passive:!1})}async _initBook(){try{this.loadingText.innerText="Downloading Document...",pdfExports.GlobalWorkerOptions.workerSrc=this.options.workerUrl,this.pdfDoc=await pdfExports.getDocument(this.pdfUrl).promise,this.totalPDFPages=this.pdfDoc.numPages,this.pageTotal.innerText=`/ ${this.totalPDFPages}`;const U=(await this.pdfDoc.getPage(1)).getViewport({scale:1}),_=U.width/U.height,v=this.wrapper.clientHeight||window.innerHeight*.85,V=Math.floor(v*.9),H=Math.floor(V*_);await this._renderPages(H,V,U),this._setupFlipEngine(H,V)}catch(g){console.error(g),this.loadingText.innerText="Error: "+g.message}}async _renderPages(g,U,_){this._createPageElement("transparent");for(let V=1;V<=this.totalPDFPages;V++){this.loadingText.innerText=`Rendering Page ${V} of ${this.totalPDFPages}...`;const H=await this.pdfDoc.getPage(V),Q=this._createPageElement("#fdfdfd",`
155
+ <div class="pfb-branding">
156
+ <i class="fas fa-book-open pfb-brand-logo"></i>
157
+ <div class="pfb-brand-text">${this.options.brandText}</div>
158
+ </div>
159
+ `),N=document.createElement("canvas"),A=H.getViewport({scale:g/_.width*2});N.width=A.width,N.height=A.height;const k=N.getContext("2d");await H.render({canvasContext:k,viewport:A}).promise,Q.appendChild(N)}(1+this.totalPDFPages)%2!==0&&this._createPageElement("transparent")}_createPageElement(g,U=""){const _=document.createElement("div");return _.className="pfb-page",_.style.backgroundColor=g,_.innerHTML=U,_.setAttribute("data-density","soft"),this.bookEl.appendChild(_),_}_setupFlipEngine(g,U){this.loadingText.innerText="Finalizing...",setTimeout(()=>{const _=this.bookEl.querySelectorAll(".pfb-page");this.pageFlip=new pageFlip_browserExports.PageFlip(this.bookEl,{width:g,height:U,size:"fixed",showCover:!1,maxShadowOpacity:.5,mobileScrollSupport:!1,flippingTime:800}),this.pageFlip.loadFromHTML(_),this._updateBookView(0),this.pageFlip.on("flip",v=>this._onFlip(v)),this.pageFlip.on("changeState",v=>this._onFlipStateChange(v)),this.loader.style.opacity="0",setTimeout(()=>{this.loader.style.display="none"},500)},100)}_onFlip(g){const U=g.data;if(U===0)this.pageInput.value="1";else{let _=U,v=U+1;v>this.totalPDFPages?this.pageInput.value=_:this.pageInput.value=`${_}-${v}`}this._updateBookView(U)}_updateBookView(g){if(!this.pageFlip)return;const U=g===0,_=g+2>=this.pageFlip.getPageCount();let v=0,V="none";U?(v=-25,V="inset(0 0 0 50%)"):_&&(v=25,V="inset(0 50% 0 0)"),this.currentTranslateX=v,this.bookEl.style.transform=`scale(${this.currentZoom}) translateX(${v}%)`,this.bookEl.style.clipPath=V}_onFlipStateChange(g){const U=g.data,_=this.pageFlip.getCurrentPageIndex();if(U==="flipping"&&(this.bookEl.style.transform=`scale(${this.currentZoom}) translateX(0%)`,this.bookEl.style.clipPath="none"),U==="user_fold"){const v=this.bookEl.querySelectorAll(".pfb-page");if(_<=1){const V=v[1];if(V){V.style.backgroundColor="white";const H=V.querySelector(".pfb-branding");H&&(H.style.opacity="0")}}if(_>=this.totalPDFPages-1){const V=v[v.length-2];if(V){V.style.backgroundColor="white";const H=V.querySelector(".pfb-branding");H&&(H.style.opacity="0")}}}if(U==="read"){const v=this.bookEl.querySelectorAll(".pfb-page");for(let V=1;V<v.length-1;V++){const H=v[V];H.style.backgroundColor="#fdfdfd";const Q=H.querySelector(".pfb-branding");Q&&(Q.style.opacity="1")}this._updateBookView(_)}}_handleZoom(g){const U=this.currentZoom+g;U<.4||(this.currentZoom=U,this.bookEl.style.transform=`scale(${this.currentZoom}) translateX(${this.currentTranslateX}%)`)}_handleGoToPage(g){let U=parseInt(g.split("-")[0]);(isNaN(U)||U<1)&&(U=1),U>this.totalPDFPages&&(U=this.totalPDFPages);let _;U===1?_=0:_=U%2===0?U:U-1,this.pageFlip&&this.pageFlip.flip(_)}}exports.ProFlipbook=ProFlipbook,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});