10&&"function"==typeof n,c=l?Date.now()+15:0;let d=0;const h=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==i&&a===i.nextBreakPoint)return i.breakIt(a,n),a;if(p=s[a],p!==gn.dependency)this[p].apply(this,r[a]);else for(const t of r[a]){const e=t.startsWith("g_")?h:u;if(!e.has(t))return e.get(t,n),a}if(a++,a===o)return a;if(l&&++d>10){if(Date.now()>c)return n(),a;d=0}}}#Oe(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,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)}endDrawing(){this.#Oe(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#Ne()}#Ne(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const n=t.width??t.displayWidth,i=t.height??t.displayHeight;let r,s,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=n,c=i,d="prescale1";for(;a>2&&l>1||o>2&&c>1;){let e=l,n=c;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&c>1&&(n=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,o/=c/n),r=this.cachedCanvases.getCanvas(d,e,n),s=r.context,s.clearRect(0,0,e,n),s.drawImage(t,0,0,l,c,0,0,e,n),t=r.canvas,l=e,c=n,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,{width:n,height:i}=t,r=this.current.fillColor,s=this.current.patternFill,a=ai(e);let o,l,c,d;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(s?a:[a.slice(0,4),r]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const n=o.get(l);if(n&&!s)return{canvas:n,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])};c=n}c||(d=this.cachedCanvases.getCanvas("maskCanvas",n,i),rr(d.context,t));let h=qn.transform(a,[1/n,0,0,-1/i,0,0]);h=qn.transform(h,[1,0,0,1,0,-i]);const[u,p,f,g]=qn.getAxialAlignedBoundingBox([0,0,n,i],h),m=Math.round(f-u)||1,v=Math.round(g-p)||1,b=this.cachedCanvases.getCanvas("fillCanvas",m,v),y=b.context,_=u,w=p;y.translate(-_,-w),y.transform(...h),c||(c=this._scaleImage(d.canvas,oi(y)),c=c.img,o&&s&&o.set(l,c)),y.imageSmoothingEnabled=or(ai(y),t.interpolate),er(y,c,0,0,c.width,c.height,0,0,n,i),y.globalCompositeOperation="source-in";const A=qn.transform(oi(y),[1,0,0,1,-_,-w]);return y.fillStyle=s?r.getPattern(e,this,A,ji):r,y.fillRect(0,0,n,i),o&&!s&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,b.canvas)),{canvas:b.canvas,offsetX:Math.round(_),offsetY:Math.round(w)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=lr[t]}setLineJoin(t){this.ctx.lineJoin=cr[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(t),n.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,n]of t)switch(e){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(n,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const r=this.ctx;r.setTransform(...ai(this.suspendedCtx)),sr(this.suspendedCtx,r),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,n){e.translate(t,n),this.__originalTranslate(t,n)},t.scale=function(t,n){e.scale(t,n),this.__originalScale(t,n)},t.transform=function(t,n,i,r,s,a){e.transform(t,n,i,r,s,a),this.__originalTransform(t,n,i,r,s,a)},t.setTransform=function(t,n,i,r,s,a){e.setTransform(t,n,i,r,s,a),this.__originalSetTransform(t,n,i,r,s,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,n){e.moveTo(t,n),this.__originalMoveTo(t,n)},t.lineTo=function(t,n){e.lineTo(t,n),this.__originalLineTo(t,n)},t.bezierCurveTo=function(t,n,i,r,s,a){e.bezierCurveTo(t,n,i,r,s,a),this.__originalBezierCurveTo(t,n,i,r,s,a)},t.rect=function(t,n,i,r){e.rect(t,n,i,r),this.__originalRect(t,n,i,r)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(r,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(),sr(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,e,this.ctx,t),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()}composeSMask(t,e,n,i){const r=i[0],s=i[1],a=i[2]-r,o=i[3]-s;0!==a&&0!==o&&(this.genericComposeSMask(e.context,n,a,o,e.subtype,e.backdrop,e.transferMap,r,s,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(n.canvas,0,0),t.restore())}genericComposeSMask(t,e,n,i,r,s,a,o,l,c,d){let h=t.canvas,u=o-c,p=l-d;if(s){const e=qn.makeHexColor(...s);if(u<0||p<0||u+n>h.width||p+i>h.height){const t=this.cachedCanvases.getCanvas("maskExtension",n,i),r=t.context;r.drawImage(h,-u,-p),r.globalCompositeOperation="destination-atop",r.fillStyle=e,r.fillRect(0,0,n,i),r.globalCompositeOperation="source-over",h=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const r=new Path2D;r.rect(u,p,n,i),t.clip(r),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,n,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===r&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===r&&(e.filter=this.filterFactory.addLuminosityFilter(a));const f=new Path2D;f.rect(o,l,n,i),e.clip(f),e.globalCompositeOperation="destination-in",e.drawImage(h,u,p,n,i,o,l,n,i),e.restore()}save(){this.inSMaskMode?(sr(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),sr(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,n,i,r,s){this.ctx.transform(t,e,n,i,r,s),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,n){const i=this.ctx,r=this.current;let s,a,o=r.x,l=r.y;const c=ai(i),d=0===c[0]&&0===c[3]||0===c[1]&&0===c[2],h=d?n.slice(0):null;for(let n=0,u=0,p=t.length;n100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${s}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,n,i,r,s){this.current.textMatrix=[t,e,n,i,r,s],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,n,i){const r=this.ctx,s=this.current,a=s.font,o=s.textRenderingMode,l=s.fontSize/s.fontSizeScale,c=3&o,d=!!(4&o),h=s.patternFill&&!a.missingFile;let u;(a.disableFontFace||d||h)&&(u=a.getPathGenerator(this.commonObjs,t)),a.disableFontFace||h?(r.save(),r.translate(e,n),r.beginPath(),u(r,l),i&&r.setTransform(...i),0!==c&&2!==c||r.fill(),1!==c&&2!==c||r.stroke(),r.restore()):(0!==c&&2!==c||r.fillText(t,e,n),1!==c&&2!==c||r.strokeText(t,e,n)),d&&(this.pendingTextPaths||=[]).push({transform:ai(r),x:e,y:n,fontSize:l,addToPath:u})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let n=!1;for(let t=3;t0&&e[t]<255){n=!0;break}return Sn(this,"isFontSubpixelAAEnabled",n)}showText(t){const e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(0===i)return;const r=this.ctx,s=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,c=e.textHScale*l,d=t.length,h=n.vertical,u=h?1:-1,p=n.defaultVMetrics,f=i*e.fontMatrix[0],g=0===e.textRenderingMode&&!n.disableFontFace&&!e.patternFill;let m;if(r.save(),r.transform(...e.textMatrix),r.translate(e.x,e.y+e.textRise),l>0?r.scale(c,-1):r.scale(c,1),e.patternFill){r.save();const t=e.fillColor.getPattern(r,this,oi(r),ji);m=ai(r),r.restore(),r.fillStyle=t}let v=e.lineWidth;const b=e.textMatrixScale;if(0===b||0===v){const t=3&e.textRenderingMode;1!==t&&2!==t||(v=this.getSinglePixelWidth())}else v/=b;if(1!==s&&(r.scale(s,s),v/=s),r.lineWidth=v,n.isInvalidPDFjsFont){const n=[];let i=0;for(const e of t)n.push(e.unicode),i+=e.width;return r.fillText(n.join(""),0,0),e.x+=i*f*c,r.restore(),void this.compose()}let y,_=0;for(y=0;y0){const t=1e3*r.measureText(v).width/i*s;if(xnew ur(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Qi(t,n,this.ctx,r,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,n){this.ctx.strokeStyle=this.current.strokeColor=qn.makeHexColor(t,e,n)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,n){this.ctx.fillStyle=this.current.fillColor=qn.makeHexColor(t,e,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let n;return this.cachedPatterns.has(t)?n=this.cachedPatterns.get(t):(n=function(t){switch(t[0]){case"RadialAxial":return new Wi(t);case"Mesh":return new Ki(t);case"Dummy":return new Yi}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,n)),e&&(n.matrix=e),n}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,oi(e),Ui);const i=oi(e);if(i){const{width:t,height:n}=e.canvas,[r,s,a,o]=qn.getAxialAlignedBoundingBox([0,0,t,n],i);this.ctx.fillRect(r,s,a-r,o-s)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){An("Should not call beginInlineImage")}beginImageData(){An("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=ai(this.ctx),e)){const t=e[2]-e[0],n=e[3]-e[1];this.ctx.rect(e[0],e[1],t,n),this.current.updateRectMinMax(ai(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||_n("TODO: Support non-isolated groups."),t.knockout&&wn("Knockout groups not supported.");const n=ai(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=qn.getAxialAlignedBoundingBox(t.bbox,ai(e));const r=[0,0,e.canvas.width,e.canvas.height];i=qn.intersect(i,r)||[0,0,0,0];const s=Math.floor(i[0]),a=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-s,1),l=Math.max(Math.ceil(i[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let c="groupAt"+this.groupLevel;t.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,o,l),h=d.context;h.translate(-s,-a),h.transform(...n),t.smask?this.smaskStack.push({canvas:d.canvas,context:h,offsetX:s,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(s,a),e.save()),sr(e,h),this.ctx=h,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=ai(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const n=qn.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,n,i,r){if(this.#Oe(),ar(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const i=e[2]-e[0],s=e[3]-e[1];if(r&&this.annotationCanvasMap){(n=n.slice())[4]-=e[0],n[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=i,e[3]=s;const[r,a]=qn.singularValueDecompose2dScale(ai(this.ctx)),{viewportScale:o}=this,l=Math.ceil(i*this.outputScaleX*o),c=Math.ceil(s*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,c);const{canvas:d,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(r,0,0,-a,0,s*a),ar(this.ctx)}else ar(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],i,s),this.ctx.clip(),this.ctx.beginPath()}this.current=new nr(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Ne(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const n=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(t){const{width:e,height:n}=t;if(e>1e3||n>1e3)return null;const i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),r=e+1;let s,a,o,l=new Uint8Array(r*(n+1));const c=e+7&-8;let d=new Uint8Array(c*n),h=0;for(const e of t.data){let t=128;for(;t>0;)d[h++]=e&t?0:255,t>>=1}let u=0;for(h=0,0!==d[h]&&(l[0]=1,++u),a=1;a>2)+(d[h+1]?4:0)+(d[h-c+1]?8:0),i[t]&&(l[o+a]=i[t],++u),h++;if(d[h-c]!==d[h]&&(l[o+a]=d[h]?2:4,++u),u>1e3)return null}for(h=c*(n-1),o=s*r,0!==d[h]&&(l[o]=8,++u),a=1;a1e3)return null;const p=new Int32Array([0,r,-1,0,-r,0,0,0,1]),f=new Path2D;for(s=0;u&&s<=n;s++){let t=s*r;const n=t+e;for(;t>4,l[t]&=a>>2|a<<2),f.lineTo(t%r,t/r|0),l[t]||--u}while(i!==t);--s}return d=null,l=null,function(t){t.save(),t.scale(1/e,-1/n),t.translate(0,-n),t.fill(f),t.beginPath(),t.restore()}}(t)),i.compiled))return void i.compiled(n);const r=this._createMaskCanvas(t),s=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(s,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,n=0,i=0,r,s){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=ai(a);a.transform(e,n,i,r,0,0);const l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,c=s.length;te?c/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=s,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:n}=this.current,[i,r]=this.getScaleForStroking();if(e.lineWidth=n||1,1===i&&1===r)return void e.stroke();const s=e.getLineDash();if(t&&e.save(),e.scale(i,r),s.length>0){const t=Math.max(i,r);e.setLineDash(s.map((e=>e/t))),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in gn)void 0!==ur.prototype[t]&&(ur.prototype[gn[t]]=ur.prototype[t]);class pr{static#Be=null;static#qe="";static get workerPort(){return this.#Be}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Be=t}static get workerSrc(){return this.#qe}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#qe=t}}function fr(t){switch(t instanceof Error||"object"==typeof t&&null!==t||An('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Rn(t.message);case"MissingPDFException":return new In(t.message);case"PasswordException":return new Cn(t.message,t.code);case"UnexpectedResponseException":return new Ln(t.message,t.status);case"UnknownErrorException":return new kn(t.message,t.details);default:return new kn(t.message,t.toString())}}class gr{#He=new AbortController;constructor(t,e,n){this.sourceName=t,this.targetName=e,this.comObj=n,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),n.addEventListener("message",this.#je.bind(this),{signal:this.#He.signal})}#je({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ze(t);if(t.callback){const e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)n.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");n.reject(fr(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const n=this.sourceName,i=t.sourceName,r=this.comObj;new Promise((function(n){n(e(t.data))})).then((function(e){r.postMessage({sourceName:n,targetName:i,callback:1,callbackId:t.callbackId,data:e})}),(function(e){r.postMessage({sourceName:n,targetName:i,callback:2,callbackId:t.callbackId,reason:fr(e)})}))}else t.streamId?this.#Ue(t):e(t.data)}on(t,e){const n=this.actionHandler;if(n[t])throw new Error(`There is already an actionName called "${t}"`);n[t]=e}send(t,e,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},n)}sendWithPromise(t,e,n){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},n)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,n,i){const r=this.streamId++,s=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:n=>{const l=Promise.withResolvers();return this.streamControllers[r]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:s,targetName:a,action:t,streamId:r,data:e,desiredSize:n.desiredSize},i),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[r].pullCall=e,o.postMessage({sourceName:s,targetName:a,stream:6,streamId:r,desiredSize:t.desiredSize}),e.promise},cancel:t=>{xn(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[r].cancelCall=e,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:s,targetName:a,stream:1,streamId:r,reason:fr(t)}),e.promise}},n)}#Ue(t){const e=t.streamId,n=this.sourceName,i=t.sourceName,r=this.comObj,s=this,a=this.actionHandler[t.action],o={enqueue(t,s=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=s,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:i,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:3,streamId:e}),delete s.streamSinks[e])},error(t){xn(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:5,streamId:e,reason:fr(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise((function(e){e(a(t.data,o))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:e,success:!0})}),(function(t){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:e,reason:fr(t)})}))}#ze(t){const e=t.streamId,n=this.sourceName,i=t.sourceName,r=this.comObj,s=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?s.startCall.resolve():s.startCall.reject(fr(t.reason));break;case 7:t.success?s.pullCall.resolve():s.pullCall.reject(fr(t.reason));break;case 6:if(!a){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,new Promise((function(t){t(a.onPull?.())})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:e,success:!0})}),(function(t){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:e,reason:fr(t)})}));break;case 4:if(xn(s,"enqueue should have stream controller"),s.isClosed)break;s.controller.enqueue(t.chunk);break;case 3:if(xn(s,"close should have stream controller"),s.isClosed)break;s.isClosed=!0,s.controller.close(),this.#Ve(s,e);break;case 5:xn(s,"error should have stream controller"),s.controller.error(fr(t.reason)),this.#Ve(s,e);break;case 2:t.success?s.cancelCall.resolve():s.cancelCall.reject(fr(t.reason)),this.#Ve(s,e);break;case 1:if(!a)break;new Promise((function(e){e(a.onCancel?.(fr(t.reason)))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:e,success:!0})}),(function(t){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:e,reason:fr(t)})})),a.sinkCapability.reject(fr(t.reason)),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#Ve(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#He?.abort(),this.#He=null}}class mr{#Ge;#We;constructor({parsedData:t,rawData:e}){this.#Ge=t,this.#We=e}getRaw(){return this.#We}get(t){return this.#Ge.get(t)??null}getAll(){return On(this.#Ge)}has(t){return this.#Ge.has(t)}}const vr=Symbol("INTERNAL");class br{#$e=!1;#Xe=!1;#Ke=!1;#Ye=!0;constructor(t,{name:e,intent:n,usage:i,rbGroups:r}){this.#$e=!!(2&t),this.#Xe=!!(4&t),this.name=e,this.intent=n,this.usage=i,this.rbGroups=r}get visible(){if(this.#Ke)return this.#Ye;if(!this.#Ye)return!1;const{print:t,view:e}=this.usage;return this.#$e?"OFF"!==e?.viewState:!this.#Xe||"OFF"!==t?.printState}_setVisible(t,e,n=!1){t!==vr&&An("Internal method `_setVisible` called."),this.#Ke=n,this.#Ye=e}}class yr{#Qe=null;#Je=new Map;#Ze=null;#tn=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#tn=t.order;for(const n of t.groups)this.#Je.set(n.id,new br(e,n));if("OFF"===t.baseState)for(const t of this.#Je.values())t._setVisible(vr,!1);for(const e of t.on)this.#Je.get(e)._setVisible(vr,!0);for(const e of t.off)this.#Je.get(e)._setVisible(vr,!1);this.#Ze=this.getHash()}}#en(t){const e=t.length;if(e<2)return!0;const n=t[0];for(let i=1;i0?On(this.#Je):null}getGroup(t){return this.#Je.get(t)||null}getHash(){if(null!==this.#Qe)return this.#Qe;const t=new Si;for(const[e,n]of this.#Je)t.update(`${e}:${n.visible}`);return this.#Qe=t.hexdigest()}}class _r{constructor(t,{disableRange:e=!1,disableStream:n=!1}){xn(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:r,progressiveDone:s,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=a,r?.length>0){const t=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const n=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):xn(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){xn(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new wr(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=new Ar(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class wr{constructor(t,e,n=!1,i=null){this._stream=t,this._done=n||!1,this._filename=Yn(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Ar{constructor(t,e,n){this._stream=t,this._begin=e,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function xr(t,e){const n=new Headers;if(!t||!e||"object"!=typeof e)return n;for(const t in e){const i=e[t];void 0!==i&&n.append(t,i)}return n}function Er({responseHeaders:t,isHttp:e,rangeChunkSize:n,disableRange:i}){const r={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(t.get("Content-Length"),10);return Number.isInteger(s)?(r.suggestedLength=s,s<=2*n||i||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r):r}function Sr(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,n=i("filename\\*","i").exec(t);if(n){n=n[1];let t=a(n);return t=unescape(t),t=o(t),t=l(t),s(t)}if(n=function(t){const e=[];let n;const r=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(n=r.exec(t));){let[,t,i,r]=n;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[i,r]}const s=[];for(let t=0;t{if(!Cr(e.status))throw Tr(e.status,i);this._reader=e.body.getReader(),this._headersCapability.resolve();const n=e.headers,{allowRangeRequests:r,suggestedLength:s}=Er({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=s||this._contentLength,this._filename=Sr(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Rn("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Mr(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Pr{constructor(t,e,n){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${n-1}`);const s=i.url;fetch(s,kr(r,this._withCredentials,this._abortController)).then((t=>{if(!Cr(t.status))throw Tr(t.status,s);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Mr(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Rr{constructor({url:t,httpHeaders:e,withCredentials:n}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=xr(this.isHttp,e),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,n){const i={begin:t,end:e};for(const t in n)i[t]=n[t];return this.request(i)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,n=this.currXhrId++,i=this.pendingRequests[n]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,n]of this.headers)e.setRequestHeader(t,n);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=206):i.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,n),e.onprogress=this.onProgress.bind(this,n),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),n}onProgress(t,e){const n=this.pendingRequests[t];n&&n.onProgress?.(e)}onStateChange(t,e){const n=this.pendingRequests[t];if(!n)return;const i=n.xhr;if(i.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==i.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===i.status&&this.isHttp)return void n.onError?.(i.status);const r=i.status||200;if((200!==r||206!==n.expectedStatus)&&r!==n.expectedStatus)return void n.onError?.(i.status);const s=function(t){const e=t.response;return"string"!=typeof e?e:Fn(e).buffer}(i);if(206===r){const t=i.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);n.onDone({begin:parseInt(e[1],10),chunk:s})}else s?n.onDone({begin:0,chunk:s}):n.onError?.(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Dr{constructor(t){this._source=t,this._manager=new Rr(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return xn(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Fr(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const n=new Or(this._manager,t,e);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Fr{constructor(t,e){this._manager=t;const n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(n),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),n=new Headers(e.getAllResponseHeaders().trim().split(/[\r\n]+/).map((t=>{const[e,...n]=t.split(": ");return[e,n.join(": ")]}))),{allowRangeRequests:i,suggestedLength:r}=Er({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Sr(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Tr(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.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._headersCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Or{constructor(t,e,n){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,n,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Tr(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Nr=/^[a-z][a-z0-9\-+.]+:/i;function Br(t,e,n){return"http:"===t.protocol?qi.get("http").request(t,{headers:e},n):qi.get("https").request(t,{headers:e},n)}class qr{constructor(t){this.source=t,this.url=function(t){if(Nr.test(t))return new URL(t);const e=qi.get("url");return new URL(e.pathToFileURL(t))}(t.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.headers=xr(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return xn(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Vr(this):new zr(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const n=this.isFsUrl?new Gr(this,t,e):new Ur(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Hr{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Rn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class jr{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}class zr extends Hr{constructor(t){super(t);const e=Object.fromEntries(t.headers);this._request=Br(this._url,e,(e=>{if(404===e.statusCode){const t=new In(`Missing PDF "${this._url}".`);return this._storedError=t,void this._headersCapability.reject(t)}this._headersCapability.resolve(),this._setReadableStream(e);const n=new Headers(this._readableStream.headers),{allowRangeRequests:i,suggestedLength:r}=Er({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=r||this._contentLength,this._filename=Sr(n)})),this._request.on("error",(t=>{this._storedError=t,this._headersCapability.reject(t)})),this._request.end()}}class Ur extends jr{constructor(t,e,n){super(t);const i=Object.fromEntries(t.headers);i.Range=`bytes=${e}-${n-1}`,this._request=Br(this._url,i,(t=>{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new In(`Missing PDF "${this._url}".`);this._storedError=t}})),this._request.on("error",(t=>{this._storedError=t})),this._request.end()}}class Vr extends Hr{constructor(t){super(t);const e=qi.get("fs");e.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(e.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new In(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)}))}}class Gr extends jr{constructor(t,e,n){super(t);const i=qi.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:n-1}))}}const Wr=30;class $r{#nn=Promise.withResolvers();#ut=null;#in=!1;#rn=!!globalThis.FontInspector?.enabled;#sn=null;#an=null;#on=0;#ln=0;#cn=null;#dn=null;#hn=0;#un=0;#pn=Object.create(null);#fn=[];#gn=null;#mn=[];#vn=new WeakMap;#bn=null;static#yn=new Map;static#_n=new Map;static#wn=new WeakMap;static#An=null;static#xn=new Set;constructor({textContentSource:t,container:e,viewport:n}){if(t instanceof ReadableStream)this.#gn=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#gn=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#ut=this.#dn=e,this.#un=n.scale*(globalThis.devicePixelRatio||1),this.#hn=n.rotation,this.#an={div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:r,pageX:s,pageY:a}=n.rawDims;this.#bn=[1,0,0,-1,-s,a+r],this.#ln=i,this.#on=r,$r.#En(),li(e,n),this.#nn.promise.finally((()=>{$r.#xn.delete(this),this.#an=null,this.#pn=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Nn.platform;return Sn(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#cn.read().then((({value:e,done:n})=>{n?this.#nn.resolve():(this.#sn??=e.lang,Object.assign(this.#pn,e.styles),this.#Sn(e.items),t())}),this.#nn.reject)};return this.#cn=this.#gn.getReader(),$r.#xn.add(this),t(),this.#nn.promise}update({viewport:t,onBefore:e=null}){const n=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#hn&&(e?.(),this.#hn=i,li(this.#dn,{rotation:i})),n!==this.#un){e?.(),this.#un=n;const t={div:null,properties:null,ctx:$r.#Tn(this.#sn)};for(const e of this.#mn)t.properties=this.#vn.get(e),t.div=e,this.#Cn(t)}}cancel(){const t=new Rn("TextLayer task cancelled.");this.#cn?.cancel(t).catch((()=>{})),this.#cn=null,this.#nn.reject(t)}get textDivs(){return this.#mn}get textContentItemsStr(){return this.#fn}#Sn(t){if(this.#in)return;this.#an.ctx??=$r.#Tn(this.#sn);const e=this.#mn,n=this.#fn;for(const i of t){if(e.length>1e5)return wn("Ignoring additional textDivs for performance reasons."),void(this.#in=!0);if(void 0!==i.str)n.push(i.str),this.#kn(i);else if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){const t=this.#ut;this.#ut=document.createElement("span"),this.#ut.classList.add("markedContent"),null!==i.id&&this.#ut.setAttribute("id",`${i.id}`),t.append(this.#ut)}else"endMarkedContent"===i.type&&(this.#ut=this.#ut.parentNode)}}#kn(t){const e=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#mn.push(e);const i=qn.transform(this.#bn,t.transform);let r=Math.atan2(i[1],i[0]);const s=this.#pn[t.fontName];s.vertical&&(r+=Math.PI/2);let a=this.#rn&&s.fontSubstitution||s.fontFamily;a=$r.fontFamilyMap.get(a)||a;const o=Math.hypot(i[2],i[3]),l=o*$r.#Mn(a,this.#sn);let c,d;0===r?(c=i[4],d=i[5]-l):(c=i[4]+l*Math.sin(r),d=i[5]-l*Math.cos(r));const h="calc(var(--scale-factor)*",u=e.style;this.#ut===this.#dn?(u.left=`${(100*c/this.#ln).toFixed(2)}%`,u.top=`${(100*d/this.#on).toFixed(2)}%`):(u.left=`${h}${c.toFixed(2)}px)`,u.top=`${h}${d.toFixed(2)}px)`),u.fontSize=`${h}${($r.#An*o).toFixed(2)}px)`,u.fontFamily=a,n.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#rn&&(e.dataset.fontName=s.fontSubstitutionLoadedName||t.fontName),0!==r&&(n.angle=r*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(p=!0)}if(p&&(n.canvasWidth=s.vertical?t.height:t.width),this.#vn.set(e,n),this.#an.div=e,this.#an.properties=n,this.#Cn(this.#an),n.hasText&&this.#ut.append(e),n.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#ut.append(t)}}#Cn(t){const{div:e,properties:n,ctx:i}=t,{style:r}=e;let s="";if($r.#An>1&&(s=`scale(${1/$r.#An})`),0!==n.canvasWidth&&n.hasText){const{fontFamily:t}=r,{canvasWidth:a,fontSize:o}=n;$r.#In(i,o*this.#un,t);const{width:l}=i.measureText(e.textContent);l>0&&(s=`scaleX(${a*this.#un/l}) ${s}`)}0!==n.angle&&(s=`rotate(${n.angle}deg) ${s}`),s.length>0&&(r.transform=s)}static cleanup(){if(!(this.#xn.size>0)){this.#yn.clear();for(const{canvas:t}of this.#_n.values())t.remove();this.#_n.clear()}}static#Tn(t=null){let e=this.#_n.get(t||="");if(!e){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),e=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#_n.set(t,e),this.#wn.set(e,{size:0,family:""})}return e}static#In(t,e,n){const i=this.#wn.get(t);e===i.size&&n===i.family||(t.font=`${e}px ${n}`,i.size=e,i.family=n)}static#En(){if(null!==this.#An)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#An=t.getBoundingClientRect().height,t.remove()}static#Mn(t,e){const n=this.#yn.get(t);if(n)return n;const i=this.#Tn(e);i.canvas.width=i.canvas.height=Wr,this.#In(i,Wr,t);const r=i.measureText("");let s=r.fontBoundingBoxAscent,a=Math.abs(r.fontBoundingBoxDescent);if(s){const e=s/(s+a);return this.#yn.set(t,e),i.canvas.width=i.canvas.height=0,e}i.strokeStyle="red",i.clearRect(0,0,Wr,Wr),i.strokeText("g",0,0);let o=i.getImageData(0,0,Wr,Wr).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/Wr);break}i.clearRect(0,0,Wr,Wr),i.strokeText("A",0,Wr),o=i.getImageData(0,0,Wr,Wr).data,s=0;for(let t=0,e=o.length;t0){s=Wr-Math.floor(t/4/Wr);break}i.canvas.width=i.canvas.height=0;const l=s?s/(s+a):.8;return this.#yn.set(t,l),l}}class Xr{static textContent(t){const e=[],n={items:e,styles:Object.create(null)};return function t(n){if(!n)return;let i=null;const r=n.name;if("#text"===r)i=n.value;else{if(!Xr.shouldBuildText(r))return;n?.attributes?.textContent?i=n.attributes.textContent:n.value&&(i=n.value)}if(null!==i&&e.push({str:i}),n.children)for(const e of n.children)t(e)}(t),n}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const Kr=65536,Yr=sn?class extends Li{_createCanvas(t,e){return qi.get("canvas").createCanvas(t,e)}}:class extends Li{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const n=this._document.createElement("canvas");return n.width=t,n.height=e,n}},Qr=sn?class extends Pi{async _fetch(t){return Hi(t)}}:Ri,Jr=sn?class extends Di{}:class extends Di{#Ln;#Pn;#Rn;#Dn;#Fn;#On;#y=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#Dn=t,this.#Fn=e}get#w(){return this.#Pn||=new Map}get#Nn(){return this.#On||=new Map}get#Bn(){if(!this.#Rn){const t=this.#Fn.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const n=this.#Fn.createElementNS(Vn,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#Rn=this.#Fn.createElementNS(Vn,"defs"),t.append(n),n.append(this.#Rn),this.#Fn.body.append(t)}return this.#Rn}#qn(t){if(1===t.length){const e=t[0],n=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255;const i=n.join(",");return[i,i,i]}const[e,n,i]=t,r=new Array(256),s=new Array(256),a=new Array(256);for(let t=0;t<256;t++)r[t]=e[t]/255,s[t]=n[t]/255,a[t]=i[t]/255;return[r.join(","),s.join(","),a.join(",")]}#Hn(t){if(void 0===this.#Ln){this.#Ln="";const t=this.#Fn.URL;t!==this.#Fn.baseURI&&(Kn(t)?wn('#createUrl: ignore "data:"-URL for performance reasons.'):this.#Ln=t.split("#",1)[0])}return`url(${this.#Ln}#${t})`}addFilter(t){if(!t)return"none";let e=this.#w.get(t);if(e)return e;const[n,i,r]=this.#qn(t),s=1===t.length?n:`${n}${i}${r}`;if(e=this.#w.get(s),e)return this.#w.set(t,e),e;const a=`g_${this.#Dn}_transfer_map_${this.#y++}`,o=this.#Hn(a);this.#w.set(t,o),this.#w.set(s,o);const l=this.#jn(a);return this.#zn(n,i,r,l),o}addHCMFilter(t,e){const n=`${t}-${e}`,i="base";let r=this.#Nn.get(i);if(r?.key===n)return r.url;if(r?(r.filter?.remove(),r.key=n,r.url="none",r.filter=null):(r={key:n,url:"none",filter:null},this.#Nn.set(i,r)),!t||!e)return r.url;const s=this.#Un(t);t=qn.makeHexColor(...s);const a=this.#Un(e);if(e=qn.makeHexColor(...a),this.#Bn.style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),c=`g_${this.#Dn}_hcm_filter`,d=r.filter=this.#jn(c);this.#zn(l,l,l,d),this.#Vn(d);const h=(t,e)=>{const n=s[t]/255,i=a[t]/255,r=new Array(e+1);for(let t=0;t<=e;t++)r[t]=n+t/e*(i-n);return r.join(",")};return this.#zn(h(0,5),h(1,5),h(2,5),d),r.url=this.#Hn(c),r.url}addAlphaFilter(t){let e=this.#w.get(t);if(e)return e;const[n]=this.#qn([t]),i=`alpha_${n}`;if(e=this.#w.get(i),e)return this.#w.set(t,e),e;const r=`g_${this.#Dn}_alpha_map_${this.#y++}`,s=this.#Hn(r);this.#w.set(t,s),this.#w.set(i,s);const a=this.#jn(r);return this.#Gn(n,a),s}addLuminosityFilter(t){let e,n,i=this.#w.get(t||"luminosity");if(i)return i;if(t?([e]=this.#qn([t]),n=`luminosity_${e}`):n="luminosity",i=this.#w.get(n),i)return this.#w.set(t,i),i;const r=`g_${this.#Dn}_luminosity_map_${this.#y++}`,s=this.#Hn(r);this.#w.set(t,s),this.#w.set(n,s);const a=this.#jn(r);return this.#Wn(a),t&&this.#Gn(e,a),s}addHighlightHCMFilter(t,e,n,i,r){const s=`${e}-${n}-${i}-${r}`;let a=this.#Nn.get(t);if(a?.key===s)return a.url;if(a?(a.filter?.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},this.#Nn.set(t,a)),!e||!n)return a.url;const[o,l]=[e,n].map(this.#Un.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[h,u]=[i,r].map(this.#Un.bind(this));d{const i=new Array(256),r=(d-c)/n,s=t/255,a=(e-t)/(255*n);let o=0;for(let t=0;t<=n;t++){const e=Math.round(c+t*r),n=s+t*a;for(let t=o;t<=e;t++)i[t]=n;o=e+1}for(let t=o;t<256;t++)i[t]=i[o-1];return i.join(",")},f=`g_${this.#Dn}_hcm_${t}_filter`,g=a.filter=this.#jn(f);return this.#Vn(g),this.#zn(p(h[0],u[0],5),p(h[1],u[1],5),p(h[2],u[2],5),g),a.url=this.#Hn(f),a.url}destroy(t=!1){t&&0!==this.#Nn.size||(this.#Rn&&(this.#Rn.parentNode.parentNode.remove(),this.#Rn=null),this.#Pn&&(this.#Pn.clear(),this.#Pn=null),this.#y=0)}#Wn(t){const e=this.#Fn.createElementNS(Vn,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#Vn(t){const e=this.#Fn.createElementNS(Vn,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#jn(t){const e=this.#Fn.createElementNS(Vn,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#Bn.append(e),e}#$n(t,e,n){const i=this.#Fn.createElementNS(Vn,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",n),t.append(i)}#zn(t,e,n,i){const r=this.#Fn.createElementNS(Vn,"feComponentTransfer");i.append(r),this.#$n(r,"feFuncR",t),this.#$n(r,"feFuncG",e),this.#$n(r,"feFuncB",n)}#Gn(t,e){const n=this.#Fn.createElementNS(Vn,"feComponentTransfer");e.append(n),this.#$n(n,"feFuncA",t)}#Un(t){return this.#Bn.style.color=t,si(getComputedStyle(this.#Bn).getPropertyValue("color"))}},Zr=sn?class extends Fi{async _fetch(t){return Hi(t)}}:Oi;function ts(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new ns,{docId:n}=e,i=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(sn&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,r=t.data?function(t){if(sn&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Fn(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,s=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof is?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:Kr;let d=t.worker instanceof os?t.worker:null;const h=t.verbosity,u="string"!=typeof t.docBaseUrl||Kn(t.docBaseUrl)?null:t.docBaseUrl,p="string"==typeof t.cMapUrl?t.cMapUrl:null,f=!1!==t.cMapPacked,g=t.CMapReaderFactory||Qr,m="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,v=t.StandardFontDataFactory||Zr,b=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,_=!1!==t.isEvalSupported,w="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!sn,A="boolean"==typeof t.isChrome?t.isChrome:!Nn.platform.isFirefox&&"undefined"!=typeof window&&!!window?.chrome,x=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,E="boolean"==typeof t.disableFontFace?t.disableFontFace:sn,S=!0===t.fontExtraProperties,T=!0===t.enableXfa,C=t.ownerDocument||globalThis.document,k=!0===t.disableRange,M=!0===t.disableStream,I=!0===t.disableAutoFetch,L=!0===t.pdfBug,P=t.CanvasFactory||Yr,R=t.FilterFactory||Jr,D=!0===t.enableHWA,F=l?l.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!sn&&!E,N="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:g===Ri&&v===Oi&&p&&m&&ti(p,document.baseURI)&&ti(m,document.baseURI);t.canvasFactory&&ni("`canvasFactory`-instance option, please use `CanvasFactory` instead."),t.filterFactory&&ni("`filterFactory`-instance option, please use `FilterFactory` instead."),bn(h);const B={canvasFactory:new P({ownerDocument:C,enableHWA:D}),filterFactory:new R({docId:n,ownerDocument:C}),cMapReaderFactory:N?null:new g({baseUrl:p,isCompressed:f}),standardFontDataFactory:N?null:new v({baseUrl:m})};if(!d){const t={verbosity:h,port:pr.workerPort};d=t.port?os.fromPort(t):new os(t),e._worker=d}const q={docId:n,apiVersion:"4.8.69",data:r,password:o,disableAutoFetch:I,rangeChunkSize:c,length:F,docBaseUrl:u,enableXfa:T,evaluatorOptions:{maxImageSize:y,disableFontFace:E,ignoreErrors:b,isEvalSupported:_,isOffscreenCanvasSupported:w,isChrome:A,canvasMaxAreaInBytes:x,fontExtraProperties:S,useSystemFonts:O,cMapUrl:N?p:null,standardFontDataUrl:N?m:null}},H={disableFontFace:E,fontExtraProperties:S,ownerDocument:C,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:T}};return d.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const t=d.messageHandler.sendWithPromise("GetDocRequest",q,r?[r.buffer]:null);let o;if(l)o=new _r(l,{disableRange:k,disableStream:M});else if(!r){if(!i)throw new Error("getDocument - no `url` parameter provided.");let t;t=sn?"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&ti(i)?Ir:qr:ti(i)?Ir:Dr,o=new t({url:i,length:F,httpHeaders:s,withCredentials:a,rangeChunkSize:c,disableRange:k,disableStream:M})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const i=new gr(n,t,d.port),r=new ls(i,e,o,H,B);e._transport=r,i.send("Ready",null)}))})).catch(e._capability.reject),e}function es(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class ns{static#Dn=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+ns.#Dn++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class is{constructor(t,e,n=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=n,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const n of this._rangeListeners)n(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const n of this._progressListeners)n(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){An("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class rs{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Sn(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class ss{#Xn=null;#Kn=!1;constructor(t,e,n,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=i?new Zn:null,this._pdfBug=i,this.commonObjs=n.commonObjs,this.objs=new ds,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:n=0,offsetY:i=0,dontFlip:r=!1}={}){return new $n({viewBox:this.view,scale:t,rotation:e,offsetX:n,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Sn(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:n="display",annotationMode:i=cn.ENABLE,transform:r=null,background:s=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:c=null,isEditing:d=!1}){this._stats?.time("Overall");const h=this._transport.getRenderingIntent(n,i,c,d),{renderingIntent:u,cacheKey:p}=h;this.#Kn=!1,this.#Yn(),a||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(p);f||(f=Object.create(null),this._intentStates.set(p,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const g=!!(4&u);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(h));const m=t=>{f.renderTasks.delete(v),(this._maybeCleanupAfterRender||g)&&(this.#Kn=!0),this.#Qn(!g),t?(v.capability.reject(t),this._abortOperatorList({intentState:f,reason:t instanceof Error?t:new Error(t)})):v.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},v=new us({callback:m,params:{canvasContext:t,viewport:e,transform:r,background:s},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:l});(f.renderTasks||=new Set).add(v);const b=v.task;return Promise.all([f.displayReadyCapability.promise,a]).then((([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");v.initializeGraphics({transparency:t,optionalContentConfig:e}),v.operatorListChanged()}})).catch(m),b}getOperatorList({intent:t="display",annotationMode:e=cn.ENABLE,printAnnotationStorage:n=null,isEditing:i=!1}={}){const r=this._transport.getRenderingIntent(t,e,n,i,!0);let s,a=this._intentStates.get(r.cacheKey);return a||(a=Object.create(null),this._intentStates.set(r.cacheKey,a)),a.opListReadCapability||(s=Object.create(null),s.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(s))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(s),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>Xr.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,n){const i=e.getReader(),r={items:[],styles:Object.create(null),lang:null};!function e(){i.read().then((function({value:n,done:i}){i?t(r):(r.lang??=n.lang,Object.assign(r.styles,n.styles),r.items.push(...n.items),e())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const n of e.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),this.#Kn=!1,this.#Yn(),Promise.all(t)}cleanup(t=!1){this.#Kn=!0;const e=this.#Qn(!1);return t&&e&&(this._stats&&=new Zn),e}#Qn(t=!1){if(this.#Yn(),!this.#Kn||this.destroyed)return!1;if(t)return this.#Xn=setTimeout((()=>{this.#Xn=null,this.#Qn(!1)}),5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#Kn=!1,!0}#Yn(){this.#Xn&&(clearTimeout(this.#Xn),this.#Xn=null)}_startRenderPage(t,e){const n=this._intentStates.get(e);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let n=0,i=t.length;n{a.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#Qn(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(e instanceof Xn){let n=100;return e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),n))}}if(t.streamReader.cancel(new Rn(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,n]of this._intentStates)if(n===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class as{#Jn=new Map;#Zn=Promise.resolve();postMessage(t,e){const n={data:structuredClone(t,e?{transfer:e}:null)};this.#Zn.then((()=>{for(const[t]of this.#Jn)t.call(this,n)}))}addEventListener(t,e,n=null){let i=null;if(n?.signal instanceof AbortSignal){const{signal:r}=n;if(r.aborted)return void wn("LoopbackPort - cannot use an `aborted` signal.");const s=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",s),r.addEventListener("abort",s)}this.#Jn.set(e,i)}removeEventListener(t,e){const n=this.#Jn.get(e);n?.(),this.#Jn.delete(e)}terminate(){for(const[,t]of this.#Jn)t?.();this.#Jn.clear()}}class os{static#ti=0;static#ei=!1;static#ni;static{sn&&(this.#ei=!0,pr.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let n;try{if(n=new URL(t),!n.origin||"null"===n.origin)return!1}catch{return!1}const i=new URL(e,n);return n.origin===i.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:n=yn()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(os.#ni?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(os.#ni||=new WeakMap).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return sn?Promise.all([qi.promise,this._readyCapability.promise]):this._readyCapability.promise}#ii(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new gr("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#ii()}_initialize(){if(os.#ei||os.#ri)return void this._setupFakeWorker();let{workerSrc:t}=os;try{os._isSameOrigin(window.location.href,t)||(t=os._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),n=new gr("main","worker",e),i=()=>{r.abort(),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;e.addEventListener("error",(()=>{this._webWorker||i()}),{signal:r.signal}),n.on("test",(t=>{r.abort(),!this.destroyed&&t?(this._messageHandler=n,this._port=e,this._webWorker=e,this.#ii()):i()})),n.on("ready",(t=>{if(r.abort(),this.destroyed)i();else try{s()}catch{this._setupFakeWorker()}}));const s=()=>{const t=new Uint8Array;n.send("test",t,[t.buffer])};return void s()}catch{_n("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){os.#ei||(wn("Setting up fake worker."),os.#ei=!0),os._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new as;this._port=e;const n="fake"+os.#ti++,i=new gr(n+"_worker",n,e);t.setup(i,e),this._messageHandler=new gr(n,n+"_worker",e),this.#ii()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),os.#ni?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#ni?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new os(t)}static get workerSrc(){if(pr.workerSrc)return pr.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#ri(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Sn(this,"_setupFakeWorkerGlobal",(async()=>this.#ri?this.#ri:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ls{#si=new Map;#ai=new Map;#oi=new Map;#li=new Map;#ci=null;constructor(t,e,n,i,r){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ds,this.fontLoader=new Mi({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#di(t,e=null){const n=this.#si.get(t);if(n)return n;const i=this.messageHandler.sendWithPromise(t,e);return this.#si.set(t,i),i}get annotationStorage(){return Sn(this,"annotationStorage",new Ci)}getRenderingIntent(t,e=cn.ENABLE,n=null,i=!1,r=!1){let s=2,a=Ti;switch(t){case"any":s=1;break;case"display":break;case"print":s=4;break;default:wn(`getRenderingIntent - invalid intent: ${t}`)}const o=4&s&&n instanceof ki?n:this.annotationStorage;switch(e){case cn.DISABLE:s+=64;break;case cn.ENABLE:break;case cn.ENABLE_FORMS:s+=16;break;case cn.ENABLE_STORAGE:s+=32,a=o.serializable;break;default:wn(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(s+=128),r&&(s+=256);const{ids:l,hash:c}=o.modifiedIds;return{renderingIntent:s,cacheKey:[s,a.hash,c].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#ci?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#ai.values())t.push(e._destroy());this.#ai.clear(),this.#oi.clear(),this.#li.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#si.clear(),this.filterFactory.destroy(),$r.cleanup(),this._networkStream?.cancelAllRequests(new Rn("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{xn(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:n}){n?e.close():(xn(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:i,contentLength:r}=this._fullReader;return n&&i||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:n,isRangeSupported:i,contentLength:r}})),t.on("GetRangeReader",((t,e)=>{xn(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(t.begin,t.end);n?(e.onPull=()=>{n.read().then((function({value:t,done:n}){n?e.close():(xn(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{n.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new rs(t,this))})),t.on("DocException",(function(t){let n;switch(t.name){case"PasswordException":n=new Cn(t.message,t.code);break;case"InvalidPDFException":n=new Mn(t.message);break;case"MissingPDFException":n=new In(t.message);break;case"UnexpectedResponseException":n=new Ln(t.message,t.status);break;case"UnknownErrorException":n=new kn(t.message,t.details);break;default:An("DocException - expected a valid Error.")}e._capability.reject(n)})),t.on("PasswordRequest",(t=>{if(this.#ci=Promise.withResolvers(),e.onPassword){const n=t=>{t instanceof Error?this.#ci.reject(t):this.#ci.resolve({password:t})};try{e.onPassword(n,t.code)}catch(t){this.#ci.reject(t)}}else this.#ci.reject(new Cn(t.message,t.code));return this.#ci.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#ai.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,n,i])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(n){case"Font":const{disableFontFace:r,fontExtraProperties:s,pdfBug:a}=this._params;if("error"in i){const t=i.error;wn(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=a&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new Ii(i,{disableFontFace:r,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!s&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:c}=i;xn(c,"The imageRef must be defined.");for(const t of this.#ai.values())for(const[,n]of t.objs)if(n?.ref===c)return n.dataLen?(this.commonObjs.resolve(e,structuredClone(n)),n.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${n}`)}return null})),t.on("obj",(([t,e,n,i])=>{if(this.destroyed)return;const r=this.#ai.get(e);if(!r.objs.has(t))if(0!==r._intentStates.size)switch(n){case"Image":r.objs.resolve(t,i),i?.dataLen>1e7&&(r._maybeCleanupAfterRender=!0);break;case"Pattern":r.objs.resolve(t,i);break;default:throw new Error(`Got unknown object type ${n}`)}else i?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)})),t.on("FetchStandardFontData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&wn("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,n=this.#oi.get(e);if(n)return n;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#li.set(n.refStr,t);const i=new ss(e,n,this,this._params.pdfBug);return this.#ai.set(e,i),i}));return this.#oi.set(e,i),i}getPageIndex(t){return es(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#di("GetFieldObjects")}hasJSActions(){return this.#di("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#di("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#di("GetOptionalContentConfig").then((e=>new yr(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#si.get(t);if(e)return e;const n=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new mr(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#si.set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#ai.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#si.clear(),this.filterFactory.destroy(!0),$r.cleanup()}}cachedPageNumber(t){if(!es(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#li.get(e)??null}}const cs=Symbol("INITIAL_DATA");class ds{#hi=Object.create(null);#ui(t){return this.#hi[t]||={...Promise.withResolvers(),data:cs}}get(t,e=null){if(e){const n=this.#ui(t);return n.promise.then((()=>e(n.data))),null}const n=this.#hi[t];if(!n||n.data===cs)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){const e=this.#hi[t];return!!e&&e.data!==cs}resolve(t,e=null){const n=this.#ui(t);n.data=e,n.resolve()}clear(){for(const t in this.#hi){const{data:e}=this.#hi[t];e?.bitmap?.close()}this.#hi=Object.create(null)}*[Symbol.iterator](){for(const t in this.#hi){const{data:e}=this.#hi[t];e!==cs&&(yield[t,e])}}}class hs{#pi=null;constructor(t){this.#pi=t,this.onContinue=null}get promise(){return this.#pi.capability.promise}cancel(t=0){this.#pi.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#pi.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#pi;return t.form||t.canvas&&e?.size>0}}class us{#fi=null;static#gi=new WeakSet;constructor({callback:t,params:e,objs:n,commonObjs:i,annotationCanvasMap:r,operatorList:s,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:h=null}){this.callback=t,this.params=e,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=h,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new hs(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(us.#gi.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");us.#gi.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:i,transform:r,background:s}=this.params;this.gfx=new ur(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:i,transparency:t,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#fi&&(window.cancelAnimationFrame(this.#fi),this.#fi=null),us.#gi.delete(this._canvas),this.callback(t||new Xn(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#fi=window.requestAnimationFrame((()=>{this.#fi=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),us.#gi.delete(this._canvas),this.callback())))}}const ps="4.8.69",fs="3634dab10";function gs(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ms(t){return Math.max(0,Math.min(255,255*t))}class vs{static CMYK_G([t,e,n,i]){return["G",1-Math.min(1,.3*t+.59*n+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=ms(t),t,t]}static G_HTML([t]){const e=gs(t);return`#${e}${e}${e}`}static RGB_G([t,e,n]){return["G",.3*t+.59*e+.11*n]}static RGB_rgb(t){return t.map(ms)}static RGB_HTML(t){return`#${t.map(gs).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,n,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,n+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,n,i]){return[ms(1-Math.min(1,t+i)),ms(1-Math.min(1,n+i)),ms(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,n]){const i=1-t,r=1-e,s=1-n;return["CMYK",i,r,s,Math.min(i,r,s)]}}class bs{create(t,e,n=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),n||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){An("Abstract method `_createSVG` called.")}}class ys extends bs{_createSVG(t){return document.createElementNS(Vn,t)}}class _s{static setupStorage(t,e,n,i,r){const s=i.getValue(e,{value:null});switch(n.name){case"textarea":if(null!==s.value&&(t.textContent=s.value),"print"===r)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(s.value===n.attributes.xfaOn?t.setAttribute("checked",!0):s.value===n.attributes.xfaOff&&t.removeAttribute("checked"),"print"===r)break;t.addEventListener("change",(t=>{i.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==s.value&&t.setAttribute("value",s.value),"print"===r)break;t.addEventListener("input",(t=>{i.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==s.value){t.setAttribute("value",s.value);for(const t of n.children)t.attributes.value===s.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const n=t.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;i.setValue(e,{value:r})}))}}static setAttributes({html:t,element:e,storage:n=null,intent:i,linkService:r}){const{attributes:s}=e,a=t instanceof HTMLAnchorElement;"radio"===s.type&&(s.name=`${s.name}-${i}`);for(const[e,n]of Object.entries(s))if(null!=n)switch(e){case"class":n.length&&t.setAttribute(e,n.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",n);break;case"style":Object.assign(t.style,n);break;case"textContent":t.textContent=n;break;default:(!a||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,n)}a&&r.addLinkAttributes(t,s.href,s.newWindow),n&&s.dataId&&this.setupStorage(t,s.dataId,e,n)}static render(t){const e=t.annotationStorage,n=t.linkService,i=t.xfaHtml,r=t.intent||"display",s=document.createElement(i.name);i.attributes&&this.setAttributes({html:s,element:i,intent:r,linkService:n});const a="richText"!==r,o=t.div;if(o.append(s),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===i.children.length){if(i.value){const t=document.createTextNode(i.value);s.append(t),a&&Xr.shouldBuildText(i.name)&&l.push(t)}return{textDivs:l}}const c=[[i,-1,s]];for(;c.length>0;){const[t,i,s]=c.at(-1);if(i+1===t.children.length){c.pop();continue}const o=t.children[++c.at(-1)[1]];if(null===o)continue;const{name:d}=o;if("#text"===d){const t=document.createTextNode(o.value);l.push(t),s.append(t);continue}const h=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(s.append(h),o.attributes&&this.setAttributes({html:h,element:o,storage:e,intent:r,linkService:n}),o.children?.length>0)c.push([o,-1,h]);else if(o.value){const t=document.createTextNode(o.value);a&&Xr.shouldBuildText(d)&&l.push(t),h.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const ws=1e3,As=new WeakSet;function xs(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Es{static create(t){switch(t.data.annotationType){case 2:return new Ts(t);case 1:return new Cs(t);case 20:switch(t.data.fieldType){case"Tx":return new Ms(t);case"Btn":return t.data.radioButton?new Ps(t):t.data.checkBox?new Ls(t):new Rs(t);case"Ch":return new Ds(t);case"Sig":return new Is(t)}return new ks(t);case 16:return new Fs(t);case 3:return new Ns(t);case 4:return new Bs(t);case 5:return new qs(t);case 6:return new Hs(t);case 8:return new js(t);case 14:return new Us(t);case 15:return new Vs(t);case 7:return new zs(t);case 9:return new Gs(t);case 10:return new Ws(t);case 11:return new $s(t);case 12:return new Xs(t);case 13:return new Ks(t);case 17:return new Ys(t);default:return new Ss(t)}}}class Ss{#mi=null;#vi=!1;#bi=null;constructor(t,{isRenderable:e=!1,ignoreBorder:n=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(n)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:n}){return!!(t?.str||e?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Ss._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#mi||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#yi(e),this.#bi?.popup.updateEdited(t)}resetEdited(){this.#mi&&(this.#yi(this.#mi.rect),this.#bi?.popup.resetEdited(),this.#mi=null)}#yi(t){const{container:{style:e},data:{rect:n,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:s,pageX:a,pageY:o}}}}=this;n?.splice(0,4,...t);const{width:l,height:c}=xs(t);e.left=100*(t[0]-a)/r+"%",e.top=100*(s-t[3]+o)/s+"%",0===i?(e.width=100*l/r+"%",e.height=100*c/s+"%"):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:n,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),this instanceof ks||(r.tabIndex=ws);const{style:s}=r;if(s.zIndex=this.parent.zIndex++,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof Fs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,r),r}const{width:a,height:o}=xs(e.rect);if(!t&&e.borderStyle.width>0){s.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,n=e.borderStyle.verticalCornerRadius;if(t>0||n>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;s.borderRadius=e}else if(this instanceof Ps){const t=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;s.borderRadius=t}switch(e.borderStyle.style){case 1:s.borderStyle="solid";break;case 2:s.borderStyle="dashed";break;case 3:wn("Unimplemented border style: beveled");break;case 4:wn("Unimplemented border style: inset");break;case 5:s.borderBottomStyle="solid"}const i=e.borderColor||null;i?(this.#vi=!0,s.borderColor=qn.makeHexColor(0|i[0],0|i[1],0|i[2])):s.borderWidth=0}const l=qn.normalizeRect([e.rect[0],n.view[3]-e.rect[1]+n.view[1],e.rect[2],n.view[3]-e.rect[3]+n.view[1]]),{pageWidth:c,pageHeight:d,pageX:h,pageY:u}=i.rawDims;s.left=100*(l[0]-h)/c+"%",s.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(s.width=100*a/c+"%",s.height=100*o/d+"%"):this.setRotation(p,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:i}=this.parent.viewport.rawDims,{width:r,height:s}=xs(this.data.rect);let a,o;t%180==0?(a=100*r/n,o=100*s/i):(a=100*s/n,o=100*r/i),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,n)=>{const i=n.detail[t],r=i[0],s=i.slice(1);n.target.style[e]=vs[`${r}_HTML`](s),this.annotationStorage.setValue(this.data.id,{[e]:vs[`${r}_rgb`](s)})};return Sn(this,"_commonActions",{display:t=>{const{display:e}=t.detail,n=e%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const n=this._commonActions;for(const i of Object.keys(e.detail)){const r=t[i]||n[i];r?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const n=this._commonActions;for(const[i,r]of Object.entries(e)){const s=n[i];s&&(s({detail:{[i]:r},target:t}),delete e[i])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,n,i,r]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[s,a,o,l]=t.subarray(2,6);if(i===s&&r===a&&e===o&&n===l)return}const{style:s}=this.container;let a;if(this.#vi){const{borderColor:t,borderWidth:e}=s;s.borderWidth=0,a=["url('data:image/svg+xml;utf8,",'')"),s.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#bi=new Fs({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){An("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const n=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:t,id:r,exportValues:s}of i){if(-1===t)continue;if(r===e)continue;const i="string"==typeof s?s:null,a=document.querySelector(`[data-element-id="${r}"]`);!a||As.has(a)?n.push({id:r,exportValue:i,domElement:a}):wn(`_getElementsByName - element not allowed: ${r}`)}return n}for(const i of document.getElementsByName(t)){const{exportValue:t}=i,r=i.getAttribute("data-element-id");r!==e&&As.has(i)&&n.push({id:r,exportValue:t,domElement:i})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}class Ts extends Ss{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,n=document.createElement("a");n.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(n,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(n,t.action),i=!0):t.attachment?(this.#_i(n,t.attachment,t.attachmentDest),i=!0):t.setOCGState?(this.#wi(n,t.setOCGState),i=!0):t.dest?(this._bindLink(n,t.dest),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,t),i=!0),t.resetForm?(this._bindResetFormAction(n,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(n,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(n),this.container}#Ai(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Ai()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Ai()}#_i(t,e,n=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,n),!1),this.#Ai()}#wi(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Ai()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const r=n.get(i);r&&(t[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}t.onclick||(t.onclick=()=>!1),this.#Ai()}_bindResetFormAction(t,e){const n=t.onclick;if(n||(t.href=this.linkService.getAnchorUrl("")),this.#Ai(),!this._fieldObjects)return wn('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(t.onclick=()=>!1));t.onclick=()=>{n?.();const{fields:t,refs:i,include:r}=e,s=[];if(0!==t.length||0!==i.length){const e=new Set(i);for(const n of t){const t=this._fieldObjects[n]||[];for(const{id:n}of t)e.add(n)}for(const t of Object.values(this._fieldObjects))for(const n of t)e.has(n.id)===r&&s.push(n)}else for(const t of Object.values(this._fieldObjects))s.push(...t);const a=this.annotationStorage,o=[];for(const t of s){const{id:e}=t;switch(o.push(e),t.type){case"text":{const n=t.defaultValue||"";a.setValue(e,{value:n});break}case"checkbox":case"radiobutton":{const n=t.defaultValue===t.exportValues;a.setValue(e,{value:n});break}case"combobox":case"listbox":{const n=t.defaultValue||"";a.setValue(e,{value:n});break}default:continue}const n=document.querySelector(`[data-element-id="${e}"]`);n&&(As.has(n)?n.dispatchEvent(new Event("resetform")):wn(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class Cs extends Ss{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class ks extends Ss{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Nn.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,n,i,r){n.includes("mouse")?t.addEventListener(n,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(n,(t=>{if("blur"===n){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===n){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(t)}})}))}_setEventListeners(t,e,n,i){for(const[r,s]of n)("Action"===s||this.data.actions?.[s])&&("Focus"!==s&&"Blur"!==s||(e||={focused:!1}),this._setEventListener(t,e,r,s,i),"Focus"!==s||this.data.actions?.Blur?"Blur"!==s||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":qn.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const{fontColor:e}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,i=t.style;let r;const s=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(ln*n))||1);r=Math.min(n,s(e/ln))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(n,s(t/ln))}i.fontSize=`calc(${r}px * var(--scale-factor))`,i.color=qn.makeHexColor(e[0],e[1],e[2]),null!==this.data.textAlignment&&(i.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Ms extends ks{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,n,i){const r=this.annotationStorage;for(const s of this._getElementsByName(t.name,t.id))s.domElement&&(s.domElement[e]=n),r.setValue(s.id,{[i]:n})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let r=i.value||"";const s=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;s&&r.length>s&&(r=r.slice(0,s));let a=i.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:r,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=a??r,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",a??r),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),As.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=ws,this._setRequired(n,this.data.required),s&&(n.maxLength=s),n.addEventListener("input",(i=>{t.setValue(e,{value:i.target.value}),this.setPropertyOnSiblings(n,"value",i.target.value,"value"),o.formattedValue=null})),n.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";n.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),n.addEventListener("updatefromsandbox",(n=>{this.showElementAndHideCanvas(n.target);const i={value(n){o.userValue=n.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),n.target.value=o.userValue},formattedValue(n){const{formattedValue:i}=n.detail;o.formattedValue=i,null!=i&&n.target!==document.activeElement&&(n.target.value=i),t.setValue(e,{formattedValue:i})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:n=>{const{charLimit:i}=n.detail,{target:r}=n;if(0===i)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",i);let s=o.userValue;!s||s.length<=i||(s=s.slice(0,i),r.value=o.userValue=s,t.setValue(e,{value:s}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}};this._dispatchEventFromSandbox(i,n)})),n.addEventListener("keydown",(t=>{o.commitKey=1;let n=-1;if("Escape"===t.key?n=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):n=2,-1===n)return;const{value:i}=t.target;o.lastCommittedValue!==i&&(o.lastCommittedValue=i,o.userValue=i,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const i=l;l=null,n.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:n}=t.target;o.userValue=n,o.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),i(t)})),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:n,target:i}=t,{value:r,selectionStart:s,selectionEnd:a}=i;let l=s,c=a;switch(t.inputType){case"deleteWordBackward":{const t=r.substring(0,s).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=r.substring(s).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":s===a&&(l-=1);break;case"deleteContentForward":s===a&&(c+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:n||"",willCommit:!1,selStart:l,selEnd:c}})})),this._setEventListeners(n,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&n.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/s;n.classList.add("comb"),n.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Is extends ks{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Ls extends ks{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,n=e.id;let i=t.getValue(n,{value:e.exportValue===e.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,t.setValue(n,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return As.add(r),r.setAttribute("data-element-id",n),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=ws,r.addEventListener("change",(i=>{const{name:r,checked:s}=i.target;for(const i of this._getElementsByName(r,n)){const n=s&&i.exportValue===e.exportValue;i.domElement&&(i.domElement.checked=n),t.setValue(i.id,{value:n})}t.setValue(n,{value:s})})),r.addEventListener("resetform",(t=>{const n=e.defaultFieldValue||"Off";t.target.checked=n===e.exportValue})),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",(e=>{const i={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(n,{value:e.target.checked})}};this._dispatchEventFromSandbox(i,e)})),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Ps extends ks{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,n=e.id;let i=t.getValue(n,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof i&&(i=i!==e.buttonValue,t.setValue(n,{value:i})),i)for(const i of this._getElementsByName(e.fieldName,n))t.setValue(i.id,{value:!1});const r=document.createElement("input");if(As.add(r),r.setAttribute("data-element-id",n),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=ws,r.addEventListener("change",(e=>{const{name:i,checked:r}=e.target;for(const e of this._getElementsByName(i,n))t.setValue(e.id,{value:!1});t.setValue(n,{value:r})})),r.addEventListener("resetform",(t=>{const n=e.defaultFieldValue;t.target.checked=null!=n&&n===e.buttonValue})),this.enableScripting&&this.hasJSActions){const i=e.buttonValue;r.addEventListener("updatefromsandbox",(e=>{const r={value:e=>{const r=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=r&&i.id===n;i.domElement&&(i.domElement.checked=e),t.setValue(i.id,{value:e})}}};this._dispatchEventFromSandbox(r,e)})),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Rs extends Ts{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Ds extends ks{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,n=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");As.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=ws;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of i.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,n.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),r=!1),i.append(e)}let s=null;if(r){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),i.prepend(t),s=()=>{t.remove(),i.removeEventListener("input",s),s=null},i.addEventListener("input",s)}const a=t=>{const e=t?"value":"textContent",{options:n,multiple:r}=i;return r?Array.prototype.filter.call(n,(t=>t.selected)).map((t=>t[e])):-1===n.selectedIndex?null:n[n.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",(n=>{const r={value(n){s?.();const r=n.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(const t of i.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){i.multiple=!0},remove(n){const r=i.options,s=n.detail.remove;r[s].selected=!1,i.remove(s),r.length>0&&-1===Array.prototype.findIndex.call(r,(t=>t.selected))&&(r[0].selected=!0),t.setValue(e,{value:a(!0),items:l(n)}),o=a(!1)},clear(n){for(;0!==i.length;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(n){const{index:r,displayValue:s,exportValue:c}=n.detail.insert,d=i.children[r],h=document.createElement("option");h.textContent=s,h.value=c,d?d.before(h):i.append(h),t.setValue(e,{value:a(!0),items:l(n)}),o=a(!1)},items(n){const{items:r}=n.detail;for(;0!==i.length;)i.remove(0);for(const t of r){const{displayValue:e,exportValue:n}=t,r=document.createElement("option");r.textContent=e,r.value=n,i.append(r)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(n)}),o=a(!1)},indices(n){const i=new Set(n.detail.indices);for(const t of n.target.options)t.selected=i.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(r,n)})),i.addEventListener("input",(n=>{const i=a(!0),r=a(!1);t.setValue(e,{value:i}),n.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:r,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):i.addEventListener("input",(function(n){t.setValue(e,{value:a(!0)})})),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Fs extends Ss{constructor(t){const{data:e,elements:n}=t;super(t,{isRenderable:Ss._hasPopupData(e)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Os({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const n of this.elements)n.popup=t,n.container.ariaHasPopup="dialog",e.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${Un}${t}`)).join(",")),this.container}}class Os{#xi=this.#Ei.bind(this);#Si=this.#Ti.bind(this);#Ci=this.#ki.bind(this);#Mi=this.#Ii.bind(this);#Li=null;#ut=null;#Pi=null;#Ri=null;#Di=null;#Fi=null;#Oi=null;#Ni=!1;#Bi=null;#T=null;#qi=null;#Hi=null;#ji=null;#mi=null;#zi=!1;constructor({container:t,color:e,elements:n,titleObj:i,modificationDate:r,contentsObj:s,richText:a,parent:o,rect:l,parentRect:c,open:d}){this.#ut=t,this.#ji=i,this.#Pi=s,this.#Hi=a,this.#Fi=o,this.#Li=e,this.#qi=l,this.#Oi=c,this.#Di=n,this.#Ri=ii.toDateObject(r),this.trigger=n.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#Mi),t.addEventListener("mouseenter",this.#Ci),t.addEventListener("mouseleave",this.#Si),t.classList.add("popupTriggerArea");for(const t of n)t.container?.addEventListener("keydown",this.#xi);this.#ut.hidden=!0,d&&this.#Ii()}render(){if(this.#Bi)return;const t=this.#Bi=document.createElement("div");if(t.className="popup",this.#Li){const e=t.style.outlineColor=qn.makeHexColor(...this.#Li);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=qn.makeHexColor(...this.#Li.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const n=document.createElement("h1");if(e.append(n),({dir:n.dir,str:n.textContent}=this.#ji),t.append(e),this.#Ri){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#Ri.valueOf()})),e.append(t)}const i=this.#Ui;if(i)_s.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#Pi);t.append(e)}this.#ut.append(t)}get#Ui(){const t=this.#Hi,e=this.#Pi;return!t?.str||e?.str&&e.str!==t.str?null:this.#Hi.html||null}get#Vi(){return this.#Ui?.attributes?.style?.fontSize||0}get#Gi(){return this.#Ui?.attributes?.style?.color||null}#Wi(t){const e=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#Gi,fontSize:this.#Vi?`calc(${this.#Vi}px * var(--scale-factor))`:""}};for(const n of t.split("\n"))e.push({name:"span",value:n,attributes:i});return n}_formatContents({str:t,dir:e}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let t=0,e=i.length;t{"Enter"===t.key&&(i?t.metaKey:t.ctrlKey)&&this.#tr()})),!e.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),t.append(n),t}getElementsToTriggerPopup(){return this.#Zi}addHighlightArea(){this.container.classList.add("highlightArea")}#tr(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class Qs{#er=null;#nr=null;#ir=new Map;#rr=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:n,annotationEditorUIManager:i,page:r,viewport:s,structTreeLayer:a}){this.div=t,this.#er=e,this.#nr=n,this.#rr=a||null,this.page=r,this.viewport=s,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return this.#ir.size>0}async#sr(t,e){const n=t.firstChild||t,i=n.id=`${Un}${e}`,r=await(this.#rr?.getAriaAttributes(i));if(r)for(const[t,e]of r)n.setAttribute(t,e);this.div.append(t),this.#er?.moveElementInDOM(this.div,t,n,!1)}async render(t){const{annotations:e}=t,n=this.div;li(n,this.viewport);const i=new Map,r={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new ys,annotationStorage:t.annotationStorage||new Ci,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=16===t.annotationType;if(e){const e=i.get(t.id);if(!e)continue;r.elements=e}else{const{width:e,height:n}=xs(t.rect);if(e<=0||n<=0)continue}r.data=t;const n=Es.create(r);if(!n.isRenderable)continue;if(!e&&t.popupRef){const e=i.get(t.popupRef);e?e.push(n):i.set(t.popupRef,[n])}const s=n.render();t.hidden&&(s.style.visibility="hidden"),await this.#sr(s,t.id),n._isEditable&&(this.#ir.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#ar()}update({viewport:t}){const e=this.div;this.viewport=t,li(e,{rotation:t.rotation}),this.#ar(),e.hidden=!1}#ar(){if(!this.#nr)return;const t=this.div;for(const[e,n]of this.#nr){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;n.className="annotationContent";const{firstChild:r}=i;r?"CANVAS"===r.nodeName?r.replaceWith(n):r.classList.contains("annotationContent")?r.after(n):r.before(n):i.append(n)}this.#nr.clear()}getEditableAnnotations(){return Array.from(this.#ir.values())}getEditableAnnotation(t){return this.#ir.get(t)}}const Js=/\r\n?|\n/g;class Zs extends _i{#Li;#or="";#lr=`${this.id}-editor`;#cr=null;#Vi;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Zs.prototype,e=t=>t.isEmpty(),n=bi.TRANSLATE_SMALL,i=bi.TRANSLATE_BIG;return Sn(this,"_keyboardManager",new mi([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=dn.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#Li=t.color||Zs._defaultColor||_i._defaultLineColor,this.#Vi=t.fontSize||Zs._defaultFontSize}static initialize(t,e){_i.initialize(t,e);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case hn.FREETEXT_SIZE:Zs._defaultFontSize=e;break;case hn.FREETEXT_COLOR:Zs._defaultColor=e}}updateParams(t,e){switch(t){case hn.FREETEXT_SIZE:this.#dr(e);break;case hn.FREETEXT_COLOR:this.#hr(e)}}static get defaultPropertiesToUpdate(){return[[hn.FREETEXT_SIZE,Zs._defaultFontSize],[hn.FREETEXT_COLOR,Zs._defaultColor||_i._defaultLineColor]]}get propertiesToUpdate(){return[[hn.FREETEXT_SIZE,this.#Vi],[hn.FREETEXT_COLOR,this.#Li]]}#dr(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#Vi)*this.parentScale),this.#Vi=t,this.#ur()},n=this.#Vi;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:hn.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#hr(t){const e=t=>{this.#Li=this.editorDiv.style.color=t},n=this.#Li;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:hn.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Zs._internalPadding*t,-(Zs._internalPadding+this.#Vi)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(dn.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#cr=new AbortController;const t=this._uiManager.combinedSignal(this.#cr);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#lr),this._isDraggable=!0,this.#cr?.abort(),this.#cr=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#pr(){const t=[];this.editorDiv.normalize();let e=null;for(const n of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===n.nodeName||(t.push(Zs.#fr(n)),e=n);return t.join("\n")}#ur(){const[t,e]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,i=e.style.display,r=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),n=e.getBoundingClientRect(),e.remove(),e.style.display=i,e.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=n.width/t,this.height=n.height/e):(this.width=n.height/t,this.height=n.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#or,e=this.#or=this.#pr().trimEnd();if(t===e)return;const n=t=>{this.#or=t,t?(this.#gr(),this._uiManager.rebuild(this),this.#ur()):this.remove()};this.addCommands({cmd:()=>{n(e)},undo:()=>{n(t)},mustExec:!1}),this.#ur()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Zs._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}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 t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#lr),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#Vi}px * var(--scale-factor))`,n.color=this.#Li,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),ui(this,this.div,["dblclick","keydown"]),this.width){const[n,i]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this._initialData;let[s,a]=this.getInitialTranslation();[s,a]=this.pageTranslationToScreen(s,a);const[o,l]=this.pageDimensions,[c,d]=this.pageTranslation;let h,u;switch(this.rotation){case 0:h=t+(r[0]-c)/o,u=e+this.height-(r[1]-d)/l;break;case 90:h=t+(r[0]-c)/o,u=e-(r[1]-d)/l,[s,a]=[a,-s];break;case 180:h=t-this.width+(r[0]-c)/o,u=e-(r[1]-d)/l,[s,a]=[-s,-a];break;case 270:h=t+(r[0]-c-this.height*l)/o,u=e+(r[1]-d-this.width*o)/l,[s,a]=[-a,s]}this.setAt(h*n,u*i,s,a)}else this.setAt(t*n,e*i,this.width*n,this.height*i);this.#gr(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#fr(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Js,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:n}=e;if(1===n.length&&"text/plain"===n[0])return;t.preventDefault();const i=Zs.#mr(e.getData("text")||"").replaceAll(Js,"\n");if(!i)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const s=r.getRangeAt(0);if(!i.includes("\n"))return s.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),void r.collapseToStart();const{startContainer:a,startOffset:o}=s,l=[],c=[];if(a.nodeType===Node.TEXT_NODE){const t=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(Js,"")),t!==this.editorDiv){let e=l;for(const n of this.editorDiv.childNodes)n!==t?e.push(Zs.#fr(n)):e=c}l.push(a.nodeValue.slice(0,o).replaceAll(Js,""))}else if(a===this.editorDiv){let t=l,e=0;for(const n of this.editorDiv.childNodes)e++===o&&(t=c),t.push(Zs.#fr(n))}this.#or=`${l.join("\n")}${i}${c.join("\n")}`,this.#gr();const d=new Range;let h=l.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(h<=e){d.setStart(t,h),d.setEnd(t,h);break}h-=e}r.removeAllRanges(),r.addRange(d)}#gr(){if(this.editorDiv.replaceChildren(),this.#or)for(const t of this.#or.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#vr(){return this.#or.replaceAll(" "," ")}static#mr(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,n){let i=null;if(t instanceof Ns){const{data:{defaultAppearanceData:{fontSize:e,fontColor:n},rect:r,rotation:s,id:a,popupRef:o},textContent:l,textPosition:c,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;i=t={annotationType:dn.FREETEXT,color:Array.from(n),fontSize:e,value:l.join("\n"),position:c,pageIndex:d-1,rect:r.slice(0),rotation:s,id:a,deleted:!1,popupRef:o}}const r=await super.deserialize(t,e,n);return r.#Vi=t.fontSize,r.#Li=qn.makeHexColor(...t.color),r.#or=Zs.#mr(t.value),r.annotationElementId=t.id||null,r._initialData=i,r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Zs._internalPadding*this.parentScale,n=this.getRect(e,e),i=_i._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#Li),r={annotationType:dn.FREETEXT,color:i,fontSize:this.#Vi,value:this.#vr(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?r:this.annotationElementId&&!this.#br(r)?null:(r.id=this.annotationElementId,r)}#br(t){const{value:e,fontSize:n,color:i,pageIndex:r}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==n||t.color.some(((t,e)=>t!==i[e]))||t.pageIndex!==r}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:n}=e;n.fontSize=`calc(${this.#Vi}px * var(--scale-factor))`,n.color=this.#Li,e.replaceChildren();for(const t of this.#or.split("\n")){const n=document.createElement("div");n.append(t?document.createTextNode(t):document.createElement("br")),e.append(n)}const i=Zs._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#or}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class ta{toSVGPath(){An("Abstract method `toSVGPath` must be implemented.")}get box(){An("Abstract getter `box` must be implemented.")}serialize(t,e){An("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){An("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){An("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}class ea{#yr;#_r=[];#wr;#Ar;#xr=[];#Er=new Float64Array(18);#Sr;#Tr;#Cr;#kr;#Mr;#Ir;#Lr=[];static#Pr=8;static#Rr=2;static#Dr=ea.#Pr+ea.#Rr;constructor({x:t,y:e},n,i,r,s,a=0){this.#yr=n,this.#Ir=r*i,this.#Ar=s,this.#Er.set([NaN,NaN,NaN,NaN,t,e],6),this.#wr=a,this.#kr=ea.#Pr*i,this.#Cr=ea.#Dr*i,this.#Mr=i,this.#Lr.push(t,e)}isEmpty(){return isNaN(this.#Er[8])}#Fr(){const t=this.#Er.subarray(4,6),e=this.#Er.subarray(16,18),[n,i,r,s]=this.#yr;return[(this.#Sr+(t[0]-e[0])/2-n)/r,(this.#Tr+(t[1]-e[1])/2-i)/s,(this.#Sr+(e[0]-t[0])/2-n)/r,(this.#Tr+(e[1]-t[1])/2-i)/s]}add({x:t,y:e}){this.#Sr=t,this.#Tr=e;const[n,i,r,s]=this.#yr;let[a,o,l,c]=this.#Er.subarray(8,12);const d=t-l,h=e-c,u=Math.hypot(d,h);if(u=6;t-=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#Br(n),n.join(" ")}#Or(){const[t,e,n,i]=this.#yr,[r,s,a,o]=this.#Fr();return`M${(this.#Er[2]-t)/n} ${(this.#Er[3]-e)/i} L${(this.#Er[4]-t)/n} ${(this.#Er[5]-e)/i} L${r} ${s} L${a} ${o} L${(this.#Er[16]-t)/n} ${(this.#Er[17]-e)/i} L${(this.#Er[14]-t)/n} ${(this.#Er[15]-e)/i} Z`}#Br(t){const e=this.#_r;t.push(`L${e[4]} ${e[5]} Z`)}#Nr(t){const[e,n,i,r]=this.#yr,s=this.#Er.subarray(4,6),a=this.#Er.subarray(16,18),[o,l,c,d]=this.#Fr();t.push(`L${(s[0]-e)/i} ${(s[1]-n)/r} L${o} ${l} L${c} ${d} L${(a[0]-e)/i} ${(a[1]-n)/r}`)}newFreeDrawOutline(t,e,n,i,r,s){return new na(t,e,n,i,r,s)}getOutlines(){const t=this.#xr,e=this.#_r,n=this.#Er,[i,r,s,a]=this.#yr,o=new Float64Array((this.#Lr?.length??0)+2);for(let t=0,e=o.length-2;t=6;t-=6)for(let n=0;n<6;n+=2)isNaN(e[t+n])?(l[c]=l[c+1]=NaN,c+=2):(l[c]=e[t+n],l[c+1]=e[t+n+1],c+=2);return this.#jr(l,c),this.newFreeDrawOutline(l,o,this.#yr,this.#Mr,this.#wr,this.#Ar)}#qr(t){const e=this.#Er,[n,i,r,s]=this.#yr,[a,o,l,c]=this.#Fr(),d=new Float64Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-n)/r,(e[3]-i)/s,NaN,NaN,NaN,NaN,(e[4]-n)/r,(e[5]-i)/s,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,(e[16]-n)/r,(e[17]-i)/s,NaN,NaN,NaN,NaN,(e[14]-n)/r,(e[15]-i)/s],0),this.newFreeDrawOutline(d,t,this.#yr,this.#Mr,this.#wr,this.#Ar)}#jr(t,e){const n=this.#_r;return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+6}#Hr(t,e){const n=this.#Er.subarray(4,6),i=this.#Er.subarray(16,18),[r,s,a,o]=this.#yr,[l,c,d,h]=this.#Fr();return t.set([NaN,NaN,NaN,NaN,(n[0]-r)/a,(n[1]-s)/o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-s)/o],e),e+24}}class na extends ta{#yr;#zr=null;#wr;#Ar;#Lr;#Mr;#Ur;constructor(t,e,n,i,r,s){super(),this.#Ur=t,this.#Lr=e,this.#yr=n,this.#Mr=i,this.#wr=r,this.#Ar=s,this.#Vr(s);const{x:a,y:o,width:l,height:c}=this.#zr;for(let e=0,n=t.length;et[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#$r)e[3]?(t.push(...this.#Kr(e)),this.#Yr(e)):(this.#Qr(e),t.push(...this.#Kr(e)));return this.#Jr(t)}#Jr(t){const e=[],n=new Set;for(const n of t){const[t,i,r]=n;e.push([t,i,n],[t,r,n])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,i=e.length;t0;){const t=n.values().next().value;let[e,s,a,o,l]=t;n.delete(t);let c=e,d=s;for(r=[e,a],i.push(r);;){let t;if(n.has(o))t=o;else{if(!n.has(l))break;t=l}n.delete(t),[e,s,a,o,l]=t,c!==e&&(r.push(c,d,e,d===s?s:a),c=e),d=d===s?a:s}r.push(c,d)}return new ra(i,this.#yr)}#Zr(t){const e=this.#Xr;let n=0,i=e.length-1;for(;n<=i;){const r=n+i>>1,s=e[r][0];if(s===t)return r;s=0;i--){const[n,r]=this.#Xr[i];if(n!==t)break;if(n===t&&r===e)return void this.#Xr.splice(i,1)}}#Kr(t){const[e,n,i]=t,r=[[e,n,i]],s=this.#Zr(i);for(let t=0;t=n)if(o>i)r[t][1]=i;else{if(1===s)return[];r.splice(t,1),t--,s--}else r[t][2]=n,o>i&&r.push([e,i,o])}}return r}}class ra extends ta{#yr;#ts;constructor(t,e){super(),this.#ts=t,this.#yr=e}toSVGPath(){const t=[];for(const e of this.#ts){let[n,i]=e;t.push(`M${n} ${i}`);for(let r=2;r-1?(this.#Es=!0,this.#Is(t),this.#Ls()):this.#vs&&(this.#gs=t.anchorNode,this.#ms=t.anchorOffset,this.#_s=t.focusNode,this.#ws=t.focusOffset,this.#Ps(),this.#Ls(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Es?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#Ir,methodOfCreation:this.#Ms}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#Ps(){const t=new ia(this.#vs,.001);this.#xs=t.getOutlines(),({x:this.x,y:this.y,width:this.width,height:this.height}=this.#xs.box);const e=new ia(this.#vs,.0025,.001,"ltr"===this._uiManager.direction);this.#ys=e.getOutlines();const{lastPoint:n}=this.#ys.box;this.#Ss=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#Is({highlightOutlines:t,highlightId:e,clipPathId:n}){if(this.#xs=t,this.#ys=t.getNewOutline(this.#Ir/2+1.5,.0025),e>=0)this.#y=e,this.#bs=n,this.parent.drawLayer.finalizeLine(e,t),this.#Cs=this.parent.drawLayer.drawOutline(this.#ys);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#y,t),this.parent.drawLayer.updateBox(this.#y,la.#Rs(this.#xs.box,(e-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#Cs,this.#ys),this.parent.drawLayer.updateBox(this.#Cs,la.#Rs(this.#ys.box,e))}const{x:i,y:r,width:s,height:a}=t.box;switch(this.rotation){case 0:this.x=i,this.y=r,this.width=s,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=r,this.y=1-i,this.width=s*e/t,this.height=a*t/e;break}case 180:this.x=1-i,this.y=1-r,this.width=s,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-r,this.y=i,this.width=s*e/t,this.height=a*t/e;break}}const{lastPoint:o}=this.#ys.box;this.#Ss=[(o[0]-i)/s,(o[1]-r)/a]}static initialize(t,e){_i.initialize(t,e),la._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case hn.HIGHLIGHT_DEFAULT_COLOR:la._defaultColor=e;break;case hn.HIGHLIGHT_THICKNESS:la._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Ss}updateParams(t,e){switch(t){case hn.HIGHLIGHT_COLOR:this.#hr(e);break;case hn.HIGHLIGHT_THICKNESS:this.#Ds(e)}}static get defaultPropertiesToUpdate(){return[[hn.HIGHLIGHT_DEFAULT_COLOR,la._defaultColor],[hn.HIGHLIGHT_THICKNESS,la._defaultThickness]]}get propertiesToUpdate(){return[[hn.HIGHLIGHT_COLOR,this.color||la._defaultColor],[hn.HIGHLIGHT_THICKNESS,this.#Ir||la._defaultThickness],[hn.HIGHLIGHT_FREE,this.#Es]]}#hr(t){const e=(t,e)=>{this.color=t,this.parent?.drawLayer.changeColor(this.#y,t),this.#r?.updateColor(t),this.#Ts=e,this.parent?.drawLayer.changeOpacity(this.#y,e)},n=this.color,i=this.#Ts;this.addCommands({cmd:e.bind(this,t,la._defaultOpacity),undo:e.bind(this,n,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:hn.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#Ds(t){const e=this.#Ir,n=t=>{this.#Ir=t,this.#Fs(t)};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:hn.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#r=new oa({editor:this}),t.addColorPicker(this.#r)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#Os())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#Os())}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#Ns(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Ls(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#Ns():t&&(this.#Ls(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#Fs(t){if(!this.#Es)return;this.#Is({highlightOutlines:this.#xs.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)}#Ns(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#Cs),this.#Cs=null)}#Ls(t=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#bs}=t.drawLayer.draw(this.#xs,this.color,this.#Ts)),this.#Cs=t.drawLayer.drawOutline(this.#ys),this.#As&&(this.#As.style.clipPath=this.#bs))}static#Rs({x:t,y:e,width:n,height:i},r){switch(r){case 90:return{x:1-e-i,y:t,width:i,height:n};case 180:return{x:1-t-n,y:1-e-i,width:n,height:i};case 270:return{x:e,y:1-t-n,width:i,height:n}}return{x:t,y:e,width:n,height:i}}rotate(t){const{drawLayer:e}=this.parent;let n;this.#Es?(t=(t-this.rotation+360)%360,n=la.#Rs(this.#xs.box,t)):n=la.#Rs(this,t),e.rotate(this.#y,t),e.rotate(this.#Cs,t),e.updateBox(this.#y,n),e.updateBox(this.#Cs,la.#Rs(this.#ys.box,t))}render(){if(this.div)return this.div;const t=super.render();this.#ks&&(t.setAttribute("aria-label",this.#ks),t.setAttribute("role","mark")),this.#Es?t.classList.add("free"):this.div.addEventListener("keydown",this.#Bs.bind(this),{signal:this._uiManager._signal});const e=this.#As=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#bs;const[n,i]=this.parentDimensions;return this.setDims(this.width*n,this.height*i),ui(this,this.#As,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent.drawLayer.addClass(this.#Cs,"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(this.#Cs,"hovered")}#Bs(t){la._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#qs(!0);break;case 1:case 3:this.#qs(!1)}}#qs(t){if(!this.#gs)return;const e=window.getSelection();t?e.setPosition(this.#gs,this.#ms):e.setPosition(this.#_s,this.#ws)}select(){super.select(),this.#Cs&&(this.parent?.drawLayer.removeClass(this.#Cs,"hovered"),this.parent?.drawLayer.addClass(this.#Cs,"selected"))}unselect(){super.unselect(),this.#Cs&&(this.parent?.drawLayer.removeClass(this.#Cs,"selected"),this.#Es||this.#qs(!1))}get _mustFixPosition(){return!this.#Es}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.show(this.#y,t),this.parent.drawLayer.show(this.#Cs,t))}#Os(){return this.#Es?this.rotation:0}#Hs(){if(this.#Es)return null;const[t,e]=this.pageDimensions,[n,i]=this.pageTranslation,r=this.#vs,s=new Float32Array(8*r.length);let a=0;for(const{x:o,y:l,width:c,height:d}of r){const r=o*t+n,h=(1-l-d)*e+i;s[a]=s[a+4]=r,s[a+1]=s[a+3]=h,s[a+2]=s[a+6]=r+c*t,s[a+5]=s[a+7]=h+d*e,a+=8}return s}#js(t){return this.#xs.serialize(t,this.#Os())}static startHighlighting(t,e,{target:n,x:i,y:r}){const{x:s,y:a,width:o,height:l}=n.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),h=e=>{c.abort(),this.#zs(t,e)};window.addEventListener("blur",h,{signal:d}),window.addEventListener("pointerup",h,{signal:d}),window.addEventListener("pointerdown",(t=>{t.preventDefault(),t.stopPropagation()}),{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",ei,{signal:d}),n.addEventListener("pointermove",this.#Us.bind(this,t),{signal:d}),this._freeHighlight=new sa({x:i,y:r},[s,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static#Us(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#zs(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,n){let i=null;if(t instanceof Gs){const{data:{quadPoints:e,rect:n,rotation:r,id:s,color:a,opacity:o,popupRef:l},parent:{page:{pageNumber:c}}}=t;i=t={annotationType:dn.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:c-1,rect:n.slice(0),rotation:r,id:s,deleted:!1,popupRef:l}}else if(t instanceof Vs){const{data:{inkLists:e,rect:n,rotation:r,id:s,color:a,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:c}}}=t;i=t={annotationType:dn.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:c-1,rect:n.slice(0),rotation:r,id:s,deleted:!1,popupRef:l}}const{color:r,quadPoints:s,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,n);l.color=qn.makeHexColor(...r),l.#Ts=o||1,a&&(l.#Ir=t.thickness),l.annotationElementId=t.id||null,l._initialData=i;const[c,d]=l.pageDimensions,[h,u]=l.pageTranslation;if(s){const t=l.#vs=[];for(let e=0;et!==e[n]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class ca extends _i{#Vs=0;#Gs=0;#Ws=null;#$s=new Path2D;#Xs=!1;#Ks=null;#Ys=!1;#Qs=!1;#Js=null;#Zs=null;#ta=0;#ea=0;#na=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=dn.INK;constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,e){_i.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case hn.INK_THICKNESS:ca._defaultThickness=e;break;case hn.INK_COLOR:ca._defaultColor=e;break;case hn.INK_OPACITY:ca._defaultOpacity=e/100}}updateParams(t,e){switch(t){case hn.INK_THICKNESS:this.#Ds(e);break;case hn.INK_COLOR:this.#hr(e);break;case hn.INK_OPACITY:this.#ia(e)}}static get defaultPropertiesToUpdate(){return[[hn.INK_THICKNESS,ca._defaultThickness],[hn.INK_COLOR,ca._defaultColor||_i._defaultLineColor],[hn.INK_OPACITY,Math.round(100*ca._defaultOpacity)]]}get propertiesToUpdate(){return[[hn.INK_THICKNESS,this.thickness||ca._defaultThickness],[hn.INK_COLOR,this.color||ca._defaultColor||_i._defaultLineColor],[hn.INK_OPACITY,Math.round(100*(this.opacity??ca._defaultOpacity))]]}#Ds(t){const e=t=>{this.thickness=t,this.#ra()},n=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:hn.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#hr(t){const e=t=>{this.color=t,this.#sa()},n=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:hn.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#ia(t){const e=t=>{this.opacity=t,this.#sa()};t/=100;const n=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:hn.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(this.#aa(),this.#oa()),this.isAttachedToDOM||(this.parent.add(this),this.#la()),this.#ra()))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#Ws&&(clearTimeout(this.#Ws),this.#Ws=null),this.#Js?.disconnect(),this.#Js=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&null===t&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,n=this.width*t,i=this.height*e;this.setDimensions(n,i)}enableEditMode(){this.#Xs||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.#ca())}disableEditMode(){this.isInEditMode()&&null!==this.canvas&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.#da())}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#ha(){const{parentRotation:t,parentDimensions:[e,n]}=this;switch(t){case 90:return[0,n,n,e];case 180:return[e,n,e,n];case 270:return[e,0,n,e];default:return[0,0,e,n]}}#ua(){const{ctx:t,color:e,opacity:n,thickness:i,parentScale:r,scaleFactor:s}=this;t.lineWidth=i*r/s,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${function(t){return Math.round(Math.min(255,Math.max(1,255*t))).toString(16).padStart(2,"0")}(n)}`}#pa(t,e){this.canvas.addEventListener("contextmenu",ei,{signal:this._uiManager._signal}),this.#da(),this.#Ks=new AbortController;const n=this._uiManager.combinedSignal(this.#Ks);this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:n}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:n}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:n}),this.isEditing=!0,this.#Qs||(this.#Qs=!0,this.#la(),this.thickness||=ca._defaultThickness,this.color||=ca._defaultColor||_i._defaultLineColor,this.opacity??=ca._defaultOpacity),this.currentPath.push([t,e]),this.#Ys=!1,this.#ua(),this.#na=()=>{this.#fa(),this.#na&&window.requestAnimationFrame(this.#na)},window.requestAnimationFrame(this.#na)}#ga(t,e){const[n,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===n&&e===i)return;const r=this.currentPath;let s=this.#$s;if(r.push([t,e]),this.#Ys=!0,r.length<=2)return s.moveTo(...r[0]),void s.lineTo(t,e);3===r.length&&(this.#$s=s=new Path2D,s.moveTo(...r[0])),this.#ma(s,...r.at(-3),...r.at(-2),t,e)}#va(){if(0===this.currentPath.length)return;const t=this.currentPath.at(-1);this.#$s.lineTo(...t)}#ba(t,e){let n;if(this.#na=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#ga(t,e),this.#va(),1!==this.currentPath.length)n=this.#ya();else{const i=[t,e];n=[[i,i.slice(),i.slice(),i]]}const i=this.#$s,r=this.currentPath;this.currentPath=[],this.#$s=new Path2D,this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(n),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(this.#aa(),this.#oa()),this.#ra())},mustExec:!0})}#fa(){if(!this.#Ys)return;this.#Ys=!1;Math.ceil(this.thickness*this.parentScale);const t=this.currentPath.slice(-3),e=t.map((t=>t[0])),n=t.map((t=>t[1])),{ctx:i}=(Math.min(...e),Math.max(...e),Math.min(...n),Math.max(...n),this);i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.bezierPath2D)i.stroke(t);i.stroke(this.#$s),i.restore()}#ma(t,e,n,i,r,s,a){const o=(e+i)/2,l=(n+r)/2,c=(i+s)/2,d=(r+a)/2;t.bezierCurveTo(o+2*(i-o)/3,l+2*(r-l)/3,c+2*(i-c)/3,d+2*(r-d)/3,c,d)}#ya(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let n,[i,r]=t[0];for(n=1;n{this.#Ws=null,this.canvas.removeEventListener("contextmenu",ei)}),10),this.#ba(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#aa(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#oa(){this.#Js=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)})),this.#Js.observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{this.#Js?.disconnect(),this.#Js=null}),{once:!0})}get isResizable(){return!this.isEmpty()&&this.#Xs}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[n,i,r,s]=this.#ha();if(this.setAt(n,i,0,0),this.setDims(r,s),this.#aa(),this.width){const[n,i]=this.parentDimensions;this.setAspectRatio(this.width*n,this.height*i),this.setAt(t*n,e*i,this.width*n,this.height*i),this.#Qs=!0,this.#la(),this.setDims(this.width*n,this.height*i),this.#sa(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#oa(),this.div}#la(){if(!this.#Qs)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#_a()}setDimensions(t,e){const n=Math.round(t),i=Math.round(e);if(this.#ta===n&&this.#ea===i)return;this.#ta=n,this.#ea=i,this.canvas.style.visibility="hidden";const[r,s]=this.parentDimensions;this.width=t/r,this.height=e/s,this.fixAndSetPosition(),this.#Xs&&this.#Aa(t,e),this.#la(),this.#sa(),this.canvas.style.visibility="visible",this.fixDims()}#Aa(t,e){const n=this.#xa(),i=(t-n)/this.#Gs,r=(e-n)/this.#Vs;this.scaleFactor=Math.min(i,r)}#_a(){const t=this.#xa()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#Ea(t){const e=new Path2D;for(let n=0,i=t.length;n`image/${t}`)))}static get supportedTypesStr(){return Sn(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(dn.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#qa(t,e=!1){t?(this.#Ma=t.bitmap,e||(this.#Ia=t.id,this.#Na=t.isSvg),t.file&&(this.#Da=t.file.name),this.#aa()):this.remove()}#Ha(){if(this.#La=null,this._uiManager.enableWaiting(!1),this.#Fa){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ma)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ma){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:r,height:s}=t||this.copyCanvas(null,null,!0).imageData,a=await n.guess({name:"altText",request:{data:i,width:r,height:s,channels:i.length/(r*s)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#ja(){if(this.#Ia)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Ia).then((t=>this.#qa(t,!0))).finally((()=>this.#Ha()));if(this.#Pa){const t=this.#Pa;return this.#Pa=null,this._uiManager.enableWaiting(!0),void(this.#La=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#qa(t))).finally((()=>this.#Ha())))}if(this.#Ra){const t=this.#Ra;return this.#Ra=null,this._uiManager.enableWaiting(!0),void(this.#La=this._uiManager.imageManager.getFromFile(t).then((t=>this.#qa(t))).finally((()=>this.#Ha())))}const t=document.createElement("input");t.type="file",t.accept=da.supportedTypesStr;const e=this._uiManager._signal;this.#La=new Promise((n=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#qa(e)}else this.remove();n()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),n()}),{signal:e})})).finally((()=>this.#Ha())),t.click()}remove(){this.#Ia&&(this.#Ma=null,this._uiManager.imageManager.deleteId(this.#Ia),this.#Fa?.remove(),this.#Fa=null,this.#Js?.disconnect(),this.#Js=null,this.#Oa&&(clearTimeout(this.#Oa),this.#Oa=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Ia&&null===this.#Fa&&this.#ja(),this.isAttachedToDOM||this.parent.add(this))):this.#Ia&&this.#ja()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#La||this.#Ma||this.#Pa||this.#Ra||this.#Ia)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Ma?this.#aa():this.#ja(),this.width&&!this.annotationElementId){const[n,i]=this.parentDimensions;this.setAt(t*n,e*i,this.width*n,this.height*i)}return this.div}#aa(){const{div:t}=this;let{width:e,height:n}=this.#Ma;const[i,r]=this.pageDimensions,s=.75;if(this.width)e=this.width*i,n=this.height*r;else if(e>s*i||n>s*r){const t=Math.min(s*i/e,s*r/n);e*=t,n*=t}const[a,o]=this.parentDimensions;this.setDims(e*a/i,n*o/r),this._uiManager.enableWaiting(!1);const l=this.#Fa=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#za(e,n),this.#oa(),this.#Ba||(this.parent.addUndoableEditor(this),this.#Ba=!0),this._reportTelemetry({action:"inserted_image"}),this.#Da&&l.setAttribute("aria-label",this.#Da)}copyCanvas(t,e,n=!1){t||(t=224);const{width:i,height:r}=this.#Ma,s=new ci;let a=this.#Ma,o=i,l=r,c=null;if(e){if(i>e||r>e){const t=Math.min(e/i,e/r);o=Math.floor(i*t),l=Math.floor(r*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(o*s.sx),n=c.height=Math.ceil(l*s.sy);this.#Na||(a=this.#Ua(t,n));const d=c.getContext("2d");d.filter=this._uiManager.hcmFilter;let h="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(h="#8f8f9d",u="#42414d");const p=15,f=p*s.sx,g=p*s.sy,m=new OffscreenCanvas(2*f,2*g),v=m.getContext("2d");v.fillStyle=h,v.fillRect(0,0,2*f,2*g),v.fillStyle=u,v.fillRect(0,0,f,g),v.fillRect(f,g,f,g),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,n),d.drawImage(a,0,0,a.width,a.height,0,0,t,n)}let d=null;if(n){let e,n;if(s.symmetric&&a.widtht||r>t){const s=Math.min(t/i,t/r);e=Math.floor(i*s),n=Math.floor(r*s),this.#Na||(a=this.#Ua(e,n))}const o=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,n),d={width:e,height:n,data:o.getImageData(0,0,e,n).data}}return{canvas:c,width:o,height:l,imageData:d}}#Va(t,e){const[n,i]=this.parentDimensions;this.width=t/n,this.height=e/i,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#Oa&&clearTimeout(this.#Oa),this.#Oa=setTimeout((()=>{this.#Oa=null,this.#za(t,e)}),200)}#Ua(t,e){const{width:n,height:i}=this.#Ma;let r=n,s=i,a=this.#Ma;for(;r>2*t||s>2*e;){const n=r,i=s;r>2*t&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),s>2*e&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2));const o=new OffscreenCanvas(r,s);o.getContext("2d").drawImage(a,0,0,n,i,0,0,r,s),a=o.transferToImageBitmap()}return a}#za(t,e){const n=new ci,i=Math.ceil(t*n.sx),r=Math.ceil(e*n.sy),s=this.#Fa;if(!s||s.width===i&&s.height===r)return;s.width=i,s.height=r;const a=this.#Na?this.#Ma:this.#Ua(i,r),o=s.getContext("2d");o.filter=this._uiManager.hcmFilter,o.drawImage(a,0,0,a.width,a.height,0,0,i,r)}getImageForAltText(){return this.#Fa}#Ga(t){if(t){if(this.#Na){const t=this._uiManager.imageManager.getSvgUrl(this.#Ia);if(t)return t}const t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#Ma),t.getContext("2d").drawImage(this.#Ma,0,0),t.toDataURL()}if(this.#Na){const[t,e]=this.pageDimensions,n=Math.round(this.width*t*Gn.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Gn.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(n,i);return r.getContext("2d").drawImage(this.#Ma,0,0,this.#Ma.width,this.#Ma.height,0,0,n,i),r.transferToImageBitmap()}return structuredClone(this.#Ma)}#oa(){this._uiManager._signal&&(this.#Js=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.#Va(e.width,e.height)})),this.#Js.observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{this.#Js?.disconnect(),this.#Js=null}),{once:!0}))}static async deserialize(t,e,n){let i=null;if(t instanceof Ks){const{data:{rect:r,rotation:s,id:a,structParent:o,popupRef:l},container:c,parent:{page:{pageNumber:d}}}=t,h=c.querySelector("canvas"),u=n.imageManager.getFromCanvas(c.id,h);h.remove();const p=(await e._structTree.getAriaAttributes(`${Un}${a}`))?.get("aria-label")||"";i=t={annotationType:dn.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:r.slice(0),rotation:s,id:a,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const r=await super.deserialize(t,e,n),{rect:s,bitmap:a,bitmapUrl:o,bitmapId:l,isSvg:c,accessibilityData:d}=t;l&&n.imageManager.isValidId(l)?(r.#Ia=l,a&&(r.#Ma=a)):r.#Pa=o,r.#Na=c;const[h,u]=r.pageDimensions;return r.width=(s[2]-s[0])/h,r.height=(s[3]-s[1])/u,r.annotationElementId=t.id||null,d&&(r.altTextData=d),r._initialData=i,r.#Ba=!!i,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n={annotationType:dn.STAMP,bitmapId:this.#Ia,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Na,structTreeParentId:this._structTreeParentId};if(t)return n.bitmapUrl=this.#Ga(!0),n.accessibilityData=this.serializeAltText(!0),n;const{decorative:i,altText:r}=this.serializeAltText(!1);if(!i&&r&&(n.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const t=this.#br(n);if(t.isSame)return null;t.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,null===e)return n;e.stamps||=new Map;const s=this.#Na?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(e.stamps.has(this.#Ia)){if(this.#Na){const t=e.stamps.get(this.#Ia);s>t.area&&(t.area=s,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Ga(!1))}}else e.stamps.set(this.#Ia,{area:s,serialized:n}),n.bitmap=this.#Ga(!1);return n}#br(t){const{rect:e,pageIndex:n,accessibilityData:{altText:i}}=this._initialData,r=t.rect.every(((t,n)=>Math.abs(t-e[n])<1)),s=t.pageIndex===n,a=(t.accessibilityData?.alt||"")===i;return{isSame:r&&s&&a,isSameAltText:a}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class ha{#er;#Wa=!1;#$a=null;#Xa=null;#Ka=null;#Ya=new Map;#Qa=!1;#Ja=!1;#Za=!1;#to=null;#eo=null;#g;static _initialized=!1;static#H=new Map([Zs,ca,da,la].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:n,structTreeLayer:i,accessibilityManager:r,annotationLayer:s,drawLayer:a,textLayer:o,viewport:l,l10n:c}){const d=[...ha.#H.values()];if(!ha._initialized){ha._initialized=!0;for(const e of d)e.initialize(c,t)}t.registerEditorTypes(d),this.#g=t,this.pageIndex=e,this.div=n,this.#er=r,this.#$a=s,this.viewport=l,this.#to=o,this.drawLayer=a,this._structTree=i,this.#g.addLayer(this)}get isEmpty(){return 0===this.#Ya.size}get isInvisible(){return this.isEmpty&&this.#g.getMode()===dn.NONE}updateToolbar(t){this.#g.updateToolbar(t)}updateMode(t=this.#g.getMode()){switch(this.#no(),t){case dn.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case dn.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case dn.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const n of ha.#H.values())e.toggle(`${n._type}Editing`,t===n._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#to?.div}addInkEditorIfNeeded(t){if(this.#g.getMode()===dn.INK){if(!t)for(const t of this.#Ya.values())if(t.isEmpty())return void t.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(t){this.#g.setEditingState(t)}addCommands(t){this.#g.addCommands(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#$a?.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#Ya.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#g.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#$a)return;const e=this.#$a.getEditableAnnotations();for(const n of e){if(n.hide(),this.#g.isDeletedAnnotationElement(n.data.id))continue;if(t.has(n.data.id))continue;const e=await this.deserialize(n);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){this.#Za=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of this.#Ya.values())n.disableEditing(),n.annotationElementId&&(null===n.serialize()?(e.set(n.annotationElementId,n),this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()):t.set(n.annotationElementId,n));if(this.#$a){const n=this.#$a.getEditableAnnotations();for(const i of n){const{id:n}=i.data;if(this.#g.isDeletedAnnotationElement(n))continue;let r=e.get(n);r?(r.resetAnnotationElement(i),r.show(!1),i.show()):(r=t.get(n),r&&(this.#g.addChangedExistingAnnotation(r),r.renderAnnotationElement(i)&&r.show(!1)),i.show())}}this.#no(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const t of ha.#H.values())n.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#Za=!1}getEditableAnnotation(t){return this.#$a?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#g.getActive()!==t&&this.#g.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#to?.div&&!this.#eo){this.#eo=new AbortController;const t=this.#g.combinedSignal(this.#eo);this.#to.div.addEventListener("pointerdown",this.#io.bind(this),{signal:t}),this.#to.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#to?.div&&this.#eo&&(this.#eo.abort(),this.#eo=null,this.#to.div.classList.remove("highlighting"))}#io(t){this.#g.unselectAll();const{target:e}=t;if(e===this.#to.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#to.div.contains(e)){const{isMac:e}=Nn.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#g.showAllEditors("highlight",!0,!0),this.#to.div.classList.add("free"),this.toggleDrawing(),la.startHighlighting(this,"ltr"===this.#g.direction,{target:this.#to.div,x:t.x,y:t.y}),this.#to.div.addEventListener("pointerup",(()=>{this.#to.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#g._signal}),t.preventDefault()}}enableClick(){if(this.#Xa)return;this.#Xa=new AbortController;const t=this.#g.combinedSignal(this.#Xa);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){this.#Xa?.abort(),this.#Xa=null}attach(t){this.#Ya.set(t.id,t);const{annotationElementId:e}=t;e&&this.#g.isDeletedAnnotationElement(e)&&this.#g.removeDeletedAnnotationElement(t)}detach(t){this.#Ya.delete(t.id),this.#er?.removePointerInTextLayer(t.contentDiv),!this.#Za&&t.annotationElementId&&this.#g.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#g.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#Ja||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#g.addDeletedAnnotationElement(t.annotationElementId),_i.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#g.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#g.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Ka&&(t._focusEventsAllowed=!1,this.#Ka=setTimeout((()=>{this.#Ka=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#g._signal}),e.focus())}),0)),t._structTreeParentId=this.#er?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#g.getId()}get#ro(){return ha.#H.get(this.#g.getMode())}combinedSignal(t){return this.#g.combinedSignal(t)}#so(t){const e=this.#ro;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#ro?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#g.updateToolbar(t),this.#g.updateMode(t);const{offsetX:n,offsetY:i}=this.#ao(),r=this.getNextId(),s=this.#so({parent:this,id:r,x:n,y:i,uiManager:this.#g,isCentered:!0,...e});s&&this.add(s)}async deserialize(t){return await(ha.#H.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#g))||null}createAndAddNewEditor(t,e,n={}){const i=this.getNextId(),r=this.#so({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#g,isCentered:e,...n});return r&&this.add(r),r}#ao(){const{x:t,y:e,width:n,height:i}=this.div.getBoundingClientRect(),r=Math.max(0,t),s=Math.max(0,e),a=(r+Math.min(window.innerWidth,t+n))/2-t,o=(s+Math.min(window.innerHeight,e+i))/2-e,[l,c]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:c}}addNewEditor(){this.createAndAddNewEditor(this.#ao(),!0)}setSelected(t){this.#g.setSelected(t)}toggleSelected(t){this.#g.toggleSelected(t)}unselect(t){this.#g.unselect(t)}pointerup(t){const{isMac:e}=Nn.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#Qa&&(this.#Qa=!1,this.#Wa?this.#g.getMode()!==dn.STAMP?this.createAndAddNewEditor(t,!1):this.#g.unselectAll():this.#Wa=!0)}pointerdown(t){if(this.#g.getMode()===dn.HIGHLIGHT&&this.enableTextSelection(),this.#Qa)return void(this.#Qa=!1);const{isMac:e}=Nn.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;this.#Qa=!0;const n=this.#g.getActive();this.#Wa=!n||n.isEmpty()}findNewParent(t,e,n){const i=this.#g.findParent(e,n);return null!==i&&i!==this&&(i.changeParent(t),!0)}destroy(){this.#g.getActive()?.parent===this&&(this.#g.commitOrRemove(),this.#g.setActiveEditor(null)),this.#Ka&&(clearTimeout(this.#Ka),this.#Ka=null);for(const t of this.#Ya.values())this.#er?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Ya.clear(),this.#g.removeLayer(this)}#no(){this.#Ja=!0;for(const t of this.#Ya.values())t.isEmpty()&&t.remove();this.#Ja=!1}render({viewport:t}){this.viewport=t,li(this.div,t);for(const t of this.#g.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#g.commitOrRemove(),this.#no();const e=this.viewport.rotation,n=t.rotation;if(this.viewport=t,li(this.div,{rotation:n}),e!==n)for(const t of this.#Ya.values())t.rotate(n);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#g.viewParameters.realScale}}class ua{#Fi=null;#y=0;#oo=new Map;#lo=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#Fi){if(this.#Fi!==t){if(this.#oo.size>0)for(const e of this.#oo.values())e.remove(),t.append(e);this.#Fi=t}}else this.#Fi=t}static get _svgFactory(){return Sn(this,"_svgFactory",new ys)}static#co(t,{x:e=0,y:n=0,width:i=1,height:r=1}={}){const{style:s}=t;s.top=100*n+"%",s.left=100*e+"%",s.width=100*i+"%",s.height=100*r+"%"}#do(t){const e=ua._svgFactory.create(1,1,!0);return this.#Fi.append(e),e.setAttribute("aria-hidden",!0),ua.#co(e,t),e}#ho(t,e){const n=ua._svgFactory.createElement("clipPath");t.append(n);const i=`clip_${e}`;n.setAttribute("id",i),n.setAttribute("clipPathUnits","objectBoundingBox");const r=ua._svgFactory.createElement("use");return n.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i}draw(t,e,n,i=!1){const r=this.#y++,s=this.#do(t.box);s.classList.add(...t.classNamesForDrawing);const a=ua._svgFactory.createElement("defs");s.append(a);const o=ua._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${r}`;o.setAttribute("id",l),o.setAttribute("d",t.toSVGPath()),i&&this.#lo.set(r,o);const c=this.#ho(a,l),d=ua._svgFactory.createElement("use");return s.append(d),s.setAttribute("fill",e),s.setAttribute("fill-opacity",n),d.setAttribute("href",`#${l}`),this.#oo.set(r,s),{id:r,clipPathId:`url(#${c})`}}drawOutline(t){const e=this.#y++,n=this.#do(t.box);n.classList.add(...t.classNamesForOutlining);const i=ua._svgFactory.createElement("defs");n.append(i);const r=ua._svgFactory.createElement("path");i.append(r);const s=`path_p${this.pageIndex}_${e}`;let a;if(r.setAttribute("id",s),r.setAttribute("d",t.toSVGPath()),r.setAttribute("vector-effect","non-scaling-stroke"),t.mustRemoveSelfIntersections){const t=ua._svgFactory.createElement("mask");i.append(t),a=`mask_p${this.pageIndex}_${e}`,t.setAttribute("id",a),t.setAttribute("maskUnits","objectBoundingBox");const n=ua._svgFactory.createElement("rect");t.append(n),n.setAttribute("width","1"),n.setAttribute("height","1"),n.setAttribute("fill","white");const r=ua._svgFactory.createElement("use");t.append(r),r.setAttribute("href",`#${s}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}const o=ua._svgFactory.createElement("use");n.append(o),o.setAttribute("href",`#${s}`),a&&o.setAttribute("mask",`url(#${a})`);const l=o.cloneNode();return n.append(l),o.classList.add("mainOutline"),l.classList.add("secondaryOutline"),this.#oo.set(e,n),e}finalizeLine(t,e){const n=this.#lo.get(t);this.#lo.delete(t),this.updateBox(t,e.box),n.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#oo.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){this.#lo.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){ua.#co(this.#oo.get(t),e)}show(t,e){this.#oo.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#oo.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#oo.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#oo.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#oo.get(t).classList.add(e)}removeClass(t,e){this.#oo.get(t).classList.remove(e)}getSVGRoot(t){return this.#oo.get(t)}remove(t){this.#lo.delete(t),null!==this.#Fi&&(this.#oo.get(t).remove(),this.#oo.delete(t))}destroy(){this.#Fi=null;for(const t of this.#oo.values())t.remove();this.#oo.clear(),this.#lo.clear()}}function pa(t){return pa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pa(t)}function fa(){fa=function(){return e};var t,e={},n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function d(t,e,n,i){var s=e&&e.prototype instanceof v?e:v,a=Object.create(s.prototype),o=new I(i||[]);return r(a,"_invoke",{value:T(t,n,o)}),a}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var u="suspendedStart",p="suspendedYield",f="executing",g="completed",m={};function v(){}function b(){}function y(){}var _={};c(_,a,(function(){return this}));var w=Object.getPrototypeOf,A=w&&w(w(L([])));A&&A!==n&&i.call(A,a)&&(_=A);var x=y.prototype=v.prototype=Object.create(_);function E(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function n(r,s,a,o){var l=h(t[r],t,s);if("throw"!==l.type){var c=l.arg,d=c.value;return d&&"object"==pa(d)&&i.call(d,"__await")?e.resolve(d.__await).then((function(t){n("next",t,a,o)}),(function(t){n("throw",t,a,o)})):e.resolve(d).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,o)}))}o(l.arg)}var s;r(this,"_invoke",{value:function(t,i){function r(){return new e((function(e,r){n(t,i,e,r)}))}return s=s?s.then(r,r):r()}})}function T(e,n,i){var r=u;return function(s,a){if(r===f)throw Error("Generator is already running");if(r===g){if("throw"===s)throw a;return{value:t,done:!0}}for(i.method=s,i.arg=a;;){var o=i.delegate;if(o){var l=C(o,i);if(l){if(l===m)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===u)throw r=g,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=f;var c=h(e,n,i);if("normal"===c.type){if(r=i.done?g:p,c.arg===m)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=g,i.method="throw",i.arg=c.arg)}}}function C(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,C(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),m;var s=h(r,e.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,m;var a=s.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,s=function n(){for(;++r=0;--s){var a=this.tryEntries[s],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(l&&c){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),M(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;M(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:L(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),m}},e}function ga(t,e,n,i,r,s,a){try{var o=t[s](a),l=o.value}catch(t){return void n(t)}o.done?e(l):Promise.resolve(l).then(i,r)}"undefined"!=typeof window&&"Worker"in window&&(rn.GlobalWorkerOptions.workerPort=new Worker(new URL(n.p+n.u(332),n.b),{type:"module"}));var ma={renderedCss:!1};function va(){var t;ma.renderedCss||((t=document.createElement("style")).textContent="\n/* Learnosity render PDF styles */\n.lt__renderPDF_pdf .pdf-viewer {\n border: none;\n width: 100%;\n height: 650px;\n}\n",document.head.append(t),ma.renderedCss=!0),A.appInstance().on("item:load",(function(t){var e,n;e=O.itemReference(),(n=document.querySelector('.learnosity-item[data-reference="'.concat(e,'"]')).querySelectorAll(".lrn_widget .resource")).length&&n.forEach((function(t,e){var n=t.querySelector("a").getAttribute("href");if("pdf"===n.substring(n.length-3)){t.classList.add("sr-only"),function(t){return ba.apply(this,arguments)}(n).then((function(e){!function(e){if(!document.getElementById(e)){var i=document.createElement("div"),r=document.createElement("iframe");i.setAttribute("id",e),i.setAttribute("class","lt__renderPDF_pdf"),t.before(i),r.setAttribute("class","pdf-viewer"),r.setAttribute("src","".concat(n,"#sidebarViewOnLoad=0&_pagemode=none&_toolbar=0&view=FitH")),i.appendChild(r)}}(e)}))}}))}))}function ba(){var t;return t=fa().mark((function t(e){var n,i,r,s,a;return fa().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new TextEncoder,i=n.encode(e),t.next=4,crypto.subtle.digest("SHA-256",i);case 4:return r=t.sent,s=Array.from(new Uint8Array(r)),a=s.map((function(t){return t.toString(16).padStart(2,"0")})).join(""),t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})),ba=function(){var e=this,n=arguments;return new Promise((function(i,r){var s=t.apply(e,n);function a(t){ga(s,i,r,a,o,"next",t)}function o(t){ga(s,i,r,a,o,"throw",t)}a(void 0)}))},ba.apply(this,arguments)}function ya(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){o=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}(n);try{for(r.s();!(i=r.n()).done;){var s=i.value;if(_a.types.includes("*")||_a.types.includes(s.type)){var a=s.response_id,o=document.getElementById(a),l=o.querySelector(".lrn_response"),c=o.querySelector(".".concat(_a.class));c||(l.append((t=void 0,e=void 0,t=document.createElement("button"),e=document.createElement("span"),t.classList.add("lds-btn","lds-btn-secondary","lrn_btn",_a.class),e.append(_a.label),t.append(e),t)),(c=o.querySelector(".".concat(_a.class))).addEventListener("click",Aa))}}}catch(t){r.e(t)}finally{r.f()}}catch(t){M.A.error(t)}}()}))}function Aa(t){var e=t.srcElement.closest(".lrn_widget").getAttribute("id");A.questionsApp().question(e).resetResponse()}var xa="ERROR",Ea={_initialised:!1,elTimerWrapper:null,forceRenderTimer:!1,renderedCss:!1};function Sa(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:60;if(Ea._initialised)M.A.debug("Toggle timer already initialised, ignoring run();",xa);else{var n=document.querySelector(".lrn-sm");if(Ea.elTimerWrapper=document.querySelector(".lrn-timer-wrapper"),n&&Ea.elTimerWrapper){Ea.renderedCss||((t=document.createElement("style")).textContent="\n/* Learnosity toggle timer styles */\n.lrn.lrn-assess .lrn-region:not(.lrn-items-region) .lrn_btn.lt__timer-button {\n font-size: inherit;\n}\n\n.lrn-assess .lrn_btn.lt__timer-button .timer {\n padding: 8px;\n height: 29px;\n position: relative;\n top: -4px;\n}\n\n.lrn.lrn-assess .lt__timer-wrapper.lt__timer-hide .lrn_btn.lt__timer-button .timer .clock:before {\n padding-right: 0;\n}\n\n.lrn-timer-wrapper.lt__timer-hide .lt__timer-button .timer > *:not(.clock) {\n display: none;\n}\n",document.head.append(t),Ea.renderedCss=!0),Ea._initialised=!0;var i=Array.from(Ea.elTimerWrapper.children),r=document.createElement("button");r.classList.add("lrn_btn","lt__timer-button"),r.setAttribute("type","button"),r.setAttribute("aria-label","".concat(Ea.elTimerWrapper.getAttribute("aria-label"),", click to toggle visibility of the timer.")),Ea.elTimerWrapper.innerHTML="",Ea.elTimerWrapper.appendChild(r),i.forEach((function(t){r.appendChild(t)})),r.addEventListener("click",(function(){Ta()})),A.appInstance().on("time:change",(function(){var t=x.timeRemaining();!Ea.forceRenderTimer&&"number"==typeof t&&t<=Number(e)&&Ea.elTimerWrapper.classList.contains("lt__timer-hide")&&(Ea.forceRenderTimer=!0,Ea.elTimerWrapper.classList.remove("lt__timer-hide"),M.A.info("Force show the timer limit (".concat(e,") reached.")))}))}else M.A.warn("Timer wrapper, or `lrn-sm`, not found")}}function Ta(){Ea.elTimerWrapper.classList.toggle("lt__timer-hide")}var Ca=n(4196),ka={elementId:null,player:{instances:{beach:null,birds:null,wind:null,thunder:null,campfire:null,rain:null},sound:null,volume:null},playlist:{beach:"https://assets.learnosity.com/learnosity_toolkit/whitenoise/beach.mp3",birds:"https://assets.learnosity.com/learnosity_toolkit/whitenoise/birds.mp3",wind:"https://assets.learnosity.com/learnosity_toolkit/whitenoise/wind.mp3",thunder:"https://assets.learnosity.com/learnosity_toolkit/whitenoise/thunder.mp3",campfire:"https://assets.learnosity.com/learnosity_toolkit/whitenoise/campfire.mp3",rain:"https://assets.learnosity.com/learnosity_toolkit/whitenoise/rain.mp3"},queryRoot:document,renderedCss:!1};function Ma(t,e){ka.elementId=t||null,ka.queryRoot=e||document,ka.renderedCss||function(){var t=":root";ka.queryRoot!==document&&(t=":host");var e=document.createElement("style"),n="\n/* Learnosity white noise player styles */\n".concat(t,' {\n --lt-wn-border: #888888;\n --lt-wn-border-radius: 10px;\n --lt-wn-color: #333333;\n --lt-wn-svg-size: 4rem;\n --lt-wn-control-svg-size: 1.5rem;\n --lt-wn-range-size: 15rem;\n --lt-wn-min-height: 19rem;\n}\n\n@container (max-width: 300px) {\n .lt__player {\n min-height: var(--lt-wn-min-height);\n svg {\n --lt-wn-svg-size: 3rem;\n }\n .lt__control-wrapper {\n svg {\n --lt-wn-control-svg-size: 1rem;\n }\n input[type="range"] {\n --lt-wn-range-size: 10rem;\n }\n }\n }\n}\n\n.lt__player {\n container-type: size;\n background-color: #fff;\n width: 100%;\n max-width: 30rem;\n min-height: var(--lt-wn-min-height);\n border: 1px solid #dddddd;\n border-radius: var(--lt-wn-border-radius);\n padding: 1rem;\n filter: drop-shadow(4px 5px 7px #8d8d8d);\n font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;\n color: var(--lt-wn-color);\n margin: 0 auto;\n}\n.lt__player svg {\n width: var(--lt-wn-svg-size);\n height: var(--lt-wn-svg-size);\n display: inline;\n}\n.lt__meta ul {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n list-style: none;\n text-align: center;\n margin: 0;\n padding: 0;\n}\n.lt__meta ul li {\n box-sizing: border-box;\n border-radius: var(--lt-wn-border-radius);\n border: 1px solid var(--lt-wn-border);\n margin: 0.3rem;\n\n &:hover {\n background-color: #f2f4f5;\n }\n}\n.lt__meta ul li button {\n display: block;\n text-decoration: none;\n border-radius: inherit;\n width: 100%;\n border: none;\n background: none;\n\n &:hover,\n &:focus {\n outline: 5px auto -webkit-focus-ring-color;\n outline-offset: -2px;\n background-color: #f2f4f5;\n }\n\n &:active {\n box-shadow: 0 0 0 0.25rem rgba(49, 132, 253, 0.5);\n }\n}\n.lt__meta ul li button.lt__sound-active {\n box-shadow: 0 0 0 0.25rem rgba(49, 132, 253, 0.5);\n background: #efefef;\n}\n.lt__meta ul li svg {\n padding: 1rem 1rem 0.3rem 1rem;\n vertical-align: middle;\n}\n.lt__control-wrapper svg {\n width: var(--lt-wn-control-svg-size);\n}\n.lt__control-wrapper svg:last-child {\n position: relative;\n left: 0.6rem;\n}\n.lt__sound-label {\n display: block;\n padding-bottom: 0.7rem;\n}\n.lt__toolbar {\n margin-top: 0.5rem;\n text-align: center;\n}\n.lt__control-wrapper label {\n text-align: center;\n padding-bottom: 0;\n margin-bottom: 0;\n display: block;\n position: relative;\n top: 10px;\n}\n.lt__control-wrapper button {\n background: none;\n border: none;\n cursor: pointer;\n}\ninput[type="range"] {\n -webkit-appearance: none;\n appearance: none;\n background: transparent;\n cursor: pointer;\n width: var(--lt-wn-range-size);\n}\n/* Removes default focus */\ninput[type="range"]:focus {\n outline: none;\n}\ninput[type="range"]::-webkit-slider-runnable-track {\n background-color: #01243d;\n border-radius: 0.5rem;\n height: 0.5rem;\n}\ninput[type="range"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n margin-top: -12px;\n background-color: #fff;\n border: 2px solid #01243d;\n height: 2rem;\n width: 1rem;\n}\ninput[type="range"]:focus::-webkit-slider-thumb {\n border: 1px solid #01243d;\n outline: 3px solid #01243d;\n outline-offset: 0.125rem;\n}\ninput[type="range"]::-moz-range-track {\n background-color: #01243d;\n border-radius: 0.5rem;\n height: 0.5rem;\n}\ninput[type="range"]::-moz-range-thumb {\n border: none;\n border-radius: 0;\n border: 1px solid #01243d;\n background-color: #fff;\n height: 2rem;\n width: 1rem;\n}\ninput[type="range"]:focus::-moz-range-thumb {\n border: 1px solid #01243d;\n outline: 3px solid #01243d;\n outline-offset: 0.125rem;\n}\n\n@media (max-width: 400px) {\n .lt__meta ul {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n }\n input[type="range"] {\n width: 10rem;\n }\n}\n\n.lt__whitenoise-player-icon::before {\n content: url(\'data:image/svg+xml,\');\n width: 16px;\n color: var(--lt-wn-color);\n margin-top: 0;\n font-size: 16px;\n -webkit-transition: color .2s;\n transition: color .2s;\n -webkit-font-smoothing: antialiased;\n}\n');e.textContent=n,ka.queryRoot===document?document.head.append(e):ka.queryRoot.appendChild(e),ka.renderedCss=!0}();try{A.assessApp().on("button:btn-whitenoise:clicked",(function(){Ia()}))}catch(t){t instanceof TypeError||console.log("Error with white noise player:",t)}}function Ia(){var t='';if(ka.elementId&&!ka.shadowRoot){var e=ka.queryRoot.querySelector("#".concat(ka.elementId));if(!e)return void M.A.error("Element id '".concat(ka.elementId,"' not found, could not render player."));e.innerHTML=t}else if(ka.elementId&&ka.queryRoot!==document){var n=ka.queryRoot.querySelector("#".concat(ka.elementId));if(console.log(n),!n)return void M.A.error("Shadow root element id '".concat(ka.elementId,"' not found, could not render player."));n.innerHTML=t}else I.dialog({header:"White noise player",body:t,buttons:[{button_id:"dialog_btn_whitenoise_player",label:"Close",is_primary:!1}]});setTimeout((function(){var t=ka.queryRoot.querySelectorAll(".lt__controls-sound"),e=ka.queryRoot.querySelector("#ld-volume");t.forEach((function(t){t.addEventListener("keydown",(function(e){" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),t.click())})),t.addEventListener("click",(function(e){e.preventDefault(),function(t){var e=t.getAttribute("data-lt-sound"),n=ka.queryRoot.querySelector('[data-lt-sound="'.concat(e,'"]'));ka.player.sound&&La(ka.player.sound),n.classList.contains("lt__sound-active")?La(e):(ka.player.instances[e]||function(t){ka.player.instances[t]=new Ca.Howl({src:[ka.playlist[t]],html5:!0,loop:!0})}(e),ka.player.sound=e,function(t){ka.player.instances[t].play()}(e)),Ra(e)}(t)}))})),ka.player.sound&&Ra(ka.player.sound),e.value=ka.player.volume||1,Pa(),e.addEventListener("input",(function(){Pa()}))}),500);try{A.assessApp().on("button:dialog_btn_whitenoise_player:clicked",(function(){I.hideDialog()}))}catch(t){t instanceof TypeError||console.log("Error with white noise player:",t)}}function La(t){ka.player.instances[t].stop()}function Pa(){var t=ka.queryRoot.querySelector("#ld-volume"),e=ka.queryRoot.querySelector("#ld-volume-value"),n=t.value;ka.player.volume=n,Ca.Howler.volume(n),e.innerHTML=100*n}function Ra(t){ka.queryRoot.querySelectorAll(".lt__controls-sound").forEach((function(e){e.getAttribute("data-lt-sound")!==t||e.classList.contains("lt__sound-active")?(e.classList.remove("lt__sound-active"),e.setAttribute("aria-pressed","false")):(e.classList.add("lt__sound-active"),e.focus(),e.setAttribute("aria-pressed","true"))}))}function Da(t){return Da="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Da(t)}function Fa(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function Oa(t){for(var e=1;e{n.d(e,{r:()=>i});var i="2.22.1"},8097:(t,e,n)=>{n.d(e,{LT:()=>g});var i=n(4113),r=n(173),s=n(3674),a=n(7518),o=n(77),l=n(3963),c=n(7028);function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function h(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function u(t){for(var e=1;e{n.r(e),n.d(e,{activity:()=>a,activityId:()=>o,activitySubTitle:()=>d,activityTags:()=>h,activityTemplateId:()=>l,activityTitle:()=>c,adaptiveType:()=>u,annotationsConfig:()=>p,autoSaveConfig:()=>f,elapsedTime:()=>g,hasActivityTemplate:()=>m,hasAnnotations:()=>v,hasAnswerMasking:()=>b,hasAutoSave:()=>y,hasEvents:()=>w,hasItemPool:()=>A,hasLineReader:()=>x,hasResourceItems:()=>E,hasSections:()=>S,hasShuffledItems:()=>_,hasTryAgain:()=>T,isAdaptive:()=>C,isResuming:()=>k,itemBank:()=>M,itemPool:()=>I,maxTime:()=>L,region:()=>P,resourceItems:()=>R,sessionId:()=>D,state:()=>F,timeRemaining:()=>O,totalItems:()=>N,userId:()=>B});var i=n(4113),r=n(7028),s=n(5059);function a(){return i.appInstance().getActivity()}function o(){return a().activity_id}function l(){return a().activity_template_id}function c(){return a().config.title}function d(){return a().config.subtitle}function h(){return i.appInstance().getTags()}function u(){return C()&&a().adaptive.hasOwnProperty("type")?a().adaptive.type:""}function p(){var t;return v()&&null!==(t=a())&&void 0!==t&&null!==(t=t.config)&&void 0!==t&&t.annotations_api_init_options?a().config.annotations_api_init_options:{}}function f(){var t,e=a();return null!=e&&null!==(t=e.config)&&void 0!==t&&null!==(t=t.navigation)&&void 0!==t&&t.auto_save?e.config.navigation.auto_save:{}}function g(){return i.appInstance().getTime()}function m(){return a().hasOwnProperty("activity_template_id")}function v(){var t,e,n=a();return Boolean(!0===(null==n||null===(t=n.config)||void 0===t?void 0:t.annotations)||(null==n||null===(e=n.config)||void 0===e?void 0:e.annotations_api_init_options))}function b(){return!!document.querySelector(".test-answer-masking")}function y(){var t=a();return t.hasOwnProperty("config")&&t.config.hasOwnProperty("navigation")&&t.config.navigation.hasOwnProperty("auto_save")&&!1!==t.config.navigation.auto_save}function _(){var t;return Boolean(null===(t=a())||void 0===t||null===(t=t.config)||void 0===t||null===(t=t.configuration)||void 0===t?void 0:t.shuffle_items)}function w(){var t=a();return t.hasOwnProperty("events")&&!1!==t.events}function A(){return a().hasOwnProperty("item_pool_id")}function x(){return!!document.querySelector(".lrn_linereader-toggle")}function E(){var t;return Boolean(null===(t=a())||void 0===t||null===(t=t.config)||void 0===t||null===(t=t.navigation)||void 0===t?void 0:t.resource_items)}function S(){return a().hasOwnProperty("sections")}function T(){var t;return null===(t=a())||void 0===t?void 0:t.dynamic_items.hasOwnProperty("try_again")}function C(){return a().hasOwnProperty("adaptive")}function k(){return a().existing_session}function M(){var t;return null===(t=a())||void 0===t?void 0:t.organisation_id}function I(){var t;return null===(t=a())||void 0===t?void 0:t.item_pool_id}function L(){var t;return null!==(t=a())&&void 0!==t&&null!==(t=t.config)&&void 0!==t&&null!==(t=t.time)&&void 0!==t&&t.max_time?a().config.time.max_time:0}function P(){var t;return null===(t=a())||void 0===t||null===(t=t.config)||void 0===t?void 0:t.regions}function R(){var t;return null===(t=a())||void 0===t||null===(t=t.config)||void 0===t||null===(t=t.navigation)||void 0===t?void 0:t.resource_items}function D(){var t;return null===(t=a())||void 0===t?void 0:t.session_id}function F(){var t;return void 0===(null===(t=a())||void 0===t?void 0:t.state)?"initial":a().state}function O(){return 0===L()?null:L()-g()}function N(){if(S()){for(var t=0,e=r.sections(),n=0;n{n.r(e),n.d(e,{annotationsApp:()=>l,appInstance:()=>o,assessApp:()=>c,eventsApp:()=>d,init:()=>a,questionsApp:()=>h});var i=n(3674),r=n(3963),s={};function a(t){s.app=t,s.app.on("all",(function(t){(0,i.handleEvent)(t)})),s.app.on("item:load",(function(t){(0,r.questionResponseIds)().forEach((function(t){s.app.question(t).on("changed",(function(t){(0,i.handleEvent)("changed")})),s.app.question(t).on("beforeValidate",(function(t){(0,i.handleEvent)("beforeValidate")})),s.app.question(t).on("rendered",(function(t){(0,i.handleEvent)("rendered")})),s.app.question(t).on("validated",(function(t){(0,i.handleEvent)("validated")}))}))}))}function o(){return s.app}function l(){return void 0!==o().annotationsApp()?o().annotationsApp():null}function c(){return o().assessApp()}function d(){return o().eventsApp()}function h(){return o().questionsApp()}},3674:(t,e,n)=>{n.r(e),n.d(e,{diagnostics:()=>l,filterEvent:()=>c,handleEvent:()=>d,listen:()=>h});var i=n(4113),r=n(173),s=n(5059),a=n(2201),o={events:{broadcast:!1,listenFor:"item"}};function l(){var t=window.LearnosityApp?LearnosityApp.versions:{};return{apps:{annotations:{app:i.annotationsApp(),config:r.annotationsConfig(),enabled:r.hasAnnotations()},assess:{app:i.assessApp()},events:{app:i.eventsApp(),enabled:r.hasEvents()},items:{app:i.appInstance(),metadata:r.activity().config.metadata},questions:{app:i.questionsApp()}},activity:{activity:r.activityId(),activityTemplate:r.activityTemplateId(),autoSave:{config:r.autoSaveConfig(),enabled:r.hasAutoSave()},itemBank:r.itemBank(),itemPool:r.itemPool(),session:r.sessionId(),state:r.state(),type:r.activity().type,user:r.userId()},LT:{version:a.r},versions:t}}function c(t){/^[a-zA-Z:*]*$/.test(t)?o.events.listenFor=t:s.A.warn("Invalid event type")}function d(t){if(o.events.broadcast){var e=o.events.listenFor,n=e.replaceAll("*","");1===e.length&&"*"===e||"all"===e?s.A.info(t):e.startsWith("*")&&!e.endsWith("*")?t.endsWith(n)&&s.A.info(t):e.endsWith("*")&&!e.startsWith("*")?t.startsWith(n)&&s.A.info(t):e.startsWith("*")&&e.endsWith("*")?t.includes(n)&&s.A.info(t):t.startsWith(n)&&s.A.info(t)}}function h(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];o.events.broadcast=Boolean(t),Boolean(t)?s.A.info("👂 listening for '".concat(o.events.listenFor,"'")):s.A.info("🚫👂 not listening")}},7518:(t,e,n)=>{n.r(e),n.d(e,{dynamic:()=>l,flag:()=>c,isDynamicItem:()=>d,isFirstItem:()=>h,isFlagged:()=>p,isItemFullyAttempted:()=>f,isLastItem:()=>u,isMaskingEnabled:()=>g,item:()=>m,itemAttemptStatus:()=>v,itemByResponseId:()=>b,itemElement:()=>y,itemPosition:()=>_,itemReference:()=>w,itemTags:()=>A});var i=n(4113),r=n(173),s=n(3963),a=n(7028);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function l(){var t=w();return i.assessApp().item(t).dynamic||{}}function c(){var t=w();i.assessApp().item(t).flag()}function d(){var t;return null===(t=m())||void 0===t?void 0:t.source.hasOwnProperty("data_table_seed")}function h(){return r.hasSections()?("object"===o(a.sections()[0].items[0])?a.sections()[0].items[0].reference:a.sections()[0].items[0])===m().reference:("object"===o(r.activity().items[0])?r.activity().items[0].reference:r.activity().items[0])===m().reference}function u(){return m().is_last_item}function p(){return m().user_flagged}function f(t){var e,n,r;if(e=t?i.appInstance().getItems()[t].questions:s.questions(),Array.isArray(e)&&e.length)for(var a=0;a{n.r(e),n.d(e,{answerMasking:()=>o,dialog:()=>l,hideDialog:()=>c,isResponsiveMode:()=>d,isReviewScreen:()=>h,lineReader:()=>u,navigate:()=>p,next:()=>f,previous:()=>g,review:()=>m,submit:()=>v}),n(173);var i=n(4113),r=n(7518),s=n(5059),a={answerMasking:{enabled:null},lineReader:{enabled:null,id:null}};function o(t){if(null===a.answerMasking.enabled){var e=document.querySelector(".test-answer-masking");a.answerMasking.enabled=!!e}a.answerMasking.enabled?void 0!==t&&i.appInstance().questionsApp().masking(t):s.A.warn("Answer masking is not enabled in the Items API configuration.")}function l(t){i.assessApp().dialogs().custom.show(t)}function c(){i.assessApp().dialogs().custom.hide()}function d(){return Boolean(document.querySelector(".has-menu-region"))}function h(){var t=!1;setTimeout((function(){return null===document.getElementsByClassName("review-screen")[0].getAttribute("aria-hidden")&&(t=!0),t}),500)}function u(t){if(null===a.lineReader.enabled){var e=document.querySelector(".lrn_linereader-toggle");if(e){a.lineReader.enabled=!0;var n=e.querySelector("[data-lrn-widget-container]").getAttribute("data-lrn-widget-container").match(/\d+$/);n?a.lineReader.id=n[0]:s.A.warn("Could not find the line reader unique id.")}else a.lineReader.enabled=!1}if(a.lineReader.enabled&&null!==a.lineReader.id){var r=i.appInstance().features()["lrn-assessapp-feature_".concat(a.lineReader.id)];switch(t){case"show":r.show();break;case"hide":r.hide();break;default:r.toggle()}}else s.A.warn("Line reader is not enabled in the Items API configuration.")}function p(t){switch(t){case"previous":i.appInstance().items().previous();break;case"next":r.isLastItem()||i.appInstance().items().next();break;case"review":null===document.getElementsByClassName("review-screen")[0].getAttribute("aria-hidden")?i.appInstance().dialogs().reviewScreen.hide():i.appInstance().dialogs().reviewScreen.show();break;case"submit":var e={show_submit_confirmation:!0,show_submit_ui:!0,success:function(t){alert("Test saved!")},error:function(t){alert("Test submit failed...check browser log"),console.log("Submission failed: ",t)}};i.appInstance().submit(e);break;default:"number"==typeof Number(t)&&Number(t)>=0?i.appInstance().items().goto(Number(t)):s.A.warn("Invalid target (".concat(t,")"))}}function f(){p("next")}function g(){p("previous")}function m(){p("review")}function v(){p("submit")}},3963:(t,e,n)=>{n.r(e),n.d(e,{hasCheckAnswer:()=>o,isAutoScorable:()=>l,question:()=>c,questionInstance:()=>d,questionResponse:()=>u,questionResponseIds:()=>p,questionScore:()=>f,questions:()=>h});var i=n(4113),r=n(7518),s=n(173),a=n(5059);function o(t){var e;if(!l(t))return!1;var n=(null===(e=(0,s.activity)())||void 0===e||null===(e=e.config)||void 0===e||null===(e=e.questions_api_init_options)||void 0===e?void 0:e.attribute_overrides)&&(0,s.activity)().config.questions_api_init_options.attribute_overrides.hasOwnProperty("instant_feedback")&&"boolean"==typeof(0,s.activity)().config.questions_api_init_options.attribute_overrides.instant_feedback,i=c(t);return n?(0,s.activity)().config.questions_api_init_options.attribute_overrides.instant_feedback:!(!i.hasOwnProperty("instant_feedback")||"boolean"!=typeof i.instant_feedback)&&i.instant_feedback}function l(t){return c(t),d(t).checkValidation().has_validation}function c(t){var e=t||p()[0];return e?i.appInstance().question(e).getQuestion():(a.A.error("Question not found (index ".concat(e,")")),{})}function d(t){var e=t||p()[0];return e?i.appInstance().question(e):{}}function h(){return r.item().questions}function u(t){var e=t||p()[0];return e?function(t){return i.appInstance().question(t)?i.appInstance().question(t).getResponse():void a.A.error("Response not found ".concat(t))}(e):{}}function p(){return h().map((function(t){return t.response_id}))}function f(t){var e=t||p()[0];return e&&i.appInstance().getScores()[e]||{}}},7028:(t,e,n)=>{n.r(e),n.d(e,{isFirstItemInSection:()=>s,isLastItemInSection:()=>a,section:()=>o,sectionHasShuffledItems:()=>l,sectionIndex:()=>c,sectionItemPosition:()=>d,sections:()=>h,totalItemsInSection:()=>u});var i=n(173),r=n(7518);function s(){return 1===d()}function a(){return d()===u()}function o(){if(i.hasSections()){for(var t=r.itemReference(),e=h(),n=-1,s=!1,a=0;a{n.d(e,{A:()=>i});const i={debug:function(t,e){"DEBUG"===e&&console.log(t)},error:function(t){console.error("%cError:%c "+t,"display:inline-block;background-color:#e0005a;color:#fff;font-weight:bold;padding:3px 7px;border-radius:3px","")},info:function(t){console.info("%cInfo:%c "+t,"display:inline-block;background-color:#46C0FF;color:#000;font-weight:bold;padding:3px 7px;border-radius:3px","")},log:function(t){console.log(t)},warn:function(t){console.warn("%cWarning:%c "+t,"display:inline-block;background-color:gold;color:#000;font-weight:bold;padding:3px 7px;border-radius:3px","")}}},4196:(t,e,n)=>{var i;!function(){var r=function(){this.init()};r.prototype={init:function(){var t=this||s;return t._counter=1e3,t._html5AudioPool=[],t.html5PoolSize=10,t._codecs={},t._howls=[],t._muted=!1,t._volume=1,t._canPlayEvent="canplaythrough",t._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,t.masterGain=null,t.noAudio=!1,t.usingWebAudio=!0,t.autoSuspend=!0,t.ctx=null,t.autoUnlock=!0,t._setup(),t},volume:function(t){var e=this||s;if(t=parseFloat(t),e.ctx||p(),void 0!==t&&t>=0&&t<=1){if(e._volume=t,e._muted)return e;e.usingWebAudio&&e.masterGain.gain.setValueAtTime(t,s.ctx.currentTime);for(var n=0;n=0;e--)t._howls[e].unload();return t.usingWebAudio&&t.ctx&&void 0!==t.ctx.close&&(t.ctx.close(),t.ctx=null,p()),t},codecs:function(t){return(this||s)._codecs[t.replace(/^x-/,"")]},_setup:function(){var t=this||s;if(t.state=t.ctx&&t.ctx.state||"suspended",t._autoSuspend(),!t.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(t._canPlayEvent="canplay")}catch(e){t.noAudio=!0}else t.noAudio=!0;try{(new Audio).muted&&(t.noAudio=!0)}catch(t){}return t.noAudio||t._setupCodecs(),t},_setupCodecs:function(){var t=this||s,e=null;try{e="undefined"!=typeof Audio?new Audio:null}catch(e){return t}if(!e||"function"!=typeof e.canPlayType)return t;var n=e.canPlayType("audio/mpeg;").replace(/^no$/,""),i=t._navigator?t._navigator.userAgent:"",r=i.match(/OPR\/(\d+)/g),a=r&&parseInt(r[0].split("/")[1],10)<33,o=-1!==i.indexOf("Safari")&&-1===i.indexOf("Chrome"),l=i.match(/Version\/(.*?) /),c=o&&l&&parseInt(l[1],10)<15;return t._codecs={mp3:!(a||!n&&!e.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!n,opus:!!e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(e.canPlayType('audio/wav; codecs="1"')||e.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!e.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!e.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/m4a;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(e.canPlayType("audio/x-m4b;")||e.canPlayType("audio/m4b;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(e.canPlayType("audio/x-mp4;")||e.canPlayType("audio/mp4;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(c||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(c||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!e.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(e.canPlayType("audio/x-flac;")||e.canPlayType("audio/flac;")).replace(/^no$/,"")},t},_unlockAudio:function(){var t=this||s;if(!t._audioUnlocked&&t.ctx){t._audioUnlocked=!1,t.autoUnlock=!1,t._mobileUnloaded||44100===t.ctx.sampleRate||(t._mobileUnloaded=!0,t.unload()),t._scratchBuffer=t.ctx.createBuffer(1,1,22050);var e=function(n){for(;t._html5AudioPool.length0?o._seek:n._sprite[t][0]/1e3),d=Math.max(0,(n._sprite[t][0]+n._sprite[t][1])/1e3-c),h=1e3*d/Math.abs(o._rate),u=n._sprite[t][0]/1e3,p=(n._sprite[t][0]+n._sprite[t][1])/1e3;o._sprite=t,o._ended=!1;var f=function(){o._paused=!1,o._seek=c,o._start=u,o._stop=p,o._loop=!(!o._loop&&!n._sprite[t][2])};if(!(c>=p)){var g=o._node;if(n._webAudio){var m=function(){n._playLock=!1,f(),n._refreshBuffer(o);var t=o._muted||n._muted?0:o._volume;g.gain.setValueAtTime(t,s.ctx.currentTime),o._playStart=s.ctx.currentTime,void 0===g.bufferSource.start?o._loop?g.bufferSource.noteGrainOn(0,c,86400):g.bufferSource.noteGrainOn(0,c,d):o._loop?g.bufferSource.start(0,c,86400):g.bufferSource.start(0,c,d),h!==1/0&&(n._endTimers[o._id]=setTimeout(n._ended.bind(n,o),h)),e||setTimeout((function(){n._emit("play",o._id),n._loadQueue()}),0)};"running"===s.state&&"interrupted"!==s.ctx.state?m():(n._playLock=!0,n.once("resume",m),n._clearTimer(o._id))}else{var v=function(){g.currentTime=c,g.muted=o._muted||n._muted||s._muted||g.muted,g.volume=o._volume*s.volume(),g.playbackRate=o._rate;try{var i=g.play();if(i&&"undefined"!=typeof Promise&&(i instanceof Promise||"function"==typeof i.then)?(n._playLock=!0,f(),i.then((function(){n._playLock=!1,g._unlocked=!0,e?n._loadQueue():n._emit("play",o._id)})).catch((function(){n._playLock=!1,n._emit("playerror",o._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),o._ended=!0,o._paused=!0}))):e||(n._playLock=!1,f(),n._emit("play",o._id)),g.playbackRate=o._rate,g.paused)return void n._emit("playerror",o._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");"__default"!==t||o._loop?n._endTimers[o._id]=setTimeout(n._ended.bind(n,o),h):(n._endTimers[o._id]=function(){n._ended(o),g.removeEventListener("ended",n._endTimers[o._id],!1)},g.addEventListener("ended",n._endTimers[o._id],!1))}catch(t){n._emit("playerror",o._id,t)}};"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===g.src&&(g.src=n._src,g.load());var b=window&&window.ejecta||!g.readyState&&s._navigator.isCocoonJS;if(g.readyState>=3||b)v();else{n._playLock=!0,n._state="loading";var y=function(){n._state="loaded",v(),g.removeEventListener(s._canPlayEvent,y,!1)};g.addEventListener(s._canPlayEvent,y,!1),n._clearTimer(o._id)}}return o._id}n._ended(o)},pause:function(t){var e=this;if("loaded"!==e._state||e._playLock)return e._queue.push({event:"pause",action:function(){e.pause(t)}}),e;for(var n=e._getSoundIds(t),i=0;i=0?e=parseInt(r[0],10):t=parseFloat(r[0]):r.length>=2&&(t=parseFloat(r[0]),e=parseInt(r[1],10)),!(void 0!==t&&t>=0&&t<=1))return(n=e?i._soundById(e):i._sounds[0])?n._volume:0;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"volume",action:function(){i.volume.apply(i,r)}}),i;void 0===e&&(i._volume=t),e=i._getSoundIds(e);for(var a=0;a0?i/c:i),h=Date.now();t._fadeTo=n,t._interval=setInterval((function(){var r=(Date.now()-h)/i;h=Date.now(),o+=l*r,o=Math.round(100*o)/100,o=l<0?Math.max(n,o):Math.min(n,o),a._webAudio?t._volume=o:a.volume(o,t._id,!0),s&&(a._volume=o),(ne&&o>=n)&&(clearInterval(t._interval),t._interval=null,t._fadeTo=null,a.volume(n,t._id),a._emit("fade",t._id))}),d)},_stopFade:function(t){var e=this,n=e._soundById(t);return n&&n._interval&&(e._webAudio&&n._node.gain.cancelScheduledValues(s.ctx.currentTime),clearInterval(n._interval),n._interval=null,e.volume(n._fadeTo,t),n._fadeTo=null,e._emit("fade",t)),e},loop:function(){var t,e,n,i=this,r=arguments;if(0===r.length)return i._loop;if(1===r.length){if("boolean"!=typeof r[0])return!!(n=i._soundById(parseInt(r[0],10)))&&n._loop;t=r[0],i._loop=t}else 2===r.length&&(t=r[0],e=parseInt(r[1],10));for(var s=i._getSoundIds(e),a=0;a=0?e=parseInt(r[0],10):t=parseFloat(r[0]):2===r.length&&(t=parseFloat(r[0]),e=parseInt(r[1],10)),"number"!=typeof t)return(n=i._soundById(e))?n._rate:i._rate;if("loaded"!==i._state||i._playLock)return i._queue.push({event:"rate",action:function(){i.rate.apply(i,r)}}),i;void 0===e&&(i._rate=t),e=i._getSoundIds(e);for(var a=0;a=0?e=parseInt(i[0],10):n._sounds.length&&(e=n._sounds[0]._id,t=parseFloat(i[0])):2===i.length&&(t=parseFloat(i[0]),e=parseInt(i[1],10)),void 0===e)return 0;if("number"==typeof t&&("loaded"!==n._state||n._playLock))return n._queue.push({event:"seek",action:function(){n.seek.apply(n,i)}}),n;var r=n._soundById(e);if(r){if(!("number"==typeof t&&t>=0)){if(n._webAudio){var a=n.playing(e)?s.ctx.currentTime-r._playStart:0,o=r._rateSeek?r._rateSeek-r._seek:0;return r._seek+(o+a*Math.abs(r._rate))}return r._node.currentTime}var l=n.playing(e);l&&n.pause(e,!0),r._seek=t,r._ended=!1,n._clearTimer(e),n._webAudio||!r._node||isNaN(r._node.duration)||(r._node.currentTime=t);var c=function(){l&&n.play(e,!0),n._emit("seek",e)};if(l&&!n._webAudio){var d=function(){n._playLock?setTimeout(d,0):c()};setTimeout(d,0)}else c()}return n},playing:function(t){var e=this;if("number"==typeof t){var n=e._soundById(t);return!!n&&!n._paused}for(var i=0;i=0&&s._howls.splice(i,1);var r=!0;for(n=0;n=0){r=!1;break}return l&&r&&delete l[t._src],s.noAudio=!1,t._state="unloaded",t._sounds=[],t=null,null},on:function(t,e,n,i){var r=this["_on"+t];return"function"==typeof e&&r.push(i?{id:n,fn:e,once:i}:{id:n,fn:e}),this},off:function(t,e,n){var i=this,r=i["_on"+t],s=0;if("number"==typeof e&&(n=e,e=null),e||n)for(s=0;s=0;s--)r[s].id&&r[s].id!==e&&"load"!==t||(setTimeout(function(t){t.call(this,e,n)}.bind(i,r[s].fn),0),r[s].once&&i.off(t,r[s].fn,r[s].id));return i._loadQueue(t),i},_loadQueue:function(t){var e=this;if(e._queue.length>0){var n=e._queue[0];n.event===t&&(e._queue.shift(),e._loadQueue()),t||n.action()}return e},_ended:function(t){var e=this,n=t._sprite;if(!e._webAudio&&t._node&&!t._node.paused&&!t._node.ended&&t._node.currentTime=0;i--){if(n<=e)return;t._sounds[i]._ended&&(t._webAudio&&t._sounds[i]._node&&t._sounds[i]._node.disconnect(0),t._sounds.splice(i,1),n--)}}},_getSoundIds:function(t){if(void 0===t){for(var e=[],n=0;n=0;if(!t.bufferSource)return this;if(s._scratchBuffer&&t.bufferSource&&(t.bufferSource.onended=null,t.bufferSource.disconnect(0),e))try{t.bufferSource.buffer=s._scratchBuffer}catch(t){}return t.bufferSource=null,this},_clearSound:function(t){/MSIE |Trident\//.test(s._navigator&&s._navigator.userAgent)||(t.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var o=function(t){this._parent=t,this.init()};o.prototype={init:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++s._counter,e._sounds.push(t),t.create(),t},create:function(){var t=this,e=t._parent,n=s._muted||t._muted||t._parent._muted?0:t._volume;return e._webAudio?(t._node=void 0===s.ctx.createGain?s.ctx.createGainNode():s.ctx.createGain(),t._node.gain.setValueAtTime(n,s.ctx.currentTime),t._node.paused=!0,t._node.connect(s.masterGain)):s.noAudio||(t._node=s._obtainHtml5Audio(),t._errorFn=t._errorListener.bind(t),t._node.addEventListener("error",t._errorFn,!1),t._loadFn=t._loadListener.bind(t),t._node.addEventListener(s._canPlayEvent,t._loadFn,!1),t._endFn=t._endListener.bind(t),t._node.addEventListener("ended",t._endFn,!1),t._node.src=e._src,t._node.preload=!0===e._preload?"auto":e._preload,t._node.volume=n*s.volume(),t._node.load()),t},reset:function(){var t=this,e=t._parent;return t._muted=e._muted,t._loop=e._loop,t._volume=e._volume,t._rate=e._rate,t._seek=0,t._rateSeek=0,t._paused=!0,t._ended=!0,t._sprite="__default",t._id=++s._counter,t},_errorListener:function(){var t=this;t._parent._emit("loaderror",t._id,t._node.error?t._node.error.code:0),t._node.removeEventListener("error",t._errorFn,!1)},_loadListener:function(){var t=this,e=t._parent;e._duration=Math.ceil(10*t._node.duration)/10,0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue()),t._node.removeEventListener(s._canPlayEvent,t._loadFn,!1)},_endListener:function(){var t=this,e=t._parent;e._duration===1/0&&(e._duration=Math.ceil(10*t._node.duration)/10,e._sprite.__default[1]===1/0&&(e._sprite.__default[1]=1e3*e._duration),e._ended(t)),t._node.removeEventListener("ended",t._endFn,!1)}};var l={},c=function(t){var e=t._src;if(l[e])return t._duration=l[e].duration,void u(t);if(/^data:[^;]+;base64,/.test(e)){for(var n=atob(e.split(",")[1]),i=new Uint8Array(n.length),r=0;r0?(l[e._src]=t,u(e,t)):n()};"undefined"!=typeof Promise&&1===s.ctx.decodeAudioData.length?s.ctx.decodeAudioData(t).then(i).catch(n):s.ctx.decodeAudioData(t,i,n)},u=function(t,e){e&&!t._duration&&(t._duration=e.duration),0===Object.keys(t._sprite).length&&(t._sprite={__default:[0,1e3*t._duration]}),"loaded"!==t._state&&(t._state="loaded",t._emit("load"),t._loadQueue())},p=function(){if(s.usingWebAudio){try{"undefined"!=typeof AudioContext?s.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?s.ctx=new webkitAudioContext:s.usingWebAudio=!1}catch(t){s.usingWebAudio=!1}s.ctx||(s.usingWebAudio=!1);var t=/iP(hone|od|ad)/.test(s._navigator&&s._navigator.platform),e=s._navigator&&s._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),n=e?parseInt(e[1],10):null;if(t&&n&&n<9){var i=/safari/.test(s._navigator&&s._navigator.userAgent.toLowerCase());s._navigator&&!i&&(s.usingWebAudio=!1)}s.usingWebAudio&&(s.masterGain=void 0===s.ctx.createGain?s.ctx.createGainNode():s.ctx.createGain(),s.masterGain.gain.setValueAtTime(s._muted?0:s._volume,s.ctx.currentTime),s.masterGain.connect(s.ctx.destination)),s._setup()}};void 0===(i=function(){return{Howler:s,Howl:a}}.apply(e,[]))||(t.exports=i),e.Howler=s,e.Howl=a,void 0!==n.g?(n.g.HowlerGlobal=r,n.g.Howler=s,n.g.Howl=a,n.g.Sound=o):"undefined"!=typeof window&&(window.HowlerGlobal=r,window.Howler=s,window.Howl=a,window.Sound=o)}(),function(){var t;HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var n=e._howls.length-1;n>=0;n--)e._howls[n].stereo(t);return e},HowlerGlobal.prototype.pos=function(t,e,n){var i=this;return i.ctx&&i.ctx.listener?(e="number"!=typeof e?i._pos[1]:e,n="number"!=typeof n?i._pos[2]:n,"number"!=typeof t?i._pos:(i._pos=[t,e,n],void 0!==i.ctx.listener.positionX?(i.ctx.listener.positionX.setTargetAtTime(i._pos[0],Howler.ctx.currentTime,.1),i.ctx.listener.positionY.setTargetAtTime(i._pos[1],Howler.ctx.currentTime,.1),i.ctx.listener.positionZ.setTargetAtTime(i._pos[2],Howler.ctx.currentTime,.1)):i.ctx.listener.setPosition(i._pos[0],i._pos[1],i._pos[2]),i)):i},HowlerGlobal.prototype.orientation=function(t,e,n,i,r,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;var o=a._orientation;return e="number"!=typeof e?o[1]:e,n="number"!=typeof n?o[2]:n,i="number"!=typeof i?o[3]:i,r="number"!=typeof r?o[4]:r,s="number"!=typeof s?o[5]:s,"number"!=typeof t?o:(a._orientation=[t,e,n,i,r,s],void 0!==a.ctx.listener.forwardX?(a.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(n,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(i,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(t,e,n,i,r,s),a)},Howl.prototype.init=(t=Howl.prototype.init,function(e){var n=this;return n._orientation=e.orientation||[1,0,0],n._stereo=e.stereo||null,n._pos=e.pos||null,n._pannerAttr={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:360,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:360,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:0,distanceModel:void 0!==e.distanceModel?e.distanceModel:"inverse",maxDistance:void 0!==e.maxDistance?e.maxDistance:1e4,panningModel:void 0!==e.panningModel?e.panningModel:"HRTF",refDistance:void 0!==e.refDistance?e.refDistance:1,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:1},n._onstereo=e.onstereo?[{fn:e.onstereo}]:[],n._onpos=e.onpos?[{fn:e.onpos}]:[],n._onorientation=e.onorientation?[{fn:e.onorientation}]:[],t.call(this,e)}),Howl.prototype.stereo=function(t,n){var i=this;if(!i._webAudio)return i;if("loaded"!==i._state)return i._queue.push({event:"stereo",action:function(){i.stereo(t,n)}}),i;var r=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===n){if("number"!=typeof t)return i._stereo;i._stereo=t,i._pos=[t,0,0]}for(var s=i._getSoundIds(n),a=0;a{var i;!function(r,s){if(r){for(var a,o={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},l={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},c={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},d={option:"alt",command:"meta",return:"enter",escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},h=1;h<20;++h)o[111+h]="f"+h;for(h=0;h<=9;++h)o[h+96]=h.toString();b.prototype.bind=function(t,e,n){var i=this;return t=t instanceof Array?t:[t],i._bindMultiple.call(i,t,e,n),i},b.prototype.unbind=function(t,e){return this.bind.call(this,t,(function(){}),e)},b.prototype.trigger=function(t,e){var n=this;return n._directMap[t+":"+e]&&n._directMap[t+":"+e]({},t),n},b.prototype.reset=function(){var t=this;return t._callbacks={},t._directMap={},t},b.prototype.stopCallback=function(t,e){if((" "+e.className+" ").indexOf(" mousetrap ")>-1)return!1;if(v(e,this.target))return!1;if("composedPath"in t&&"function"==typeof t.composedPath){var n=t.composedPath()[0];n!==t.target&&(e=n)}return"INPUT"==e.tagName||"SELECT"==e.tagName||"TEXTAREA"==e.tagName||e.isContentEditable},b.prototype.handleKey=function(){return this._handleKey.apply(this,arguments)},b.addKeycodes=function(t){for(var e in t)t.hasOwnProperty(e)&&(o[e]=t[e]);a=null},b.init=function(){var t=b(s);for(var e in t)"_"!==e.charAt(0)&&(b[e]=function(e){return function(){return t[e].apply(t,arguments)}}(e))},b.init(),r.Mousetrap=b,t.exports&&(t.exports=b),void 0===(i=function(){return b}.call(e,n,e,t))||(t.exports=i)}function u(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)}function p(t){if("keypress"==t.type){var e=String.fromCharCode(t.which);return t.shiftKey||(e=e.toLowerCase()),e}return o[t.which]?o[t.which]:l[t.which]?l[t.which]:String.fromCharCode(t.which).toLowerCase()}function f(t){return"shift"==t||"ctrl"==t||"alt"==t||"meta"==t}function g(t,e,n){return n||(n=function(){if(!a)for(var t in a={},o)t>95&&t<112||o.hasOwnProperty(t)&&(a[o[t]]=t);return a}()[t]?"keydown":"keypress"),"keypress"==n&&e.length&&(n="keydown"),n}function m(t,e){var n,i,r,s=[];for(n=function(t){return"+"===t?["+"]:(t=t.replace(/\+{2}/g,"+plus")).split("+")}(t),r=0;r1?function(t,e,s,a){function c(e){return function(){o=e,++i[t],clearTimeout(n),n=setTimeout(l,1e3)}}function h(e){d(s,e,t),"keyup"!==a&&(r=p(e)),setTimeout(l,10)}i[t]=0;for(var u=0;u0,s.tv=r.includes("TV"),l=navigator.getGamepads?Array.from(navigator.getGamepads()).filter((function(t){return null!=t})).length:0,s.gamepad=l>0,t("(orientation: portrait)",(function(t){s.portrait=t,s.landscape=!t,s.orientation=t?"portrait":"landscape",o("portrait",s.portrait),o("landscape",s.landscape),o("orientation",s.orientation)})),t("(any-pointer: coarse)",(function(t){e("touch",t),e("formfactor",d())&&c()})),t("(hover: hover)",(function(t){e("mouse",t),e("input",t?"mouse":"touch"),e("formfactor",d())&&c()}))}}return s.csp=s.uwp||!1,s.nwjs?s.dev="sdk"===process.versions["nw-flavor"]:s.electron?s.dev=process.execPath.replace(/\\/g,"/").includes("node_modules/electron/"):s.uwp?s.dev=Windows.ApplicationModel.Package.current.isDevelopmentMode:s.node?s.dev=!1:s.dev=void 0,s}()},7391:(t,e,n)=>{var i=n(7180),r=n(3181),s=n(3031),a=n(9067),o=n(6833),l=n(3717),c=n(4801);c.alea=i,c.xor128=r,c.xorwow=s,c.xorshift7=a,c.xor4096=o,c.tychei=l,t.exports=c},7180:function(t,e,n){var i;!function(t,r){function s(t){var e,n=this,i=(e=4022871197,function(t){t=String(t);for(var n=0;n>>0,e=(i*=e)>>>0,e+=4294967296*(i-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=i(" "),n.s1=i(" "),n.s2=i(" "),n.s0-=i(t),n.s0<0&&(n.s0+=1),n.s1-=i(t),n.s1<0&&(n.s1+=1),n.s2-=i(t),n.s2<0&&(n.s2+=1),i=null}function a(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function o(t,e){var n=new s(t),i=e&&e.state,r=n.next;return r.int32=function(){return 4294967296*n.next()|0},r.double=function(){return r()+11102230246251565e-32*(2097152*r()|0)},r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,r))||(r.exports=i):this.alea=o}(0,t=n.nmd(t),n.amdD)},3717:function(t,e,n){var i;!function(t,r){function s(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,i=e.d,r=e.a;return t=t<<25^t>>>7^n,n=n-i|0,i=i<<24^i>>>8^r,r=r-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-i|0,e.d=i<<16^n>>>16^r,e.a=r-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var i=0;i>>0)/4294967296};return r.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=n.next,r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,r))||(r.exports=i):this.tychei=o}(0,t=n.nmd(t),n.amdD)},3181:function(t,e,n){var i;!function(t,r){function s(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var i=0;i>>0)/4294967296};return r.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=n.next,r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,r))||(r.exports=i):this.xor128=o}(0,t=n.nmd(t),n.amdD)},6833:function(t,e,n){var i;!function(t,r){function s(t){var e=this;e.next=function(){var t,n,i=e.w,r=e.X,s=e.i;return e.w=i=i+1640531527|0,n=r[s+34&127],t=r[s=s+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=r[s]=n^t,e.i=s,n+(i^i>>>16)|0},function(t,e){var n,i,r,s,a,o=[],l=128;for(e===(0|e)?(i=e,e=null):(e+="\0",i=0,l=Math.max(l,e.length)),r=0,s=-32;s>>15,i^=i<<4,i^=i>>>13,s>=0&&(a=a+1640531527|0,r=0==(n=o[127&s]^=i+a)?r+1:0);for(r>=128&&(o[127&(e&&e.length||0)]=-1),r=127,s=512;s>0;--s)i=o[r+34&127],n=o[r=r+1&127],i^=i<<13,n^=n<<17,i^=i>>>15,n^=n>>>12,o[r]=i^n;t.w=a,t.X=o,t.i=r}(e,t)}function a(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function o(t,e){null==t&&(t=+new Date);var n=new s(t),i=e&&e.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=n.next,r.quick=r,i&&(i.X&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,r))||(r.exports=i):this.xor4096=o}(0,t=n.nmd(t),n.amdD)},9067:function(t,e,n){var i;!function(t,r){function s(t){var e=this;e.next=function(){var t,n,i=e.x,r=e.i;return t=i[r],n=(t^=t>>>7)^t<<24,n^=(t=i[r+1&7])^t>>>10,n^=(t=i[r+3&7])^t>>>3,n^=(t=i[r+4&7])^t<<7,t=i[r+7&7],n^=(t^=t<<13)^t<<9,i[r]=n,e.i=r+1&7,n},function(t,e){var n,i=[];if(e===(0|e))i[0]=e;else for(e=""+e,n=0;n0;--n)t.next()}(e,t)}function a(t,e){return e.x=t.x.slice(),e.i=t.i,e}function o(t,e){null==t&&(t=+new Date);var n=new s(t),i=e&&e.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=n.next,r.quick=r,i&&(i.x&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,r))||(r.exports=i):this.xorshift7=o}(0,t=n.nmd(t),n.amdD)},3031:function(t,e,n){var i;!function(t,r){function s(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var i=0;i>>4),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function o(t,e){var n=new s(t),i=e&&e.state,r=function(){return(n.next()>>>0)/4294967296};return r.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},r.int32=n.next,r.quick=r,i&&("object"==typeof i&&a(i,n),r.state=function(){return a(n,{})}),r}r&&r.exports?r.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,r))||(r.exports=i):this.xorwow=o}(0,t=n.nmd(t),n.amdD)},4801:function(t,e,n){var i;!function(r,s,a){var o,l=256,c=a.pow(l,6),d=a.pow(2,52),h=2*d,u=255;function p(t,e,n){var i=[],u=v(m((e=1==e?{entropy:!0}:e||{}).entropy?[t,b(s)]:null==t?function(){try{var t;return o&&(t=o.randomBytes)?t=t(l):(t=new Uint8Array(l),(r.crypto||r.msCrypto).getRandomValues(t)),b(t)}catch(t){var e=r.navigator,n=e&&e.plugins;return[+new Date,r,n,r.screen,b(s)]}}():t,3),i),p=new f(i),y=function(){for(var t=p.g(6),e=c,n=0;t=h;)t/=2,e/=2,n>>>=1;return(t+n)/e};return y.int32=function(){return 0|p.g(4)},y.quick=function(){return p.g(4)/4294967296},y.double=y,v(b(p.S),s),(e.pass||n||function(t,e,n,i){return i&&(i.S&&g(i,p),t.state=function(){return g(p,{})}),n?(a.random=t,e):t})(y,u,"global"in e?e.global:this==a,e.state)}function f(t){var e,n=t.length,i=this,r=0,s=i.i=i.j=0,a=i.S=[];for(n||(t=[n++]);r{}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var s=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}n.m=t,n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;if("string"==typeof import.meta.url&&(t=import.meta.url),!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t+"../"})(),n.b=new URL("../",import.meta.url);var i={};n.d(i,{LT:()=>qa});var r={};n.r(r),n.d(r,{run:()=>E});var s={};n.r(s),n.d(s,{run:()=>S});var a={};n.r(a),n.d(a,{run:()=>F});var o={};n.r(o),n.d(o,{run:()=>B});var l={};n.r(l),n.d(l,{escapeHTML:()=>$,getTabsTheme:()=>K,run:()=>W,validateOptions:()=>X});var c={};n.r(c),n.d(c,{run:()=>Q});var d={};n.r(d),n.d(d,{run:()=>_t});var h={};n.r(h),n.d(h,{run:()=>xe});var u={};n.r(u),n.d(u,{run:()=>ke});var p={};n.r(p),n.d(p,{run:()=>Le,setupButtons:()=>Pe,toggle:()=>Re});var f={};n.r(f),n.d(f,{run:()=>Be});var g={};n.r(g),n.d(g,{run:()=>$e});var m={};n.r(m),n.d(m,{halt:()=>en,run:()=>tn});var v={};n.r(v),n.d(v,{run:()=>va});var b={};n.r(b),n.d(b,{run:()=>wa});var y={};n.r(y),n.d(y,{run:()=>Sa,toggle:()=>Ta});var _={};n.r(_),n.d(_,{launchPlayer:()=>Ia,run:()=>Ma});var w=n(8097),A=n(4113),x=n(173);function E(){A.appInstance().on("item:load",(function(){for(var t=x.totalItems(),e=Array.from(document.getElementsByClassName("item-prev")),n=Array.from(document.getElementsByClassName("item-next")),i=e.concat(n),r=0;r=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){o=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}function P(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);nBefore moving on, attempt all questions and click the "Check Answer" button.
\n Note: the "Check Answer" button may not appear on every question.
'}};function F(t){var e,n;t&&null!=t&&t.message&&(null!==(e=D.message)&&void 0!==e&&e.header.length&&(D.message.header=t.message.header),null!==(n=D.message)&&void 0!==n&&n.body.length&&(D.message.body=t.message.body)),A.appInstance().on("item:beforeunload",(function(t){!function(t){(function(){var t,e=!1,n=L(k.questions());try{for(n.s();!(t=n.n()).done;){var i=t.value.response_id;if(k.hasCheckAnswer(i)){e=!0;break}}}catch(t){n.e(t)}finally{n.f()}return e})()&&(function(){var t,e=L(k.questions());try{for(e.s();!(t=e.n()).done;){var n=t.value.response_id;if(k.hasCheckAnswer(n)&&(!k.questionResponse(n)||!k.questionResponse(n).hasOwnProperty("feedbackAttemptsCount")))return!1}}catch(t){e.e(t)}finally{e.f()}return!0}()||(M.A.debug("Disabling navigation.",R),t.preventDefault(),(0,I.dialog)({header:D.message.header,body:D.message.body,buttons:[{button_id:"lt__check_answer_validation",label:"Close",is_primary:!1}]}),A.assessApp().on("button:lt__check_answer_validation:clicked",(function(){(0,I.hideDialog)()}))))}(t)}))}var O=n(7518),N={renderedCss:!1,resize:{triggered:!1}};function B(){var t;N.renderedCss||((t=document.createElement("style")).textContent="\n/* Learnosity column resizer styles */\n.lrn-resizer {\n background-color: #e8e8e8;\n cursor: grab;\n width: 3px;\n padding: 0;\n position: relative;\n}\n.lrn-resizer span {\n position: relative;\n width: 45px;\n height: 30px;\n border: 1px solid #e4e4e4;\n left: -22px;\n border-radius: 3px;\n cursor: grab;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.5em;\n z-index: 2;\n padding-bottom: 3px;\n color: #444;\n\n -webkit-user-select: none;\n user-select: none;\n\n background: rgb(233,233,233);\n background: linear-gradient(0deg, rgba(233,233,233,1) 0%, rgba(250,250,250,1) 51%, rgba(238,238,238,1) 100%);\n}\n.row {\n display: flex;\n}\n.col-xs-6.lrn-column-left {\n display: flex;\n min-width: 5em;\n overflow: hidden;\n}\n.col-xs-6.lrn-column-right {\n display: flex;\n\n flex: 1;\n display: flex;\n flex-direction: column;\n min-width: 5em;\n overflow: hidden;\n}\n.lrn-column-left .lrn_widget,\n.lrn-column-right .lrn_widget {\n padding: 1.5em;\n}\n@media (max-width: 650px) {\n .lrn-resizer {\n display: none;\n }\n}\n",document.head.append(t),N.renderedCss=!0),A.appInstance().on("item:load",(function(){q()})),window.addEventListener("resize",function(t){var e,n=this;return N.resize.triggered||(N.resize.triggered=!0,t.apply(this)),function(){for(var i=arguments.length,r=new Array(i),s=0;s=10&&a<=90&&(e.style.width=a+"%")},a=function(){document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",a),document.removeEventListener("touchmove",s),document.removeEventListener("touchend",a)};t.addEventListener("mousedown",r),t.addEventListener("touchstart",r)}(e)}(t)}}function H(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function j(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,i=Array(e);n=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){o=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}(n);try{for(r.s();!(i=r.n()).done;){var s=i.value,a=s.getAttribute("style");if(!a||!a.includes("--tab-count")){var o=s.querySelectorAll("li");s.style.setProperty("--tab-count",o.length),s.querySelectorAll("a[data-tab-target]").forEach((function(t){if(!t.hasAttribute("title")){var e=$(t.textContent.trim());t.setAttribute("title",e)}}))}}}catch(t){r.e(t)}finally{r.f()}}}))}function $(t){return t.replace(/&/g,"&").replace(/