@d-i-t-a/reader 2.3.1 → 2.3.2

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.
package/dist/reader.js CHANGED
@@ -69,7 +69,7 @@ function print() { __p += __j.call(arguments, '') }
69
69
  `)}return this.compiledGlyphs[d]=new Function("c","size",y.join(""))}return this.compiledGlyphs[d]=function(y,w){for(let v of m)v.cmd==="scale"&&(v.args=[w,-w]),y[v.cmd].apply(y,v.args)}}}t.FontFaceObject=l},(r,t,n)=>{var ce,Sx;Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasGraphics=void 0;var i=n(8),o=n(1),s=n(13),l=n(14),h=n(3);let u=16,d=100,m=4096,y=15,w=10,v=h.isNodeJS&&typeof Path2D=="undefined"?-1:1e3,g=16;function f(Q,N){if(Q._removeMirroring)throw new Error("Context is already forwarding operations.");Q.__originalSave=Q.save,Q.__originalRestore=Q.restore,Q.__originalRotate=Q.rotate,Q.__originalScale=Q.scale,Q.__originalTranslate=Q.translate,Q.__originalTransform=Q.transform,Q.__originalSetTransform=Q.setTransform,Q.__originalResetTransform=Q.resetTransform,Q.__originalClip=Q.clip,Q.__originalMoveTo=Q.moveTo,Q.__originalLineTo=Q.lineTo,Q.__originalBezierCurveTo=Q.bezierCurveTo,Q.__originalRect=Q.rect,Q.__originalClosePath=Q.closePath,Q.__originalBeginPath=Q.beginPath,Q._removeMirroring=()=>{Q.save=Q.__originalSave,Q.restore=Q.__originalRestore,Q.rotate=Q.__originalRotate,Q.scale=Q.__originalScale,Q.translate=Q.__originalTranslate,Q.transform=Q.__originalTransform,Q.setTransform=Q.__originalSetTransform,Q.resetTransform=Q.__originalResetTransform,Q.clip=Q.__originalClip,Q.moveTo=Q.__originalMoveTo,Q.lineTo=Q.__originalLineTo,Q.bezierCurveTo=Q.__originalBezierCurveTo,Q.rect=Q.__originalRect,Q.closePath=Q.__originalClosePath,Q.beginPath=Q.__originalBeginPath,delete Q._removeMirroring},Q.save=function(){N.save(),this.__originalSave()},Q.restore=function(){N.restore(),this.__originalRestore()},Q.translate=function(D,W){N.translate(D,W),this.__originalTranslate(D,W)},Q.scale=function(D,W){N.scale(D,W),this.__originalScale(D,W)},Q.transform=function(D,W,z,J,he,fe){N.transform(D,W,z,J,he,fe),this.__originalTransform(D,W,z,J,he,fe)},Q.setTransform=function(D,W,z,J,he,fe){N.setTransform(D,W,z,J,he,fe),this.__originalSetTransform(D,W,z,J,he,fe)},Q.resetTransform=function(){N.resetTransform(),this.__originalResetTransform()},Q.rotate=function(D){N.rotate(D),this.__originalRotate(D)},Q.clip=function(D){N.clip(D),this.__originalClip(D)},Q.moveTo=function(B,D){N.moveTo(B,D),this.__originalMoveTo(B,D)},Q.lineTo=function(B,D){N.lineTo(B,D),this.__originalLineTo(B,D)},Q.bezierCurveTo=function(B,D,W,z,J,he){N.bezierCurveTo(B,D,W,z,J,he),this.__originalBezierCurveTo(B,D,W,z,J,he)},Q.rect=function(B,D,W,z){N.rect(B,D,W,z),this.__originalRect(B,D,W,z)},Q.closePath=function(){N.closePath(),this.__originalClosePath()},Q.beginPath=function(){N.beginPath(),this.__originalBeginPath()}}class p{constructor(N){this.canvasFactory=N,this.cache=Object.create(null)}getCanvas(N,B,D){let W;return this.cache[N]!==void 0?(W=this.cache[N],this.canvasFactory.reset(W,B,D)):(W=this.canvasFactory.create(B,D),this.cache[N]=W),W}delete(N){delete this.cache[N]}clear(){for(let N in this.cache){let B=this.cache[N];this.canvasFactory.destroy(B),delete this.cache[N]}}}function b(Q,N,B,D,W,z,J,he,fe,I){let[$,K,ne,re,de,Ee]=(0,i.getCurrentTransform)(Q);if(K===0&&ne===0){let oe=J*$+de,le=Math.round(oe),ye=he*re+Ee,Oe=Math.round(ye),j=(J+fe)*$+de,se=Math.abs(Math.round(j)-le)||1,Se=(he+I)*re+Ee,Re=Math.abs(Math.round(Se)-Oe)||1;return Q.setTransform(Math.sign($),0,0,Math.sign(re),le,Oe),Q.drawImage(N,B,D,W,z,0,0,se,Re),Q.setTransform($,K,ne,re,de,Ee),[se,Re]}if($===0&&re===0){let oe=he*ne+de,le=Math.round(oe),ye=J*K+Ee,Oe=Math.round(ye),j=(he+I)*ne+de,se=Math.abs(Math.round(j)-le)||1,Se=(J+fe)*K+Ee,Re=Math.abs(Math.round(Se)-Oe)||1;return Q.setTransform(0,Math.sign(K),Math.sign(ne),0,le,Oe),Q.drawImage(N,B,D,W,z,0,0,Re,se),Q.setTransform($,K,ne,re,de,Ee),[Re,se]}Q.drawImage(N,B,D,W,z,J,he,fe,I);let je=Math.hypot($,K),ae=Math.hypot(ne,re);return[je*fe,ae*I]}function S(Q){let{width:N,height:B}=Q;if(N>v||B>v)return null;let D=1e3,W=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),z=N+1,J=new Uint8Array(z*(B+1)),he,fe,I,$=N+7&~7,K=new Uint8Array($*B),ne=0;for(let ae of Q.data){let oe=128;for(;oe>0;)K[ne++]=ae&oe?0:255,oe>>=1}let re=0;for(ne=0,K[ne]!==0&&(J[0]=1,++re),fe=1;fe<N;fe++)K[ne]!==K[ne+1]&&(J[fe]=K[ne]?2:1,++re),ne++;for(K[ne]!==0&&(J[fe]=2,++re),he=1;he<B;he++){ne=he*$,I=he*z,K[ne-$]!==K[ne]&&(J[I]=K[ne]?1:8,++re);let ae=(K[ne]?4:0)+(K[ne-$]?8:0);for(fe=1;fe<N;fe++)ae=(ae>>2)+(K[ne+1]?4:0)+(K[ne-$+1]?8:0),W[ae]&&(J[I+fe]=W[ae],++re),ne++;if(K[ne-$]!==K[ne]&&(J[I+fe]=K[ne]?2:4,++re),re>D)return null}for(ne=$*(B-1),I=he*z,K[ne]!==0&&(J[I]=8,++re),fe=1;fe<N;fe++)K[ne]!==K[ne+1]&&(J[I+fe]=K[ne]?4:8,++re),ne++;if(K[ne]!==0&&(J[I+fe]=4,++re),re>D)return null;let de=new Int32Array([0,z,-1,0,-z,0,0,0,1]),Ee=new Path2D;for(he=0;re&&he<=B;he++){let ae=he*z,oe=ae+N;for(;ae<oe&&!J[ae];)ae++;if(ae===oe)continue;Ee.moveTo(ae%z,he);let le=ae,ye=J[ae];do{let Oe=de[ye];do ae+=Oe;while(!J[ae]);let j=J[ae];j!==5&&j!==10?(ye=j,J[ae]=0):(ye=j&51*ye>>4,J[ae]&=ye>>2|ye<<2),Ee.lineTo(ae%z,ae/z|0),J[ae]||--re}while(le!==ae);--he}return K=null,J=null,function(ae){ae.save(),ae.scale(1/N,-1/B),ae.translate(0,-B),ae.fill(Ee),ae.beginPath(),ae.restore()}}class C{constructor(N,B){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=o.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=o.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=o.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,N,B])}clone(){let N=Object.create(this);return N.clipBox=this.clipBox.slice(),N}setCurrentPoint(N,B){this.x=N,this.y=B}updatePathMinMax(N,B,D){[B,D]=o.Util.applyTransform([B,D],N),this.minX=Math.min(this.minX,B),this.minY=Math.min(this.minY,D),this.maxX=Math.max(this.maxX,B),this.maxY=Math.max(this.maxY,D)}updateRectMinMax(N,B){let D=o.Util.applyTransform(B,N),W=o.Util.applyTransform(B.slice(2),N);this.minX=Math.min(this.minX,D[0],W[0]),this.minY=Math.min(this.minY,D[1],W[1]),this.maxX=Math.max(this.maxX,D[0],W[0]),this.maxY=Math.max(this.maxY,D[1],W[1])}updateScalingPathMinMax(N,B){o.Util.scaleMinMax(N,B),this.minX=Math.min(this.minX,B[0]),this.maxX=Math.max(this.maxX,B[1]),this.minY=Math.min(this.minY,B[2]),this.maxY=Math.max(this.maxY,B[3])}updateCurvePathMinMax(N,B,D,W,z,J,he,fe,I,$){let K=o.Util.bezierBoundingBox(B,D,W,z,J,he,fe,I);if($){$[0]=Math.min($[0],K[0],K[2]),$[1]=Math.max($[1],K[0],K[2]),$[2]=Math.min($[2],K[1],K[3]),$[3]=Math.max($[3],K[1],K[3]);return}this.updateRectMinMax(N,K)}getPathBoundingBox(N=s.PathType.FILL,B=null){let D=[this.minX,this.minY,this.maxX,this.maxY];if(N===s.PathType.STROKE){B||(0,o.unreachable)("Stroke bounding box must include transform.");let W=o.Util.singularValueDecompose2dScale(B),z=W[0]*this.lineWidth/2,J=W[1]*this.lineWidth/2;D[0]-=z,D[1]-=J,D[2]+=z,D[3]+=J}return D}updateClipFromPath(){let N=o.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(N||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(N){this.clipBox=N,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(N=s.PathType.FILL,B=null){return o.Util.intersect(this.clipBox,this.getPathBoundingBox(N,B))}}function x(Q,N,B=null){if(typeof ImageData!="undefined"&&N instanceof ImageData){Q.putImageData(N,0,0);return}let D=N.height,W=N.width,z=D%g,J=(D-z)/g,he=z===0?J:J+1,fe=Q.createImageData(W,g),I=0,$,K=N.data,ne=fe.data,re,de,Ee,je,ae,oe,le,ye;if(B)switch(B.length){case 1:ae=B[0],oe=B[0],le=B[0],ye=B[0];break;case 4:ae=B[0],oe=B[1],le=B[2],ye=B[3];break}if(N.kind===o.ImageKind.GRAYSCALE_1BPP){let Oe=K.byteLength,j=new Uint32Array(ne.buffer,0,ne.byteLength>>2),se=j.length,Se=W+7>>3,Re=4294967295,Le=o.FeatureTest.isLittleEndian?4278190080:255;for(ye&&ye[0]===255&&ye[255]===0&&([Re,Le]=[Le,Re]),re=0;re<he;re++){for(Ee=re<J?g:z,$=0,de=0;de<Ee;de++){let Ze=Oe-I,Qe=0,Xe=Ze>Se?W:Ze*8-7,nt=Xe&~7,Ke=0,rt=0;for(;Qe<nt;Qe+=8)rt=K[I++],j[$++]=rt&128?Re:Le,j[$++]=rt&64?Re:Le,j[$++]=rt&32?Re:Le,j[$++]=rt&16?Re:Le,j[$++]=rt&8?Re:Le,j[$++]=rt&4?Re:Le,j[$++]=rt&2?Re:Le,j[$++]=rt&1?Re:Le;for(;Qe<Xe;Qe++)Ke===0&&(rt=K[I++],Ke=128),j[$++]=rt&Ke?Re:Le,Ke>>=1}for(;$<se;)j[$++]=0;Q.putImageData(fe,0,re*g)}}else if(N.kind===o.ImageKind.RGBA_32BPP){let Oe=!!(ae||oe||le);for(de=0,je=W*g*4,re=0;re<J;re++){if(ne.set(K.subarray(I,I+je)),I+=je,Oe)for(let j=0;j<je;j+=4)ae&&(ne[j+0]=ae[ne[j+0]]),oe&&(ne[j+1]=oe[ne[j+1]]),le&&(ne[j+2]=le[ne[j+2]]);Q.putImageData(fe,0,de),de+=g}if(re<he){if(je=W*z*4,ne.set(K.subarray(I,I+je)),Oe)for(let j=0;j<je;j+=4)ae&&(ne[j+0]=ae[ne[j+0]]),oe&&(ne[j+1]=oe[ne[j+1]]),le&&(ne[j+2]=le[ne[j+2]]);Q.putImageData(fe,0,de)}}else if(N.kind===o.ImageKind.RGB_24BPP){let Oe=!!(ae||oe||le);for(Ee=g,je=W*Ee,re=0;re<he;re++){for(re>=J&&(Ee=z,je=W*Ee),$=0,de=je;de--;)ne[$++]=K[I++],ne[$++]=K[I++],ne[$++]=K[I++],ne[$++]=255;if(Oe)for(let j=0;j<$;j+=4)ae&&(ne[j+0]=ae[ne[j+0]]),oe&&(ne[j+1]=oe[ne[j+1]]),le&&(ne[j+2]=le[ne[j+2]]);Q.putImageData(fe,0,re*g)}}else throw new Error(`bad image kind: ${N.kind}`)}function E(Q,N){if(N.bitmap){Q.drawImage(N.bitmap,0,0);return}let B=N.height,D=N.width,W=B%g,z=(B-W)/g,J=W===0?z:z+1,he=Q.createImageData(D,g),fe=0,I=N.data,$=he.data;for(let K=0;K<J;K++){let ne=K<z?g:W;({srcPos:fe}=(0,l.applyMaskImageData)({src:I,srcPos:fe,dest:$,width:D,height:ne})),Q.putImageData(he,0,K*g)}}function T(Q,N){let B=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"];for(let D=0,W=B.length;D<W;D++){let z=B[D];Q[z]!==void 0&&(N[z]=Q[z])}Q.setLineDash!==void 0&&(N.setLineDash(Q.getLineDash()),N.lineDashOffset=Q.lineDashOffset)}function R(Q,N){Q.strokeStyle=Q.fillStyle=N||"#000000",Q.fillRule="nonzero",Q.globalAlpha=1,Q.lineWidth=1,Q.lineCap="butt",Q.lineJoin="miter",Q.miterLimit=10,Q.globalCompositeOperation="source-over",Q.font="10px sans-serif",Q.setLineDash!==void 0&&(Q.setLineDash([]),Q.lineDashOffset=0)}function O(Q,N,B,D){let W=Q.length;for(let z=3;z<W;z+=4){let J=Q[z];if(J===0)Q[z-3]=N,Q[z-2]=B,Q[z-1]=D;else if(J<255){let he=255-J;Q[z-3]=Q[z-3]*J+N*he>>8,Q[z-2]=Q[z-2]*J+B*he>>8,Q[z-1]=Q[z-1]*J+D*he>>8}}}function L(Q,N,B){let D=Q.length,W=1/255;for(let z=3;z<D;z+=4){let J=B?B[Q[z]]:Q[z];N[z]=N[z]*J*W|0}}function M(Q,N,B){let D=Q.length;for(let W=3;W<D;W+=4){let z=Q[W-3]*77+Q[W-2]*152+Q[W-1]*28;N[W]=B?N[W]*B[z>>8]>>8:N[W]*z>>16}}function k(Q,N,B,D,W,z,J,he,fe,I,$){let K=!!z,ne=K?z[0]:0,re=K?z[1]:0,de=K?z[2]:0,Ee;W==="Luminosity"?Ee=M:Ee=L;let ae=Math.min(D,Math.ceil(1048576/B));for(let oe=0;oe<D;oe+=ae){let le=Math.min(ae,D-oe),ye=Q.getImageData(he-I,oe+(fe-$),B,le),Oe=N.getImageData(he,oe+fe,B,le);K&&O(ye.data,ne,re,de),Ee(ye.data,Oe.data,J),N.putImageData(Oe,he,oe+fe)}}function F(Q,N,B,D){let W=D[0],z=D[1],J=D[2]-W,he=D[3]-z;J===0||he===0||(k(N.context,B,J,he,N.subtype,N.backdrop,N.transferMap,W,z,N.offsetX,N.offsetY),Q.save(),Q.globalAlpha=1,Q.globalCompositeOperation="source-over",Q.setTransform(1,0,0,1,0,0),Q.drawImage(B.canvas,0,0),Q.restore())}function q(Q,N){let B=o.Util.singularValueDecompose2dScale(Q);B[0]=Math.fround(B[0]),B[1]=Math.fround(B[1]);let D=Math.fround((globalThis.devicePixelRatio||1)*i.PixelsPerInch.PDF_TO_CSS_UNITS);return N!==void 0?N:B[0]<=D||B[1]<=D}let G=["butt","round","square"],ie=["miter","round","bevel"],ee={},Z={},ve=class{constructor(N,B,D,W,z,J,he,fe){ke(this,ce);this.ctx=N,this.current=new C(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=B,this.objs=D,this.canvasFactory=W,this.imageLayer=z,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=J,this.cachedCanvases=new p(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=he,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.backgroundColor=fe?.background||null,this.foregroundColor=fe?.foreground||null,this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(N,B=null){return typeof N=="string"?N.startsWith("g_")?this.commonObjs.get(N):this.objs.get(N):B}beginDrawing({transform:N,viewport:B,transparency:D=!1,background:W=null}){let z=this.ctx.canvas.width,J=this.ctx.canvas.height,he=W||"#ffffff";if(this.ctx.save(),this.foregroundColor&&this.backgroundColor){this.ctx.fillStyle=this.foregroundColor;let fe=this.foregroundColor=this.ctx.fillStyle;this.ctx.fillStyle=this.backgroundColor;let I=this.backgroundColor=this.ctx.fillStyle,$=!0,K=he;if(this.ctx.fillStyle=he,K=this.ctx.fillStyle,$=typeof K=="string"&&/^#[0-9A-Fa-f]{6}$/.test(K),fe==="#000000"&&I==="#ffffff"||fe===I||!$)this.foregroundColor=this.backgroundColor=null;else{let[ne,re,de]=(0,i.getRGB)(K),Ee=ae=>(ae/=255,ae<=.03928?ae/12.92:((ae+.055)/1.055)**2.4),je=Math.round(.2126*Ee(ne)+.7152*Ee(re)+.0722*Ee(de));this.selectColor=(ae,oe,le)=>{let ye=.2126*Ee(ae)+.7152*Ee(oe)+.0722*Ee(le);return Math.round(ye)===je?I:fe}}}if(this.ctx.fillStyle=this.backgroundColor||he,this.ctx.fillRect(0,0,z,J),this.ctx.restore(),D){let fe=this.cachedCanvases.getCanvas("transparent",z,J);this.compositeCtx=this.ctx,this.transparentCanvas=fe.canvas,this.ctx=fe.context,this.ctx.save(),this.ctx.transform(...(0,i.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),R(this.ctx,this.foregroundColor),N&&(this.ctx.transform(...N),this.outputScaleX=N[0],this.outputScaleY=N[0]),this.ctx.transform(...B.transform),this.viewportScale=B.scale,this.baseTransform=(0,i.getCurrentTransform)(this.ctx),this.imageLayer&&((0,i.deprecated)("The `imageLayer` functionality will be removed in the future."),this.imageLayer.beginLayout())}executeOperatorList(N,B,D,W){let z=N.argsArray,J=N.fnArray,he=B||0,fe=z.length;if(fe===he)return he;let I=fe-he>w&&typeof D=="function",$=I?Date.now()+y:0,K=0,ne=this.commonObjs,re=this.objs,de;for(;;){if(W!==void 0&&he===W.nextBreakPoint)return W.breakIt(he,D),he;if(de=J[he],de!==o.OPS.dependency)this[de].apply(this,z[he]);else for(let Ee of z[he]){let je=Ee.startsWith("g_")?ne:re;if(!je.has(Ee))return je.get(Ee,D),he}if(he++,he===fe)return he;if(I&&++K>w){if(Date.now()>$)return D(),he;K=0}}}endDrawing(){De(this,ce,Sx).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let N of this._cachedBitmapsMap.values()){for(let B of N.values())typeof HTMLCanvasElement!="undefined"&&B instanceof HTMLCanvasElement&&(B.width=B.height=0);N.clear()}this._cachedBitmapsMap.clear(),this.imageLayer&&this.imageLayer.endLayout()}_scaleImage(N,B){let D=N.width,W=N.height,z=Math.max(Math.hypot(B[0],B[1]),1),J=Math.max(Math.hypot(B[2],B[3]),1),he=D,fe=W,I="prescale1",$,K;for(;z>2&&he>1||J>2&&fe>1;){let ne=he,re=fe;z>2&&he>1&&(ne=Math.ceil(he/2),z/=he/ne),J>2&&fe>1&&(re=Math.ceil(fe/2),J/=fe/re),$=this.cachedCanvases.getCanvas(I,ne,re),K=$.context,K.clearRect(0,0,ne,re),K.drawImage(N,0,0,he,fe,0,0,ne,re),N=$.canvas,he=ne,fe=re,I=I==="prescale1"?"prescale2":"prescale1"}return{img:N,paintWidth:he,paintHeight:fe}}_createMaskCanvas(N){let B=this.ctx,{width:D,height:W}=N,z=this.current.fillColor,J=this.current.patternFill,he=(0,i.getCurrentTransform)(B),fe,I,$,K;if((N.bitmap||N.data)&&N.count>1){let se=N.bitmap||N.data.buffer,Se=he.slice(0,4);I=JSON.stringify(J?Se:[Se,z]),fe=this._cachedBitmapsMap.get(se),fe||(fe=new Map,this._cachedBitmapsMap.set(se,fe));let Re=fe.get(I);if(Re&&!J){let Le=Math.round(Math.min(he[0],he[2])+he[4]),Ze=Math.round(Math.min(he[1],he[3])+he[5]);return{canvas:Re,offsetX:Le,offsetY:Ze}}$=Re}$||(K=this.cachedCanvases.getCanvas("maskCanvas",D,W),E(K.context,N));let ne=o.Util.transform(he,[1/D,0,0,-1/W,0,0]);ne=o.Util.transform(ne,[1,0,0,1,0,-W]);let re=o.Util.applyTransform([0,0],ne),de=o.Util.applyTransform([D,W],ne),Ee=o.Util.normalizeRect([re[0],re[1],de[0],de[1]]),je=Math.round(Ee[2]-Ee[0])||1,ae=Math.round(Ee[3]-Ee[1])||1,oe=this.cachedCanvases.getCanvas("fillCanvas",je,ae),le=oe.context,ye=Math.min(re[0],de[0]),Oe=Math.min(re[1],de[1]);le.translate(-ye,-Oe),le.transform(...ne),$||($=this._scaleImage(K.canvas,(0,i.getCurrentTransformInverse)(le)),$=$.img,fe&&J&&fe.set(I,$)),le.imageSmoothingEnabled=q((0,i.getCurrentTransform)(le),N.interpolate),b(le,$,0,0,$.width,$.height,0,0,D,W),le.globalCompositeOperation="source-in";let j=o.Util.transform((0,i.getCurrentTransformInverse)(le),[1,0,0,1,-ye,-Oe]);return le.fillStyle=J?z.getPattern(B,this,j,s.PathType.FILL):z,le.fillRect(0,0,D,W),fe&&!J&&(this.cachedCanvases.delete("fillCanvas"),fe.set(I,oe.canvas)),{canvas:oe.canvas,offsetX:Math.round(ye),offsetY:Math.round(Oe)}}setLineWidth(N){N!==this.current.lineWidth&&(this._cachedScaleForStroking=null),this.current.lineWidth=N,this.ctx.lineWidth=N}setLineCap(N){this.ctx.lineCap=G[N]}setLineJoin(N){this.ctx.lineJoin=ie[N]}setMiterLimit(N){this.ctx.miterLimit=N}setDash(N,B){let D=this.ctx;D.setLineDash!==void 0&&(D.setLineDash(N),D.lineDashOffset=B)}setRenderingIntent(N){}setFlatness(N){}setGState(N){for(let B=0,D=N.length;B<D;B++){let W=N[B],z=W[0],J=W[1];switch(z){case"LW":this.setLineWidth(J);break;case"LC":this.setLineCap(J);break;case"LJ":this.setLineJoin(J);break;case"ML":this.setMiterLimit(J);break;case"D":this.setDash(J[0],J[1]);break;case"RI":this.setRenderingIntent(J);break;case"FL":this.setFlatness(J);break;case"Font":this.setFont(J[0],J[1]);break;case"CA":this.current.strokeAlpha=W[1];break;case"ca":this.current.fillAlpha=W[1],this.ctx.globalAlpha=W[1];break;case"BM":this.ctx.globalCompositeOperation=J;break;case"SMask":this.current.activeSMask=J?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.current.transferMaps=J}}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let N=this.inSMaskMode;this.current.activeSMask&&!N?this.beginSMaskMode():!this.current.activeSMask&&N&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let N=this.ctx.canvas.width,B=this.ctx.canvas.height,D="smaskGroupAt"+this.groupLevel,W=this.cachedCanvases.getCanvas(D,N,B);this.suspendedCtx=this.ctx,this.ctx=W.context;let z=this.ctx;z.setTransform(...(0,i.getCurrentTransform)(this.suspendedCtx)),T(this.suspendedCtx,z),f(z,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(),T(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(N){if(!this.current.activeSMask)return;N?(N[0]=Math.floor(N[0]),N[1]=Math.floor(N[1]),N[2]=Math.ceil(N[2]),N[3]=Math.ceil(N[3])):N=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let B=this.current.activeSMask,D=this.suspendedCtx;F(D,B,this.ctx,N),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?(T(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let N=this.current;this.stateStack.push(N),this.current=N.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),T(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null)}transform(N,B,D,W,z,J){this.ctx.transform(N,B,D,W,z,J),this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null}constructPath(N,B,D){let W=this.ctx,z=this.current,J=z.x,he=z.y,fe,I,$=(0,i.getCurrentTransform)(W),K=$[0]===0&&$[3]===0||$[1]===0&&$[2]===0,ne=K?D.slice(0):null;for(let re=0,de=0,Ee=N.length;re<Ee;re++)switch(N[re]|0){case o.OPS.rectangle:J=B[de++],he=B[de++];let je=B[de++],ae=B[de++],oe=J+je,le=he+ae;W.moveTo(J,he),je===0||ae===0?W.lineTo(oe,le):(W.lineTo(oe,he),W.lineTo(oe,le),W.lineTo(J,le)),K||z.updateRectMinMax($,[J,he,oe,le]),W.closePath();break;case o.OPS.moveTo:J=B[de++],he=B[de++],W.moveTo(J,he),K||z.updatePathMinMax($,J,he);break;case o.OPS.lineTo:J=B[de++],he=B[de++],W.lineTo(J,he),K||z.updatePathMinMax($,J,he);break;case o.OPS.curveTo:fe=J,I=he,J=B[de+4],he=B[de+5],W.bezierCurveTo(B[de],B[de+1],B[de+2],B[de+3],J,he),z.updateCurvePathMinMax($,fe,I,B[de],B[de+1],B[de+2],B[de+3],J,he,ne),de+=6;break;case o.OPS.curveTo2:fe=J,I=he,W.bezierCurveTo(J,he,B[de],B[de+1],B[de+2],B[de+3]),z.updateCurvePathMinMax($,fe,I,J,he,B[de],B[de+1],B[de+2],B[de+3],ne),J=B[de+2],he=B[de+3],de+=4;break;case o.OPS.curveTo3:fe=J,I=he,J=B[de+2],he=B[de+3],W.bezierCurveTo(B[de],B[de+1],J,he,J,he),z.updateCurvePathMinMax($,fe,I,B[de],B[de+1],J,he,J,he,ne),de+=4;break;case o.OPS.closePath:W.closePath();break}K&&z.updateScalingPathMinMax($,ne),z.setCurrentPoint(J,he)}closePath(){this.ctx.closePath()}stroke(N){N=typeof N!="undefined"?N:!0;let B=this.ctx,D=this.current.strokeColor;B.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof D=="object"&&D?.getPattern?(B.save(),B.strokeStyle=D.getPattern(B,this,(0,i.getCurrentTransformInverse)(B),s.PathType.STROKE),this.rescaleAndStroke(!1),B.restore()):this.rescaleAndStroke(!0)),N&&this.consumePath(this.current.getClippedPathBoundingBox()),B.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(N){N=typeof N!="undefined"?N:!0;let B=this.ctx,D=this.current.fillColor,W=this.current.patternFill,z=!1;W&&(B.save(),B.fillStyle=D.getPattern(B,this,(0,i.getCurrentTransformInverse)(B),s.PathType.FILL),z=!0);let J=this.current.getClippedPathBoundingBox();this.contentVisible&&J!==null&&(this.pendingEOFill?(B.fill("evenodd"),this.pendingEOFill=!1):B.fill()),z&&B.restore(),N&&this.consumePath(J)}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=ee}eoClip(){this.pendingClip=Z}beginText(){this.current.textMatrix=o.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let N=this.pendingTextPaths,B=this.ctx;if(N===void 0){B.beginPath();return}B.save(),B.beginPath();for(let D of N)B.setTransform(...D.transform),B.translate(D.x,D.y),D.addToPath(B,D.fontSize);B.restore(),B.clip(),B.beginPath(),delete this.pendingTextPaths}setCharSpacing(N){this.current.charSpacing=N}setWordSpacing(N){this.current.wordSpacing=N}setHScale(N){this.current.textHScale=N/100}setLeading(N){this.current.leading=-N}setFont(N,B){let D=this.commonObjs.get(N),W=this.current;if(!D)throw new Error(`Can't find font for ${N}`);if(W.fontMatrix=D.fontMatrix||o.FONT_IDENTITY_MATRIX,(W.fontMatrix[0]===0||W.fontMatrix[3]===0)&&(0,o.warn)("Invalid font matrix for font "+N),B<0?(B=-B,W.fontDirection=-1):W.fontDirection=1,this.current.font=D,this.current.fontSize=B,D.isType3Font)return;let z=D.loadedName||"sans-serif",J="normal";D.black?J="900":D.bold&&(J="bold");let he=D.italic?"italic":"normal",fe=`"${z}", ${D.fallbackName}`,I=B;B<u?I=u:B>d&&(I=d),this.current.fontSizeScale=B/I,this.ctx.font=`${he} ${J} ${I}px ${fe}`}setTextRenderingMode(N){this.current.textRenderingMode=N}setTextRise(N){this.current.textRise=N}moveText(N,B){this.current.x=this.current.lineX+=N,this.current.y=this.current.lineY+=B}setLeadingMoveText(N,B){this.setLeading(-B),this.moveText(N,B)}setTextMatrix(N,B,D,W,z,J){this.current.textMatrix=[N,B,D,W,z,J],this.current.textMatrixScale=Math.hypot(N,B),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(N,B,D,W){let z=this.ctx,J=this.current,he=J.font,fe=J.textRenderingMode,I=J.fontSize/J.fontSizeScale,$=fe&o.TextRenderingMode.FILL_STROKE_MASK,K=!!(fe&o.TextRenderingMode.ADD_TO_PATH_FLAG),ne=J.patternFill&&!he.missingFile,re;(he.disableFontFace||K||ne)&&(re=he.getPathGenerator(this.commonObjs,N)),he.disableFontFace||ne?(z.save(),z.translate(B,D),z.beginPath(),re(z,I),W&&z.setTransform(...W),($===o.TextRenderingMode.FILL||$===o.TextRenderingMode.FILL_STROKE)&&z.fill(),($===o.TextRenderingMode.STROKE||$===o.TextRenderingMode.FILL_STROKE)&&z.stroke(),z.restore()):(($===o.TextRenderingMode.FILL||$===o.TextRenderingMode.FILL_STROKE)&&z.fillText(N,B,D),($===o.TextRenderingMode.STROKE||$===o.TextRenderingMode.FILL_STROKE)&&z.strokeText(N,B,D)),K&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,i.getCurrentTransform)(z),x:B,y:D,fontSize:I,addToPath:re})}get isFontSubpixelAAEnabled(){let{context:N}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);N.scale(1.5,1),N.fillText("I",0,10);let B=N.getImageData(0,0,10,10).data,D=!1;for(let W=3;W<B.length;W+=4)if(B[W]>0&&B[W]<255){D=!0;break}return(0,o.shadow)(this,"isFontSubpixelAAEnabled",D)}showText(N){let B=this.current,D=B.font;if(D.isType3Font)return this.showType3Text(N);let W=B.fontSize;if(W===0)return;let z=this.ctx,J=B.fontSizeScale,he=B.charSpacing,fe=B.wordSpacing,I=B.fontDirection,$=B.textHScale*I,K=N.length,ne=D.vertical,re=ne?1:-1,de=D.defaultVMetrics,Ee=W*B.fontMatrix[0],je=B.textRenderingMode===o.TextRenderingMode.FILL&&!D.disableFontFace&&!B.patternFill;z.save(),z.transform(...B.textMatrix),z.translate(B.x,B.y+B.textRise),I>0?z.scale($,-1):z.scale($,1);let ae;if(B.patternFill){z.save();let j=B.fillColor.getPattern(z,this,(0,i.getCurrentTransformInverse)(z),s.PathType.FILL);ae=(0,i.getCurrentTransform)(z),z.restore(),z.fillStyle=j}let oe=B.lineWidth,le=B.textMatrixScale;if(le===0||oe===0){let j=B.textRenderingMode&o.TextRenderingMode.FILL_STROKE_MASK;(j===o.TextRenderingMode.STROKE||j===o.TextRenderingMode.FILL_STROKE)&&(oe=this.getSinglePixelWidth())}else oe/=le;J!==1&&(z.scale(J,J),oe/=J),z.lineWidth=oe;let ye=0,Oe;for(Oe=0;Oe<K;++Oe){let j=N[Oe];if(typeof j=="number"){ye+=re*j*W/1e3;continue}let se=!1,Se=(j.isSpace?fe:0)+he,Re=j.fontChar,Le=j.accent,Ze,Qe,Xe=j.width;if(ne){let Ke=j.vmetric||de,rt=-(j.vmetric?Ke[1]:Xe*.5)*Ee,Pe=Ke[2]*Ee;Xe=Ke?-Ke[0]:Xe,Ze=rt/J,Qe=(ye+Pe)/J}else Ze=ye/J,Qe=0;if(D.remeasure&&Xe>0){let Ke=z.measureText(Re).width*1e3/W*J;if(Xe<Ke&&this.isFontSubpixelAAEnabled){let rt=Xe/Ke;se=!0,z.save(),z.scale(rt,1),Ze/=rt}else Xe!==Ke&&(Ze+=(Xe-Ke)/2e3*W/J)}if(this.contentVisible&&(j.isInFont||D.missingFile)){if(je&&!Le)z.fillText(Re,Ze,Qe);else if(this.paintChar(Re,Ze,Qe,ae),Le){let Ke=Ze+W*Le.offset.x/J,rt=Qe-W*Le.offset.y/J;this.paintChar(Le.fontChar,Ke,rt,ae)}}let nt;ne?nt=Xe*Ee-Se*I:nt=Xe*Ee+Se*I,ye+=nt,se&&z.restore()}ne?B.y-=ye:B.x+=ye*$,z.restore(),this.compose()}showType3Text(N){let B=this.ctx,D=this.current,W=D.font,z=D.fontSize,J=D.fontDirection,he=W.vertical?1:-1,fe=D.charSpacing,I=D.wordSpacing,$=D.textHScale*J,K=D.fontMatrix||o.FONT_IDENTITY_MATRIX,ne=N.length,re=D.textRenderingMode===o.TextRenderingMode.INVISIBLE,de,Ee,je,ae;if(!(re||z===0)){for(this._cachedScaleForStroking=null,this._cachedGetSinglePixelWidth=null,B.save(),B.transform(...D.textMatrix),B.translate(D.x,D.y),B.scale($,J),de=0;de<ne;++de){if(Ee=N[de],typeof Ee=="number"){ae=he*Ee*z/1e3,this.ctx.translate(ae,0),D.x+=ae*$;continue}let oe=(Ee.isSpace?I:0)+fe,le=W.charProcOperatorList[Ee.operatorListId];if(!le){(0,o.warn)(`Type3 character "${Ee.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=Ee,this.save(),B.scale(z,z),B.transform(...K),this.executeOperatorList(le),this.restore()),je=o.Util.applyTransform([Ee.width,0],K)[0]*z+oe,B.translate(je,0),D.x+=je*$}B.restore(),this.processingType3=null}}setCharWidth(N,B){}setCharWidthAndBounds(N,B,D,W,z,J){this.ctx.rect(D,W,z-D,J-W),this.ctx.clip(),this.endPath()}getColorN_Pattern(N){let B;if(N[0]==="TilingPattern"){let D=N[1],W=this.baseTransform||(0,i.getCurrentTransform)(this.ctx),z={createCanvasGraphics:J=>new ve(J,this.commonObjs,this.objs,this.canvasFactory)};B=new s.TilingPattern(N,D,this.ctx,z,W)}else B=this._getPattern(N[1],N[2]);return B}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(N,B,D){let W=this.selectColor?.(N,B,D)||o.Util.makeHexColor(N,B,D);this.ctx.strokeStyle=W,this.current.strokeColor=W}setFillRGBColor(N,B,D){let W=this.selectColor?.(N,B,D)||o.Util.makeHexColor(N,B,D);this.ctx.fillStyle=W,this.current.fillColor=W,this.current.patternFill=!1}_getPattern(N,B=null){let D;return this.cachedPatterns.has(N)?D=this.cachedPatterns.get(N):(D=(0,s.getShadingPattern)(this.objs.get(N)),this.cachedPatterns.set(N,D)),B&&(D.matrix=B),D}shadingFill(N){if(!this.contentVisible)return;let B=this.ctx;this.save();let D=this._getPattern(N);B.fillStyle=D.getPattern(B,this,(0,i.getCurrentTransformInverse)(B),s.PathType.SHADING);let W=(0,i.getCurrentTransformInverse)(B);if(W){let z=B.canvas,J=z.width,he=z.height,fe=o.Util.applyTransform([0,0],W),I=o.Util.applyTransform([0,he],W),$=o.Util.applyTransform([J,0],W),K=o.Util.applyTransform([J,he],W),ne=Math.min(fe[0],I[0],$[0],K[0]),re=Math.min(fe[1],I[1],$[1],K[1]),de=Math.max(fe[0],I[0],$[0],K[0]),Ee=Math.max(fe[1],I[1],$[1],K[1]);this.ctx.fillRect(ne,re,de-ne,Ee-re)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,o.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,o.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(N,B){if(!!this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(N)&&N.length===6&&this.transform(...N),this.baseTransform=(0,i.getCurrentTransform)(this.ctx),B)){let D=B[2]-B[0],W=B[3]-B[1];this.ctx.rect(B[0],B[1],D,W),this.current.updateRectMinMax((0,i.getCurrentTransform)(this.ctx),B),this.clip(),this.endPath()}}paintFormXObjectEnd(){!this.contentVisible||(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(N){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let B=this.ctx;N.isolated||(0,o.info)("TODO: Support non-isolated groups."),N.knockout&&(0,o.warn)("Knockout groups not supported.");let D=(0,i.getCurrentTransform)(B);if(N.matrix&&B.transform(...N.matrix),!N.bbox)throw new Error("Bounding box is required.");let W=o.Util.getAxialAlignedBoundingBox(N.bbox,(0,i.getCurrentTransform)(B)),z=[0,0,B.canvas.width,B.canvas.height];W=o.Util.intersect(W,z)||[0,0,0,0];let J=Math.floor(W[0]),he=Math.floor(W[1]),fe=Math.max(Math.ceil(W[2])-J,1),I=Math.max(Math.ceil(W[3])-he,1),$=1,K=1;fe>m&&($=fe/m,fe=m),I>m&&(K=I/m,I=m),this.current.startNewPathAndClipBox([0,0,fe,I]);let ne="groupAt"+this.groupLevel;N.smask&&(ne+="_smask_"+this.smaskCounter++%2);let re=this.cachedCanvases.getCanvas(ne,fe,I),de=re.context;de.scale(1/$,1/K),de.translate(-J,-he),de.transform(...D),N.smask?this.smaskStack.push({canvas:re.canvas,context:de,offsetX:J,offsetY:he,scaleX:$,scaleY:K,subtype:N.smask.subtype,backdrop:N.smask.backdrop,transferMap:N.smask.transferMap||null,startTransformInverse:null}):(B.setTransform(1,0,0,1,0,0),B.translate(J,he),B.scale($,K),B.save()),T(B,de),this.ctx=de,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(B),this.groupLevel++}endGroup(N){if(!this.contentVisible)return;this.groupLevel--;let B=this.ctx,D=this.groupStack.pop();if(this.ctx=D,this.ctx.imageSmoothingEnabled=!1,N.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let W=(0,i.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...W);let z=o.Util.getAxialAlignedBoundingBox([0,0,B.canvas.width,B.canvas.height],W);this.ctx.drawImage(B.canvas,0,0),this.ctx.restore(),this.compose(z)}}beginAnnotation(N,B,D,W,z){if(De(this,ce,Sx).call(this),R(this.ctx,this.foregroundColor),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(B)&&B.length===4){let J=B[2]-B[0],he=B[3]-B[1];if(z&&this.annotationCanvasMap){D=D.slice(),D[4]-=B[0],D[5]-=B[1],B=B.slice(),B[0]=B[1]=0,B[2]=J,B[3]=he;let[fe,I]=o.Util.singularValueDecompose2dScale((0,i.getCurrentTransform)(this.ctx)),{viewportScale:$}=this,K=Math.ceil(J*this.outputScaleX*$),ne=Math.ceil(he*this.outputScaleY*$);this.annotationCanvas=this.canvasFactory.create(K,ne);let{canvas:re,context:de}=this.annotationCanvas;this.annotationCanvasMap.set(N,re),this.annotationCanvas.savedCtx=this.ctx,this.ctx=de,this.ctx.setTransform(fe,0,0,-I,0,he*I),R(this.ctx,this.foregroundColor)}else R(this.ctx,this.foregroundColor),this.ctx.rect(B[0],B[1],J,he),this.ctx.clip(),this.endPath()}this.current=new C(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...D),this.transform(...W)}endAnnotation(){this.annotationCanvas&&(this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(N){if(!this.contentVisible)return;let B=N.count;N=this.getObject(N.data,N),N.count=B;let D=this.ctx,W=this.processingType3;if(W&&(W.compiled===void 0&&(W.compiled=S(N)),W.compiled)){W.compiled(D);return}let z=this._createMaskCanvas(N),J=z.canvas;D.save(),D.setTransform(1,0,0,1,0,0),D.drawImage(J,z.offsetX,z.offsetY),D.restore(),this.compose()}paintImageMaskXObjectRepeat(N,B,D=0,W=0,z,J){if(!this.contentVisible)return;N=this.getObject(N.data,N);let he=this.ctx;he.save();let fe=(0,i.getCurrentTransform)(he);he.transform(B,D,W,z,0,0);let I=this._createMaskCanvas(N);he.setTransform(1,0,0,1,0,0);for(let $=0,K=J.length;$<K;$+=2){let ne=o.Util.transform(fe,[B,D,W,z,J[$],J[$+1]]),[re,de]=o.Util.applyTransform([0,0],ne);he.drawImage(I.canvas,re,de)}he.restore(),this.compose()}paintImageMaskXObjectGroup(N){if(!this.contentVisible)return;let B=this.ctx,D=this.current.fillColor,W=this.current.patternFill;for(let z of N){let{data:J,width:he,height:fe,transform:I}=z,$=this.cachedCanvases.getCanvas("maskCanvas",he,fe),K=$.context;K.save();let ne=this.getObject(J,z);E(K,ne),K.globalCompositeOperation="source-in",K.fillStyle=W?D.getPattern(K,this,(0,i.getCurrentTransformInverse)(B),s.PathType.FILL):D,K.fillRect(0,0,he,fe),K.restore(),B.save(),B.transform(...I),B.scale(1,-1),b(B,$.canvas,0,0,he,fe,0,-1,1,1),B.restore()}this.compose()}paintImageXObject(N){if(!this.contentVisible)return;let B=this.getObject(N);if(!B){(0,o.warn)("Dependent image isn't ready yet");return}this.paintInlineImageXObject(B)}paintImageXObjectRepeat(N,B,D,W){if(!this.contentVisible)return;let z=this.getObject(N);if(!z){(0,o.warn)("Dependent image isn't ready yet");return}let J=z.width,he=z.height,fe=[];for(let I=0,$=W.length;I<$;I+=2)fe.push({transform:[B,0,0,D,W[I],W[I+1]],x:0,y:0,w:J,h:he});this.paintInlineImageXObjectGroup(z,fe)}paintInlineImageXObject(N){if(!this.contentVisible)return;let B=N.width,D=N.height,W=this.ctx;this.save(),W.scale(1/B,-1/D);let z;if(typeof HTMLElement=="function"&&N instanceof HTMLElement||!N.data)z=N;else{let I=this.cachedCanvases.getCanvas("inlineImage",B,D),$=I.context;x($,N,this.current.transferMaps),z=I.canvas}let J=this._scaleImage(z,(0,i.getCurrentTransformInverse)(W));W.imageSmoothingEnabled=q((0,i.getCurrentTransform)(W),N.interpolate);let[he,fe]=b(W,J.img,0,0,J.paintWidth,J.paintHeight,0,-D,B,D);if(this.imageLayer){let[I,$]=o.Util.applyTransform([0,-D],(0,i.getCurrentTransform)(this.ctx));this.imageLayer.appendImage({imgData:N,left:I,top:$,width:he,height:fe})}this.compose(),this.restore()}paintInlineImageXObjectGroup(N,B){if(!this.contentVisible)return;let D=this.ctx,W=N.width,z=N.height,J=this.cachedCanvases.getCanvas("inlineImage",W,z),he=J.context;x(he,N,this.current.transferMaps);for(let fe of B){if(D.save(),D.transform(...fe.transform),D.scale(1,-1),b(D,J.canvas,fe.x,fe.y,fe.w,fe.h,0,-1,1,1),this.imageLayer){let[I,$]=o.Util.applyTransform([fe.x,fe.y],(0,i.getCurrentTransform)(this.ctx));this.imageLayer.appendImage({imgData:N,left:I,top:$,width:W,height:z})}D.restore()}this.compose()}paintSolidColorImageMask(){!this.contentVisible||(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(N){}markPointProps(N,B){}beginMarkedContent(N){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(N,B){N==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(B)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(N){let B=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(N);let D=this.ctx;this.pendingClip&&(B||(this.pendingClip===Z?D.clip("evenodd"):D.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),D.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let N=(0,i.getCurrentTransform)(this.ctx);if(N[1]===0&&N[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(N[0]),Math.abs(N[3]));else{let B=Math.abs(N[0]*N[3]-N[2]*N[1]),D=Math.hypot(N[0],N[2]),W=Math.hypot(N[1],N[3]);this._cachedGetSinglePixelWidth=Math.max(D,W)/B}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(!this._cachedScaleForStroking){let{lineWidth:N}=this.current,B=(0,i.getCurrentTransform)(this.ctx),D,W;if(B[1]===0&&B[2]===0){let z=Math.abs(B[0]),J=Math.abs(B[3]);if(N===0)D=1/z,W=1/J;else{let he=z*N,fe=J*N;D=he<1?1/he:1,W=fe<1?1/fe:1}}else{let z=Math.abs(B[0]*B[3]-B[2]*B[1]),J=Math.hypot(B[0],B[1]),he=Math.hypot(B[2],B[3]);if(N===0)D=he/z,W=J/z;else{let fe=N*z;D=he>fe?he/fe:1,W=J>fe?J/fe:1}}this._cachedScaleForStroking=[D,W]}return this._cachedScaleForStroking}rescaleAndStroke(N){let{ctx:B}=this,{lineWidth:D}=this.current,[W,z]=this.getScaleForStroking();if(B.lineWidth=D||1,W===1&&z===1){B.stroke();return}let J,he,fe;N&&(J=(0,i.getCurrentTransform)(B),he=B.getLineDash().slice(),fe=B.lineDashOffset),B.scale(W,z);let I=Math.max(W,z);B.setLineDash(B.getLineDash().map($=>$/I)),B.lineDashOffset/=I,B.stroke(),N&&(B.setTransform(...J),B.setLineDash(he),B.lineDashOffset=fe)}isContentVisible(){for(let N=this.markedContentStack.length-1;N>=0;N--)if(!this.markedContentStack[N].visible)return!1;return!0}},X=ve;ce=new WeakSet,Sx=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)},t.CanvasGraphics=X;for(let Q in o.OPS)X.prototype[Q]!==void 0&&(X.prototype[o.OPS[Q]]=X.prototype[Q])},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TilingPattern=t.PathType=void 0,t.getShadingPattern=g;var i=n(1),o=n(8),s=n(3);let l={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};t.PathType=l;function h(b,S){if(!S||s.isNodeJS)return;let C=S[2]-S[0],x=S[3]-S[1],E=new Path2D;E.rect(S[0],S[1],C,x),b.clip(E)}class u{constructor(){this.constructor===u&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class d extends u{constructor(S){super();this._type=S[1],this._bbox=S[2],this._colorStops=S[3],this._p0=S[4],this._p1=S[5],this._r0=S[6],this._r1=S[7],this.matrix=null}_createGradient(S){let C;this._type==="axial"?C=S.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(C=S.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let x of this._colorStops)C.addColorStop(x[0],x[1]);return C}getPattern(S,C,x,E){let T;if(E===l.STROKE||E===l.FILL){let R=C.current.getClippedPathBoundingBox(E,(0,o.getCurrentTransform)(S))||[0,0,0,0],O=Math.ceil(R[2]-R[0])||1,L=Math.ceil(R[3]-R[1])||1,M=C.cachedCanvases.getCanvas("pattern",O,L,!0),k=M.context;k.clearRect(0,0,k.canvas.width,k.canvas.height),k.beginPath(),k.rect(0,0,k.canvas.width,k.canvas.height),k.translate(-R[0],-R[1]),x=i.Util.transform(x,[1,0,0,1,R[0],R[1]]),k.transform(...C.baseTransform),this.matrix&&k.transform(...this.matrix),h(k,this._bbox),k.fillStyle=this._createGradient(k),k.fill(),T=S.createPattern(M.canvas,"no-repeat");let F=new DOMMatrix(x);try{T.setTransform(F)}catch(q){(0,i.warn)(`RadialAxialShadingPattern.getPattern: "${q?.message}".`)}}else h(S,this._bbox),T=this._createGradient(S);return T}}function m(b,S,C,x,E,T,R,O){let L=S.coords,M=S.colors,k=b.data,F=b.width*4,q;L[C+1]>L[x+1]&&(q=C,C=x,x=q,q=T,T=R,R=q),L[x+1]>L[E+1]&&(q=x,x=E,E=q,q=R,R=O,O=q),L[C+1]>L[x+1]&&(q=C,C=x,x=q,q=T,T=R,R=q);let G=(L[C]+S.offsetX)*S.scaleX,ie=(L[C+1]+S.offsetY)*S.scaleY,ee=(L[x]+S.offsetX)*S.scaleX,Z=(L[x+1]+S.offsetY)*S.scaleY,X=(L[E]+S.offsetX)*S.scaleX,ce=(L[E+1]+S.offsetY)*S.scaleY;if(ie>=ce)return;let we=M[T],ve=M[T+1],Q=M[T+2],N=M[R],B=M[R+1],D=M[R+2],W=M[O],z=M[O+1],J=M[O+2],he=Math.round(ie),fe=Math.round(ce),I,$,K,ne,re,de,Ee,je;for(let ae=he;ae<=fe;ae++){if(ae<Z){let j;ae<ie?j=0:j=(ie-ae)/(ie-Z),I=G-(G-ee)*j,$=we-(we-N)*j,K=ve-(ve-B)*j,ne=Q-(Q-D)*j}else{let j;ae>ce?j=1:Z===ce?j=0:j=(Z-ae)/(Z-ce),I=ee-(ee-X)*j,$=N-(N-W)*j,K=B-(B-z)*j,ne=D-(D-J)*j}let oe;ae<ie?oe=0:ae>ce?oe=1:oe=(ie-ae)/(ie-ce),re=G-(G-X)*oe,de=we-(we-W)*oe,Ee=ve-(ve-z)*oe,je=Q-(Q-J)*oe;let le=Math.round(Math.min(I,re)),ye=Math.round(Math.max(I,re)),Oe=F*ae+le*4;for(let j=le;j<=ye;j++)oe=(I-j)/(I-re),oe<0?oe=0:oe>1&&(oe=1),k[Oe++]=$-($-de)*oe|0,k[Oe++]=K-(K-Ee)*oe|0,k[Oe++]=ne-(ne-je)*oe|0,k[Oe++]=255}}function y(b,S,C){let x=S.coords,E=S.colors,T,R;switch(S.type){case"lattice":let O=S.verticesPerRow,L=Math.floor(x.length/O)-1,M=O-1;for(T=0;T<L;T++){let k=T*O;for(let F=0;F<M;F++,k++)m(b,C,x[k],x[k+1],x[k+O],E[k],E[k+1],E[k+O]),m(b,C,x[k+O+1],x[k+1],x[k+O],E[k+O+1],E[k+1],E[k+O])}break;case"triangles":for(T=0,R=x.length;T<R;T+=3)m(b,C,x[T],x[T+1],x[T+2],E[T],E[T+1],E[T+2]);break;default:throw new Error("illegal figure")}}class w extends u{constructor(S){super();this._coords=S[2],this._colors=S[3],this._figures=S[4],this._bounds=S[5],this._bbox=S[7],this._background=S[8],this.matrix=null}_createMeshCanvas(S,C,x){let E=1.1,T=3e3,R=2,O=Math.floor(this._bounds[0]),L=Math.floor(this._bounds[1]),M=Math.ceil(this._bounds[2])-O,k=Math.ceil(this._bounds[3])-L,F=Math.min(Math.ceil(Math.abs(M*S[0]*E)),T),q=Math.min(Math.ceil(Math.abs(k*S[1]*E)),T),G=M/F,ie=k/q,ee={coords:this._coords,colors:this._colors,offsetX:-O,offsetY:-L,scaleX:1/G,scaleY:1/ie},Z=F+R*2,X=q+R*2,ce=x.getCanvas("mesh",Z,X,!1),we=ce.context,ve=we.createImageData(F,q);if(C){let N=ve.data;for(let B=0,D=N.length;B<D;B+=4)N[B]=C[0],N[B+1]=C[1],N[B+2]=C[2],N[B+3]=255}for(let N of this._figures)y(ve,N,ee);return we.putImageData(ve,R,R),{canvas:ce.canvas,offsetX:O-R*G,offsetY:L-R*ie,scaleX:G,scaleY:ie}}getPattern(S,C,x,E){h(S,this._bbox);let T;if(E===l.SHADING)T=i.Util.singularValueDecompose2dScale((0,o.getCurrentTransform)(S));else if(T=i.Util.singularValueDecompose2dScale(C.baseTransform),this.matrix){let O=i.Util.singularValueDecompose2dScale(this.matrix);T=[T[0]*O[0],T[1]*O[1]]}let R=this._createMeshCanvas(T,E===l.SHADING?null:this._background,C.cachedCanvases);return E!==l.SHADING&&(S.setTransform(...C.baseTransform),this.matrix&&S.transform(...this.matrix)),S.translate(R.offsetX,R.offsetY),S.scale(R.scaleX,R.scaleY),S.createPattern(R.canvas,"no-repeat")}}class v extends u{getPattern(){return"hotpink"}}function g(b){switch(b[0]){case"RadialAxial":return new d(b);case"Mesh":return new w(b);case"Dummy":return new v}throw new Error(`Unknown IR type: ${b[0]}`)}let f={COLORED:1,UNCOLORED:2};class p{static get MAX_PATTERN_SIZE(){return(0,i.shadow)(this,"MAX_PATTERN_SIZE",3e3)}constructor(S,C,x,E,T){this.operatorList=S[2],this.matrix=S[3]||[1,0,0,1,0,0],this.bbox=S[4],this.xstep=S[5],this.ystep=S[6],this.paintType=S[7],this.tilingType=S[8],this.color=C,this.ctx=x,this.canvasGraphicsFactory=E,this.baseTransform=T}createPatternCanvas(S){let C=this.operatorList,x=this.bbox,E=this.xstep,T=this.ystep,R=this.paintType,O=this.tilingType,L=this.color,M=this.canvasGraphicsFactory;(0,i.info)("TilingType: "+O);let k=x[0],F=x[1],q=x[2],G=x[3],ie=i.Util.singularValueDecompose2dScale(this.matrix),ee=i.Util.singularValueDecompose2dScale(this.baseTransform),Z=[ie[0]*ee[0],ie[1]*ee[1]],X=this.getSizeAndScale(E,this.ctx.canvas.width,Z[0]),ce=this.getSizeAndScale(T,this.ctx.canvas.height,Z[1]),we=S.cachedCanvases.getCanvas("pattern",X.size,ce.size,!0),ve=we.context,Q=M.createCanvasGraphics(ve);Q.groupLevel=S.groupLevel,this.setFillAndStrokeStyleToContext(Q,R,L);let N=k,B=F,D=q,W=G;return k<0&&(N=0,D+=Math.abs(k)),F<0&&(B=0,W+=Math.abs(F)),ve.translate(-(X.scale*N),-(ce.scale*B)),Q.transform(X.scale,0,0,ce.scale,0,0),ve.save(),this.clipBbox(Q,N,B,D,W),Q.baseTransform=(0,o.getCurrentTransform)(Q.ctx),Q.executeOperatorList(C),Q.endDrawing(),{canvas:we.canvas,scaleX:X.scale,scaleY:ce.scale,offsetX:N,offsetY:B}}getSizeAndScale(S,C,x){S=Math.abs(S);let E=Math.max(p.MAX_PATTERN_SIZE,C),T=Math.ceil(S*x);return T>=E?T=E:x=T/S,{scale:x,size:T}}clipBbox(S,C,x,E,T){let R=E-C,O=T-x;S.ctx.rect(C,x,R,O),S.current.updateRectMinMax((0,o.getCurrentTransform)(S.ctx),[C,x,E,T]),S.clip(),S.endPath()}setFillAndStrokeStyleToContext(S,C,x){let E=S.ctx,T=S.current;switch(C){case f.COLORED:let R=this.ctx;E.fillStyle=R.fillStyle,E.strokeStyle=R.strokeStyle,T.fillColor=R.fillStyle,T.strokeColor=R.strokeStyle;break;case f.UNCOLORED:let O=i.Util.makeHexColor(x[0],x[1],x[2]);E.fillStyle=O,E.strokeStyle=O,T.fillColor=O,T.strokeColor=O;break;default:throw new i.FormatError(`Unsupported paint type: ${C}`)}}getPattern(S,C,x,E){let T=x;E!==l.SHADING&&(T=i.Util.transform(T,C.baseTransform),this.matrix&&(T=i.Util.transform(T,this.matrix)));let R=this.createPatternCanvas(C),O=new DOMMatrix(T);O=O.translate(R.offsetX,R.offsetY),O=O.scale(1/R.scaleX,1/R.scaleY);let L=S.createPattern(R.canvas,"repeat");try{L.setTransform(O)}catch(M){(0,i.warn)(`TilingPattern.getPattern: "${M?.message}".`)}return L}}t.TilingPattern=p},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.applyMaskImageData=o;var i=n(1);function o({src:s,srcPos:l=0,dest:h,destPos:u=0,width:d,height:m,inverseDecode:y=!1}){let w=i.FeatureTest.isLittleEndian?4278190080:255,[v,g]=y?[0,w]:[w,0],f=d>>3,p=d&7,b=s.length;h=new Uint32Array(h.buffer);for(let S=0;S<m;S++){for(let x=l+f;l<x;l++){let E=l<b?s[l]:255;h[u++]=E&128?g:v,h[u++]=E&64?g:v,h[u++]=E&32?g:v,h[u++]=E&16?g:v,h[u++]=E&8?g:v,h[u++]=E&4?g:v,h[u++]=E&2?g:v,h[u++]=E&1?g:v}if(p===0)continue;let C=l<b?s[l++]:255;for(let x=0;x<p;x++)h[u++]=C&1<<7-x?g:v}return{srcPos:l,destPos:u}}},(r,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalWorkerOptions=void 0;let n=Object.create(null);t.GlobalWorkerOptions=n,n.workerPort=n.workerPort===void 0?null:n.workerPort,n.workerSrc=n.workerSrc===void 0?"":n.workerSrc},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MessageHandler=void 0;var i=n(1);let o={UNKNOWN:0,DATA:1,ERROR:2},s={UNKNOWN:0,CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function l(u){switch(u instanceof Error||typeof u=="object"&&u!==null||(0,i.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new i.AbortException(u.message);case"MissingPDFException":return new i.MissingPDFException(u.message);case"PasswordException":return new i.PasswordException(u.message,u.code);case"UnexpectedResponseException":return new i.UnexpectedResponseException(u.message,u.status);case"UnknownErrorException":return new i.UnknownErrorException(u.message,u.details);default:return new i.UnknownErrorException(u.message,u.toString())}}class h{constructor(d,m,y){this.sourceName=d,this.targetName=m,this.comObj=y,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=w=>{let v=w.data;if(v.targetName!==this.sourceName)return;if(v.stream){this._processStreamMessage(v);return}if(v.callback){let f=v.callbackId,p=this.callbackCapabilities[f];if(!p)throw new Error(`Cannot resolve callback ${f}`);if(delete this.callbackCapabilities[f],v.callback===o.DATA)p.resolve(v.data);else if(v.callback===o.ERROR)p.reject(l(v.reason));else throw new Error("Unexpected callback case");return}let g=this.actionHandler[v.action];if(!g)throw new Error(`Unknown action from worker: ${v.action}`);if(v.callbackId){let f=this.sourceName,p=v.sourceName;new Promise(function(b){b(g(v.data))}).then(function(b){y.postMessage({sourceName:f,targetName:p,callback:o.DATA,callbackId:v.callbackId,data:b})},function(b){y.postMessage({sourceName:f,targetName:p,callback:o.ERROR,callbackId:v.callbackId,reason:l(b)})});return}if(v.streamId){this._createStreamSink(v);return}g(v.data)},y.addEventListener("message",this._onComObjOnMessage)}on(d,m){let y=this.actionHandler;if(y[d])throw new Error(`There is already an actionName called "${d}"`);y[d]=m}send(d,m,y){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:d,data:m},y)}sendWithPromise(d,m,y){let w=this.callbackId++,v=(0,i.createPromiseCapability)();this.callbackCapabilities[w]=v;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:d,callbackId:w,data:m},y)}catch(g){v.reject(g)}return v.promise}sendWithStream(d,m,y,w){let v=this.streamId++,g=this.sourceName,f=this.targetName,p=this.comObj;return new ReadableStream({start:b=>{let S=(0,i.createPromiseCapability)();return this.streamControllers[v]={controller:b,startCall:S,pullCall:null,cancelCall:null,isClosed:!1},p.postMessage({sourceName:g,targetName:f,action:d,streamId:v,data:m,desiredSize:b.desiredSize},w),S.promise},pull:b=>{let S=(0,i.createPromiseCapability)();return this.streamControllers[v].pullCall=S,p.postMessage({sourceName:g,targetName:f,stream:s.PULL,streamId:v,desiredSize:b.desiredSize}),S.promise},cancel:b=>{(0,i.assert)(b instanceof Error,"cancel must have a valid reason");let S=(0,i.createPromiseCapability)();return this.streamControllers[v].cancelCall=S,this.streamControllers[v].isClosed=!0,p.postMessage({sourceName:g,targetName:f,stream:s.CANCEL,streamId:v,reason:l(b)}),S.promise}},y)}_createStreamSink(d){let m=d.streamId,y=this.sourceName,w=d.sourceName,v=this.comObj,g=this,f=this.actionHandler[d.action],p={enqueue(b,S=1,C){if(this.isCancelled)return;let x=this.desiredSize;this.desiredSize-=S,x>0&&this.desiredSize<=0&&(this.sinkCapability=(0,i.createPromiseCapability)(),this.ready=this.sinkCapability.promise),v.postMessage({sourceName:y,targetName:w,stream:s.ENQUEUE,streamId:m,chunk:b},C)},close(){this.isCancelled||(this.isCancelled=!0,v.postMessage({sourceName:y,targetName:w,stream:s.CLOSE,streamId:m}),delete g.streamSinks[m])},error(b){(0,i.assert)(b instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,v.postMessage({sourceName:y,targetName:w,stream:s.ERROR,streamId:m,reason:l(b)}))},sinkCapability:(0,i.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:d.desiredSize,ready:null};p.sinkCapability.resolve(),p.ready=p.sinkCapability.promise,this.streamSinks[m]=p,new Promise(function(b){b(f(d.data,p))}).then(function(){v.postMessage({sourceName:y,targetName:w,stream:s.START_COMPLETE,streamId:m,success:!0})},function(b){v.postMessage({sourceName:y,targetName:w,stream:s.START_COMPLETE,streamId:m,reason:l(b)})})}_processStreamMessage(d){let m=d.streamId,y=this.sourceName,w=d.sourceName,v=this.comObj,g=this.streamControllers[m],f=this.streamSinks[m];switch(d.stream){case s.START_COMPLETE:d.success?g.startCall.resolve():g.startCall.reject(l(d.reason));break;case s.PULL_COMPLETE:d.success?g.pullCall.resolve():g.pullCall.reject(l(d.reason));break;case s.PULL:if(!f){v.postMessage({sourceName:y,targetName:w,stream:s.PULL_COMPLETE,streamId:m,success:!0});break}f.desiredSize<=0&&d.desiredSize>0&&f.sinkCapability.resolve(),f.desiredSize=d.desiredSize,new Promise(function(p){p(f.onPull&&f.onPull())}).then(function(){v.postMessage({sourceName:y,targetName:w,stream:s.PULL_COMPLETE,streamId:m,success:!0})},function(p){v.postMessage({sourceName:y,targetName:w,stream:s.PULL_COMPLETE,streamId:m,reason:l(p)})});break;case s.ENQUEUE:if((0,i.assert)(g,"enqueue should have stream controller"),g.isClosed)break;g.controller.enqueue(d.chunk);break;case s.CLOSE:if((0,i.assert)(g,"close should have stream controller"),g.isClosed)break;g.isClosed=!0,g.controller.close(),this._deleteStreamController(g,m);break;case s.ERROR:(0,i.assert)(g,"error should have stream controller"),g.controller.error(l(d.reason)),this._deleteStreamController(g,m);break;case s.CANCEL_COMPLETE:d.success?g.cancelCall.resolve():g.cancelCall.reject(l(d.reason)),this._deleteStreamController(g,m);break;case s.CANCEL:if(!f)break;new Promise(function(p){p(f.onCancel&&f.onCancel(l(d.reason)))}).then(function(){v.postMessage({sourceName:y,targetName:w,stream:s.CANCEL_COMPLETE,streamId:m,success:!0})},function(p){v.postMessage({sourceName:y,targetName:w,stream:s.CANCEL_COMPLETE,streamId:m,reason:l(p)})}),f.sinkCapability.reject(l(d.reason)),f.isCancelled=!0,delete this.streamSinks[m];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(d,m){await Promise.allSettled([d.startCall&&d.startCall.promise,d.pullCall&&d.pullCall.promise,d.cancelCall&&d.cancelCall.promise]),delete this.streamControllers[m]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}t.MessageHandler=h},(r,t,n)=>{var s,l;Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var i=n(1);class o{constructor({parsedData:u,rawData:d}){ke(this,s,void 0);ke(this,l,void 0);Ve(this,s,u),Ve(this,l,d)}getRaw(){return te(this,l)}get(u){return te(this,s).get(u)??null}getAll(){return(0,i.objectFromMap)(te(this,s))}has(u){return te(this,s).has(u)}}s=new WeakMap,l=new WeakMap,t.Metadata=o},(r,t,n)=>{var h,u,d,m,y,w,Ax;Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalContentConfig=void 0;var i=n(1);let o=Symbol("INTERNAL");class s{constructor(f,p){ke(this,h,!0);this.name=f,this.intent=p}get visible(){return te(this,h)}_setVisible(f,p){f!==o&&(0,i.unreachable)("Internal method `_setVisible` called."),Ve(this,h,p)}}h=new WeakMap;class l{constructor(f){ke(this,w);ke(this,u,!0);ke(this,d,new Map);ke(this,m,null);ke(this,y,null);if(this.name=null,this.creator=null,f!==null){this.name=f.name,this.creator=f.creator,Ve(this,y,f.order);for(let p of f.groups)te(this,d).set(p.id,new s(p.name,p.intent));if(f.baseState==="OFF")for(let p of te(this,d).values())p._setVisible(o,!1);for(let p of f.on)te(this,d).get(p)._setVisible(o,!0);for(let p of f.off)te(this,d).get(p)._setVisible(o,!1);Ve(this,m,new Map);for(let[p,b]of te(this,d))te(this,m).set(p,b.visible)}}isVisible(f){if(te(this,d).size===0)return!0;if(!f)return(0,i.warn)("Optional content group not defined."),!0;if(f.type==="OCG")return te(this,d).has(f.id)?te(this,d).get(f.id).visible:((0,i.warn)(`Optional content group not found: ${f.id}`),!0);if(f.type==="OCMD"){if(f.expression)return De(this,w,Ax).call(this,f.expression);if(!f.policy||f.policy==="AnyOn"){for(let p of f.ids){if(!te(this,d).has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(te(this,d).get(p).visible)return!0}return!1}else if(f.policy==="AllOn"){for(let p of f.ids){if(!te(this,d).has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(!te(this,d).get(p).visible)return!1}return!0}else if(f.policy==="AnyOff"){for(let p of f.ids){if(!te(this,d).has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(!te(this,d).get(p).visible)return!0}return!1}else if(f.policy==="AllOff"){for(let p of f.ids){if(!te(this,d).has(p))return(0,i.warn)(`Optional content group not found: ${p}`),!0;if(te(this,d).get(p).visible)return!1}return!0}return(0,i.warn)(`Unknown optional content policy ${f.policy}.`),!0}return(0,i.warn)(`Unknown group type ${f.type}.`),!0}setVisibility(f,p=!0){if(!te(this,d).has(f)){(0,i.warn)(`Optional content group not found: ${f}`);return}te(this,d).get(f)._setVisible(o,!!p),Ve(this,u,null)}get hasInitialVisibility(){if(te(this,u)!==null)return te(this,u);for(let[f,p]of te(this,d)){let b=te(this,m).get(f);if(p.visible!==b)return Ve(this,u,!1)}return Ve(this,u,!0)}getOrder(){return te(this,d).size?te(this,y)?te(this,y).slice():[...te(this,d).keys()]:null}getGroups(){return te(this,d).size>0?(0,i.objectFromMap)(te(this,d)):null}getGroup(f){return te(this,d).get(f)||null}}u=new WeakMap,d=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakSet,Ax=function(f){let p=f.length;if(p<2)return!0;let b=f[0];for(let S=1;S<p;S++){let C=f[S],x;if(Array.isArray(C))x=De(this,w,Ax).call(this,C);else if(te(this,d).has(C))x=te(this,d).get(C).visible;else return(0,i.warn)(`Optional content group not found: ${C}`),!0;switch(b){case"And":if(!x)return!1;break;case"Or":if(x)return!0;break;case"Not":return!x;default:return!0}}return b==="And"},t.OptionalContentConfig=l},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFDataTransportStream=void 0;var i=n(1),o=n(8);class s{constructor(d,m){(0,i.assert)(m,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=d.progressiveDone||!1,this._contentDispositionFilename=d.contentDispositionFilename||null;let y=d.initialData;if(y?.length>0){let w=new Uint8Array(y).buffer;this._queuedChunks.push(w)}this._pdfDataRangeTransport=m,this._isStreamingSupported=!d.disableStream,this._isRangeSupported=!d.disableRange,this._contentLength=d.length,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener((w,v)=>{this._onReceiveData({begin:w,chunk:v})}),this._pdfDataRangeTransport.addProgressListener((w,v)=>{this._onProgress({loaded:w,total:v})}),this._pdfDataRangeTransport.addProgressiveReadListener(w=>{this._onReceiveData({chunk:w})}),this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),this._pdfDataRangeTransport.transportReady()}_onReceiveData(d){let m=new Uint8Array(d.chunk).buffer;if(d.begin===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(m):this._queuedChunks.push(m);else{let y=this._rangeReaders.some(function(w){return w._begin!==d.begin?!1:(w._enqueue(m),!0)});(0,i.assert)(y,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(d){if(d.total===void 0){let m=this._rangeReaders[0];m?.onProgress&&m.onProgress({loaded:d.loaded})}else{let m=this._fullRequestReader;m?.onProgress&&m.onProgress({loaded:d.loaded,total:d.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(d){let m=this._rangeReaders.indexOf(d);m>=0&&this._rangeReaders.splice(m,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let d=this._queuedChunks;return this._queuedChunks=null,new l(this,d,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(d,m){if(m<=this._progressiveDataLength)return null;let y=new h(this,d,m);return this._pdfDataRangeTransport.requestDataRange(d,m),this._rangeReaders.push(y),y}cancelAllRequests(d){this._fullRequestReader&&this._fullRequestReader.cancel(d);for(let m of this._rangeReaders.slice(0))m.cancel(d);this._pdfDataRangeTransport.abort()}}t.PDFDataTransportStream=s;class l{constructor(d,m,y=!1,w=null){this._stream=d,this._done=y||!1,this._filename=(0,o.isPdfFile)(w)?w:null,this._queuedChunks=m||[],this._loaded=0;for(let v of this._queuedChunks)this._loaded+=v.byteLength;this._requests=[],this._headersReady=Promise.resolve(),d._fullRequestReader=this,this.onProgress=null}_enqueue(d){this._done||(this._requests.length>0?this._requests.shift().resolve({value:d,done:!1}):this._queuedChunks.push(d),this._loaded+=d.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};let d=(0,i.createPromiseCapability)();return this._requests.push(d),d.promise}cancel(d){this._done=!0;for(let m of this._requests)m.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class h{constructor(d,m,y){this._stream=d,this._begin=m,this._end=y,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(d){if(!this._done){if(this._requests.length===0)this._queuedChunk=d;else{this._requests.shift().resolve({value:d,done:!1});for(let y of this._requests)y.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){let m=this._queuedChunk;return this._queuedChunk=null,{value:m,done:!1}}if(this._done)return{value:void 0,done:!0};let d=(0,i.createPromiseCapability)();return this._requests.push(d),d.promise}cancel(d){this._done=!0;for(let m of this._requests)m.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(r,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaText=void 0;class n{static textContent(o){let s=[],l={items:s,styles:Object.create(null)};function h(u){if(!u)return;let d=null,m=u.name;if(m==="#text")d=u.value;else if(n.shouldBuildText(m))u?.attributes?.textContent?d=u.attributes.textContent:u.value&&(d=u.value);else return;if(d!==null&&s.push({str:d}),!!u.children)for(let y of u.children)h(y)}return h(o),l}static shouldBuildText(o){return!(o==="textarea"||o==="input"||o==="option"||o==="select")}}t.XfaText=n},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NodeStandardFontDataFactory=t.NodeCanvasFactory=t.NodeCMapReaderFactory=void 0;var i=n(9);let o=function(u){return new Promise((d,m)=>{Cd().readFile(u,(w,v)=>{if(w||!v){m(new Error(w));return}d(new Uint8Array(v))})})};class s extends i.BaseCanvasFactory{_createCanvas(d,m){return mx().createCanvas(d,m)}}t.NodeCanvasFactory=s;class l extends i.BaseCMapReaderFactory{_fetchData(d,m){return o(d).then(y=>({cMapData:y,compressionType:m}))}}t.NodeCMapReaderFactory=l;class h extends i.BaseStandardFontDataFactory{_fetchData(d){return o(d)}}t.NodeStandardFontDataFactory=h},(r,t,n)=>{var u,d,m,y,w,v,g,f,p,xx,S,d8,x,Cx,T,h8;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditorLayer=void 0;var i=n(7),o=n(1),s=n(23),l=n(24);let O=class{constructor(M){ke(this,p);ke(this,S);ke(this,x);ke(this,T);ke(this,u,void 0);ke(this,d,!1);ke(this,m,this.pointerup.bind(this));ke(this,y,this.pointerdown.bind(this));ke(this,w,new Map);ke(this,v,!1);ke(this,g,!1);ke(this,f,void 0);O._initialized||(O._initialized=!0,s.FreeTextEditor.initialize(M.l10n),l.InkEditor.initialize(M.l10n),M.uiManager.registerEditorTypes([s.FreeTextEditor,l.InkEditor])),Ve(this,f,M.uiManager),this.annotationStorage=M.annotationStorage,this.pageIndex=M.pageIndex,this.div=M.div,Ve(this,u,M.accessibilityManager),te(this,f).addLayer(this)}updateToolbar(M){te(this,f).updateToolbar(M)}updateMode(M=te(this,f).getMode()){De(this,T,h8).call(this),M===o.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),te(this,f).unselectAll()}addInkEditorIfNeeded(M){if(!M&&te(this,f).getMode()!==o.AnnotationEditorType.INK)return;if(!M){for(let F of te(this,w).values())if(F.isEmpty()){F.setInBackground();return}}De(this,x,Cx).call(this,{offsetX:0,offsetY:0}).setInBackground()}setEditingState(M){te(this,f).setEditingState(M)}addCommands(M){te(this,f).addCommands(M)}enable(){this.div.style.pointerEvents="auto";for(let M of te(this,w).values())M.enableEditing()}disable(){this.div.style.pointerEvents="none";for(let M of te(this,w).values())M.disableEditing()}setActiveEditor(M){te(this,f).getActive()!==M&&te(this,f).setActiveEditor(M)}enableClick(){this.div.addEventListener("pointerdown",te(this,y)),this.div.addEventListener("pointerup",te(this,m))}disableClick(){this.div.removeEventListener("pointerdown",te(this,y)),this.div.removeEventListener("pointerup",te(this,m))}attach(M){te(this,w).set(M.id,M)}detach(M){te(this,w).delete(M.id),te(this,u)?.removePointerInTextLayer(M.contentDiv)}remove(M){te(this,f).removeEditor(M),this.detach(M),this.annotationStorage.remove(M.id),M.div.style.display="none",setTimeout(()=>{M.div.style.display="",M.div.remove(),M.isAttachedToDOM=!1,document.activeElement===document.body&&te(this,f).focusMainContainer()},0),te(this,g)||this.addInkEditorIfNeeded(!1)}add(M){if(De(this,p,xx).call(this,M),te(this,f).addEditor(M),this.attach(M),!M.isAttachedToDOM){let k=M.render();this.div.append(k),M.isAttachedToDOM=!0}this.moveEditorInDOM(M),M.onceAdded(),this.addToAnnotationStorage(M)}moveEditorInDOM(M){te(this,u)?.moveElementInDOM(this.div,M.div,M.contentDiv,!0)}addToAnnotationStorage(M){!M.isEmpty()&&!this.annotationStorage.has(M.id)&&this.annotationStorage.setValue(M.id,M)}addOrRebuild(M){M.needsToBeRebuilt()?M.rebuild():this.add(M)}addANewEditor(M){let k=()=>{this.addOrRebuild(M)},F=()=>{M.remove()};this.addCommands({cmd:k,undo:F,mustExec:!0})}addUndoableEditor(M){let k=()=>{this.addOrRebuild(M)},F=()=>{M.remove()};this.addCommands({cmd:k,undo:F,mustExec:!1})}getNextId(){return te(this,f).getId()}deserialize(M){switch(M.annotationType){case o.AnnotationEditorType.FREETEXT:return s.FreeTextEditor.deserialize(M,this);case o.AnnotationEditorType.INK:return l.InkEditor.deserialize(M,this)}return null}setSelected(M){te(this,f).setSelected(M)}toggleSelected(M){te(this,f).toggleSelected(M)}isSelected(M){return te(this,f).isSelected(M)}unselect(M){te(this,f).unselect(M)}pointerup(M){let k=i.KeyboardManager.platform.isMac;if(!(M.button!==0||M.ctrlKey&&k)&&M.target===this.div&&!!te(this,v)){if(Ve(this,v,!1),!te(this,d)){Ve(this,d,!0);return}De(this,x,Cx).call(this,M)}}pointerdown(M){let k=i.KeyboardManager.platform.isMac;if(M.button!==0||M.ctrlKey&&k||M.target!==this.div)return;Ve(this,v,!0);let F=te(this,f).getActive();Ve(this,d,!F||F.isEmpty())}drop(M){let k=M.dataTransfer.getData("text/plain"),F=te(this,f).getEditor(k);if(!F)return;M.preventDefault(),M.dataTransfer.dropEffect="move",De(this,p,xx).call(this,F);let q=this.div.getBoundingClientRect(),G=M.clientX-q.x,ie=M.clientY-q.y;F.translate(G-F.startX,ie-F.startY),this.moveEditorInDOM(F),F.div.focus()}dragover(M){M.preventDefault()}destroy(){te(this,f).getActive()?.parent===this&&te(this,f).setActiveEditor(null);for(let M of te(this,w).values())te(this,u)?.removePointerInTextLayer(M.contentDiv),M.isAttachedToDOM=!1,M.div.remove(),M.parent=null;this.div=null,te(this,w).clear(),te(this,f).removeLayer(this)}render(M){this.viewport=M.viewport,(0,i.bindEvents)(this,this.div,["dragover","drop"]),this.setDimensions();for(let k of te(this,f).getEditors(this.pageIndex))this.add(k);this.updateMode()}update(M){this.viewport=M.viewport,this.setDimensions(),this.updateMode()}get scaleFactor(){return this.viewport.scale}get pageDimensions(){let[M,k,F,q]=this.viewport.viewBox,G=F-M,ie=q-k;return[G,ie]}get viewportBaseDimensions(){let{width:M,height:k,rotation:F}=this.viewport;return F%180==0?[M,k]:[k,M]}setDimensions(){let{width:M,height:k,rotation:F}=this.viewport,q=F%180!=0,G=Math.floor(M)+"px",ie=Math.floor(k)+"px";this.div.style.width=q?ie:G,this.div.style.height=q?G:ie,this.div.setAttribute("data-main-rotation",F)}},h=O;u=new WeakMap,d=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap,v=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakSet,xx=function(M){M.parent!==this&&(this.attach(M),M.pageIndex=this.pageIndex,M.parent?.detach(M),M.parent=this,M.div&&M.isAttachedToDOM&&(M.div.remove(),this.div.append(M.div)))},S=new WeakSet,d8=function(M){switch(te(this,f).getMode()){case o.AnnotationEditorType.FREETEXT:return new s.FreeTextEditor(M);case o.AnnotationEditorType.INK:return new l.InkEditor(M)}return null},x=new WeakSet,Cx=function(M){let k=this.getNextId(),F=De(this,S,d8).call(this,{parent:this,id:k,x:M.offsetX,y:M.offsetY});return F&&this.add(F),F},T=new WeakSet,h8=function(){Ve(this,g,!0);for(let M of te(this,w).values())M.isEmpty()&&M.remove();Ve(this,g,!1)},En(h,"_initialized",!1),t.AnnotationEditorLayer=h},(r,t,n)=>{var h,u,d,m,y,w,v,g,f8,p,p8,S,g8,x,Tx;Object.defineProperty(t,"__esModule",{value:!0}),t.FreeTextEditor=void 0;var i=n(1),o=n(7),s=n(6);let T=class extends s.AnnotationEditor{constructor(O){super(nn(dt({},O),{name:"freeTextEditor"}));ke(this,g);ke(this,p);ke(this,S);ke(this,x);ke(this,h,this.editorDivBlur.bind(this));ke(this,u,this.editorDivFocus.bind(this));ke(this,d,this.editorDivKeydown.bind(this));ke(this,m,void 0);ke(this,y,"");ke(this,w,!1);ke(this,v,void 0);Ve(this,m,O.color||T._defaultColor||s.AnnotationEditor._defaultLineColor),Ve(this,v,O.fontSize||T._defaultFontSize)}static initialize(O){this._l10nPromise=new Map(["free_text_default_content","editor_free_text_aria_label"].map(M=>[M,O.get(M)]));let L=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(L.getPropertyValue("--freetext-padding"))}static updateDefaultParams(O,L){switch(O){case i.AnnotationEditorParamsType.FREETEXT_SIZE:T._defaultFontSize=L;break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:T._defaultColor=L;break}}updateParams(O,L){switch(O){case i.AnnotationEditorParamsType.FREETEXT_SIZE:De(this,g,f8).call(this,L);break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:De(this,p,p8).call(this,L);break}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,T._defaultFontSize],[i.AnnotationEditorParamsType.FREETEXT_COLOR,T._defaultColor||s.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,te(this,v)],[i.AnnotationEditorParamsType.FREETEXT_COLOR,te(this,m)]]}getInitialTranslation(){return[-T._internalPadding*this.parent.scaleFactor,-(T._internalPadding+te(this,v))*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(i.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.enableEditing(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this.div.draggable=!1,this.editorDiv.addEventListener("keydown",te(this,d)),this.editorDiv.addEventListener("focus",te(this,u)),this.editorDiv.addEventListener("blur",te(this,h)))}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",te(this,d)),this.editorDiv.removeEventListener("focus",te(this,u)),this.editorDiv.removeEventListener("blur",te(this,h)),this.div.focus(),this.isEditing=!1)}focusin(O){super.focusin(O),O.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(),te(this,w)||(Ve(this,w,!0),this.parent.addUndoableEditor(this)),this.disableEditMode(),Ve(this,y,De(this,S,g8).call(this).trimEnd()),De(this,x,Tx).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}dblclick(O){this.enableEditMode(),this.editorDiv.focus()}keydown(O){O.target===this.div&&O.key==="Enter"&&(this.enableEditMode(),this.editorDiv.focus())}editorDivKeydown(O){T._keyboardManager.exec(this,O)}editorDivFocus(O){this.isEditing=!0}editorDivBlur(O){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 O,L;this.width&&(O=this.x,L=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",`${this.id}-editor`),this.enableEditing(),T._l10nPromise.get("editor_free_text_aria_label").then(k=>this.editorDiv?.setAttribute("aria-label",k)),T._l10nPromise.get("free_text_default_content").then(k=>this.editorDiv?.setAttribute("default-content",k)),this.editorDiv.contentEditable=!0;let{style:M}=this.editorDiv;if(M.fontSize=`calc(${te(this,v)}px * var(--scale-factor))`,M.color=te(this,m),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,o.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){let[k,F]=this.parent.viewportBaseDimensions;this.setAt(O*k,L*F,this.width*k,this.height*F);for(let q of te(this,y).split(`
70
70
  `)){let G=document.createElement("div");G.append(q?document.createTextNode(q):document.createElement("br")),this.editorDiv.append(G)}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(O,L){let M=super.deserialize(O,L);return Ve(M,v,O.fontSize),Ve(M,m,i.Util.makeHexColor(...O.color)),Ve(M,y,O.value),M}serialize(){if(this.isEmpty())return null;let O=T._internalPadding*this.parent.scaleFactor,L=this.getRect(O,O),M=s.AnnotationEditor._colorManager.convert(getComputedStyle(this.editorDiv).color);return{annotationType:i.AnnotationEditorType.FREETEXT,color:M,fontSize:te(this,v),value:te(this,y),pageIndex:this.parent.pageIndex,rect:L,rotation:this.rotation}}},l=T;h=new WeakMap,u=new WeakMap,d=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap,v=new WeakMap,g=new WeakSet,f8=function(O){let L=k=>{this.editorDiv.style.fontSize=`calc(${k}px * var(--scale-factor))`,this.translate(0,-(k-te(this,v))*this.parent.scaleFactor),Ve(this,v,k),De(this,x,Tx).call(this)},M=te(this,v);this.parent.addCommands({cmd:()=>{L(O)},undo:()=>{L(M)},mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},p=new WeakSet,p8=function(O){let L=te(this,m);this.parent.addCommands({cmd:()=>{Ve(this,m,O),this.editorDiv.style.color=O},undo:()=>{Ve(this,m,L),this.editorDiv.style.color=L},mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},S=new WeakSet,g8=function(){let O=this.editorDiv.getElementsByTagName("div");if(O.length===0)return this.editorDiv.innerText;let L=[];for(let M=0,k=O.length;M<k;M++){let q=O[M].firstChild;q?.nodeName==="#text"?L.push(q.data):L.push("")}return L.join(`
71
71
  `)},x=new WeakSet,Tx=function(){let[O,L]=this.parent.viewportBaseDimensions,M=this.div.getBoundingClientRect();this.width=M.width/O,this.height=M.height/L},En(l,"_freeTextDefaultContent",""),En(l,"_l10nPromise"),En(l,"_internalPadding",0),En(l,"_defaultColor",null),En(l,"_defaultFontSize",10),En(l,"_keyboardManager",new o.KeyboardManager([[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],T.prototype.commitOrRemove]])),En(l,"_type","freetext"),t.FreeTextEditor=l},(r,t,n)=>{var d,m,y,w,v,g,f,p,b,S,C,x,E,T,R,m8,L,y8,k,b8,q,v8,ie,Ox,Z,w8,ce,E8,ve,_8,N,ho,D,Rx,z,Dg,he,Fg,I,Yl,K,Px,re,jg,Ee,Mx,ae,S8,le,A8,Oe,x8,se,kx,Re,Hg,Ze,Xl,Xe,Ix;Object.defineProperty(t,"__esModule",{value:!0}),t.InkEditor=void 0,Object.defineProperty(t,"fitCurve",{enumerable:!0,get:function(){return s.fitCurve}});var i=n(1),o=n(6),s=n(25),l=n(7);let h=16,Ke=class extends o.AnnotationEditor{constructor(Pe){super(nn(dt({},Pe),{name:"inkEditor"}));ke(this,R);ke(this,L);ke(this,k);ke(this,q);ke(this,ie);ke(this,Z);ke(this,ce);ke(this,ve);ke(this,N);ke(this,D);ke(this,z);ke(this,he);ke(this,I);ke(this,K);ke(this,re);ke(this,ae);ke(this,le);ke(this,Oe);ke(this,se);ke(this,Re);ke(this,Ze);ke(this,Xe);ke(this,d,0);ke(this,m,0);ke(this,y,0);ke(this,w,this.canvasPointermove.bind(this));ke(this,v,this.canvasPointerleave.bind(this));ke(this,g,this.canvasPointerup.bind(this));ke(this,f,this.canvasPointerdown.bind(this));ke(this,p,!1);ke(this,b,!1);ke(this,S,null);ke(this,C,null);ke(this,x,0);ke(this,E,0);ke(this,T,null);this.color=Pe.color||null,this.thickness=Pe.thickness||null,this.opacity=Pe.opacity||null,this.paths=[],this.bezierPath2D=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0}static initialize(Pe){this._l10nPromise=new Map(["editor_ink_canvas_aria_label","editor_ink_aria_label"].map(Ue=>[Ue,Pe.get(Ue)]))}static updateDefaultParams(Pe,Ue){switch(Pe){case i.AnnotationEditorParamsType.INK_THICKNESS:Ke._defaultThickness=Ue;break;case i.AnnotationEditorParamsType.INK_COLOR:Ke._defaultColor=Ue;break;case i.AnnotationEditorParamsType.INK_OPACITY:Ke._defaultOpacity=Ue/100;break}}updateParams(Pe,Ue){switch(Pe){case i.AnnotationEditorParamsType.INK_THICKNESS:De(this,R,m8).call(this,Ue);break;case i.AnnotationEditorParamsType.INK_COLOR:De(this,L,y8).call(this,Ue);break;case i.AnnotationEditorParamsType.INK_OPACITY:De(this,k,b8).call(this,Ue);break}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.INK_THICKNESS,Ke._defaultThickness],[i.AnnotationEditorParamsType.INK_COLOR,Ke._defaultColor||o.AnnotationEditor._defaultLineColor],[i.AnnotationEditorParamsType.INK_OPACITY,Math.round(Ke._defaultOpacity*100)]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||Ke._defaultThickness],[i.AnnotationEditorParamsType.INK_COLOR,this.color||Ke._defaultColor||o.AnnotationEditor._defaultLineColor],[i.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(this.opacity??Ke._defaultOpacity))]]}rebuild(){super.rebuild(),this.div!==null&&(this.canvas||(De(this,z,Dg).call(this),De(this,he,Fg).call(this)),this.isAttachedToDOM||(this.parent.add(this),De(this,I,Yl).call(this)),De(this,Ze,Xl).call(this))}remove(){this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,te(this,C).disconnect(),Ve(this,C,null),super.remove())}enableEditMode(){te(this,p)||this.canvas===null||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",te(this,f)),this.canvas.addEventListener("pointerup",te(this,g)))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",te(this,f)),this.canvas.removeEventListener("pointerup",te(this,g)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){te(this,p)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),Ve(this,p,!0),this.div.classList.add("disabled"),De(this,Ze,Xl).call(this,!0),this.parent.addInkEditorIfNeeded(!0),this.parent.moveEditorInDOM(this),this.div.focus())}focusin(Pe){super.focusin(Pe),this.enableEditMode()}canvasPointerdown(Pe){Pe.button!==0||!this.isInEditMode()||te(this,p)||(this.setInForeground(),Pe.type!=="mouse"&&this.div.focus(),Pe.stopPropagation(),this.canvas.addEventListener("pointerleave",te(this,v)),this.canvas.addEventListener("pointermove",te(this,w)),De(this,Z,w8).call(this,Pe.offsetX,Pe.offsetY))}canvasPointermove(Pe){Pe.stopPropagation(),De(this,ce,E8).call(this,Pe.offsetX,Pe.offsetY)}canvasPointerup(Pe){Pe.button===0&&this.isInEditMode()&&this.currentPath.length!==0&&(Pe.stopPropagation(),De(this,D,Rx).call(this,Pe),this.setInBackground())}canvasPointerleave(Pe){De(this,D,Rx).call(this,Pe),this.setInBackground()}render(){if(this.div)return this.div;let Pe,Ue;this.width&&(Pe=this.x,Ue=this.y),super.render(),Ke._l10nPromise.get("editor_ink_aria_label").then(Fe=>this.div?.setAttribute("aria-label",Fe));let[it,Te,pe,ge]=De(this,q,v8).call(this);if(this.setAt(it,Te,0,0),this.setDims(pe,ge),De(this,z,Dg).call(this),this.width){let[Fe,Je]=this.parent.viewportBaseDimensions;this.setAt(Pe*Fe,Ue*Je,this.width*Fe,this.height*Je),Ve(this,b,!0),De(this,I,Yl).call(this),this.setDims(this.width*Fe,this.height*Je),De(this,N,ho).call(this),De(this,Xe,Ix).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return De(this,he,Fg).call(this),this.div}setDimensions(Pe,Ue){let it=Math.round(Pe),Te=Math.round(Ue);if(te(this,x)===it&&te(this,E)===Te)return;Ve(this,x,it),Ve(this,E,Te),this.canvas.style.visibility="hidden",te(this,d)&&Math.abs(te(this,d)-Pe/Ue)>.01&&(Ue=Math.ceil(Pe/te(this,d)),this.setDims(Pe,Ue));let[pe,ge]=this.parent.viewportBaseDimensions;this.width=Pe/pe,this.height=Ue/ge,te(this,p)&&De(this,K,Px).call(this,Pe,Ue),De(this,I,Yl).call(this),De(this,N,ho).call(this),this.canvas.style.visibility="visible"}static deserialize(Pe,Ue){var en,Wt;let it=super.deserialize(Pe,Ue);it.thickness=Pe.thickness,it.color=i.Util.makeHexColor(...Pe.color),it.opacity=Pe.opacity;let[Te,pe]=Ue.pageDimensions,ge=it.width*Te,Fe=it.height*pe,Je=Ue.scaleFactor,ft=Pe.thickness/2;Ve(it,d,ge/Fe),Ve(it,p,!0),Ve(it,x,Math.round(ge)),Ve(it,E,Math.round(Fe));for(let{bezier:Tt}of Pe.paths){let qt=[];it.paths.push(qt);let un=Je*(Tt[0]-ft),hn=Je*(Fe-Tt[1]-ft);for(let It=2,Wn=Tt.length;It<Wn;It+=6){let An=Je*(Tt[It]-ft),zn=Je*(Fe-Tt[It+1]-ft),_i=Je*(Tt[It+2]-ft),Hi=Je*(Fe-Tt[It+3]-ft),bn=Je*(Tt[It+4]-ft),br=Je*(Fe-Tt[It+5]-ft);qt.push([[un,hn],[An,zn],[_i,Hi],[bn,br]]),un=bn,hn=br}let pn=De(this,Ee,Mx).call(this,qt);it.bezierPath2D.push(pn)}let ct=De(en=it,se,kx).call(en);return Ve(it,y,Math.max(h,ct[2]-ct[0])),Ve(it,m,Math.max(h,ct[3]-ct[1])),De(Wt=it,K,Px).call(Wt,ge,Fe),it}serialize(){if(this.isEmpty())return null;let Pe=this.getRect(0,0),Ue=this.rotation%180==0?Pe[3]-Pe[1]:Pe[2]-Pe[0],it=o.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);return{annotationType:i.AnnotationEditorType.INK,color:it,thickness:this.thickness,opacity:this.opacity,paths:De(this,ae,S8).call(this,this.scaleFactor/this.parent.scaleFactor,this.translationX,this.translationY,Ue),pageIndex:this.parent.pageIndex,rect:Pe,rotation:this.rotation}}},u=Ke;d=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap,v=new WeakMap,g=new WeakMap,f=new WeakMap,p=new WeakMap,b=new WeakMap,S=new WeakMap,C=new WeakMap,x=new WeakMap,E=new WeakMap,T=new WeakMap,R=new WeakSet,m8=function(Pe){let Ue=this.thickness;this.parent.addCommands({cmd:()=>{this.thickness=Pe,De(this,Ze,Xl).call(this)},undo:()=>{this.thickness=Ue,De(this,Ze,Xl).call(this)},mustExec:!0,type:i.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},L=new WeakSet,y8=function(Pe){let Ue=this.color;this.parent.addCommands({cmd:()=>{this.color=Pe,De(this,N,ho).call(this)},undo:()=>{this.color=Ue,De(this,N,ho).call(this)},mustExec:!0,type:i.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},k=new WeakSet,b8=function(Pe){Pe/=100;let Ue=this.opacity;this.parent.addCommands({cmd:()=>{this.opacity=Pe,De(this,N,ho).call(this)},undo:()=>{this.opacity=Ue,De(this,N,ho).call(this)},mustExec:!0,type:i.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},q=new WeakSet,v8=function(){let{width:Pe,height:Ue,rotation:it}=this.parent.viewport;switch(it){case 90:return[0,Pe,Pe,Ue];case 180:return[Pe,Ue,Pe,Ue];case 270:return[Ue,0,Pe,Ue];default:return[0,0,Pe,Ue]}},ie=new WeakSet,Ox=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,l.opacityToHex)(this.opacity)}`},Z=new WeakSet,w8=function(Pe,Ue){this.isEditing=!0,te(this,b)||(Ve(this,b,!0),De(this,I,Yl).call(this),this.thickness||=Ke._defaultThickness,this.color||=Ke._defaultColor||o.AnnotationEditor._defaultLineColor,this.opacity??=Ke._defaultOpacity),this.currentPath.push([Pe,Ue]),Ve(this,S,null),De(this,ie,Ox).call(this),this.ctx.beginPath(),this.ctx.moveTo(Pe,Ue),Ve(this,T,()=>{!te(this,T)||(te(this,S)&&(this.isEmpty()?(this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)):De(this,N,ho).call(this),this.ctx.lineTo(...te(this,S)),Ve(this,S,null),this.ctx.stroke()),window.requestAnimationFrame(te(this,T)))}),window.requestAnimationFrame(te(this,T))},ce=new WeakSet,E8=function(Pe,Ue){let[it,Te]=this.currentPath.at(-1);Pe===it&&Ue===Te||(this.currentPath.push([Pe,Ue]),Ve(this,S,[Pe,Ue]))},ve=new WeakSet,_8=function(Pe,Ue){var ft;this.ctx.closePath(),Ve(this,T,null),Pe=Math.min(Math.max(Pe,0),this.canvas.width),Ue=Math.min(Math.max(Ue,0),this.canvas.height);let[it,Te]=this.currentPath.at(-1);(Pe!==it||Ue!==Te)&&this.currentPath.push([Pe,Ue]);let pe;if(this.currentPath.length!==1)pe=(0,s.fitCurve)(this.currentPath,30,null);else{let ct=[Pe,Ue];pe=[[ct,ct.slice(),ct.slice(),ct]]}let ge=De(ft=Ke,Ee,Mx).call(ft,pe);this.currentPath.length=0;let Fe=()=>{this.paths.push(pe),this.bezierPath2D.push(ge),this.rebuild()},Je=()=>{this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(De(this,z,Dg).call(this),De(this,he,Fg).call(this)),De(this,Ze,Xl).call(this))};this.parent.addCommands({cmd:Fe,undo:Je,mustExec:!0})},N=new WeakSet,ho=function(){if(this.isEmpty()){De(this,re,jg).call(this);return}De(this,ie,Ox).call(this);let{canvas:Pe,ctx:Ue}=this;Ue.setTransform(1,0,0,1,0,0),Ue.clearRect(0,0,Pe.width,Pe.height),De(this,re,jg).call(this);for(let it of this.bezierPath2D)Ue.stroke(it)},D=new WeakSet,Rx=function(Pe){De(this,ve,_8).call(this,Pe.offsetX,Pe.offsetY),this.canvas.removeEventListener("pointerleave",te(this,v)),this.canvas.removeEventListener("pointermove",te(this,w)),this.parent.addToAnnotationStorage(this)},z=new WeakSet,Dg=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",Ke._l10nPromise.get("editor_ink_canvas_aria_label").then(Pe=>this.canvas?.setAttribute("aria-label",Pe)),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},he=new WeakSet,Fg=function(){Ve(this,C,new ResizeObserver(Pe=>{let Ue=Pe[0].contentRect;Ue.width&&Ue.height&&this.setDimensions(Ue.width,Ue.height)})),te(this,C).observe(this.div)},I=new WeakSet,Yl=function(){if(!te(this,b))return;let[Pe,Ue]=this.parent.viewportBaseDimensions;this.canvas.width=Math.ceil(this.width*Pe),this.canvas.height=Math.ceil(this.height*Ue),De(this,re,jg).call(this)},K=new WeakSet,Px=function(Pe,Ue){let it=De(this,Re,Hg).call(this),Te=(Pe-it)/te(this,y),pe=(Ue-it)/te(this,m);this.scaleFactor=Math.min(Te,pe)},re=new WeakSet,jg=function(){let Pe=De(this,Re,Hg).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+Pe,this.translationY*this.scaleFactor+Pe)},Ee=new WeakSet,Mx=function(Pe){let Ue=new Path2D;for(let it=0,Te=Pe.length;it<Te;it++){let[pe,ge,Fe,Je]=Pe[it];it===0&&Ue.moveTo(...pe),Ue.bezierCurveTo(ge[0],ge[1],Fe[0],Fe[1],Je[0],Je[1])}return Ue},ae=new WeakSet,S8=function(Pe,Ue,it,Te){let pe=4,ge=[],Fe=this.thickness/2,Je,ft;for(let ct of this.paths){Je=[],ft=[];for(let en=0,Wt=ct.length;en<Wt;en++){let[Tt,qt,un,hn]=ct[en],pn=Pe*(Tt[0]+Ue)+Fe,It=Te-Pe*(Tt[1]+it)-Fe,Wn=Pe*(qt[0]+Ue)+Fe,An=Te-Pe*(qt[1]+it)-Fe,zn=Pe*(un[0]+Ue)+Fe,_i=Te-Pe*(un[1]+it)-Fe,Hi=Pe*(hn[0]+Ue)+Fe,bn=Te-Pe*(hn[1]+it)-Fe;en===0&&(Je.push(pn,It),ft.push(pn,It)),Je.push(Wn,An,zn,_i,Hi,bn),De(this,le,A8).call(this,pn,It,Wn,An,zn,_i,Hi,bn,pe,ft)}ge.push({bezier:Je,points:ft})}return ge},le=new WeakSet,A8=function(Pe,Ue,it,Te,pe,ge,Fe,Je,ft,ct){if(De(this,Oe,x8).call(this,Pe,Ue,it,Te,pe,ge,Fe,Je)){ct.push(Fe,Je);return}for(let en=1;en<ft-1;en++){let Wt=en/ft,Tt=1-Wt,qt=Wt*Pe+Tt*it,un=Wt*Ue+Tt*Te,hn=Wt*it+Tt*pe,pn=Wt*Te+Tt*ge,It=Wt*pe+Tt*Fe,Wn=Wt*ge+Tt*Je;qt=Wt*qt+Tt*hn,un=Wt*un+Tt*pn,hn=Wt*hn+Tt*It,pn=Wt*pn+Tt*Wn,qt=Wt*qt+Tt*hn,un=Wt*un+Tt*pn,ct.push(qt,un)}ct.push(Fe,Je)},Oe=new WeakSet,x8=function(Pe,Ue,it,Te,pe,ge,Fe,Je){let ft=10,ct=(3*it-2*Pe-Fe)**2,en=(3*Te-2*Ue-Je)**2,Wt=(3*pe-Pe-2*Fe)**2,Tt=(3*ge-Ue-2*Je)**2;return Math.max(ct,Wt)+Math.max(en,Tt)<=ft},se=new WeakSet,kx=function(){let Pe=1/0,Ue=-1/0,it=1/0,Te=-1/0;for(let pe of this.paths)for(let[ge,Fe,Je,ft]of pe){let ct=i.Util.bezierBoundingBox(...ge,...Fe,...Je,...ft);Pe=Math.min(Pe,ct[0]),it=Math.min(it,ct[1]),Ue=Math.max(Ue,ct[2]),Te=Math.max(Te,ct[3])}return[Pe,it,Ue,Te]},Re=new WeakSet,Hg=function(){return te(this,p)?Math.ceil(this.thickness*this.parent.scaleFactor):0},Ze=new WeakSet,Xl=function(Pe=!1){if(this.isEmpty())return;if(!te(this,p)){De(this,N,ho).call(this);return}let Ue=De(this,se,kx).call(this),it=De(this,Re,Hg).call(this);Ve(this,y,Math.max(h,Ue[2]-Ue[0])),Ve(this,m,Math.max(h,Ue[3]-Ue[1]));let Te=Math.ceil(it+te(this,y)*this.scaleFactor),pe=Math.ceil(it+te(this,m)*this.scaleFactor),[ge,Fe]=this.parent.viewportBaseDimensions;this.width=Te/ge,this.height=pe/Fe,Ve(this,d,Te/pe),De(this,Xe,Ix).call(this);let Je=this.translationX,ft=this.translationY;this.translationX=-Ue[0],this.translationY=-Ue[1],De(this,I,Yl).call(this),De(this,N,ho).call(this),Ve(this,x,Te),Ve(this,E,pe),this.setDims(Te,pe);let ct=Pe?it/this.scaleFactor/2:0;this.translate(Je-this.translationX-ct,ft-this.translationY-ct)},Xe=new WeakSet,Ix=function(){let{style:Pe}=this.div;te(this,d)>=1?(Pe.minHeight=`${h}px`,Pe.minWidth=`${Math.round(te(this,d)*h)}px`):(Pe.minWidth=`${h}px`,Pe.minHeight=`${Math.round(h/te(this,d))}px`)},ke(u,Ee),En(u,"_defaultColor",null),En(u,"_defaultOpacity",1),En(u,"_defaultThickness",1),En(u,"_l10nPromise"),En(u,"_type","ink"),t.InkEditor=u},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fitCurve=void 0;let i=n(26);t.fitCurve=i},r=>{function t(g,f,p){if(!Array.isArray(g))throw new TypeError("First argument should be an array");if(g.forEach(x=>{if(!Array.isArray(x)||x.some(E=>typeof E!="number")||x.length!==g[0].length)throw Error("Each point should be an array of numbers. Each point should have the same amount of numbers.")}),g=g.filter((x,E)=>E===0||!x.every((T,R)=>T===g[E-1][R])),g.length<2)return[];let b=g.length,S=y(g[1],g[0]),C=y(g[b-2],g[b-1]);return n(g,S,C,f,p)}function n(g,f,p,b,S){let C=20;var x,E,T,R,O,L,M,k,F,q,G,ie,ee;if(g.length===2)return ie=w.vectorLen(w.subtract(g[0],g[1]))/3,x=[g[0],w.addArrays(g[0],w.mulItems(f,ie)),w.addArrays(g[1],w.mulItems(p,ie)),g[1]],[x];if(E=h(g),[x,R,L]=i(g,E,E,f,p,S),R===0||R<b)return[x];if(R<b*b)for(T=E,O=R,M=L,ee=0;ee<C;ee++){if(T=s(x,g,T),[x,R,L]=i(g,E,T,f,p,S),R<b)return[x];if(L===M){let Z=R/O;if(Z>.9999&&Z<1.0001)break}O=R,M=L}return G=[],k=w.subtract(g[L-1],g[L+1]),k.every(Z=>Z===0)&&(k=w.subtract(g[L-1],g[L]),[k[0],k[1]]=[-k[1],k[0]]),F=w.normalize(k),q=w.mulItems(F,-1),G=G.concat(n(g.slice(0,L+1),f,F,b,S)),G=G.concat(n(g.slice(L),q,p,b,S)),G}function i(g,f,p,b,S,C){var x,E,T;return x=o(g,p,b,S,C),[E,T]=u(g,x,f),C&&C({bez:x,points:g,params:f,maxErr:E,maxPoint:T}),[x,E,T]}function o(g,f,p,b){var S,C,x,E,T,R,O,L,M,k,F,q,G,ie,ee,Z,X,ce=g[0],we=g[g.length-1];for(S=[ce,null,null,we],C=w.zeros_Xx2x2(f.length),G=0,ie=f.length;G<ie;G++)Z=f[G],X=1-Z,x=C[G],x[0]=w.mulItems(p,3*Z*(X*X)),x[1]=w.mulItems(b,3*X*(Z*Z));for(E=[[0,0],[0,0]],T=[0,0],G=0,ie=g.length;G<ie;G++)Z=f[G],x=C[G],E[0][0]+=w.dot(x[0],x[0]),E[0][1]+=w.dot(x[0],x[1]),E[1][0]+=w.dot(x[0],x[1]),E[1][1]+=w.dot(x[1],x[1]),ee=w.subtract(g[G],v.q([ce,ce,we,we],Z)),T[0]+=w.dot(x[0],ee),T[1]+=w.dot(x[1],ee);return R=E[0][0]*E[1][1]-E[1][0]*E[0][1],O=E[0][0]*T[1]-E[1][0]*T[0],L=T[0]*E[1][1]-T[1]*E[0][1],M=R===0?0:L/R,k=R===0?0:O/R,q=w.vectorLen(w.subtract(ce,we)),F=1e-6*q,M<F||k<F?(S[1]=w.addArrays(ce,w.mulItems(p,q/3)),S[2]=w.addArrays(we,w.mulItems(b,q/3))):(S[1]=w.addArrays(ce,w.mulItems(p,M)),S[2]=w.addArrays(we,w.mulItems(b,k))),S}function s(g,f,p){return p.map((b,S)=>l(g,f[S],b))}function l(g,f,p){var b=w.subtract(v.q(g,p),f),S=v.qprime(g,p),C=w.mulMatrix(b,S),x=w.sum(w.squareItems(S))+2*w.mulMatrix(b,v.qprimeprime(g,p));return x===0?p:p-C/x}function h(g){var f=[],p,b,S;return g.forEach((C,x)=>{p=x?b+w.vectorLen(w.subtract(C,S)):0,f.push(p),b=p,S=C}),f=f.map(C=>C/b),f}function u(g,f,p){var b,S,C,x,E,T,R,O;S=0,C=Math.floor(g.length/2);let L=d(f,10);for(E=0,T=g.length;E<T;E++)R=g[E],O=m(f,p[E],L,10),x=w.subtract(v.q(f,O),R),b=x[0]*x[0]+x[1]*x[1],b>S&&(S=b,C=E);return[S,C]}var d=function(g,f){for(var p,b=[0],S=g[0],C=0,x=1;x<=f;x++)p=v.q(g,x/f),C+=w.vectorLen(w.subtract(p,S)),b.push(C),S=p;return b=b.map(E=>E/C),b};function m(g,f,p,b){if(f<0)return 0;if(f>1)return 1;for(var S,C,x,E,T,R=1;R<=b;R++)if(f<=p[R]){E=(R-1)/b,x=R/b,C=p[R-1],S=p[R],T=(f-C)/(S-C)*(x-E)+E;break}return T}function y(g,f){return w.normalize(w.subtract(g,f))}class w{static zeros_Xx2x2(f){for(var p=[];f--;)p.push([0,0]);return p}static mulItems(f,p){return f.map(b=>b*p)}static mulMatrix(f,p){return f.reduce((b,S,C)=>b+S*p[C],0)}static subtract(f,p){return f.map((b,S)=>b-p[S])}static addArrays(f,p){return f.map((b,S)=>b+p[S])}static addItems(f,p){return f.map(b=>b+p)}static sum(f){return f.reduce((p,b)=>p+b)}static dot(f,p){return w.mulMatrix(f,p)}static vectorLen(f){return Math.hypot(...f)}static divItems(f,p){return f.map(b=>b/p)}static squareItems(f){return f.map(p=>p*p)}static normalize(f){return this.divItems(f,this.vectorLen(f))}}class v{static q(f,p){var b=1-p,S=w.mulItems(f[0],b*b*b),C=w.mulItems(f[1],3*b*b*p),x=w.mulItems(f[2],3*b*p*p),E=w.mulItems(f[3],p*p*p);return w.addArrays(w.addArrays(S,C),w.addArrays(x,E))}static qprime(f,p){var b=1-p,S=w.mulItems(w.subtract(f[1],f[0]),3*b*b),C=w.mulItems(w.subtract(f[2],f[1]),6*b*p),x=w.mulItems(w.subtract(f[3],f[2]),3*p*p);return w.addArrays(w.addArrays(S,C),x)}static qprimeprime(f,p){return w.addArrays(w.mulItems(w.addArrays(w.subtract(f[2],w.mulItems(f[1],2)),f[0]),6*(1-p)),w.mulItems(w.addArrays(w.subtract(f[3],w.mulItems(f[2],2)),f[1]),6*p))}}r.exports=t,r.exports.fitCubic=n,r.exports.createTangent=y},(r,t,n)=>{var N,Lx,D,Bx,z,Nx;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationLayer=void 0;var i=n(1),o=n(8),s=n(5),l=n(28),h=n(29);let u=1e3,d=9,m=new WeakSet;function y(fe){return{width:fe[2]-fe[0],height:fe[3]-fe[1]}}class w{static create(I){switch(I.data.annotationType){case i.AnnotationType.LINK:return new g(I);case i.AnnotationType.TEXT:return new f(I);case i.AnnotationType.WIDGET:switch(I.data.fieldType){case"Tx":return new b(I);case"Btn":return I.data.radioButton?new C(I):I.data.checkBox?new S(I):new x(I);case"Ch":return new E(I)}return new p(I);case i.AnnotationType.POPUP:return new T(I);case i.AnnotationType.FREETEXT:return new O(I);case i.AnnotationType.LINE:return new L(I);case i.AnnotationType.SQUARE:return new M(I);case i.AnnotationType.CIRCLE:return new k(I);case i.AnnotationType.POLYLINE:return new F(I);case i.AnnotationType.CARET:return new G(I);case i.AnnotationType.INK:return new ie(I);case i.AnnotationType.POLYGON:return new q(I);case i.AnnotationType.HIGHLIGHT:return new ee(I);case i.AnnotationType.UNDERLINE:return new Z(I);case i.AnnotationType.SQUIGGLY:return new X(I);case i.AnnotationType.STRIKEOUT:return new ce(I);case i.AnnotationType.STAMP:return new we(I);case i.AnnotationType.FILEATTACHMENT:return new ve(I);default:return new v(I)}}}class v{constructor(I,{isRenderable:$=!1,ignoreBorder:K=!1,createQuadrilaterals:ne=!1}={}){this.isRenderable=$,this.data=I.data,this.layer=I.layer,this.page=I.page,this.viewport=I.viewport,this.linkService=I.linkService,this.downloadManager=I.downloadManager,this.imageResourcesPath=I.imageResourcesPath,this.renderForms=I.renderForms,this.svgFactory=I.svgFactory,this.annotationStorage=I.annotationStorage,this.enableScripting=I.enableScripting,this.hasJSActions=I.hasJSActions,this._fieldObjects=I.fieldObjects,this._mouseState=I.mouseState,$&&(this.container=this._createContainer(K)),ne&&(this.quadrilaterals=this._createQuadrilaterals(K))}_createContainer(I=!1){let $=this.data,K=this.page,ne=this.viewport,re=document.createElement("section"),{width:de,height:Ee}=y($.rect),[je,ae,oe,le]=ne.viewBox,ye=oe-je,Oe=le-ae;re.setAttribute("data-annotation-id",$.id);let j=i.Util.normalizeRect([$.rect[0],K.view[3]-$.rect[1]+K.view[1],$.rect[2],K.view[3]-$.rect[3]+K.view[1]]);if(!I&&$.borderStyle.width>0){re.style.borderWidth=`${$.borderStyle.width}px`;let Se=$.borderStyle.horizontalCornerRadius,Re=$.borderStyle.verticalCornerRadius;if(Se>0||Re>0){let Ze=`calc(${Se}px * var(--scale-factor)) / calc(${Re}px * var(--scale-factor))`;re.style.borderRadius=Ze}else if(this instanceof C){let Ze=`calc(${de}px * var(--scale-factor)) / calc(${Ee}px * var(--scale-factor))`;re.style.borderRadius=Ze}switch($.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:re.style.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:re.style.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:re.style.borderBottomStyle="solid";break;default:break}let Le=$.borderColor||null;Le?re.style.borderColor=i.Util.makeHexColor(Le[0]|0,Le[1]|0,Le[2]|0):re.style.borderWidth=0}re.style.left=`${100*(j[0]-je)/ye}%`,re.style.top=`${100*(j[1]-ae)/Oe}%`;let{rotation:se}=$;return $.hasOwnCanvas||se===0?(re.style.width=`${100*de/ye}%`,re.style.height=`${100*Ee/Oe}%`):this.setRotation(se,re),re}setRotation(I,$=this.container){let[K,ne,re,de]=this.viewport.viewBox,Ee=re-K,je=de-ne,{width:ae,height:oe}=y(this.data.rect),le,ye;I%180==0?(le=100*ae/Ee,ye=100*oe/je):(le=100*oe/Ee,ye=100*ae/je),$.style.width=`${le}%`,$.style.height=`${ye}%`,$.setAttribute("data-main-rotation",(360-I)%360)}get _commonActions(){let I=($,K,ne)=>{let re=ne.detail[$];ne.target.style[K]=l.ColorConverters[`${re[0]}_HTML`](re.slice(1))};return(0,i.shadow)(this,"_commonActions",{display:$=>{let K=$.detail.display%2==1;this.container.style.visibility=K?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:K,print:$.detail.display===0||$.detail.display===3})},print:$=>{this.annotationStorage.setValue(this.data.id,{print:$.detail.print})},hidden:$=>{this.container.style.visibility=$.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:$.detail.hidden})},focus:$=>{setTimeout(()=>$.target.focus({preventScroll:!1}),0)},userName:$=>{$.target.title=$.detail.userName},readonly:$=>{$.detail.readonly?$.target.setAttribute("readonly",""):$.target.removeAttribute("readonly")},required:$=>{this._setRequired($.target,$.detail.required)},bgColor:$=>{I("bgColor","backgroundColor",$)},fillColor:$=>{I("fillColor","backgroundColor",$)},fgColor:$=>{I("fgColor","color",$)},textColor:$=>{I("textColor","color",$)},borderColor:$=>{I("borderColor","borderColor",$)},strokeColor:$=>{I("strokeColor","borderColor",$)},rotation:$=>{let K=$.detail.rotation;this.setRotation(K),this.annotationStorage.setValue(this.data.id,{rotation:K})}})}_dispatchEventFromSandbox(I,$){let K=this._commonActions;for(let ne of Object.keys($.detail)){let re=I[ne]||K[ne];re&&re($)}}_setDefaultPropertiesFromJS(I){if(!this.enableScripting)return;let $=this.annotationStorage.getRawValue(this.data.id);if(!$)return;let K=this._commonActions;for(let[ne,re]of Object.entries($)){let de=K[ne];if(de){let Ee={detail:{[ne]:re},target:I};de(Ee),delete $[ne]}}}_createQuadrilaterals(I=!1){if(!this.data.quadPoints)return null;let $=[],K=this.data.rect;for(let ne of this.data.quadPoints)this.data.rect=[ne[2].x,ne[2].y,ne[1].x,ne[1].y],$.push(this._createContainer(I));return this.data.rect=K,$}_createPopup(I,$){let K=this.container;this.quadrilaterals&&(I=I||this.quadrilaterals,K=this.quadrilaterals[0]),I||(I=document.createElement("div"),I.className="popupTriggerArea",K.append(I));let re=new R({container:K,trigger:I,color:$.color,titleObj:$.titleObj,modificationDate:$.modificationDate,contentsObj:$.contentsObj,richText:$.richText,hideWrapper:!0}).render();re.style.left="100%",K.append(re)}_renderQuadrilaterals(I){for(let $ of this.quadrilaterals)$.className=I;return this.quadrilaterals}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(I,$=null){let K=[];if(this._fieldObjects){let ne=this._fieldObjects[I];if(ne)for(let{page:re,id:de,exportValues:Ee}of ne){if(re===-1||de===$)continue;let je=typeof Ee=="string"?Ee:null,ae=document.querySelector(`[data-element-id="${de}"]`);if(ae&&!m.has(ae)){(0,i.warn)(`_getElementsByName - element not allowed: ${de}`);continue}K.push({id:de,exportValue:je,domElement:ae})}return K}for(let ne of document.getElementsByName(I)){let{id:re,exportValue:de}=ne;re!==$&&(!m.has(ne)||K.push({id:re,exportValue:de,domElement:ne}))}return K}static get platform(){let I=typeof navigator!="undefined"?navigator.platform:"";return(0,i.shadow)(this,"platform",{isWin:I.includes("Win"),isMac:I.includes("Mac")})}}class g extends v{constructor(I,$=null){super(I,{isRenderable:!0,ignoreBorder:!!$?.ignoreBorder,createQuadrilaterals:!0});this.isTooltipOnly=I.data.isTooltipOnly}render(){let{data:I,linkService:$}=this,K=document.createElement("a");K.setAttribute("data-element-id",I.id);let ne=!1;return I.url?($.addLinkAttributes(K,I.url,I.newWindow),ne=!0):I.action?(this._bindNamedAction(K,I.action),ne=!0):I.dest?(this._bindLink(K,I.dest),ne=!0):(I.actions&&(I.actions.Action||I.actions["Mouse Up"]||I.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(K,I),ne=!0),I.resetForm?(this._bindResetFormAction(K,I.resetForm),ne=!0):this.isTooltipOnly&&!ne&&(this._bindLink(K,""),ne=!0)),this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map((re,de)=>{let Ee=de===0?K:K.cloneNode();return re.append(Ee),re}):(this.container.className="linkAnnotation",ne&&this.container.append(K),this.container)}_bindLink(I,$){I.href=this.linkService.getDestinationHash($),I.onclick=()=>($&&this.linkService.goToDestination($),!1),($||$==="")&&(I.className="internalLink")}_bindNamedAction(I,$){I.href=this.linkService.getAnchorUrl(""),I.onclick=()=>(this.linkService.executeNamedAction($),!1),I.className="internalLink"}_bindJSAction(I,$){I.href=this.linkService.getAnchorUrl("");let K=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let ne of Object.keys($.actions)){let re=K.get(ne);!re||(I[re]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:$.id,name:ne}}),!1))}I.onclick||(I.onclick=()=>!1),I.className="internalLink"}_bindResetFormAction(I,$){let K=I.onclick;if(K||(I.href=this.linkService.getAnchorUrl("")),I.className="internalLink",!this._fieldObjects){(0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),K||(I.onclick=()=>!1);return}I.onclick=()=>{K&&K();let{fields:ne,refs:re,include:de}=$,Ee=[];if(ne.length!==0||re.length!==0){let oe=new Set(re);for(let le of ne){let ye=this._fieldObjects[le]||[];for(let{id:Oe}of ye)oe.add(Oe)}for(let le of Object.values(this._fieldObjects))for(let ye of le)oe.has(ye.id)===de&&Ee.push(ye)}else for(let oe of Object.values(this._fieldObjects))Ee.push(...oe);let je=this.annotationStorage,ae=[];for(let oe of Ee){let{id:le}=oe;switch(ae.push(le),oe.type){case"text":{let Oe=oe.defaultValue||"";je.setValue(le,{value:Oe});break}case"checkbox":case"radiobutton":{let Oe=oe.defaultValue===oe.exportValues;je.setValue(le,{value:Oe});break}case"combobox":case"listbox":{let Oe=oe.defaultValue||"";je.setValue(le,{value:Oe});break}default:continue}let ye=document.querySelector(`[data-element-id="${le}"]`);if(ye){if(!m.has(ye)){(0,i.warn)(`_bindResetFormAction - element not allowed: ${le}`);continue}}else continue;ye.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:ae,name:"ResetForm"}}),!1}}}class f extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$})}render(){this.container.className="textAnnotation";let I=document.createElement("img");return I.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",I.alt="[{{type}} Annotation]",I.dataset.l10nId="text_annotation_type",I.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.hasPopup||this._createPopup(I,this.data),this.container.append(I),this.container}}class p extends v{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}_getKeyModifier(I){let{isWin:$,isMac:K}=v.platform;return $&&I.ctrlKey||K&&I.metaKey}_setEventListener(I,$,K,ne){$.includes("mouse")?I.addEventListener($,re=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:K,value:ne(re),shift:re.shiftKey,modifier:this._getKeyModifier(re)}})}):I.addEventListener($,re=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:K,value:ne(re)}})})}_setEventListeners(I,$,K){for(let[ne,re]of $)(re==="Action"||this.data.actions?.[re])&&this._setEventListener(I,ne,re,K)}_setBackgroundColor(I){let $=this.data.backgroundColor||null;I.style.backgroundColor=$===null?"transparent":i.Util.makeHexColor($[0],$[1],$[2])}_setTextStyle(I){let $=["left","center","right"],{fontColor:K}=this.data.defaultAppearanceData,ne=this.data.defaultAppearanceData.fontSize||d,re=I.style,de;if(this.data.multiLine){let Ee=Math.abs(this.data.rect[3]-this.data.rect[1]),je=Math.round(Ee/(i.LINE_FACTOR*ne))||1,ae=Ee/je;de=Math.min(ne,Math.round(ae/i.LINE_FACTOR))}else{let Ee=Math.abs(this.data.rect[3]-this.data.rect[1]);de=Math.min(ne,Math.round(Ee/i.LINE_FACTOR))}re.fontSize=`calc(${de}px * var(--scale-factor))`,re.color=i.Util.makeHexColor(K[0],K[1],K[2]),this.data.textAlignment!==null&&(re.textAlign=$[this.data.textAlignment])}_setRequired(I,$){$?I.setAttribute("required",!0):I.removeAttribute("required"),I.setAttribute("aria-required",$)}}class b extends p{constructor(I){let $=I.renderForms||!I.data.hasAppearance&&!!I.data.fieldValue;super(I,{isRenderable:$})}setPropertyOnSiblings(I,$,K,ne){let re=this.annotationStorage;for(let de of this._getElementsByName(I.name,I.id))de.domElement&&(de.domElement[$]=K),re.setValue(de.id,{[ne]:K})}render(){let I=this.annotationStorage,$=this.data.id;this.container.className="textWidgetAnnotation";let K=null;if(this.renderForms){let ne=I.getValue($,{value:this.data.fieldValue}),re=ne.formattedValue||ne.value||"",de=I.getValue($,{charLimit:this.data.maxLen}).charLimit;de&&re.length>de&&(re=re.slice(0,de));let Ee={userValue:re,formattedValue:null,valueOnFocus:""};this.data.multiLine?(K=document.createElement("textarea"),K.textContent=re,this.data.doNotScroll&&(K.style.overflowY="hidden")):(K=document.createElement("input"),K.type="text",K.setAttribute("value",re),this.data.doNotScroll&&(K.style.overflowX="hidden")),m.add(K),K.setAttribute("data-element-id",$),K.disabled=this.data.readOnly,K.name=this.data.fieldName,K.tabIndex=u,this._setRequired(K,this.data.required),de&&(K.maxLength=de),K.addEventListener("input",ae=>{I.setValue($,{value:ae.target.value}),this.setPropertyOnSiblings(K,"value",ae.target.value,"value")}),K.addEventListener("resetform",ae=>{let oe=this.data.defaultFieldValue??"";K.value=Ee.userValue=oe,Ee.formattedValue=null});let je=ae=>{let{formattedValue:oe}=Ee;oe!=null&&(ae.target.value=oe),ae.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){K.addEventListener("focus",oe=>{Ee.userValue&&(oe.target.value=Ee.userValue),Ee.valueOnFocus=oe.target.value}),K.addEventListener("updatefromsandbox",oe=>{let le={value(ye){Ee.userValue=ye.detail.value??"",I.setValue($,{value:Ee.userValue.toString()}),ye.target.value=Ee.userValue},formattedValue(ye){let{formattedValue:Oe}=ye.detail;Ee.formattedValue=Oe,Oe!=null&&ye.target!==document.activeElement&&(ye.target.value=Oe),I.setValue($,{formattedValue:Oe})},selRange(ye){ye.target.setSelectionRange(...ye.detail.selRange)},charLimit:ye=>{let{charLimit:Oe}=ye.detail,{target:j}=ye;if(Oe===0){j.removeAttribute("maxLength");return}j.setAttribute("maxLength",Oe);let se=Ee.userValue;!se||se.length<=Oe||(se=se.slice(0,Oe),j.value=Ee.userValue=se,I.setValue($,{value:se}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:$,name:"Keystroke",value:se,willCommit:!0,commitKey:1,selStart:j.selectionStart,selEnd:j.selectionEnd}}))}};this._dispatchEventFromSandbox(le,oe)}),K.addEventListener("keydown",oe=>{let le=-1;if(oe.key==="Escape"?le=0:oe.key==="Enter"?le=2:oe.key==="Tab"&&(le=3),le===-1)return;let{value:ye}=oe.target;Ee.valueOnFocus!==ye&&(Ee.userValue=ye,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:$,name:"Keystroke",value:ye,willCommit:!0,commitKey:le,selStart:oe.target.selectionStart,selEnd:oe.target.selectionEnd}}))});let ae=je;je=null,K.addEventListener("blur",oe=>{let{value:le}=oe.target;Ee.userValue=le,this._mouseState.isDown&&Ee.valueOnFocus!==le&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:$,name:"Keystroke",value:le,willCommit:!0,commitKey:1,selStart:oe.target.selectionStart,selEnd:oe.target.selectionEnd}}),ae(oe)}),this.data.actions?.Keystroke&&K.addEventListener("beforeinput",oe=>{let{data:le,target:ye}=oe,{value:Oe,selectionStart:j,selectionEnd:se}=ye,Se=j,Re=se;switch(oe.inputType){case"deleteWordBackward":{let Le=Oe.substring(0,j).match(/\w*[^\w]*$/);Le&&(Se-=Le[0].length);break}case"deleteWordForward":{let Le=Oe.substring(j).match(/^[^\w]*\w*/);Le&&(Re+=Le[0].length);break}case"deleteContentBackward":j===se&&(Se-=1);break;case"deleteContentForward":j===se&&(Re+=1);break}oe.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:$,name:"Keystroke",value:Oe,change:le||"",willCommit:!1,selStart:Se,selEnd:Re}})}),this._setEventListeners(K,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],oe=>oe.target.value)}if(je&&K.addEventListener("blur",je),this.data.comb){let oe=(this.data.rect[2]-this.data.rect[0])/de;K.classList.add("comb"),K.style.letterSpacing=`calc(${oe}px * var(--scale-factor) - 1ch)`}}else K=document.createElement("div"),K.textContent=this.data.fieldValue,K.style.verticalAlign="middle",K.style.display="table-cell";return this._setTextStyle(K),this._setBackgroundColor(K),this._setDefaultPropertiesFromJS(K),this.container.append(K),this.container}}class S extends p{constructor(I){super(I,{isRenderable:I.renderForms})}render(){let I=this.annotationStorage,$=this.data,K=$.id,ne=I.getValue(K,{value:$.exportValue===$.fieldValue}).value;typeof ne=="string"&&(ne=ne!=="Off",I.setValue(K,{value:ne})),this.container.className="buttonWidgetAnnotation checkBox";let re=document.createElement("input");return m.add(re),re.setAttribute("data-element-id",K),re.disabled=$.readOnly,this._setRequired(re,this.data.required),re.type="checkbox",re.name=$.fieldName,ne&&re.setAttribute("checked",!0),re.setAttribute("exportValue",$.exportValue),re.tabIndex=u,re.addEventListener("change",de=>{let{name:Ee,checked:je}=de.target;for(let ae of this._getElementsByName(Ee,K)){let oe=je&&ae.exportValue===$.exportValue;ae.domElement&&(ae.domElement.checked=oe),I.setValue(ae.id,{value:oe})}I.setValue(K,{value:je})}),re.addEventListener("resetform",de=>{let Ee=$.defaultFieldValue||"Off";de.target.checked=Ee===$.exportValue}),this.enableScripting&&this.hasJSActions&&(re.addEventListener("updatefromsandbox",de=>{let Ee={value(je){je.target.checked=je.detail.value!=="Off",I.setValue(K,{value:je.target.checked})}};this._dispatchEventFromSandbox(Ee,de)}),this._setEventListeners(re,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],de=>de.target.checked)),this._setBackgroundColor(re),this._setDefaultPropertiesFromJS(re),this.container.append(re),this.container}}class C extends p{constructor(I){super(I,{isRenderable:I.renderForms})}render(){this.container.className="buttonWidgetAnnotation radioButton";let I=this.annotationStorage,$=this.data,K=$.id,ne=I.getValue(K,{value:$.fieldValue===$.buttonValue}).value;typeof ne=="string"&&(ne=ne!==$.buttonValue,I.setValue(K,{value:ne}));let re=document.createElement("input");if(m.add(re),re.setAttribute("data-element-id",K),re.disabled=$.readOnly,this._setRequired(re,this.data.required),re.type="radio",re.name=$.fieldName,ne&&re.setAttribute("checked",!0),re.tabIndex=u,re.addEventListener("change",de=>{let{name:Ee,checked:je}=de.target;for(let ae of this._getElementsByName(Ee,K))I.setValue(ae.id,{value:!1});I.setValue(K,{value:je})}),re.addEventListener("resetform",de=>{let Ee=$.defaultFieldValue;de.target.checked=Ee!=null&&Ee===$.buttonValue}),this.enableScripting&&this.hasJSActions){let de=$.buttonValue;re.addEventListener("updatefromsandbox",Ee=>{let je={value:ae=>{let oe=de===ae.detail.value;for(let le of this._getElementsByName(ae.target.name)){let ye=oe&&le.id===K;le.domElement&&(le.domElement.checked=ye),I.setValue(le.id,{value:ye})}}};this._dispatchEventFromSandbox(je,Ee)}),this._setEventListeners(re,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],Ee=>Ee.target.checked)}return this._setBackgroundColor(re),this._setDefaultPropertiesFromJS(re),this.container.append(re),this.container}}class x extends g{constructor(I){super(I,{ignoreBorder:I.data.hasAppearance})}render(){let I=super.render();I.className="buttonWidgetAnnotation pushButton",this.data.alternativeText&&(I.title=this.data.alternativeText);let $=I.lastChild;return this.enableScripting&&this.hasJSActions&&$&&(this._setDefaultPropertiesFromJS($),$.addEventListener("updatefromsandbox",K=>{this._dispatchEventFromSandbox({},K)})),I}}class E extends p{constructor(I){super(I,{isRenderable:I.renderForms})}render(){this.container.className="choiceWidgetAnnotation";let I=this.annotationStorage,$=this.data.id,K=I.getValue($,{value:this.data.fieldValue}),ne=document.createElement("select");m.add(ne),ne.setAttribute("data-element-id",$),ne.disabled=this.data.readOnly,this._setRequired(ne,this.data.required),ne.name=this.data.fieldName,ne.tabIndex=u;let re=this.data.combo&&this.data.options.length>0;this.data.combo||(ne.size=this.data.options.length,this.data.multiSelect&&(ne.multiple=!0)),ne.addEventListener("resetform",ae=>{let oe=this.data.defaultFieldValue;for(let le of ne.options)le.selected=le.value===oe});for(let ae of this.data.options){let oe=document.createElement("option");oe.textContent=ae.displayValue,oe.value=ae.exportValue,K.value.includes(ae.exportValue)&&(oe.setAttribute("selected",!0),re=!1),ne.append(oe)}let de=null;if(re){let ae=document.createElement("option");ae.value=" ",ae.setAttribute("hidden",!0),ae.setAttribute("selected",!0),ne.prepend(ae),de=()=>{ae.remove(),ne.removeEventListener("input",de),de=null},ne.addEventListener("input",de)}let Ee=(ae,oe)=>{let le=oe?"value":"textContent",ye=ae.target.options;return ae.target.multiple?Array.prototype.filter.call(ye,Oe=>Oe.selected).map(Oe=>Oe[le]):ye.selectedIndex===-1?null:ye[ye.selectedIndex][le]},je=ae=>{let oe=ae.target.options;return Array.prototype.map.call(oe,le=>({displayValue:le.textContent,exportValue:le.value}))};return this.enableScripting&&this.hasJSActions?(ne.addEventListener("updatefromsandbox",ae=>{let oe={value(le){de?.();let ye=le.detail.value,Oe=new Set(Array.isArray(ye)?ye:[ye]);for(let j of ne.options)j.selected=Oe.has(j.value);I.setValue($,{value:Ee(le,!0)})},multipleSelection(le){ne.multiple=!0},remove(le){let ye=ne.options,Oe=le.detail.remove;ye[Oe].selected=!1,ne.remove(Oe),ye.length>0&&Array.prototype.findIndex.call(ye,se=>se.selected)===-1&&(ye[0].selected=!0),I.setValue($,{value:Ee(le,!0),items:je(le)})},clear(le){for(;ne.length!==0;)ne.remove(0);I.setValue($,{value:null,items:[]})},insert(le){let{index:ye,displayValue:Oe,exportValue:j}=le.detail.insert,se=ne.children[ye],Se=document.createElement("option");Se.textContent=Oe,Se.value=j,se?se.before(Se):ne.append(Se),I.setValue($,{value:Ee(le,!0),items:je(le)})},items(le){let{items:ye}=le.detail;for(;ne.length!==0;)ne.remove(0);for(let Oe of ye){let{displayValue:j,exportValue:se}=Oe,Se=document.createElement("option");Se.textContent=j,Se.value=se,ne.append(Se)}ne.options.length>0&&(ne.options[0].selected=!0),I.setValue($,{value:Ee(le,!0),items:je(le)})},indices(le){let ye=new Set(le.detail.indices);for(let Oe of le.target.options)Oe.selected=ye.has(Oe.index);I.setValue($,{value:Ee(le,!0)})},editable(le){le.target.disabled=!le.detail.editable}};this._dispatchEventFromSandbox(oe,ae)}),ne.addEventListener("input",ae=>{let oe=Ee(ae,!0),le=Ee(ae,!1);I.setValue($,{value:oe}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:$,name:"Keystroke",value:le,changeEx:oe,willCommit:!0,commitKey:1,keyDown:!1}})}),this._setEventListeners(ne,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"]],ae=>ae.target.checked)):ne.addEventListener("input",function(ae){I.setValue($,{value:Ee(ae,!0)})}),this.data.combo&&this._setTextStyle(ne),this._setBackgroundColor(ne),this._setDefaultPropertiesFromJS(ne),this.container.append(ne),this.container}}class T extends v{constructor(I){let $=!!(I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$})}render(){let I=["Line","Square","Circle","PolyLine","Polygon","Ink"];if(this.container.className="popupAnnotation",I.includes(this.data.parentType))return this.container;let $=`[data-annotation-id="${this.data.parentId}"]`,K=this.layer.querySelectorAll($);if(K.length===0)return this.container;let ne=new R({container:this.container,trigger:Array.from(K),color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText}),re=this.page,de=i.Util.normalizeRect([this.data.parentRect[0],re.view[3]-this.data.parentRect[1]+re.view[1],this.data.parentRect[2],re.view[3]-this.data.parentRect[3]+re.view[1]]),Ee=de[0]+this.data.parentRect[2]-this.data.parentRect[0],je=de[1],[ae,oe,le,ye]=this.viewport.viewBox,Oe=le-ae,j=ye-oe;return this.container.style.left=`${100*(Ee-ae)/Oe}%`,this.container.style.top=`${100*(je-oe)/j}%`,this.container.append(ne.render()),this.container}}class R{constructor(I){this.container=I.container,this.trigger=I.trigger,this.color=I.color,this.titleObj=I.titleObj,this.modificationDate=I.modificationDate,this.contentsObj=I.contentsObj,this.richText=I.richText,this.hideWrapper=I.hideWrapper||!1,this.pinned=!1}render(){let I=.7,$=document.createElement("div");$.className="popupWrapper",this.hideElement=this.hideWrapper?$:this.container,this.hideElement.hidden=!0;let K=document.createElement("div");K.className="popup";let ne=this.color;if(ne){let Ee=I*(255-ne[0])+ne[0],je=I*(255-ne[1])+ne[1],ae=I*(255-ne[2])+ne[2];K.style.backgroundColor=i.Util.makeHexColor(Ee|0,je|0,ae|0)}let re=document.createElement("h1");re.dir=this.titleObj.dir,re.textContent=this.titleObj.str,K.append(re);let de=o.PDFDateString.toDateObject(this.modificationDate);if(de){let Ee=document.createElement("span");Ee.className="popupDate",Ee.textContent="{{date}}, {{time}}",Ee.dataset.l10nId="annotation_date_string",Ee.dataset.l10nArgs=JSON.stringify({date:de.toLocaleDateString(),time:de.toLocaleTimeString()}),K.append(Ee)}if(this.richText?.str&&(!this.contentsObj?.str||this.contentsObj.str===this.richText.str))h.XfaLayer.render({xfaHtml:this.richText.html,intent:"richText",div:K}),K.lastChild.className="richText popupContent";else{let Ee=this._formatContents(this.contentsObj);K.append(Ee)}Array.isArray(this.trigger)||(this.trigger=[this.trigger]);for(let Ee of this.trigger)Ee.addEventListener("click",this._toggle.bind(this)),Ee.addEventListener("mouseover",this._show.bind(this,!1)),Ee.addEventListener("mouseout",this._hide.bind(this,!1));return K.addEventListener("click",this._hide.bind(this,!0)),$.append(K),$}_formatContents({str:I,dir:$}){let K=document.createElement("p");K.className="popupContent",K.dir=$;let ne=I.split(/(?:\r\n?|\n)/);for(let re=0,de=ne.length;re<de;++re){let Ee=ne[re];K.append(document.createTextNode(Ee)),re<de-1&&K.append(document.createElement("br"))}return K}_toggle(){this.pinned?this._hide(!0):this._show(!0)}_show(I=!1){I&&(this.pinned=!0),this.hideElement.hidden&&(this.hideElement.hidden=!1,this.container.style.zIndex=parseInt(this.container.style.zIndex)+1e3)}_hide(I=!0){I&&(this.pinned=!1),!this.hideElement.hidden&&!this.pinned&&(this.hideElement.hidden=!0,this.container.style.zIndex=parseInt(this.container.style.zIndex)-1e3)}}class O extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0});this.textContent=I.data.textContent}render(){if(this.container.className="freeTextAnnotation",this.textContent){let I=document.createElement("div");I.className="annotationTextContent",I.setAttribute("role","comment");for(let $ of this.textContent){let K=document.createElement("span");K.textContent=$,I.append(K)}this.container.append(I)}return this.data.hasPopup||this._createPopup(null,this.data),this.container}}class L extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0})}render(){this.container.className="lineAnnotation";let I=this.data,{width:$,height:K}=y(I.rect),ne=this.svgFactory.create($,K,!0),re=this.svgFactory.createElement("svg:line");return re.setAttribute("x1",I.rect[2]-I.lineCoordinates[0]),re.setAttribute("y1",I.rect[3]-I.lineCoordinates[1]),re.setAttribute("x2",I.rect[2]-I.lineCoordinates[2]),re.setAttribute("y2",I.rect[3]-I.lineCoordinates[3]),re.setAttribute("stroke-width",I.borderStyle.width||1),re.setAttribute("stroke","transparent"),re.setAttribute("fill","transparent"),ne.append(re),this.container.append(ne),this._createPopup(re,I),this.container}}class M extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0})}render(){this.container.className="squareAnnotation";let I=this.data,{width:$,height:K}=y(I.rect),ne=this.svgFactory.create($,K,!0),re=I.borderStyle.width,de=this.svgFactory.createElement("svg:rect");return de.setAttribute("x",re/2),de.setAttribute("y",re/2),de.setAttribute("width",$-re),de.setAttribute("height",K-re),de.setAttribute("stroke-width",re||1),de.setAttribute("stroke","transparent"),de.setAttribute("fill","transparent"),ne.append(de),this.container.append(ne),this._createPopup(de,I),this.container}}class k extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0})}render(){this.container.className="circleAnnotation";let I=this.data,{width:$,height:K}=y(I.rect),ne=this.svgFactory.create($,K,!0),re=I.borderStyle.width,de=this.svgFactory.createElement("svg:ellipse");return de.setAttribute("cx",$/2),de.setAttribute("cy",K/2),de.setAttribute("rx",$/2-re/2),de.setAttribute("ry",K/2-re/2),de.setAttribute("stroke-width",re||1),de.setAttribute("stroke","transparent"),de.setAttribute("fill","transparent"),ne.append(de),this.container.append(ne),this._createPopup(de,I),this.container}}class F extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0});this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;let I=this.data,{width:$,height:K}=y(I.rect),ne=this.svgFactory.create($,K,!0),re=[];for(let Ee of I.vertices){let je=Ee.x-I.rect[0],ae=I.rect[3]-Ee.y;re.push(je+","+ae)}re=re.join(" ");let de=this.svgFactory.createElement(this.svgElementName);return de.setAttribute("points",re),de.setAttribute("stroke-width",I.borderStyle.width||1),de.setAttribute("stroke","transparent"),de.setAttribute("fill","transparent"),ne.append(de),this.container.append(ne),this._createPopup(de,I),this.container}}class q extends F{constructor(I){super(I);this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class G extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0})}render(){return this.container.className="caretAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class ie extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0});this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;let I=this.data,{width:$,height:K}=y(I.rect),ne=this.svgFactory.create($,K,!0);for(let re of I.inkLists){let de=[];for(let je of re){let ae=je.x-I.rect[0],oe=I.rect[3]-je.y;de.push(`${ae},${oe}`)}de=de.join(" ");let Ee=this.svgFactory.createElement(this.svgElementName);Ee.setAttribute("points",de),Ee.setAttribute("stroke-width",I.borderStyle.width||1),Ee.setAttribute("stroke","transparent"),Ee.setAttribute("fill","transparent"),this._createPopup(Ee,I),ne.append(Ee)}return this.container.append(ne),this.container}}class ee extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,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 Z extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,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 X extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,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 ce extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,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 we extends v{constructor(I){let $=!!(I.data.hasPopup||I.data.titleObj?.str||I.data.contentsObj?.str||I.data.richText?.str);super(I,{isRenderable:$,ignoreBorder:!0})}render(){return this.container.className="stampAnnotation",this.data.hasPopup||this._createPopup(null,this.data),this.container}}class ve extends v{constructor(I){super(I,{isRenderable:!0});let{filename:$,content:K}=this.data.file;this.filename=(0,o.getFilenameFromUrl)($),this.content=K,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,filename:$,content:K})}render(){this.container.className="fileAttachmentAnnotation";let I=document.createElement("div");return I.className="popupTriggerArea",I.addEventListener("dblclick",this._download.bind(this)),!this.data.hasPopup&&(this.data.titleObj?.str||this.data.contentsObj?.str||this.data.richText)&&this._createPopup(I,this.data),this.container.append(I),this.container}_download(){this.downloadManager?.openOrDownloadData(this.container,this.content,this.filename)}}let he=class{static render(I){var Ee,je;let{annotations:$,div:K,viewport:ne,accessibilityManager:re}=I;De(this,D,Bx).call(this,K,ne);let de=0;for(let ae of $){if(ae.annotationType!==i.AnnotationType.POPUP){let{width:le,height:ye}=y(ae.rect);if(le<=0||ye<=0)continue}let oe=w.create({data:ae,layer:K,page:I.page,viewport:ne,linkService:I.linkService,downloadManager:I.downloadManager,imageResourcesPath:I.imageResourcesPath||"",renderForms:I.renderForms!==!1,svgFactory:new o.DOMSVGFactory,annotationStorage:I.annotationStorage||new s.AnnotationStorage,enableScripting:I.enableScripting,hasJSActions:I.hasJSActions,fieldObjects:I.fieldObjects,mouseState:I.mouseState||{isDown:!1}});if(oe.isRenderable){let le=oe.render();if(ae.hidden&&(le.style.visibility="hidden"),Array.isArray(le))for(let ye of le)ye.style.zIndex=de++,De(Ee=he,N,Lx).call(Ee,ye,ae.id,K,re);else le.style.zIndex=de++,oe instanceof T?K.prepend(le):De(je=he,N,Lx).call(je,le,ae.id,K,re)}}De(this,z,Nx).call(this,K,I.annotationCanvasMap)}static update(I){let{annotationCanvasMap:$,div:K,viewport:ne}=I;De(this,D,Bx).call(this,K,ne),De(this,z,Nx).call(this,K,$),K.hidden=!1}},Q=he;N=new WeakSet,Lx=function(I,$,K,ne){let re=I.firstChild||I;re.id=`${o.AnnotationPrefix}${$}`,K.append(I),ne?.moveElementInDOM(K,I,re,!1)},D=new WeakSet,Bx=function(I,{width:$,height:K,rotation:ne}){let{style:re}=I,de=ne%180!=0,Ee=Math.floor($)+"px",je=Math.floor(K)+"px";re.width=de?je:Ee,re.height=de?Ee:je,I.setAttribute("data-main-rotation",ne)},z=new WeakSet,Nx=function(I,$){if(!!$){for(let[K,ne]of $){let re=I.querySelector(`[data-annotation-id="${K}"]`);if(!re)continue;let{firstChild:de}=re;de?de.nodeName==="CANVAS"?de.replaceWith(ne):de.before(ne):re.append(ne)}$.clear()}},ke(Q,N),ke(Q,D),ke(Q,z),t.AnnotationLayer=Q},(r,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorConverters=void 0;function n(o){return Math.floor(Math.max(0,Math.min(1,o))*255).toString(16).padStart(2,"0")}class i{static CMYK_G([s,l,h,u]){return["G",1-Math.min(1,.3*s+.59*h+.11*l+u)]}static G_CMYK([s]){return["CMYK",0,0,0,1-s]}static G_RGB([s]){return["RGB",s,s,s]}static G_HTML([s]){let l=n(s);return`#${l}${l}${l}`}static RGB_G([s,l,h]){return["G",.3*s+.59*l+.11*h]}static RGB_HTML([s,l,h]){let u=n(s),d=n(l),m=n(h);return`#${u}${d}${m}`}static T_HTML(){return"#00000000"}static CMYK_RGB([s,l,h,u]){return["RGB",1-Math.min(1,s+u),1-Math.min(1,h+u),1-Math.min(1,l+u)]}static CMYK_HTML(s){let l=this.CMYK_RGB(s).slice(1);return this.RGB_HTML(l)}static RGB_CMYK([s,l,h]){let u=1-s,d=1-l,m=1-h,y=Math.min(u,d,m);return["CMYK",u,d,m,y]}}t.ColorConverters=i},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaLayer=void 0;var i=n(20);class o{static setupStorage(l,h,u,d,m){let y=d.getValue(h,{value:null});switch(u.name){case"textarea":if(y.value!==null&&(l.textContent=y.value),m==="print")break;l.addEventListener("input",w=>{d.setValue(h,{value:w.target.value})});break;case"input":if(u.attributes.type==="radio"||u.attributes.type==="checkbox"){if(y.value===u.attributes.xfaOn?l.setAttribute("checked",!0):y.value===u.attributes.xfaOff&&l.removeAttribute("checked"),m==="print")break;l.addEventListener("change",w=>{d.setValue(h,{value:w.target.checked?w.target.getAttribute("xfaOn"):w.target.getAttribute("xfaOff")})})}else{if(y.value!==null&&l.setAttribute("value",y.value),m==="print")break;l.addEventListener("input",w=>{d.setValue(h,{value:w.target.value})})}break;case"select":if(y.value!==null)for(let w of u.children)w.attributes.value===y.value&&(w.attributes.selected=!0);l.addEventListener("input",w=>{let v=w.target.options,g=v.selectedIndex===-1?"":v[v.selectedIndex].value;d.setValue(h,{value:g})});break}}static setAttributes({html:l,element:h,storage:u=null,intent:d,linkService:m}){let{attributes:y}=h,w=l instanceof HTMLAnchorElement;y.type==="radio"&&(y.name=`${y.name}-${d}`);for(let[v,g]of Object.entries(y))if(g!=null)switch(v){case"class":g.length&&l.setAttribute(v,g.join(" "));break;case"dataId":break;case"id":l.setAttribute("data-element-id",g);break;case"style":Object.assign(l.style,g);break;case"textContent":l.textContent=g;break;default:(!w||v!=="href"&&v!=="newWindow")&&l.setAttribute(v,g)}w&&m.addLinkAttributes(l,y.href,y.newWindow),u&&y.dataId&&this.setupStorage(l,y.dataId,h,u)}static render(l){let h=l.annotationStorage,u=l.linkService,d=l.xfaHtml,m=l.intent||"display",y=document.createElement(d.name);d.attributes&&this.setAttributes({html:y,element:d,intent:m,linkService:u});let w=[[d,-1,y]],v=l.div;if(v.append(y),l.viewport){let f=`matrix(${l.viewport.transform.join(",")})`;v.style.transform=f}m!=="richText"&&v.setAttribute("class","xfaLayer xfaFont");let g=[];for(;w.length>0;){let[f,p,b]=w.at(-1);if(p+1===f.children.length){w.pop();continue}let S=f.children[++w.at(-1)[1]];if(S===null)continue;let{name:C}=S;if(C==="#text"){let E=document.createTextNode(S.value);g.push(E),b.append(E);continue}let x;if(S?.attributes?.xmlns?x=document.createElementNS(S.attributes.xmlns,C):x=document.createElement(C),b.append(x),S.attributes&&this.setAttributes({html:x,element:S,storage:h,intent:m,linkService:u}),S.children&&S.children.length>0)w.push([S,-1,x]);else if(S.value){let E=document.createTextNode(S.value);i.XfaText.shouldBuildText(C)&&g.push(E),x.append(E)}}for(let f of v.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))f.setAttribute("readOnly",!0);return{textDivs:g}}static update(l){let h=`matrix(${l.viewport.transform.join(",")})`;l.div.style.transform=h,l.div.hidden=!1}}t.XfaLayer=o},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextLayerRenderTask=void 0,t.renderTextLayer=S;var i=n(1),o=n(8);let s=1e5,l=30,h=.8,u=new Map,d=/^\s+$/g;function m(C,x){let E=u.get(C);if(E)return E;x.save(),x.font=`${l}px ${C}`;let T=x.measureText(""),R=T.fontBoundingBoxAscent,O=Math.abs(T.fontBoundingBoxDescent);if(R){x.restore();let M=R/(R+O);return u.set(C,M),M}x.strokeStyle="red",x.clearRect(0,0,l,l),x.strokeText("g",0,0);let L=x.getImageData(0,0,l,l).data;O=0;for(let M=L.length-1-3;M>=0;M-=4)if(L[M]>0){O=Math.ceil(M/4/l);break}x.clearRect(0,0,l,l),x.strokeText("A",0,l),L=x.getImageData(0,0,l,l).data,R=0;for(let M=0,k=L.length;M<k;M+=4)if(L[M]>0){R=l-Math.floor(M/4/l);break}if(x.restore(),R){let M=R/(R+O);return u.set(C,M),M}return u.set(C,h),h}function y(C,x,E,T){let R=document.createElement("span"),O=C._enhanceTextSelection?{angle:0,canvasWidth:0,hasText:x.str!=="",hasEOL:x.hasEOL,originalTransform:null,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,scale:1,fontSize:0}:{angle:0,canvasWidth:0,hasText:x.str!=="",hasEOL:x.hasEOL,fontSize:0};C._textDivs.push(R);let L=i.Util.transform(C._viewport.transform,x.transform),M=Math.atan2(L[1],L[0]),k=E[x.fontName];k.vertical&&(M+=Math.PI/2);let F=Math.hypot(L[2],L[3]),q=F*m(k.fontFamily,T),G,ie;M===0?(G=L[4],ie=L[5]-q):(G=L[4]+q*Math.sin(M),ie=L[5]-q*Math.cos(M)),R.style.left=`${G}px`,R.style.top=`${ie}px`,R.style.fontSize=`${F}px`,R.style.fontFamily=k.fontFamily,O.fontSize=F,R.setAttribute("role","presentation"),R.textContent=x.str,R.dir=x.dir,C._fontInspectorEnabled&&(R.dataset.fontName=x.fontName),M!==0&&(O.angle=M*(180/Math.PI));let ee=!1;if(x.str.length>1||C._enhanceTextSelection&&d.test(x.str))ee=!0;else if(x.str!==" "&&x.transform[0]!==x.transform[3]){let Z=Math.abs(x.transform[0]),X=Math.abs(x.transform[3]);Z!==X&&Math.max(Z,X)/Math.min(Z,X)>1.5&&(ee=!0)}if(ee&&(k.vertical?O.canvasWidth=x.height*C._viewport.scale:O.canvasWidth=x.width*C._viewport.scale),C._textDivProperties.set(R,O),C._textContentStream&&C._layoutText(R),C._enhanceTextSelection&&O.hasText){let Z=1,X=0;M!==0&&(Z=Math.cos(M),X=Math.sin(M));let ce=(k.vertical?x.height:x.width)*C._viewport.scale,we=F,ve,Q;M!==0?(ve=[Z,X,-X,Z,G,ie],Q=i.Util.getAxialAlignedBoundingBox([0,0,ce,we],ve)):Q=[G,ie,G+ce,ie+we],C._bounds.push({left:Q[0],top:Q[1],right:Q[2],bottom:Q[3],div:R,size:[ce,we],m:ve})}}function w(C){if(C._canceled)return;let x=C._textDivs,E=C._capability,T=x.length;if(T>s){C._renderingDone=!0,E.resolve();return}if(!C._textContentStream)for(let R=0;R<T;R++)C._layoutText(x[R]);C._renderingDone=!0,E.resolve()}function v(C,x,E){let T=0;for(let R=0;R<E;R++){let O=C[x++];O>0&&(T=T?Math.min(O,T):O)}return T}function g(C){let x=C._bounds,E=C._viewport,T=f(E.width,E.height,x);for(let R=0;R<T.length;R++){let O=x[R].div,L=C._textDivProperties.get(O);if(L.angle===0){L.paddingLeft=x[R].left-T[R].left,L.paddingTop=x[R].top-T[R].top,L.paddingRight=T[R].right-x[R].right,L.paddingBottom=T[R].bottom-x[R].bottom,C._textDivProperties.set(O,L);continue}let M=T[R],k=x[R],F=k.m,q=F[0],G=F[1],ie=[[0,0],[0,k.size[1]],[k.size[0],0],k.size],ee=new Float64Array(64);for(let X=0,ce=ie.length;X<ce;X++){let we=i.Util.applyTransform(ie[X],F);ee[X+0]=q&&(M.left-we[0])/q,ee[X+4]=G&&(M.top-we[1])/G,ee[X+8]=q&&(M.right-we[0])/q,ee[X+12]=G&&(M.bottom-we[1])/G,ee[X+16]=G&&(M.left-we[0])/-G,ee[X+20]=q&&(M.top-we[1])/q,ee[X+24]=G&&(M.right-we[0])/-G,ee[X+28]=q&&(M.bottom-we[1])/q,ee[X+32]=q&&(M.left-we[0])/-q,ee[X+36]=G&&(M.top-we[1])/-G,ee[X+40]=q&&(M.right-we[0])/-q,ee[X+44]=G&&(M.bottom-we[1])/-G,ee[X+48]=G&&(M.left-we[0])/G,ee[X+52]=q&&(M.top-we[1])/-q,ee[X+56]=G&&(M.right-we[0])/G,ee[X+60]=q&&(M.bottom-we[1])/-q}let Z=1+Math.min(Math.abs(q),Math.abs(G));L.paddingLeft=v(ee,32,16)/Z,L.paddingTop=v(ee,48,16)/Z,L.paddingRight=v(ee,0,16)/Z,L.paddingBottom=v(ee,16,16)/Z,C._textDivProperties.set(O,L)}}function f(C,x,E){let T=E.map(function(O,L){return{x1:O.left,y1:O.top,x2:O.right,y2:O.bottom,index:L,x1New:void 0,x2New:void 0}});p(C,T);let R=new Array(E.length);for(let O of T){let L=O.index;R[L]={left:O.x1New,top:0,right:O.x2New,bottom:0}}E.map(function(O,L){let M=R[L],k=T[L];k.x1=O.top,k.y1=C-M.right,k.x2=O.bottom,k.y2=C-M.left,k.index=L,k.x1New=void 0,k.x2New=void 0}),p(x,T);for(let O of T){let L=O.index;R[L].top=O.x1New,R[L].bottom=O.x2New}return R}function p(C,x){x.sort(function(R,O){return R.x1-O.x1||R.index-O.index});let T=[{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(let R of x){let O=0;for(;O<T.length&&T[O].end<=R.y1;)O++;let L=T.length-1;for(;L>=0&&T[L].start>=R.y2;)L--;let M,k,F,q,G=-1/0;for(F=O;F<=L;F++){M=T[F],k=M.boundary;let Z;k.x2>R.x1?Z=k.index>R.index?k.x1New:R.x1:k.x2New===void 0?Z=(k.x2+R.x1)/2:Z=k.x2New,Z>G&&(G=Z)}for(R.x1New=G,F=O;F<=L;F++)M=T[F],k=M.boundary,k.x2New===void 0?k.x2>R.x1?k.index>R.index&&(k.x2New=k.x2):k.x2New=G:k.x2New>G&&(k.x2New=Math.max(G,k.x2));let ie=[],ee=null;for(F=O;F<=L;F++){M=T[F],k=M.boundary;let Z=k.x2>R.x2?k:R;ee===Z?ie.at(-1).end=M.end:(ie.push({start:M.start,end:M.end,boundary:Z}),ee=Z)}for(T[O].start<R.y1&&(ie[0].start=R.y1,ie.unshift({start:T[O].start,end:R.y1,boundary:T[O].boundary})),R.y2<T[L].end&&(ie.at(-1).end=R.y2,ie.push({start:R.y2,end:T[L].end,boundary:T[L].boundary})),F=O;F<=L;F++){if(M=T[F],k=M.boundary,k.x2New!==void 0)continue;let Z=!1;for(q=O-1;!Z&&q>=0&&T[q].start>=k.y1;q--)Z=T[q].boundary===k;for(q=L+1;!Z&&q<T.length&&T[q].end<=k.y2;q++)Z=T[q].boundary===k;for(q=0;!Z&&q<ie.length;q++)Z=ie[q].boundary===k;Z||(k.x2New=G)}Array.prototype.splice.apply(T,[O,L-O+1,...ie])}for(let R of T){let O=R.boundary;O.x2New===void 0&&(O.x2New=Math.max(C,O.x2))}}class b{constructor({textContent:x,textContentStream:E,container:T,viewport:R,textDivs:O,textContentItemsStr:L,enhanceTextSelection:M}){M&&(0,o.deprecated)("The `enhanceTextSelection` functionality will be removed in the future."),this._textContent=x,this._textContentStream=E,this._container=T,this._document=T.ownerDocument,this._viewport=R,this._textDivs=O||[],this._textContentItemsStr=L||[],this._enhanceTextSelection=!!M,this._fontInspectorEnabled=!!globalThis.FontInspector?.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,i.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 i.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(x,E){for(let T=0,R=x.length;T<R;T++){if(x[T].str===void 0){if(x[T].type==="beginMarkedContentProps"||x[T].type==="beginMarkedContent"){let O=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),x[T].id!==null&&this._container.setAttribute("id",`${x[T].id}`),O.append(this._container)}else x[T].type==="endMarkedContent"&&(this._container=this._container.parentNode);continue}this._textContentItemsStr.push(x[T].str),y(this,x[T],E,this._layoutTextCtx)}}_layoutText(x){let E=this._textDivProperties.get(x),T="";if(E.canvasWidth!==0&&E.hasText){let{fontFamily:R}=x.style,{fontSize:O}=E;(O!==this._layoutTextLastFontSize||R!==this._layoutTextLastFontFamily)&&(this._layoutTextCtx.font=`${O*this._devicePixelRatio}px ${R}`,this._layoutTextLastFontSize=O,this._layoutTextLastFontFamily=R);let{width:L}=this._layoutTextCtx.measureText(x.textContent);if(L>0){let M=this._devicePixelRatio*E.canvasWidth/L;this._enhanceTextSelection&&(E.scale=M),T=`scaleX(${M})`}}if(E.angle!==0&&(T=`rotate(${E.angle}deg) ${T}`),T.length>0&&(this._enhanceTextSelection&&(E.originalTransform=T),x.style.transform=T),E.hasText&&this._container.append(x),E.hasEOL){let R=document.createElement("br");R.setAttribute("role","presentation"),this._container.append(R)}}_render(x=0){let E=(0,i.createPromiseCapability)(),T=Object.create(null),R=this._document.createElement("canvas");if(R.height=R.width=l,this._layoutTextCtx=R.getContext("2d",{alpha:!1}),this._textContent){let O=this._textContent.items,L=this._textContent.styles;this._processItems(O,L),E.resolve()}else if(this._textContentStream){let O=()=>{this._reader.read().then(({value:L,done:M})=>{if(M){E.resolve();return}Object.assign(T,L.styles),this._processItems(L.items,T),O()},E.reject)};this._reader=this._textContentStream.getReader(),O()}else throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');E.promise.then(()=>{T=null,x?this._renderTimer=setTimeout(()=>{w(this),this._renderTimer=null},x):w(this)},this._capability.reject)}expandTextDivs(x=!1){if(!this._enhanceTextSelection||!this._renderingDone)return;this._bounds!==null&&(g(this),this._bounds=null);let E=[],T=[];for(let R=0,O=this._textDivs.length;R<O;R++){let L=this._textDivs[R],M=this._textDivProperties.get(L);!M.hasText||(x?(E.length=0,T.length=0,M.originalTransform&&E.push(M.originalTransform),M.paddingTop>0?(T.push(`${M.paddingTop}px`),E.push(`translateY(${-M.paddingTop}px)`)):T.push(0),M.paddingRight>0?T.push(`${M.paddingRight/M.scale}px`):T.push(0),M.paddingBottom>0?T.push(`${M.paddingBottom}px`):T.push(0),M.paddingLeft>0?(T.push(`${M.paddingLeft/M.scale}px`),E.push(`translateX(${-M.paddingLeft/M.scale}px)`)):T.push(0),L.style.padding=T.join(" "),E.length&&(L.style.transform=E.join(" "))):(L.style.padding=null,L.style.transform=M.originalTransform))}}}t.TextLayerRenderTask=b;function S(C){let x=new b({textContent:C.textContent,textContentStream:C.textContentStream,container:C.container,viewport:C.viewport,textDivs:C.textDivs,textContentItemsStr:C.textContentItemsStr,enhanceTextSelection:C.enhanceTextSelection});return x._render(C.timeout),x}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SVGGraphics=void 0;var i=n(8),o=n(1),s=n(3);let l=class{constructor(){(0,o.unreachable)("Not implemented: SVGGraphics")}};t.SVGGraphics=l;{let f=function(E){let T=[],R=[];for(let O of E){if(O.fn==="save"){T.push({fnId:92,fn:"group",items:[]}),R.push(T),T=T.at(-1).items;continue}O.fn==="restore"?T=R.pop():T.push(O)}return T},p=function(E){if(Number.isInteger(E))return E.toString();let T=E.toFixed(10),R=T.length-1;if(T[R]!=="0")return T;do R--;while(T[R]==="0");return T.substring(0,T[R]==="."?R:R+1)},b=function(E){if(E[4]===0&&E[5]===0){if(E[1]===0&&E[2]===0)return E[0]===1&&E[3]===1?"":`scale(${p(E[0])} ${p(E[3])})`;if(E[0]===E[3]&&E[1]===-E[2]){let T=Math.acos(E[0])*180/Math.PI;return`rotate(${p(T)})`}}else if(E[0]===1&&E[1]===0&&E[2]===0&&E[3]===1)return`translate(${p(E[4])} ${p(E[5])})`;return`matrix(${p(E[0])} ${p(E[1])} ${p(E[2])} ${p(E[3])} ${p(E[4])} ${p(E[5])})`},h={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},u="http://www.w3.org/XML/1998/namespace",d="http://www.w3.org/1999/xlink",m=["butt","round","square"],y=["miter","round","bevel"],w=function(E,T="",R=!1){if(URL.createObjectURL&&typeof Blob!="undefined"&&!R)return URL.createObjectURL(new Blob([E],{type:T}));let O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",L=`data:${T};base64,`;for(let M=0,k=E.length;M<k;M+=3){let F=E[M]&255,q=E[M+1]&255,G=E[M+2]&255,ie=F>>2,ee=(F&3)<<4|q>>4,Z=M+1<k?(q&15)<<2|G>>6:64,X=M+2<k?G&63:64;L+=O[ie]+O[ee]+O[Z]+O[X]}return L},v=function(){let E=new Uint8Array([137,80,78,71,13,10,26,10]),T=12,R=new Int32Array(256);for(let G=0;G<256;G++){let ie=G;for(let ee=0;ee<8;ee++)ie&1?ie=3988292384^ie>>1&2147483647:ie=ie>>1&2147483647;R[G]=ie}function O(G,ie,ee){let Z=-1;for(let X=ie;X<ee;X++){let ce=(Z^G[X])&255,we=R[ce];Z=Z>>>8^we}return Z^-1}function L(G,ie,ee,Z){let X=Z,ce=ie.length;ee[X]=ce>>24&255,ee[X+1]=ce>>16&255,ee[X+2]=ce>>8&255,ee[X+3]=ce&255,X+=4,ee[X]=G.charCodeAt(0)&255,ee[X+1]=G.charCodeAt(1)&255,ee[X+2]=G.charCodeAt(2)&255,ee[X+3]=G.charCodeAt(3)&255,X+=4,ee.set(ie,X),X+=ie.length;let we=O(ee,Z+4,X);ee[X]=we>>24&255,ee[X+1]=we>>16&255,ee[X+2]=we>>8&255,ee[X+3]=we&255}function M(G,ie,ee){let Z=1,X=0;for(let ce=ie;ce<ee;++ce)Z=(Z+(G[ce]&255))%65521,X=(X+Z)%65521;return X<<16|Z}function k(G){if(!s.isNodeJS)return F(G);try{let ie;parseInt(process.versions.node)>=8?ie=G:ie=Buffer.from(G);let ee=yx().deflateSync(ie,{level:9});return ee instanceof Uint8Array?ee:new Uint8Array(ee)}catch(ie){(0,o.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+ie)}return F(G)}function F(G){let ie=G.length,ee=65535,Z=Math.ceil(ie/ee),X=new Uint8Array(2+ie+Z*5+4),ce=0;X[ce++]=120,X[ce++]=156;let we=0;for(;ie>ee;)X[ce++]=0,X[ce++]=255,X[ce++]=255,X[ce++]=0,X[ce++]=0,X.set(G.subarray(we,we+ee),ce),ce+=ee,we+=ee,ie-=ee;X[ce++]=1,X[ce++]=ie&255,X[ce++]=ie>>8&255,X[ce++]=~ie&65535&255,X[ce++]=(~ie&65535)>>8&255,X.set(G.subarray(we),ce),ce+=G.length-we;let ve=M(G,0,G.length);return X[ce++]=ve>>24&255,X[ce++]=ve>>16&255,X[ce++]=ve>>8&255,X[ce++]=ve&255,X}function q(G,ie,ee,Z){let X=G.width,ce=G.height,we,ve,Q,N=G.data;switch(ie){case o.ImageKind.GRAYSCALE_1BPP:ve=0,we=1,Q=X+7>>3;break;case o.ImageKind.RGB_24BPP:ve=2,we=8,Q=X*3;break;case o.ImageKind.RGBA_32BPP:ve=6,we=8,Q=X*4;break;default:throw new Error("invalid format")}let B=new Uint8Array((1+Q)*ce),D=0,W=0;for(let $=0;$<ce;++$)B[D++]=0,B.set(N.subarray(W,W+Q),D),W+=Q,D+=Q;if(ie===o.ImageKind.GRAYSCALE_1BPP&&Z){D=0;for(let $=0;$<ce;$++){D++;for(let K=0;K<Q;K++)B[D++]^=255}}let z=new Uint8Array([X>>24&255,X>>16&255,X>>8&255,X&255,ce>>24&255,ce>>16&255,ce>>8&255,ce&255,we,ve,0,0,0]),J=k(B),he=E.length+T*3+z.length+J.length,fe=new Uint8Array(he),I=0;return fe.set(E,I),I+=E.length,L("IHDR",z,fe,I),I+=T+z.length,L("IDATA",J,fe,I),I+=T+J.length,L("IEND",new Uint8Array(0),fe,I),w(fe,"image/png",ee)}return function(ie,ee,Z){let X=ie.kind===void 0?o.ImageKind.GRAYSCALE_1BPP:ie.kind;return q(ie,X,ee,Z)}}();class g{constructor(){this.fontSizeScale=1,this.fontWeight=h.fontWeight,this.fontSize=0,this.textMatrix=o.IDENTITY_MATRIX,this.fontMatrix=o.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=o.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=h.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(T,R){this.x=T,this.y=R}}let S=0,C=0,x=0;t.SVGGraphics=l=class{constructor(E,T,R=!1){(0,i.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new i.DOMSVGFactory,this.current=new g,this.transformMatrix=o.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=E,this.objs=T,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!R,this._operatorIdMapping=[];for(let O in o.OPS)this._operatorIdMapping[o.OPS[O]]=O}save(){this.transformStack.push(this.transformMatrix);let 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){let T=E.fnArray,R=E.argsArray;for(let O=0,L=T.length;O<L;O++)if(T[O]===o.OPS.dependency)for(let M of R[O]){let k=M.startsWith("g_")?this.commonObjs:this.objs,F=new Promise(q=>{k.get(M,q)});this.current.dependencies.push(F)}return Promise.all(this.current.dependencies)}transform(E,T,R,O,L,M){let k=[E,T,R,O,L,M];this.transformMatrix=o.Util.transform(this.transformMatrix,k),this.tgrp=null}getSVG(E,T){this.viewport=T;let R=this._initialize(T);return this.loadDependencies(E).then(()=>(this.transformMatrix=o.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(E)),R))}convertOpList(E){let T=this._operatorIdMapping,R=E.argsArray,O=E.fnArray,L=[];for(let M=0,k=O.length;M<k;M++){let F=O[M];L.push({fnId:F,fn:T[F],args:R[M]})}return f(L)}executeOpTree(E){for(let T of E){let R=T.fn,O=T.fnId,L=T.args;switch(O|0){case o.OPS.beginText:this.beginText();break;case o.OPS.dependency:break;case o.OPS.setLeading:this.setLeading(L);break;case o.OPS.setLeadingMoveText:this.setLeadingMoveText(L[0],L[1]);break;case o.OPS.setFont:this.setFont(L);break;case o.OPS.showText:this.showText(L[0]);break;case o.OPS.showSpacedText:this.showText(L[0]);break;case o.OPS.endText:this.endText();break;case o.OPS.moveText:this.moveText(L[0],L[1]);break;case o.OPS.setCharSpacing:this.setCharSpacing(L[0]);break;case o.OPS.setWordSpacing:this.setWordSpacing(L[0]);break;case o.OPS.setHScale:this.setHScale(L[0]);break;case o.OPS.setTextMatrix:this.setTextMatrix(L[0],L[1],L[2],L[3],L[4],L[5]);break;case o.OPS.setTextRise:this.setTextRise(L[0]);break;case o.OPS.setTextRenderingMode:this.setTextRenderingMode(L[0]);break;case o.OPS.setLineWidth:this.setLineWidth(L[0]);break;case o.OPS.setLineJoin:this.setLineJoin(L[0]);break;case o.OPS.setLineCap:this.setLineCap(L[0]);break;case o.OPS.setMiterLimit:this.setMiterLimit(L[0]);break;case o.OPS.setFillRGBColor:this.setFillRGBColor(L[0],L[1],L[2]);break;case o.OPS.setStrokeRGBColor:this.setStrokeRGBColor(L[0],L[1],L[2]);break;case o.OPS.setStrokeColorN:this.setStrokeColorN(L);break;case o.OPS.setFillColorN:this.setFillColorN(L);break;case o.OPS.shadingFill:this.shadingFill(L[0]);break;case o.OPS.setDash:this.setDash(L[0],L[1]);break;case o.OPS.setRenderingIntent:this.setRenderingIntent(L[0]);break;case o.OPS.setFlatness:this.setFlatness(L[0]);break;case o.OPS.setGState:this.setGState(L[0]);break;case o.OPS.fill:this.fill();break;case o.OPS.eoFill:this.eoFill();break;case o.OPS.stroke:this.stroke();break;case o.OPS.fillStroke:this.fillStroke();break;case o.OPS.eoFillStroke:this.eoFillStroke();break;case o.OPS.clip:this.clip("nonzero");break;case o.OPS.eoClip:this.clip("evenodd");break;case o.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case o.OPS.paintImageXObject:this.paintImageXObject(L[0]);break;case o.OPS.paintInlineImageXObject:this.paintInlineImageXObject(L[0]);break;case o.OPS.paintImageMaskXObject:this.paintImageMaskXObject(L[0]);break;case o.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(L[0],L[1]);break;case o.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case o.OPS.closePath:this.closePath();break;case o.OPS.closeStroke:this.closeStroke();break;case o.OPS.closeFillStroke:this.closeFillStroke();break;case o.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case o.OPS.nextLine:this.nextLine();break;case o.OPS.transform:this.transform(L[0],L[1],L[2],L[3],L[4],L[5]);break;case o.OPS.constructPath:this.constructPath(L[0],L[1]);break;case o.OPS.endPath:this.endPath();break;case 92:this.group(T.items);break;default:(0,o.warn)(`Unimplemented operator ${R}`);break}}}setWordSpacing(E){this.current.wordSpacing=E}setCharSpacing(E){this.current.charSpacing=E}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(E,T,R,O,L,M){let k=this.current;k.textMatrix=k.lineMatrix=[E,T,R,O,L,M],k.textMatrixScale=Math.hypot(E,T),k.x=k.lineX=0,k.y=k.lineY=0,k.xcoords=[],k.ycoords=[],k.tspan=this.svgFactory.createElement("svg:tspan"),k.tspan.setAttributeNS(null,"font-family",k.fontFamily),k.tspan.setAttributeNS(null,"font-size",`${p(k.fontSize)}px`),k.tspan.setAttributeNS(null,"y",p(-k.y)),k.txtElement=this.svgFactory.createElement("svg:text"),k.txtElement.append(k.tspan)}beginText(){let E=this.current;E.x=E.lineX=0,E.y=E.lineY=0,E.textMatrix=o.IDENTITY_MATRIX,E.lineMatrix=o.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,T){let R=this.current;R.x=R.lineX+=E,R.y=R.lineY+=T,R.xcoords=[],R.ycoords=[],R.tspan=this.svgFactory.createElement("svg:tspan"),R.tspan.setAttributeNS(null,"font-family",R.fontFamily),R.tspan.setAttributeNS(null,"font-size",`${p(R.fontSize)}px`),R.tspan.setAttributeNS(null,"y",p(-R.y))}showText(E){let T=this.current,R=T.font,O=T.fontSize;if(O===0)return;let L=T.fontSizeScale,M=T.charSpacing,k=T.wordSpacing,F=T.fontDirection,q=T.textHScale*F,G=R.vertical,ie=G?1:-1,ee=R.defaultVMetrics,Z=O*T.fontMatrix[0],X=0;for(let ve of E){if(ve===null){X+=F*k;continue}else if(typeof ve=="number"){X+=ie*ve*O/1e3;continue}let Q=(ve.isSpace?k:0)+M,N=ve.fontChar,B,D,W=ve.width;if(G){let J,he=ve.vmetric||ee;J=ve.vmetric?he[1]:W*.5,J=-J*Z;let fe=he[2]*Z;W=he?-he[0]:W,B=J/L,D=(X+fe)/L}else B=X/L,D=0;(ve.isInFont||R.missingFile)&&(T.xcoords.push(T.x+B),G&&T.ycoords.push(-T.y+D),T.tspan.textContent+=N);let z;G?z=W*Z-Q*F:z=W*Z+Q*F,X+=z}T.tspan.setAttributeNS(null,"x",T.xcoords.map(p).join(" ")),G?T.tspan.setAttributeNS(null,"y",T.ycoords.map(p).join(" ")):T.tspan.setAttributeNS(null,"y",p(-T.y)),G?T.y-=X:T.x+=X*q,T.tspan.setAttributeNS(null,"font-family",T.fontFamily),T.tspan.setAttributeNS(null,"font-size",`${p(T.fontSize)}px`),T.fontStyle!==h.fontStyle&&T.tspan.setAttributeNS(null,"font-style",T.fontStyle),T.fontWeight!==h.fontWeight&&T.tspan.setAttributeNS(null,"font-weight",T.fontWeight);let ce=T.textRenderingMode&o.TextRenderingMode.FILL_STROKE_MASK;if(ce===o.TextRenderingMode.FILL||ce===o.TextRenderingMode.FILL_STROKE?(T.fillColor!==h.fillColor&&T.tspan.setAttributeNS(null,"fill",T.fillColor),T.fillAlpha<1&&T.tspan.setAttributeNS(null,"fill-opacity",T.fillAlpha)):T.textRenderingMode===o.TextRenderingMode.ADD_TO_PATH?T.tspan.setAttributeNS(null,"fill","transparent"):T.tspan.setAttributeNS(null,"fill","none"),ce===o.TextRenderingMode.STROKE||ce===o.TextRenderingMode.FILL_STROKE){let ve=1/(T.textMatrixScale||1);this._setStrokeAttributes(T.tspan,ve)}let we=T.textMatrix;T.textRise!==0&&(we=we.slice(),we[5]+=T.textRise),T.txtElement.setAttributeNS(null,"transform",`${b(we)} scale(${p(q)}, -1)`),T.txtElement.setAttributeNS(u,"xml:space","preserve"),T.txtElement.append(T.tspan),T.txtgrp.append(T.txtElement),this._ensureTransformGroup().append(T.txtElement)}setLeadingMoveText(E,T){this.setLeading(-T),this.moveText(E,T)}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));let T=w(E.data,E.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${E.loadedName}"; src: url(${T}); }
72
- `}setFont(E){let T=this.current,R=this.commonObjs.get(E[0]),O=E[1];T.font=R,this.embedFonts&&!R.missingFile&&!this.embeddedFonts[R.loadedName]&&(this.addFontStyle(R),this.embeddedFonts[R.loadedName]=R),T.fontMatrix=R.fontMatrix||o.FONT_IDENTITY_MATRIX;let L="normal";R.black?L="900":R.bold&&(L="bold");let M=R.italic?"italic":"normal";O<0?(O=-O,T.fontDirection=-1):T.fontDirection=1,T.fontSize=O,T.fontFamily=R.loadedName,T.fontWeight=L,T.fontStyle=M,T.tspan=this.svgFactory.createElement("svg:tspan"),T.tspan.setAttributeNS(null,"y",p(-T.y)),T.xcoords=[],T.ycoords=[]}endText(){let E=this.current;E.textRenderingMode&o.TextRenderingMode.ADD_TO_PATH_FLAG&&E.txtElement?.hasChildNodes()&&(E.element=E.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(E){E>0&&(this.current.lineWidth=E)}setLineCap(E){this.current.lineCap=m[E]}setLineJoin(E){this.current.lineJoin=y[E]}setMiterLimit(E){this.current.miterLimit=E}setStrokeAlpha(E){this.current.strokeAlpha=E}setStrokeRGBColor(E,T,R){this.current.strokeColor=o.Util.makeHexColor(E,T,R)}setFillAlpha(E){this.current.fillAlpha=E}setFillRGBColor(E,T,R){this.current.fillColor=o.Util.makeHexColor(E,T,R),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){let T=this.viewport.width,R=this.viewport.height,O=o.Util.inverseTransform(this.transformMatrix),L=o.Util.applyTransform([0,0],O),M=o.Util.applyTransform([0,R],O),k=o.Util.applyTransform([T,0],O),F=o.Util.applyTransform([T,R],O),q=Math.min(L[0],M[0],k[0],F[0]),G=Math.min(L[1],M[1],k[1],F[1]),ie=Math.max(L[0],M[0],k[0],F[0]),ee=Math.max(L[1],M[1],k[1],F[1]),Z=this.svgFactory.createElement("svg:rect");Z.setAttributeNS(null,"x",q),Z.setAttributeNS(null,"y",G),Z.setAttributeNS(null,"width",ie-q),Z.setAttributeNS(null,"height",ee-G),Z.setAttributeNS(null,"fill",this._makeShadingPattern(E)),this.current.fillAlpha<1&&Z.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(Z)}_makeColorN_Pattern(E){return E[0]==="TilingPattern"?this._makeTilingPattern(E):this._makeShadingPattern(E)}_makeTilingPattern(E){let T=E[1],R=E[2],O=E[3]||o.IDENTITY_MATRIX,[L,M,k,F]=E[4],q=E[5],G=E[6],ie=E[7],ee=`shading${x++}`,[Z,X,ce,we]=o.Util.normalizeRect([...o.Util.applyTransform([L,M],O),...o.Util.applyTransform([k,F],O)]),[ve,Q]=o.Util.singularValueDecompose2dScale(O),N=q*ve,B=G*Q,D=this.svgFactory.createElement("svg:pattern");D.setAttributeNS(null,"id",ee),D.setAttributeNS(null,"patternUnits","userSpaceOnUse"),D.setAttributeNS(null,"width",N),D.setAttributeNS(null,"height",B),D.setAttributeNS(null,"x",`${Z}`),D.setAttributeNS(null,"y",`${X}`);let W=this.svg,z=this.transformMatrix,J=this.current.fillColor,he=this.current.strokeColor,fe=this.svgFactory.create(ce-Z,we-X);if(this.svg=fe,this.transformMatrix=O,ie===2){let I=o.Util.makeHexColor(...T);this.current.fillColor=I,this.current.strokeColor=I}return this.executeOpTree(this.convertOpList(R)),this.svg=W,this.transformMatrix=z,this.current.fillColor=J,this.current.strokeColor=he,D.append(fe.childNodes[0]),this.defs.append(D),`url(#${ee})`}_makeShadingPattern(E){switch(typeof E=="string"&&(E=this.objs.get(E)),E[0]){case"RadialAxial":let T=`shading${x++}`,R=E[3],O;switch(E[1]){case"axial":let L=E[4],M=E[5];O=this.svgFactory.createElement("svg:linearGradient"),O.setAttributeNS(null,"id",T),O.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),O.setAttributeNS(null,"x1",L[0]),O.setAttributeNS(null,"y1",L[1]),O.setAttributeNS(null,"x2",M[0]),O.setAttributeNS(null,"y2",M[1]);break;case"radial":let k=E[4],F=E[5],q=E[6],G=E[7];O=this.svgFactory.createElement("svg:radialGradient"),O.setAttributeNS(null,"id",T),O.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),O.setAttributeNS(null,"cx",F[0]),O.setAttributeNS(null,"cy",F[1]),O.setAttributeNS(null,"r",G),O.setAttributeNS(null,"fx",k[0]),O.setAttributeNS(null,"fy",k[1]),O.setAttributeNS(null,"fr",q);break;default:throw new Error(`Unknown RadialAxial type: ${E[1]}`)}for(let L of R){let M=this.svgFactory.createElement("svg:stop");M.setAttributeNS(null,"offset",L[0]),M.setAttributeNS(null,"stop-color",L[1]),O.append(M)}return this.defs.append(O),`url(#${T})`;case"Mesh":return(0,o.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${E[0]}`)}}setDash(E,T){this.current.dashArray=E,this.current.dashPhase=T}constructPath(E,T){let R=this.current,O=R.x,L=R.y,M=[],k=0;for(let F of E)switch(F|0){case o.OPS.rectangle:O=T[k++],L=T[k++];let q=T[k++],G=T[k++],ie=O+q,ee=L+G;M.push("M",p(O),p(L),"L",p(ie),p(L),"L",p(ie),p(ee),"L",p(O),p(ee),"Z");break;case o.OPS.moveTo:O=T[k++],L=T[k++],M.push("M",p(O),p(L));break;case o.OPS.lineTo:O=T[k++],L=T[k++],M.push("L",p(O),p(L));break;case o.OPS.curveTo:O=T[k+4],L=T[k+5],M.push("C",p(T[k]),p(T[k+1]),p(T[k+2]),p(T[k+3]),p(O),p(L)),k+=6;break;case o.OPS.curveTo2:M.push("C",p(O),p(L),p(T[k]),p(T[k+1]),p(T[k+2]),p(T[k+3])),O=T[k+2],L=T[k+3],k+=4;break;case o.OPS.curveTo3:O=T[k+2],L=T[k+3],M.push("C",p(T[k]),p(T[k+1]),p(O),p(L),p(O),p(L)),k+=4;break;case o.OPS.closePath:M.push("Z");break}M=M.join(" "),R.path&&E.length>0&&E[0]!==o.OPS.rectangle&&E[0]!==o.OPS.moveTo?M=R.path.getAttributeNS(null,"d")+M:(R.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(R.path)),R.path.setAttributeNS(null,"d",M),R.path.setAttributeNS(null,"fill","none"),R.element=R.path,R.setCurrentPoint(O,L)}endPath(){let E=this.current;if(E.path=null,!this.pendingClip)return;if(!E.element){this.pendingClip=null;return}let T=`clippath${S++}`,R=this.svgFactory.createElement("svg:clipPath");R.setAttributeNS(null,"id",T),R.setAttributeNS(null,"transform",b(this.transformMatrix));let O=E.element.cloneNode(!0);if(this.pendingClip==="evenodd"?O.setAttributeNS(null,"clip-rule","evenodd"):O.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,R.append(O),this.defs.append(R),E.activeClipUrl){E.clipGroup=null;for(let L of this.extraStack)L.clipGroup=null;R.setAttributeNS(null,"clip-path",E.activeClipUrl)}E.activeClipUrl=`url(#${T})`,this.tgrp=null}clip(E){this.pendingClip=E}closePath(){let E=this.current;if(E.path){let T=`${E.path.getAttributeNS(null,"d")}Z`;E.path.setAttributeNS(null,"d",T)}}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(let[T,R]of E)switch(T){case"LW":this.setLineWidth(R);break;case"LC":this.setLineCap(R);break;case"LJ":this.setLineJoin(R);break;case"ML":this.setMiterLimit(R);break;case"D":this.setDash(R[0],R[1]);break;case"RI":this.setRenderingIntent(R);break;case"FL":this.setFlatness(R);break;case"Font":this.setFont(R);break;case"CA":this.setStrokeAlpha(R);break;case"ca":this.setFillAlpha(R);break;default:(0,o.warn)(`Unimplemented graphic state operator ${T}`);break}}fill(){let E=this.current;E.element&&(E.element.setAttributeNS(null,"fill",E.fillColor),E.element.setAttributeNS(null,"fill-opacity",E.fillAlpha),this.endPath())}stroke(){let E=this.current;E.element&&(this._setStrokeAttributes(E.element),E.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(E,T=1){let R=this.current,O=R.dashArray;T!==1&&O.length>0&&(O=O.map(function(L){return T*L})),E.setAttributeNS(null,"stroke",R.strokeColor),E.setAttributeNS(null,"stroke-opacity",R.strokeAlpha),E.setAttributeNS(null,"stroke-miterlimit",p(R.miterLimit)),E.setAttributeNS(null,"stroke-linecap",R.lineCap),E.setAttributeNS(null,"stroke-linejoin",R.lineJoin),E.setAttributeNS(null,"stroke-width",p(T*R.lineWidth)+"px"),E.setAttributeNS(null,"stroke-dasharray",O.map(p).join(" ")),E.setAttributeNS(null,"stroke-dashoffset",p(T*R.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(){let 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){let T=E.startsWith("g_")?this.commonObjs.get(E):this.objs.get(E);if(!T){(0,o.warn)(`Dependent image with object ID ${E} is not ready yet`);return}this.paintInlineImageXObject(T)}paintInlineImageXObject(E,T){let R=E.width,O=E.height,L=v(E,this.forceDataSchema,!!T),M=this.svgFactory.createElement("svg:rect");M.setAttributeNS(null,"x","0"),M.setAttributeNS(null,"y","0"),M.setAttributeNS(null,"width",p(R)),M.setAttributeNS(null,"height",p(O)),this.current.element=M,this.clip("nonzero");let k=this.svgFactory.createElement("svg:image");k.setAttributeNS(d,"xlink:href",L),k.setAttributeNS(null,"x","0"),k.setAttributeNS(null,"y",p(-O)),k.setAttributeNS(null,"width",p(R)+"px"),k.setAttributeNS(null,"height",p(O)+"px"),k.setAttributeNS(null,"transform",`scale(${p(1/R)} ${p(-1/O)})`),T?T.append(k):this._ensureTransformGroup().append(k)}paintImageMaskXObject(E){let T=this.current,R=E.width,O=E.height,L=T.fillColor;T.maskId=`mask${C++}`;let M=this.svgFactory.createElement("svg:mask");M.setAttributeNS(null,"id",T.maskId);let k=this.svgFactory.createElement("svg:rect");k.setAttributeNS(null,"x","0"),k.setAttributeNS(null,"y","0"),k.setAttributeNS(null,"width",p(R)),k.setAttributeNS(null,"height",p(O)),k.setAttributeNS(null,"fill",L),k.setAttributeNS(null,"mask",`url(#${T.maskId})`),this.defs.append(M),this._ensureTransformGroup().append(k),this.paintInlineImageXObject(E,M)}paintFormXObjectBegin(E,T){if(Array.isArray(E)&&E.length===6&&this.transform(E[0],E[1],E[2],E[3],E[4],E[5]),T){let R=T[2]-T[0],O=T[3]-T[1],L=this.svgFactory.createElement("svg:rect");L.setAttributeNS(null,"x",T[0]),L.setAttributeNS(null,"y",T[1]),L.setAttributeNS(null,"width",p(R)),L.setAttributeNS(null,"height",p(O)),this.current.element=L,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(E){let T=this.svgFactory.create(E.width,E.height),R=this.svgFactory.createElement("svg:defs");T.append(R),this.defs=R;let O=this.svgFactory.createElement("svg:g");return O.setAttributeNS(null,"transform",b(E.transform)),T.append(O),this.svg=O,T}_ensureClipGroup(){if(!this.current.clipGroup){let 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",b(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNodeStream=void 0;var i=n(1),o=n(33);let s=Cd(),l=bx(),h=vx(),u=xd(),d=/^file:\/\/\/[a-zA-Z]:\//;function m(C){let x=u.parse(C);return x.protocol==="file:"||x.host?x:/^[a-z]:[/\\]/i.test(C)?u.parse(`file:///${C}`):(x.host||(x.protocol="file:"),x)}class y{constructor(x){this.source=x,this.url=m(x.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&x.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new b(this):new f(this),this._fullRequestReader}getRangeReader(x,E){if(E<=this._progressiveDataLength)return null;let T=this.isFsUrl?new S(this,x,E):new p(this,x,E);return this._rangeRequestReaders.push(T),T}cancelAllRequests(x){this._fullRequestReader&&this._fullRequestReader.cancel(x);for(let E of this._rangeRequestReaders.slice(0))E.cancel(x)}}t.PDFNodeStream=y;class w{constructor(x){this._url=x.url,this._done=!1,this._storedError=null,this.onProgress=null;let E=x.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,i.createPromiseCapability)(),this._headersCapability=(0,i.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;let x=this._readableStream.read();return x===null?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=x.length,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(x).buffer,done:!1})}cancel(x){if(!this._readableStream){this._error(x);return}this._readableStream.destroy(x)}_error(x){this._storedError=x,this._readCapability.resolve()}_setReadableStream(x){this._readableStream=x,x.on("readable",()=>{this._readCapability.resolve()}),x.on("end",()=>{x.destroy(),this._done=!0,this._readCapability.resolve()}),x.on("error",E=>{this._error(E)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class v{constructor(x){this._url=x.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=(0,i.createPromiseCapability)();let E=x.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;let x=this._readableStream.read();return x===null?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=x.length,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(x).buffer,done:!1})}cancel(x){if(!this._readableStream){this._error(x);return}this._readableStream.destroy(x)}_error(x){this._storedError=x,this._readCapability.resolve()}_setReadableStream(x){this._readableStream=x,x.on("readable",()=>{this._readCapability.resolve()}),x.on("end",()=>{x.destroy(),this._done=!0,this._readCapability.resolve()}),x.on("error",E=>{this._error(E)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function g(C,x){return{protocol:C.protocol,auth:C.auth,host:C.hostname,port:C.port,path:C.path,method:"GET",headers:x}}class f extends w{constructor(x){super(x);let E=T=>{if(T.statusCode===404){let M=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=M,this._headersCapability.reject(M);return}this._headersCapability.resolve(),this._setReadableStream(T);let R=M=>this._readableStream.headers[M.toLowerCase()],{allowRangeRequests:O,suggestedLength:L}=(0,o.validateRangeRequestCapabilities)({getResponseHeader:R,isHttp:x.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=O,this._contentLength=L||this._contentLength,this._filename=(0,o.extractFilenameFromHeader)(R)};this._request=null,this._url.protocol==="http:"?this._request=l.request(g(this._url,x.httpHeaders),E):this._request=h.request(g(this._url,x.httpHeaders),E),this._request.on("error",T=>{this._storedError=T,this._headersCapability.reject(T)}),this._request.end()}}class p extends v{constructor(x,E,T){super(x);this._httpHeaders={};for(let O in x.httpHeaders){let L=x.httpHeaders[O];typeof L!="undefined"&&(this._httpHeaders[O]=L)}this._httpHeaders.Range=`bytes=${E}-${T-1}`;let R=O=>{if(O.statusCode===404){let L=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=L;return}this._setReadableStream(O)};this._request=null,this._url.protocol==="http:"?this._request=l.request(g(this._url,this._httpHeaders),R):this._request=h.request(g(this._url,this._httpHeaders),R),this._request.on("error",O=>{this._storedError=O}),this._request.end()}}class b extends w{constructor(x){super(x);let E=decodeURIComponent(this._url.path);d.test(this._url.href)&&(E=E.replace(/^\//,"")),s.lstat(E,(T,R)=>{if(T){T.code==="ENOENT"&&(T=new i.MissingPDFException(`Missing PDF "${E}".`)),this._storedError=T,this._headersCapability.reject(T);return}this._contentLength=R.size,this._setReadableStream(s.createReadStream(E)),this._headersCapability.resolve()})}}class S extends v{constructor(x,E,T){super(x);let R=decodeURIComponent(this._url.path);d.test(this._url.href)&&(R=R.replace(/^\//,"")),this._setReadableStream(s.createReadStream(R,{start:E,end:T-1}))}}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=u,t.extractFilenameFromHeader=h,t.validateRangeRequestCapabilities=l,t.validateResponseStatus=d;var i=n(1),o=n(34),s=n(8);function l({getResponseHeader:m,isHttp:y,rangeChunkSize:w,disableRange:v}){let g={allowRangeRequests:!1,suggestedLength:void 0},f=parseInt(m("Content-Length"),10);return!Number.isInteger(f)||(g.suggestedLength=f,f<=2*w)||v||!y||m("Accept-Ranges")!=="bytes"||(m("Content-Encoding")||"identity")!=="identity"||(g.allowRangeRequests=!0),g}function h(m){let y=m("Content-Disposition");if(y){let w=(0,o.getFilenameFromContentDispositionHeader)(y);if(w.includes("%"))try{w=decodeURIComponent(w)}catch(v){}if((0,s.isPdfFile)(w))return w}return null}function u(m,y){return m===404||m===0&&y.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+y+'".'):new i.UnexpectedResponseException(`Unexpected server response (${m}) while retrieving PDF "${y}".`,m)}function d(m){return m===200||m===206}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=o;var i=n(1);function o(s){let l=!0,h=u("filename\\*","i").exec(s);if(h){h=h[1];let f=w(h);return f=unescape(f),f=v(f),f=g(f),m(f)}if(h=y(s),h){let f=g(h);return m(f)}if(h=u("filename","i").exec(s),h){h=h[1];let f=w(h);return f=g(f),m(f)}function u(f,p){return new RegExp("(?:^|;)\\s*"+f+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',p)}function d(f,p){if(f){if(!/^[\x00-\xFF]+$/.test(p))return p;try{let b=new TextDecoder(f,{fatal:!0}),S=(0,i.stringToBytes)(p);p=b.decode(S),l=!1}catch(b){}}return p}function m(f){return l&&/[\x80-\xff]/.test(f)&&(f=d("utf-8",f),l&&(f=d("iso-8859-1",f))),f}function y(f){let p=[],b,S=u("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(b=S.exec(f))!==null;){let[,x,E,T]=b;if(x=parseInt(x,10),x in p){if(x===0)break;continue}p[x]=[E,T]}let C=[];for(let x=0;x<p.length&&x in p;++x){let[E,T]=p[x];T=w(T),E&&(T=unescape(T),x===0&&(T=v(T))),C.push(T)}return C.join("")}function w(f){if(f.startsWith('"')){let p=f.slice(1).split('\\"');for(let b=0;b<p.length;++b){let S=p[b].indexOf('"');S!==-1&&(p[b]=p[b].slice(0,S),p.length=b+1),p[b]=p[b].replace(/\\(.)/g,"$1")}f=p.join('"')}return f}function v(f){let p=f.indexOf("'");if(p===-1)return f;let b=f.slice(0,p),C=f.slice(p+1).replace(/^[^']*'/,"");return d(b,C)}function g(f){return!f.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(f)?f:f.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(p,b,S,C){if(S==="q"||S==="Q")return C=C.replace(/_/g," "),C=C.replace(/=([0-9a-fA-F]{2})/g,function(x,E){return String.fromCharCode(parseInt(E,16))}),d(b,C);try{C=atob(C)}catch(x){}return d(b,C)})}return""}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNetworkStream=void 0;var i=n(1),o=n(33);let s=200,l=206;function h(w){let v=w.response;return typeof v!="string"?v:(0,i.stringToBytes)(v).buffer}class u{constructor(v,g={}){this.url=v,this.isHttp=/^https?:/i.test(v),this.httpHeaders=this.isHttp&&g.httpHeaders||Object.create(null),this.withCredentials=g.withCredentials||!1,this.getXhr=g.getXhr||function(){return new XMLHttpRequest},this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(v,g,f){let p={begin:v,end:g};for(let b in f)p[b]=f[b];return this.request(p)}requestFull(v){return this.request(v)}request(v){let g=this.getXhr(),f=this.currXhrId++,p=this.pendingRequests[f]={xhr:g};g.open("GET",this.url),g.withCredentials=this.withCredentials;for(let b in this.httpHeaders){let S=this.httpHeaders[b];typeof S!="undefined"&&g.setRequestHeader(b,S)}return this.isHttp&&"begin"in v&&"end"in v?(g.setRequestHeader("Range",`bytes=${v.begin}-${v.end-1}`),p.expectedStatus=l):p.expectedStatus=s,g.responseType="arraybuffer",v.onError&&(g.onerror=function(b){v.onError(g.status)}),g.onreadystatechange=this.onStateChange.bind(this,f),g.onprogress=this.onProgress.bind(this,f),p.onHeadersReceived=v.onHeadersReceived,p.onDone=v.onDone,p.onError=v.onError,p.onProgress=v.onProgress,g.send(null),f}onProgress(v,g){let f=this.pendingRequests[v];!f||f.onProgress?.(g)}onStateChange(v,g){let f=this.pendingRequests[v];if(!f)return;let p=f.xhr;if(p.readyState>=2&&f.onHeadersReceived&&(f.onHeadersReceived(),delete f.onHeadersReceived),p.readyState!==4||!(v in this.pendingRequests))return;if(delete this.pendingRequests[v],p.status===0&&this.isHttp){f.onError?.(p.status);return}let b=p.status||s;if(!(b===s&&f.expectedStatus===l)&&b!==f.expectedStatus){f.onError?.(p.status);return}let C=h(p);if(b===l){let x=p.getResponseHeader("Content-Range"),E=/bytes (\d+)-(\d+)\/(\d+)/.exec(x);f.onDone({begin:parseInt(E[1],10),chunk:C})}else C?f.onDone({begin:0,chunk:C}):f.onError?.(p.status)}getRequestXhr(v){return this.pendingRequests[v].xhr}isPendingRequest(v){return v in this.pendingRequests}abortRequest(v){let g=this.pendingRequests[v].xhr;delete this.pendingRequests[v],g.abort()}}class d{constructor(v){this._source=v,this._manager=new u(v.url,{httpHeaders:v.httpHeaders,withCredentials:v.withCredentials}),this._rangeChunkSize=v.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(v){let g=this._rangeRequestReaders.indexOf(v);g>=0&&this._rangeRequestReaders.splice(g,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new m(this._manager,this._source),this._fullRequestReader}getRangeReader(v,g){let f=new y(this._manager,v,g);return f.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(f),f}cancelAllRequests(v){this._fullRequestReader?.cancel(v);for(let g of this._rangeRequestReaders.slice(0))g.cancel(v)}}t.PDFNetworkStream=d;class m{constructor(v,g){this._manager=v;let f={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=g.url,this._fullRequestId=v.requestFull(f),this._headersReceivedCapability=(0,i.createPromiseCapability)(),this._disableRange=g.disableRange||!1,this._contentLength=g.length,this._rangeChunkSize=g.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(){let v=this._fullRequestId,g=this._manager.getRequestXhr(v),f=S=>g.getResponseHeader(S),{allowRangeRequests:p,suggestedLength:b}=(0,o.validateRangeRequestCapabilities)({getResponseHeader:f,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});p&&(this._isRangeSupported=!0),this._contentLength=b||this._contentLength,this._filename=(0,o.extractFilenameFromHeader)(f),this._isRangeSupported&&this._manager.abortRequest(v),this._headersReceivedCapability.resolve()}_onDone(v){if(v&&(this._requests.length>0?this._requests.shift().resolve({value:v.chunk,done:!1}):this._cachedChunks.push(v.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(v){this._storedError=(0,o.createResponseStatusError)(v,this._url),this._headersReceivedCapability.reject(this._storedError);for(let g of this._requests)g.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(v){this.onProgress?.({loaded:v.loaded,total:v.lengthComputable?v.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};let v=(0,i.createPromiseCapability)();return this._requests.push(v),v.promise}cancel(v){this._done=!0,this._headersReceivedCapability.reject(v);for(let g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class y{constructor(v,g,f){this._manager=v;let p={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=v.url,this._requestId=v.requestRange(g,f,p),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(v){let g=v.chunk;this._requests.length>0?this._requests.shift().resolve({value:g,done:!1}):this._queuedChunk=g,this._done=!0;for(let f of this._requests)f.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(v){this._storedError=(0,o.createResponseStatusError)(v,this._url);for(let g of this._requests)g.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(v){this.isStreamingSupported||this.onProgress?.({loaded:v.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let g=this._queuedChunk;return this._queuedChunk=null,{value:g,done:!1}}if(this._done)return{value:void 0,done:!0};let v=(0,i.createPromiseCapability)();return this._requests.push(v),v.promise}cancel(v){this._done=!0;for(let g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFetchStream=void 0;var i=n(1),o=n(33);function s(m,y,w){return{method:"GET",headers:m,signal:w.signal,mode:"cors",credentials:y?"include":"same-origin",redirect:"follow"}}function l(m){let y=new Headers;for(let w in m){let v=m[w];typeof v!="undefined"&&y.append(w,v)}return y}class h{constructor(y){this.source=y,this.isHttp=/^https?:/i.test(y.url),this.httpHeaders=this.isHttp&&y.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new u(this),this._fullRequestReader}getRangeReader(y,w){if(w<=this._progressiveDataLength)return null;let v=new d(this,y,w);return this._rangeRequestReaders.push(v),v}cancelAllRequests(y){this._fullRequestReader&&this._fullRequestReader.cancel(y);for(let w of this._rangeRequestReaders.slice(0))w.cancel(y)}}t.PDFFetchStream=h;class u{constructor(y){this._stream=y,this._reader=null,this._loaded=0,this._filename=null;let w=y.source;this._withCredentials=w.withCredentials||!1,this._contentLength=w.length,this._headersCapability=(0,i.createPromiseCapability)(),this._disableRange=w.disableRange||!1,this._rangeChunkSize=w.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!w.disableStream,this._isRangeSupported=!w.disableRange,this._headers=l(this._stream.httpHeaders);let v=w.url;fetch(v,s(this._headers,this._withCredentials,this._abortController)).then(g=>{if(!(0,o.validateResponseStatus)(g.status))throw(0,o.createResponseStatusError)(g.status,v);this._reader=g.body.getReader(),this._headersCapability.resolve();let f=S=>g.headers.get(S),{allowRangeRequests:p,suggestedLength:b}=(0,o.validateRangeRequestCapabilities)({getResponseHeader:f,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=p,this._contentLength=b||this._contentLength,this._filename=(0,o.extractFilenameFromHeader)(f),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.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;let{value:y,done:w}=await this._reader.read();return w?{value:y,done:w}:(this._loaded+=y.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(y).buffer,done:!1})}cancel(y){this._reader&&this._reader.cancel(y),this._abortController.abort()}}class d{constructor(y,w,v){this._stream=y,this._reader=null,this._loaded=0;let g=y.source;this._withCredentials=g.withCredentials||!1,this._readCapability=(0,i.createPromiseCapability)(),this._isStreamingSupported=!g.disableStream,this._abortController=new AbortController,this._headers=l(this._stream.httpHeaders),this._headers.append("Range",`bytes=${w}-${v-1}`);let f=g.url;fetch(f,s(this._headers,this._withCredentials,this._abortController)).then(p=>{if(!(0,o.validateResponseStatus)(p.status))throw(0,o.createResponseStatusError)(p.status,f);this._readCapability.resolve(),this._reader=p.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:y,done:w}=await this._reader.read();return w?{value:y,done:w}:(this._loaded+=y.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(y).buffer,done:!1})}cancel(y){this._reader&&this._reader.cancel(y),this._abortController.abort()}}}],__webpack_module_cache__={};function __w_pdfjs_require__(r){var t=__webpack_module_cache__[r];if(t!==void 0)return t.exports;var n=__webpack_module_cache__[r]={exports:{}};return __webpack_modules__[r](n,n.exports,__w_pdfjs_require__),n.exports}var __webpack_exports__={};return(()=>{var r=__webpack_exports__;Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"AnnotationEditorLayer",{enumerable:!0,get:function(){return o.AnnotationEditorLayer}}),Object.defineProperty(r,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return t.AnnotationEditorParamsType}}),Object.defineProperty(r,"AnnotationEditorType",{enumerable:!0,get:function(){return t.AnnotationEditorType}}),Object.defineProperty(r,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return s.AnnotationEditorUIManager}}),Object.defineProperty(r,"AnnotationLayer",{enumerable:!0,get:function(){return l.AnnotationLayer}}),Object.defineProperty(r,"AnnotationMode",{enumerable:!0,get:function(){return t.AnnotationMode}}),Object.defineProperty(r,"CMapCompressionType",{enumerable:!0,get:function(){return t.CMapCompressionType}}),Object.defineProperty(r,"GlobalWorkerOptions",{enumerable:!0,get:function(){return h.GlobalWorkerOptions}}),Object.defineProperty(r,"InvalidPDFException",{enumerable:!0,get:function(){return t.InvalidPDFException}}),Object.defineProperty(r,"LoopbackPort",{enumerable:!0,get:function(){return n.LoopbackPort}}),Object.defineProperty(r,"MissingPDFException",{enumerable:!0,get:function(){return t.MissingPDFException}}),Object.defineProperty(r,"OPS",{enumerable:!0,get:function(){return t.OPS}}),Object.defineProperty(r,"PDFDataRangeTransport",{enumerable:!0,get:function(){return n.PDFDataRangeTransport}}),Object.defineProperty(r,"PDFDateString",{enumerable:!0,get:function(){return i.PDFDateString}}),Object.defineProperty(r,"PDFWorker",{enumerable:!0,get:function(){return n.PDFWorker}}),Object.defineProperty(r,"PasswordResponses",{enumerable:!0,get:function(){return t.PasswordResponses}}),Object.defineProperty(r,"PermissionFlag",{enumerable:!0,get:function(){return t.PermissionFlag}}),Object.defineProperty(r,"PixelsPerInch",{enumerable:!0,get:function(){return i.PixelsPerInch}}),Object.defineProperty(r,"RenderingCancelledException",{enumerable:!0,get:function(){return i.RenderingCancelledException}}),Object.defineProperty(r,"SVGGraphics",{enumerable:!0,get:function(){return m.SVGGraphics}}),Object.defineProperty(r,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return t.UNSUPPORTED_FEATURES}}),Object.defineProperty(r,"UnexpectedResponseException",{enumerable:!0,get:function(){return t.UnexpectedResponseException}}),Object.defineProperty(r,"Util",{enumerable:!0,get:function(){return t.Util}}),Object.defineProperty(r,"VerbosityLevel",{enumerable:!0,get:function(){return t.VerbosityLevel}}),Object.defineProperty(r,"XfaLayer",{enumerable:!0,get:function(){return y.XfaLayer}}),Object.defineProperty(r,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(r,"createPromiseCapability",{enumerable:!0,get:function(){return t.createPromiseCapability}}),Object.defineProperty(r,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return t.createValidAbsoluteUrl}}),Object.defineProperty(r,"getDocument",{enumerable:!0,get:function(){return n.getDocument}}),Object.defineProperty(r,"getFilenameFromUrl",{enumerable:!0,get:function(){return i.getFilenameFromUrl}}),Object.defineProperty(r,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return i.getPdfFilenameFromUrl}}),Object.defineProperty(r,"getXfaPageViewport",{enumerable:!0,get:function(){return i.getXfaPageViewport}}),Object.defineProperty(r,"isPdfFile",{enumerable:!0,get:function(){return i.isPdfFile}}),Object.defineProperty(r,"loadScript",{enumerable:!0,get:function(){return i.loadScript}}),Object.defineProperty(r,"renderTextLayer",{enumerable:!0,get:function(){return d.renderTextLayer}}),Object.defineProperty(r,"shadow",{enumerable:!0,get:function(){return t.shadow}}),Object.defineProperty(r,"version",{enumerable:!0,get:function(){return n.version}});var t=__w_pdfjs_require__(1),n=__w_pdfjs_require__(4),i=__w_pdfjs_require__(8),o=__w_pdfjs_require__(22),s=__w_pdfjs_require__(7),l=__w_pdfjs_require__(27),h=__w_pdfjs_require__(15),u=__w_pdfjs_require__(3),d=__w_pdfjs_require__(30),m=__w_pdfjs_require__(31),y=__w_pdfjs_require__(29);let w="2.16.105",v="172ccdbe5";if(u.isNodeJS){let{PDFNodeStream:g}=__w_pdfjs_require__(32);(0,n.setPDFNetworkStreamFactory)(f=>new g(f))}else{let{PDFNetworkStream:g}=__w_pdfjs_require__(35),{PDFFetchStream:f}=__w_pdfjs_require__(36);(0,n.setPDFNetworkStreamFactory)(p=>(0,i.isValidFetchUrl)(p.url)?new f(p):new g(p))}})(),__webpack_exports__})())});var k8={};sM(k8,{Link:()=>Jl,default:()=>P8,load:()=>M8});H();H();H();var xw=gt(Sw()),Cw=gt(ii());H();var Aw=gt(ii());function ia(r,t){return Aw.TaJson.deserialize(r,t)}var Co=class extends xw.Publication{static async fromUrl(t,n){let o=await(await fetch(t.href,n)).json(),s=ia(o,Co);return s.manifestUrl=t,s}get readingOrder(){return this.Spine??[]}get resources(){return this.Resources??[]}get tableOfContents(){return this.sample?.isSampleRead&&this.positions?.length>0?this.limitedTOC():this.TOC}limitedTOC(){function t(i){for(let o=0;o<i.Children.length;o++){let s=i.Children[o];s.Href=void 0,s.Children&&t(s)}}return this.TOC.map(i=>{if(i.Href){let o=this.positionsByHref(this.getRelativeHref(i.Href));if(o?.length>0){let s=o[0],l=Math.round(s.locations.totalProgression?s.locations.totalProgression:0*100);this.sample?.limit&&(l<=this.sample?.limit||(i.Href=void 0,i.Children&&t(i)))}}return i})}get landmarks(){return this.Landmarks}get pageList(){return this.PageList}get isFixedLayout(){return this.Metadata.Rendition?.Layout==="fixed"}get isReflowable(){return!this.isFixedLayout}get layout(){return this.isFixedLayout?"fixed":"reflowable"}get hasMediaOverlays(){return this.readingOrder?this.readingOrder.filter(t=>t.Properties?.MediaOverlay).length>0:!1}getStartLink(){if(this.readingOrder!==void 0&&this.readingOrder.length>0)return this.readingOrder[0]}getPreviousSpineItem(t){let n=this.getSpineIndex(t);if(n!==void 0&&this.readingOrder!==void 0&&n>0)return this.readingOrder[n-1]}getNextSpineItem(t){let n=this.getSpineIndex(t);if(n!==void 0&&this.readingOrder!==void 0&&n<this.readingOrder.length-1)return this.readingOrder[n+1]}getSpineItem(t){let n=this.getSpineIndex(t);if(n!==void 0&&this.readingOrder!==void 0)return this.readingOrder[n]}getSpineIndex(t){return this.readingOrder?.findIndex(n=>n.Href&&this.getAbsoluteHref(n.Href)===t)}getAbsoluteHref(t){return new URL(t,this.manifestUrl.href).href}getRelativeHref(t){let n=this.manifestUrl.href.replace("/manifest.json",""),i=t.replace(n,"");return i.indexOf("#")>0&&(i=i.slice(0,i.indexOf("#"))),i.charAt(0)==="/"&&(i=i.substring(1)),i}getTOCItemAbsolute(t){let n=this.getAbsoluteHref(t),i=(s,l)=>{for(let h=0;h<l.length;h++){let u=l[h];if(u.Href){let d=u.Href.indexOf("#")!==-1?u.Href.slice(0,u.Href.indexOf("#")):u.Href;if(this.getAbsoluteHref(d)===s)return u}if(u.Children){let d=i(s,u.Children);if(d!==void 0)return d}}},o=i(n,this.tableOfContents);return o===void 0&&this.readingOrder!==void 0&&(o=i(n,this.readingOrder)),o}getTOCItem(t){let n=(o,s)=>{for(let l=0;l<s.length;l++){let h=s[l];if(h.Href&&this.getAbsoluteHref(h.Href)===o)return h;if(h.Children){let u=n(o,h.Children);if(u!==void 0)return u}}},i=n(t,this.tableOfContents);if(i===void 0&&this.readingOrder!==void 0&&(i=n(t,this.readingOrder)),i===void 0&&t.indexOf("#")!==-1){let o=t.slice(0,t.indexOf("#"));i=n(o,this.tableOfContents),i===void 0&&this.readingOrder!==void 0&&(i=n(o,this.readingOrder))}return i}positionsByHref(t){let n=decodeURI(t)??"";return this.positions?.filter(i=>n.includes(i.href))}async autoGeneratePositions(t,n=SL){let i=0,o=0,s=[];if(this.readingOrder!==void 0)for(let h of this.readingOrder)if(this.isFixedLayout){let u={href:h.Href,locations:{progression:0,position:i+1},type:h.TypeLink};s.push(u),i=i+1}else{let u=this.getAbsoluteHref(h.Href),d=await n(u,t);h.contentLength=d,o+=d;let y=Math.max(1,Math.ceil(d/1024));for(let w=0;w<y;w++){let v={href:h.Href,locations:{progression:w/y,position:i+(w+1)},type:h.TypeLink};s.push(v)}i=i+y}var l=0;if(this.isReflowable&&this.readingOrder!==void 0)for(let h of this.readingOrder){if(!h.contentLength){console.error("Link is missing contentLength",h);return}h.contentWeight=100/o*h.contentLength,l=l+h.contentWeight}for(let h of s){let u=s.filter(m=>m.href===decodeURI(h.href)),d=Math.ceil((h.locations.progression?h.locations.progression:0)*(u.length-1));h.locations.position&&(h.locations.totalProgression=(h.locations.position-1)/s.length),h.locations.remainingPositions=Math.abs(d-(u.length-1)),h.locations.position&&(h.locations.totalRemainingPositions=Math.abs(h.locations.position-1-(s.length-1)))}this.positions=s}async fetchPositionsFromService(t,n){let o=await(await fetch(t,n)).json();this.positions=o.positions}async fetchWeightsFromService(t,n){if(this.isFixedLayout){console.warn("Not fetching weights from service for fixed layout publication.");return}let o=await(await fetch(t,n)).json();this.readingOrder!==void 0&&this.readingOrder.forEach(s=>{s.contentWeight=o[s.Href]})}};Co=Uc([(0,Cw.JsonObject)()],Co);var SL=async(r,t)=>(await(await fetch(r,t)).blob()).size;H();H();var ra=class{json(){return JSON.stringify(this)}},Tw=class extends ra{constructor(t,n,i){super();this.value=t,this.ref=n,this.name=i}toString(){return this.value}},Ow=class extends ra{constructor(t,n,i){super();this.value=t,this.ref=n,this.name=i}toString(){return this.value}toJson(){return JSON.parse(this.value)}},Rw=class extends ra{constructor(t,n,i,o){super();this.value=t,this.values=n,this.ref=i,this.name=o}toString(){return this.values[this.value]}},Pw=class extends ra{constructor(t,n,i,o,s,l,h){super();this.countDecimals=function(t){return t%1!=0?t.toString().split(".")[1].length:1};this.value=t,this.min=n,this.max=i,this.step=o,this.suffix=s,this.ref=l,this.name=h}toString(){return this.value.toString()+this.suffix}increment(){let t=this.countDecimals(this.max);parseFloat(this.value.toFixed(t))<this.max&&(this.value=parseFloat(this.value.toFixed(t))+this.step)}decrement(){let t=this.countDecimals(this.min);parseFloat(this.value.toFixed(t))>this.min&&(this.value=parseFloat(this.value.toFixed(t))-this.step)}},ol=class extends ra{constructor(t,n,i,o,s){super();this.value=i,this.onValue=t,this.offValue=n,this.ref=o,this.name=s}toString(){return this.value?this.onValue:this.offValue}switch(){this.value=!this.value}},Zr=class{constructor(){this.properties=[]}addIncremental(t,n,i,o,s,l,h){this.properties.push(new Pw(t,n,i,o,s,l,h))}addStringable(t,n,i){this.properties.push(new Tw(t,n,i))}addJSONable(t,n,i){this.properties.push(new Ow(t,n,i))}addSwitchable(t,n,i,o,s){this.properties.push(new ol(t,n,i,o,s))}addEnumerable(t,n,i,o){this.properties.push(new Rw(t,n,i,o))}getByRef(t){let n=this.properties.filter(i=>i.ref===t);return n.length>0?n[0]:null}getByKey(t){let n=this.properties.filter(i=>i.key===t);return n.length>0?n[0]:null}};H();var Bi=class{},Ae=Bi;Ae.FONT_SIZE_REF="fontSize",Ae.FONT_FAMILY_REF="fontFamily",Ae.FONT_OVERRIDE_REF="fontOverride",Ae.APPEARANCE_REF="appearance",Ae.SCROLL_REF="scroll",Ae.TEXT_ALIGNMENT_REF="textAlign",Ae.COLUMN_COUNT_REF="colCount",Ae.WORD_SPACING_REF="wordSpacing",Ae.LETTER_SPACING_REF="letterSpacing",Ae.PAGE_MARGINS_REF="pageMargins",Ae.LINE_HEIGHT_REF="lineHeight",Ae.FONT_SIZE_KEY="--USER__"+Bi.FONT_SIZE_REF,Ae.FONT_FAMILY_KEY="--USER__"+Bi.FONT_FAMILY_REF,Ae.FONT_OVERRIDE_KEY="--USER__"+Bi.FONT_OVERRIDE_REF,Ae.APPEARANCE_KEY="--USER__"+Bi.APPEARANCE_REF,Ae.SCROLL_KEY="--USER__"+Bi.SCROLL_REF,Ae.TEXT_ALIGNMENT_KEY="--USER__"+Bi.TEXT_ALIGNMENT_REF,Ae.COLUMN_COUNT_KEY="--USER__"+Bi.COLUMN_COUNT_REF,Ae.WORD_SPACING_KEY="--USER__"+Bi.WORD_SPACING_REF,Ae.LETTER_SPACING_KEY="--USER__"+Bi.LETTER_SPACING_REF,Ae.PAGE_MARGINS_KEY="--USER__"+Bi.PAGE_MARGINS_REF,Ae.LINE_HEIGHT_KEY="--USER__"+Bi.LINE_HEIGHT_REF;H();function $e(r,t){return r.querySelector(t)}function Rt(r,t){let n=$e(r,t);if(n&&n instanceof HTMLElement)return n;throw new Error("required element "+t+" not found")}function On(r,t){if(r===null)throw new Error("parent element is null");return r.querySelector(t)}function Qr(r,t){let n=On(r,t);if(n)return n;throw new Error("required element "+t+" not found in iframe")}function Un(r,t,n){r.setAttribute(t,n)}H();H();var x_=gt(M0());var Ol=class{constructor(t){this.getScrollingElement=t=>t.scrollingElement?t.scrollingElement:t.body;this.navigator=t}async handleFootnote(t,n){let i=t.getAttribute("href");if(i&&i.indexOf("#")>0){let s=function(h){let u=document.location.href;return new URL(h,u).href},o=i.substring(i.indexOf("#")+1),l=s(i);l&&(l=l.substring(0,l.indexOf("#")),n.preventDefault(),n.stopPropagation(),await fetch(l,this.navigator.requestConfig).then(h=>h.text()).then(async h=>{let m=new DOMParser().parseFromString(h,"text/html").querySelector("#"+o);m&&(n.preventDefault(),n.stopPropagation(),this.showPopup(m,n))}))}}async hidePopover(){let t=this.navigator.iframes[0].contentDocument?.getElementById("d2-popover");t&&t.parentElement?.removeChild(t);let n=Rt(document,"#iframe-wrapper");n.style.overflow="auto"}async showPopover(t,n){let i=t.getAttribute("href"),o=t.getAttribute("src");function s(l){let h=document.location.href;return new URL(l,h).href}if(i){let l=s(i);if(l){n.preventDefault(),n.stopPropagation();let h=this.navigator.iframes[0].contentDocument?.getElementById("d2-popover");h&&h.parentElement?.removeChild(h);let u=document.createElement("div");u.id="d2-popover",u.className="d2-popover is-active";let d=Rt(document,"#iframe-wrapper");d.style.overflow="hidden",u.style.top=d.scrollTop+"px",u.style.height=d.clientHeight*.9+"px";let m=document.createElement("div");m.className="d2-popover-wrapper",u.appendChild(m);let y=document.createElement("div");y.className="d2-popover-content",m.appendChild(y),await fetch(l,this.navigator.requestConfig).then(g=>g.text()).then(async g=>{y.innerHTML=g;let f=this.navigator.iframes[0].contentDocument;f&&f.body.appendChild(u)});let w=this.navigator.iframes[0].contentWindow;if(!w)return;let v=this;w.onclick=function(g){n.target!==g.target&&u.parentElement&&(v.hidePopover(),w&&(w.onclick=null))}}}else if(o&&s(o)){n.preventDefault(),n.stopPropagation();let h=this.navigator.iframes[0].contentDocument?.getElementById("d2-popover");h&&h.parentElement?.removeChild(h);let u=document.createElement("div");u.id="d2-popover",u.className="d2-popover is-active";let d=Rt(document,"#iframe-wrapper");d.style.overflow="hidden",u.style.top=d.scrollTop+"px",u.style.height=d.clientHeight*.9+"px";let m=document.createElement("div");m.className="d2-popover-wrapper",u.appendChild(m);let y=document.createElement("img");y.className="d2-popover-content",m.appendChild(y),y.src=o;let w=this.navigator.iframes[0].contentDocument;w&&w.body.appendChild(u);let v=this.navigator.iframes[0].contentWindow;if(!v)return;let g=this;v.onclick=function(f){n.target!==f.target&&u.parentElement&&(g.hidePopover(),v&&(v.onclick=null))}}}showPopup(t,n){let i=this.navigator.iframes[0].contentDocument?.getElementById("d2-popup");i&&i.parentElement?.removeChild(i);let o=document.createElement("aside");o.id="d2-popup",o.className="d2-popup is-active";let s=document.createElement("div");s.className="d2-popup-wrapper",o.appendChild(s);let l=document.createElement("div");l.className="d2-popup-content",s.appendChild(l);let h=document.createElement("p");l.appendChild(h),typeof t=="string"?h.innerHTML=t:h.innerHTML=(0,x_.default)(t.innerHTML,{allowedTags:[],allowedAttributes:{}});let u=this.navigator.view?.isPaginated(),d=this.navigator.iframes[0].contentDocument;if(!d)return;let m=this.getScrollingElement(d),y=u?m.scrollLeft:0,w=u?m.scrollTop:0,v=n.x+y,g=n.y+w;o.style.top=g+"px",u&&(o.style.left=v+"px"),d.body.appendChild(o);let f=this.navigator.iframes[0].contentWindow;!f||(f.onclick=function(p){n.target!==p.target&&o.parentElement&&(o.style.display="none",o.parentElement.removeChild(o),f&&(f.onclick=null))})}};var Kd=gt(cn());function Ce(r,t,n){r&&r.addEventListener(t,n,!0)}function ze(r,t,n){r&&r.removeEventListener(t,n,!0)}var Yd=class{constructor(t){this.onInternalLink=()=>{};this.onClickThrough=()=>{};this.checkForLink=t=>{let n=t.target;for(;n&&n.tagName.toLowerCase()!=="body";){if(n.tagName.toLowerCase()==="a"&&n.href)return n;n=n.parentElement}return null};this.linkInPublication=(t,n)=>t.some(i=>!i.Rel?.includes("external")&&this.navigator.publication.getRelativeHref(n).includes(i.Href));this.isReadingOrderInternal=t=>(Kd.default.log("clickedLink: ",t),this.linkInPublication(this.navigator.publication.readingOrder,t.href));this.isResourceInternal=t=>(Kd.default.log("clickedLink: ",t),this.linkInPublication(this.navigator.publication.resources,t.href));this.handleLinks=async t=>{Kd.default.log("R2 Click Handler");let n=this.checkForLink(t);if(n){let i=window.location.protocol===n.protocol&&window.location.port===n.port&&window.location.hostname===n.hostname,o=this.isReadingOrderInternal(n),s=this.isResourceInternal(n);s||await this.popup.hidePopover();let l=n.href.indexOf("#");if(!o&&!s)window.open(n.href,n.target??"_blank"),t.preventDefault(),t.stopPropagation();else if(t.target.href=n.href,(i||o)&&l!==-1){let h=t.target;h?h.getAttribute("epub:type")==="noteref"?await this.popup.handleFootnote(h,t):s&&!o?await this.popup.showPopover(h,t):this.onInternalLink(t):this.onInternalLink(t)}else(i||o)&&l===-1&&this.onInternalLink(t)}else this.onClickThrough(t)};this.navigator=t,this.popup=new Ol(this.navigator)}setupEvents(t){if(t!==null)t.addEventListener("dblclick",async n=>{let i=n.target;n.target&&i.tagName.toLowerCase()==="img"&&await this.popup.showPopover(i,n)},!0),t.addEventListener("click",this.handleLinks.bind(this));else throw"cannot setup events for null"}};H();H();function T_(){return Rt(document,"#iframe-wrapper").clientWidth}function gr(){return Rt(document,"#iframe-wrapper").clientHeight}var R_=gt(Mo()),Xd=class{constructor(t){this.layout="reflowable";this.USERSETTINGS="userSetting";this.sideMargin=20;this.height=0;this.attributes={margin:0};this.hasFixedScrollWidth=!1;this.store=t,this.scrollMode?(this.name="readium-scroll-on",this.label="Scrolling"):(this.name="readium-scroll-off",this.label="Paginated")}setMode(t){if(this.scrollMode=t,t){this.name="readium-scroll-on",this.label="Scrolling";let n=this.iframe.contentDocument;if(n){let i=On(n,"head");if(i){let s=$e(i,"meta[name=viewport]");s&&s.remove()}let o=On(n,"html");o&&o.style.setProperty("--USER__scroll","readium-scroll-on")}this.setSize(),this.setIframeHeight(this.iframe)}else{this.height=gr()-40-this.attributes.margin,this.name="readium-scroll-off",this.label="Paginated",this.checkForFixedScrollWidth();let n=this.iframe.contentDocument;if(n){let i=On(n,"html");i&&i.style.setProperty("--USER__scroll","readium-scroll-off")}this.setSize()}this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate()}start(){if(this.scrollMode){let t=this.iframe.contentDocument;if(t){let n=On(t,"head");if(n){let i=$e(n,"meta[name=viewport]");i&&i.remove()}}this.setSize(),this.setIframeHeight(this.iframe)}else{this.iframe.height="0",this.iframe.width="0",this.setSize();let t=document.createElement("meta");t.name="viewport",t.content="width=device-width, initial-scale=1, maximum-scale=1",this.checkForFixedScrollWidth()}}stop(){if(this.iframe.height="0",this.iframe.width="0",this.iframe.contentDocument){let n=On(this.iframe.contentDocument,"body"),i=Array.prototype.slice.call(n.querySelectorAll("img"));for(let o of i)o.style.maxWidth=""}}getCurrentPosition(){let t=Rt(document,"#iframe-wrapper");if(this.scrollMode)return t.scrollTop/this.scrollingElement.scrollHeight;{let n=this.getColumnWidth(),i=this.getLeftColumnsWidth(),o=this.getRightColumnsWidth(),s=i+n+o;return i/s}}goToProgression(t){let n=Rt(document,"#iframe-wrapper");if(this.scrollMode)n.scrollTop=this.scrollingElement.scrollHeight*t;else{let i=this.getColumnWidth(),o=this.getLeftColumnsWidth(),s=this.getRightColumnsWidth(),l=o+i+s,h=t*l,u=Math.round(h/i)*i;u>=l&&(u=u-i),this.setLeftColumnsWidth(u)}}goToCssSelector(t,n){let i=this.iframe.contentDocument;if(i){let o=i.querySelector(t);this.goToElement(o,n)}}goToFragment(t,n){let i=this.iframe.contentDocument;if(i){let o=i.getElementById(t);this.goToElement(o,n)}}snap(t,n){if(t&&!this.scrollMode){let i=t.style.height;t.style.height="0";let o=this.getColumnWidth(),s=this.getLeftColumnsWidth()+t.getBoundingClientRect().left,l=Math.floor(s/o)*o;t.style.height=i,this.setLeftColumnsWidth(l),this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate(0)}}goToElement(t,n){if(this.scrollMode)t&&t.scrollIntoView({block:"center"});else if(t){let i=t.style.height;t.style.height="0";let o=t.getBoundingClientRect().left,s=this.getColumnWidth(),l=this.scrollingElement.scrollLeft-s,h=Math.ceil(o/s)*s+l;if(n){let u=this.getLeftColumnsWidth();h=Math.ceil(o/s)*s+u}t.style.height=i,this.setLeftColumnsWidth(h),this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate(200)}}atStart(){return this.scrollMode?Rt(document,"#iframe-wrapper").scrollTop===0:this.getLeftColumnsWidth()<=0}atEnd(){if(this.scrollMode){let t=Rt(document,"#iframe-wrapper");return Math.ceil(this.scrollingElement.scrollHeight-t.scrollTop)-1<=gr()}else return Math.floor(this.getRightColumnsWidth())<=0}goToPreviousPage(){let t=Rt(document,"#iframe-wrapper");if(this.scrollMode){let n=t.scrollTop,i=this.getScreenHeight()-40,o=n-i;o>=0?t.scrollTop=o:t.scrollTop=0}else{let n=this.getLeftColumnsWidth(),i=this.getColumnWidth(),o=n-i;o>=0?this.setLeftColumnsWidth(o):this.setLeftColumnsWidth(0),this.navigator.checkResourcePosition()}this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate()}goToNextPage(){let t=Rt(document,"#iframe-wrapper");if(this.scrollMode){let n=t.scrollTop,i=this.getScreenHeight()-40,o=this.scrollingElement.scrollHeight,s=n+i;s<o?t.scrollTop=s:t.scrollTop=o}else{let n=this.getLeftColumnsWidth(),i=this.getColumnWidth(),o=this.scrollWidth,s=n+i;s<o?this.setLeftColumnsWidth(s):this.setLeftColumnsWidth(o),this.navigator.checkResourcePosition()}this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate()}getCurrentPage(){return this.scrollMode?0:this.getCurrentPosition()*this.getPageCount()+1}getPageCount(){if(this.scrollMode)return 0;{let t=this.getColumnWidth();return this.scrollWidth/t}}isPaginated(){if(this.iframe){let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n)return!(n.style.getPropertyValue("--USER__scroll")==="readium-scroll-on")}}return!this.scrollMode}isScrollMode(){if(this.iframe){let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n)return n.style.getPropertyValue("--USER__scroll")==="readium-scroll-on"}}return this.scrollMode}async getProperty(t){let n=await this.store.get(this.USERSETTINGS);if(n){let i=JSON.parse(n);return i=i.filter(o=>o.name===t),i.length===0?null:i[0]}return null}getScreenHeight(){return Rt(document,"#iframe-wrapper").clientHeight}setIframeHeight(t){(0,R_.debounce)(i=>{if(i){let o=i.contentWindow.document.body,s=i.contentWindow.document.documentElement,l=Math.max(o?.scrollHeight,o?.offsetHeight,s?.clientHeight,s?.scrollHeight,s?.offsetHeight);if(l){let h=gr()-this.attributes.margin;i.height=Math.max(h,l)+"px"}}},200)(t)}checkForFixedScrollWidth(){let t=this.iframe.contentDocument;if(t){let n=On(t,"body"),i=n?.scrollWidth;this.hasFixedScrollWidth=n?.scrollWidth===i}}setSize(){if(this.iframe.width=T_()+"px",this.scrollMode){let t=this.iframe.contentWindow?.document?.documentElement;this.iframe.height=t?.offsetHeight+"px"}else{let t=this.iframe.contentDocument;t&&t.documentElement&&(t.documentElement.style.height=this.height+"px"),this.iframe.height=this.height+"px"}}getLeftColumnsWidth(){return Math.ceil(this.scrollingElement.scrollLeft)}getRightColumnsWidth(){let t=this.getColumnWidth(),n=this.scrollWidth-t;if(this.hasFixedScrollWidth){let i=this.getLeftColumnsWidth();n=Math.max(0,n-i)}return n}getColumnWidth(){return this.scrollingElement.clientWidth}setLeftColumnsWidth(t){this.scrollingElement.scrollLeft=t}get scrollingElement(){return this.iframe.contentDocument?.scrollingElement?this.iframe.contentDocument?.scrollingElement:this.iframe.contentDocument?.body?this.iframe.contentDocument?.body:document.createElement("body")}get scrollWidth(){let t=this.scrollingElement?.scrollWidth,n=this.getColumnWidth();return Math.floor(t/n)*n}};H();var Zd=class{constructor(){this.layout="fixed";this.sideMargin=20;this.height=0;this.attributes={margin:0}}start(){}stop(){}getCurrentPosition(){return 0}getScreenHeight(){return Rt(document,"#iframe-wrapper").clientHeight}goToProgression(t){}goToCssSelector(t,n){}goToFragment(t,n){}snap(t,n){}getCurrentPage(){return 0}getPageCount(){return 1}setSize(){}isPaginated(){return!0}isScrollMode(){return!1}atEnd(){return!0}atStart(){return!0}};var Di=gt(cn()),Gt=class{constructor(t,n,i,o,s){this.USERSETTINGS="userSetting";this.fontSize=100;this.fontOverride=!1;this.fontFamily=0;this.appearance=0;this.verticalScroll=!0;this.textAlignment=0;this.columnCount=0;this.wordSpacing=0;this.letterSpacing=0;this.pageMargins=2;this.lineHeight=1;this.settingsChangeCallback=()=>{};this.settingsColumnsChangeCallback=()=>{};this.viewChangeCallback=()=>{};this.store=t,this.view=s==="fixed"?new Zd:new Xd(this.store),this.headerMenu=n,this.api=i,this.injectables=o,this.injectables?.forEach(l=>{l.type==="style"&&(l.fontFamily&&this.addFont(l.fontFamily),l.appearance&&this.addAppearance(l.appearance))})}async isPaginated(){return!await this.getPropertyAndFallback("verticalScroll",Ae.SCROLL_KEY)}async isScrollMode(){return!await this.isPaginated()}static async create(t){let n=new this(t.store,t.headerMenu,t.api,t.injectables,t.layout);if(await n.initialise(),t.initialUserSettings){n.userProperties||(n.userProperties=n.getUserSettings());let i=t.initialUserSettings;if(i.verticalScroll!==void 0){n.verticalScroll=this.parseScrollSetting(i.verticalScroll);let o=n.userProperties.getByRef(Ae.SCROLL_REF);o&&(o.value=n.verticalScroll,await n.saveProperty(o)),Di.default.log(n.verticalScroll)}if(i.appearance){n.appearance=Gt.appearanceValues.findIndex(s=>s===i.appearance);let o=n.userProperties.getByRef(Ae.APPEARANCE_REF);o&&(o.value=n.appearance,await n.saveProperty(o)),Di.default.log(n.appearance)}if(i.fontSize){n.fontSize=i.fontSize;let o=n.userProperties.getByRef(Ae.FONT_SIZE_REF);o&&(o.value=n.fontSize,await n.saveProperty(o)),Di.default.log(n.fontSize)}if(i.fontFamily){n.fontFamily=Gt.fontFamilyValues.findIndex(s=>s===i.fontFamily);let o=n.userProperties.getByRef(Ae.FONT_FAMILY_REF);o&&(o.value=n.fontFamily,await n.saveProperty(o)),Di.default.log(n.fontFamily),n.fontFamily!==0&&(n.fontOverride=!0)}if(i.textAlignment){n.textAlignment=Gt.textAlignmentValues.findIndex(s=>s===i.textAlignment);let o=n.userProperties.getByRef(Ae.TEXT_ALIGNMENT_REF);o&&(o.value=n.textAlignment,await n.saveProperty(o)),Di.default.log(n.textAlignment)}if(i.columnCount){n.columnCount=Gt.columnCountValues.findIndex(s=>s===i.columnCount);let o=n.userProperties.getByRef(Ae.COLUMN_COUNT_REF);o&&(o.value=n.columnCount,await n.saveProperty(o)),Di.default.log(n.columnCount)}if(i.wordSpacing){n.wordSpacing=i.wordSpacing;let o=n.userProperties.getByRef(Ae.WORD_SPACING_REF);o&&(o.value=n.wordSpacing,await n.saveProperty(o)),Di.default.log(n.wordSpacing)}if(i.letterSpacing){n.letterSpacing=i.letterSpacing;let o=n.userProperties.getByRef(Ae.LETTER_SPACING_REF);o&&(o.value=n.letterSpacing,await n.saveProperty(o)),Di.default.log(n.letterSpacing)}if(i.pageMargins){n.pageMargins=i.pageMargins;let o=n.userProperties.getByRef(Ae.PAGE_MARGINS_REF);o&&(o.value=n.pageMargins,await n.saveProperty(o)),Di.default.log(n.pageMargins)}if(i.lineHeight){n.lineHeight=i.lineHeight;let o=n.userProperties.getByRef(Ae.LINE_HEIGHT_REF);o&&(o.value=n.lineHeight,await n.saveProperty(o)),Di.default.log(n.lineHeight)}n.userProperties=n.getUserSettings(),await n.initialise()}return await n.initializeSelections(),new Promise(i=>i(n))}stop(){Di.default.log("book settings stop")}async initialise(){this.appearance=await this.getPropertyAndFallback("appearance",Ae.APPEARANCE_KEY),this.verticalScroll=await this.getPropertyAndFallback("verticalScroll",Ae.SCROLL_KEY),this.fontFamily=await this.getPropertyAndFallback("fontFamily",Ae.FONT_FAMILY_KEY),this.fontFamily!==0&&(this.fontOverride=!0),this.textAlignment=await this.getPropertyAndFallback("textAlignment",Ae.TEXT_ALIGNMENT_KEY),this.columnCount=await this.getPropertyAndFallback("columnCount",Ae.COLUMN_COUNT_KEY),this.fontSize=await this.getPropertyAndFallback("fontSize",Ae.FONT_SIZE_KEY),this.wordSpacing=await this.getPropertyAndFallback("wordSpacing",Ae.WORD_SPACING_KEY),this.letterSpacing=await this.getPropertyAndFallback("letterSpacing",Ae.LETTER_SPACING_KEY),this.pageMargins=await this.getPropertyAndFallback("pageMargins",Ae.PAGE_MARGINS_KEY),this.lineHeight=await this.getPropertyAndFallback("lineHeight",Ae.LINE_HEIGHT_KEY),this.userProperties=this.getUserSettings()}async reset(){this.appearance=0,this.verticalScroll=!0,this.fontSize=100,this.fontOverride=!1,this.fontFamily=0,this.textAlignment=0,this.columnCount=0,this.wordSpacing=0,this.letterSpacing=0,this.pageMargins=2,this.lineHeight=1,this.userProperties=this.getUserSettings();let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n){let i=document.documentElement,o=Rt(i,"body");n.style.removeProperty(Ae.FONT_SIZE_KEY),n.style.removeProperty(Ae.WORD_SPACING_KEY),n.style.removeProperty(Ae.LETTER_SPACING_KEY),n.style.removeProperty(Ae.COLUMN_COUNT_KEY),n.style.removeProperty(Ae.TEXT_ALIGNMENT_KEY),n.style.removeProperty(Ae.LINE_HEIGHT_KEY),n.style.removeProperty(Ae.PAGE_MARGINS_KEY),n.style.removeProperty(Ae.APPEARANCE_KEY),Un(i,"data-viewer-theme","day"),Un(o,"data-viewer-theme","day"),n.style.removeProperty(Ae.FONT_FAMILY_KEY),Un(n,"data-viewer-font","publisher"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-off")}}}async initializeSelections(){this.headerMenu&&(this.settingsView=$e(this.headerMenu,"#container-view-settings"))}async applyProperties(){this.userProperties=this.getUserSettings();let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n){let i=document.documentElement,o=Rt(i,"body");if(this.view?.navigator.publication.isReflowable&&(await this.getProperty(Ae.FONT_SIZE_KEY)&&n.style.setProperty(Ae.FONT_SIZE_KEY,this.userProperties.getByRef(Ae.FONT_SIZE_REF)?.toString()??null),await this.getProperty(Ae.WORD_SPACING_KEY)&&n.style.setProperty(Ae.WORD_SPACING_KEY,this.userProperties.getByRef(Ae.WORD_SPACING_REF)?.toString()??null),await this.getProperty(Ae.LETTER_SPACING_KEY)&&n.style.setProperty(Ae.LETTER_SPACING_KEY,this.userProperties.getByRef(Ae.LETTER_SPACING_REF)?.toString()??null)),await this.getProperty(Ae.COLUMN_COUNT_KEY)&&n.style.setProperty(Ae.COLUMN_COUNT_KEY,this.userProperties.getByRef(Ae.COLUMN_COUNT_REF)?.toString()??null),this.view?.navigator.publication.isReflowable&&(await this.getProperty(Ae.TEXT_ALIGNMENT_KEY)&&(this.userProperties.getByRef(Ae.TEXT_ALIGNMENT_REF)?.toString()==="auto"?n.style.removeProperty(Ae.TEXT_ALIGNMENT_KEY):n.style.setProperty(Ae.TEXT_ALIGNMENT_KEY,this.userProperties.getByRef(Ae.TEXT_ALIGNMENT_REF)?.toString()??null)),await this.getProperty(Ae.LINE_HEIGHT_KEY)&&n.style.setProperty(Ae.LINE_HEIGHT_KEY,this.userProperties.getByRef(Ae.LINE_HEIGHT_REF)?.toString()??null),await this.getProperty(Ae.PAGE_MARGINS_KEY)&&n.style.setProperty(Ae.PAGE_MARGINS_KEY,this.userProperties.getByRef(Ae.PAGE_MARGINS_REF)?.toString()??null)),await this.getProperty(Ae.APPEARANCE_KEY)?(n.style.setProperty(Ae.APPEARANCE_KEY,this.userProperties.getByRef(Ae.APPEARANCE_REF)?.toString()??null),this.userProperties.getByRef(Ae.APPEARANCE_REF)?.value===0?(Un(i,"data-viewer-theme","day"),Un(o,"data-viewer-theme","day")):this.userProperties.getByRef(Ae.APPEARANCE_REF)?.value===1?(Un(i,"data-viewer-theme","sepia"),Un(o,"data-viewer-theme","sepia")):this.userProperties.getByRef(Ae.APPEARANCE_REF)?.value===2&&(Un(i,"data-viewer-theme","night"),Un(o,"data-viewer-theme","night"))):(n.style.setProperty(Ae.APPEARANCE_KEY,this.userProperties.getByRef(Ae.APPEARANCE_REF)?.toString()??null),Un(i,"data-viewer-theme","day"),Un(o,"data-viewer-theme","day")),this.view?.navigator.publication.isReflowable){if(await this.getProperty(Ae.FONT_FAMILY_KEY))if(n.style.setProperty(Ae.FONT_FAMILY_KEY,this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.toString()??null),this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.value===0)Un(n,"data-viewer-font","publisher"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-off");else if(this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.value===1)Un(n,"data-viewer-font","serif"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-on");else if(this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.value===2)Un(n,"data-viewer-font","sans"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-on");else{let s=this.userProperties.getByRef(Ae.FONT_FAMILY_REF);s&&Un(n,"data-viewer-font",s.toString()),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-on")}else n.style.setProperty(Ae.FONT_FAMILY_KEY,this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.toString()??null),Un(n,"data-viewer-font","publisher"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-off");await this.getProperty(Ae.SCROLL_KEY)?this.userProperties.getByRef(Ae.SCROLL_REF)?.value===!0?n.style.setProperty("--USER__scroll","readium-scroll-on"):n.style.setProperty("--USER__scroll","readium-scroll-off"):n.style.setProperty("--USER__scroll","readium-scroll-on"),n.style.setProperty("--USER__advancedSettings","readium-advanced-on"),this.isScrollMode().then(s=>{this.view?.setMode?.(s)})}}}}setIframe(t){this.iframe=t,this.view&&(this.view.iframe=t),this.settingsView&&Gt.renderControls(this.settingsView)}static renderControls(t){Ce($e(t,"ul"),"click",n=>{n.stopPropagation()})}onSettingsChange(t){this.settingsChangeCallback=t}onColumnSettingsChange(t){this.settingsColumnsChangeCallback=t}onViewChange(t){this.viewChangeCallback=t}async storeProperty(t){await this.updateUserSettings(),await this.saveProperty(t)}addAppearance(t){Gt.appearanceValues.includes(t)||Gt.appearanceValues.push(t)}initAddedAppearance(){this.applyProperties()}addFont(t){Gt.fontFamilyValues.includes(t)||Gt.fontFamilyValues.push(t)}initAddedFont(){this.applyProperties()}async updateUserSettings(){let t={fontFamily:Gt.fontFamilyValues[await this.userProperties?.getByRef(Ae.FONT_FAMILY_REF)?.value],fontSize:this.userProperties?.getByRef(Ae.FONT_SIZE_REF)?.value,appearance:Gt.appearanceValues[await this.userProperties?.getByRef(Ae.APPEARANCE_REF)?.value],textAlignment:Gt.textAlignmentValues[await this.userProperties?.getByRef(Ae.TEXT_ALIGNMENT_REF)?.value],columnCount:Gt.columnCountValues[await this.userProperties?.getByRef(Ae.COLUMN_COUNT_REF)?.value],wordSpacing:this.userProperties?.getByRef(Ae.WORD_SPACING_REF)?.value,letterSpacing:this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)?.value,verticalScroll:this.userProperties?.getByRef(Ae.SCROLL_REF)?.value};this.api?.updateSettings&&this.api?.updateSettings(t).then(n=>{Di.default.log("api updated user settings",JSON.stringify(t))})}getUserSettings(){let t=new Zr;return t.addSwitchable("readium-font-on","readium-font-off",this.fontOverride,Ae.FONT_OVERRIDE_REF,Ae.FONT_OVERRIDE_KEY),t.addEnumerable(this.columnCount,Gt.columnCountValues,Ae.COLUMN_COUNT_REF,Ae.COLUMN_COUNT_KEY),t.addEnumerable(this.appearance,Gt.appearanceValues,Ae.APPEARANCE_REF,Ae.APPEARANCE_KEY),t.addIncremental(this.pageMargins,.5,4,.25,"",Ae.PAGE_MARGINS_REF,Ae.PAGE_MARGINS_KEY),t.addEnumerable(this.textAlignment,Gt.textAlignmentValues,Ae.TEXT_ALIGNMENT_REF,Ae.TEXT_ALIGNMENT_KEY),t.addEnumerable(this.fontFamily,Gt.fontFamilyValues,Ae.FONT_FAMILY_REF,Ae.FONT_FAMILY_KEY),t.addIncremental(this.fontSize,100,300,25,"%",Ae.FONT_SIZE_REF,Ae.FONT_SIZE_KEY),t.addIncremental(this.lineHeight,1,2,.25,"em",Ae.LINE_HEIGHT_REF,Ae.LINE_HEIGHT_KEY),t.addIncremental(this.wordSpacing,0,1,.25,"rem",Ae.WORD_SPACING_REF,Ae.WORD_SPACING_KEY),t.addIncremental(this.letterSpacing,0,.5,.0625,"em",Ae.LETTER_SPACING_REF,Ae.LETTER_SPACING_KEY),t.addSwitchable("readium-scroll-on","readium-scroll-off",this.verticalScroll,Ae.SCROLL_REF,Ae.SCROLL_KEY),t}async saveProperty(t){let n=await this.store.get(this.USERSETTINGS);if(n){let i=JSON.parse(n);i=i.filter(o=>o.name!==t.name),t.value!==void 0&&i.push(t),await this.store.set(this.USERSETTINGS,JSON.stringify(i))}else{let i=[];i.push(t),await this.store.set(this.USERSETTINGS,JSON.stringify(i))}return new Promise(i=>i(t))}async getProperty(t){let n=await this.store.get(this.USERSETTINGS);if(n){let i=JSON.parse(n);return i=i.filter(o=>o.name===t),i.length===0?null:i[0]}return null}async getPropertyAndFallback(t,n){return(await this.getProperty(n))?.value??this[t]}async resetUserSettings(){await this.store.remove(this.USERSETTINGS),await this.reset(),this.settingsChangeCallback()}get currentSettings(){return{appearance:Gt.appearanceValues[this.userProperties?.getByRef(Ae.APPEARANCE_REF)?.value],fontFamily:Gt.fontFamilyValues[this.userProperties?.getByRef(Ae.FONT_FAMILY_REF)?.value],textAlignment:Gt.textAlignmentValues[this.userProperties?.getByRef(Ae.TEXT_ALIGNMENT_REF)?.value],columnCount:Gt.columnCountValues[this.userProperties?.getByRef(Ae.COLUMN_COUNT_REF)?.value],verticalScroll:this.verticalScroll,fontSize:this.fontSize,wordSpacing:this.wordSpacing,letterSpacing:this.letterSpacing,pageMargins:this.pageMargins,lineHeight:this.lineHeight}}async applyUserSettings(t){if(t.appearance){let n;t.appearance==="day"||t.appearance==="readium-default-on"?n=Gt.appearanceValues[0]:t.appearance==="sepia"||t.appearance==="readium-sepia-on"?n=Gt.appearanceValues[1]:t.appearance==="night"||t.appearance==="readium-night-on"?n=Gt.appearanceValues[2]:n=t.appearance,this.appearance=Gt.appearanceValues.findIndex(o=>o===n);let i=this.userProperties?.getByRef(Ae.APPEARANCE_REF);i&&(i.value=this.appearance,await this.storeProperty(i))}if(t.fontSize){this.fontSize=t.fontSize;let n=this.userProperties?.getByRef(Ae.FONT_SIZE_REF);n&&(n.value=this.fontSize,await this.storeProperty(n))}if(t.fontFamily){this.fontFamily=Gt.fontFamilyValues.findIndex(i=>i===t.fontFamily);let n=this.userProperties?.getByRef(Ae.FONT_FAMILY_REF);n&&(n.value=this.fontFamily,await this.storeProperty(n))}if(t.letterSpacing){this.letterSpacing=t.letterSpacing;let n=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF);n&&(n.value=this.letterSpacing,await this.storeProperty(n))}if(t.wordSpacing){this.wordSpacing=t.wordSpacing;let n=this.userProperties?.getByRef(Ae.WORD_SPACING_REF);n&&(n.value=this.wordSpacing,await this.storeProperty(n))}if(t.columnCount){this.columnCount=Gt.columnCountValues.findIndex(i=>i===t.columnCount);let n=this.userProperties?.getByRef(Ae.COLUMN_COUNT_REF);n&&(n.value=this.columnCount,await this.storeProperty(n)),this.settingsColumnsChangeCallback()}if(t.textAlignment){this.textAlignment=Gt.textAlignmentValues.findIndex(i=>i===t.textAlignment);let n=this.userProperties?.getByRef(Ae.TEXT_ALIGNMENT_REF);n&&(n.value=this.textAlignment,await this.storeProperty(n))}if(t.lineHeight){this.lineHeight=t.lineHeight;let n=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF);n&&(n.value=this.lineHeight,await this.storeProperty(n))}if(t.pageMargins){this.pageMargins=t.pageMargins;let n=this.userProperties?.getByRef(Ae.PAGE_MARGINS_REF);n&&(n.value=this.pageMargins,await this.storeProperty(n))}if(t.verticalScroll!==void 0){let n=this.view?.getCurrentPosition();this.verticalScroll=Gt.parseScrollSetting(t.verticalScroll);let i=this.userProperties?.getByRef(Ae.SCROLL_REF);i&&(i.value=this.verticalScroll,await this.saveProperty(i)),this.view?.setMode?.(this.verticalScroll),n&&this.view?.goToProgression(n),this.viewChangeCallback()}await this.applyProperties(),this.settingsChangeCallback()}static parseScrollSetting(t){switch(t){case!0:case"scroll":case"readium-scroll-on":return!0;case!1:case"paginated":case"readium-scroll-off":return!1;default:return!1}}async scroll(t){let n=this.view?.getCurrentPosition();this.verticalScroll=t;let i=this.userProperties?.getByRef(Ae.SCROLL_REF);i&&(i.value=this.verticalScroll,await this.saveProperty(i)),await this.applyProperties(),this.view?.setMode?.(this.verticalScroll),n&&this.view?.goToProgression(n),this.viewChangeCallback()}async increase(t){if(t==="fontSize"){(this.userProperties?.getByRef(Ae.FONT_SIZE_REF)).increment(),this.fontSize=this.userProperties?.getByRef(Ae.FONT_SIZE_REF)?.value;let n=this.userProperties?.getByRef(Ae.FONT_SIZE_REF);n&&await this.storeProperty(n)}else if(t==="letterSpacing"){(this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)).increment(),this.letterSpacing=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="wordSpacing"){(this.userProperties?.getByRef(Ae.WORD_SPACING_REF)).increment(),this.wordSpacing=this.userProperties?.getByRef(Ae.WORD_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.WORD_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="lineHeight"){(this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)).increment(),this.lineHeight=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)?.value;let n=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF);n&&await this.storeProperty(n)}await this.applyProperties(),this.settingsChangeCallback()}async decrease(t){if(t==="fontSize"){(this.userProperties?.getByRef(Ae.FONT_SIZE_REF)).decrement(),this.fontSize=this.userProperties?.getByRef(Ae.FONT_SIZE_REF)?.value;let n=this.userProperties?.getByRef(Ae.FONT_SIZE_REF);n&&await this.storeProperty(n)}else if(t==="letterSpacing"){(this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)).decrement(),this.letterSpacing=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="wordSpacing"){(this.userProperties?.getByRef(Ae.WORD_SPACING_REF)).decrement(),this.wordSpacing=this.userProperties?.getByRef(Ae.WORD_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.WORD_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="lineHeight"){(this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)).decrement(),this.wordSpacing=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)?.value;let n=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF);n&&await this.storeProperty(n)}await this.applyProperties(),this.settingsChangeCallback()}},ko=Gt;ko.appearanceValues=["readium-default-on","readium-sepia-on","readium-night-on"],ko.fontFamilyValues=["Original","serif","sans-serif"],ko.textAlignmentValues=["auto","justify","start"],ko.columnCountValues=["auto","1","2"];H();H();var Fi;(function(n){n[n.Bookmark=0]="Bookmark",n[n.Annotation=1]="Annotation"})(Fi||(Fi={}));H();H();H();H();H();H();var P_={stringify(r){let t=r.nSigBytes,n=r.words,i=[];for(let o=0;o<t;o++){let s=n[o>>>2]>>>24-o%4*8&255;i.push((s>>>4).toString(16)),i.push((s&15).toString(16))}return i.join("")},parse(r){let t=r.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(r))throw new Error(`Invalid Hex string: ${r}`);let n=[];for(let i=0;i<t;i+=2)n[i>>>3]|=parseInt(r.substr(i,2),16)<<24-i%8*4;return new Yn(n,t/2)}};H();H();var M_=typeof navigator!="undefined"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",fs=(()=>{let r=parseInt((/msie (\d+)/.exec(M_)||[])[1],10);return isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(M_)||[])[1],10),isNaN(r)?!1:r):r})();function k_(r,t){return fs===!1?!1:t?r==="<"?fs<t:r==="<="?fs<=t:r===">"?fs>t:r===">="?fs>=t:fs===t:!0}function z5(){if(typeof window!="undefined"){let r=window.crypto||window.msCrypto;if(!r){if(k_("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(Math.random()*512)%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}else{if(typeof globalThis!="undefined"&&globalThis.crypto)return function(){return globalThis.crypto.randomBytes(4).readInt32LE()};if(typeof Ja=="function")return function(){return __non_webpack_require__("crypto").randomBytes(4).readInt32LE()}}throw new Error("Unable to find crypto module")}var I_=z5();var Yn=class{constructor(t,n){if(Array.isArray(t)||!t){this._words=Array.isArray(t)?t:[],this._nSignificantBytes=typeof n=="number"?n:this._words.length*4;return}else if(t instanceof Yn){this._words=t.words.slice(),this._nSignificantBytes=t.nSigBytes;return}let i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(l){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");let o=i.byteLength,s=[];for(let l=0;l<o;l++)s[l>>>2]|=i[l]<<24-l%4*8;this._words=s,this._nSignificantBytes=o}get nSigBytes(){return this._nSignificantBytes}set nSigBytes(t){this._nSignificantBytes=t}get words(){return this._words}toString(t){return t?t.stringify(this):P_.stringify(this)}toUint8Array(){let t=this._words,n=this._nSignificantBytes,i=new Uint8Array(n);for(let o=0;o<n;o++)i[o]=t[o>>>2]>>>24-o%4*8&255;return i}concat(t){let n=t.words.slice(),i=t.nSigBytes;if(this.clamp(),this._nSignificantBytes%4)for(let o=0;o<i;o++){let s=n[o>>>2]>>>24-o%4*8&255;this._words[this._nSignificantBytes+o>>>2]|=s<<24-(this._nSignificantBytes+o)%4*8}else for(let o=0;o<i;o+=4)this._words[this._nSignificantBytes+o>>>2]=n[o>>>2];return this._nSignificantBytes+=i,this}clamp(){let t=this._nSignificantBytes;this._words[t>>>2]&=4294967295<<32-t%4*8,this._words.length=Math.ceil(t/4)}clone(){return new Yn(this._words.slice(),this._nSignificantBytes)}static random(t){let n=[];for(let i=0;i<t;i+=4)n.push(I_());return new Yn(n,t)}};H();H();var I0={stringify(r){let t=r.nSigBytes,n=r.words,i=[];for(let o=0;o<t;o++){let s=n[o>>>2]>>>24-o%4*8&255;i.push(String.fromCharCode(s))}return i.join("")},parse(r){let t=r.length,n=[];for(let i=0;i<t;i++)n[i>>>2]|=(r.charCodeAt(i)&255)<<24-i%4*8;return new Yn(n,t)}};var L_={stringify(r){try{return decodeURIComponent(escape(I0.stringify(r)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse(r){return I0.parse(unescape(encodeURIComponent(r)))}};var L0=class{constructor(t){this._minBufferSize=0,this._blockSize=0,this._props=t,this._data=t&&typeof t.data!="undefined"?t.data.clone():new Yn,this._nBytes=t&&typeof t.nBytes=="number"?t.nBytes:0}get blockSize(){return this._blockSize}reset(t,n){this._data=typeof t!="undefined"?t.clone():new Yn,this._nBytes=typeof n=="number"?n:0}_append(t){let n=typeof t=="string"?L_.parse(t):t;this._data.concat(n),this._nBytes+=n.nSigBytes}_process(t){let n,i=this._data.words,o=this._data.nSigBytes,s=this._blockSize,l=this._blockSize*4,h=o/l;t?h=Math.ceil(h):h=Math.max((h|0)-this._minBufferSize,0);let u=h*s,d=Math.min(u*4,o);if(u){for(let m=0;m<u;m+=s)this._doProcessBlock(i,m);n=i.splice(0,u),this._data.nSigBytes-=d}return new Yn(n,d)}_doProcessBlock(t,n){throw new Error("Not implemented")}};var B0=class extends L0{constructor(t){super(t);this._blockSize=512/32,this._props=t,t&&typeof t.blockSize=="number"&&(this._blockSize=t.blockSize),this.reset(t?t.data:void 0,t?t.nBytes:void 0)}get blockSize(){return this._blockSize}reset(t,n){super.reset.call(this,t,n),this._doReset()}update(t){return this._append(t),this._process(),this}finalize(t){return t&&this._append(t),this._doFinalize()}_doReset(){throw new Error("Not implemented")}_doFinalize(){throw new Error("Not implemented")}};var N0=[],B_=[];function G5(r){let t=Math.sqrt(r);for(let n=2;n<=t;n++)if(!(r%n))return!1;return!0}function N_(r){return(r-(r|0))*4294967296|0}(function(){let t=2,n=0;for(;n<64;)G5(t)&&(n<8&&(N0[n]=N_(Math.pow(t,1/2))),B_[n]=N_(Math.pow(t,1/3)),n++),t++})();var ps=[],er=class extends B0{constructor(t){super(t);this._hash=new Yn(N0.slice(0)),this._props=t,t&&typeof t.hash!="undefined"&&(this._hash=t.hash.clone())}_doReset(){this._hash=new Yn(N0.slice(0))}_doProcessBlock(t,n){let i=this._hash.words,o=i[0],s=i[1],l=i[2],h=i[3],u=i[4],d=i[5],m=i[6],y=i[7];for(let w=0;w<64;w++){if(w<16)ps[w]=t[n+w]|0;else{let C=ps[w-15],x=(C<<25|C>>>7)^(C<<14|C>>>18)^C>>>3,E=ps[w-2],T=(E<<15|E>>>17)^(E<<13|E>>>19)^E>>>10;ps[w]=x+ps[w-7]+T+ps[w-16]}let v=u&d^~u&m,g=o&s^o&l^s&l,f=(o<<30|o>>>2)^(o<<19|o>>>13)^(o<<10|o>>>22),p=(u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25),b=y+p+v+B_[w]+ps[w],S=f+g;y=m,m=d,d=u,u=h+b|0,h=l,l=s,s=o,o=b+S|0}i[0]=i[0]+o|0,i[1]=i[1]+s|0,i[2]=i[2]+l|0,i[3]=i[3]+h|0,i[4]=i[4]+u|0,i[5]=i[5]+d|0,i[6]=i[6]+m|0,i[7]=i[7]+y|0}_doFinalize(){let t=this._data.words,n=this._nBytes*8,i=this._data.nSigBytes*8;return t[i>>>5]|=128<<24-i%32,t[(i+64>>>9<<4)+14]=Math.floor(n/4294967296),t[(i+64>>>9<<4)+15]=n,this._data.nSigBytes=t.length*4,this._process(),this._hash}clone(){let t={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new er(t)}static hash(t,n){return new er(n).finalize(t)}};var Pl=gt(Mo());H();var mt;(function(h){h[h.Annotation=0]="Annotation",h[h.Search=1]="Search",h[h.ReadAloud=2]="ReadAloud",h[h.PageBreak=3]="PageBreak",h[h.Definition=4]="Definition",h[h.LineFocus=5]="LineFocus",h[h.Comment=6]="Comment"})(mt||(mt={}));H();var Xn=gt(cn());function Qd(r,t){let n=r.getClientRects();return D0(n,t)}function D0(r,t){let n=1,i=[];for(let u of r)i.push({bottom:u.bottom,height:u.height,left:u.left,right:u.right,top:u.top,width:u.width});let o=F_(i,n,t),s=Z5(o,n),l=j_(s),h=2*2;for(let u=l.length-1;u>=0;u--){let d=l[u];if(!(d.width*d.height>h))if(l.length>1)Xn.default.log("CLIENT RECT: remove small"),l.splice(u,1);else{Xn.default.log("CLIENT RECT: remove small, but keep otherwise empty!");break}}return H_(l),Xn.default.log(`CLIENT RECT: reduced ${i.length} --> ${l.length}`),l}function tr(r,t,n){return Math.abs(r-t)<=n}function V5(r,t){let n=Math.max(r.left,t.left),i=Math.min(r.right,t.right),o=Math.max(r.top,t.top),s=Math.min(r.bottom,t.bottom);return{bottom:s,height:Math.max(0,s-o),left:n,right:i,top:o,width:Math.max(0,i-n)}}function D_(r,t){let n=V5(t,r);if(n.height===0||n.width===0)return[r];let i=[];{let o={bottom:r.bottom,height:0,left:r.left,right:n.left,top:r.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{let o={bottom:n.top,height:0,left:n.left,right:n.right,top:r.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{let o={bottom:r.bottom,height:0,left:n.left,right:n.right,top:n.bottom,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{let o={bottom:r.bottom,height:0,left:n.right,right:r.right,top:r.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}return i}function eh(r,t,n,i){return(r.left<t||tr(r.left,t,i))&&(r.right>t||tr(r.right,t,i))&&(r.top<n||tr(r.top,n,i))&&(r.bottom>n||tr(r.bottom,n,i))}function J5(r,t,n){return eh(r,t.left,t.top,n)&&eh(r,t.right,t.top,n)&&eh(r,t.left,t.bottom,n)&&eh(r,t.right,t.bottom,n)}function K5(r,t){let n=Math.min(r.left,t.left),i=Math.max(r.right,t.right),o=Math.min(r.top,t.top),s=Math.max(r.bottom,t.bottom);return{bottom:s,height:s-o,left:n,right:i,top:o,width:i-n}}function F0(r,t,n){return(r.left<t.right||n>=0&&tr(r.left,t.right,n))&&(t.left<r.right||n>=0&&tr(t.left,r.right,n))&&(r.top<t.bottom||n>=0&&tr(r.top,t.bottom,n))&&(t.top<r.bottom||n>=0&&tr(t.top,r.bottom,n))}function F_(r,t,n){for(let i=0;i<r.length;i++)for(let o=i+1;o<r.length;o++){let s=r[i],l=r[o];if(s===l){Xn.default.log("mergeTouchingRects rect1 === rect2 ??!");continue}let h=tr(s.top,l.top,t)&&tr(s.bottom,l.bottom,t),u=tr(s.left,l.left,t)&&tr(s.right,l.right,t);if((u&&!n||h&&!u)&&F0(s,l,t)){Xn.default.log(`CLIENT RECT: merging two into one, VERTICAL: ${h} HORIZONTAL: ${u} (${n})`);let w=r.filter(g=>g!==s&&g!==l),v=K5(s,l);return w.push(v),F_(w,t,n)}}return r}function j_(r){for(let t=0;t<r.length;t++)for(let n=t+1;n<r.length;n++){let i=r[t],o=r[n];if(i===o){Xn.default.log("replaceOverlappingRects rect1 === rect2 ??!");continue}if(F0(i,o,-1)){let s=[],l,h,u=D_(i,o);if(u.length===1)s=u,l=i,h=o;else{let y=D_(o,i);u.length<y.length?(s=u,l=i,h=o):(s=y,l=o,h=i)}let d=[];d.push(h),Array.prototype.push.apply(d,s),H_(d),Xn.default.log(`CLIENT RECT: overlap, cut one rect into ${s.length}`);let m=r.filter(y=>y!==l);return Array.prototype.push.apply(m,s),j_(m)}}return r}function Y5(r,t){return Math.max(0,Math.min(r.right,t.right)-Math.max(r.left,t.left))}function X5(r,t){return Math.max(0,Math.min(r.bottom,t.bottom)-Math.max(r.top,t.top))}function Z5(r,t){let n=new Set(r);for(let i of r){if(!(i.width>1&&i.height>1)){Xn.default.log("CLIENT RECT: remove tiny"),n.delete(i);continue}for(let s of r)if(i!==s&&!!n.has(s)&&J5(s,i,t)){Xn.default.log("CLIENT RECT: remove contained"),n.delete(i);break}}return Array.from(n)}function H_(r){let t=[];for(let n of r)for(let i of r){if(n===i)continue;let o=t.indexOf(n)>=0,s=t.indexOf(i)>=0;if((!o||!s)&&F0(n,i,-1)){o||t.push(n),s||t.push(i),Xn.default.log("CLIENT RECT: overlap ---"),Xn.default.log(`#1 TOP:${n.top} BOTTOM:${n.bottom} LEFT:${n.left} RIGHT:${n.right} WIDTH:${n.width} HEIGHT:${n.height}`),Xn.default.log(`#2 TOP:${i.top} BOTTOM:${i.bottom} LEFT:${i.left} RIGHT:${i.right} WIDTH:${i.width} HEIGHT:${i.height}`);let l=Y5(n,i);Xn.default.log(`xOverlap: ${l}`);let h=X5(n,i);Xn.default.log(`yOverlap: ${h}`)}}t.length&&Xn.default.log(`CLIENT RECT: overlaps ${t.length}`)}H();var Zt=gt(cn());function Ir(r,t){let n=r?r.getSelection():null;if(!n)return;if(n.isCollapsed){Zt.default.log("^^^ SELECTION COLLAPSED.");return}let i=n.toString(),o=i.trim().replace(/\n/g," ").replace(/\s\s+/g," ");if(o.length===0){Zt.default.log("^^^ SELECTION TEXT EMPTY.");return}if(!n.anchorNode||!n.focusNode)return;let s=n.rangeCount===1?n.getRangeAt(0):U_(n.anchorNode,n.anchorOffset,n.focusNode,n.focusOffset);if(!s||s.collapsed){Zt.default.log("$$$$$$$$$$$$$$$$$ CANNOT GET NON-COLLAPSED SELECTION RANGE?!");return}let l=eD(s);l.startContainer!==s.startContainer&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startContainer"),Zt.default.log(l.startContainer),Zt.default.log(s.startContainer)),l.startOffset!==s.startOffset&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startOffset"),Zt.default.log(`${l.startOffset} !== ${s.startOffset}`)),l.endContainer!==s.endContainer&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endContainer"),Zt.default.log(l.endContainer),Zt.default.log(s.endContainer)),l.endOffset!==s.endOffset&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endOffset"),Zt.default.log(`${l.endOffset} !== ${s.endOffset}`));let h=oo(l,t);if(!h){Zt.default.log("^^^ SELECTION RANGE INFO FAIL?!");return}return{rangeInfo:h,cleanText:o,rawText:i,range:l}}function U_(r,t,n,i){try{let o=new Range;if(o.setStart(r,t),o.setEnd(n,i),!o.collapsed)return Zt.default.log(">>> createOrderedRange RANGE OK"),o;Zt.default.log(">>> createOrderedRange COLLAPSED ... RANGE REVERSE?");let s=new Range;if(s.setStart(n,i),s.setEnd(r,t),!s.collapsed)return Zt.default.log(">>> createOrderedRange RANGE REVERSE OK."),o;Zt.default.log(">>> createOrderedRange RANGE REVERSE ALSO COLLAPSED?!");return}catch(o){console.warn(o.message);return}}function oo(r,t){let n=r.startContainer.nodeType===Node.ELEMENT_NODE,i=n?r.startContainer:r.startContainer.parentNode&&r.startContainer.parentNode.nodeType===Node.ELEMENT_NODE?r.startContainer.parentNode:void 0;if(!i)return;let o=n?-1:Array.from(i.childNodes).indexOf(r.startContainer);if(o<-1)return;let s=t(i),l=r.endContainer.nodeType===Node.ELEMENT_NODE,h=l?r.endContainer:r.endContainer.parentNode&&r.endContainer.parentNode.nodeType===Node.ELEMENT_NODE?r.endContainer.parentNode:void 0;if(!h)return;let u=l?-1:Array.from(h.childNodes).indexOf(r.endContainer);if(u<-1)return;let d=t(h),m=Q5(r.startContainer,r.endContainer);if(!m){Zt.default.log("^^^ NO RANGE COMMON ANCESTOR?!");return}if(r.commonAncestorContainer){let y=r.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?r.commonAncestorContainer:r.commonAncestorContainer.parentNode;y&&y.nodeType===Node.ELEMENT_NODE&&m!==y&&(Zt.default.log(">>>>>> COMMON ANCESTOR CONTAINER DIFF??!"),Zt.default.log(t(m)),Zt.default.log(t(y)))}if(d&&s)return{endContainerChildTextNodeIndex:u,endContainerElementCssSelector:d,endOffset:r.endOffset,startContainerChildTextNodeIndex:o,startContainerElementCssSelector:s,startOffset:r.startOffset}}function th(r,t){let n=r.querySelector(t.startContainerElementCssSelector);if(!n){Zt.default.log("^^^ convertRangeInfo NO START ELEMENT CSS SELECTOR?!");return}let i=n;if(t.startContainerChildTextNodeIndex>=0){if(t.startContainerChildTextNodeIndex>=n.childNodes.length){Zt.default.log("^^^ convertRangeInfo rangeInfo.startContainerChildTextNodeIndex >= startElement.childNodes.length?!");return}if(i=n.childNodes[t.startContainerChildTextNodeIndex],i.nodeType!==Node.TEXT_NODE){Zt.default.log("^^^ convertRangeInfo startContainer.nodeType !== Node.TEXT_NODE?!");return}}let o=r.querySelector(t.endContainerElementCssSelector);if(!o){Zt.default.log("^^^ convertRangeInfo NO END ELEMENT CSS SELECTOR?!");return}let s=o;if(t.endContainerChildTextNodeIndex>=0){if(t.endContainerChildTextNodeIndex>=o.childNodes.length){Zt.default.log("^^^ convertRangeInfo rangeInfo.endContainerChildTextNodeIndex >= endElement.childNodes.length?!");return}if(s=o.childNodes[t.endContainerChildTextNodeIndex],s.nodeType!==Node.TEXT_NODE){Zt.default.log("^^^ convertRangeInfo endContainer.nodeType !== Node.TEXT_NODE?!");return}}return U_(i,t.startOffset,s,t.endOffset)}function Q5(r,t){if(r.nodeType===Node.ELEMENT_NODE&&r===t||r.nodeType===Node.ELEMENT_NODE&&r.contains(t))return r;if(t.nodeType===Node.ELEMENT_NODE&&t.contains(r))return t;let n=[],i=r.parentNode;for(;i&&i.nodeType===Node.ELEMENT_NODE;)n.push(i),i=i.parentNode;let o=[];for(i=t.parentNode;i&&i.nodeType===Node.ELEMENT_NODE;)o.push(i),i=i.parentNode;let s=n.find(l=>o.indexOf(l)>=0);return s||(s=o.find(l=>n.indexOf(l)>=0)),s}function eD(r){let t=r.cloneRange(),n=t.startContainer,i=t.startOffset,o=t.endContainer,s=t.endOffset;n.childNodes.length&&i>0&&(n=q_(n.childNodes[i-1]),i=n.length||0),s<o.childNodes.length&&(o=$_(o.childNodes[s]),s=0);let l=$_(n),h=q_(o);function u(d){if(d.childNodes.length)return!1;let m=d.length||0;return d===n&&i===m?!1:!(d===o&&s===0)}for(;l&&!u(l)&&l!==h;)l=tD(l);for(l===n?t.setStart(n,i):l!==null&&(l.nodeType===3?t.setStart(l,0):t.setStartBefore(l));h&&!u(h)&&h!==l;)h=nD(h);return h===o?t.setEnd(o,s):h!==null&&(h.nodeType===3?t.setEnd(h,h.length):t.setEndAfter(h)),t}function tD(r){if(r.firstChild)return r.firstChild;let t=r;for(;!t.nextSibling;)if(t=t.parentNode,!t)return null;return t.nextSibling}function nD(r){if(r.lastChild)return r.lastChild;let t=r;for(;!t.previousSibling;)if(t=t.parentNode,!t)return null;return t.previousSibling}function $_(r){for(;r.firstChild;)r=r.firstChild;return r}function q_(r){for(;r.lastChild;)r=r.lastChild;return r}H();var H0=gt(z_()),Io;(function(i){i[i.All=0]="All",i[i.Two=1]="Two",i[i.One=2]="One"})(Io||(Io={}));var so,U0;function Nn(r,t,n){if(r.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(r.tagName.toLowerCase()==="html")return r.tagName.toLowerCase();let i={className:s=>!0,idName:s=>!0,optimizedMinLength:2,root:t.body,seedMinLength:1,tagName:s=>!0,threshold:1e3};so=dt(dt({},i),n),U0=cD(so.root,i);let o=$0(r,0,()=>$0(r,1,()=>$0(r,2)));if(o){let s=Y_(X_(o,r));return s.length>0&&(o=s[0]),nh(o)}else throw new Error("Selector was not found.")}function cD(r,t){return r.nodeType===Node.DOCUMENT_NODE?r:r===t.root?r.ownerDocument:r}function $0(r,t,n){let i=null,o=[],s=r,l=0;for(;s&&s!==so.root.parentElement;){let h=z0(uD(s))||z0(...dD(s))||z0(hD(s))||[fD()],u=pD(s);if(t===0)u&&(h=h.concat(h.filter(W0).map(d=>q0(d,u))));else if(t===1)h=h.slice(0,1),u&&(h=h.concat(h.filter(W0).map(d=>q0(d,u))));else if(t===2){let[d]=h=h.slice(0,1);u&&W0(d)&&(h=[q0(d,u)])}for(let d of h)d.level=l;if(o.push(h),o.length>=so.seedMinLength&&(i=G_(o,n),i))break;s=s.parentElement,l++}return i||(i=G_(o,n)),i}function G_(r,t){let n=Y_(K_(r));if(n.length>so.threshold)return t?t():null;for(let i of n)if(J_(i))return i;return null}function nh(r){let t=r[0],n=t.name;for(let i=1;i<r.length;i++){let o=r[i].level||0;t.level===o-1?n=`${r[i].name} > ${n}`:n=`${r[i].name} ${n}`,t=r[i]}return n}function V_(r){return r.map(t=>t.penalty).reduce((t,n)=>t+n,0)}function J_(r){switch(U0.querySelectorAll(nh(r)).length){case 0:throw new Error(`Can't select any node with this selector: ${nh(r)}`);case 1:return!0;default:return!1}}function uD(r){let t=r.getAttribute("id");return t&&so.idName(t)?{name:"#"+(0,H0.default)(t,{isIdentifier:!0}),penalty:0}:null}function dD(r){return Array.from(r.classList).filter(so.className).map(n=>({name:"."+(0,H0.default)(n,{isIdentifier:!0}),penalty:1}))}function hD(r){let t=r.tagName.toLowerCase();return so.tagName(t)?{name:t,penalty:2}:null}function fD(){return{name:"*",penalty:3}}function pD(r){let t=r.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let i=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&i++,n!==r);)n=n.nextSibling;return i}function q0(r,t){return{name:r.name+`:nth-child(${t})`,penalty:r.penalty+1}}function W0(r){return r.name!=="html"&&!r.name.startsWith("#")}function z0(...r){let t=r.filter(gD);return t.length>0?t:null}function gD(r){return r!=null}function*K_(r,t=[]){if(r.length>0)for(let n of r[0])yield*K_(r.slice(1,r.length),t.concat(n));else yield t}function Y_(r){return Array.from(r).sort((t,n)=>V_(t)-V_(n))}function*X_(r,t){if(r.length>2&&r.length>so.optimizedMinLength)for(let n=1;n<r.length-1;n++){let i=[...r];i.splice(n,1),J_(i)&&mD(i,t)&&(yield i,yield*X_(i,t))}}function mD(r,t){return U0.querySelector(nh(r))===t}H();var ot;(function(s){s[s.Highlight=0]="Highlight",s[s.Underline=1]="Underline",s[s.Bookmark=2]="Bookmark",s[s.Custom=3]="Custom",s[s.Comment=4]="Comment"})(ot||(ot={}));H();var G0=24,yD=24,Z_="0 0 24 24",mi=(r,t,n,i="icon")=>`<svg xmlns="http://www.w3.org/2000/svg" width="${G0}" height="${yD}" viewBox="${Z_}" preserveAspectRatio="xMidYMid meet" role="img" class="${i}" aria-labelledBy="${r}">
72
+ `}setFont(E){let T=this.current,R=this.commonObjs.get(E[0]),O=E[1];T.font=R,this.embedFonts&&!R.missingFile&&!this.embeddedFonts[R.loadedName]&&(this.addFontStyle(R),this.embeddedFonts[R.loadedName]=R),T.fontMatrix=R.fontMatrix||o.FONT_IDENTITY_MATRIX;let L="normal";R.black?L="900":R.bold&&(L="bold");let M=R.italic?"italic":"normal";O<0?(O=-O,T.fontDirection=-1):T.fontDirection=1,T.fontSize=O,T.fontFamily=R.loadedName,T.fontWeight=L,T.fontStyle=M,T.tspan=this.svgFactory.createElement("svg:tspan"),T.tspan.setAttributeNS(null,"y",p(-T.y)),T.xcoords=[],T.ycoords=[]}endText(){let E=this.current;E.textRenderingMode&o.TextRenderingMode.ADD_TO_PATH_FLAG&&E.txtElement?.hasChildNodes()&&(E.element=E.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(E){E>0&&(this.current.lineWidth=E)}setLineCap(E){this.current.lineCap=m[E]}setLineJoin(E){this.current.lineJoin=y[E]}setMiterLimit(E){this.current.miterLimit=E}setStrokeAlpha(E){this.current.strokeAlpha=E}setStrokeRGBColor(E,T,R){this.current.strokeColor=o.Util.makeHexColor(E,T,R)}setFillAlpha(E){this.current.fillAlpha=E}setFillRGBColor(E,T,R){this.current.fillColor=o.Util.makeHexColor(E,T,R),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){let T=this.viewport.width,R=this.viewport.height,O=o.Util.inverseTransform(this.transformMatrix),L=o.Util.applyTransform([0,0],O),M=o.Util.applyTransform([0,R],O),k=o.Util.applyTransform([T,0],O),F=o.Util.applyTransform([T,R],O),q=Math.min(L[0],M[0],k[0],F[0]),G=Math.min(L[1],M[1],k[1],F[1]),ie=Math.max(L[0],M[0],k[0],F[0]),ee=Math.max(L[1],M[1],k[1],F[1]),Z=this.svgFactory.createElement("svg:rect");Z.setAttributeNS(null,"x",q),Z.setAttributeNS(null,"y",G),Z.setAttributeNS(null,"width",ie-q),Z.setAttributeNS(null,"height",ee-G),Z.setAttributeNS(null,"fill",this._makeShadingPattern(E)),this.current.fillAlpha<1&&Z.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(Z)}_makeColorN_Pattern(E){return E[0]==="TilingPattern"?this._makeTilingPattern(E):this._makeShadingPattern(E)}_makeTilingPattern(E){let T=E[1],R=E[2],O=E[3]||o.IDENTITY_MATRIX,[L,M,k,F]=E[4],q=E[5],G=E[6],ie=E[7],ee=`shading${x++}`,[Z,X,ce,we]=o.Util.normalizeRect([...o.Util.applyTransform([L,M],O),...o.Util.applyTransform([k,F],O)]),[ve,Q]=o.Util.singularValueDecompose2dScale(O),N=q*ve,B=G*Q,D=this.svgFactory.createElement("svg:pattern");D.setAttributeNS(null,"id",ee),D.setAttributeNS(null,"patternUnits","userSpaceOnUse"),D.setAttributeNS(null,"width",N),D.setAttributeNS(null,"height",B),D.setAttributeNS(null,"x",`${Z}`),D.setAttributeNS(null,"y",`${X}`);let W=this.svg,z=this.transformMatrix,J=this.current.fillColor,he=this.current.strokeColor,fe=this.svgFactory.create(ce-Z,we-X);if(this.svg=fe,this.transformMatrix=O,ie===2){let I=o.Util.makeHexColor(...T);this.current.fillColor=I,this.current.strokeColor=I}return this.executeOpTree(this.convertOpList(R)),this.svg=W,this.transformMatrix=z,this.current.fillColor=J,this.current.strokeColor=he,D.append(fe.childNodes[0]),this.defs.append(D),`url(#${ee})`}_makeShadingPattern(E){switch(typeof E=="string"&&(E=this.objs.get(E)),E[0]){case"RadialAxial":let T=`shading${x++}`,R=E[3],O;switch(E[1]){case"axial":let L=E[4],M=E[5];O=this.svgFactory.createElement("svg:linearGradient"),O.setAttributeNS(null,"id",T),O.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),O.setAttributeNS(null,"x1",L[0]),O.setAttributeNS(null,"y1",L[1]),O.setAttributeNS(null,"x2",M[0]),O.setAttributeNS(null,"y2",M[1]);break;case"radial":let k=E[4],F=E[5],q=E[6],G=E[7];O=this.svgFactory.createElement("svg:radialGradient"),O.setAttributeNS(null,"id",T),O.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),O.setAttributeNS(null,"cx",F[0]),O.setAttributeNS(null,"cy",F[1]),O.setAttributeNS(null,"r",G),O.setAttributeNS(null,"fx",k[0]),O.setAttributeNS(null,"fy",k[1]),O.setAttributeNS(null,"fr",q);break;default:throw new Error(`Unknown RadialAxial type: ${E[1]}`)}for(let L of R){let M=this.svgFactory.createElement("svg:stop");M.setAttributeNS(null,"offset",L[0]),M.setAttributeNS(null,"stop-color",L[1]),O.append(M)}return this.defs.append(O),`url(#${T})`;case"Mesh":return(0,o.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${E[0]}`)}}setDash(E,T){this.current.dashArray=E,this.current.dashPhase=T}constructPath(E,T){let R=this.current,O=R.x,L=R.y,M=[],k=0;for(let F of E)switch(F|0){case o.OPS.rectangle:O=T[k++],L=T[k++];let q=T[k++],G=T[k++],ie=O+q,ee=L+G;M.push("M",p(O),p(L),"L",p(ie),p(L),"L",p(ie),p(ee),"L",p(O),p(ee),"Z");break;case o.OPS.moveTo:O=T[k++],L=T[k++],M.push("M",p(O),p(L));break;case o.OPS.lineTo:O=T[k++],L=T[k++],M.push("L",p(O),p(L));break;case o.OPS.curveTo:O=T[k+4],L=T[k+5],M.push("C",p(T[k]),p(T[k+1]),p(T[k+2]),p(T[k+3]),p(O),p(L)),k+=6;break;case o.OPS.curveTo2:M.push("C",p(O),p(L),p(T[k]),p(T[k+1]),p(T[k+2]),p(T[k+3])),O=T[k+2],L=T[k+3],k+=4;break;case o.OPS.curveTo3:O=T[k+2],L=T[k+3],M.push("C",p(T[k]),p(T[k+1]),p(O),p(L),p(O),p(L)),k+=4;break;case o.OPS.closePath:M.push("Z");break}M=M.join(" "),R.path&&E.length>0&&E[0]!==o.OPS.rectangle&&E[0]!==o.OPS.moveTo?M=R.path.getAttributeNS(null,"d")+M:(R.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(R.path)),R.path.setAttributeNS(null,"d",M),R.path.setAttributeNS(null,"fill","none"),R.element=R.path,R.setCurrentPoint(O,L)}endPath(){let E=this.current;if(E.path=null,!this.pendingClip)return;if(!E.element){this.pendingClip=null;return}let T=`clippath${S++}`,R=this.svgFactory.createElement("svg:clipPath");R.setAttributeNS(null,"id",T),R.setAttributeNS(null,"transform",b(this.transformMatrix));let O=E.element.cloneNode(!0);if(this.pendingClip==="evenodd"?O.setAttributeNS(null,"clip-rule","evenodd"):O.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,R.append(O),this.defs.append(R),E.activeClipUrl){E.clipGroup=null;for(let L of this.extraStack)L.clipGroup=null;R.setAttributeNS(null,"clip-path",E.activeClipUrl)}E.activeClipUrl=`url(#${T})`,this.tgrp=null}clip(E){this.pendingClip=E}closePath(){let E=this.current;if(E.path){let T=`${E.path.getAttributeNS(null,"d")}Z`;E.path.setAttributeNS(null,"d",T)}}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(let[T,R]of E)switch(T){case"LW":this.setLineWidth(R);break;case"LC":this.setLineCap(R);break;case"LJ":this.setLineJoin(R);break;case"ML":this.setMiterLimit(R);break;case"D":this.setDash(R[0],R[1]);break;case"RI":this.setRenderingIntent(R);break;case"FL":this.setFlatness(R);break;case"Font":this.setFont(R);break;case"CA":this.setStrokeAlpha(R);break;case"ca":this.setFillAlpha(R);break;default:(0,o.warn)(`Unimplemented graphic state operator ${T}`);break}}fill(){let E=this.current;E.element&&(E.element.setAttributeNS(null,"fill",E.fillColor),E.element.setAttributeNS(null,"fill-opacity",E.fillAlpha),this.endPath())}stroke(){let E=this.current;E.element&&(this._setStrokeAttributes(E.element),E.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(E,T=1){let R=this.current,O=R.dashArray;T!==1&&O.length>0&&(O=O.map(function(L){return T*L})),E.setAttributeNS(null,"stroke",R.strokeColor),E.setAttributeNS(null,"stroke-opacity",R.strokeAlpha),E.setAttributeNS(null,"stroke-miterlimit",p(R.miterLimit)),E.setAttributeNS(null,"stroke-linecap",R.lineCap),E.setAttributeNS(null,"stroke-linejoin",R.lineJoin),E.setAttributeNS(null,"stroke-width",p(T*R.lineWidth)+"px"),E.setAttributeNS(null,"stroke-dasharray",O.map(p).join(" ")),E.setAttributeNS(null,"stroke-dashoffset",p(T*R.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(){let 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){let T=E.startsWith("g_")?this.commonObjs.get(E):this.objs.get(E);if(!T){(0,o.warn)(`Dependent image with object ID ${E} is not ready yet`);return}this.paintInlineImageXObject(T)}paintInlineImageXObject(E,T){let R=E.width,O=E.height,L=v(E,this.forceDataSchema,!!T),M=this.svgFactory.createElement("svg:rect");M.setAttributeNS(null,"x","0"),M.setAttributeNS(null,"y","0"),M.setAttributeNS(null,"width",p(R)),M.setAttributeNS(null,"height",p(O)),this.current.element=M,this.clip("nonzero");let k=this.svgFactory.createElement("svg:image");k.setAttributeNS(d,"xlink:href",L),k.setAttributeNS(null,"x","0"),k.setAttributeNS(null,"y",p(-O)),k.setAttributeNS(null,"width",p(R)+"px"),k.setAttributeNS(null,"height",p(O)+"px"),k.setAttributeNS(null,"transform",`scale(${p(1/R)} ${p(-1/O)})`),T?T.append(k):this._ensureTransformGroup().append(k)}paintImageMaskXObject(E){let T=this.current,R=E.width,O=E.height,L=T.fillColor;T.maskId=`mask${C++}`;let M=this.svgFactory.createElement("svg:mask");M.setAttributeNS(null,"id",T.maskId);let k=this.svgFactory.createElement("svg:rect");k.setAttributeNS(null,"x","0"),k.setAttributeNS(null,"y","0"),k.setAttributeNS(null,"width",p(R)),k.setAttributeNS(null,"height",p(O)),k.setAttributeNS(null,"fill",L),k.setAttributeNS(null,"mask",`url(#${T.maskId})`),this.defs.append(M),this._ensureTransformGroup().append(k),this.paintInlineImageXObject(E,M)}paintFormXObjectBegin(E,T){if(Array.isArray(E)&&E.length===6&&this.transform(E[0],E[1],E[2],E[3],E[4],E[5]),T){let R=T[2]-T[0],O=T[3]-T[1],L=this.svgFactory.createElement("svg:rect");L.setAttributeNS(null,"x",T[0]),L.setAttributeNS(null,"y",T[1]),L.setAttributeNS(null,"width",p(R)),L.setAttributeNS(null,"height",p(O)),this.current.element=L,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(E){let T=this.svgFactory.create(E.width,E.height),R=this.svgFactory.createElement("svg:defs");T.append(R),this.defs=R;let O=this.svgFactory.createElement("svg:g");return O.setAttributeNS(null,"transform",b(E.transform)),T.append(O),this.svg=O,T}_ensureClipGroup(){if(!this.current.clipGroup){let 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",b(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNodeStream=void 0;var i=n(1),o=n(33);let s=Cd(),l=bx(),h=vx(),u=xd(),d=/^file:\/\/\/[a-zA-Z]:\//;function m(C){let x=u.parse(C);return x.protocol==="file:"||x.host?x:/^[a-z]:[/\\]/i.test(C)?u.parse(`file:///${C}`):(x.host||(x.protocol="file:"),x)}class y{constructor(x){this.source=x,this.url=m(x.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&x.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new b(this):new f(this),this._fullRequestReader}getRangeReader(x,E){if(E<=this._progressiveDataLength)return null;let T=this.isFsUrl?new S(this,x,E):new p(this,x,E);return this._rangeRequestReaders.push(T),T}cancelAllRequests(x){this._fullRequestReader&&this._fullRequestReader.cancel(x);for(let E of this._rangeRequestReaders.slice(0))E.cancel(x)}}t.PDFNodeStream=y;class w{constructor(x){this._url=x.url,this._done=!1,this._storedError=null,this.onProgress=null;let E=x.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,i.createPromiseCapability)(),this._headersCapability=(0,i.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;let x=this._readableStream.read();return x===null?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=x.length,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(x).buffer,done:!1})}cancel(x){if(!this._readableStream){this._error(x);return}this._readableStream.destroy(x)}_error(x){this._storedError=x,this._readCapability.resolve()}_setReadableStream(x){this._readableStream=x,x.on("readable",()=>{this._readCapability.resolve()}),x.on("end",()=>{x.destroy(),this._done=!0,this._readCapability.resolve()}),x.on("error",E=>{this._error(E)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class v{constructor(x){this._url=x.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=(0,i.createPromiseCapability)();let E=x.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;let x=this._readableStream.read();return x===null?(this._readCapability=(0,i.createPromiseCapability)(),this.read()):(this._loaded+=x.length,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(x).buffer,done:!1})}cancel(x){if(!this._readableStream){this._error(x);return}this._readableStream.destroy(x)}_error(x){this._storedError=x,this._readCapability.resolve()}_setReadableStream(x){this._readableStream=x,x.on("readable",()=>{this._readCapability.resolve()}),x.on("end",()=>{x.destroy(),this._done=!0,this._readCapability.resolve()}),x.on("error",E=>{this._error(E)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function g(C,x){return{protocol:C.protocol,auth:C.auth,host:C.hostname,port:C.port,path:C.path,method:"GET",headers:x}}class f extends w{constructor(x){super(x);let E=T=>{if(T.statusCode===404){let M=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=M,this._headersCapability.reject(M);return}this._headersCapability.resolve(),this._setReadableStream(T);let R=M=>this._readableStream.headers[M.toLowerCase()],{allowRangeRequests:O,suggestedLength:L}=(0,o.validateRangeRequestCapabilities)({getResponseHeader:R,isHttp:x.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=O,this._contentLength=L||this._contentLength,this._filename=(0,o.extractFilenameFromHeader)(R)};this._request=null,this._url.protocol==="http:"?this._request=l.request(g(this._url,x.httpHeaders),E):this._request=h.request(g(this._url,x.httpHeaders),E),this._request.on("error",T=>{this._storedError=T,this._headersCapability.reject(T)}),this._request.end()}}class p extends v{constructor(x,E,T){super(x);this._httpHeaders={};for(let O in x.httpHeaders){let L=x.httpHeaders[O];typeof L!="undefined"&&(this._httpHeaders[O]=L)}this._httpHeaders.Range=`bytes=${E}-${T-1}`;let R=O=>{if(O.statusCode===404){let L=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=L;return}this._setReadableStream(O)};this._request=null,this._url.protocol==="http:"?this._request=l.request(g(this._url,this._httpHeaders),R):this._request=h.request(g(this._url,this._httpHeaders),R),this._request.on("error",O=>{this._storedError=O}),this._request.end()}}class b extends w{constructor(x){super(x);let E=decodeURIComponent(this._url.path);d.test(this._url.href)&&(E=E.replace(/^\//,"")),s.lstat(E,(T,R)=>{if(T){T.code==="ENOENT"&&(T=new i.MissingPDFException(`Missing PDF "${E}".`)),this._storedError=T,this._headersCapability.reject(T);return}this._contentLength=R.size,this._setReadableStream(s.createReadStream(E)),this._headersCapability.resolve()})}}class S extends v{constructor(x,E,T){super(x);let R=decodeURIComponent(this._url.path);d.test(this._url.href)&&(R=R.replace(/^\//,"")),this._setReadableStream(s.createReadStream(R,{start:E,end:T-1}))}}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=u,t.extractFilenameFromHeader=h,t.validateRangeRequestCapabilities=l,t.validateResponseStatus=d;var i=n(1),o=n(34),s=n(8);function l({getResponseHeader:m,isHttp:y,rangeChunkSize:w,disableRange:v}){let g={allowRangeRequests:!1,suggestedLength:void 0},f=parseInt(m("Content-Length"),10);return!Number.isInteger(f)||(g.suggestedLength=f,f<=2*w)||v||!y||m("Accept-Ranges")!=="bytes"||(m("Content-Encoding")||"identity")!=="identity"||(g.allowRangeRequests=!0),g}function h(m){let y=m("Content-Disposition");if(y){let w=(0,o.getFilenameFromContentDispositionHeader)(y);if(w.includes("%"))try{w=decodeURIComponent(w)}catch(v){}if((0,s.isPdfFile)(w))return w}return null}function u(m,y){return m===404||m===0&&y.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+y+'".'):new i.UnexpectedResponseException(`Unexpected server response (${m}) while retrieving PDF "${y}".`,m)}function d(m){return m===200||m===206}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=o;var i=n(1);function o(s){let l=!0,h=u("filename\\*","i").exec(s);if(h){h=h[1];let f=w(h);return f=unescape(f),f=v(f),f=g(f),m(f)}if(h=y(s),h){let f=g(h);return m(f)}if(h=u("filename","i").exec(s),h){h=h[1];let f=w(h);return f=g(f),m(f)}function u(f,p){return new RegExp("(?:^|;)\\s*"+f+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',p)}function d(f,p){if(f){if(!/^[\x00-\xFF]+$/.test(p))return p;try{let b=new TextDecoder(f,{fatal:!0}),S=(0,i.stringToBytes)(p);p=b.decode(S),l=!1}catch(b){}}return p}function m(f){return l&&/[\x80-\xff]/.test(f)&&(f=d("utf-8",f),l&&(f=d("iso-8859-1",f))),f}function y(f){let p=[],b,S=u("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(b=S.exec(f))!==null;){let[,x,E,T]=b;if(x=parseInt(x,10),x in p){if(x===0)break;continue}p[x]=[E,T]}let C=[];for(let x=0;x<p.length&&x in p;++x){let[E,T]=p[x];T=w(T),E&&(T=unescape(T),x===0&&(T=v(T))),C.push(T)}return C.join("")}function w(f){if(f.startsWith('"')){let p=f.slice(1).split('\\"');for(let b=0;b<p.length;++b){let S=p[b].indexOf('"');S!==-1&&(p[b]=p[b].slice(0,S),p.length=b+1),p[b]=p[b].replace(/\\(.)/g,"$1")}f=p.join('"')}return f}function v(f){let p=f.indexOf("'");if(p===-1)return f;let b=f.slice(0,p),C=f.slice(p+1).replace(/^[^']*'/,"");return d(b,C)}function g(f){return!f.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(f)?f:f.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(p,b,S,C){if(S==="q"||S==="Q")return C=C.replace(/_/g," "),C=C.replace(/=([0-9a-fA-F]{2})/g,function(x,E){return String.fromCharCode(parseInt(E,16))}),d(b,C);try{C=atob(C)}catch(x){}return d(b,C)})}return""}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNetworkStream=void 0;var i=n(1),o=n(33);let s=200,l=206;function h(w){let v=w.response;return typeof v!="string"?v:(0,i.stringToBytes)(v).buffer}class u{constructor(v,g={}){this.url=v,this.isHttp=/^https?:/i.test(v),this.httpHeaders=this.isHttp&&g.httpHeaders||Object.create(null),this.withCredentials=g.withCredentials||!1,this.getXhr=g.getXhr||function(){return new XMLHttpRequest},this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(v,g,f){let p={begin:v,end:g};for(let b in f)p[b]=f[b];return this.request(p)}requestFull(v){return this.request(v)}request(v){let g=this.getXhr(),f=this.currXhrId++,p=this.pendingRequests[f]={xhr:g};g.open("GET",this.url),g.withCredentials=this.withCredentials;for(let b in this.httpHeaders){let S=this.httpHeaders[b];typeof S!="undefined"&&g.setRequestHeader(b,S)}return this.isHttp&&"begin"in v&&"end"in v?(g.setRequestHeader("Range",`bytes=${v.begin}-${v.end-1}`),p.expectedStatus=l):p.expectedStatus=s,g.responseType="arraybuffer",v.onError&&(g.onerror=function(b){v.onError(g.status)}),g.onreadystatechange=this.onStateChange.bind(this,f),g.onprogress=this.onProgress.bind(this,f),p.onHeadersReceived=v.onHeadersReceived,p.onDone=v.onDone,p.onError=v.onError,p.onProgress=v.onProgress,g.send(null),f}onProgress(v,g){let f=this.pendingRequests[v];!f||f.onProgress?.(g)}onStateChange(v,g){let f=this.pendingRequests[v];if(!f)return;let p=f.xhr;if(p.readyState>=2&&f.onHeadersReceived&&(f.onHeadersReceived(),delete f.onHeadersReceived),p.readyState!==4||!(v in this.pendingRequests))return;if(delete this.pendingRequests[v],p.status===0&&this.isHttp){f.onError?.(p.status);return}let b=p.status||s;if(!(b===s&&f.expectedStatus===l)&&b!==f.expectedStatus){f.onError?.(p.status);return}let C=h(p);if(b===l){let x=p.getResponseHeader("Content-Range"),E=/bytes (\d+)-(\d+)\/(\d+)/.exec(x);f.onDone({begin:parseInt(E[1],10),chunk:C})}else C?f.onDone({begin:0,chunk:C}):f.onError?.(p.status)}getRequestXhr(v){return this.pendingRequests[v].xhr}isPendingRequest(v){return v in this.pendingRequests}abortRequest(v){let g=this.pendingRequests[v].xhr;delete this.pendingRequests[v],g.abort()}}class d{constructor(v){this._source=v,this._manager=new u(v.url,{httpHeaders:v.httpHeaders,withCredentials:v.withCredentials}),this._rangeChunkSize=v.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(v){let g=this._rangeRequestReaders.indexOf(v);g>=0&&this._rangeRequestReaders.splice(g,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new m(this._manager,this._source),this._fullRequestReader}getRangeReader(v,g){let f=new y(this._manager,v,g);return f.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(f),f}cancelAllRequests(v){this._fullRequestReader?.cancel(v);for(let g of this._rangeRequestReaders.slice(0))g.cancel(v)}}t.PDFNetworkStream=d;class m{constructor(v,g){this._manager=v;let f={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=g.url,this._fullRequestId=v.requestFull(f),this._headersReceivedCapability=(0,i.createPromiseCapability)(),this._disableRange=g.disableRange||!1,this._contentLength=g.length,this._rangeChunkSize=g.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(){let v=this._fullRequestId,g=this._manager.getRequestXhr(v),f=S=>g.getResponseHeader(S),{allowRangeRequests:p,suggestedLength:b}=(0,o.validateRangeRequestCapabilities)({getResponseHeader:f,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});p&&(this._isRangeSupported=!0),this._contentLength=b||this._contentLength,this._filename=(0,o.extractFilenameFromHeader)(f),this._isRangeSupported&&this._manager.abortRequest(v),this._headersReceivedCapability.resolve()}_onDone(v){if(v&&(this._requests.length>0?this._requests.shift().resolve({value:v.chunk,done:!1}):this._cachedChunks.push(v.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(v){this._storedError=(0,o.createResponseStatusError)(v,this._url),this._headersReceivedCapability.reject(this._storedError);for(let g of this._requests)g.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(v){this.onProgress?.({loaded:v.loaded,total:v.lengthComputable?v.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};let v=(0,i.createPromiseCapability)();return this._requests.push(v),v.promise}cancel(v){this._done=!0,this._headersReceivedCapability.reject(v);for(let g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class y{constructor(v,g,f){this._manager=v;let p={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=v.url,this._requestId=v.requestRange(g,f,p),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(v){let g=v.chunk;this._requests.length>0?this._requests.shift().resolve({value:g,done:!1}):this._queuedChunk=g,this._done=!0;for(let f of this._requests)f.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(v){this._storedError=(0,o.createResponseStatusError)(v,this._url);for(let g of this._requests)g.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(v){this.isStreamingSupported||this.onProgress?.({loaded:v.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let g=this._queuedChunk;return this._queuedChunk=null,{value:g,done:!1}}if(this._done)return{value:void 0,done:!0};let v=(0,i.createPromiseCapability)();return this._requests.push(v),v.promise}cancel(v){this._done=!0;for(let g of this._requests)g.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(r,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFetchStream=void 0;var i=n(1),o=n(33);function s(m,y,w){return{method:"GET",headers:m,signal:w.signal,mode:"cors",credentials:y?"include":"same-origin",redirect:"follow"}}function l(m){let y=new Headers;for(let w in m){let v=m[w];typeof v!="undefined"&&y.append(w,v)}return y}class h{constructor(y){this.source=y,this.isHttp=/^https?:/i.test(y.url),this.httpHeaders=this.isHttp&&y.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new u(this),this._fullRequestReader}getRangeReader(y,w){if(w<=this._progressiveDataLength)return null;let v=new d(this,y,w);return this._rangeRequestReaders.push(v),v}cancelAllRequests(y){this._fullRequestReader&&this._fullRequestReader.cancel(y);for(let w of this._rangeRequestReaders.slice(0))w.cancel(y)}}t.PDFFetchStream=h;class u{constructor(y){this._stream=y,this._reader=null,this._loaded=0,this._filename=null;let w=y.source;this._withCredentials=w.withCredentials||!1,this._contentLength=w.length,this._headersCapability=(0,i.createPromiseCapability)(),this._disableRange=w.disableRange||!1,this._rangeChunkSize=w.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!w.disableStream,this._isRangeSupported=!w.disableRange,this._headers=l(this._stream.httpHeaders);let v=w.url;fetch(v,s(this._headers,this._withCredentials,this._abortController)).then(g=>{if(!(0,o.validateResponseStatus)(g.status))throw(0,o.createResponseStatusError)(g.status,v);this._reader=g.body.getReader(),this._headersCapability.resolve();let f=S=>g.headers.get(S),{allowRangeRequests:p,suggestedLength:b}=(0,o.validateRangeRequestCapabilities)({getResponseHeader:f,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=p,this._contentLength=b||this._contentLength,this._filename=(0,o.extractFilenameFromHeader)(f),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.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;let{value:y,done:w}=await this._reader.read();return w?{value:y,done:w}:(this._loaded+=y.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(y).buffer,done:!1})}cancel(y){this._reader&&this._reader.cancel(y),this._abortController.abort()}}class d{constructor(y,w,v){this._stream=y,this._reader=null,this._loaded=0;let g=y.source;this._withCredentials=g.withCredentials||!1,this._readCapability=(0,i.createPromiseCapability)(),this._isStreamingSupported=!g.disableStream,this._abortController=new AbortController,this._headers=l(this._stream.httpHeaders),this._headers.append("Range",`bytes=${w}-${v-1}`);let f=g.url;fetch(f,s(this._headers,this._withCredentials,this._abortController)).then(p=>{if(!(0,o.validateResponseStatus)(p.status))throw(0,o.createResponseStatusError)(p.status,f);this._readCapability.resolve(),this._reader=p.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:y,done:w}=await this._reader.read();return w?{value:y,done:w}:(this._loaded+=y.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(y).buffer,done:!1})}cancel(y){this._reader&&this._reader.cancel(y),this._abortController.abort()}}}],__webpack_module_cache__={};function __w_pdfjs_require__(r){var t=__webpack_module_cache__[r];if(t!==void 0)return t.exports;var n=__webpack_module_cache__[r]={exports:{}};return __webpack_modules__[r](n,n.exports,__w_pdfjs_require__),n.exports}var __webpack_exports__={};return(()=>{var r=__webpack_exports__;Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"AnnotationEditorLayer",{enumerable:!0,get:function(){return o.AnnotationEditorLayer}}),Object.defineProperty(r,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return t.AnnotationEditorParamsType}}),Object.defineProperty(r,"AnnotationEditorType",{enumerable:!0,get:function(){return t.AnnotationEditorType}}),Object.defineProperty(r,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return s.AnnotationEditorUIManager}}),Object.defineProperty(r,"AnnotationLayer",{enumerable:!0,get:function(){return l.AnnotationLayer}}),Object.defineProperty(r,"AnnotationMode",{enumerable:!0,get:function(){return t.AnnotationMode}}),Object.defineProperty(r,"CMapCompressionType",{enumerable:!0,get:function(){return t.CMapCompressionType}}),Object.defineProperty(r,"GlobalWorkerOptions",{enumerable:!0,get:function(){return h.GlobalWorkerOptions}}),Object.defineProperty(r,"InvalidPDFException",{enumerable:!0,get:function(){return t.InvalidPDFException}}),Object.defineProperty(r,"LoopbackPort",{enumerable:!0,get:function(){return n.LoopbackPort}}),Object.defineProperty(r,"MissingPDFException",{enumerable:!0,get:function(){return t.MissingPDFException}}),Object.defineProperty(r,"OPS",{enumerable:!0,get:function(){return t.OPS}}),Object.defineProperty(r,"PDFDataRangeTransport",{enumerable:!0,get:function(){return n.PDFDataRangeTransport}}),Object.defineProperty(r,"PDFDateString",{enumerable:!0,get:function(){return i.PDFDateString}}),Object.defineProperty(r,"PDFWorker",{enumerable:!0,get:function(){return n.PDFWorker}}),Object.defineProperty(r,"PasswordResponses",{enumerable:!0,get:function(){return t.PasswordResponses}}),Object.defineProperty(r,"PermissionFlag",{enumerable:!0,get:function(){return t.PermissionFlag}}),Object.defineProperty(r,"PixelsPerInch",{enumerable:!0,get:function(){return i.PixelsPerInch}}),Object.defineProperty(r,"RenderingCancelledException",{enumerable:!0,get:function(){return i.RenderingCancelledException}}),Object.defineProperty(r,"SVGGraphics",{enumerable:!0,get:function(){return m.SVGGraphics}}),Object.defineProperty(r,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return t.UNSUPPORTED_FEATURES}}),Object.defineProperty(r,"UnexpectedResponseException",{enumerable:!0,get:function(){return t.UnexpectedResponseException}}),Object.defineProperty(r,"Util",{enumerable:!0,get:function(){return t.Util}}),Object.defineProperty(r,"VerbosityLevel",{enumerable:!0,get:function(){return t.VerbosityLevel}}),Object.defineProperty(r,"XfaLayer",{enumerable:!0,get:function(){return y.XfaLayer}}),Object.defineProperty(r,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(r,"createPromiseCapability",{enumerable:!0,get:function(){return t.createPromiseCapability}}),Object.defineProperty(r,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return t.createValidAbsoluteUrl}}),Object.defineProperty(r,"getDocument",{enumerable:!0,get:function(){return n.getDocument}}),Object.defineProperty(r,"getFilenameFromUrl",{enumerable:!0,get:function(){return i.getFilenameFromUrl}}),Object.defineProperty(r,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return i.getPdfFilenameFromUrl}}),Object.defineProperty(r,"getXfaPageViewport",{enumerable:!0,get:function(){return i.getXfaPageViewport}}),Object.defineProperty(r,"isPdfFile",{enumerable:!0,get:function(){return i.isPdfFile}}),Object.defineProperty(r,"loadScript",{enumerable:!0,get:function(){return i.loadScript}}),Object.defineProperty(r,"renderTextLayer",{enumerable:!0,get:function(){return d.renderTextLayer}}),Object.defineProperty(r,"shadow",{enumerable:!0,get:function(){return t.shadow}}),Object.defineProperty(r,"version",{enumerable:!0,get:function(){return n.version}});var t=__w_pdfjs_require__(1),n=__w_pdfjs_require__(4),i=__w_pdfjs_require__(8),o=__w_pdfjs_require__(22),s=__w_pdfjs_require__(7),l=__w_pdfjs_require__(27),h=__w_pdfjs_require__(15),u=__w_pdfjs_require__(3),d=__w_pdfjs_require__(30),m=__w_pdfjs_require__(31),y=__w_pdfjs_require__(29);let w="2.16.105",v="172ccdbe5";if(u.isNodeJS){let{PDFNodeStream:g}=__w_pdfjs_require__(32);(0,n.setPDFNetworkStreamFactory)(f=>new g(f))}else{let{PDFNetworkStream:g}=__w_pdfjs_require__(35),{PDFFetchStream:f}=__w_pdfjs_require__(36);(0,n.setPDFNetworkStreamFactory)(p=>(0,i.isValidFetchUrl)(p.url)?new f(p):new g(p))}})(),__webpack_exports__})())});var k8={};sM(k8,{Link:()=>Jl,default:()=>P8,load:()=>M8});H();H();H();var xw=gt(Sw()),Cw=gt(ii());H();var Aw=gt(ii());function ia(r,t){return Aw.TaJson.deserialize(r,t)}var Co=class extends xw.Publication{static async fromUrl(t,n){let o=await(await fetch(t.href,n)).json(),s=ia(o,Co);return s.manifestUrl=t,s}get readingOrder(){return this.Spine??[]}get resources(){return this.Resources??[]}get tableOfContents(){return this.sample?.isSampleRead&&this.positions?.length>0?this.limitedTOC():this.TOC}limitedTOC(){function t(i){for(let o=0;o<i.Children.length;o++){let s=i.Children[o];s.Href=void 0,s.Children&&t(s)}}return this.TOC.map(i=>{if(i.Href){let o=this.positionsByHref(this.getRelativeHref(i.Href));if(o?.length>0){let s=o[0],l=Math.round(s.locations.totalProgression?s.locations.totalProgression:0*100);this.sample?.limit&&(l<=this.sample?.limit||(i.Href=void 0,i.Children&&t(i)))}}return i})}get landmarks(){return this.Landmarks}get pageList(){return this.PageList}get isFixedLayout(){return this.Metadata.Rendition?.Layout==="fixed"}get isReflowable(){return!this.isFixedLayout}get layout(){return this.isFixedLayout?"fixed":"reflowable"}get hasMediaOverlays(){return this.readingOrder?this.readingOrder.filter(t=>t.Properties?.MediaOverlay).length>0:!1}getStartLink(){if(this.readingOrder!==void 0&&this.readingOrder.length>0)return this.readingOrder[0]}getPreviousSpineItem(t){let n=this.getSpineIndex(t);if(n!==void 0&&this.readingOrder!==void 0&&n>0)return this.readingOrder[n-1]}getNextSpineItem(t){let n=this.getSpineIndex(t);if(n!==void 0&&this.readingOrder!==void 0&&n<this.readingOrder.length-1)return this.readingOrder[n+1]}getSpineItem(t){let n=this.getSpineIndex(t);if(n!==void 0&&this.readingOrder!==void 0)return this.readingOrder[n]}getSpineIndex(t){return this.readingOrder?.findIndex(n=>n.Href&&this.getAbsoluteHref(n.Href)===t)}getAbsoluteHref(t){return new URL(t,this.manifestUrl.href).href}getRelativeHref(t){let n=this.manifestUrl.href.replace("/manifest.json",""),i=t.replace(n,"");return i.indexOf("#")>0&&(i=i.slice(0,i.indexOf("#"))),i.charAt(0)==="/"&&(i=i.substring(1)),i}getTOCItemAbsolute(t){let n=this.getAbsoluteHref(t),i=(s,l)=>{for(let h=0;h<l.length;h++){let u=l[h];if(u.Href){let d=u.Href.indexOf("#")!==-1?u.Href.slice(0,u.Href.indexOf("#")):u.Href;if(this.getAbsoluteHref(d)===s)return u}if(u.Children){let d=i(s,u.Children);if(d!==void 0)return d}}},o=i(n,this.tableOfContents);return o===void 0&&this.readingOrder!==void 0&&(o=i(n,this.readingOrder)),o}getTOCItem(t){let n=(o,s)=>{for(let l=0;l<s.length;l++){let h=s[l];if(h.Href&&this.getAbsoluteHref(h.Href)===o)return h;if(h.Children){let u=n(o,h.Children);if(u!==void 0)return u}}},i=n(t,this.tableOfContents);if(i===void 0&&this.readingOrder!==void 0&&(i=n(t,this.readingOrder)),i===void 0&&t.indexOf("#")!==-1){let o=t.slice(0,t.indexOf("#"));i=n(o,this.tableOfContents),i===void 0&&this.readingOrder!==void 0&&(i=n(o,this.readingOrder))}return i}positionsByHref(t){let n=decodeURI(t)??"";return this.positions?.filter(i=>n.includes(i.href))}async autoGeneratePositions(t,n=SL){let i=0,o=0,s=[];if(this.readingOrder!==void 0)for(let h of this.readingOrder)if(this.isFixedLayout){let u={href:h.Href,locations:{progression:0,position:i+1},type:h.TypeLink};s.push(u),i=i+1}else{let u=this.getAbsoluteHref(h.Href),d=await n(u,t);h.contentLength=d,o+=d;let y=Math.max(1,Math.ceil(d/1024));for(let w=0;w<y;w++){let v={href:h.Href,locations:{progression:w/y,position:i+(w+1)},type:h.TypeLink};s.push(v)}i=i+y}var l=0;if(this.isReflowable&&this.readingOrder!==void 0)for(let h of this.readingOrder){if(!h.contentLength){console.error("Link is missing contentLength",h);return}h.contentWeight=100/o*h.contentLength,l=l+h.contentWeight}for(let h of s){let u=s.filter(m=>m.href===decodeURI(h.href)),d=Math.ceil((h.locations.progression?h.locations.progression:0)*(u.length-1));h.locations.position&&(h.locations.totalProgression=(h.locations.position-1)/s.length),h.locations.remainingPositions=Math.abs(d-(u.length-1)),h.locations.position&&(h.locations.totalRemainingPositions=Math.abs(h.locations.position-1-(s.length-1)))}this.positions=s}async fetchPositionsFromService(t,n){let o=await(await fetch(t,n)).json();this.positions=o.positions}async fetchWeightsFromService(t,n){if(this.isFixedLayout){console.warn("Not fetching weights from service for fixed layout publication.");return}let o=await(await fetch(t,n)).json();this.readingOrder!==void 0&&this.readingOrder.forEach(s=>{s.contentWeight=o[s.Href]})}};Co=Uc([(0,Cw.JsonObject)()],Co);var SL=async(r,t)=>(await(await fetch(r,t)).blob()).size;H();H();var ra=class{json(){return JSON.stringify(this)}},Tw=class extends ra{constructor(t,n,i){super();this.value=t,this.ref=n,this.name=i}toString(){return this.value}},Ow=class extends ra{constructor(t,n,i){super();this.value=t,this.ref=n,this.name=i}toString(){return this.value}toJson(){return JSON.parse(this.value)}},Rw=class extends ra{constructor(t,n,i,o){super();this.value=t,this.values=n,this.ref=i,this.name=o}toString(){return this.values[this.value]}},Pw=class extends ra{constructor(t,n,i,o,s,l,h){super();this.countDecimals=function(t){return t%1!=0?t.toString().split(".")[1].length:1};this.value=t,this.min=n,this.max=i,this.step=o,this.suffix=s,this.ref=l,this.name=h}toString(){return this.value.toString()+this.suffix}increment(){let t=this.countDecimals(this.max);parseFloat(this.value.toFixed(t))<this.max&&(this.value=parseFloat(this.value.toFixed(t))+this.step)}decrement(){let t=this.countDecimals(this.min);parseFloat(this.value.toFixed(t))>this.min&&(this.value=parseFloat(this.value.toFixed(t))-this.step)}},ol=class extends ra{constructor(t,n,i,o,s){super();this.value=i,this.onValue=t,this.offValue=n,this.ref=o,this.name=s}toString(){return this.value?this.onValue:this.offValue}switch(){this.value=!this.value}},Zr=class{constructor(){this.properties=[]}addIncremental(t,n,i,o,s,l,h){this.properties.push(new Pw(t,n,i,o,s,l,h))}addStringable(t,n,i){this.properties.push(new Tw(t,n,i))}addJSONable(t,n,i){this.properties.push(new Ow(t,n,i))}addSwitchable(t,n,i,o,s){this.properties.push(new ol(t,n,i,o,s))}addEnumerable(t,n,i,o){this.properties.push(new Rw(t,n,i,o))}getByRef(t){let n=this.properties.filter(i=>i.ref===t);return n.length>0?n[0]:null}getByKey(t){let n=this.properties.filter(i=>i.key===t);return n.length>0?n[0]:null}};H();var Bi=class{},Ae=Bi;Ae.FONT_SIZE_REF="fontSize",Ae.FONT_FAMILY_REF="fontFamily",Ae.FONT_OVERRIDE_REF="fontOverride",Ae.APPEARANCE_REF="appearance",Ae.SCROLL_REF="scroll",Ae.TEXT_ALIGNMENT_REF="textAlign",Ae.COLUMN_COUNT_REF="colCount",Ae.WORD_SPACING_REF="wordSpacing",Ae.LETTER_SPACING_REF="letterSpacing",Ae.PAGE_MARGINS_REF="pageMargins",Ae.LINE_HEIGHT_REF="lineHeight",Ae.FONT_SIZE_KEY="--USER__"+Bi.FONT_SIZE_REF,Ae.FONT_FAMILY_KEY="--USER__"+Bi.FONT_FAMILY_REF,Ae.FONT_OVERRIDE_KEY="--USER__"+Bi.FONT_OVERRIDE_REF,Ae.APPEARANCE_KEY="--USER__"+Bi.APPEARANCE_REF,Ae.SCROLL_KEY="--USER__"+Bi.SCROLL_REF,Ae.TEXT_ALIGNMENT_KEY="--USER__"+Bi.TEXT_ALIGNMENT_REF,Ae.COLUMN_COUNT_KEY="--USER__"+Bi.COLUMN_COUNT_REF,Ae.WORD_SPACING_KEY="--USER__"+Bi.WORD_SPACING_REF,Ae.LETTER_SPACING_KEY="--USER__"+Bi.LETTER_SPACING_REF,Ae.PAGE_MARGINS_KEY="--USER__"+Bi.PAGE_MARGINS_REF,Ae.LINE_HEIGHT_KEY="--USER__"+Bi.LINE_HEIGHT_REF;H();function $e(r,t){return r.querySelector(t)}function Rt(r,t){let n=$e(r,t);if(n&&n instanceof HTMLElement)return n;throw new Error("required element "+t+" not found")}function On(r,t){if(r===null)throw new Error("parent element is null");return r.querySelector(t)}function Qr(r,t){let n=On(r,t);if(n)return n;throw new Error("required element "+t+" not found in iframe")}function Un(r,t,n){r.setAttribute(t,n)}H();H();var x_=gt(M0());var Ol=class{constructor(t){this.getScrollingElement=t=>t.scrollingElement?t.scrollingElement:t.body;this.navigator=t}async handleFootnote(t,n){let i=t.getAttribute("href");if(i&&i.indexOf("#")>0){let s=function(h){let u=document.location.href;return new URL(h,u).href},o=i.substring(i.indexOf("#")+1),l=s(i);l&&(l=l.substring(0,l.indexOf("#")),n.preventDefault(),n.stopPropagation(),await fetch(l,this.navigator.requestConfig).then(h=>h.text()).then(async h=>{let m=new DOMParser().parseFromString(h,"text/html").querySelector("#"+o);m&&(n.preventDefault(),n.stopPropagation(),this.showPopup(m,n))}))}}async hidePopover(){let t=this.navigator.iframes[0].contentDocument?.getElementById("d2-popover");t&&t.parentElement?.removeChild(t);let n=Rt(document,"#iframe-wrapper");n.style.overflow="auto"}async showPopover(t,n){let i=t.getAttribute("href"),o=t.getAttribute("src");function s(l){let h=document.location.href;return new URL(l,h).href}if(i){let l=s(i);if(l){n.preventDefault(),n.stopPropagation();let h=this.navigator.iframes[0].contentDocument?.getElementById("d2-popover");h&&h.parentElement?.removeChild(h);let u=document.createElement("div");u.id="d2-popover",u.className="d2-popover is-active";let d=Rt(document,"#iframe-wrapper");d.style.overflow="hidden",u.style.top=d.scrollTop+"px",u.style.height=d.clientHeight*.9+"px";let m=document.createElement("div");m.className="d2-popover-wrapper",u.appendChild(m);let y=document.createElement("div");y.className="d2-popover-content",m.appendChild(y),await fetch(l,this.navigator.requestConfig).then(g=>g.text()).then(async g=>{y.innerHTML=g;let f=this.navigator.iframes[0].contentDocument;f&&f.body.appendChild(u)});let w=this.navigator.iframes[0].contentWindow;if(!w)return;let v=this;w.onclick=function(g){n.target!==g.target&&u.parentElement&&(v.hidePopover(),w&&(w.onclick=null))}}}else if(o&&s(o)){n.preventDefault(),n.stopPropagation();let h=this.navigator.iframes[0].contentDocument?.getElementById("d2-popover");h&&h.parentElement?.removeChild(h);let u=document.createElement("div");u.id="d2-popover",u.className="d2-popover is-active";let d=Rt(document,"#iframe-wrapper");d.style.overflow="hidden",u.style.top=d.scrollTop+"px",u.style.height=d.clientHeight*.9+"px";let m=document.createElement("div");m.className="d2-popover-wrapper",u.appendChild(m);let y=document.createElement("img");y.className="d2-popover-content",m.appendChild(y),y.src=o;let w=this.navigator.iframes[0].contentDocument;w&&w.body.appendChild(u);let v=this.navigator.iframes[0].contentWindow;if(!v)return;let g=this;v.onclick=function(f){n.target!==f.target&&u.parentElement&&(g.hidePopover(),v&&(v.onclick=null))}}}showPopup(t,n){let i=this.navigator.iframes[0].contentDocument?.getElementById("d2-popup");i&&i.parentElement?.removeChild(i);let o=document.createElement("aside");o.id="d2-popup",o.className="d2-popup is-active";let s=document.createElement("div");s.className="d2-popup-wrapper",o.appendChild(s);let l=document.createElement("div");l.className="d2-popup-content",s.appendChild(l);let h=document.createElement("p");l.appendChild(h),typeof t=="string"?h.innerHTML=t:h.innerHTML=(0,x_.default)(t.innerHTML,{allowedTags:[],allowedAttributes:{}});let u=this.navigator.view?.isPaginated(),d=this.navigator.iframes[0].contentDocument;if(!d)return;let m=this.getScrollingElement(d),y=u?m.scrollLeft:0,w=u?m.scrollTop:0,v=n.x+y,g=n.y+w;o.style.top=g+"px",u&&(o.style.left=v+"px"),d.body.appendChild(o);let f=this.navigator.iframes[0].contentWindow;!f||(f.onclick=function(p){n.target!==p.target&&o.parentElement&&(o.style.display="none",o.parentElement.removeChild(o),f&&(f.onclick=null))})}};var Kd=gt(cn());function Ce(r,t,n){r&&r.addEventListener(t,n,!0)}function ze(r,t,n){r&&r.removeEventListener(t,n,!0)}var Yd=class{constructor(t){this.onInternalLink=()=>{};this.onClickThrough=()=>{};this.checkForLink=t=>{let n=t.target;for(;n&&n.tagName.toLowerCase()!=="body";){if(n.tagName.toLowerCase()==="a"&&n.href)return n;n=n.parentElement}return null};this.linkInPublication=(t,n)=>t.some(i=>!i.Rel?.includes("external")&&this.navigator.publication.getRelativeHref(n).includes(i.Href));this.isReadingOrderInternal=t=>(Kd.default.log("clickedLink: ",t),this.linkInPublication(this.navigator.publication.readingOrder,t.href));this.isResourceInternal=t=>(Kd.default.log("clickedLink: ",t),this.linkInPublication(this.navigator.publication.resources,t.href));this.handleLinks=async t=>{Kd.default.log("R2 Click Handler");let n=this.checkForLink(t);if(n){let i=window.location.protocol===n.protocol&&window.location.port===n.port&&window.location.hostname===n.hostname,o=this.isReadingOrderInternal(n),s=this.isResourceInternal(n);s||await this.popup.hidePopover();let l=n.href.indexOf("#");if(!o&&!s)window.open(n.href,n.target??"_blank"),t.preventDefault(),t.stopPropagation();else if(t.target.href=n.href,(i||o)&&l!==-1){let h=t.target;h?h.getAttribute("epub:type")==="noteref"?await this.popup.handleFootnote(h,t):s&&!o?await this.popup.showPopover(h,t):this.onInternalLink(t):this.onInternalLink(t)}else(i||o)&&l===-1&&this.onInternalLink(t)}else this.onClickThrough(t)};this.navigator=t,this.popup=new Ol(this.navigator)}setupEvents(t){if(t!==null)t.addEventListener("dblclick",async n=>{let i=n.target;n.target&&i.tagName.toLowerCase()==="img"&&await this.popup.showPopover(i,n)},!0),t.addEventListener("click",this.handleLinks.bind(this));else throw"cannot setup events for null"}};H();H();function T_(){return Rt(document,"#iframe-wrapper").clientWidth}function gr(){return Rt(document,"#iframe-wrapper").clientHeight}var R_=gt(Mo()),Xd=class{constructor(t){this.layout="reflowable";this.USERSETTINGS="userSetting";this.sideMargin=20;this.height=0;this.attributes={margin:0};this.hasFixedScrollWidth=!1;this.store=t,this.scrollMode?(this.name="readium-scroll-on",this.label="Scrolling"):(this.name="readium-scroll-off",this.label="Paginated")}setMode(t){if(this.scrollMode=t,t){this.name="readium-scroll-on",this.label="Scrolling";let n=this.iframe.contentDocument;if(n){let i=On(n,"head");if(i){let s=$e(i,"meta[name=viewport]");s&&s.remove()}let o=On(n,"html");o&&o.style.setProperty("--USER__scroll","readium-scroll-on")}this.setSize(),this.setIframeHeight(this.iframe)}else{this.height=gr()-40-this.attributes.margin,this.name="readium-scroll-off",this.label="Paginated",this.checkForFixedScrollWidth();let n=this.iframe.contentDocument;if(n){let i=On(n,"html");i&&i.style.setProperty("--USER__scroll","readium-scroll-off")}this.setSize()}this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate()}start(){if(this.scrollMode){let t=this.iframe.contentDocument;if(t){let n=On(t,"head");if(n){let i=$e(n,"meta[name=viewport]");i&&i.remove()}}this.setSize(),this.setIframeHeight(this.iframe)}else{this.iframe.height="0",this.iframe.width="0",this.setSize();let t=document.createElement("meta");t.name="viewport",t.content="width=device-width, initial-scale=1, maximum-scale=1",this.checkForFixedScrollWidth()}}stop(){if(this.iframe.height="0",this.iframe.width="0",this.iframe.contentDocument){let n=On(this.iframe.contentDocument,"body"),i=Array.prototype.slice.call(n.querySelectorAll("img"));for(let o of i)o.style.maxWidth=""}}getCurrentPosition(){let t=Rt(document,"#iframe-wrapper");if(this.scrollMode)return t.scrollTop/this.scrollingElement.scrollHeight;{let n=this.getColumnWidth(),i=this.getLeftColumnsWidth(),o=this.getRightColumnsWidth(),s=i+n+o;return i/s}}goToProgression(t){let n=Rt(document,"#iframe-wrapper");if(this.scrollMode)n.scrollTop=this.scrollingElement.scrollHeight*t;else{let i=this.getColumnWidth(),o=this.getLeftColumnsWidth(),s=this.getRightColumnsWidth(),l=o+i+s,h=t*l,u=Math.round(h/i)*i;u>=l&&(u=u-i),this.setLeftColumnsWidth(u)}}goToCssSelector(t,n){let i=this.iframe.contentDocument;if(i){let o=i.querySelector(t);this.goToElement(o,n)}}goToFragment(t,n){let i=this.iframe.contentDocument;if(i){let o=i.getElementById(t);this.goToElement(o,n)}}snap(t,n){if(t&&!this.scrollMode){let i=t.style.height;t.style.height="0";let o=this.getColumnWidth(),s=this.getLeftColumnsWidth()+t.getBoundingClientRect().left,l=Math.floor(s/o)*o;t.style.height=i,this.setLeftColumnsWidth(l),this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate(0)}}goToElement(t,n){if(this.scrollMode)t&&t.scrollIntoView({block:"center"});else if(t){let i=t.style.height;t.style.height="0";let o=t.getBoundingClientRect().left,s=this.getColumnWidth(),l=this.scrollingElement.scrollLeft-s,h=Math.ceil(o/s)*s+l;if(n){let u=this.getLeftColumnsWidth();h=Math.ceil(o/s)*s+u}t.style.height=i,this.setLeftColumnsWidth(h),this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate(200)}}atStart(){return this.scrollMode?Rt(document,"#iframe-wrapper").scrollTop===0:this.getLeftColumnsWidth()<=0}atEnd(){if(this.scrollMode){let t=Rt(document,"#iframe-wrapper");return Math.ceil(this.scrollingElement.scrollHeight-t.scrollTop)-1<=gr()}else return Math.floor(this.getRightColumnsWidth())<=0||Math.ceil(this.getCurrentPage())===this.getPageCount()}goToPreviousPage(){let t=Rt(document,"#iframe-wrapper");if(this.scrollMode){let n=t.scrollTop,i=this.getScreenHeight()-40,o=n-i;o>=0?t.scrollTop=o:t.scrollTop=0}else{let n=this.getLeftColumnsWidth(),i=this.getColumnWidth(),o=n-i;o>=0?this.setLeftColumnsWidth(o):this.setLeftColumnsWidth(0),this.navigator.checkResourcePosition()}this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate()}goToNextPage(){let t=Rt(document,"#iframe-wrapper");if(this.scrollMode){let n=t.scrollTop,i=this.getScreenHeight()-40,o=this.scrollingElement.scrollHeight,s=n+i;s<o?t.scrollTop=s:t.scrollTop=o}else{let n=this.getLeftColumnsWidth(),i=this.getColumnWidth(),o=this.scrollWidth,s=n+i;s<o?this.setLeftColumnsWidth(s):this.setLeftColumnsWidth(o),this.navigator.checkResourcePosition()}this.navigator.rights.enableContentProtection&&this.navigator.contentProtectionModule?.recalculate()}getCurrentPage(){return this.scrollMode?0:this.getCurrentPosition()*this.getPageCount()+1}getPageCount(){if(this.scrollMode)return 0;{let t=this.getColumnWidth();return this.scrollWidth/t}}isPaginated(){if(this.iframe){let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n)return!(n.style.getPropertyValue("--USER__scroll")==="readium-scroll-on")}}return!this.scrollMode}isScrollMode(){if(this.iframe){let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n)return n.style.getPropertyValue("--USER__scroll")==="readium-scroll-on"}}return this.scrollMode}async getProperty(t){let n=await this.store.get(this.USERSETTINGS);if(n){let i=JSON.parse(n);return i=i.filter(o=>o.name===t),i.length===0?null:i[0]}return null}getScreenHeight(){return Rt(document,"#iframe-wrapper").clientHeight}setIframeHeight(t){(0,R_.debounce)(i=>{if(i){let o=i.contentWindow.document.body,s=i.contentWindow.document.documentElement,l=Math.max(o?.scrollHeight,o?.offsetHeight,s?.clientHeight,s?.scrollHeight,s?.offsetHeight);if(l){let h=gr()-this.attributes.margin;i.height=Math.max(h,l)+"px"}}},200)(t)}checkForFixedScrollWidth(){let t=this.iframe.contentDocument;if(t){let n=On(t,"body"),i=n?.scrollWidth;this.hasFixedScrollWidth=n?.scrollWidth===i}}setSize(){if(this.iframe.width=T_()+"px",this.scrollMode){let t=this.iframe.contentWindow?.document?.documentElement;this.iframe.height=t?.offsetHeight+"px"}else{let t=this.iframe.contentDocument;t&&t.documentElement&&(t.documentElement.style.height=this.height+"px"),this.iframe.height=this.height+"px"}}getLeftColumnsWidth(){return Math.ceil(this.scrollingElement.scrollLeft)}getRightColumnsWidth(){let t=this.getColumnWidth(),n=this.scrollWidth-t;if(this.hasFixedScrollWidth){let i=this.getLeftColumnsWidth();n=Math.max(0,n-i)}return n}getColumnWidth(){return this.scrollingElement.clientWidth}setLeftColumnsWidth(t){this.scrollingElement.scrollLeft=t}get scrollingElement(){return this.iframe.contentDocument?.scrollingElement?this.iframe.contentDocument?.scrollingElement:this.iframe.contentDocument?.body?this.iframe.contentDocument?.body:document.createElement("body")}get scrollWidth(){let t=this.scrollingElement?.scrollWidth,n=this.getColumnWidth();return Math.ceil(t/n)*n}};H();var Zd=class{constructor(){this.layout="fixed";this.sideMargin=20;this.height=0;this.attributes={margin:0}}start(){}stop(){}getCurrentPosition(){return 0}getScreenHeight(){return Rt(document,"#iframe-wrapper").clientHeight}goToProgression(t){}goToCssSelector(t,n){}goToFragment(t,n){}snap(t,n){}getCurrentPage(){return 0}getPageCount(){return 1}setSize(){}isPaginated(){return!0}isScrollMode(){return!1}atEnd(){return!0}atStart(){return!0}};var Di=gt(cn()),Gt=class{constructor(t,n,i,o,s){this.USERSETTINGS="userSetting";this.fontSize=100;this.fontOverride=!1;this.fontFamily=0;this.appearance=0;this.verticalScroll=!0;this.textAlignment=0;this.columnCount=0;this.wordSpacing=0;this.letterSpacing=0;this.pageMargins=2;this.lineHeight=1;this.settingsChangeCallback=()=>{};this.settingsColumnsChangeCallback=()=>{};this.viewChangeCallback=()=>{};this.store=t,this.view=s==="fixed"?new Zd:new Xd(this.store),this.headerMenu=n,this.api=i,this.injectables=o,this.injectables?.forEach(l=>{l.type==="style"&&(l.fontFamily&&this.addFont(l.fontFamily),l.appearance&&this.addAppearance(l.appearance))})}async isPaginated(){return!await this.getPropertyAndFallback("verticalScroll",Ae.SCROLL_KEY)}async isScrollMode(){return!await this.isPaginated()}static async create(t){let n=new this(t.store,t.headerMenu,t.api,t.injectables,t.layout);if(await n.initialise(),t.initialUserSettings){n.userProperties||(n.userProperties=n.getUserSettings());let i=t.initialUserSettings;if(i.verticalScroll!==void 0){n.verticalScroll=this.parseScrollSetting(i.verticalScroll);let o=n.userProperties.getByRef(Ae.SCROLL_REF);o&&(o.value=n.verticalScroll,await n.saveProperty(o)),Di.default.log(n.verticalScroll)}if(i.appearance){n.appearance=Gt.appearanceValues.findIndex(s=>s===i.appearance);let o=n.userProperties.getByRef(Ae.APPEARANCE_REF);o&&(o.value=n.appearance,await n.saveProperty(o)),Di.default.log(n.appearance)}if(i.fontSize){n.fontSize=i.fontSize;let o=n.userProperties.getByRef(Ae.FONT_SIZE_REF);o&&(o.value=n.fontSize,await n.saveProperty(o)),Di.default.log(n.fontSize)}if(i.fontFamily){n.fontFamily=Gt.fontFamilyValues.findIndex(s=>s===i.fontFamily);let o=n.userProperties.getByRef(Ae.FONT_FAMILY_REF);o&&(o.value=n.fontFamily,await n.saveProperty(o)),Di.default.log(n.fontFamily),n.fontFamily!==0&&(n.fontOverride=!0)}if(i.textAlignment){n.textAlignment=Gt.textAlignmentValues.findIndex(s=>s===i.textAlignment);let o=n.userProperties.getByRef(Ae.TEXT_ALIGNMENT_REF);o&&(o.value=n.textAlignment,await n.saveProperty(o)),Di.default.log(n.textAlignment)}if(i.columnCount){n.columnCount=Gt.columnCountValues.findIndex(s=>s===i.columnCount);let o=n.userProperties.getByRef(Ae.COLUMN_COUNT_REF);o&&(o.value=n.columnCount,await n.saveProperty(o)),Di.default.log(n.columnCount)}if(i.wordSpacing){n.wordSpacing=i.wordSpacing;let o=n.userProperties.getByRef(Ae.WORD_SPACING_REF);o&&(o.value=n.wordSpacing,await n.saveProperty(o)),Di.default.log(n.wordSpacing)}if(i.letterSpacing){n.letterSpacing=i.letterSpacing;let o=n.userProperties.getByRef(Ae.LETTER_SPACING_REF);o&&(o.value=n.letterSpacing,await n.saveProperty(o)),Di.default.log(n.letterSpacing)}if(i.pageMargins){n.pageMargins=i.pageMargins;let o=n.userProperties.getByRef(Ae.PAGE_MARGINS_REF);o&&(o.value=n.pageMargins,await n.saveProperty(o)),Di.default.log(n.pageMargins)}if(i.lineHeight){n.lineHeight=i.lineHeight;let o=n.userProperties.getByRef(Ae.LINE_HEIGHT_REF);o&&(o.value=n.lineHeight,await n.saveProperty(o)),Di.default.log(n.lineHeight)}n.userProperties=n.getUserSettings(),await n.initialise()}return await n.initializeSelections(),new Promise(i=>i(n))}stop(){Di.default.log("book settings stop")}async initialise(){this.appearance=await this.getPropertyAndFallback("appearance",Ae.APPEARANCE_KEY),this.verticalScroll=await this.getPropertyAndFallback("verticalScroll",Ae.SCROLL_KEY),this.fontFamily=await this.getPropertyAndFallback("fontFamily",Ae.FONT_FAMILY_KEY),this.fontFamily!==0&&(this.fontOverride=!0),this.textAlignment=await this.getPropertyAndFallback("textAlignment",Ae.TEXT_ALIGNMENT_KEY),this.columnCount=await this.getPropertyAndFallback("columnCount",Ae.COLUMN_COUNT_KEY),this.fontSize=await this.getPropertyAndFallback("fontSize",Ae.FONT_SIZE_KEY),this.wordSpacing=await this.getPropertyAndFallback("wordSpacing",Ae.WORD_SPACING_KEY),this.letterSpacing=await this.getPropertyAndFallback("letterSpacing",Ae.LETTER_SPACING_KEY),this.pageMargins=await this.getPropertyAndFallback("pageMargins",Ae.PAGE_MARGINS_KEY),this.lineHeight=await this.getPropertyAndFallback("lineHeight",Ae.LINE_HEIGHT_KEY),this.userProperties=this.getUserSettings()}async reset(){this.appearance=0,this.verticalScroll=!0,this.fontSize=100,this.fontOverride=!1,this.fontFamily=0,this.textAlignment=0,this.columnCount=0,this.wordSpacing=0,this.letterSpacing=0,this.pageMargins=2,this.lineHeight=1,this.userProperties=this.getUserSettings();let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n){let i=document.documentElement,o=Rt(i,"body");n.style.removeProperty(Ae.FONT_SIZE_KEY),n.style.removeProperty(Ae.WORD_SPACING_KEY),n.style.removeProperty(Ae.LETTER_SPACING_KEY),n.style.removeProperty(Ae.COLUMN_COUNT_KEY),n.style.removeProperty(Ae.TEXT_ALIGNMENT_KEY),n.style.removeProperty(Ae.LINE_HEIGHT_KEY),n.style.removeProperty(Ae.PAGE_MARGINS_KEY),n.style.removeProperty(Ae.APPEARANCE_KEY),Un(i,"data-viewer-theme","day"),Un(o,"data-viewer-theme","day"),n.style.removeProperty(Ae.FONT_FAMILY_KEY),Un(n,"data-viewer-font","publisher"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-off")}}}async initializeSelections(){this.headerMenu&&(this.settingsView=$e(this.headerMenu,"#container-view-settings"))}async applyProperties(){this.userProperties=this.getUserSettings();let t=this.iframe.contentDocument;if(t){let n=On(t,"html");if(n){let i=document.documentElement,o=Rt(i,"body");if(this.view?.navigator.publication.isReflowable&&(await this.getProperty(Ae.FONT_SIZE_KEY)&&n.style.setProperty(Ae.FONT_SIZE_KEY,this.userProperties.getByRef(Ae.FONT_SIZE_REF)?.toString()??null),await this.getProperty(Ae.WORD_SPACING_KEY)&&n.style.setProperty(Ae.WORD_SPACING_KEY,this.userProperties.getByRef(Ae.WORD_SPACING_REF)?.toString()??null),await this.getProperty(Ae.LETTER_SPACING_KEY)&&n.style.setProperty(Ae.LETTER_SPACING_KEY,this.userProperties.getByRef(Ae.LETTER_SPACING_REF)?.toString()??null)),await this.getProperty(Ae.COLUMN_COUNT_KEY)&&n.style.setProperty(Ae.COLUMN_COUNT_KEY,this.userProperties.getByRef(Ae.COLUMN_COUNT_REF)?.toString()??null),this.view?.navigator.publication.isReflowable&&(await this.getProperty(Ae.TEXT_ALIGNMENT_KEY)&&(this.userProperties.getByRef(Ae.TEXT_ALIGNMENT_REF)?.toString()==="auto"?n.style.removeProperty(Ae.TEXT_ALIGNMENT_KEY):n.style.setProperty(Ae.TEXT_ALIGNMENT_KEY,this.userProperties.getByRef(Ae.TEXT_ALIGNMENT_REF)?.toString()??null)),await this.getProperty(Ae.LINE_HEIGHT_KEY)&&n.style.setProperty(Ae.LINE_HEIGHT_KEY,this.userProperties.getByRef(Ae.LINE_HEIGHT_REF)?.toString()??null),await this.getProperty(Ae.PAGE_MARGINS_KEY)&&n.style.setProperty(Ae.PAGE_MARGINS_KEY,this.userProperties.getByRef(Ae.PAGE_MARGINS_REF)?.toString()??null)),await this.getProperty(Ae.APPEARANCE_KEY)?(n.style.setProperty(Ae.APPEARANCE_KEY,this.userProperties.getByRef(Ae.APPEARANCE_REF)?.toString()??null),this.userProperties.getByRef(Ae.APPEARANCE_REF)?.value===0?(Un(i,"data-viewer-theme","day"),Un(o,"data-viewer-theme","day")):this.userProperties.getByRef(Ae.APPEARANCE_REF)?.value===1?(Un(i,"data-viewer-theme","sepia"),Un(o,"data-viewer-theme","sepia")):this.userProperties.getByRef(Ae.APPEARANCE_REF)?.value===2&&(Un(i,"data-viewer-theme","night"),Un(o,"data-viewer-theme","night"))):(n.style.setProperty(Ae.APPEARANCE_KEY,this.userProperties.getByRef(Ae.APPEARANCE_REF)?.toString()??null),Un(i,"data-viewer-theme","day"),Un(o,"data-viewer-theme","day")),this.view?.navigator.publication.isReflowable){if(await this.getProperty(Ae.FONT_FAMILY_KEY))if(n.style.setProperty(Ae.FONT_FAMILY_KEY,this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.toString()??null),this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.value===0)Un(n,"data-viewer-font","publisher"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-off");else if(this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.value===1)Un(n,"data-viewer-font","serif"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-on");else if(this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.value===2)Un(n,"data-viewer-font","sans"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-on");else{let s=this.userProperties.getByRef(Ae.FONT_FAMILY_REF);s&&Un(n,"data-viewer-font",s.toString()),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-on")}else n.style.setProperty(Ae.FONT_FAMILY_KEY,this.userProperties.getByRef(Ae.FONT_FAMILY_REF)?.toString()??null),Un(n,"data-viewer-font","publisher"),n.style.setProperty(Ae.FONT_OVERRIDE_KEY,"readium-font-off");await this.getProperty(Ae.SCROLL_KEY)?this.userProperties.getByRef(Ae.SCROLL_REF)?.value===!0?n.style.setProperty("--USER__scroll","readium-scroll-on"):n.style.setProperty("--USER__scroll","readium-scroll-off"):n.style.setProperty("--USER__scroll","readium-scroll-on"),n.style.setProperty("--USER__advancedSettings","readium-advanced-on"),this.isScrollMode().then(s=>{this.view?.setMode?.(s)})}}}}setIframe(t){this.iframe=t,this.view&&(this.view.iframe=t),this.settingsView&&Gt.renderControls(this.settingsView)}static renderControls(t){Ce($e(t,"ul"),"click",n=>{n.stopPropagation()})}onSettingsChange(t){this.settingsChangeCallback=t}onColumnSettingsChange(t){this.settingsColumnsChangeCallback=t}onViewChange(t){this.viewChangeCallback=t}async storeProperty(t){await this.updateUserSettings(),await this.saveProperty(t)}addAppearance(t){Gt.appearanceValues.includes(t)||Gt.appearanceValues.push(t)}initAddedAppearance(){this.applyProperties()}addFont(t){Gt.fontFamilyValues.includes(t)||Gt.fontFamilyValues.push(t)}initAddedFont(){this.applyProperties()}async updateUserSettings(){let t={fontFamily:Gt.fontFamilyValues[await this.userProperties?.getByRef(Ae.FONT_FAMILY_REF)?.value],fontSize:this.userProperties?.getByRef(Ae.FONT_SIZE_REF)?.value,appearance:Gt.appearanceValues[await this.userProperties?.getByRef(Ae.APPEARANCE_REF)?.value],textAlignment:Gt.textAlignmentValues[await this.userProperties?.getByRef(Ae.TEXT_ALIGNMENT_REF)?.value],columnCount:Gt.columnCountValues[await this.userProperties?.getByRef(Ae.COLUMN_COUNT_REF)?.value],wordSpacing:this.userProperties?.getByRef(Ae.WORD_SPACING_REF)?.value,letterSpacing:this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)?.value,verticalScroll:this.userProperties?.getByRef(Ae.SCROLL_REF)?.value};this.api?.updateSettings&&this.api?.updateSettings(t).then(n=>{Di.default.log("api updated user settings",JSON.stringify(t))})}getUserSettings(){let t=new Zr;return t.addSwitchable("readium-font-on","readium-font-off",this.fontOverride,Ae.FONT_OVERRIDE_REF,Ae.FONT_OVERRIDE_KEY),t.addEnumerable(this.columnCount,Gt.columnCountValues,Ae.COLUMN_COUNT_REF,Ae.COLUMN_COUNT_KEY),t.addEnumerable(this.appearance,Gt.appearanceValues,Ae.APPEARANCE_REF,Ae.APPEARANCE_KEY),t.addIncremental(this.pageMargins,.5,4,.25,"",Ae.PAGE_MARGINS_REF,Ae.PAGE_MARGINS_KEY),t.addEnumerable(this.textAlignment,Gt.textAlignmentValues,Ae.TEXT_ALIGNMENT_REF,Ae.TEXT_ALIGNMENT_KEY),t.addEnumerable(this.fontFamily,Gt.fontFamilyValues,Ae.FONT_FAMILY_REF,Ae.FONT_FAMILY_KEY),t.addIncremental(this.fontSize,100,300,25,"%",Ae.FONT_SIZE_REF,Ae.FONT_SIZE_KEY),t.addIncremental(this.lineHeight,1,2,.25,"em",Ae.LINE_HEIGHT_REF,Ae.LINE_HEIGHT_KEY),t.addIncremental(this.wordSpacing,0,1,.25,"rem",Ae.WORD_SPACING_REF,Ae.WORD_SPACING_KEY),t.addIncremental(this.letterSpacing,0,.5,.0625,"em",Ae.LETTER_SPACING_REF,Ae.LETTER_SPACING_KEY),t.addSwitchable("readium-scroll-on","readium-scroll-off",this.verticalScroll,Ae.SCROLL_REF,Ae.SCROLL_KEY),t}async saveProperty(t){let n=await this.store.get(this.USERSETTINGS);if(n){let i=JSON.parse(n);i=i.filter(o=>o.name!==t.name),t.value!==void 0&&i.push(t),await this.store.set(this.USERSETTINGS,JSON.stringify(i))}else{let i=[];i.push(t),await this.store.set(this.USERSETTINGS,JSON.stringify(i))}return new Promise(i=>i(t))}async getProperty(t){let n=await this.store.get(this.USERSETTINGS);if(n){let i=JSON.parse(n);return i=i.filter(o=>o.name===t),i.length===0?null:i[0]}return null}async getPropertyAndFallback(t,n){return(await this.getProperty(n))?.value??this[t]}async resetUserSettings(){await this.store.remove(this.USERSETTINGS),await this.reset(),this.settingsChangeCallback()}get currentSettings(){return{appearance:Gt.appearanceValues[this.userProperties?.getByRef(Ae.APPEARANCE_REF)?.value],fontFamily:Gt.fontFamilyValues[this.userProperties?.getByRef(Ae.FONT_FAMILY_REF)?.value],textAlignment:Gt.textAlignmentValues[this.userProperties?.getByRef(Ae.TEXT_ALIGNMENT_REF)?.value],columnCount:Gt.columnCountValues[this.userProperties?.getByRef(Ae.COLUMN_COUNT_REF)?.value],verticalScroll:this.verticalScroll,fontSize:this.fontSize,wordSpacing:this.wordSpacing,letterSpacing:this.letterSpacing,pageMargins:this.pageMargins,lineHeight:this.lineHeight}}async applyUserSettings(t){if(t.appearance){let n;t.appearance==="day"||t.appearance==="readium-default-on"?n=Gt.appearanceValues[0]:t.appearance==="sepia"||t.appearance==="readium-sepia-on"?n=Gt.appearanceValues[1]:t.appearance==="night"||t.appearance==="readium-night-on"?n=Gt.appearanceValues[2]:n=t.appearance,this.appearance=Gt.appearanceValues.findIndex(o=>o===n);let i=this.userProperties?.getByRef(Ae.APPEARANCE_REF);i&&(i.value=this.appearance,await this.storeProperty(i))}if(t.fontSize){this.fontSize=t.fontSize;let n=this.userProperties?.getByRef(Ae.FONT_SIZE_REF);n&&(n.value=this.fontSize,await this.storeProperty(n))}if(t.fontFamily){this.fontFamily=Gt.fontFamilyValues.findIndex(i=>i===t.fontFamily);let n=this.userProperties?.getByRef(Ae.FONT_FAMILY_REF);n&&(n.value=this.fontFamily,await this.storeProperty(n))}if(t.letterSpacing){this.letterSpacing=t.letterSpacing;let n=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF);n&&(n.value=this.letterSpacing,await this.storeProperty(n))}if(t.wordSpacing){this.wordSpacing=t.wordSpacing;let n=this.userProperties?.getByRef(Ae.WORD_SPACING_REF);n&&(n.value=this.wordSpacing,await this.storeProperty(n))}if(t.columnCount){this.columnCount=Gt.columnCountValues.findIndex(i=>i===t.columnCount);let n=this.userProperties?.getByRef(Ae.COLUMN_COUNT_REF);n&&(n.value=this.columnCount,await this.storeProperty(n)),this.settingsColumnsChangeCallback()}if(t.textAlignment){this.textAlignment=Gt.textAlignmentValues.findIndex(i=>i===t.textAlignment);let n=this.userProperties?.getByRef(Ae.TEXT_ALIGNMENT_REF);n&&(n.value=this.textAlignment,await this.storeProperty(n))}if(t.lineHeight){this.lineHeight=t.lineHeight;let n=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF);n&&(n.value=this.lineHeight,await this.storeProperty(n))}if(t.pageMargins){this.pageMargins=t.pageMargins;let n=this.userProperties?.getByRef(Ae.PAGE_MARGINS_REF);n&&(n.value=this.pageMargins,await this.storeProperty(n))}if(t.verticalScroll!==void 0){let n=this.view?.getCurrentPosition();this.verticalScroll=Gt.parseScrollSetting(t.verticalScroll);let i=this.userProperties?.getByRef(Ae.SCROLL_REF);i&&(i.value=this.verticalScroll,await this.saveProperty(i)),this.view?.setMode?.(this.verticalScroll),n&&this.view?.goToProgression(n),this.viewChangeCallback()}await this.applyProperties(),this.settingsChangeCallback()}static parseScrollSetting(t){switch(t){case!0:case"scroll":case"readium-scroll-on":return!0;case!1:case"paginated":case"readium-scroll-off":return!1;default:return!1}}async scroll(t){let n=this.view?.getCurrentPosition();this.verticalScroll=t;let i=this.userProperties?.getByRef(Ae.SCROLL_REF);i&&(i.value=this.verticalScroll,await this.saveProperty(i)),await this.applyProperties(),this.view?.setMode?.(this.verticalScroll),n&&this.view?.goToProgression(n),this.viewChangeCallback()}async increase(t){if(t==="fontSize"){(this.userProperties?.getByRef(Ae.FONT_SIZE_REF)).increment(),this.fontSize=this.userProperties?.getByRef(Ae.FONT_SIZE_REF)?.value;let n=this.userProperties?.getByRef(Ae.FONT_SIZE_REF);n&&await this.storeProperty(n)}else if(t==="letterSpacing"){(this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)).increment(),this.letterSpacing=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="wordSpacing"){(this.userProperties?.getByRef(Ae.WORD_SPACING_REF)).increment(),this.wordSpacing=this.userProperties?.getByRef(Ae.WORD_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.WORD_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="lineHeight"){(this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)).increment(),this.lineHeight=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)?.value;let n=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF);n&&await this.storeProperty(n)}await this.applyProperties(),this.settingsChangeCallback()}async decrease(t){if(t==="fontSize"){(this.userProperties?.getByRef(Ae.FONT_SIZE_REF)).decrement(),this.fontSize=this.userProperties?.getByRef(Ae.FONT_SIZE_REF)?.value;let n=this.userProperties?.getByRef(Ae.FONT_SIZE_REF);n&&await this.storeProperty(n)}else if(t==="letterSpacing"){(this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)).decrement(),this.letterSpacing=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.LETTER_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="wordSpacing"){(this.userProperties?.getByRef(Ae.WORD_SPACING_REF)).decrement(),this.wordSpacing=this.userProperties?.getByRef(Ae.WORD_SPACING_REF)?.value;let n=this.userProperties?.getByRef(Ae.WORD_SPACING_REF);n&&await this.storeProperty(n)}else if(t==="lineHeight"){(this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)).decrement(),this.wordSpacing=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF)?.value;let n=this.userProperties?.getByRef(Ae.LINE_HEIGHT_REF);n&&await this.storeProperty(n)}await this.applyProperties(),this.settingsChangeCallback()}},ko=Gt;ko.appearanceValues=["readium-default-on","readium-sepia-on","readium-night-on"],ko.fontFamilyValues=["Original","serif","sans-serif"],ko.textAlignmentValues=["auto","justify","start"],ko.columnCountValues=["auto","1","2"];H();H();var Fi;(function(n){n[n.Bookmark=0]="Bookmark",n[n.Annotation=1]="Annotation"})(Fi||(Fi={}));H();H();H();H();H();H();var P_={stringify(r){let t=r.nSigBytes,n=r.words,i=[];for(let o=0;o<t;o++){let s=n[o>>>2]>>>24-o%4*8&255;i.push((s>>>4).toString(16)),i.push((s&15).toString(16))}return i.join("")},parse(r){let t=r.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(r))throw new Error(`Invalid Hex string: ${r}`);let n=[];for(let i=0;i<t;i+=2)n[i>>>3]|=parseInt(r.substr(i,2),16)<<24-i%8*4;return new Yn(n,t/2)}};H();H();var M_=typeof navigator!="undefined"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",fs=(()=>{let r=parseInt((/msie (\d+)/.exec(M_)||[])[1],10);return isNaN(r)?(r=parseInt((/trident\/.*; rv:(\d+)/.exec(M_)||[])[1],10),isNaN(r)?!1:r):r})();function k_(r,t){return fs===!1?!1:t?r==="<"?fs<t:r==="<="?fs<=t:r===">"?fs>t:r===">="?fs>=t:fs===t:!0}function z5(){if(typeof window!="undefined"){let r=window.crypto||window.msCrypto;if(!r){if(k_("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(Math.random()*512)%256};throw new Error("Crypto module not found")}return function(){return r.getRandomValues(new Uint32Array(1))[0]}}else{if(typeof globalThis!="undefined"&&globalThis.crypto)return function(){return globalThis.crypto.randomBytes(4).readInt32LE()};if(typeof Ja=="function")return function(){return __non_webpack_require__("crypto").randomBytes(4).readInt32LE()}}throw new Error("Unable to find crypto module")}var I_=z5();var Yn=class{constructor(t,n){if(Array.isArray(t)||!t){this._words=Array.isArray(t)?t:[],this._nSignificantBytes=typeof n=="number"?n:this._words.length*4;return}else if(t instanceof Yn){this._words=t.words.slice(),this._nSignificantBytes=t.nSigBytes;return}let i;try{t instanceof ArrayBuffer?i=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(l){throw new Error("Invalid argument")}if(!i)throw new Error("Invalid argument");let o=i.byteLength,s=[];for(let l=0;l<o;l++)s[l>>>2]|=i[l]<<24-l%4*8;this._words=s,this._nSignificantBytes=o}get nSigBytes(){return this._nSignificantBytes}set nSigBytes(t){this._nSignificantBytes=t}get words(){return this._words}toString(t){return t?t.stringify(this):P_.stringify(this)}toUint8Array(){let t=this._words,n=this._nSignificantBytes,i=new Uint8Array(n);for(let o=0;o<n;o++)i[o]=t[o>>>2]>>>24-o%4*8&255;return i}concat(t){let n=t.words.slice(),i=t.nSigBytes;if(this.clamp(),this._nSignificantBytes%4)for(let o=0;o<i;o++){let s=n[o>>>2]>>>24-o%4*8&255;this._words[this._nSignificantBytes+o>>>2]|=s<<24-(this._nSignificantBytes+o)%4*8}else for(let o=0;o<i;o+=4)this._words[this._nSignificantBytes+o>>>2]=n[o>>>2];return this._nSignificantBytes+=i,this}clamp(){let t=this._nSignificantBytes;this._words[t>>>2]&=4294967295<<32-t%4*8,this._words.length=Math.ceil(t/4)}clone(){return new Yn(this._words.slice(),this._nSignificantBytes)}static random(t){let n=[];for(let i=0;i<t;i+=4)n.push(I_());return new Yn(n,t)}};H();H();var I0={stringify(r){let t=r.nSigBytes,n=r.words,i=[];for(let o=0;o<t;o++){let s=n[o>>>2]>>>24-o%4*8&255;i.push(String.fromCharCode(s))}return i.join("")},parse(r){let t=r.length,n=[];for(let i=0;i<t;i++)n[i>>>2]|=(r.charCodeAt(i)&255)<<24-i%4*8;return new Yn(n,t)}};var L_={stringify(r){try{return decodeURIComponent(escape(I0.stringify(r)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse(r){return I0.parse(unescape(encodeURIComponent(r)))}};var L0=class{constructor(t){this._minBufferSize=0,this._blockSize=0,this._props=t,this._data=t&&typeof t.data!="undefined"?t.data.clone():new Yn,this._nBytes=t&&typeof t.nBytes=="number"?t.nBytes:0}get blockSize(){return this._blockSize}reset(t,n){this._data=typeof t!="undefined"?t.clone():new Yn,this._nBytes=typeof n=="number"?n:0}_append(t){let n=typeof t=="string"?L_.parse(t):t;this._data.concat(n),this._nBytes+=n.nSigBytes}_process(t){let n,i=this._data.words,o=this._data.nSigBytes,s=this._blockSize,l=this._blockSize*4,h=o/l;t?h=Math.ceil(h):h=Math.max((h|0)-this._minBufferSize,0);let u=h*s,d=Math.min(u*4,o);if(u){for(let m=0;m<u;m+=s)this._doProcessBlock(i,m);n=i.splice(0,u),this._data.nSigBytes-=d}return new Yn(n,d)}_doProcessBlock(t,n){throw new Error("Not implemented")}};var B0=class extends L0{constructor(t){super(t);this._blockSize=512/32,this._props=t,t&&typeof t.blockSize=="number"&&(this._blockSize=t.blockSize),this.reset(t?t.data:void 0,t?t.nBytes:void 0)}get blockSize(){return this._blockSize}reset(t,n){super.reset.call(this,t,n),this._doReset()}update(t){return this._append(t),this._process(),this}finalize(t){return t&&this._append(t),this._doFinalize()}_doReset(){throw new Error("Not implemented")}_doFinalize(){throw new Error("Not implemented")}};var N0=[],B_=[];function G5(r){let t=Math.sqrt(r);for(let n=2;n<=t;n++)if(!(r%n))return!1;return!0}function N_(r){return(r-(r|0))*4294967296|0}(function(){let t=2,n=0;for(;n<64;)G5(t)&&(n<8&&(N0[n]=N_(Math.pow(t,1/2))),B_[n]=N_(Math.pow(t,1/3)),n++),t++})();var ps=[],er=class extends B0{constructor(t){super(t);this._hash=new Yn(N0.slice(0)),this._props=t,t&&typeof t.hash!="undefined"&&(this._hash=t.hash.clone())}_doReset(){this._hash=new Yn(N0.slice(0))}_doProcessBlock(t,n){let i=this._hash.words,o=i[0],s=i[1],l=i[2],h=i[3],u=i[4],d=i[5],m=i[6],y=i[7];for(let w=0;w<64;w++){if(w<16)ps[w]=t[n+w]|0;else{let C=ps[w-15],x=(C<<25|C>>>7)^(C<<14|C>>>18)^C>>>3,E=ps[w-2],T=(E<<15|E>>>17)^(E<<13|E>>>19)^E>>>10;ps[w]=x+ps[w-7]+T+ps[w-16]}let v=u&d^~u&m,g=o&s^o&l^s&l,f=(o<<30|o>>>2)^(o<<19|o>>>13)^(o<<10|o>>>22),p=(u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25),b=y+p+v+B_[w]+ps[w],S=f+g;y=m,m=d,d=u,u=h+b|0,h=l,l=s,s=o,o=b+S|0}i[0]=i[0]+o|0,i[1]=i[1]+s|0,i[2]=i[2]+l|0,i[3]=i[3]+h|0,i[4]=i[4]+u|0,i[5]=i[5]+d|0,i[6]=i[6]+m|0,i[7]=i[7]+y|0}_doFinalize(){let t=this._data.words,n=this._nBytes*8,i=this._data.nSigBytes*8;return t[i>>>5]|=128<<24-i%32,t[(i+64>>>9<<4)+14]=Math.floor(n/4294967296),t[(i+64>>>9<<4)+15]=n,this._data.nSigBytes=t.length*4,this._process(),this._hash}clone(){let t={hash:this._hash,blockSize:this._blockSize,data:this._data,nBytes:this._nBytes};return new er(t)}static hash(t,n){return new er(n).finalize(t)}};var Pl=gt(Mo());H();var mt;(function(h){h[h.Annotation=0]="Annotation",h[h.Search=1]="Search",h[h.ReadAloud=2]="ReadAloud",h[h.PageBreak=3]="PageBreak",h[h.Definition=4]="Definition",h[h.LineFocus=5]="LineFocus",h[h.Comment=6]="Comment"})(mt||(mt={}));H();var Xn=gt(cn());function Qd(r,t){let n=r.getClientRects();return D0(n,t)}function D0(r,t){let n=1,i=[];for(let u of r)i.push({bottom:u.bottom,height:u.height,left:u.left,right:u.right,top:u.top,width:u.width});let o=F_(i,n,t),s=Z5(o,n),l=j_(s),h=2*2;for(let u=l.length-1;u>=0;u--){let d=l[u];if(!(d.width*d.height>h))if(l.length>1)Xn.default.log("CLIENT RECT: remove small"),l.splice(u,1);else{Xn.default.log("CLIENT RECT: remove small, but keep otherwise empty!");break}}return H_(l),Xn.default.log(`CLIENT RECT: reduced ${i.length} --> ${l.length}`),l}function tr(r,t,n){return Math.abs(r-t)<=n}function V5(r,t){let n=Math.max(r.left,t.left),i=Math.min(r.right,t.right),o=Math.max(r.top,t.top),s=Math.min(r.bottom,t.bottom);return{bottom:s,height:Math.max(0,s-o),left:n,right:i,top:o,width:Math.max(0,i-n)}}function D_(r,t){let n=V5(t,r);if(n.height===0||n.width===0)return[r];let i=[];{let o={bottom:r.bottom,height:0,left:r.left,right:n.left,top:r.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{let o={bottom:n.top,height:0,left:n.left,right:n.right,top:r.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{let o={bottom:r.bottom,height:0,left:n.left,right:n.right,top:n.bottom,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}{let o={bottom:r.bottom,height:0,left:n.right,right:r.right,top:r.top,width:0};o.width=o.right-o.left,o.height=o.bottom-o.top,o.height!==0&&o.width!==0&&i.push(o)}return i}function eh(r,t,n,i){return(r.left<t||tr(r.left,t,i))&&(r.right>t||tr(r.right,t,i))&&(r.top<n||tr(r.top,n,i))&&(r.bottom>n||tr(r.bottom,n,i))}function J5(r,t,n){return eh(r,t.left,t.top,n)&&eh(r,t.right,t.top,n)&&eh(r,t.left,t.bottom,n)&&eh(r,t.right,t.bottom,n)}function K5(r,t){let n=Math.min(r.left,t.left),i=Math.max(r.right,t.right),o=Math.min(r.top,t.top),s=Math.max(r.bottom,t.bottom);return{bottom:s,height:s-o,left:n,right:i,top:o,width:i-n}}function F0(r,t,n){return(r.left<t.right||n>=0&&tr(r.left,t.right,n))&&(t.left<r.right||n>=0&&tr(t.left,r.right,n))&&(r.top<t.bottom||n>=0&&tr(r.top,t.bottom,n))&&(t.top<r.bottom||n>=0&&tr(t.top,r.bottom,n))}function F_(r,t,n){for(let i=0;i<r.length;i++)for(let o=i+1;o<r.length;o++){let s=r[i],l=r[o];if(s===l){Xn.default.log("mergeTouchingRects rect1 === rect2 ??!");continue}let h=tr(s.top,l.top,t)&&tr(s.bottom,l.bottom,t),u=tr(s.left,l.left,t)&&tr(s.right,l.right,t);if((u&&!n||h&&!u)&&F0(s,l,t)){Xn.default.log(`CLIENT RECT: merging two into one, VERTICAL: ${h} HORIZONTAL: ${u} (${n})`);let w=r.filter(g=>g!==s&&g!==l),v=K5(s,l);return w.push(v),F_(w,t,n)}}return r}function j_(r){for(let t=0;t<r.length;t++)for(let n=t+1;n<r.length;n++){let i=r[t],o=r[n];if(i===o){Xn.default.log("replaceOverlappingRects rect1 === rect2 ??!");continue}if(F0(i,o,-1)){let s=[],l,h,u=D_(i,o);if(u.length===1)s=u,l=i,h=o;else{let y=D_(o,i);u.length<y.length?(s=u,l=i,h=o):(s=y,l=o,h=i)}let d=[];d.push(h),Array.prototype.push.apply(d,s),H_(d),Xn.default.log(`CLIENT RECT: overlap, cut one rect into ${s.length}`);let m=r.filter(y=>y!==l);return Array.prototype.push.apply(m,s),j_(m)}}return r}function Y5(r,t){return Math.max(0,Math.min(r.right,t.right)-Math.max(r.left,t.left))}function X5(r,t){return Math.max(0,Math.min(r.bottom,t.bottom)-Math.max(r.top,t.top))}function Z5(r,t){let n=new Set(r);for(let i of r){if(!(i.width>1&&i.height>1)){Xn.default.log("CLIENT RECT: remove tiny"),n.delete(i);continue}for(let s of r)if(i!==s&&!!n.has(s)&&J5(s,i,t)){Xn.default.log("CLIENT RECT: remove contained"),n.delete(i);break}}return Array.from(n)}function H_(r){let t=[];for(let n of r)for(let i of r){if(n===i)continue;let o=t.indexOf(n)>=0,s=t.indexOf(i)>=0;if((!o||!s)&&F0(n,i,-1)){o||t.push(n),s||t.push(i),Xn.default.log("CLIENT RECT: overlap ---"),Xn.default.log(`#1 TOP:${n.top} BOTTOM:${n.bottom} LEFT:${n.left} RIGHT:${n.right} WIDTH:${n.width} HEIGHT:${n.height}`),Xn.default.log(`#2 TOP:${i.top} BOTTOM:${i.bottom} LEFT:${i.left} RIGHT:${i.right} WIDTH:${i.width} HEIGHT:${i.height}`);let l=Y5(n,i);Xn.default.log(`xOverlap: ${l}`);let h=X5(n,i);Xn.default.log(`yOverlap: ${h}`)}}t.length&&Xn.default.log(`CLIENT RECT: overlaps ${t.length}`)}H();var Zt=gt(cn());function Ir(r,t){let n=r?r.getSelection():null;if(!n)return;if(n.isCollapsed){Zt.default.log("^^^ SELECTION COLLAPSED.");return}let i=n.toString(),o=i.trim().replace(/\n/g," ").replace(/\s\s+/g," ");if(o.length===0){Zt.default.log("^^^ SELECTION TEXT EMPTY.");return}if(!n.anchorNode||!n.focusNode)return;let s=n.rangeCount===1?n.getRangeAt(0):U_(n.anchorNode,n.anchorOffset,n.focusNode,n.focusOffset);if(!s||s.collapsed){Zt.default.log("$$$$$$$$$$$$$$$$$ CANNOT GET NON-COLLAPSED SELECTION RANGE?!");return}let l=eD(s);l.startContainer!==s.startContainer&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startContainer"),Zt.default.log(l.startContainer),Zt.default.log(s.startContainer)),l.startOffset!==s.startOffset&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: startOffset"),Zt.default.log(`${l.startOffset} !== ${s.startOffset}`)),l.endContainer!==s.endContainer&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endContainer"),Zt.default.log(l.endContainer),Zt.default.log(s.endContainer)),l.endOffset!==s.endOffset&&(Zt.default.log(">>>>>>>>>>>>>>>>>>>>>>> SELECTION RANGE NORMALIZE diff: endOffset"),Zt.default.log(`${l.endOffset} !== ${s.endOffset}`));let h=oo(l,t);if(!h){Zt.default.log("^^^ SELECTION RANGE INFO FAIL?!");return}return{rangeInfo:h,cleanText:o,rawText:i,range:l}}function U_(r,t,n,i){try{let o=new Range;if(o.setStart(r,t),o.setEnd(n,i),!o.collapsed)return Zt.default.log(">>> createOrderedRange RANGE OK"),o;Zt.default.log(">>> createOrderedRange COLLAPSED ... RANGE REVERSE?");let s=new Range;if(s.setStart(n,i),s.setEnd(r,t),!s.collapsed)return Zt.default.log(">>> createOrderedRange RANGE REVERSE OK."),o;Zt.default.log(">>> createOrderedRange RANGE REVERSE ALSO COLLAPSED?!");return}catch(o){console.warn(o.message);return}}function oo(r,t){let n=r.startContainer.nodeType===Node.ELEMENT_NODE,i=n?r.startContainer:r.startContainer.parentNode&&r.startContainer.parentNode.nodeType===Node.ELEMENT_NODE?r.startContainer.parentNode:void 0;if(!i)return;let o=n?-1:Array.from(i.childNodes).indexOf(r.startContainer);if(o<-1)return;let s=t(i),l=r.endContainer.nodeType===Node.ELEMENT_NODE,h=l?r.endContainer:r.endContainer.parentNode&&r.endContainer.parentNode.nodeType===Node.ELEMENT_NODE?r.endContainer.parentNode:void 0;if(!h)return;let u=l?-1:Array.from(h.childNodes).indexOf(r.endContainer);if(u<-1)return;let d=t(h),m=Q5(r.startContainer,r.endContainer);if(!m){Zt.default.log("^^^ NO RANGE COMMON ANCESTOR?!");return}if(r.commonAncestorContainer){let y=r.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?r.commonAncestorContainer:r.commonAncestorContainer.parentNode;y&&y.nodeType===Node.ELEMENT_NODE&&m!==y&&(Zt.default.log(">>>>>> COMMON ANCESTOR CONTAINER DIFF??!"),Zt.default.log(t(m)),Zt.default.log(t(y)))}if(d&&s)return{endContainerChildTextNodeIndex:u,endContainerElementCssSelector:d,endOffset:r.endOffset,startContainerChildTextNodeIndex:o,startContainerElementCssSelector:s,startOffset:r.startOffset}}function th(r,t){let n=r.querySelector(t.startContainerElementCssSelector);if(!n){Zt.default.log("^^^ convertRangeInfo NO START ELEMENT CSS SELECTOR?!");return}let i=n;if(t.startContainerChildTextNodeIndex>=0){if(t.startContainerChildTextNodeIndex>=n.childNodes.length){Zt.default.log("^^^ convertRangeInfo rangeInfo.startContainerChildTextNodeIndex >= startElement.childNodes.length?!");return}if(i=n.childNodes[t.startContainerChildTextNodeIndex],i.nodeType!==Node.TEXT_NODE){Zt.default.log("^^^ convertRangeInfo startContainer.nodeType !== Node.TEXT_NODE?!");return}}let o=r.querySelector(t.endContainerElementCssSelector);if(!o){Zt.default.log("^^^ convertRangeInfo NO END ELEMENT CSS SELECTOR?!");return}let s=o;if(t.endContainerChildTextNodeIndex>=0){if(t.endContainerChildTextNodeIndex>=o.childNodes.length){Zt.default.log("^^^ convertRangeInfo rangeInfo.endContainerChildTextNodeIndex >= endElement.childNodes.length?!");return}if(s=o.childNodes[t.endContainerChildTextNodeIndex],s.nodeType!==Node.TEXT_NODE){Zt.default.log("^^^ convertRangeInfo endContainer.nodeType !== Node.TEXT_NODE?!");return}}return U_(i,t.startOffset,s,t.endOffset)}function Q5(r,t){if(r.nodeType===Node.ELEMENT_NODE&&r===t||r.nodeType===Node.ELEMENT_NODE&&r.contains(t))return r;if(t.nodeType===Node.ELEMENT_NODE&&t.contains(r))return t;let n=[],i=r.parentNode;for(;i&&i.nodeType===Node.ELEMENT_NODE;)n.push(i),i=i.parentNode;let o=[];for(i=t.parentNode;i&&i.nodeType===Node.ELEMENT_NODE;)o.push(i),i=i.parentNode;let s=n.find(l=>o.indexOf(l)>=0);return s||(s=o.find(l=>n.indexOf(l)>=0)),s}function eD(r){let t=r.cloneRange(),n=t.startContainer,i=t.startOffset,o=t.endContainer,s=t.endOffset;n.childNodes.length&&i>0&&(n=q_(n.childNodes[i-1]),i=n.length||0),s<o.childNodes.length&&(o=$_(o.childNodes[s]),s=0);let l=$_(n),h=q_(o);function u(d){if(d.childNodes.length)return!1;let m=d.length||0;return d===n&&i===m?!1:!(d===o&&s===0)}for(;l&&!u(l)&&l!==h;)l=tD(l);for(l===n?t.setStart(n,i):l!==null&&(l.nodeType===3?t.setStart(l,0):t.setStartBefore(l));h&&!u(h)&&h!==l;)h=nD(h);return h===o?t.setEnd(o,s):h!==null&&(h.nodeType===3?t.setEnd(h,h.length):t.setEndAfter(h)),t}function tD(r){if(r.firstChild)return r.firstChild;let t=r;for(;!t.nextSibling;)if(t=t.parentNode,!t)return null;return t.nextSibling}function nD(r){if(r.lastChild)return r.lastChild;let t=r;for(;!t.previousSibling;)if(t=t.parentNode,!t)return null;return t.previousSibling}function $_(r){for(;r.firstChild;)r=r.firstChild;return r}function q_(r){for(;r.lastChild;)r=r.lastChild;return r}H();var H0=gt(z_()),Io;(function(i){i[i.All=0]="All",i[i.Two=1]="Two",i[i.One=2]="One"})(Io||(Io={}));var so,U0;function Nn(r,t,n){if(r.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(r.tagName.toLowerCase()==="html")return r.tagName.toLowerCase();let i={className:s=>!0,idName:s=>!0,optimizedMinLength:2,root:t.body,seedMinLength:1,tagName:s=>!0,threshold:1e3};so=dt(dt({},i),n),U0=cD(so.root,i);let o=$0(r,0,()=>$0(r,1,()=>$0(r,2)));if(o){let s=Y_(X_(o,r));return s.length>0&&(o=s[0]),nh(o)}else throw new Error("Selector was not found.")}function cD(r,t){return r.nodeType===Node.DOCUMENT_NODE?r:r===t.root?r.ownerDocument:r}function $0(r,t,n){let i=null,o=[],s=r,l=0;for(;s&&s!==so.root.parentElement;){let h=z0(uD(s))||z0(...dD(s))||z0(hD(s))||[fD()],u=pD(s);if(t===0)u&&(h=h.concat(h.filter(W0).map(d=>q0(d,u))));else if(t===1)h=h.slice(0,1),u&&(h=h.concat(h.filter(W0).map(d=>q0(d,u))));else if(t===2){let[d]=h=h.slice(0,1);u&&W0(d)&&(h=[q0(d,u)])}for(let d of h)d.level=l;if(o.push(h),o.length>=so.seedMinLength&&(i=G_(o,n),i))break;s=s.parentElement,l++}return i||(i=G_(o,n)),i}function G_(r,t){let n=Y_(K_(r));if(n.length>so.threshold)return t?t():null;for(let i of n)if(J_(i))return i;return null}function nh(r){let t=r[0],n=t.name;for(let i=1;i<r.length;i++){let o=r[i].level||0;t.level===o-1?n=`${r[i].name} > ${n}`:n=`${r[i].name} ${n}`,t=r[i]}return n}function V_(r){return r.map(t=>t.penalty).reduce((t,n)=>t+n,0)}function J_(r){switch(U0.querySelectorAll(nh(r)).length){case 0:throw new Error(`Can't select any node with this selector: ${nh(r)}`);case 1:return!0;default:return!1}}function uD(r){let t=r.getAttribute("id");return t&&so.idName(t)?{name:"#"+(0,H0.default)(t,{isIdentifier:!0}),penalty:0}:null}function dD(r){return Array.from(r.classList).filter(so.className).map(n=>({name:"."+(0,H0.default)(n,{isIdentifier:!0}),penalty:1}))}function hD(r){let t=r.tagName.toLowerCase();return so.tagName(t)?{name:t,penalty:2}:null}function fD(){return{name:"*",penalty:3}}function pD(r){let t=r.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let i=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&i++,n!==r);)n=n.nextSibling;return i}function q0(r,t){return{name:r.name+`:nth-child(${t})`,penalty:r.penalty+1}}function W0(r){return r.name!=="html"&&!r.name.startsWith("#")}function z0(...r){let t=r.filter(gD);return t.length>0?t:null}function gD(r){return r!=null}function*K_(r,t=[]){if(r.length>0)for(let n of r[0])yield*K_(r.slice(1,r.length),t.concat(n));else yield t}function Y_(r){return Array.from(r).sort((t,n)=>V_(t)-V_(n))}function*X_(r,t){if(r.length>2&&r.length>so.optimizedMinLength)for(let n=1;n<r.length-1;n++){let i=[...r];i.splice(n,1),J_(i)&&mD(i,t)&&(yield i,yield*X_(i,t))}}function mD(r,t){return U0.querySelector(nh(r))===t}H();var ot;(function(s){s[s.Highlight=0]="Highlight",s[s.Underline=1]="Underline",s[s.Bookmark=2]="Bookmark",s[s.Custom=3]="Custom",s[s.Comment=4]="Comment"})(ot||(ot={}));H();var G0=24,yD=24,Z_="0 0 24 24",mi=(r,t,n,i="icon")=>`<svg xmlns="http://www.w3.org/2000/svg" width="${G0}" height="${yD}" viewBox="${Z_}" preserveAspectRatio="xMidYMid meet" role="img" class="${i}" aria-labelledBy="${r}">
73
73
  <title id="${r}">${t}</title>
74
74
  ${n}
75
75
  </svg>`,bD=(r,t,n,i,o="icon")=>`<svg xmlns="http://www.w3.org/2000/svg" width="${G0}" height="${G0}" viewBox="${i}" preserveAspectRatio="xMidYMid meet" role="img" class="${o}" aria-labelledBy="${r}">