react-edit-to-html 1.2.7 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +128 -28
- package/dist/index.js +325 -272
- package/dist/react-edit-to-html.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require("react");l=c(l,1);let u=require("react-dom/client"),d=require("react/jsx-runtime");function f(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){_(a,r,i,o,s,`next`,e)}function s(e){_(a,r,i,o,s,`throw`,e)}o(void 0)})}}function y(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function b(e,t,n){y(e,t),t.set(e,n)}function x(e,t){return e.get(f(e,t))}function S(e,t){y(e,t),t.add(e)}function C(e,t,n){return e.set(f(e,t),n),n}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?w(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function E(e){var t,n,r,i=2;for(typeof Symbol<`u`&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&(t=e[n])!=null)return t.call(e);if(r&&(t=e[r])!=null)return new D(t.call(e));n=`@@asyncIterator`,r=`@@iterator`}throw TypeError(`Object is not async iterable`)}function D(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+` is not an object.`));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return D=function(e){this.s=e,this.n=e.next},D.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return n===void 0?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return n===void 0?Promise.reject(e):t(n.apply(this.s,arguments))}},new D(e)}function O(e,t,n){t||(t=[]);var r=t.length++;return Object.defineProperty({},"_",{set:function(i){t[r]=i,e.apply(n,t)}})}var k=o({AbortException:()=>Xe,AnnotationEditorLayer:()=>by,AnnotationEditorParamsType:()=>N,AnnotationEditorType:()=>M,AnnotationEditorUIManager:()=>Rr,AnnotationLayer:()=>xh,AnnotationMode:()=>we,AnnotationType:()=>Ae,CSSConstants:()=>Lt,ColorPicker:()=>np,DOMSVGFactory:()=>bp,DrawLayer:()=>By,FeatureTest:()=>R,GlobalWorkerOptions:()=>Bu,ImageKind:()=>ke,InvalidPDFException:()=>qe,MathClamp:()=>B,OPS:()=>P,OutputScale:()=>Pt,PDFDataRangeTransport:()=>sf,PDFDateString:()=>Et,PDFWorker:()=>yf,PasswordException:()=>Ge,PasswordResponses:()=>Pe,PermissionFlag:()=>De,PixelsPerInch:()=>pt,RenderingCancelledException:()=>gt,ResponseException:()=>Je,SignatureExtractor:()=>gv,SupportedImageMimeTypes:()=>Ft,TextLayer:()=>Vd,TextLayerImages:()=>ub,TouchManager:()=>Xi,Util:()=>z,VerbosityLevel:()=>Me,XfaLayer:()=>ft,applyOpacity:()=>Rt,build:()=>Wf,createValidAbsoluteUrl:()=>Ve,fetchData:()=>mt,findContrastColor:()=>Wt,getDocument:()=>tf,getFilenameFromUrl:()=>yt,getPdfFilenameFromUrl:()=>bt,getRGB:()=>kt,getRGBA:()=>Ot,getUuid:()=>at,isDataScheme:()=>_t,isPdfFile:()=>vt,isValidExplicitDest:()=>Ps,makeArr:()=>st,makeMap:()=>ct,makeObj:()=>lt,noContextMenu:()=>wt,normalizeUnicode:()=>it,renderRichText:()=>Gt,setLayerDimensions:()=>Nt,shadow:()=>L,stopEvent:()=>Tt,updateUrlHash:()=>He,version:()=>Uf}),A,ee,te,ne,re,j,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge,_e=typeof process==`object`&&process+``==`[object process]`&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!==`browser`),ve=[1/0,1/0,-1/0,-1/0],ye=new Float32Array(ve),be=[.001,0,0,.001,0,0],xe=1.35,Se=`http://www.w3.org/2000/svg`,Ce={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},we={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Te=`pdfjs_internal_id_`,Ee=`pdfjs_internal_editor_`,M={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},N={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},De={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Oe={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},ke={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Ae={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},je={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Me={ERRORS:0,WARNINGS:1,INFOS:5},P={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Ne={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},Pe={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Fe=Me.WARNINGS;function Ie(e){Number.isInteger(e)&&(Fe=e)}function Le(){return Fe}function Re(e){Fe>=Me.INFOS&&console.info(`Info: ${e}`)}function F(e){Fe>=Me.WARNINGS&&console.warn(`Warning: ${e}`)}function I(e){throw Error(e)}function ze(e,t){e||I(t)}function Be(e){switch(e==null?void 0:e.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function Ve(e,t=null,n=null){if(!e)return null;if(n&&typeof e==`string`){if(n.addDefaultProtocol&&e.startsWith(`www.`)){let t=e.match(/\./g);(t==null?void 0:t.length)>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=tt(e)}catch(e){}}let r=t?URL.parse(e,t):URL.parse(e);return Be(r)?r:null}function He(e,t,n=!1){let r=URL.parse(e);return r?(r.hash=t,r.href):n&&Ve(e,`http://example.com`)?e.split(`#`,1)[0]+`${t?`#${t}`:``}`:``}function Ue(e){return e.substring(e.lastIndexOf(`/`)+1)}function L(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var We=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),Ge=class extends We{constructor(e,t){super(e,`PasswordException`),this.code=t}},Ke=class extends We{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},qe=class extends We{constructor(e){super(e,`InvalidPDFException`)}},Je=class extends We{constructor(e,t,n){super(e,`ResponseException`),this.status=t,this.missing=n}},Ye=class extends We{constructor(e){super(e,`FormatError`)}},Xe=class extends We{constructor(e){super(e,`AbortException`)}};function Ze(e){(typeof e!=`object`||(e==null?void 0:e.length)===void 0)&&I(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let r=[];for(let i=0;i<t;i+=n){let a=Math.min(i+n,t),o=e.subarray(i,a);r.push(String.fromCharCode.apply(null,o))}return r.join(``)}function Qe(e){typeof e!=`string`&&I(`Invalid argument for stringToBytes`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r)&255;return n}var R=class{static get isLittleEndian(){let e=new Uint8Array(4);e[0]=1;let t=new Uint32Array(e.buffer,0,1);return L(this,`isLittleEndian`,t[0]===1)}static get isOffscreenCanvasSupported(){return L(this,`isOffscreenCanvasSupported`,typeof OffscreenCanvas<`u`)}static get isImageDecoderSupported(){return L(this,`isImageDecoderSupported`,typeof ImageDecoder<`u`)}static get isFloat16ArraySupported(){return L(this,`isFloat16ArraySupported`,typeof Float16Array<`u`)}static get isSanitizerSupported(){return L(this,`isSanitizerSupported`,typeof Sanitizer<`u`)}static get platform(){let{platform:e,userAgent:t}=navigator;return L(this,`platform`,{isAndroid:t.includes(`Android`),isLinux:e.includes(`Linux`),isMac:e.includes(`Mac`),isWindows:e.includes(`Win`),isFirefox:t.includes(`Firefox`)})}static get isCanvasFilterSupported(){let e;return this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext(`2d`):typeof document<`u`&&(e=document.createElement(`canvas`).getContext(`2d`)),L(this,`isCanvasFilterSupported`,(e==null?void 0:e.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>`u`)return L(this,`isAlphaColorInputSupported`,!1);let e=document.createElement(`input`);return e.type=`color`,e.setAttribute(`alpha`,``),e.value=`#ff000080`,L(this,`isAlphaColorInputSupported`,e.value!==`#ff0000`)}static get isBackdropFilterSupported(){return L(this,`isBackdropFilterSupported`,typeof CSS<`u`&&CSS.supports(`backdrop-filter`,`blur(1px)`))}},z=class e{static get hexNums(){return L(this,`hexNums`,Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)))}static makeHexColor(e,t,n){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[n]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,n=0){let r=e[n],i=e[n+1];e[n]=r*t[0]+i*t[2]+t[4],e[n+1]=r*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];for(let t=0;t<6;t+=2){let l=e[n+t],u=e[n+t+1];e[n+t]=l*r+u*a+s,e[n+t+1]=l*i+u*o+c}}static applyInverseTransform(e,t){let n=e[0],r=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-r*t[2]+t[2]*t[5]-t[4]*t[3])/i,e[1]=(-n*t[1]+r*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=e[0],u=e[1],d=e[2],f=e[3],p=r*l+s,m=p,h=r*d+s,g=h,_=o*u+c,v=_,y=o*f+c,b=y;if(i!==0||a!==0){let e=i*l,t=i*d,n=a*u,r=a*f;p+=n,g+=n,h+=r,m+=r,_+=e,b+=e,y+=t,v+=t}n[0]=Math.min(n[0],p,h,m,g),n[1]=Math.min(n[1],_,y,v,b),n[2]=Math.max(n[2],p,h,m,g),n[3]=Math.max(n[3],_,y,v,b)}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){let n=e[0],r=e[1],i=e[2],a=e[3],o=Math.pow(n,2)+Math.pow(r,2),s=n*i+r*a,c=Math.pow(i,2)+Math.pow(a,2),l=(o+c)/2,u=Math.sqrt(Math.pow(l,2)-(o*c-Math.pow(s,2)));t[0]=Math.sqrt(l+u||1),t[1]=Math.sqrt(l-u||1)}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],t),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,r,i){i[0]=Math.min(i[0],e,n),i[1]=Math.min(i[1],t,r),i[2]=Math.max(i[2],e,n),i[3]=Math.max(i[3],t,r)}static bezierBoundingBox(t,n,r,i,a,o,s,c,l){l[0]=Math.min(l[0],t,s),l[1]=Math.min(l[1],n,c),l[2]=Math.max(l[2],t,s),l[3]=Math.max(l[3],n,c),f(e,this,et).call(this,t,r,a,s,n,i,o,c,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),l),f(e,this,et).call(this,t,r,a,s,n,i,o,c,3*(-n+3*(i-o)+c),6*(n-2*i+o),3*(i-n),l)}};A=z;function $e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}function et(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&f(A,this,$e).call(this,e,t,n,r,i,a,o,s,-u/l,d);return}let p=Math.pow(l,2)-4*u*c;if(p<0)return;let m=Math.sqrt(p),h=2*c;f(A,this,$e).call(this,e,t,n,r,i,a,o,s,(-l+m)/h,d),f(A,this,$e).call(this,e,t,n,r,i,a,o,s,(-l-m)/h,d)}function tt(e){return decodeURIComponent(escape(e))}var nt=null,rt=null;function it(e){return nt||(nt=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,rt=new Map([[`ſt`,`ſt`]])),e.replaceAll(nt,(e,t,n)=>t?t.normalize(`NFKC`):rt.get(n))}function at(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),Ze(e)}function ot(e,t,n){if(!Array.isArray(n)||n.length<2)return!1;let[r,i,...a]=n;if(!e(r)&&!Number.isInteger(r)||!t(i))return!1;let o=a.length,s=!0;switch(i.name){case`XYZ`:if(o<2||o>3)return!1;break;case`Fit`:case`FitB`:return o===0;case`FitH`:case`FitBH`:case`FitV`:case`FitBV`:if(o>1)return!1;break;case`FitR`:if(o!==4)return!1;s=!1;break;default:return!1}for(let e of a)if(!(typeof e==`number`||s&&e===null))return!1;return!0}var st=()=>[],ct=()=>new Map,lt=()=>Object.create(null);function B(e,t,n){return Math.min(Math.max(e,t),n)}var ut=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let e=this.viewBox;return L(this,`rawDims`,{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){let n=[e,t];return z.applyTransform(n,this.transform),n}convertToPdfPoint(e,t){let n=[e,t];return z.applyInverseTransform(n,this.transform),n}},dt=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){var r;if(!t)return;let a=null,o=t.name;if(o===`#text`)a=t.value;else if(e.shouldBuildText(o))!(t==null||(r=t.attributes)==null)&&r.textContent?a=t.attributes.textContent:t.value&&(a=t.value);else return;if(a!==null&&n.push({str:a}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return!(e===`textarea`||e===`input`||e===`option`||e===`select`)}},ft=class{static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})});break}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null)switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=document.createElement(r.name);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&dt.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){var u,d;let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:f}=s;if(f===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let p=!(s==null||(u=s.attributes)==null)&&u.xmlns?document.createElementNS(s.attributes.xmlns,f):document.createElement(f);if(a.append(p),s.attributes&&this.setAttributes({html:p,element:s,storage:t,intent:i,linkService:n}),((d=s.children)==null?void 0:d.length)>0)l.push([s,-1,p]);else if(s.value){let e=document.createTextNode(s.value);o&&dt.shouldBuildText(f)&&c.push(e),p.append(e)}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new ut({viewBox:[0,0,parseInt(r,10),parseInt(i,10)],userUnit:1,scale:t,rotation:n})}},pt=class{};ee=pt,g(pt,`CSS`,96),g(pt,`PDF`,72),g(pt,`PDF_TO_CSS_UNITS`,ee.CSS/ee.PDF);function mt(e){return ht.apply(this,arguments)}function ht(){return ht=v(function*(e,t=`text`){if(Ct(e,document.baseURI)){let n=yield fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`blob`:return n.blob();case`bytes`:return n.bytes();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t===`bytes`?`arraybuffer`:t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`bytes`:n(new Uint8Array(i.response));return;case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}),ht.apply(this,arguments)}var gt=class extends We{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function _t(e){let t=e.length,n=0;for(;n<t&&e[n].trim()===``;)n++;return e.substring(n,n+5).toLowerCase()===`data:`}function vt(e){return typeof e==`string`&&/\.pdf$/i.test(e)}function yt(e){return[e]=e.split(/[#?]/,1),Ue(e)}function bt(e,t=`document.pdf`){if(typeof e!=`string`)return t;if(_t(e))return F(`getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.`),t;let n=(e=>{try{return new URL(e)}catch(e){}try{return new URL(decodeURIComponent(e))}catch(e){}try{return new URL(e,`https://foo.bar`)}catch(e){}try{return new URL(decodeURIComponent(e),`https://foo.bar`)}catch(e){}return null})(e);if(!n)return t;let r=e=>{try{let t=decodeURIComponent(e);return t.includes(`/`)&&(t=Ue(t),t.length===4&&i.test(t))?e:t}catch(t){return e}},i=/\.pdf$/i,a=Ue(n.pathname);if(i.test(a))return r(a);if(n.searchParams.size>0){var o;let e=e=>[...e].findLast(e=>i.test(e)),t=(o=e(n.searchParams.values()))==null?e(n.searchParams.keys()):o;if(t)return r(t)}if(n.hash){let e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(e)return r(e[0])}return t}var xt=new WeakMap,St=class{constructor(){b(this,xt,new Map),g(this,`times`,[])}time(e){x(xt,this).has(e)&&F(`Timer is already running for ${e}`),x(xt,this).set(e,Date.now())}timeEnd(e){x(xt,this).has(e)||F(`Timer has not been started for ${e}`),this.times.push({name:e,start:x(xt,this).get(e),end:Date.now()}),x(xt,this).delete(e)}toString(){let e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join(``)}};function Ct(e,t){var n;let r=t?URL.parse(e,t):URL.parse(e);return/https?:/.test((n=r==null?void 0:r.protocol)==null?``:n)}function wt(e){e.preventDefault()}function Tt(e){e.preventDefault(),e.stopPropagation()}var Et=class e{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!=`string`)return null;f(e,this,Dt)._||(Dt._=f(e,this,RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?`)));let n=f(e,this,Dt)._.exec(t);if(!n)return null;let r=parseInt(n[1],10),i=parseInt(n[2],10);i=i>=1&&i<=12?i-1:0;let a=parseInt(n[3],10);a=a>=1&&a<=31?a:1;let o=parseInt(n[4],10);o=o>=0&&o<=23?o:0;let s=parseInt(n[5],10);s=s>=0&&s<=59?s:0;let c=parseInt(n[6],10);c=c>=0&&c<=59?c:0;let l=n[7]||`Z`,u=parseInt(n[8],10);u=u>=0&&u<=23?u:0;let d=parseInt(n[9],10)||0;return d=d>=0&&d<=59?d:0,l===`-`?(o+=u,s+=d):l===`+`&&(o-=u,s-=d),new Date(Date.UTC(r,i,a,o,s,c))}},Dt={_:void 0};function Ot(e){if(e.startsWith(`#`)){let t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith(`rgb(`)){let[t,n,r]=e.slice(4,-1).split(`,`).map(e=>parseInt(e,10));return[t,n,r,1]}if(e.startsWith(`rgba(`)){let t=e.slice(5,-1).split(`,`);return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}let t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!==`none`?parseFloat(t[4]):1]:null}function kt(e){let t=Ot(e);return t?t.slice(0,3):(F(`Not a valid color format: "${e}"`),[0,0,0])}function At(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,t.style.colorScheme=`only light`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,kt(r))}t.remove()}function jt(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function Mt(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Nt(e,t,n=!1,r=!0){if(t instanceof ut){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-x))`,s=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;!n||t.rotation%180==0?(a.width=o,a.height=s):(a.width=s,a.height=o)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var Pt=class e{constructor(){let{pixelRatio:t}=e;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,n,r,i,a=-1){let o=1/0,s=1/0,c=1/0;r=e.capPixels(r,a),r>0&&(o=Math.sqrt(r/(t*n))),i!==-1&&(s=i/t,c=i/n);let l=Math.min(o,s,c);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){let n=Math.ceil(window.screen.availWidth*window.screen.availHeight*Math.pow(this.pixelRatio,2)*(1+t/100));return e>0?Math.min(e,n):n}return e}},Ft=[`image/apng`,`image/avif`,`image/bmp`,`image/gif`,`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`image/x-icon`],It=class{static get isDarkMode(){var e,t;return L(this,`isDarkMode`,!!(!((e=window)==null||(t=e.matchMedia)==null)&&t.call(e,`(prefers-color-scheme: dark)`).matches))}},Lt=class{static get commentForegroundColor(){let e=document.createElement(`span`);e.classList.add(`comment`,`sidebar`);let{style:t}=e;t.width=t.height=`0`,t.display=`none`,t.color=`var(--comment-fg-color)`,document.body.append(e);let{color:n}=window.getComputedStyle(e);return e.remove(),L(this,`commentForegroundColor`,kt(n))}};function Rt(e,t){var n;t=B((n=t)==null?1:n,0,1);let r=255*(1-t);return e.map(e=>Math.round(e*t+r))}function zt(e,t){let n=e[0]/255,r=e[1]/255,i=e[2]/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)t[0]=t[1]=0;else{let e=a-o;switch(t[1]=s<.5?e/(a+o):e/(2-a-o),a){case n:t[0]=((r-i)/e+(r<i?6:0))*60;break;case r:t[0]=((i-n)/e+2)*60;break;case i:t[0]=((n-r)/e+4)*60;break}}t[2]=s}function Bt(e,t){let n=e[0],r=e[1],i=e[2],a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(n/60%2-1)),s=i-a/2;switch(Math.floor(n/60)){case 0:t[0]=a+s,t[1]=o+s,t[2]=s;break;case 1:t[0]=o+s,t[1]=a+s,t[2]=s;break;case 2:t[0]=s,t[1]=a+s,t[2]=o+s;break;case 3:t[0]=s,t[1]=o+s,t[2]=a+s;break;case 4:t[0]=o+s,t[1]=s,t[2]=a+s;break;case 5:case 6:t[0]=a+s,t[1]=s,t[2]=o+s;break}}function Vt(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Ht(e,t,n){Bt(e,n),n.map(Vt);let r=.2126*n[0]+.7152*n[1]+.0722*n[2];Bt(t,n),n.map(Vt);let i=.2126*n[0]+.7152*n[1]+.0722*n[2];return r>i?(r+.05)/(i+.05):(i+.05)/(r+.05)}var Ut=new Map;function Wt(e,t){let n=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,r=Ut.get(n);if(r)return r;let i=new Float32Array(9),a=i.subarray(0,3),o=i.subarray(3,6);zt(e,o);let s=i.subarray(6,9);zt(t,s);let c=s[2]<.5,l=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),Ht(o,s,a)<l){let e,t;for(c?(e=o[2],t=1):(e=0,t=o[2]);t-e>.005;){let n=o[2]=(e+t)/2;c===Ht(o,s,a)<l?e=n:t=n}o[2]=c?t:e}return Bt(o,a),r=z.makeHexColor(Math.round(a[0]*255),Math.round(a[1]*255),Math.round(a[2]*255)),Ut.set(n,r),r}function Gt({html:e,dir:t,className:n},r){let i=document.createDocumentFragment();if(typeof e==`string`){let n=document.createElement(`p`);n.dir=t||`auto`;let r=e.split(/\r\n?|\n/);for(let e=0,t=r.length;e<t;++e){let i=r[e];n.append(document.createTextNode(i)),e<t-1&&n.append(document.createElement(`br`))}i.append(n)}else ft.render({xfaHtml:e,div:i,intent:`richText`});i.firstElementChild.classList.add(`richText`,n),r.append(i)}function Kt(e){let t=new Path2D;if(!e)return t;for(let n=0,r=e.length;n<r;)switch(e[n++]){case Ne.moveTo:t.moveTo(e[n++],e[n++]);break;case Ne.lineTo:t.lineTo(e[n++],e[n++]);break;case Ne.curveTo:t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);break;case Ne.quadraticCurveTo:t.quadraticCurveTo(e[n++],e[n++],e[n++],e[n++]);break;case Ne.closePath:t.closePath();break;default:F(`Unrecognized drawing path operator: ${e[n-1]}`);break}return t}var qt=new WeakMap,Jt=new WeakMap,Yt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,$t=new WeakMap,en=new WeakMap,tn=new WeakSet,nn=class{constructor(e){S(this,tn),b(this,qt,null),b(this,Jt,null),b(this,Yt,void 0),b(this,Xt,null),b(this,Zt,null),b(this,Qt,null),b(this,$t,null),b(this,en,null),C(Yt,this,e),ln._||(ln._=Object.freeze({freetext:`pdfjs-editor-remove-freetext-button`,highlight:`pdfjs-editor-remove-highlight-button`,ink:`pdfjs-editor-remove-ink-button`,stamp:`pdfjs-editor-remove-stamp-button`,signature:`pdfjs-editor-remove-signature-button`}))}render(){let e=C(qt,this,document.createElement(`div`));e.classList.add(`editToolbar`,`hidden`),e.setAttribute(`role`,`toolbar`);let t=x(Yt,this)._uiManager._signal;t instanceof AbortSignal&&!t.aborted&&(e.addEventListener(`contextmenu`,wt,{signal:t}),e.addEventListener(`pointerdown`,rn,{signal:t}));let n=C(Xt,this,document.createElement(`div`));n.className=`buttons`,e.append(n);let r=x(Yt,this).toolbarPosition;if(r){let{style:t}=e;t.insetInlineEnd=`${100*(x(Yt,this)._uiManager.direction===`ltr`?1-r[0]:r[0])}%`,t.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return x(qt,this)}hide(){var e;x(qt,this).classList.add(`hidden`),(e=x(Jt,this))==null||e.hideDropdown()}show(){var e,t;x(qt,this).classList.remove(`hidden`),(e=x(Zt,this))==null||e.shown(),(t=x(Qt,this))==null||t.shown()}addDeleteButton(){let{editorType:e,_uiManager:t}=x(Yt,this),n=document.createElement(`button`);n.classList.add(`basic`,`deleteButton`),n.tabIndex=0,n.setAttribute(`data-l10n-id`,ln._[e]),f(tn,this,sn).call(this,n)&&n.addEventListener(`click`,e=>{t.delete()},{signal:t._signal}),x(Xt,this).append(n)}addAltText(e){var t=this;return v(function*(){let n=yield e.render();f(tn,t,sn).call(t,n),x(Xt,t).append(n,cn.call(f(tn,t))),C(Zt,t,e)})()}addComment(e,t=null){if(x(Qt,this))return;let n=e.renderForToolbar();if(!n)return;f(tn,this,sn).call(this,n);let r=C($t,this,cn.call(f(tn,this)));t?(x(Xt,this).insertBefore(n,t),x(Xt,this).insertBefore(r,t)):x(Xt,this).append(n,r),C(Qt,this,e),e.toolbar=this}addColorPicker(e){if(x(Jt,this))return;C(Jt,this,e);let t=e.renderButton();f(tn,this,sn).call(this,t),x(Xt,this).append(t,cn.call(f(tn,this)))}addEditSignatureButton(e){var t=this;return v(function*(){let n=C(en,t,yield e.renderEditButton(x(Yt,t)));f(tn,t,sn).call(t,n),x(Xt,t).append(n,cn.call(f(tn,t)))})()}removeButton(e){switch(e){case`comment`:var t,n;(t=x(Qt,this))==null||t.removeToolbarCommentButton(),C(Qt,this,null),(n=x($t,this))==null||n.remove(),C($t,this,null);break}}addButton(e,t){var n=this;return v(function*(){switch(e){case`colorPicker`:t&&n.addColorPicker(t);break;case`altText`:t&&(yield n.addAltText(t));break;case`editSignature`:t&&(yield n.addEditSignatureButton(t));break;case`delete`:n.addDeleteButton();break;case`comment`:t&&n.addComment(t);break}})()}addButtonBefore(e,t,n){var r=this;return v(function*(){if(!t&&e===`comment`)return;let i=x(Xt,r).querySelector(n);i&&e===`comment`&&r.addComment(t,i)})()}updateEditSignatureButton(e){x(en,this)&&(x(en,this).title=e)}remove(){var e;x(qt,this).remove(),(e=x(Jt,this))==null||e.destroy(),C(Jt,this,null)}};function rn(e){e.stopPropagation()}function an(e){x(Yt,this)._focusEventsAllowed=!1,Tt(e)}function on(e){x(Yt,this)._focusEventsAllowed=!0,Tt(e)}function sn(e){let t=x(Yt,this)._uiManager._signal;return!(t instanceof AbortSignal)||t.aborted?!1:(e.addEventListener(`focusin`,f(tn,this,an).bind(this),{capture:!0,signal:t}),e.addEventListener(`focusout`,f(tn,this,on).bind(this),{capture:!0,signal:t}),e.addEventListener(`contextmenu`,wt,{signal:t}),!0)}function cn(){let e=document.createElement(`div`);return e.className=`divider`,e}var ln={_:null},un=new WeakMap,dn=new WeakMap,fn=new WeakMap,pn=new WeakSet,mn=class{constructor(e){S(this,pn),b(this,un,null),b(this,dn,null),b(this,fn,void 0),C(fn,this,e)}show(e,t,n){let[r,i]=f(pn,this,gn).call(this,t,n),{style:a}=x(dn,this)||C(dn,this,f(pn,this,hn).call(this));e.append(x(dn,this)),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){x(dn,this).remove()}};function hn(){let e=C(dn,this,document.createElement(`div`));e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`);let t=x(fn,this)._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener(`contextmenu`,wt,{signal:t});let n=C(un,this,document.createElement(`div`));return n.className=`buttons`,e.append(n),x(fn,this).hasCommentManager()&&f(pn,this,_n).call(this,`commentButton`,`pdfjs-comment-floating-button`,`pdfjs-comment-floating-button-label`,()=>{x(fn,this).commentSelection(`floating_button`)}),f(pn,this,_n).call(this,`highlightButton`,`pdfjs-highlight-floating-button1`,`pdfjs-highlight-floating-button-label`,()=>{x(fn,this).highlightSelection(`floating_button`)}),e}function gn(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(e<n)continue;let a=i.x+(t?i.width:0);if(e>n){r=a,n=e;continue}t?a>r&&(r=a):a<r&&(r=a)}return[t?1-r:r,n]}function _n(e,t,n,r){let i=document.createElement(`button`);i.classList.add(`basic`,e),i.tabIndex=0,i.setAttribute(`data-l10n-id`,t);let a=document.createElement(`span`);i.append(a),a.className=`visuallyHidden`,a.setAttribute(`data-l10n-id`,n);let o=x(fn,this)._signal;o instanceof AbortSignal&&!o.aborted&&(i.addEventListener(`contextmenu`,wt,{signal:o}),i.addEventListener(`click`,r,{signal:o})),x(un,this).append(i)}var vn=Object.freeze({internal:`068f09d6-5b37-4f77-a97a-f8ff4f253b68`});function yn(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}var bn=class e{static initializeAndAddPointerId(e){(Sn._||(Sn._=new Set)).add(e)}static setPointer(e,t){xn._||(xn._=t),wn._!=null||(wn._=e)}static setTimeStamp(e){Cn._=e}static isSamePointerId(e){return xn._===e}static isSamePointerIdOrRemove(e){var t;return xn._===e?!0:((t=Sn._)==null||t.delete(e),!1)}static isSamePointerType(e){return wn._===e}static isInitializedAndDifferentPointerType(t){return wn._!==null&&!e.isSamePointerType(t)}static isSameTimeStamp(e){return Cn._===e}static isUsingMultiplePointers(){var e;return((e=Sn._)==null?void 0:e.size)>=1}static clearPointerType(){wn._=null}static clearPointerIds(){xn._=NaN,Sn._=null}static clearTimeStamp(){Cn._=NaN}},xn={_:NaN},Sn={_:null},Cn={_:NaN},wn={_:null},Tn=new WeakMap,En=class{constructor(){b(this,Tn,0)}get id(){var e,t;return`${Ee}${C(Tn,this,(e=x(Tn,this),t=e++,e)),t}`}},Dn=new WeakMap,On=new WeakMap,kn=new WeakMap,An=new WeakSet,jn=class{constructor(){S(this,An),b(this,Dn,at()),b(this,On,0),b(this,kn,null)}static get _isSVGFittingCanvas(){let e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Se}"><rect width="1" height="1" style="fill:red;"/></svg>`,t=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),n=new Image;n.src=e;let r=n.decode().then(()=>(t.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0));return L(this,`_isSVGFittingCanvas`,r)}getFromFile(e){var t=this;return v(function*(){let{lastModified:n,name:r,size:i,type:a}=e;return f(An,t,Mn).call(t,`${n}_${r}_${i}_${a}`,e)})()}getFromUrl(e){var t=this;return v(function*(){return f(An,t,Mn).call(t,e,e)})()}getFromBlob(e,t){var n=this;return v(function*(){let r=yield t;return f(An,n,Mn).call(n,e,r)})()}getFromId(e){var t=this;return v(function*(){x(kn,t)||C(kn,t,new Map);let n=x(kn,t).get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return t.getFromFile(n.file);if(n.blobPromise){let{blobPromise:e}=n;return delete n.blobPromise,t.getFromBlob(n.id,e)}return t.getFromUrl(n.url)})()}getFromCanvas(e,t){var n,r;x(kn,this)||C(kn,this,new Map);let i=x(kn,this).get(e);if(i!=null&&i.bitmap)return i.refCounter+=1,i;let a=new OffscreenCanvas(t.width,t.height);return a.getContext(`2d`).drawImage(t,0,0),i={bitmap:a.transferToImageBitmap(),id:`image_${x(Dn,this)}_${C(On,this,(n=x(On,this),r=n++,n)),r}`,refCounter:1,isSvg:!1},x(kn,this).set(e,i),x(kn,this).set(i.id,i),i}getSvgUrl(e){let t=x(kn,this).get(e);return t!=null&&t.isSvg?t.svgUrl:null}deleteId(e){var t;x(kn,this)||C(kn,this,new Map);let n=x(kn,this).get(e);if(!n||(--n.refCounter,n.refCounter!==0))return;let{bitmap:r}=n;if(!n.url&&!n.file){let e=new OffscreenCanvas(r.width,r.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(r),n.blobPromise=e.convertToBlob()}(t=r.close)==null||t.call(r),n.bitmap=null}isValidId(e){return e.startsWith(`image_${x(Dn,this)}_`)}};te=jn;function Mn(e,t){var n=this;return v(function*(){x(kn,n)||C(kn,n,new Map);let r=x(kn,n).get(e);if(r===null)return null;if(r!=null&&r.bitmap)return r.refCounter+=1,r;try{var i,a;r||(r={bitmap:null,id:`image_${x(Dn,n)}_${C(On,n,(i=x(On,n),a=i++,i)),a}`,refCounter:0,isSvg:!1});let e;if(typeof t==`string`?(r.url=t,e=yield mt(t,`blob`)):t instanceof File?e=r.file=t:t instanceof Blob&&(e=t),e.type===`image/svg+xml`){let t=te._isSVGFittingCanvas,n=new FileReader,i=new Image,a=new Promise((e,a)=>{i.onload=()=>{r.bitmap=i,r.isSvg=!0,e()},n.onload=v(function*(){let e=r.svgUrl=n.result;i.src=(yield t)?`${e}#svgView(preserveAspectRatio(none))`:e}),i.onerror=n.onerror=a});n.readAsDataURL(e),yield a}else r.bitmap=yield createImageBitmap(e);r.refCounter=1}catch(e){F(e),r=null}return x(kn,n).set(e,r),r&&x(kn,n).set(r.id,r),r})()}var Nn=new WeakMap,Pn=new WeakMap,Fn=new WeakMap,In=new WeakMap,Ln=class{constructor(e=128){b(this,Nn,[]),b(this,Pn,!1),b(this,Fn,void 0),b(this,In,-1),C(Fn,this,e)}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),x(Pn,this))return;let s={cmd:e,undo:t,post:n,type:i};if(x(In,this)===-1){x(Nn,this).length>0&&(x(Nn,this).length=0),C(In,this,0),x(Nn,this).push(s);return}if(a&&x(Nn,this)[x(In,this)].type===i){o&&(s.undo=x(Nn,this)[x(In,this)].undo),x(Nn,this)[x(In,this)]=s;return}let c=x(In,this)+1;c===x(Fn,this)?x(Nn,this).splice(0,1):(C(In,this,c),c<x(Nn,this).length&&x(Nn,this).splice(c)),x(Nn,this).push(s)}undo(){if(x(In,this)===-1)return;C(Pn,this,!0);let{undo:e,post:t}=x(Nn,this)[x(In,this)];e(),t==null||t(),C(Pn,this,!1),C(In,this,x(In,this)-1)}redo(){if(x(In,this)<x(Nn,this).length-1){C(In,this,x(In,this)+1),C(Pn,this,!0);let{cmd:e,post:t}=x(Nn,this)[x(In,this)];e(),t==null||t(),C(Pn,this,!1)}}hasSomethingToUndo(){return x(In,this)!==-1}hasSomethingToRedo(){return x(In,this)<x(Nn,this).length-1}cleanType(e){if(x(In,this)!==-1){for(let t=x(In,this);t>=0;t--)if(x(Nn,this)[t].type!==e){x(Nn,this).splice(t+1,x(In,this)-t),C(In,this,t);return}x(Nn,this).length=0,C(In,this,-1)}}destroy(){C(Nn,this,null)}},Rn=class e{constructor(t){this.callbacks=new Map;let{isMac:n}=R.platform;for(let[r,i,a={}]of t){let t=r.some(e=>e.startsWith(`mac+`));for(let o of r){let r=o;if(t){let e=o.startsWith(`mac+`);if(n!==e)continue;e&&(r=o.slice(4))}let[s,c]=zn.call(e,r);s!==null&&this.callbacks.getOrInsertComputed(s,st).push({callback:i,options:a,modifiers:c})}}}exec(t,n){let r=this.callbacks.get(n.key);if(!r){if(/^[a-z]$/i.test(n.key))return;let t=Bn.call(e,n.code);if(t===null||t===n.key||(r=this.callbacks.get(t),!r))return}let i=(n.altKey?e.ALT:0)|(n.ctrlKey?e.CTRL:0)|(n.metaKey?e.META:0)|(n.shiftKey?e.SHIFT:0),a=r.find(e=>e.modifiers===i);if(!a)return;let{callback:o,options:{bubbles:s=!1,args:c=[],checker:l=null}}=a;l&&!l(t,n)||(o.bind(t,...c,n)(),s||Tt(n))}};ne=Rn;function zn(e){let t=null,n=0;for(let r of e.split(`+`)){if(r=r.trim(),!r)continue;let i=r.toUpperCase(),a=ne[i];if(a){n|=a;continue}if(t!==null){F(`KeyboardManager: multiple keys in shortcut "${e}"`);break}t=i===`SPACE`?` `:r}return t===null&&F(`KeyboardManager: no key found in shortcut "${e}"`),[t,n]}function Bn(e){var t,n;let r=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return r?(t=(n=r[1])==null?void 0:n.toLowerCase())==null?r[2]:t:null}g(Rn,`ALT`,1),g(Rn,`CTRL`,2),g(Rn,`META`,4),g(Rn,`SHIFT`,8);var Vn=class e{get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return At(e),L(this,`_colors`,e)}convert(t){let n=kt(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?z.makeHexColor(...t):e}};g(Vn,`_colorsMapping`,new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]));var Hn=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Kn=new WeakMap,qn=new WeakMap,Jn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap,sr=new WeakMap,cr=new WeakMap,lr=new WeakMap,ur=new WeakMap,dr=new WeakMap,fr=new WeakMap,pr=new WeakMap,mr=new WeakMap,hr=new WeakMap,gr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,br=new WeakMap,xr=new WeakMap,Sr=new WeakMap,Cr=new WeakMap,wr=new WeakMap,Tr=new WeakMap,Er=new WeakMap,Dr=new WeakMap,Or=new WeakMap,kr=new WeakMap,Ar=new WeakMap,jr=new WeakMap,Mr=new WeakMap,Nr=new WeakMap,Pr=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,V=new WeakSet,Rr=class e{static get _keyboardManager(){let t=e.prototype,n=e=>x(Pr,e).contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return L(this,`_keyboardManager`,new Rn([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&x(Pr,e).contains(t)&&!e.isEnterHandled}],[[`Space`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&x(Pr,e).contains(document.activeElement)}],[[`Escape`],t.unselectAll],[[`ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,p,m,h,_){S(this,V),b(this,Hn,new AbortController),b(this,Un,null),b(this,Wn,null),b(this,Gn,new Map),b(this,Kn,new Map),b(this,qn,null),b(this,Jn,null),b(this,Yn,null),b(this,Xn,null),b(this,Zn,new Ln),b(this,Qn,null),b(this,$n,null),b(this,er,null),b(this,tr,0),b(this,nr,new Set),b(this,rr,null),b(this,ir,null),b(this,ar,new Set),g(this,`_editorUndoBar`,null),b(this,or,!1),b(this,sr,!1),b(this,cr,!1),b(this,lr,null),b(this,ur,null),b(this,dr,null),b(this,fr,null),b(this,pr,!1),b(this,mr,null),b(this,hr,new En),b(this,gr,!1),b(this,_r,!1),b(this,vr,!1),b(this,yr,null),b(this,br,null),b(this,xr,null),b(this,Sr,null),b(this,Cr,null),b(this,wr,M.NONE),b(this,Tr,new Set),b(this,Er,null),b(this,Dr,null),b(this,Or,null),b(this,kr,null),b(this,Ar,null),b(this,jr,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),b(this,Mr,[0,0]),b(this,Nr,null),b(this,Pr,null),b(this,Fr,null),b(this,Ir,null),b(this,Lr,null);let v=this._signal=x(Hn,this).signal;C(Pr,this,e),C(Fr,this,t),C(Ir,this,n),C(Jn,this,r),C(Qn,this,i),C(Dr,this,a),C(Ar,this,s),this._eventBus=o;let y=T({signal:v},vn);o.on(`editingaction`,this.onEditingAction.bind(this),y),o.on(`pagechanging`,this.onPageChanging.bind(this),y),o.on(`scalechanging`,this.onScaleChanging.bind(this),y),o.on(`rotationchanging`,this.onRotationChanging.bind(this),y),o.on(`setpreference`,this.onSetPreference.bind(this),y),o.on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),y),window.addEventListener(`pointerdown`,()=>{C(_r,this,!0)},{capture:!0,signal:v}),window.addEventListener(`pointerup`,()=>{C(_r,this,!1)},{capture:!0,signal:v}),window.addEventListener(`beforeunload`,f(V,this,Vr).bind(this),{capture:!0,signal:v}),f(V,this,Gr).call(this),f(V,this,Qr).call(this),f(V,this,Jr).call(this),C(Yn,this,s.annotationStorage),C(lr,this,s.filterFactory),C(Or,this,c),C(fr,this,l||null),C(or,this,u),C(sr,this,d),C(cr,this,p),C(Cr,this,m||null),this.viewParameters={realScale:pt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=h||null,this._supportsPinchToZoom=_!==!1,i==null||i.setSidebarUiManager(this)}destroy(){var e,t,n,r,i,a,o,s,c;(e=x(Lr,this))==null||e.resolve(),C(Lr,this,null),(t=x(Hn,this))==null||t.abort(),C(Hn,this,null),this._signal=null;for(let e of x(Kn,this).values())e.destroy();x(Kn,this).clear(),x(Gn,this).clear(),x(ar,this).clear(),(n=x(Sr,this))==null||n.clear(),C(Un,this,null),x(Tr,this).clear(),x(Zn,this).destroy(),(r=x(Jn,this))==null||r.destroy(),(i=x(Qn,this))==null||i.destroy(),(a=x(Dr,this))==null||a.destroy(),(o=x(mr,this))==null||o.hide(),C(mr,this,null),(s=x(xr,this))==null||s.destroy(),C(xr,this,null),C(Wn,this,null),x(ur,this)&&(clearTimeout(x(ur,this)),C(ur,this,null)),x(Nr,this)&&(clearTimeout(x(Nr,this)),C(Nr,this,null)),(c=this._editorUndoBar)==null||c.destroy(),C(Ar,this,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return x(Cr,this)}get useNewAltTextFlow(){return x(sr,this)}get useNewAltTextWhenAddingImage(){return x(cr,this)}get hcmFilter(){return L(this,`hcmFilter`,x(Or,this)?x(lr,this).addHCMFilter(x(Or,this).foreground,x(Or,this).background):`none`)}get direction(){return L(this,`direction`,getComputedStyle(x(Pr,this)).direction)}get _highlightColors(){return L(this,`_highlightColors`,x(fr,this)?new Map(x(fr,this).split(`,`).map(e=>(e=e.split(`=`).map(e=>e.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return L(this,`highlightColors`,null);let t=new Map,n=!!x(Or,this);for(let[r,i]of e){let e=r.endsWith(`_HCM`);if(n&&e){t.set(r.replace(`_HCM`,``),i);continue}!n&&!e&&t.set(r,i)}return L(this,`highlightColors`,t)}get highlightColorNames(){return L(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;let t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),C(er,this,e)}setMainHighlightColorPicker(e){C(xr,this,e)}editAltText(e,t=!1){var n;(n=x(Jn,this))==null||n.editAltText(this,e,t)}hasCommentManager(){return!!x(Qn,this)}editComment(e,t,n,r){var i;(i=x(Qn,this))==null||i.showDialog(this,e,t,n,r)}selectComment(e,t){let n=x(Kn,this).get(e),r=n==null?void 0:n.getEditorByUID(t);r==null||r.toggleComment(!0,!0)}updateComment(e){var t;(t=x(Qn,this))==null||t.updateComment(e.getData())}updatePopupColor(e){var t;(t=x(Qn,this))==null||t.updatePopupColor(e)}removeComment(e){var t;(t=x(Qn,this))==null||t.removeComments([e.uid])}deleteComment(e,t){let n=()=>{e.comment=t};this.addCommands({cmd:()=>{var t;(t=this._editorUndoBar)==null||t.show(n,`comment`),this.toggleComment(null),e.comment=null},undo:n,mustExec:!0})}toggleComment(e,t,n=void 0){var r;(r=x(Qn,this))==null||r.toggleCommentPopup(e,t,n)}makeCommentColor(e,t){var n;return e&&((n=x(Qn,this))==null?void 0:n.makeCommentColor(e,t))||null}getCommentDialogElement(){var e;return((e=x(Qn,this))==null?void 0:e.dialogElement)||null}waitForEditorsRendered(e){var t=this;return v(function*(){if(x(Kn,t).has(e-1))return;let{resolve:n,promise:r}=Promise.withResolvers(),i=r=>{r.pageNumber===e&&(t._eventBus.off(`editorsrendered`,i),n())};t._eventBus.on(`editorsrendered`,i,vn),yield r})()}getSignature(e){var t;(t=x(Dr,this))==null||t.getSignature({uiManager:this,editor:e})}get signatureManager(){return x(Dr,this)}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,T({once:!0,signal:this._signal},vn)),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case`enableNewAltTextWhenAddingImage`:C(cr,this,t);break}}onPageChanging({pageNumber:e}){C(tr,this,e-1)}deletePage(e){for(let t of this.getEditors(e))t.remove();x(Kn,this).delete(e),x(tr,this)===e&&C(tr,this,0)}focusMainContainer(){x(Pr,this).focus()}findParent(e,t){for(let n of x(Kn,this).values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){x(Fr,this).classList.toggle(`noUserSelect`,e)}addShouldRescale(e){x(ar,this).add(e)}removeShouldRescale(e){x(ar,this).delete(e)}onScaleChanging({scale:e}){var t;this.commitOrRemove(),this.viewParameters.realScale=e*pt.PDF_TO_CSS_UNITS;for(let e of x(ar,this))e.onScaleChanging();(t=x(er,this))==null||t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=``,t=!1){let n=document.getSelection();if(!n||n.isCollapsed)return;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n,s=n.toString(),c=f(V,this,zr).call(this,n).closest(`.textLayer`),l=this.getSelectionBoxes(c);if(!l)return;n.empty();let u=f(V,this,Br).call(this,c),d=x(wr,this)===M.NONE,p=()=>{let n=u==null?void 0:u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o,text:s});d&&this.showAllEditors(`highlight`,!0,!0),t&&(n==null||n.editComment())};if(d){this.switchToMode(M.HIGHLIGHT,p);return}p()}commentSelection(e=``){this.highlightSelection(e,!0)}getAndRemoveDataFromAnnotationStorage(e){if(!x(Yn,this))return null;let t=`${Ee}${e}`,n=x(Yn,this).getRawValue(t);return n&&x(Yn,this).remove(t),n}addToAnnotationStorage(e){!e.isEmpty()&&x(Yn,this)&&!x(Yn,this).has(e.id)&&x(Yn,this).setValue(e.id,e)}a11yAlert(e,t=null){let n=x(Ir,this);n&&(n.setAttribute(`data-l10n-id`,e),t?n.setAttribute(`data-l10n-args`,JSON.stringify(t)):n.removeAttribute(`data-l10n-args`))}blur(){if(this.isShiftKeyDown=!1,x(pr,this)&&(C(pr,this,!1),f(V,this,Wr).call(this,`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of x(Tr,this))if(t.div.contains(e)){C(br,this,[t,e]),t._focusEventsAllowed=!1;break}}focus(){if(!x(br,this))return;let[e,t]=x(br,this);C(br,this,null),t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){f(V,this,Jr).call(this),this.setEditingState(!0)}removeEditListeners(){f(V,this,Yr).call(this),this.setEditingState(!1)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of x(ir,this))if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of x(ir,this))if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){var t;if(e.preventDefault(),(t=x(Un,this))==null||t.commitOrRemove(),!this.hasSelection)return;let n=[];for(let e of x(Tr,this)){let t=e.serialize(!0);t&&n.push(t)}n.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(n))}cut(e){this.copy(e),this.delete()}paste(e){var t=this;return v(function*(){e.preventDefault();let{clipboardData:n}=e;for(let e of n.items)for(let n of x(ir,t))if(n.isHandlingMimeForPasting(e.type)){n.paste(e,t.currentLayer);return}let r=n.getData(`application/pdfjs`);if(!r)return;try{r=JSON.parse(r)}catch(e){F(`paste: "${e.message}".`);return}if(!Array.isArray(r))return;t.unselectAll();let i=t.currentLayer;try{let e=[];for(let t of r){let n=yield i.deserialize(t);if(!n)return;e.push(n)}t.addCommands({cmd:()=>{for(let n of e)f(V,t,ri).call(t,n);f(V,t,oi).call(t,e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){F(`paste: "${e.message}".`)}})()}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),x(wr,this)!==M.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,x(pr,this)&&(C(pr,this,!1),f(V,this,Wr).call(this,`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break;case`commentSelection`:this.commentSelection(`context_menu`);break}}updatePageIndex(e,t){for(let n of this.getEditors(e))n.pageIndex=t;let n=x(qn,this).get(e);n&&(n.pageIndex=t,x(Kn,this).set(t,n),x(gr,this)?n.enable():n.disable())}startUpdatePages(){C(qn,this,new Map(x(Kn,this))),x(Kn,this).clear()}endUpdatePages(){C(qn,this,null)}clonePage(e,t){for(let n of this.getEditors(e)){let e=n.serialize(n.mode!==M.HIGHLIGHT);e&&(e.pageIndex=t,e.id=this.getId(),e.isClone=!0,delete e.popupRef,x(Yn,this).setValue(e.id,e))}}findClonesForPage(e){let t=[],{pageIndex:n}=e;for(let[r,i]of x(Yn,this))i.pageIndex===n&&i.isClone&&(x(Yn,this).remove(r),t.push(e.deserialize(i).then(t=>{t&&(t.isClone=!0,e.addOrRebuild(t))})));return Promise.all(t)}setEditingState(e){e?(f(V,this,Kr).call(this),f(V,this,Xr).call(this),f(V,this,$r).call(this,{isEditing:x(wr,this)!==M.NONE,isEmpty:f(V,this,ai).call(this),hasSomethingToUndo:x(Zn,this).hasSomethingToUndo(),hasSomethingToRedo:x(Zn,this).hasSomethingToRedo(),hasSelectedEditor:!1})):(f(V,this,qr).call(this),f(V,this,Zr).call(this),f(V,this,$r).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!x(ir,this)){C(ir,this,e);for(let e of x(ir,this))f(V,this,ei).call(this,e.defaultPropertiesToUpdate)}}getId(){return x(hr,this).id}get currentLayer(){return x(Kn,this).get(x(tr,this))}getLayer(e){return x(Kn,this).get(e)}get currentPageIndex(){return x(tr,this)}addLayer(e){x(Kn,this).set(e.pageIndex,e),x(gr,this)?e.enable():e.disable()}removeLayer(e){x(Kn,this).delete(e.pageIndex)}updateMode(e,t=null,n=!1,r=!1,i=!1,a=!1){var o=this;return v(function*(){var s,c;if(x(wr,o)!==e&&!(x(Lr,o)&&(yield x(Lr,o).promise,!x(Lr,o)))){if(C(Lr,o,Promise.withResolvers()),(s=x(er,o))==null||s.commitOrRemove(),x(wr,o)===M.POPUP){var l;(l=x(Qn,o))==null||l.hideSidebar()}if((c=x(Qn,o))==null||c.destroyPopup(),C(wr,o,e),e===M.NONE){var u;o.setEditingState(!1),f(V,o,ni).call(o);for(let e of x(Gn,o).values())e.hideStandaloneCommentButton();(u=o._editorUndoBar)==null||u.hide(),o.toggleComment(null),x(Lr,o).resolve();return}for(let e of x(Gn,o).values())e.addStandaloneCommentButton();if(e===M.SIGNATURE){var d;yield(d=x(Dr,o))==null?void 0:d.loadSignatures()}n&&bn.clearPointerType(),o.setEditingState(!0),yield f(V,o,ti).call(o),o.unselectAll();for(let t of x(Kn,o).values())t.updateMode(e);if(e===M.POPUP){var p;x(Wn,o)||C(Wn,o,yield x(Ar,o).getAnnotationsByType(new Set(x(ir,o).map(e=>e._editorType))));let e=new Set,t=[];for(let n of x(Gn,o).values()){let{annotationElementId:r,hasComment:i,deleted:a}=n;r&&e.add(r),i&&!a&&t.push(n.getData())}for(let n of x(Wn,o)){let{id:r,popupRef:i,contentsObj:a}=n;i&&a!=null&&a.str&&!e.has(r)&&!x(nr,o).has(r)&&t.push(n)}(p=x(Qn,o))==null||p.showSidebar(t)}if(!t){r&&o.addNewEditorFromKeyboard(),x(Lr,o).resolve();return}for(let e of x(Gn,o).values())e.uid===t?(o.setSelected(e),a?e.editComment():i?e.enterInEditMode():e.focus()):e.unselect();x(Lr,o).resolve()}})()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==x(wr,this)&&this._eventBus.dispatch(`switchannotationeditormode`,T({source:this},e))}updateParams(e,t){if(x(ir,this)){switch(e){case N.CREATE:this.currentLayer.addNewEditor(t);return;case N.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(x(kr,this)||C(kr,this,new Map)).set(e,t),this.showAllEditors(`highlight`,t);break}if(this.hasSelection)for(let n of x(Tr,this))n.updateParams(e,t);else for(let n of x(ir,this))n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){var r,i;for(let n of x(Gn,this).values())n.editorType===e&&n.show(t);((r=(i=x(kr,this))==null?void 0:i.get(N.HIGHLIGHT_SHOW_ALL))==null||r)!==t&&f(V,this,ei).call(this,[[N.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(x(vr,this)!==e){C(vr,this,e);for(let t of x(Kn,this).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}*getEditors(e){for(let t of x(Gn,this).values())t.pageIndex===e&&(yield t)}getEditor(e){return x(Gn,this).get(e)}addEditor(e){x(Gn,this).set(e.id,e)}removeEditor(e){if(e.div.contains(document.activeElement)&&(x(ur,this)&&clearTimeout(x(ur,this)),C(ur,this,setTimeout(()=>{this.focusMainContainer(),C(ur,this,null)},0))),x(Gn,this).delete(e.id),e.annotationElementId){var t;(t=x(Sr,this))==null||t.delete(e.annotationElementId)}if(this.unselect(e),!e.annotationElementId||!x(nr,this).has(e.annotationElementId)){var n;(n=x(Yn,this))==null||n.remove(e.id)}}addDeletedAnnotationElement(e){x(nr,this).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return x(nr,this).has(e)}removeDeletedAnnotationElement(e){x(nr,this).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){x(Un,this)!==e&&(C(Un,this,e),e&&f(V,this,ei).call(this,e.propertiesToUpdate))}updateUI(e){ii.call(f(V,this))===e&&f(V,this,ei).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){f(V,this,ei).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(x(Tr,this).has(e)){x(Tr,this).delete(e),e.unselect(),f(V,this,$r).call(this,{hasSelectedEditor:this.hasSelection});return}x(Tr,this).add(e),e.select(),f(V,this,ei).call(this,e.propertiesToUpdate),f(V,this,$r).call(this,{hasSelectedEditor:!0})}setSelected(e){var t,n;this.updateToolbar({mode:e.mode,editId:e.uid}),(t=x(er,this))==null||t.commitOrRemove();for(let t of x(Tr,this))t!==e&&t.unselect();(n=x(Qn,this))==null||n.destroyPopup(),x(Tr,this).clear(),x(Tr,this).add(e),e.select(),f(V,this,ei).call(this,e.propertiesToUpdate),f(V,this,$r).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return x(Tr,this).values().next().value}unselect(e){e.unselect(),x(Tr,this).delete(e),f(V,this,$r).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return x(Tr,this).size!==0}get isEnterHandled(){return x(Tr,this).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;x(Zn,this).undo(),f(V,this,$r).call(this,{hasSomethingToUndo:x(Zn,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:f(V,this,ai).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){x(Zn,this).redo(),f(V,this,$r).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:x(Zn,this).hasSomethingToRedo(),isEmpty:f(V,this,ai).call(this)})}addCommands(e){x(Zn,this).add(e),f(V,this,$r).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:f(V,this,ai).call(this)})}cleanUndoStack(e){x(Zn,this).cleanType(e)}delete(){var e;this.commitOrRemove();let t=(e=this.currentLayer)==null?void 0:e.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let n=t?[t]:[...x(Tr,this)],r=()=>{var e;(e=this._editorUndoBar)==null||e.show(i,n.length===1?n[0].editorType:n.length);for(let e of n)e.remove()},i=()=>{for(let e of n)f(V,this,ri).call(this,e)};this.addCommands({cmd:r,undo:i,mustExec:!0})}commitOrRemove(){var e;(e=x(Un,this))==null||e.commitOrRemove()}hasSomethingToControl(){return x(Un,this)||this.hasSelection}selectAll(){for(let e of x(Tr,this))e.commit();f(V,this,oi).call(this,x(Gn,this).values())}unselectAll(){var e,t;if(!(x(Un,this)&&(x(Un,this).commitOrRemove(),x(wr,this)!==M.NONE))&&!((e=x(er,this))!=null&&e.commitOrRemove())&&((t=x(Qn,this))==null||t.destroyPopup(),this.hasSelection)){for(let e of x(Tr,this))e.unselect();x(Tr,this).clear(),f(V,this,$r).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;x(Mr,this)[0]+=e,x(Mr,this)[1]+=t;let[r,i]=x(Mr,this),a=[...x(Tr,this)];x(Nr,this)&&clearTimeout(x(Nr,this)),C(Nr,this,setTimeout(()=>{C(Nr,this,null),x(Mr,this)[0]=x(Mr,this)[1]=0,this.addCommands({cmd:()=>{for(let e of a)x(Gn,this).has(e.id)&&(e.translateInPage(r,i),e.translationDone())},undo:()=>{for(let e of a)x(Gn,this).has(e.id)&&(e.translateInPage(-r,-i),e.translationDone())},mustExec:!1})},1e3));for(let n of a)n.translateInPage(e,t),n.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),C(rr,this,new Map);for(let e of x(Tr,this))x(rr,this).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!x(rr,this))return!1;this.disableUserSelect(!1);let e=x(rr,this);C(rr,this,null);let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||(t=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex);if(!t)return!1;let n=(e,t,n,r)=>{if(x(Gn,this).has(e.id)){let i=x(Kn,this).get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(x(rr,this))for(let n of x(rr,this).keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||x(Tr,this).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return x(Un,this)===e}getActive(){return x(Un,this)}getMode(){return x(wr,this)}isEditingMode(){return x(wr,this)!==M.NONE}get imageManager(){return L(this,`imageManager`,new jn)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a});break}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r===0||i===0||s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){(x(Xn,this)||C(Xn,this,new Map)).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){var t;(t=x(Xn,this))==null||t.delete(e)}renderAnnotationElement(e){var t;let n=(t=x(Xn,this))==null?void 0:t.get(e.data.id);if(!n)return;let r=x(Yn,this).getRawValue(n);r&&(x(wr,this)===M.NONE&&!r.hasBeenModified||r.renderAnnotationElement(e))}setMissingCanvas(e,t,n){var r;let i=(r=x(Sr,this))==null?void 0:r.get(e);i&&(i.setCanvas(t,n),x(Sr,this).delete(e))}addMissingCanvas(e,t){(x(Sr,this)||C(Sr,this,new Map)).set(e,t)}};function zr({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function Br(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of x(Kn,this).values())if(t.hasTextLayer(e))return t;return null}function Vr(e){var t;this.commitOrRemove(),(t=this.currentLayer)==null||t.endDrawingSession(!1)}function Hr(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=f(V,this,zr).call(this,e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(x(mr,this)||C(mr,this,new mn(this)),x(mr,this).show(t,n,this.direction===`ltr`))}function Ur(){var e;let t=document.getSelection();if(!t||t.isCollapsed){if(x(Er,this)){var n;(n=x(mr,this))==null||n.hide(),C(Er,this,null),f(V,this,$r).call(this,{hasSelectedText:!1})}return}let{anchorNode:r}=t;if(r===x(Er,this))return;let i=f(V,this,zr).call(this,t).closest(`.textLayer`);if(!i){if(x(Er,this)){var a;(a=x(mr,this))==null||a.hide(),C(Er,this,null),f(V,this,$r).call(this,{hasSelectedText:!1})}return}if((e=x(mr,this))==null||e.hide(),C(Er,this,r),f(V,this,$r).call(this,{hasSelectedText:!0}),!(x(wr,this)!==M.HIGHLIGHT&&x(wr,this)!==M.NONE)&&(x(wr,this)===M.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),C(pr,this,this.isShiftKeyDown),!this.isShiftKeyDown)){let e=x(wr,this)===M.HIGHLIGHT?f(V,this,Br).call(this,i):null;if(e==null||e.toggleDrawing(),x(_r,this)){let t=new AbortController,n=this.combinedSignal(t),r=n=>{n.type===`pointerup`&&n.button!==0||(t.abort(),e==null||e.toggleDrawing(!0),n.type===`pointerup`&&f(V,this,Wr).call(this,`main_toolbar`))};window.addEventListener(`pointerup`,r,{signal:n}),window.addEventListener(`blur`,r,{signal:n})}else e==null||e.toggleDrawing(!0),f(V,this,Wr).call(this,`main_toolbar`)}}function Wr(e=``){x(wr,this)===M.HIGHLIGHT?this.highlightSelection(e):x(or,this)&&f(V,this,Hr).call(this)}function Gr(){document.addEventListener(`selectionchange`,f(V,this,Ur).bind(this),{signal:this._signal})}function Kr(){if(x(dr,this))return;C(dr,this,new AbortController);let e=this.combinedSignal(x(dr,this));window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}function qr(){var e;(e=x(dr,this))==null||e.abort(),C(dr,this,null)}function Jr(){if(x(yr,this))return;C(yr,this,new AbortController);let e=this.combinedSignal(x(yr,this));window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}function Yr(){var e;(e=x(yr,this))==null||e.abort(),C(yr,this,null)}function Xr(){if(x($n,this))return;C($n,this,new AbortController);let e=this.combinedSignal(x($n,this));document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}function Zr(){var e;(e=x($n,this))==null||e.abort(),C($n,this,null)}function Qr(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}function $r(e){Object.entries(e).some(([e,t])=>x(jr,this)[e]!==t)&&(this._eventBus.dispatch(`editingstateschanged`,{source:this,details:Object.assign(x(jr,this),e)}),x(wr,this)===M.HIGHLIGHT&&e.hasSelectedEditor===!1&&f(V,this,ei).call(this,[[N.HIGHLIGHT_FREE,!0]]))}function ei(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}function ti(){var e=this;return v(function*(){if(!x(gr,e)){C(gr,e,!0);let t=[];for(let n of x(Kn,e).values())t.push(n.enable());yield Promise.all(t);for(let t of x(Gn,e).values())t.enable()}})()}function ni(){if(this.unselectAll(),x(gr,this)){C(gr,this,!1);for(let e of x(Kn,this).values())e.disable();for(let e of x(Gn,this).values())e.disable()}}function ri(e){let t=x(Kn,this).get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}function ii(){let e=null;for(e of x(Tr,this));return e}function ai(){if(x(Gn,this).size===0)return!0;if(x(Gn,this).size===1)for(let e of x(Gn,this).values())return e.isEmpty();return!1}function oi(e){for(let e of x(Tr,this))e.unselect();x(Tr,this).clear();for(let t of e)t.isEmpty()||(x(Tr,this).add(t),t.select());f(V,this,$r).call(this,{hasSelectedEditor:this.hasSelection})}g(Rr,`TRANSLATE_SMALL`,1),g(Rr,`TRANSLATE_BIG`,10);var si=new WeakMap,ci=new WeakMap,li=new WeakMap,ui=new WeakMap,di=new WeakMap,fi=new WeakMap,pi=new WeakMap,mi=new WeakMap,hi=new WeakMap,gi=new WeakMap,_i=new WeakMap,vi=new WeakMap,yi=new WeakSet,bi=class e{constructor(e){S(this,yi),b(this,si,null),b(this,ci,!1),b(this,li,null),b(this,ui,null),b(this,di,null),b(this,fi,null),b(this,pi,!1),b(this,mi,null),b(this,hi,null),b(this,gi,null),b(this,_i,null),b(this,vi,!1),C(hi,this,e),C(vi,this,e._uiManager.useNewAltTextFlow),Ci._||(Ci._=Object.freeze({added:`pdfjs-editor-new-alt-text-added-button`,"added-label":`pdfjs-editor-new-alt-text-added-button-label`,missing:`pdfjs-editor-new-alt-text-missing-button`,"missing-label":`pdfjs-editor-new-alt-text-missing-button-label`,review:`pdfjs-editor-new-alt-text-to-review-button`,"review-label":`pdfjs-editor-new-alt-text-to-review-button-label`}))}static initialize(t){e._l10n!=null||(e._l10n=t)}render(){var e=this;return v(function*(){let t=C(li,e,document.createElement(`button`));t.className=`altText`,t.tabIndex=`0`;let n=C(ui,e,document.createElement(`span`));t.append(n),x(vi,e)?(t.classList.add(`new`),t.setAttribute(`data-l10n-id`,Ci._.missing),n.setAttribute(`data-l10n-id`,Ci._[`missing-label`])):(t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button`),n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button-label`));let r=x(hi,e)._uiManager._signal;t.addEventListener(`contextmenu`,wt,{signal:r}),t.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:r});let i=t=>{t.preventDefault(),x(hi,e)._uiManager.editAltText(x(hi,e)),x(vi,e)&&x(hi,e)._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:xi.call(f(yi,e))}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,n=>{n.target===t&&n.key===`Enter`&&(C(pi,e,!0),i(n))},{signal:r}),yield f(yi,e,Si).call(e),t})()}finish(){x(li,this)&&(x(li,this).focus({focusVisible:x(pi,this)}),C(pi,this,!1))}isEmpty(){return x(vi,this)?x(si,this)===null:!x(si,this)&&!x(ci,this)}hasData(){return x(vi,this)?x(si,this)!==null||!!x(gi,this):this.isEmpty()}get guessedText(){return x(gi,this)}setGuessedText(t){var n=this;return v(function*(){x(si,n)===null&&(C(gi,n,t),C(_i,n,yield e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t})),f(yi,n,Si).call(n))})()}toggleAltTextBadge(e=!1){if(!x(vi,this)||x(si,this)){var t;(t=x(mi,this))==null||t.remove(),C(mi,this,null);return}if(!x(mi,this)){let e=C(mi,this,document.createElement(`div`));e.className=`noAltTextBadge`,x(hi,this).div.append(e)}x(mi,this).classList.toggle(`hidden`,!e)}serialize(e){let t=x(si,this);return!e&&x(gi,this)===t&&(t=x(_i,this)),{altText:t,decorative:x(ci,this),guessedText:x(gi,this),textWithDisclaimer:x(_i,this)}}get data(){return{altText:x(si,this),decorative:x(ci,this)}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(C(gi,this,n),C(_i,this,r)),!(x(si,this)===e&&x(ci,this)===t)&&(i||(C(si,this,e),C(ci,this,t)),f(yi,this,Si).call(this))}toggle(e=!1){x(li,this)&&(!e&&x(fi,this)&&(clearTimeout(x(fi,this)),C(fi,this,null)),x(li,this).disabled=!e)}shown(){x(hi,this)._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:xi.call(f(yi,this))}})}destroy(){var e,t;(e=x(li,this))==null||e.remove(),C(li,this,null),C(ui,this,null),C(di,this,null),(t=x(mi,this))==null||t.remove(),C(mi,this,null)}};function xi(){return x(si,this)&&`added`||x(si,this)===null&&this.guessedText&&`review`||`missing`}function Si(){var e=this;return v(function*(){let t=x(li,e);if(!t)return;if(x(vi,e)){var n;if(t.classList.toggle(`done`,!!x(si,e)),t.setAttribute(`data-l10n-id`,Ci._[xi.call(f(yi,e))]),(n=x(ui,e))==null||n.setAttribute(`data-l10n-id`,Ci._[`${xi.call(f(yi,e))}-label`]),!x(si,e)){var r;(r=x(di,e))==null||r.remove();return}}else{if(!x(si,e)&&!x(ci,e)){var i;t.classList.remove(`done`),(i=x(di,e))==null||i.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let a=x(di,e);if(!a){C(di,e,a=document.createElement(`span`)),a.className=`tooltip`,a.setAttribute(`role`,`tooltip`),a.id=`alt-text-tooltip-${x(hi,e).id}`;let n=x(hi,e)._uiManager._signal;n.addEventListener(`abort`,()=>{clearTimeout(x(fi,e)),C(fi,e,null)},{once:!0}),t.addEventListener(`mouseenter`,()=>{C(fi,e,setTimeout(()=>{C(fi,e,null),x(di,e).classList.add(`show`),x(hi,e)._reportTelemetry({action:`alt_text_tooltip`})},100))},{signal:n}),t.addEventListener(`mouseleave`,()=>{var t;x(fi,e)&&(clearTimeout(x(fi,e)),C(fi,e,null)),(t=x(di,e))==null||t.classList.remove(`show`)},{signal:n})}x(ci,e)?a.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(a.removeAttribute(`data-l10n-id`),a.textContent=x(si,e)),a.parentNode||t.append(a);let o=x(hi,e).getElementForAltText();o==null||o.setAttribute(`aria-describedby`,a.id)})()}var Ci={_:null};g(bi,`_l10n`,null);var wi=new WeakMap,Ti=new WeakMap,Ei=new WeakMap,Di=new WeakMap,Oi=new WeakMap,ki=new WeakMap,Ai=new WeakMap,ji=new WeakMap,Mi=new WeakMap,Ni=new WeakMap,Pi=new WeakSet,Fi=class{constructor(e){S(this,Pi),b(this,wi,null),b(this,Ti,null),b(this,Ei,!1),b(this,Di,null),b(this,Oi,null),b(this,ki,null),b(this,Ai,null),b(this,ji,null),b(this,Mi,!1),b(this,Ni,null),C(Di,this,e)}renderForToolbar(){let e=C(Ti,this,document.createElement(`button`));return e.className=`comment`,f(Pi,this,Ii).call(this,e,!1)}renderForStandalone(){let e=C(wi,this,document.createElement(`button`));e.className=`annotationCommentButton`;let t=x(Di,this).commentButtonPosition;if(t){let{style:n}=e;n.insetInlineEnd=`calc(${100*(x(Di,this)._uiManager.direction===`ltr`?1-t[0]:t[0])}% - var(--comment-button-dim))`,n.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;let r=x(Di,this).commentButtonColor;r&&(n.backgroundColor=r)}return f(Pi,this,Ii).call(this,e,!0)}focusButton(){setTimeout(()=>{var e,t;(e=(t=x(wi,this))==null?x(Ti,this):t)==null||e.focus()},0)}onUpdatedColor(){if(!x(wi,this))return;let e=x(Di,this).commentButtonColor;e&&(x(wi,this).style.backgroundColor=e),x(Di,this)._uiManager.updatePopupColor(x(Di,this))}get commentButtonWidth(){var e,t;return((e=(t=x(wi,this))==null?void 0:t.getBoundingClientRect().width)==null?0:e)/x(Di,this).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(x(Ni,this))return x(Ni,this);if(!x(wi,this))return null;let{x:e,y:t,height:n}=x(wi,this).getBoundingClientRect(),{x:r,y:i,width:a,height:o}=x(Di,this).parent.boundingClientRect;return[(e-r)/a,(t+n-i)/o]}set commentPopupPositionInLayer(e){C(Ni,this,e)}hasDefaultPopupPosition(){return x(Ni,this)===null}removeStandaloneCommentButton(){var e;(e=x(wi,this))==null||e.remove(),C(wi,this,null)}removeToolbarCommentButton(){var e;(e=x(Ti,this))==null||e.remove(),C(Ti,this,null)}setCommentButtonStates({selected:e,hasPopup:t}){x(wi,this)&&(x(wi,this).classList.toggle(`selected`,e),x(wi,this).ariaExpanded=t)}edit(e){let t=this.commentPopupPositionInLayer,n,r;if(t)[n,r]=t;else{[n,r]=x(Di,this).commentButtonPosition;let{width:e,height:t,x:i,y:a}=x(Di,this);n=i+n*e,r=a+r*t}let i=x(Di,this).parent.boundingClientRect,{x:a,y:o,width:s,height:c}=i;x(Di,this)._uiManager.editComment(x(Di,this),a+n*s,o+r*c,T(T({},e),{},{parentDimensions:i}))}finish(){x(Ti,this)&&(x(Ti,this).focus({focusVisible:x(Ei,this)}),C(Ei,this,!1))}isDeleted(){return x(Mi,this)||x(Ai,this)===``}isEmpty(){return x(Ai,this)===null}hasBeenEdited(){return this.isDeleted()||x(Ai,this)!==x(Oi,this)}serialize(){return this.data}get data(){return{text:x(Ai,this),richText:x(ki,this),date:x(ji,this),deleted:this.isDeleted()}}set data(e){if(e!==x(Ai,this)&&C(ki,this,null),e===null){C(Ai,this,``),C(Mi,this,!0);return}C(Ai,this,e),C(ji,this,new Date),C(Mi,this,!1)}restoreData({text:e,richText:t,date:n}){C(Ai,this,e),C(ki,this,t),C(ji,this,n),C(Mi,this,!1)}setInitialText(e,t=null){C(Oi,this,e),this.data=e,C(ji,this,null),C(ki,this,t)}shown(){}destroy(){var e,t;(e=x(Ti,this))==null||e.remove(),C(Ti,this,null),(t=x(wi,this))==null||t.remove(),C(wi,this,null),C(Ai,this,``),C(ki,this,null),C(ji,this,null),C(Di,this,null),C(Ei,this,!1),C(Mi,this,!1)}};function Ii(e,t){if(!x(Di,this)._uiManager.hasCommentManager())return null;e.tabIndex=`0`,e.ariaHasPopup=`dialog`,t?(e.ariaControls=`commentPopup`,e.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`)):(e.ariaControlsElements=[x(Di,this)._uiManager.getCommentDialogElement()],e.setAttribute(`data-l10n-id`,`pdfjs-editor-add-comment-button`));let n=x(Di,this)._uiManager._signal;if(!(n instanceof AbortSignal)||n.aborted)return e;e.addEventListener(`contextmenu`,wt,{signal:n}),t&&(e.addEventListener(`focusin`,e=>{x(Di,this)._focusEventsAllowed=!1,Tt(e)},{capture:!0,signal:n}),e.addEventListener(`focusout`,e=>{x(Di,this)._focusEventsAllowed=!0,Tt(e)},{capture:!0,signal:n})),e.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:n});let r=t=>{t.preventDefault(),e===x(Ti,this)?this.edit():x(Di,this).toggleComment(!0)};return e.addEventListener(`click`,r,{capture:!0,signal:n}),e.addEventListener(`keydown`,t=>{t.target===e&&t.key===`Enter`&&(C(Ei,this,!0),r(t))},{signal:n}),e.addEventListener(`pointerenter`,()=>{x(Di,this).toggleComment(!1,!0)},{signal:n}),e.addEventListener(`pointerleave`,()=>{x(Di,this).toggleComment(!1,!1)},{signal:n}),e}var Li=new WeakMap,Ri=new WeakMap,zi=new WeakMap,Bi=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,Ui=new WeakMap,Wi=new WeakMap,Gi=new WeakMap,Ki=new WeakMap,qi=new WeakMap,Ji=new WeakMap,Yi=new WeakSet,Xi=class{constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){S(this,Yi),b(this,Li,void 0),b(this,Ri,!1),b(this,zi,null),b(this,Bi,void 0),b(this,Vi,void 0),b(this,Hi,void 0),b(this,Ui,void 0),b(this,Wi,null),b(this,Gi,void 0),b(this,Ki,null),b(this,qi,void 0),b(this,Ji,null),C(Li,this,e),C(zi,this,n),C(Bi,this,t),C(Vi,this,r),C(Hi,this,i),C(Ui,this,a),C(qi,this,new AbortController),C(Gi,this,AbortSignal.any([o,x(qi,this).signal])),e.addEventListener(`touchstart`,f(Yi,this,Zi).bind(this),{passive:!1,signal:x(Gi,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Pt.pixelRatio}destroy(){var e,t;(e=x(qi,this))==null||e.abort(),C(qi,this,null),(t=x(Wi,this))==null||t.abort(),C(Wi,this,null)}};re=Xi;function Zi(e){var t,n;if((t=x(Bi,this))!=null&&t.call(this))return;if(e.touches.length===1){if(x(Wi,this))return;let e=C(Wi,this,new AbortController),t=AbortSignal.any([x(Gi,this),e.signal]),n=x(Li,this),r={capture:!0,signal:t,passive:!1},i=e=>{if(e.pointerType===`touch`){var t;(t=x(Wi,this))==null||t.abort(),C(Wi,this,null)}};n.addEventListener(`pointerdown`,e=>{e.pointerType===`touch`&&(Tt(e),i(e))},r),n.addEventListener(`pointerup`,i,r),n.addEventListener(`pointercancel`,i,r);return}if(!x(Ji,this)){var r;C(Ji,this,new AbortController);let e=AbortSignal.any([x(Gi,this),x(Ji,this).signal]),t=x(Li,this),n={signal:e,capture:!1,passive:!1};t.addEventListener(`touchmove`,f(Yi,this,Qi).bind(this),n);let i=f(Yi,this,$i).bind(this);t.addEventListener(`touchend`,i,n),t.addEventListener(`touchcancel`,i,n),n.capture=!0,t.addEventListener(`pointerdown`,Tt,n),t.addEventListener(`pointermove`,Tt,n),t.addEventListener(`pointercancel`,Tt,n),t.addEventListener(`pointerup`,Tt,n),(r=x(Vi,this))==null||r.call(this)}if(Tt(e),e.touches.length!==2||(n=x(zi,this))!=null&&n.call(this)){C(Ki,this,null);return}let[i,a]=e.touches;i.identifier>a.identifier&&([i,a]=[a,i]),C(Ki,this,{touch0X:i.screenX,touch0Y:i.screenY,touch1X:a.screenX,touch1Y:a.screenY})}function Qi(e){var t;if(!x(Ki,this)||e.touches.length!==2)return;Tt(e);let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=x(Ki,this),{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!x(Ri,this)&&Math.abs(v-_)<=re.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,!x(Ri,this)){C(Ri,this,!0);return}let y=[(i+o)/2,(a+s)/2];(t=x(Hi,this))==null||t.call(this,y,v,_)}function $i(e){if(!(e.touches.length>=2)){if(x(Ji,this)){var t;x(Ji,this).abort(),C(Ji,this,null),(t=x(Ui,this))==null||t.call(this)}x(Ki,this)&&(Tt(e),C(Ki,this,null),C(Ri,this,!1))}}var ea=new WeakMap,ta=new WeakMap,na=new WeakMap,H=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa=new WeakMap,oa=new WeakMap,sa=new WeakMap,ca=new WeakMap,la=new WeakMap,ua=new WeakMap,da=new WeakMap,fa=new WeakMap,pa=new WeakMap,ma=new WeakMap,ha=new WeakMap,ga=new WeakMap,_a=new WeakMap,va=new WeakMap,ya=new WeakMap,ba=new WeakMap,xa=new WeakMap,Sa=new WeakMap,Ca=new WeakMap,wa=new WeakMap,U=new WeakSet,W=class e{static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=Rr.TRANSLATE_SMALL,r=Rr.TRANSLATE_BIG;return L(this,`_resizerKeyboardManager`,new Rn([[[`ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(t){S(this,U),b(this,ea,null),b(this,ta,null),b(this,na,null),b(this,H,null),b(this,ra,null),b(this,ia,!1),b(this,aa,null),b(this,oa,``),b(this,sa,null),b(this,ca,null),b(this,la,null),b(this,ua,null),b(this,da,null),b(this,fa,``),b(this,pa,!1),b(this,ma,null),b(this,ha,!1),b(this,ga,!1),b(this,_a,!1),b(this,va,null),b(this,ya,0),b(this,ba,0),b(this,xa,null),b(this,Sa,null),g(this,`isSelected`,!1),g(this,`_isCopy`,!1),g(this,`_editToolbar`,null),g(this,`_initialOptions`,Object.create(null)),g(this,`_initialData`,null),g(this,`_isVisible`,!0),g(this,`_uiManager`,null),g(this,`_focusEventsAllowed`,!0),b(this,Ca,!1),b(this,wa,e._zIndex++),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{rotation:n,rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,i],this.pageTranslation=[a,o];let[s,c]=this.parentDimensions;this.x=t.x/s,this.y=t.y/c,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return L(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new Wa({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n!=null||(e._l10n=t),e._l10nAlert!=null||(e._l10nAlert=Object.freeze({highlight:`pdfjs-editor-highlight-added-alert`,freetext:`pdfjs-editor-freetext-added-alert`,ink:`pdfjs-editor-ink-added-alert`,stamp:`pdfjs-editor-stamp-added-alert`,signature:`pdfjs-editor-signature-added-alert`})),e._l10nResizer!=null||(e._l10nResizer=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`})),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){I(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return x(Ca,this)}set _isDraggable(e){var t;C(Ca,this,e),(t=this.div)==null||t.classList.toggle(`draggable`,e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=x(wa,this)}setParent(e){if(e!==null)this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions;else{var t;f(U,this,Ua).call(this),(t=x(ua,this))==null||t.remove(),C(ua,this,null)}this.parent=e}focusin(e){this._focusEventsAllowed&&(x(pa,this)?C(pa,this,!1):this.parent.setSelected(this))}focusout(e){var t;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let n=e.relatedTarget;n!=null&&n.closest(`#${this.id}`)||(e.preventDefault(),(t=this.parent)!=null&&t.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}let[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r),this._onTranslated()}translate(e,t){f(U,this,Ta).call(this,this.parentDimensions,e,t)}translateInPage(e,t){x(ma,this)||C(ma,this,[this.x,this.y,this.width,this.height]),f(U,this,Ta).call(this,this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){x(ma,this)||C(ma,this,[this.x,this.y,this.width,this.height]);let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!x(ma,this)&&(x(ma,this)[0]!==this.x||x(ma,this)[1]!==this.y)}get _hasBeenResized(){return!!x(ma,this)&&(x(ma,this)[2]!==this.width||x(ma,this)[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=B(i,0,n-o),a=B(a,0,r-s);break;case 90:i=B(i,0,n-s),a=B(a,o,r);break;case 180:i=B(i,o,n),a=B(a,s,r);break;case 270:i=B(i,s,n),a=B(a,0,r-o);break}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,n){return Ea.call(e,t,n,this.parentRotation)}pageTranslationToScreen(t,n){return Ea.call(e,t,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(){let{div:{style:e},width:t,height:n}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*n).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=x(na,this))==null||e.finish()}get toolbarButtons(){return null}addEditToolbar(){var e=this;return v(function*(){if(e._editToolbar||x(ga,e))return e._editToolbar;e._editToolbar=new nn(e),e.div.append(e._editToolbar.render());let{toolbarButtons:t}=e;if(t)for(let[n,r]of t)yield e._editToolbar.addButton(n,r);return e.hasComment||e._editToolbar.addButton(`comment`,e.addCommentButton()),e._editToolbar.addButton(`delete`),e._editToolbar})()}addCommentButtonInToolbar(){var e;(e=this._editToolbar)==null||e.addButtonBefore(`comment`,this.addCommentButton(),`.deleteButton`)}removeCommentButtonFromToolbar(){var e;(e=this._editToolbar)==null||e.removeButton(`comment`)}removeEditToolbar(){var e,t;(e=this._editToolbar)==null||e.remove(),this._editToolbar=null,(t=x(na,this))==null||t.destroy()}addContainer(e){var t;let n=(t=this._editToolbar)==null?void 0:t.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return x(na,this)||(bi.initialize(e._l10n),C(na,this,new bi(this)),x(ea,this)&&(x(na,this).data=x(ea,this),C(ea,this,null))),x(na,this)}get altTextData(){var e;return(e=x(na,this))==null?void 0:e.data}set altTextData(e){x(na,this)&&(x(na,this).data=e)}get guessedAltText(){var e;return(e=x(na,this))==null?void 0:e.guessedText}setGuessedAltText(e){var t=this;return v(function*(){var n;yield(n=x(na,t))==null?void 0:n.setGuessedText(e)})()}serializeAltText(e){var t;return(t=x(na,this))==null?void 0:t.serialize(e)}hasAltText(){return!!x(na,this)&&!x(na,this).isEmpty()}hasAltTextData(){var e,t;return(e=(t=x(na,this))==null?void 0:t.hasData())!=null&&e}focusCommentButton(){var e;(e=x(H,this))==null||e.focusButton()}addCommentButton(){return this.canAddComment?x(H,this)||C(H,this,new Fi(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(x(ra,this)){this._uiManager.isEditingMode()&&x(ra,this).classList.remove(`hidden`);return}this.hasComment&&(C(ra,this,x(H,this).renderForStandalone()),this.div.append(x(ra,this)))}}removeStandaloneCommentButton(){x(H,this).removeStandaloneCommentButton(),C(ra,this,null)}hideStandaloneCommentButton(){var e;(e=x(ra,this))==null||e.classList.add(`hidden`)}get comment(){var e;if(!x(H,this))return null;let{data:{richText:t,text:n,date:r,deleted:i}}=x(H,this);return{text:n,richText:t,date:r,deleted:i,color:this.getNonHCMColor(),opacity:(e=this.opacity)==null?1:e}}set comment(e){x(H,this)||C(H,this,new Fi(this)),typeof e==`object`&&e?x(H,this).restoreData(e):x(H,this).data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:t,richText:n}){if(!t||(x(H,this)||C(H,this,new Fi(this)),x(H,this).setInitialText(e,n),!this.annotationElementId))return;let r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){var e;return(e=x(H,this))==null?void 0:e.hasBeenEdited()}get hasDeletedComment(){var e;return(e=x(H,this))==null?void 0:e.isDeleted()}get hasComment(){return!!x(H,this)&&!x(H,this).isEmpty()&&!x(H,this).isDeleted()}editComment(e){var t=this;return v(function*(){x(H,t)||C(H,t,new Fi(t)),x(H,t).edit(e)})()}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){x(H,this).setSelectedButton(e)}addComment(e){if(this.hasEditedComment){let[,,,t]=e.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,i=r+n+1,a=t-100,o=i+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[i,a,o,t]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){x(H,this).data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var e;let t=this.div=document.createElement(`div`);t.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),t.className=this.name,t.setAttribute(`id`,this.id),t.tabIndex=x(ia,this)?-1:0,t.setAttribute(`role`,`application`),this.defaultL10nId&&t.setAttribute(`data-l10n-id`,this.defaultL10nId),this._isVisible||t.classList.add(`hidden`),this.setInForeground(),f(U,this,Ra).call(this);let[n,r]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*r/n).toFixed(2)}%`,t.style.maxHeight=`${(100*n/r).toFixed(2)}%`);let[i,a]=this.getInitialTranslation();return this.translate(i,a),yn(this,t,[`keydown`,`pointerdown`,`dblclick`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(x(Sa,this)||C(Sa,this,new Xi({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:f(U,this,Na).bind(this),onPinching:f(U,this,Pa).bind(this),onPinchEnd:f(U,this,Fa).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(e=this._uiManager._editorUndoBar)==null||e.hide(),t}pointerdown(e){let{isMac:t}=R.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(C(pa,this,!0),this._isDraggable){f(U,this,La).call(this,e);return}f(U,this,Ia).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){x(va,this)&&clearTimeout(x(va,this)),C(va,this,setTimeout(()=>{var e;C(va,this,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&e._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var e;(e=x(H,this))==null||e.onUpdatedColor()}getData(){let{comment:{text:e,color:t,date:n,opacity:r,deleted:i,richText:a},uid:o,pageIndex:s,creationDate:c,modificationDate:l}=this;return{id:o,pageIndex:s,rect:this.getPDFRect(),richText:a,contentsObj:{str:e},creationDate:c,modificationDate:n||l,popupRef:!i,color:t,opacity:r}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),C(ga,this,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),C(ga,this,!1),!0):!1}isInEditMode(){return x(ga,this)}shouldGetKeyboardEvents(){return x(_a,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t<a&&r>0&&e<i&&n>0}rebuild(){f(U,this,Ra).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||``}}serialize(e=!1,t=null){var n;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((n=this._initialData)==null?void 0:n.popupRef)||``}}static deserialize(e,t,n){var r=this;return v(function*(){let i=new r.prototype.constructor({parent:t,id:n.getId(),uiManager:n,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});i.rotation=e.rotation,C(ea,i,e.accessibilityData),i._isCopy=e.isCopy||!1;let[a,o]=i.pageDimensions,[s,c,l,u]=i.getRectInCurrentCoords(e.rect,o);return i.x=s/a,i.y=c/o,i.width=l/a,i.height=u/o,i})()}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,t,n;if((e=x(da,this))==null||e.abort(),C(da,this,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),x(va,this)&&(clearTimeout(x(va,this)),C(va,this,null)),f(U,this,Ua).call(this),this.removeEditToolbar(),x(xa,this)){for(let e of x(xa,this).values())clearTimeout(e);C(xa,this,null)}this.parent=null,(t=x(Sa,this))==null||t.destroy(),C(Sa,this,null),(n=x(ua,this))==null||n.remove(),C(ua,this,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(f(U,this,Oa).call(this),x(sa,this).classList.remove(`hidden`))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction===`ltr`?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,n]}=this,[r,i,a,o]=this.getPDFRect();return[e._round(r+(a-r)*t),e._round(i+(o-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return x(H,this).commentPopupPositionInLayer}set commentPopupPosition(e){x(H,this).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return x(H,this).hasDefaultPopupPosition()}get commentButtonWidth(){return x(H,this).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){var t;(t=x(H,this))==null||t.setCommentButtonStates(e)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),C(la,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});let n=x(sa,this).children;if(!x(ta,this)){C(ta,this,Array.from(n));let t=f(U,this,za).bind(this),r=f(U,this,Ba).bind(this),i=this._uiManager._signal;for(let n of x(ta,this)){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,f(U,this,Va).bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=x(ta,this)[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(x(ta,this).length/4);if(a!==i){if(a<i)for(let e=0;e<i-a;e++)x(sa,this).append(x(sa,this).firstElementChild);else if(a>i)for(let e=0;e<a-i;e++)x(sa,this).firstElementChild.before(x(sa,this).lastElementChild);let t=0;for(let r of n){let n=x(ta,this)[t++].getAttribute(`data-resizer-name`);r.setAttribute(`data-l10n-id`,e._l10nResizer[n])}}f(U,this,Ha).call(this,0),C(_a,this,!0),x(sa,this).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(e,t){x(_a,this)&&f(U,this,Ma).call(this,x(fa,this),{deltaX:e,deltaY:t,fromKeyboard:!0})}_stopResizingWithKeyboard(){f(U,this,Ua).call(this),this.div.focus()}select(){var e,t,n;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(e=this.div)==null||e.classList.add(`selectedEditor`),!this._editToolbar){this.addEditToolbar().then(()=>{var e;if((e=this.div)!=null&&e.classList.contains(`selectedEditor`)){var t;(t=this._editToolbar)==null||t.show()}});return}(t=this._editToolbar)==null||t.show(),(n=x(na,this))==null||n.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var e;return(e=this.div)==null?void 0:e.focus({preventScroll:!0})},0)}unselect(){var e,t,n,r,i;this.isSelected&&(this.isSelected=!1,(e=x(sa,this))==null||e.classList.add(`hidden`),(t=this.div)==null||t.classList.remove(`selectedEditor`),(n=this.div)!=null&&n.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(r=this._editToolbar)==null||r.hide(),(i=x(na,this))==null||i.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!==`BUTTON`&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return x(ha,this)}set isEditing(e){C(ha,this,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){x(xa,this)||C(xa,this,new Map);let{action:n}=t,r=x(xa,this).get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),x(xa,this).delete(n),x(xa,this).size===0&&C(xa,this,null)},e._telemetryTimeout),x(xa,this).set(n,r);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),C(ia,this,!1)}disable(){this.div&&(this.div.tabIndex=-1),C(ia,this,!0)}updateFakeAnnotationElement(e){if(!x(ua,this)&&!this.deleted){C(ua,this,e.addFakeAnnotation(this));return}if(this.deleted){x(ua,this).remove(),C(ua,this,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&x(ua,this).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstElementChild:t}=e.container;(t==null?void 0:t.nodeName)===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}};j=W;function Ta([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}function Ea(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}function Da(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}function Oa(){if(x(sa,this))return;C(sa,this,document.createElement(`div`)),x(sa,this).classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);x(sa,this).append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,f(U,this,ka).bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,wt,{signal:t}),e.tabIndex=-1}this.div.prepend(x(sa,this))}function ka(e,t){var n;t.preventDefault();let{isMac:r}=R.platform;if(t.button!==0||t.ctrlKey&&r)return;(n=x(na,this))==null||n.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,C(ca,this,[t.screenX,t.screenY]);let a=new AbortController,o=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,f(U,this,Ma).bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener(`touchmove`,Tt,{passive:!1,signal:o}),window.addEventListener(`contextmenu`,wt,{signal:o}),C(la,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});let s=this.parent.div.style.cursor,c=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let l=()=>{var e;a.abort(),this.parent.togglePointerEvents(!0),(e=x(na,this))==null||e.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=s,this.div.style.cursor=c,f(U,this,ja).call(this)};window.addEventListener(`pointerup`,l,{signal:o}),window.addEventListener(`blur`,l,{signal:o})}function Aa(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}function ja(){if(!x(la,this))return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=x(la,this);C(la,this,null);let i=this.x,a=this.y,o=this.width,s=this.height;i===e&&a===t&&o===n&&s===r||this.addCommands({cmd:f(U,this,Aa).bind(this,i,a,o,s),undo:f(U,this,Aa).bind(this,e,t,n,r),mustExec:!0})}function Ma(e,t){let[n,r]=this.parentDimensions,i=this.x,a=this.y,o=this.width,s=this.height,c=j.MIN_SIZE/n,l=j.MIN_SIZE/r,u=f(U,this,Da).call(this,this.rotation),d=(e,t)=>[u[0]*e+u[2]*t,u[1]*e+u[3]*t],p=f(U,this,Da).call(this,360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(e){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2];break}let y=h(o,s),b=g(o,s),S=d(...b),w=j._round(i+S[0]),T=j._round(a+S[1]),E=1,D=1,O,k;if(t.fromKeyboard)({deltaX:O,deltaY:k}=t);else{let{screenX:e,screenY:n}=t,[r,i]=x(ca,this);[O,k]=this.screenToPageTranslation(e-r,n-i),x(ca,this)[0]=e,x(ca,this)[1]=n}if([O,k]=m(O/n,k/r),_){let e=Math.hypot(o,s);E=D=Math.max(Math.min(Math.hypot(b[0]-y[0]-O,b[1]-y[1]-k)/e,1/o,1/s),c/o,l/s)}else v?E=B(Math.abs(b[0]-y[0]-O),c,1)/o:D=B(Math.abs(b[1]-y[1]-k),l,1)/s;let A=j._round(o*E),ee=j._round(s*D);S=d(...g(A,ee));let te=w-S[0],ne=T-S[1];x(ma,this)||C(ma,this,[this.x,this.y,this.width,this.height]),this.width=A,this.height=ee,this.x=te,this.y=ne,this.setDims(),this.fixAndSetPosition(),this._onResizing()}function Na(){var e;C(la,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=x(na,this))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)}function Pa(e,t,n){let r=.7,i=n/t*r+1-r;if(i===1)return;let a=f(U,this,Da).call(this,this.rotation),o=(e,t)=>[a[0]*e+a[2]*t,a[1]*e+a[3]*t],[s,c]=this.parentDimensions,l=this.x,u=this.y,d=this.width,p=this.height,m=j.MIN_SIZE/s,h=j.MIN_SIZE/c;i=Math.max(Math.min(i,1/d,1/p),m/d,h/p);let g=j._round(d*i),_=j._round(p*i);if(g===d&&_===p)return;x(ma,this)||C(ma,this,[l,u,d,p]);let v=o(d/2,p/2),y=j._round(l+v[0]),b=j._round(u+v[1]),S=o(g/2,_/2);this.x=y-S[0],this.y=b-S[1],this.width=g,this.height=_,this.setDims(),this.fixAndSetPosition(),this._onResizing()}function Fa(){var e;(e=x(na,this))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),f(U,this,ja).call(this)}function Ia(e){let{isMac:t}=R.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}function La(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),C(aa,this,null),C(pa,this,!1),this._uiManager.endDragSession()||f(U,this,Ia).call(this,e),n&&this._onStopDragging()};t&&(C(ya,this,e.clientX),C(ba,this,e.clientY),C(aa,this,e.pointerId),C(oa,this,e.pointerType),window.addEventListener(`pointermove`,e=>{n||(n=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==x(aa,this)){Tt(e);return}let[a,o]=this.screenToPageTranslation(t-x(ya,this),r-x(ba,this));C(ya,this,t),C(ba,this,r),this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,Tt,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===x(oa,this)&&(x(Sa,this)||e.isPrimary)&&o(e),Tt(e)},a));let s=e=>{if(!x(aa,this)||x(aa,this)===e.pointerId){o(e);return}Tt(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}function Ra(){if(x(da,this)||!this.div)return;C(da,this,new AbortController);let e=this._uiManager.combinedSignal(x(da,this));this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}function za(e){j._resizerKeyboardManager.exec(this,e)}function Ba(e){var t;x(_a,this)&&((t=e.relatedTarget)==null?void 0:t.parentNode)!==x(sa,this)&&f(U,this,Ua).call(this)}function Va(e){C(fa,this,x(_a,this)?e:``)}function Ha(e){if(x(ta,this))for(let t of x(ta,this))t.tabIndex=e}function Ua(){C(_a,this,!1),f(U,this,Ha).call(this,-1),f(U,this,ja).call(this)}g(W,`_l10n`,null),g(W,`_l10nAlert`,null),g(W,`_l10nResizer`,null),g(W,`_borderLineWidth`,-1),g(W,`_colorManager`,new Vn),g(W,`_zIndex`,1),g(W,`_telemetryTimeout`,1e3);var Wa=class extends W{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},Ga=3285377520,Ka=4294901760,qa=65535,Ja=class{constructor(e){this.h1=e?e&4294967295:Ga,this.h2=e?e&4294967295:Ga}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&Ka|o*f&qa,o=o<<15|o>>>17,o=o*d&Ka|o*p&qa,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&Ka|s*f&qa,s=s<<15|s>>>17,s=s*d&Ka|s*p&qa,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&Ka|o*f&qa,o=o<<15|o>>>17,o=o*d&Ka|o*p&qa,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&Ka|e*36045&qa,t=t*4283543511&Ka|((t<<16|e>>>16)*2950163797&Ka)>>>16,e^=t>>>1,e=e*444984403&Ka|e*60499&qa,t=t*3301882366&Ka|((t<<16|e>>>16)*3120437893&Ka)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},Ya=Object.freeze({map:null,hash:``,transfer:void 0}),Xa=new WeakMap,Za=new WeakMap,Qa=new WeakMap,$a=new WeakMap,eo=new WeakSet;pe=Symbol.iterator;var to=class{constructor(){S(this,eo),b(this,Xa,!1),b(this,Za,null),b(this,Qa,null),b(this,$a,new Map),g(this,`onSetModified`,null),g(this,`onResetModified`,null),g(this,`onAnnotationEditor`,null)}getValue(e,t){let n=x($a,this).get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return x($a,this).get(e)}remove(e){var t;let n=x($a,this).get(e);n!==void 0&&(n instanceof W&&x(Qa,this).delete(n.annotationElementId),x($a,this).delete(e),x($a,this).size===0&&this.resetModified(),!x($a,this).values().some(e=>e instanceof W)&&((t=this.onAnnotationEditor)==null||t.call(this,null)))}setValue(e,t){let n=x($a,this).get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,x($a,this).set(e,t);if(r&&f(eo,this,no).call(this),t instanceof W){var i;(x(Qa,this)||C(Qa,this,new Map)).set(t.annotationElementId,t),(i=this.onAnnotationEditor)==null||i.call(this,t.constructor._type)}}has(e){return x($a,this).has(e)}get size(){return x($a,this).size}resetModified(){if(x(Xa,this)){var e;C(Xa,this,!1),(e=this.onResetModified)==null||e.call(this)}}get print(){return new io(this)}get serializable(){if(x($a,this).size===0)return Ya;let e=new Map,t=new Ja,n=[],r=Object.create(null),i=!1;for(let[n,a]of x($a,this)){let o=a instanceof W?a.serialize(!1,r):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||(i=!!o.bitmap))}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:Ya}get editorStats(){let e=null,t=new Map,n=0,r=0;for(let o of x($a,this).values()){var i;if(!(o instanceof W)){o.popup&&(o.popup.deleted?r+=1:n+=1);continue}o.isCommentDeleted?r+=1:o.hasEditedComment&&(n+=1);let s=o.telemetryFinalData;if(!s)continue;let{type:c}=s;t.getOrInsertComputed(c,()=>Object.getPrototypeOf(o).constructor),e||(e=Object.create(null));let l=(i=e)[c]||(i[c]=new Map);for(let[e,t]of Object.entries(s)){var a;if(e===`type`)continue;let n=l.getOrInsertComputed(e,ct);n.set(t,((a=n.get(t))==null?0:a)+1)}}if((r>0||n>0)&&(e||(e=Object.create(null)),e.comments={deleted:r,edited:n}),!e)return null;for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){C(Za,this,null)}updateEditor(e,t){var n;let r=(n=x(Qa,this))==null?void 0:n.get(e);return r?(r.updateFromAnnotationLayer(t),!0):!1}getEditor(e){var t;return((t=x(Qa,this))==null?void 0:t.get(e))||null}get modifiedIds(){if(x(Za,this))return x(Za,this);let e=[];if(x(Qa,this))for(let t of x(Qa,this).values())t.serialize()&&e.push(t.annotationElementId);let t=``;if(e.length){let n=new Ja;n.update(e.join(`,`)),t=n.hexdigest()}return C(Za,this,{ids:new Set(e),hash:t})}[pe](){return x($a,this).entries()}};function no(){if(!x(Xa,this)){var e;C(Xa,this,!0),(e=this.onSetModified)==null||e.call(this)}}var ro=new WeakMap,io=class extends to{constructor(e){super(),b(this,ro,Ya);let{serializable:t}=e;if(t===Ya)return;let{map:n,hash:r,transfer:i}=t,a=structuredClone(n,i?{transfer:i}:null);C(ro,this,{map:a,hash:r,transfer:[]})}get print(){I(`Should not call PrintAnnotationStorage.print`)}get serializable(){return x(ro,this)}get modifiedIds(){return L(this,`modifiedIds`,{ids:new Set,hash:``})}},ao=`__forcedDependency`,{floor:oo,ceil:so}=Math;function co(e,t,n,r,i,a){e[t*4+0]=Math.min(e[t*4+0],n),e[t*4+1]=Math.min(e[t*4+1],r),e[t*4+2]=Math.max(e[t*4+2],i),e[t*4+3]=Math.max(e[t*4+3],a)}function lo(e,t,n,r,i){let a;e?(e<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=e,i[2]*=e,t<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=n,i[1]+=r,i[2]+=n,i[3]+=r}var uo=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],fo=new WeakMap,po=new WeakMap,mo=class{constructor(e,t){b(this,fo,void 0),b(this,po,void 0),C(fo,this,e),C(po,this,t)}get length(){return x(fo,this).length}isEmpty(e){return x(fo,this)[e]===uo}minX(e){return x(po,this)[e*4+0]/256}minY(e){return x(po,this)[e*4+1]/256}maxX(e){return(x(po,this)[e*4+2]+1)/256}maxY(e){return(x(po,this)[e*4+3]+1)/256}},ho=(e,t)=>e==null?void 0:e.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),go=new WeakMap,G=new WeakMap,_o=new WeakMap,vo=new WeakMap,yo=new WeakMap,bo=new WeakMap,xo=new WeakMap,So=new WeakSet,Co=class{constructor(e,t){S(this,So),b(this,go,[[1,0,0,1,0,0]]),b(this,G,[-1/0,-1/0,1/0,1/0]),b(this,_o,new Float64Array(ve)),g(this,`_pendingBBoxIdx`,-1),b(this,vo,void 0),b(this,yo,void 0),b(this,bo,void 0),b(this,xo,void 0),g(this,`_savesStack`,[]),g(this,`_markedContentStack`,[]),C(vo,this,e.width),C(yo,this,e.height),f(So,this,wo).call(this,t)}growOperationsCount(e){e>=x(xo,this).length&&f(So,this,wo).call(this,e,x(xo,this))}get clipBox(){return x(G,this)}save(e){return C(G,this,{__proto__:x(G,this)}),this._savesStack.push(e),this}restore(e,t){let n=Object.getPrototypeOf(x(G,this));if(n===null)return this;C(G,this,n);let r=this._savesStack.pop();return r!==void 0&&(t==null||t(r,e),x(xo,this)[e]=x(xo,this)[r]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,t){let n=this._savesStack.pop();return n!==void 0&&(t==null||t(n,e),x(xo,this)[e]=x(xo,this)[n]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){let n=this._markedContentStack.pop();return n!==void 0&&(t==null||t(n,e),x(xo,this)[e]=x(xo,this)[n]),this}pushBaseTransform(e){return x(go,this).push(z.multiplyByDOMMatrix(x(go,this).at(-1),e.getTransform())),this}popBaseTransform(){return x(go,this).length>1&&x(go,this).pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,x(_o,this).set(ve,0)),this}recordClipBox(e,t,n,r,i,a){let o=z.multiplyByDOMMatrix(x(go,this).at(-1),t.getTransform()),s=ve.slice();z.axialAlignedBoundingBox([n,i,r,a],o,s);let c=z.intersect(x(G,this),s);return c?(x(G,this)[0]=c[0],x(G,this)[1]=c[1],x(G,this)[2]=c[2],x(G,this)[3]=c[3]):(x(G,this)[0]=x(G,this)[1]=1/0,x(G,this)[2]=x(G,this)[3]=-1/0),this}recordBBox(e,t,n,r,i,a){let o=x(G,this);if(o[0]===1/0)return this;let s=z.multiplyByDOMMatrix(x(go,this).at(-1),t.getTransform());if(o[0]===-1/0)return z.axialAlignedBoundingBox([n,i,r,a],s,x(_o,this)),this;let c=ve.slice();return z.axialAlignedBoundingBox([n,i,r,a],s,c),x(_o,this)[0]=B(c[0],o[0],x(_o,this)[0]),x(_o,this)[1]=B(c[1],o[1],x(_o,this)[1]),x(_o,this)[2]=B(c[2],x(_o,this)[2],o[2]),x(_o,this)[3]=B(c[3],x(_o,this)[3],o[3]),this}recordFullPageBBox(e){return x(_o,this)[0]=Math.max(0,x(G,this)[0]),x(_o,this)[1]=Math.max(0,x(G,this)[1]),x(_o,this)[2]=Math.min(x(vo,this),x(G,this)[2]),x(_o,this)[3]=Math.min(x(yo,this),x(G,this)[3]),this}recordOperation(e,t=!1,n){if(this._pendingBBoxIdx!==e)return this;let r=oo(x(_o,this)[0]*256/x(vo,this)),i=oo(x(_o,this)[1]*256/x(yo,this)),a=so(x(_o,this)[2]*256/x(vo,this)),o=so(x(_o,this)[3]*256/x(yo,this));if(co(x(bo,this),e,r,i,a,o),n)for(let t of n)for(let n of t)n!==e&&co(x(bo,this),n,r,i,a,o);return t||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,x(G,this)[0]=Math.max(x(G,this)[0],x(_o,this)[0]),x(G,this)[1]=Math.max(x(G,this)[1],x(_o,this)[1]),x(G,this)[2]=Math.min(x(G,this)[2],x(_o,this)[2]),x(G,this)[3]=Math.min(x(G,this)[3],x(_o,this)[3])),this}take(){return new mo(x(xo,this),x(bo,this))}takeDebugMetadata(){throw Error(`Unreachable`)}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}};function wo(e,t){let n=new ArrayBuffer(e*4);C(bo,this,new Uint8ClampedArray(n)),C(xo,this,new Uint32Array(n)),t&&t.length>0?(x(xo,this).set(t),x(xo,this).fill(uo,t.length)):x(xo,this).fill(uo)}var To=new WeakMap,Eo=new WeakMap,Do=new WeakMap,Oo=new WeakMap,ko=new WeakMap,Ao=new WeakMap,jo=new WeakMap,Mo=new WeakMap,No=class{constructor(e,t=!1){b(this,To,{__proto__:null}),b(this,Eo,{__proto__:null,transform:[],moveText:[],sameLineText:[],[ao]:[]}),b(this,Do,new Map),b(this,Oo,new Set),b(this,ko,new Map),b(this,Ao,void 0),b(this,jo,void 0),b(this,Mo,void 0),C(Mo,this,e),t&&(C(Ao,this,new Map),C(jo,this,(e,t)=>{ho(x(Ao,this),t).dependencies.add(e)}))}get clipBox(){return x(Mo,this).clipBox}growOperationsCount(e){x(Mo,this).growOperationsCount(e)}save(e){return C(To,this,{__proto__:x(To,this)}),C(Eo,this,{__proto__:x(Eo,this),transform:{__proto__:x(Eo,this).transform},moveText:{__proto__:x(Eo,this).moveText},sameLineText:{__proto__:x(Eo,this).sameLineText},[ao]:{__proto__:x(Eo,this)[ao]}}),x(Mo,this).save(e),this}restore(e){x(Mo,this).restore(e,x(jo,this));let t=Object.getPrototypeOf(x(To,this));return t===null?this:(C(To,this,t),C(Eo,this,Object.getPrototypeOf(x(Eo,this))),this)}recordOpenMarker(e){return x(Mo,this).recordOpenMarker(e,x(jo,this)),this}getOpenMarker(){return x(Mo,this).getOpenMarker()}recordCloseMarker(e){return x(Mo,this).recordCloseMarker(e,x(jo,this)),this}beginMarkedContent(e){return x(Mo,this).beginMarkedContent(e),this}endMarkedContent(e){return x(Mo,this).endMarkedContent(e,x(jo,this)),this}pushBaseTransform(e){return x(Mo,this).pushBaseTransform(e),this}popBaseTransform(){return x(Mo,this).popBaseTransform(),this}recordSimpleData(e,t){return x(To,this)[e]=t,this}recordIncrementalData(e,t){return x(Eo,this)[e].push(t),this}resetIncrementalData(e,t){return x(Eo,this)[e].length=0,this}recordNamedData(e,t){return x(Do,this).set(e,t),this}recordSimpleDataFromNamed(e,t,n){var r;x(To,this)[e]=(r=x(Do,this).get(t))==null?n:r}recordFutureForcedDependency(e,t){return this.recordIncrementalData(ao,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(let t of e)t in x(To,this)&&this.recordFutureForcedDependency(t,x(To,this)[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let e of x(Oo,this))this.recordFutureForcedDependency(ao,e);return this}resetBBox(e){return x(Mo,this).resetBBox(e),this}recordClipBox(e,t,n,r,i,a){return x(Mo,this).recordClipBox(e,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return x(Mo,this).recordBBox(e,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){let s=n.bbox,c,l;if(s&&(c=s[2]!==s[0]&&s[3]!==s[1]&&x(ko,this).get(n),c!==!1&&(l=[0,0,0,0],z.axialAlignedBoundingBox(s,n.fontMatrix,l),(r!==1||i!==0||a!==0)&&lo(r,-r,i,a,l),c)))return this.recordBBox(e,t,l[0],l[2],l[1],l[3]);if(!o)return this.recordFullPageBBox(e);let u=o();return s&&l&&c===void 0&&(c=l[0]<=i-u.actualBoundingBoxLeft&&l[2]>=i+u.actualBoundingBoxRight&&l[1]<=a-u.actualBoundingBoxAscent&&l[3]>=a+u.actualBoundingBoxDescent,x(ko,this).set(n,c),c)?this.recordBBox(e,t,l[0],l[2],l[1],l[3]):this.recordBBox(e,t,i-u.actualBoundingBoxLeft,i+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return x(Mo,this).recordFullPageBBox(e),this}getSimpleIndex(e){return x(To,this)[e]}recordDependencies(e,t){let n=x(Oo,this),r=x(To,this),i=x(Eo,this);for(let e of t)e in x(To,this)?n.add(r[e]):e in i&&i[e].forEach(n.add,n);return this}recordNamedDependency(e,t){return x(Do,this).has(t)&&x(Oo,this).add(x(Do,this).get(t)),this}recordOperation(e,t=!1){if(this.recordDependencies(e,[ao]),x(Ao,this)){let t=ho(x(Ao,this),e),{dependencies:n}=t;x(Oo,this).forEach(n.add,n),x(Mo,this)._savesStack.forEach(n.add,n),x(Mo,this)._markedContentStack.forEach(n.add,n),n.delete(e),t.isRenderingOperation=!0}let n=!t&&e===x(Mo,this)._pendingBBoxIdx;return x(Mo,this).recordOperation(e,t,[x(Oo,this),x(Mo,this)._savesStack,x(Mo,this)._markedContentStack]),n&&x(Oo,this).clear(),this}recordShowTextOperation(e,t=!1){let n=Array.from(x(Oo,this));this.recordOperation(e,t),this.recordIncrementalData(`sameLineText`,e);for(let e of n)this.recordIncrementalData(`sameLineText`,e);return this}bboxToClipBoxDropOperation(e,t=!1){let n=!t&&e===x(Mo,this)._pendingBBoxIdx;return x(Mo,this).bboxToClipBoxDropOperation(e),n&&x(Oo,this).clear(),this}take(){return x(ko,this).clear(),x(Mo,this).take()}takeDebugMetadata(){return x(Ao,this)}},Po=new WeakMap,Fo=new WeakMap,Io=new WeakMap,Lo=new WeakMap,Ro=new WeakMap,zo=class e{constructor(t,n,r){if(b(this,Po,void 0),b(this,Fo,void 0),b(this,Io,void 0),b(this,Lo,0),b(this,Ro,0),t instanceof e&&x(Io,t)===!!r)return t;C(Po,this,t),C(Fo,this,n),C(Io,this,!!r)}get clipBox(){return x(Po,this).clipBox}growOperationsCount(){throw Error(`Unreachable`)}save(e){var t;return C(Ro,this,(t=x(Ro,this),t++,t)),x(Po,this).save(x(Fo,this)),this}restore(e){if(x(Ro,this)>0){var t;x(Po,this).restore(x(Fo,this)),C(Ro,this,(t=x(Ro,this),t--,t))}return this}recordOpenMarker(e){var t;return C(Lo,this,(t=x(Lo,this),t++,t)),this}getOpenMarker(){return x(Lo,this)>0?x(Fo,this):x(Po,this).getOpenMarker()}recordCloseMarker(e){var t;return C(Lo,this,(t=x(Lo,this),t--,t)),this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return x(Po,this).pushBaseTransform(e),this}popBaseTransform(){return x(Po,this).popBaseTransform(),this}recordSimpleData(e,t){return x(Po,this).recordSimpleData(e,x(Fo,this)),this}recordIncrementalData(e,t){return x(Po,this).recordIncrementalData(e,x(Fo,this)),this}resetIncrementalData(e,t){return x(Po,this).resetIncrementalData(e,x(Fo,this)),this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return x(Po,this).recordSimpleDataFromNamed(e,t,x(Fo,this)),this}recordFutureForcedDependency(e,t){return x(Po,this).recordFutureForcedDependency(e,x(Fo,this)),this}inheritSimpleDataAsFutureForcedDependencies(e){return x(Po,this).inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return x(Po,this).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return x(Io,this)||x(Po,this).resetBBox(x(Fo,this)),this}recordClipBox(e,t,n,r,i,a){return x(Io,this)||x(Po,this).recordClipBox(x(Fo,this),t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return x(Io,this)||x(Po,this).recordBBox(x(Fo,this),t,n,r,i,a),this}recordCharacterBBox(e,t,n,r,i,a,o){return x(Io,this)||x(Po,this).recordCharacterBBox(x(Fo,this),t,n,r,i,a,o),this}recordFullPageBBox(e){return x(Io,this)||x(Po,this).recordFullPageBBox(x(Fo,this)),this}getSimpleIndex(e){return x(Po,this).getSimpleIndex(e)}recordDependencies(e,t){return x(Po,this).recordDependencies(x(Fo,this),t),this}recordNamedDependency(e,t){return x(Po,this).recordNamedDependency(x(Fo,this),t),this}recordOperation(e){return x(Po,this).recordOperation(x(Fo,this),!0),this}recordShowTextOperation(e){return x(Po,this).recordShowTextOperation(x(Fo,this),!0),this}bboxToClipBoxDropOperation(e){return x(Io,this)||x(Po,this).bboxToClipBoxDropOperation(x(Fo,this),!0),this}take(){throw Error(`Unreachable`)}takeDebugMetadata(){throw Error(`Unreachable`)}},Bo={stroke:[`path`,`transform`,`filter`,`strokeColor`,`strokeAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`dash`],fill:[`path`,`transform`,`filter`,`fillColor`,`fillAlpha`,`globalCompositeOperation`,`SMask`],imageXObject:[`transform`,`SMask`,`filter`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`],rawFillPath:[`filter`,`fillColor`,`fillAlpha`],showText:[`transform`,`leading`,`charSpacing`,`wordSpacing`,`hScale`,`textRise`,`moveText`,`textMatrix`,`font`,`fontObj`,`filter`,`fillColor`,`textRenderingMode`,`SMask`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`,`sameLineText`],transform:[`transform`],transformAndFill:[`transform`,`fillColor`]},Vo=new WeakMap,Ho=new WeakMap,Uo=new WeakMap,Wo=new WeakMap,Go=new WeakMap,Ko=class{constructor(e){b(this,Vo,void 0),b(this,Ho,void 0),b(this,Uo,4),b(this,Wo,0),b(this,Go,new qo._(x(Uo,this)*6)),C(Vo,this,e.width),C(Ho,this,e.height)}record(e,t,n,r){var i;if(x(Wo,this)===x(Uo,this)){C(Uo,this,x(Uo,this)*2);let e=new qo._(x(Uo,this)*6);e.set(x(Go,this)),C(Go,this,e)}let a=jt(e),o;if(r[0]!==1/0){let e=ve.slice();z.axialAlignedBoundingBox([0,-n,t,0],a,e);let i=z.intersect(r,e);if(!i)return;let[s,c,l,u]=i;if(s!==e[0]||c!==e[1]||l!==e[2]||u!==e[3]){let e=Math.atan2(a[1],a[0]),t=Math.abs(Math.sin(e)),n=Math.abs(Math.cos(e));if(t<1e-6||n<1e-6||Math.abs(t-n)<1e-6)o=[s,c,s,u,l,c];else{let e=l-s,r=u-c,i=t*t,a=n*n,d=n*t,f=a-i,p=(r*a-e*d)/f;o=[s+(r*d-e*i)/f,c,s,c+p,l,u-p]}}}o||(o=[0,-n,0,0,t,-n],z.applyTransform(o,a,0),z.applyTransform(o,a,2),z.applyTransform(o,a,4)),o[0]/=x(Vo,this),o[1]/=x(Ho,this),o[2]/=x(Vo,this),o[3]/=x(Ho,this),o[4]/=x(Vo,this),o[5]/=x(Ho,this),x(Go,this).set(o,x(Wo,this)*6),C(Wo,this,(i=x(Wo,this),i++,i))}take(){return x(Go,this).subarray(0,x(Wo,this)*6)}},qo={_:R.isFloat16ArraySupported?Float16Array:Float32Array},Jo=new WeakMap,Yo=new WeakMap,Xo=new WeakSet,Zo=class{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){S(this,Xo),b(this,Jo,new Set),b(this,Yo,null),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){let t=f(Xo,this,Qo).call(this);t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);if(this.nativeFontFaces.clear(),x(Jo,this).clear(),x(Yo,this)){let{adoptedStyleSheets:e}=this._document;e!=null&&e.includes(x(Yo,this))&&(this._document.adoptedStyleSheets=e.filter(e=>e!==x(Yo,this))),C(Yo,this,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:n}){var r=this;return v(function*(){if(!(!e||x(Jo,r).has(e.loadedName))){if(ze(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),r.isFontLoadingAPISupported){let{loadedName:t,src:i,style:a}=e,o=new FontFace(t,i,a);r.addNativeFontFace(o);try{yield o.load(),x(Jo,r).add(t),n==null||n(e)}catch(t){F(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),r.removeNativeFontFace(o)}return}I(`Not implemented: loadSystemFont without the Font Loading API.`)}})()}bind(e){var t=this;return v(function*(){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){yield t.loadSystemFont(e);return}if(t.isFontLoadingAPISupported){let n=e.createNativeFontFace();if(n){t.addNativeFontFace(n);try{yield n.loaded}catch(t){throw F(`Failed to load font '${n.family}': '${t}'.`),e.disableFontFace=!0,t}}return}let n=e.createFontFaceRule();if(n){if(t.insertRule(n),t.isSyncFontLoadingSupported)return;yield new Promise(n=>{let r=t._queueLoadingCallback(n);t._prepareFontLoadEvent(e,r)})}})()}get isFontLoadingAPISupported(){var e;let t=!!((e=this._document)!=null&&e.fonts);return L(this,`isFontLoadingAPISupported`,t)}get isSyncFontLoadingSupported(){return L(this,`isSyncFontLoadingSupported`,_e||R.platform.isFirefox)}_queueLoadingCallback(e){function t(){for(ze(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return L(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function i(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let a,o,s=this._document.createElement(`canvas`);s.width=1,s.height=1;let c=s.getContext(`2d`),l=0;function u(e,t){if(++l>30){F(`Load test font never loaded.`),t();return}if(c.font=`30px `+e,c.fillText(`.`,0,20),c.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(u.bind(null,e,t))}let d=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=i(f,976,d.length,d);let p=1482184792,m=n(f,16);for(a=0,o=d.length-3;a<o;a+=4)m=m-p+n(d,a)|0;a<d.length&&(m=m-p+n(d+`XXX`,a)|0),f=i(f,16,4,r(m));let h=`@font-face {font-family:"${d}";src:${`url(data:font/opentype;base64,${btoa(f)});`}}`;this.insertRule(h);let g=this._document.createElement(`div`);g.style.visibility=`hidden`,g.style.width=g.style.height=`10px`,g.style.position=`absolute`,g.style.top=g.style.left=`0px`;for(let t of[e.loadedName,d]){let e=this._document.createElement(`span`);e.textContent=`Hi`,e.style.fontFamily=t,g.append(e)}this._document.body.append(g),u(d,()=>{g.remove(),t.complete()})}};function Qo(){var e;if(x(Yo,this))return x(Yo,this);let t=((e=this._document.defaultView)==null?void 0:e.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&t){let{adoptedStyleSheets:e}=this._document;if(e){let n=new t;return e.push(n),C(Yo,this,n)}}return this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement)),C(Yo,this,this.styleElement.sheet)}var $o=new WeakMap,es=class{constructor(e,t=null,n,r){g(this,`compiledGlyphs`,Object.create(null)),b(this,$o,void 0),C($o,this,e),this._inspectFont=t,n&&(this.charProcOperatorList=n),r&&Object.assign(this,r)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var e;if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}return(e=this._inspectFont)==null||e.call(this,this,t),n}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){F(`getPathGenerator - ignoring character: "${e}".`)}let i=Kt(r==null?void 0:r.path);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}get black(){return x($o,this).black}get bold(){return x($o,this).bold}get disableFontFace(){return x($o,this).disableFontFace}set disableFontFace(e){L(this,`disableFontFace`,!!e)}get fontExtraProperties(){return x($o,this).fontExtraProperties}get isInvalidPDFjsFont(){return x($o,this).isInvalidPDFjsFont}get isType3Font(){return x($o,this).isType3Font}get italic(){return x($o,this).italic}get missingFile(){return x($o,this).missingFile}get remeasure(){return x($o,this).remeasure}get vertical(){return x($o,this).vertical}get ascent(){return x($o,this).ascent}get defaultWidth(){return x($o,this).defaultWidth}get descent(){return x($o,this).descent}get bbox(){return x($o,this).bbox}get fontMatrix(){return x($o,this).fontMatrix}get fallbackName(){return x($o,this).fallbackName}get loadedName(){return x($o,this).loadedName}get mimetype(){return x($o,this).mimetype}get name(){return x($o,this).name}get data(){return x($o,this).data}clearData(){x($o,this).clearData()}get cssFontInfo(){return x($o,this).cssFontInfo}get systemFontInfo(){return x($o,this).systemFontInfo}get defaultVMetrics(){return x($o,this).defaultVMetrics}},ts=class{};g(ts,`strings`,[`fontFamily`,`fontWeight`,`italicAngle`]);var ns=class{};g(ns,`strings`,[`css`,`loadedName`,`baseFontName`,`src`]);var rs=class{};ie=rs,g(rs,`bools`,[`black`,`bold`,`disableFontFace`,`fontExtraProperties`,`isInvalidPDFjsFont`,`isType3Font`,`italic`,`missingFile`,`remeasure`,`vertical`]),g(rs,`numbers`,[`ascent`,`defaultWidth`,`descent`]),g(rs,`strings`,[`fallbackName`,`loadedName`,`mimetype`,`name`]),g(rs,`OFFSET_NUMBERS`,Math.ceil(ie.bools.length*2/8)),g(rs,`OFFSET_BBOX`,ie.OFFSET_NUMBERS+ie.numbers.length*8),g(rs,`OFFSET_FONT_MATRIX`,ie.OFFSET_BBOX+1+8),g(rs,`OFFSET_DEFAULT_VMETRICS`,ie.OFFSET_FONT_MATRIX+1+48),g(rs,`OFFSET_STRINGS`,ie.OFFSET_DEFAULT_VMETRICS+1+6);var is=class{};g(is,`KIND`,0),g(is,`HAS_BBOX`,1),g(is,`HAS_BACKGROUND`,2),g(is,`SHADING_TYPE`,3),g(is,`N_COORD`,4),g(is,`N_COLOR`,8),g(is,`N_STOP`,12),g(is,`N_FIGURES`,16);var as=new WeakMap,os=new WeakMap,ss=new WeakMap,cs=new WeakSet,ls=class{constructor(e){S(this,cs),b(this,as,void 0),b(this,os,new TextDecoder),b(this,ss,void 0),C(as,this,e),C(ss,this,new DataView(e))}get fontFamily(){return f(cs,this,us).call(this,0)}get fontWeight(){return f(cs,this,us).call(this,1)}get italicAngle(){return f(cs,this,us).call(this,2)}};function us(e){ze(e<ts.strings.length,`Invalid string index`);let t=0;for(let n=0;n<e;n++)t+=x(ss,this).getUint32(t)+4;let n=x(ss,this).getUint32(t);return x(os,this).decode(new Uint8Array(x(as,this),t+4,n))}var ds=new WeakMap,fs=new WeakMap,ps=new WeakMap,ms=new WeakSet,hs=class{constructor(e){S(this,ms),b(this,ds,void 0),b(this,fs,new TextDecoder),b(this,ps,void 0),C(ds,this,e),C(ps,this,new DataView(e))}get guessFallback(){return x(ps,this).getUint8(0)!==0}get css(){return f(ms,this,gs).call(this,0)}get loadedName(){return f(ms,this,gs).call(this,1)}get baseFontName(){return f(ms,this,gs).call(this,2)}get src(){return f(ms,this,gs).call(this,3)}get style(){let e=1;e+=4+x(ps,this).getUint32(e);let t=x(ps,this).getUint32(e),n=x(fs,this).decode(new Uint8Array(x(ds,this),e+4,t));e+=4+t;let r=x(ps,this).getUint32(e);return{style:n,weight:x(fs,this).decode(new Uint8Array(x(ds,this),e+4,r))}}};function gs(e){ze(e<ns.strings.length,`Invalid string index`);let t=5;for(let n=0;n<e;n++)t+=x(ps,this).getUint32(t)+4;let n=x(ps,this).getUint32(t);return x(fs,this).decode(new Uint8Array(x(ds,this),t+4,n))}var _s=new WeakMap,vs=new WeakMap,ys=new WeakMap,bs=new WeakSet,xs=class{constructor({buffer:e,extra:t}){S(this,bs),b(this,_s,void 0),b(this,vs,new TextDecoder),b(this,ys,void 0),C(_s,this,e),C(ys,this,new DataView(e)),t&&Object.assign(this,t)}get black(){return f(bs,this,Ss).call(this,0)}get bold(){return f(bs,this,Ss).call(this,1)}get disableFontFace(){return f(bs,this,Ss).call(this,2)}get fontExtraProperties(){return f(bs,this,Ss).call(this,3)}get isInvalidPDFjsFont(){return f(bs,this,Ss).call(this,4)}get isType3Font(){return f(bs,this,Ss).call(this,5)}get italic(){return f(bs,this,Ss).call(this,6)}get missingFile(){return f(bs,this,Ss).call(this,7)}get remeasure(){return f(bs,this,Ss).call(this,8)}get vertical(){return f(bs,this,Ss).call(this,9)}get ascent(){return f(bs,this,Cs).call(this,0)}get defaultWidth(){return f(bs,this,Cs).call(this,1)}get descent(){return f(bs,this,Cs).call(this,2)}get bbox(){return f(bs,this,ws).call(this,rs.OFFSET_BBOX,4,`getInt16`,2)}get fontMatrix(){return f(bs,this,ws).call(this,rs.OFFSET_FONT_MATRIX,6,`getFloat64`,8)}get defaultVMetrics(){return f(bs,this,ws).call(this,rs.OFFSET_DEFAULT_VMETRICS,3,`getInt16`,2)}get fallbackName(){return f(bs,this,Ts).call(this,0)}get loadedName(){return f(bs,this,Ts).call(this,1)}get mimetype(){return f(bs,this,Ts).call(this,2)}get name(){return f(bs,this,Ts).call(this,3)}get data(){let{offset:e,length:t}=f(bs,this,Es).call(this);return t===0?void 0:new Uint8Array(x(_s,this),e+4,t)}clearData(){let{offset:e,length:t}=f(bs,this,Es).call(this);t!==0&&(x(ys,this).setUint32(e,0),C(_s,this,new Uint8Array(x(_s,this),0,e+4).slice().buffer),C(ys,this,new DataView(x(_s,this))))}get cssFontInfo(){let e=rs.OFFSET_STRINGS,t=x(ys,this).getUint32(e);e+=4+t;let n=x(ys,this).getUint32(e);e+=4+n;let r=x(ys,this).getUint32(e);if(r===0)return null;let i=new Uint8Array(r);return i.set(new Uint8Array(x(_s,this),e+4,r)),new ls(i.buffer)}get systemFontInfo(){let e=rs.OFFSET_STRINGS,t=x(ys,this).getUint32(e);e+=4+t;let n=x(ys,this).getUint32(e);if(n===0)return null;let r=new Uint8Array(n);return r.set(new Uint8Array(x(_s,this),e+4,n)),new hs(r.buffer)}};function Ss(e){ze(e<rs.bools.length,`Invalid boolean index`);let t=Math.floor(e/4),n=e*2%8,r=x(ys,this).getUint8(t)>>n&3;return r===0?void 0:r===2}function Cs(e){return ze(e<rs.numbers.length,`Invalid number index`),x(ys,this).getFloat64(rs.OFFSET_NUMBERS+e*8)}function ws(e,t,n,r){let i=x(ys,this).getUint8(e);if(i===0)return;ze(i===t,`Invalid array length.`),e+=1;let a=Array(i);for(let t=0;t<i;t++)a[t]=x(ys,this)[n](e,!0),e+=r;return a}function Ts(e){ze(e<rs.strings.length,`Invalid string index`);let t=rs.OFFSET_STRINGS+4;for(let n=0;n<e;n++)t+=x(ys,this).getUint32(t)+4;let n=x(ys,this).getUint32(t);return x(vs,this).decode(new Uint8Array(x(_s,this),t+4,n))}function Es(){let e=rs.OFFSET_STRINGS,t=x(ys,this).getUint32(e);e+=4+t;let n=x(ys,this).getUint32(e);e+=4+n;let r=x(ys,this).getUint32(e);e+=4+r;let i=x(ys,this).getUint32(e);return{offset:e,length:i}}var Ds=class{constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){let e=this.view,t=this.data[is.KIND],n=!!this.data[is.HAS_BBOX],r=!!this.data[is.HAS_BACKGROUND],i=e.getUint32(is.N_COORD,!0),a=e.getUint32(is.N_COLOR,!0),o=e.getUint32(is.N_STOP,!0),s=20,c=new Float32Array(this.buffer,s,i*2);s+=i*8;let l=new Uint8Array(this.buffer,s,a*4);s+=a*4;let u=[];for(let t=0;t<o;++t){let t=e.getFloat32(s,!0);s+=4;let n=e.getUint32(s,!0);s+=4,u.push([t,`#${n.toString(16).padStart(6,`0`)}`])}let d=null;if(n){d=[];for(let t=0;t<4;++t)d.push(e.getFloat32(s,!0)),s+=4}let f=null;if(r&&(f=new Uint8Array(this.buffer,s,3),s+=3),t===1)return[`RadialAxial`,`axial`,d,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(t===2)return[`RadialAxial`,`radial`,d,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(t===3){let e=this.data[is.SHADING_TYPE],t=null;if(c.length>0){t=ve.slice();for(let e=0,n=c.length;e<n;e+=2)z.pointBoundingBox(c[e],c[e+1],t)}return[`Mesh`,e,c,l,i,t,d,f]}throw Error(`Unsupported pattern kind: ${t}`)}},Os=new WeakMap,ks=class{constructor(e){b(this,Os,void 0),C(Os,this,e)}get path(){return R.isFloat16ArraySupported?new Float16Array(x(Os,this)):new Float32Array(x(Os,this))}};function As(e){if(e instanceof URL)return e;if(typeof e==`string`){if(_e){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);let t=process.getBuiltinModule(`url`);return new URL(t.pathToFileURL(e))}let t=URL.parse(e,window.location);if(t)return t}throw Error(`Invalid PDF url data: either string or URL-object is expected in the url property.`)}function js(e){if(_e&&typeof Buffer<`u`&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e==`string`)return Qe(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`object`&&!isNaN(e==null?void 0:e.length))return new Uint8Array(e);throw Error(`Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.`)}function Ms(e){if(typeof e!=`string`)return null;if(e.endsWith(`/`))return e;throw Error(`Invalid factory url: "${e}" must include trailing slash.`)}var Ns=e=>typeof e==`object`&&Number.isInteger(e==null?void 0:e.num)&&e.num>=0&&Number.isInteger(e==null?void 0:e.gen)&&e.gen>=0,Ps=ot.bind(null,Ns,e=>typeof e==`object`&&typeof(e==null?void 0:e.name)==`string`),Fs=new WeakMap,Is=new WeakMap,Ls=class{constructor(){b(this,Fs,new Map),b(this,Is,Promise.resolve())}postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};x(Is,this).then(()=>{for(let[e]of x(Fs,this))e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if((n==null?void 0:n.signal)instanceof AbortSignal){let{signal:i}=n;if(i.aborted){F("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}x(Fs,this).set(t,r)}removeEventListener(e,t){let n=x(Fs,this).get(t);n==null||n(),x(Fs,this).delete(t)}terminate(){for(let[,e]of x(Fs,this))e==null||e();x(Fs,this).clear()}},Rs={DATA:1,ERROR:2},zs={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Bs(){}function Vs(e){if(e instanceof Xe||e instanceof qe||e instanceof Ge||e instanceof Je||e instanceof Ke)return e;switch(e instanceof Error||typeof e==`object`&&e||I(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new Xe(e.message);case`InvalidPDFException`:return new qe(e.message);case`PasswordException`:return new Ge(e.message,e.code);case`ResponseException`:return new Je(e.message,e.status,e.missing);case`UnknownErrorException`:return new Ke(e.message,e.details)}return new Ke(e.message,e.toString())}var Hs=new WeakMap,Us=new WeakSet,Ws=class{constructor(e,t,n){S(this,Us),b(this,Hs,new AbortController),this.sourceName=e,this.targetName=t,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`,f(Us,this,Gs).bind(this),{signal:x(Hs,this).signal})}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:zs.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{ze(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:zs.CANCEL,streamId:i,reason:Vs(e)}),t.promise}},n)}destroy(){var e;(e=x(Hs,this))==null||e.abort(),C(Hs,this,null)}};function Gs({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){f(Us,this,qs).call(this,e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===Rs.DATA)n.resolve(e.data);else if(e.callback===Rs.ERROR)n.reject(Vs(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:Rs.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:Rs.ERROR,callbackId:e.callbackId,reason:Vs(t)})});return}if(e.streamId){f(Us,this,Ks).call(this,e);return}t(e.data)}function Ks(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:zs.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:zs.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){ze(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:zs.ERROR,streamId:t,reason:Vs(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:zs.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:zs.START_COMPLETE,streamId:t,reason:Vs(e)})})}function qs(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case zs.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(Vs(e.reason));break;case zs.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(Vs(e.reason));break;case zs.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:zs.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Bs).then(function(){i.postMessage({sourceName:n,targetName:r,stream:zs.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:zs.PULL_COMPLETE,streamId:t,reason:Vs(e)})});break;case zs.ENQUEUE:if(ze(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case zs.CLOSE:if(ze(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),f(Us,this,Js).call(this,a,t);break;case zs.ERROR:ze(a,`error should have stream controller`),a.controller.error(Vs(e.reason)),f(Us,this,Js).call(this,a,t);break;case zs.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(Vs(e.reason)),f(Us,this,Js).call(this,a,t);break;case zs.CANCEL:if(!o)break;let s=Vs(e.reason);Promise.try(o.onCancel||Bs,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:zs.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:zs.CANCEL_COMPLETE,streamId:t,reason:Vs(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}function Js(e,t){var n=this;return v(function*(){var r,i,a;yield Promise.allSettled([(r=e.startCall)==null?void 0:r.promise,(i=e.pullCall)==null?void 0:i.promise,(a=e.cancelCall)==null?void 0:a.promise]),delete n.streamControllers[t]})()}var Ys=new WeakMap,Xs=class{constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:n=null}){b(this,Ys,Object.freeze({cMapUrl:`CMap`,standardFontDataUrl:`font`,wasmUrl:`wasm`})),this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=n}fetch({kind:e,filename:t}){var n=this;return v(function*(){switch(e){case`cMapUrl`:case`standardFontDataUrl`:case`wasmUrl`:break;default:I(`Not implemented: ${e}`)}let r=n[e];if(!r)throw Error(`Ensure that the \`${e}\` API parameter is provided.`);let i=`${r}${t}`;return n._fetch(i,e).catch(t=>{throw Error(`Unable to load ${x(Ys,n)[e]} data at: ${i}`)})})()}_fetch(e,t){return v(function*(){I("Abstract method `_fetch` called.")})()}},Zs=class extends Xs{_fetch(e,t){return v(function*(){let n=yield mt(e,t===`cMapUrl`&&!e.endsWith(`.bcmap`)?`text`:`bytes`);return n instanceof Uint8Array?n:Qe(n)})()}},Qs=new WeakMap,$s=class{constructor({enableHWA:e=!1}){b(this,Qs,!1),C(Qs,this,e)}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!x(Qs,this)})}}reset({canvas:e},t,n){if(!e)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.width=t,e.height=n}destroy(e){let{canvas:t}=e;if(!t)throw Error(`Canvas is not specified`);t.width=t.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){I("Abstract method `_createCanvas` called.")}},ec=class extends $s{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},tc=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addKnockoutFilter(e=0){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}addSelectionHCMFilter(e,t){return`none`}addSelectionFilter(){return`none`}createSelectionStyle(e=null){return null}destroy(e=!1){}},nc=new WeakMap,rc=new WeakMap,ic=new WeakMap,ac=new WeakMap,oc=new WeakMap,sc=new WeakMap,cc=new WeakMap,K=new WeakSet,lc=class extends tc{constructor({docId:e,ownerDocument:t=globalThis.document}){super(),S(this,K),b(this,nc,void 0),b(this,rc,void 0),b(this,ic,void 0),b(this,ac,void 0),b(this,oc,void 0),b(this,sc,void 0),b(this,cc,0),C(ac,this,e),C(oc,this,t)}addFilter(e){var t,n;if(!e)return`none`;let r=uc.call(f(K,this)).get(e);if(r)return r;let[i,a,o]=f(K,this,pc).call(this,e),s=e.length===1?i:`${i}${a}${o}`;if(r=uc.call(f(K,this)).get(s),r)return uc.call(f(K,this)).set(e,r),r;let c=`g_${x(ac,this)}_transfer_map_${C(cc,this,(t=x(cc,this),n=t++,t)),n}`,l=f(K,this,mc).call(this,c);uc.call(f(K,this)).set(e,l),uc.call(f(K,this)).set(s,l);let u=f(K,this,_c).call(this,c);return f(K,this,yc).call(this,i,a,o,u),l}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=dc.call(f(K,this)).get(r);if((i==null?void 0:i.key)===n)return i.url;if(i){var a;(a=i.filter)==null||a.remove(),i.key=n,i.url=`none`,i.filter=null}else i={key:n,url:`none`,filter:null},dc.call(f(K,this)).set(r,i);if(!e||!t)return i.url;let o=f(K,this,xc).call(this,e);e=z.makeHexColor(...o);let s=f(K,this,xc).call(this,t);if(t=z.makeHexColor(...s),fc.call(f(K,this)).style.color=``,e===`#000000`&&t===`#ffffff`||e===t)return i.url;let c=Array(256);for(let e=0;e<=255;e++){let t=e/255;c[e]=t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}let l=c.join(`,`),u=`g_${x(ac,this)}_hcm_filter`,d=i.filter=f(K,this,_c).call(this,u);f(K,this,yc).call(this,l,l,l,d),f(K,this,gc).call(this,d);let p=(e,t)=>{let n=o[e]/255,r=s[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return f(K,this,yc).call(this,p(0,5),p(1,5),p(2,5),d),i.url=f(K,this,mc).call(this,u),i.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter(`selection`,e,t,`HighlightText`,`Highlight`)}addSelectionFilter(){return this.addHighlightHCMFilter(`selection_default`,`black`,`white`,`HighlightText`,`Highlight`)}createSelectionStyle(e=null){let t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return t===`none`||!R.platform.isFirefox?null:{"backdrop-filter":t,"background-color":`transparent`}}addAlphaFilter(e){var t,n;let r=uc.call(f(K,this)).get(e);if(r)return r;let[i]=f(K,this,pc).call(this,[e]),a=`alpha_${i}`;if(r=uc.call(f(K,this)).get(a),r)return uc.call(f(K,this)).set(e,r),r;let o=`g_${x(ac,this)}_alpha_map_${C(cc,this,(t=x(cc,this),n=t++,t)),n}`,s=f(K,this,mc).call(this,o);uc.call(f(K,this)).set(e,s),uc.call(f(K,this)).set(a,s);let c=f(K,this,_c).call(this,o);return f(K,this,bc).call(this,i,c),s}addLuminosityFilter(e){var t,n;let r=uc.call(f(K,this)).get(e||`luminosity`);if(r)return r;let i,a;if(e?([i]=f(K,this,pc).call(this,[e]),a=`luminosity_${i}`):a=`luminosity`,r=uc.call(f(K,this)).get(a),r)return uc.call(f(K,this)).set(e,r),r;let o=`g_${x(ac,this)}_luminosity_map_${C(cc,this,(t=x(cc,this),n=t++,t)),n}`,s=f(K,this,mc).call(this,o);uc.call(f(K,this)).set(e,s),uc.call(f(K,this)).set(a,s);let c=f(K,this,_c).call(this,o);return f(K,this,hc).call(this,c),e&&f(K,this,bc).call(this,i,c),s}addKnockoutFilter(e=0){var t,n;let r=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${r}`,a=uc.call(f(K,this)).get(i);if(a)return a;let o=`g_${x(ac,this)}_knockout_filter_${C(cc,this,(t=x(cc,this),n=t++,t)),n}`,s=f(K,this,mc).call(this,o);uc.call(f(K,this)).set(i,s);let c=f(K,this,_c).call(this,o),l=x(oc,this).createElementNS(Se,`feComponentTransfer`);c.append(l);let u=x(oc,this).createElementNS(Se,`feFuncA`);return u.setAttribute(`type`,`linear`),u.setAttribute(`slope`,`${r}`),u.setAttribute(`intercept`,`0`),l.append(u),s}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=dc.call(f(K,this)).get(e);if((o==null?void 0:o.key)===a)return o.url;if(o){var s;(s=o.filter)==null||s.remove(),o.key=a,o.url=`none`,o.filter=null}else o={key:a,url:`none`,filter:null},dc.call(f(K,this)).set(e,o);if(!t||!n)return o.url;let[c,l]=[t,n].map(f(K,this,xc).bind(this)),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[p,m]=[r,i].map(f(K,this,Cc).bind(this));d<u&&([u,d,p,m]=[d,u,m,p]),fc.call(f(K,this)).style.color=``;let h=(e,t,n)=>{let r=Array(256),i=(d-u)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(u+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},g=`g_${x(ac,this)}_hcm_${e}_filter`,_=o.filter=f(K,this,_c).call(this,g);return f(K,this,gc).call(this,_),f(K,this,yc).call(this,h(p[0],m[0],5),h(p[1],m[1],5),h(p[2],m[2],5),_),o.url=f(K,this,mc).call(this,g),o.url}destroy(e=!1){var t,n,r,i;e&&(t=x(sc,this))!=null&&t.size||((n=x(ic,this))==null||n.parentNode.parentNode.remove(),C(ic,this,null),(r=x(rc,this))==null||r.clear(),C(rc,this,null),(i=x(sc,this))==null||i.clear(),C(sc,this,null),C(cc,this,0))}};function uc(){return x(rc,this)||C(rc,this,new Map)}function dc(){return x(sc,this)||C(sc,this,new Map)}function fc(){if(!x(ic,this)){let e=x(oc,this).createElement(`div`),{style:t}=e;t.colorScheme=`only light`,t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=x(oc,this).createElementNS(Se,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),C(ic,this,x(oc,this).createElementNS(Se,`defs`)),e.append(n),n.append(x(ic,this)),x(oc,this).body.append(e)}return x(ic,this)}function pc(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}function mc(e){if(x(nc,this)===void 0){C(nc,this,``);let e=x(oc,this).URL;e!==x(oc,this).baseURI&&(_t(e)?F(`#createUrl: ignore "data:"-URL for performance reasons.`):C(nc,this,He(e,``)))}return`url(${x(nc,this)}#${e})`}function hc(e){let t=x(oc,this).createElementNS(Se,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.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`),e.append(t)}function gc(e){let t=x(oc,this).createElementNS(Se,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.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`),e.append(t)}function _c(e){let t=x(oc,this).createElementNS(Se,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),fc.call(f(K,this)).append(t),t}function vc(e,t,n){let r=x(oc,this).createElementNS(Se,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}function yc(e,t,n,r){let i=x(oc,this).createElementNS(Se,`feComponentTransfer`);r.append(i),f(K,this,vc).call(this,i,`feFuncR`,e),f(K,this,vc).call(this,i,`feFuncG`,t),f(K,this,vc).call(this,i,`feFuncB`,n)}function bc(e,t){let n=x(oc,this).createElementNS(Se,`feComponentTransfer`);t.append(n),f(K,this,vc).call(this,n,`feFuncA`,e)}function xc(e){return fc.call(f(K,this)).style.color=e,kt(getComputedStyle(fc.call(f(K,this))).getPropertyValue(`color`))}function Sc(e){return fc.call(f(K,this)).style.color=e,Ot(getComputedStyle(fc.call(f(K,this))).getPropertyValue(`color`))}function Cc(e){let[t,n,r,i]=f(K,this,Sc).call(this,e);if(i===1)return[t,n,r];let[a,o,s]=f(K,this,xc).call(this,`Canvas`);return[wc(t,a,i),wc(n,o,i),wc(r,s,i)]}function wc(e,t,n){return Math.round(n*e+(1-n)*t)}_e&&F("Please use the `legacy` build in Node.js environments.");function Tc(e){return Ec.apply(this,arguments)}function Ec(){return Ec=v(function*(e){let t=yield process.getBuiltinModule(`fs/promises`).readFile(e);return new Uint8Array(t)}),Ec.apply(this,arguments)}var Dc=class extends tc{},Oc=class extends $s{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire({}.url)(`@napi-rs/canvas`).createCanvas(e,t)}},kc=class extends Xs{_fetch(e,t){return v(function*(){return Tc(e)})()}};function Ac({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=R.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=c^l,p=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r<i;++r){for(let r=t+u;t<r;++t,m+=8){let r=e[t];n[m]=c^-(r>>7&1)&f,n[m+1]=c^-(r>>6&1)&f,n[m+2]=c^-(r>>5&1)&f,n[m+3]=c^-(r>>4&1)&f,n[m+4]=c^-(r>>3&1)&f,n[m+5]=c^-(r>>2&1)&f,n[m+6]=c^-(r>>1&1)&f,n[m+7]=c^-(r&1)&f}if(d===0)continue;let r=t<p?e[t++]:255;for(let e=0;e<d;++e,++m)n[m]=c^-(r>>7-e&1)&f}return{srcPos:t,destPos:m}}function jc({src:e,srcPos:t=0,dest:n,destPos:r=0,width:i,height:a}){let o=0,s=i*a*3,c=s>>2,l=new Uint32Array(e.buffer,t,c),u=R.isLittleEndian?4278190080:255;if(R.isLittleEndian){for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e>>>24|t<<8|u,n[r+2]=t>>>16|i<<16|u,n[r+3]=i>>>8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]|e[i+1]<<8|e[i+2]<<16|u}else{for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e<<24|t>>>8|u,n[r+2]=t<<16|i>>>16|u,n[r+3]=i<<8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|u}return{srcPos:t+s,destPos:r}}var Mc=`
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require("react");l=c(l,1);let u=require("react-dom/client"),d=require("react/jsx-runtime");function f(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){if(p(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(p(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e){var t=m(e,`string`);return p(t)==`symbol`?t:t+``}function g(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){_(a,r,i,o,s,`next`,e)}function s(e){_(a,r,i,o,s,`throw`,e)}o(void 0)})}}function y(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function b(e,t,n){y(e,t),t.set(e,n)}function x(e,t){return e.get(f(e,t))}function S(e,t){y(e,t),t.add(e)}function C(e,t,n){return e.set(f(e,t),n),n}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?w(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function E(e){var t,n,r,i=2;for(typeof Symbol<`u`&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&(t=e[n])!=null)return t.call(e);if(r&&(t=e[r])!=null)return new D(t.call(e));n=`@@asyncIterator`,r=`@@iterator`}throw TypeError(`Object is not async iterable`)}function D(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+` is not an object.`));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return D=function(e){this.s=e,this.n=e.next},D.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return n===void 0?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return n===void 0?Promise.reject(e):t(n.apply(this.s,arguments))}},new D(e)}function O(e,t,n){t||(t=[]);var r=t.length++;return Object.defineProperty({},"_",{set:function(i){t[r]=i,e.apply(n,t)}})}var k=o({AbortException:()=>Ye,AnnotationEditorLayer:()=>by,AnnotationEditorParamsType:()=>P,AnnotationEditorType:()=>N,AnnotationEditorUIManager:()=>Lr,AnnotationLayer:()=>xh,AnnotationMode:()=>Ce,AnnotationType:()=>ke,CSSConstants:()=>It,ColorPicker:()=>tp,DOMSVGFactory:()=>yp,DrawLayer:()=>By,FeatureTest:()=>z,GlobalWorkerOptions:()=>zu,ImageKind:()=>Oe,InvalidPDFException:()=>Ke,MathClamp:()=>V,OPS:()=>F,OutputScale:()=>Nt,PDFDataRangeTransport:()=>of,PDFDateString:()=>Tt,PDFWorker:()=>vf,PasswordException:()=>We,PasswordResponses:()=>Ne,PermissionFlag:()=>Ee,PixelsPerInch:()=>ft,RenderingCancelledException:()=>ht,ResponseException:()=>qe,SignatureExtractor:()=>gv,SupportedImageMimeTypes:()=>Pt,TextLayer:()=>Bd,TextLayerImages:()=>ub,TouchManager:()=>Yi,Util:()=>B,VerbosityLevel:()=>je,XfaLayer:()=>dt,applyOpacity:()=>Lt,build:()=>Uf,createValidAbsoluteUrl:()=>Be,fetchData:()=>pt,findContrastColor:()=>Ut,getDocument:()=>ef,getFilenameFromUrl:()=>vt,getPdfFilenameFromUrl:()=>yt,getRGB:()=>Ot,getRGBA:()=>Dt,getUuid:()=>it,isDataScheme:()=>gt,isPdfFile:()=>_t,isValidExplicitDest:()=>Ns,makeArr:()=>ot,makeMap:()=>st,makeObj:()=>ct,noContextMenu:()=>Ct,normalizeUnicode:()=>rt,renderRichText:()=>Wt,setLayerDimensions:()=>Mt,shadow:()=>R,stopEvent:()=>wt,updateUrlHash:()=>Ve,version:()=>Hf}),A,ee,j,te,ne,M,re,ie,ae,oe,se,ce,le,ue,de,fe,pe,me,he,ge=typeof process==`object`&&process+``==`[object process]`&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!==`browser`),_e=[1/0,1/0,-1/0,-1/0],ve=new Float32Array(_e),ye=[.001,0,0,.001,0,0],be=1.35,xe=`http://www.w3.org/2000/svg`,Se={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ce={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},we=`pdfjs_internal_id_`,Te=`pdfjs_internal_editor_`,N={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},P={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},Ee={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},De={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Oe={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ke={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},Ae={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},je={ERRORS:0,WARNINGS:1,INFOS:5},F={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},Me={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},Ne={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Pe=je.WARNINGS;function Fe(e){Number.isInteger(e)&&(Pe=e)}function Ie(){return Pe}function Le(e){Pe>=je.INFOS&&console.info(`Info: ${e}`)}function I(e){Pe>=je.WARNINGS&&console.warn(`Warning: ${e}`)}function L(e){throw Error(e)}function Re(e,t){e||L(t)}function ze(e){switch(e==null?void 0:e.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function Be(e,t=null,n=null){if(!e)return null;if(n&&typeof e==`string`){if(n.addDefaultProtocol&&e.startsWith(`www.`)){let t=e.match(/\./g);(t==null?void 0:t.length)>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=et(e)}catch(e){}}let r=t?URL.parse(e,t):URL.parse(e);return ze(r)?r:null}function Ve(e,t,n=!1){let r=URL.parse(e);return r?(r.hash=t,r.href):n&&Be(e,`http://example.com`)?e.split(`#`,1)[0]+`${t?`#${t}`:``}`:``}function He(e){return e.substring(e.lastIndexOf(`/`)+1)}function R(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var Ue=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),We=class extends Ue{constructor(e,t){super(e,`PasswordException`),this.code=t}},Ge=class extends Ue{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},Ke=class extends Ue{constructor(e){super(e,`InvalidPDFException`)}},qe=class extends Ue{constructor(e,t,n){super(e,`ResponseException`),this.status=t,this.missing=n}},Je=class extends Ue{constructor(e){super(e,`FormatError`)}},Ye=class extends Ue{constructor(e){super(e,`AbortException`)}};function Xe(e){(typeof e!=`object`||(e==null?void 0:e.length)===void 0)&&L(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let r=[];for(let i=0;i<t;i+=n){let a=Math.min(i+n,t),o=e.subarray(i,a);r.push(String.fromCharCode.apply(null,o))}return r.join(``)}function Ze(e){typeof e!=`string`&&L(`Invalid argument for stringToBytes`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r)&255;return n}var z=class{static get isLittleEndian(){let e=new Uint8Array(4);e[0]=1;let t=new Uint32Array(e.buffer,0,1);return R(this,`isLittleEndian`,t[0]===1)}static get isOffscreenCanvasSupported(){return R(this,`isOffscreenCanvasSupported`,typeof OffscreenCanvas<`u`)}static get isImageDecoderSupported(){return R(this,`isImageDecoderSupported`,typeof ImageDecoder<`u`)}static get isFloat16ArraySupported(){return R(this,`isFloat16ArraySupported`,typeof Float16Array<`u`)}static get isSanitizerSupported(){return R(this,`isSanitizerSupported`,typeof Sanitizer<`u`)}static get platform(){let{platform:e,userAgent:t}=navigator;return R(this,`platform`,{isAndroid:t.includes(`Android`),isLinux:e.includes(`Linux`),isMac:e.includes(`Mac`),isWindows:e.includes(`Win`),isFirefox:t.includes(`Firefox`)})}static get isCanvasFilterSupported(){let e;return this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext(`2d`):typeof document<`u`&&(e=document.createElement(`canvas`).getContext(`2d`)),R(this,`isCanvasFilterSupported`,(e==null?void 0:e.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>`u`)return R(this,`isAlphaColorInputSupported`,!1);let e=document.createElement(`input`);return e.type=`color`,e.setAttribute(`alpha`,``),e.value=`#ff000080`,R(this,`isAlphaColorInputSupported`,e.value!==`#ff0000`)}static get isBackdropFilterSupported(){return R(this,`isBackdropFilterSupported`,typeof CSS<`u`&&CSS.supports(`backdrop-filter`,`blur(1px)`))}},B=class e{static get hexNums(){return R(this,`hexNums`,Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)))}static makeHexColor(e,t,n){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[n]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,n=0){let r=e[n],i=e[n+1];e[n]=r*t[0]+i*t[2]+t[4],e[n+1]=r*t[1]+i*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];for(let t=0;t<6;t+=2){let l=e[n+t],u=e[n+t+1];e[n+t]=l*r+u*a+s,e[n+t+1]=l*i+u*o+c}}static applyInverseTransform(e,t){let n=e[0],r=e[1],i=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-r*t[2]+t[2]*t[5]-t[4]*t[3])/i,e[1]=(-n*t[1]+r*t[0]+t[4]*t[1]-t[5]*t[0])/i}static axialAlignedBoundingBox(e,t,n){let r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=e[0],u=e[1],d=e[2],f=e[3],p=r*l+s,m=p,h=r*d+s,g=h,_=o*u+c,v=_,y=o*f+c,b=y;if(i!==0||a!==0){let e=i*l,t=i*d,n=a*u,r=a*f;p+=n,g+=n,h+=r,m+=r,_+=e,b+=e,y+=t,v+=t}n[0]=Math.min(n[0],p,h,m,g),n[1]=Math.min(n[1],_,y,v,b),n[2]=Math.max(n[2],p,h,m,g),n[3]=Math.max(n[3],_,y,v,b)}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){let n=e[0],r=e[1],i=e[2],a=e[3],o=Math.pow(n,2)+Math.pow(r,2),s=n*i+r*a,c=Math.pow(i,2)+Math.pow(a,2),l=(o+c)/2,u=Math.sqrt(Math.pow(l,2)-(o*c-Math.pow(s,2)));t[0]=Math.sqrt(l+u||1),t[1]=Math.sqrt(l-u||1)}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],t),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,r,i){i[0]=Math.min(i[0],e,n),i[1]=Math.min(i[1],t,r),i[2]=Math.max(i[2],e,n),i[3]=Math.max(i[3],t,r)}static bezierBoundingBox(t,n,r,i,a,o,s,c,l){l[0]=Math.min(l[0],t,s),l[1]=Math.min(l[1],n,c),l[2]=Math.max(l[2],t,s),l[3]=Math.max(l[3],n,c),f(e,this,$e).call(this,t,r,a,s,n,i,o,c,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),l),f(e,this,$e).call(this,t,r,a,s,n,i,o,c,3*(-n+3*(i-o)+c),6*(n-2*i+o),3*(i-n),l)}};A=B;function Qe(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}function $e(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&f(A,this,Qe).call(this,e,t,n,r,i,a,o,s,-u/l,d);return}let p=Math.pow(l,2)-4*u*c;if(p<0)return;let m=Math.sqrt(p),h=2*c;f(A,this,Qe).call(this,e,t,n,r,i,a,o,s,(-l+m)/h,d),f(A,this,Qe).call(this,e,t,n,r,i,a,o,s,(-l-m)/h,d)}function et(e){return decodeURIComponent(escape(e))}var tt=null,nt=null;function rt(e){return tt||(tt=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,nt=new Map([[`ſt`,`ſt`]])),e.replaceAll(tt,(e,t,n)=>t?t.normalize(`NFKC`):nt.get(n))}function it(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),Xe(e)}function at(e,t,n){if(!Array.isArray(n)||n.length<2)return!1;let[r,i,...a]=n;if(!e(r)&&!Number.isInteger(r)||!t(i))return!1;let o=a.length,s=!0;switch(i.name){case`XYZ`:if(o<2||o>3)return!1;break;case`Fit`:case`FitB`:return o===0;case`FitH`:case`FitBH`:case`FitV`:case`FitBV`:if(o>1)return!1;break;case`FitR`:if(o!==4)return!1;s=!1;break;default:return!1}for(let e of a)if(!(typeof e==`number`||s&&e===null))return!1;return!0}var ot=()=>[],st=()=>new Map,ct=()=>Object.create(null);function V(e,t,n){return Math.min(Math.max(e,t),n)}var lt=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let e=this.viewBox;return R(this,`rawDims`,{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){let n=[e,t];return B.applyTransform(n,this.transform),n}convertToPdfPoint(e,t){let n=[e,t];return B.applyInverseTransform(n,this.transform),n}},ut=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){var r;if(!t)return;let a=null,o=t.name;if(o===`#text`)a=t.value;else if(e.shouldBuildText(o))!(t==null||(r=t.attributes)==null)&&r.textContent?a=t.attributes.textContent:t.value&&(a=t.value);else return;if(a!==null&&n.push({str:a}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return!(e===`textarea`||e===`input`||e===`option`||e===`select`)}},dt=class{static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})});break}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null)switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=document.createElement(r.name);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&ut.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){var u,d;let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:f}=s;if(f===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let p=!(s==null||(u=s.attributes)==null)&&u.xmlns?document.createElementNS(s.attributes.xmlns,f):document.createElement(f);if(a.append(p),s.attributes&&this.setAttributes({html:p,element:s,storage:t,intent:i,linkService:n}),((d=s.children)==null?void 0:d.length)>0)l.push([s,-1,p]);else if(s.value){let e=document.createTextNode(s.value);o&&ut.shouldBuildText(f)&&c.push(e),p.append(e)}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new lt({viewBox:[0,0,parseInt(r,10),parseInt(i,10)],userUnit:1,scale:t,rotation:n})}},ft=class{};ee=ft,g(ft,`CSS`,96),g(ft,`PDF`,72),g(ft,`PDF_TO_CSS_UNITS`,ee.CSS/ee.PDF);function pt(e){return mt.apply(this,arguments)}function mt(){return mt=v(function*(e,t=`text`){if(St(e,document.baseURI)){let n=yield fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`blob`:return n.blob();case`bytes`:return n.bytes();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t===`bytes`?`arraybuffer`:t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`bytes`:n(new Uint8Array(i.response));return;case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}),mt.apply(this,arguments)}var ht=class extends Ue{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function gt(e){let t=e.length,n=0;for(;n<t&&e[n].trim()===``;)n++;return e.substring(n,n+5).toLowerCase()===`data:`}function _t(e){return typeof e==`string`&&/\.pdf$/i.test(e)}function vt(e){return[e]=e.split(/[#?]/,1),He(e)}function yt(e,t=`document.pdf`){if(typeof e!=`string`)return t;if(gt(e))return I(`getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.`),t;let n=(e=>{try{return new URL(e)}catch(e){}try{return new URL(decodeURIComponent(e))}catch(e){}try{return new URL(e,`https://foo.bar`)}catch(e){}try{return new URL(decodeURIComponent(e),`https://foo.bar`)}catch(e){}return null})(e);if(!n)return t;let r=e=>{try{let t=decodeURIComponent(e);return t.includes(`/`)&&(t=He(t),t.length===4&&i.test(t))?e:t}catch(t){return e}},i=/\.pdf$/i,a=He(n.pathname);if(i.test(a))return r(a);if(n.searchParams.size>0){var o;let e=e=>[...e].findLast(e=>i.test(e)),t=(o=e(n.searchParams.values()))==null?e(n.searchParams.keys()):o;if(t)return r(t)}if(n.hash){let e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(e)return r(e[0])}return t}var bt=new WeakMap,xt=class{constructor(){b(this,bt,new Map),g(this,`times`,[])}time(e){x(bt,this).has(e)&&I(`Timer is already running for ${e}`),x(bt,this).set(e,Date.now())}timeEnd(e){x(bt,this).has(e)||I(`Timer has not been started for ${e}`),this.times.push({name:e,start:x(bt,this).get(e),end:Date.now()}),x(bt,this).delete(e)}toString(){let e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join(``)}};function St(e,t){var n;let r=t?URL.parse(e,t):URL.parse(e);return/https?:/.test((n=r==null?void 0:r.protocol)==null?``:n)}function Ct(e){e.preventDefault()}function wt(e){e.preventDefault(),e.stopPropagation()}var Tt=class e{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!=`string`)return null;f(e,this,Et)._||(Et._=f(e,this,RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?`)));let n=f(e,this,Et)._.exec(t);if(!n)return null;let r=parseInt(n[1],10),i=parseInt(n[2],10);i=i>=1&&i<=12?i-1:0;let a=parseInt(n[3],10);a=a>=1&&a<=31?a:1;let o=parseInt(n[4],10);o=o>=0&&o<=23?o:0;let s=parseInt(n[5],10);s=s>=0&&s<=59?s:0;let c=parseInt(n[6],10);c=c>=0&&c<=59?c:0;let l=n[7]||`Z`,u=parseInt(n[8],10);u=u>=0&&u<=23?u:0;let d=parseInt(n[9],10)||0;return d=d>=0&&d<=59?d:0,l===`-`?(o+=u,s+=d):l===`+`&&(o-=u,s-=d),new Date(Date.UTC(r,i,a,o,s,c))}},Et={_:void 0};function Dt(e){if(e.startsWith(`#`)){let t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith(`rgb(`)){let[t,n,r]=e.slice(4,-1).split(`,`).map(e=>parseInt(e,10));return[t,n,r,1]}if(e.startsWith(`rgba(`)){let t=e.slice(5,-1).split(`,`);return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}let t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!==`none`?parseFloat(t[4]):1]:null}function Ot(e){let t=Dt(e);return t?t.slice(0,3):(I(`Not a valid color format: "${e}"`),[0,0,0])}function kt(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,t.style.colorScheme=`only light`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,Ot(r))}t.remove()}function At(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function jt(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Mt(e,t,n=!1,r=!0){if(t instanceof lt){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-x))`,s=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;!n||t.rotation%180==0?(a.width=o,a.height=s):(a.width=s,a.height=o)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var Nt=class e{constructor(){let{pixelRatio:t}=e;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,n,r,i,a=-1){let o=1/0,s=1/0,c=1/0;r=e.capPixels(r,a),r>0&&(o=Math.sqrt(r/(t*n))),i!==-1&&(s=i/t,c=i/n);let l=Math.min(o,s,c);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){let n=Math.ceil(window.screen.availWidth*window.screen.availHeight*Math.pow(this.pixelRatio,2)*(1+t/100));return e>0?Math.min(e,n):n}return e}},Pt=[`image/apng`,`image/avif`,`image/bmp`,`image/gif`,`image/jpeg`,`image/png`,`image/svg+xml`,`image/webp`,`image/x-icon`],Ft=class{static get isDarkMode(){var e,t;return R(this,`isDarkMode`,!!(!((e=window)==null||(t=e.matchMedia)==null)&&t.call(e,`(prefers-color-scheme: dark)`).matches))}},It=class{static get commentForegroundColor(){let e=document.createElement(`span`);e.classList.add(`comment`,`sidebar`);let{style:t}=e;t.width=t.height=`0`,t.display=`none`,t.color=`var(--comment-fg-color)`,document.body.append(e);let{color:n}=window.getComputedStyle(e);return e.remove(),R(this,`commentForegroundColor`,Ot(n))}};function Lt(e,t){var n;t=V((n=t)==null?1:n,0,1);let r=255*(1-t);return e.map(e=>Math.round(e*t+r))}function Rt(e,t){let n=e[0]/255,r=e[1]/255,i=e[2]/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)t[0]=t[1]=0;else{let e=a-o;switch(t[1]=s<.5?e/(a+o):e/(2-a-o),a){case n:t[0]=((r-i)/e+(r<i?6:0))*60;break;case r:t[0]=((i-n)/e+2)*60;break;case i:t[0]=((n-r)/e+4)*60;break}}t[2]=s}function zt(e,t){let n=e[0],r=e[1],i=e[2],a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(n/60%2-1)),s=i-a/2;switch(Math.floor(n/60)){case 0:t[0]=a+s,t[1]=o+s,t[2]=s;break;case 1:t[0]=o+s,t[1]=a+s,t[2]=s;break;case 2:t[0]=s,t[1]=a+s,t[2]=o+s;break;case 3:t[0]=s,t[1]=o+s,t[2]=a+s;break;case 4:t[0]=o+s,t[1]=s,t[2]=a+s;break;case 5:case 6:t[0]=a+s,t[1]=s,t[2]=o+s;break}}function Bt(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Vt(e,t,n){zt(e,n),n.map(Bt);let r=.2126*n[0]+.7152*n[1]+.0722*n[2];zt(t,n),n.map(Bt);let i=.2126*n[0]+.7152*n[1]+.0722*n[2];return r>i?(r+.05)/(i+.05):(i+.05)/(r+.05)}var Ht=new Map;function Ut(e,t){let n=e[0]+e[1]*256+e[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776,r=Ht.get(n);if(r)return r;let i=new Float32Array(9),a=i.subarray(0,3),o=i.subarray(3,6);Rt(e,o);let s=i.subarray(6,9);Rt(t,s);let c=s[2]<.5,l=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),Vt(o,s,a)<l){let e,t;for(c?(e=o[2],t=1):(e=0,t=o[2]);t-e>.005;){let n=o[2]=(e+t)/2;c===Vt(o,s,a)<l?e=n:t=n}o[2]=c?t:e}return zt(o,a),r=B.makeHexColor(Math.round(a[0]*255),Math.round(a[1]*255),Math.round(a[2]*255)),Ht.set(n,r),r}function Wt({html:e,dir:t,className:n},r){let i=document.createDocumentFragment();if(typeof e==`string`){let n=document.createElement(`p`);n.dir=t||`auto`;let r=e.split(/\r\n?|\n/);for(let e=0,t=r.length;e<t;++e){let i=r[e];n.append(document.createTextNode(i)),e<t-1&&n.append(document.createElement(`br`))}i.append(n)}else dt.render({xfaHtml:e,div:i,intent:`richText`});i.firstElementChild.classList.add(`richText`,n),r.append(i)}function Gt(e){let t=new Path2D;if(!e)return t;for(let n=0,r=e.length;n<r;)switch(e[n++]){case Me.moveTo:t.moveTo(e[n++],e[n++]);break;case Me.lineTo:t.lineTo(e[n++],e[n++]);break;case Me.curveTo:t.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);break;case Me.quadraticCurveTo:t.quadraticCurveTo(e[n++],e[n++],e[n++],e[n++]);break;case Me.closePath:t.closePath();break;default:I(`Unrecognized drawing path operator: ${e[n-1]}`);break}return t}var Kt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,Yt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,$t=new WeakMap,en=new WeakSet,tn=class{constructor(e){S(this,en),b(this,Kt,null),b(this,qt,null),b(this,Jt,void 0),b(this,Yt,null),b(this,Xt,null),b(this,Zt,null),b(this,Qt,null),b(this,$t,null),C(Jt,this,e),cn._||(cn._=Object.freeze({freetext:`pdfjs-editor-remove-freetext-button`,highlight:`pdfjs-editor-remove-highlight-button`,ink:`pdfjs-editor-remove-ink-button`,stamp:`pdfjs-editor-remove-stamp-button`,signature:`pdfjs-editor-remove-signature-button`}))}render(){let e=C(Kt,this,document.createElement(`div`));e.classList.add(`editToolbar`,`hidden`),e.setAttribute(`role`,`toolbar`);let t=x(Jt,this)._uiManager._signal;t instanceof AbortSignal&&!t.aborted&&(e.addEventListener(`contextmenu`,Ct,{signal:t}),e.addEventListener(`pointerdown`,nn,{signal:t}));let n=C(Yt,this,document.createElement(`div`));n.className=`buttons`,e.append(n);let r=x(Jt,this).toolbarPosition;if(r){let{style:t}=e;t.insetInlineEnd=`${100*(x(Jt,this)._uiManager.direction===`ltr`?1-r[0]:r[0])}%`,t.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return x(Kt,this)}hide(){var e;x(Kt,this).classList.add(`hidden`),(e=x(qt,this))==null||e.hideDropdown()}show(){var e,t;x(Kt,this).classList.remove(`hidden`),(e=x(Xt,this))==null||e.shown(),(t=x(Zt,this))==null||t.shown()}addDeleteButton(){let{editorType:e,_uiManager:t}=x(Jt,this),n=document.createElement(`button`);n.classList.add(`basic`,`deleteButton`),n.tabIndex=0,n.setAttribute(`data-l10n-id`,cn._[e]),f(en,this,on).call(this,n)&&n.addEventListener(`click`,e=>{t.delete()},{signal:t._signal}),x(Yt,this).append(n)}addAltText(e){var t=this;return v(function*(){let n=yield e.render();f(en,t,on).call(t,n),x(Yt,t).append(n,sn.call(f(en,t))),C(Xt,t,e)})()}addComment(e,t=null){if(x(Zt,this))return;let n=e.renderForToolbar();if(!n)return;f(en,this,on).call(this,n);let r=C(Qt,this,sn.call(f(en,this)));t?(x(Yt,this).insertBefore(n,t),x(Yt,this).insertBefore(r,t)):x(Yt,this).append(n,r),C(Zt,this,e),e.toolbar=this}addColorPicker(e){if(x(qt,this))return;C(qt,this,e);let t=e.renderButton();f(en,this,on).call(this,t),x(Yt,this).append(t,sn.call(f(en,this)))}addEditSignatureButton(e){var t=this;return v(function*(){let n=C($t,t,yield e.renderEditButton(x(Jt,t)));f(en,t,on).call(t,n),x(Yt,t).append(n,sn.call(f(en,t)))})()}removeButton(e){switch(e){case`comment`:var t,n;(t=x(Zt,this))==null||t.removeToolbarCommentButton(),C(Zt,this,null),(n=x(Qt,this))==null||n.remove(),C(Qt,this,null);break}}addButton(e,t){var n=this;return v(function*(){switch(e){case`colorPicker`:t&&n.addColorPicker(t);break;case`altText`:t&&(yield n.addAltText(t));break;case`editSignature`:t&&(yield n.addEditSignatureButton(t));break;case`delete`:n.addDeleteButton();break;case`comment`:t&&n.addComment(t);break}})()}addButtonBefore(e,t,n){var r=this;return v(function*(){if(!t&&e===`comment`)return;let i=x(Yt,r).querySelector(n);i&&e===`comment`&&r.addComment(t,i)})()}updateEditSignatureButton(e){x($t,this)&&(x($t,this).title=e)}remove(){var e;x(Kt,this).remove(),(e=x(qt,this))==null||e.destroy(),C(qt,this,null)}};function nn(e){e.stopPropagation()}function rn(e){x(Jt,this)._focusEventsAllowed=!1,wt(e)}function an(e){x(Jt,this)._focusEventsAllowed=!0,wt(e)}function on(e){let t=x(Jt,this)._uiManager._signal;return!(t instanceof AbortSignal)||t.aborted?!1:(e.addEventListener(`focusin`,f(en,this,rn).bind(this),{capture:!0,signal:t}),e.addEventListener(`focusout`,f(en,this,an).bind(this),{capture:!0,signal:t}),e.addEventListener(`contextmenu`,Ct,{signal:t}),!0)}function sn(){let e=document.createElement(`div`);return e.className=`divider`,e}var cn={_:null},ln=new WeakMap,un=new WeakMap,dn=new WeakMap,fn=new WeakSet,pn=class{constructor(e){S(this,fn),b(this,ln,null),b(this,un,null),b(this,dn,void 0),C(dn,this,e)}show(e,t,n){let[r,i]=f(fn,this,hn).call(this,t,n),{style:a}=x(un,this)||C(un,this,f(fn,this,mn).call(this));e.append(x(un,this)),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){x(un,this).remove()}};function mn(){let e=C(un,this,document.createElement(`div`));e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`);let t=x(dn,this)._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener(`contextmenu`,Ct,{signal:t});let n=C(ln,this,document.createElement(`div`));return n.className=`buttons`,e.append(n),x(dn,this).hasCommentManager()&&f(fn,this,gn).call(this,`commentButton`,`pdfjs-comment-floating-button`,`pdfjs-comment-floating-button-label`,()=>{x(dn,this).commentSelection(`floating_button`)}),f(fn,this,gn).call(this,`highlightButton`,`pdfjs-highlight-floating-button1`,`pdfjs-highlight-floating-button-label`,()=>{x(dn,this).highlightSelection(`floating_button`)}),e}function hn(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(e<n)continue;let a=i.x+(t?i.width:0);if(e>n){r=a,n=e;continue}t?a>r&&(r=a):a<r&&(r=a)}return[t?1-r:r,n]}function gn(e,t,n,r){let i=document.createElement(`button`);i.classList.add(`basic`,e),i.tabIndex=0,i.setAttribute(`data-l10n-id`,t);let a=document.createElement(`span`);i.append(a),a.className=`visuallyHidden`,a.setAttribute(`data-l10n-id`,n);let o=x(dn,this)._signal;o instanceof AbortSignal&&!o.aborted&&(i.addEventListener(`contextmenu`,Ct,{signal:o}),i.addEventListener(`click`,r,{signal:o})),x(ln,this).append(i)}var _n=Object.freeze({internal:`068f09d6-5b37-4f77-a97a-f8ff4f253b68`});function vn(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}var yn=class e{static initializeAndAddPointerId(e){(xn._||(xn._=new Set)).add(e)}static setPointer(e,t){bn._||(bn._=t),Cn._!=null||(Cn._=e)}static setTimeStamp(e){Sn._=e}static isSamePointerId(e){return bn._===e}static isSamePointerIdOrRemove(e){var t;return bn._===e?!0:((t=xn._)==null||t.delete(e),!1)}static isSamePointerType(e){return Cn._===e}static isInitializedAndDifferentPointerType(t){return Cn._!==null&&!e.isSamePointerType(t)}static isSameTimeStamp(e){return Sn._===e}static isUsingMultiplePointers(){var e;return((e=xn._)==null?void 0:e.size)>=1}static clearPointerType(){Cn._=null}static clearPointerIds(){bn._=NaN,xn._=null}static clearTimeStamp(){Sn._=NaN}},bn={_:NaN},xn={_:null},Sn={_:NaN},Cn={_:null},wn=new WeakMap,Tn=class{constructor(){b(this,wn,0)}get id(){var e,t;return`${Te}${C(wn,this,(e=x(wn,this),t=e++,e)),t}`}},En=new WeakMap,Dn=new WeakMap,On=new WeakMap,kn=new WeakSet,An=class{constructor(){S(this,kn),b(this,En,it()),b(this,Dn,0),b(this,On,null)}static get _isSVGFittingCanvas(){let e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${xe}"><rect width="1" height="1" style="fill:red;"/></svg>`,t=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),n=new Image;n.src=e;let r=n.decode().then(()=>(t.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]===0));return R(this,`_isSVGFittingCanvas`,r)}getFromFile(e){var t=this;return v(function*(){let{lastModified:n,name:r,size:i,type:a}=e;return f(kn,t,jn).call(t,`${n}_${r}_${i}_${a}`,e)})()}getFromUrl(e){var t=this;return v(function*(){return f(kn,t,jn).call(t,e,e)})()}getFromBlob(e,t){var n=this;return v(function*(){let r=yield t;return f(kn,n,jn).call(n,e,r)})()}getFromId(e){var t=this;return v(function*(){x(On,t)||C(On,t,new Map);let n=x(On,t).get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return t.getFromFile(n.file);if(n.blobPromise){let{blobPromise:e}=n;return delete n.blobPromise,t.getFromBlob(n.id,e)}return t.getFromUrl(n.url)})()}getFromCanvas(e,t){var n,r;x(On,this)||C(On,this,new Map);let i=x(On,this).get(e);if(i!=null&&i.bitmap)return i.refCounter+=1,i;let a=new OffscreenCanvas(t.width,t.height);return a.getContext(`2d`).drawImage(t,0,0),i={bitmap:a.transferToImageBitmap(),id:`image_${x(En,this)}_${C(Dn,this,(n=x(Dn,this),r=n++,n)),r}`,refCounter:1,isSvg:!1},x(On,this).set(e,i),x(On,this).set(i.id,i),i}getSvgUrl(e){let t=x(On,this).get(e);return t!=null&&t.isSvg?t.svgUrl:null}deleteId(e){var t;x(On,this)||C(On,this,new Map);let n=x(On,this).get(e);if(!n||(--n.refCounter,n.refCounter!==0))return;let{bitmap:r}=n;if(!n.url&&!n.file){let e=new OffscreenCanvas(r.width,r.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(r),n.blobPromise=e.convertToBlob()}(t=r.close)==null||t.call(r),n.bitmap=null}isValidId(e){return e.startsWith(`image_${x(En,this)}_`)}};j=An;function jn(e,t){var n=this;return v(function*(){x(On,n)||C(On,n,new Map);let r=x(On,n).get(e);if(r===null)return null;if(r!=null&&r.bitmap)return r.refCounter+=1,r;try{var i,a;r||(r={bitmap:null,id:`image_${x(En,n)}_${C(Dn,n,(i=x(Dn,n),a=i++,i)),a}`,refCounter:0,isSvg:!1});let e;if(typeof t==`string`?(r.url=t,e=yield pt(t,`blob`)):t instanceof File?e=r.file=t:t instanceof Blob&&(e=t),e.type===`image/svg+xml`){let t=j._isSVGFittingCanvas,n=new FileReader,i=new Image,a=new Promise((e,a)=>{i.onload=()=>{r.bitmap=i,r.isSvg=!0,e()},n.onload=v(function*(){let e=r.svgUrl=n.result;i.src=(yield t)?`${e}#svgView(preserveAspectRatio(none))`:e}),i.onerror=n.onerror=a});n.readAsDataURL(e),yield a}else r.bitmap=yield createImageBitmap(e);r.refCounter=1}catch(e){I(e),r=null}return x(On,n).set(e,r),r&&x(On,n).set(r.id,r),r})()}var Mn=new WeakMap,Nn=new WeakMap,Pn=new WeakMap,Fn=new WeakMap,In=class{constructor(e=128){b(this,Mn,[]),b(this,Nn,!1),b(this,Pn,void 0),b(this,Fn,-1),C(Pn,this,e)}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),x(Nn,this))return;let s={cmd:e,undo:t,post:n,type:i};if(x(Fn,this)===-1){x(Mn,this).length>0&&(x(Mn,this).length=0),C(Fn,this,0),x(Mn,this).push(s);return}if(a&&x(Mn,this)[x(Fn,this)].type===i){o&&(s.undo=x(Mn,this)[x(Fn,this)].undo),x(Mn,this)[x(Fn,this)]=s;return}let c=x(Fn,this)+1;c===x(Pn,this)?x(Mn,this).splice(0,1):(C(Fn,this,c),c<x(Mn,this).length&&x(Mn,this).splice(c)),x(Mn,this).push(s)}undo(){if(x(Fn,this)===-1)return;C(Nn,this,!0);let{undo:e,post:t}=x(Mn,this)[x(Fn,this)];e(),t==null||t(),C(Nn,this,!1),C(Fn,this,x(Fn,this)-1)}redo(){if(x(Fn,this)<x(Mn,this).length-1){C(Fn,this,x(Fn,this)+1),C(Nn,this,!0);let{cmd:e,post:t}=x(Mn,this)[x(Fn,this)];e(),t==null||t(),C(Nn,this,!1)}}hasSomethingToUndo(){return x(Fn,this)!==-1}hasSomethingToRedo(){return x(Fn,this)<x(Mn,this).length-1}cleanType(e){if(x(Fn,this)!==-1){for(let t=x(Fn,this);t>=0;t--)if(x(Mn,this)[t].type!==e){x(Mn,this).splice(t+1,x(Fn,this)-t),C(Fn,this,t);return}x(Mn,this).length=0,C(Fn,this,-1)}}destroy(){C(Mn,this,null)}},Ln=class e{constructor(t){this.callbacks=new Map;let{isMac:n}=z.platform;for(let[r,i,a={}]of t){let t=r.some(e=>e.startsWith(`mac+`));for(let o of r){let r=o;if(t){let e=o.startsWith(`mac+`);if(n!==e)continue;e&&(r=o.slice(4))}let[s,c]=Rn.call(e,r);s!==null&&this.callbacks.getOrInsertComputed(s,ot).push({callback:i,options:a,modifiers:c})}}}exec(t,n){let r=this.callbacks.get(n.key);if(!r){if(/^[a-z]$/i.test(n.key))return;let t=zn.call(e,n.code);if(t===null||t===n.key||(r=this.callbacks.get(t),!r))return}let i=(n.altKey?e.ALT:0)|(n.ctrlKey?e.CTRL:0)|(n.metaKey?e.META:0)|(n.shiftKey?e.SHIFT:0),a=r.find(e=>e.modifiers===i);if(!a)return;let{callback:o,options:{bubbles:s=!1,args:c=[],checker:l=null}}=a;l&&!l(t,n)||(o.bind(t,...c,n)(),s||wt(n))}};te=Ln;function Rn(e){let t=null,n=0;for(let r of e.split(`+`)){if(r=r.trim(),!r)continue;let i=r.toUpperCase(),a=te[i];if(a){n|=a;continue}if(t!==null){I(`KeyboardManager: multiple keys in shortcut "${e}"`);break}t=i===`SPACE`?` `:r}return t===null&&I(`KeyboardManager: no key found in shortcut "${e}"`),[t,n]}function zn(e){var t,n;let r=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return r?(t=(n=r[1])==null?void 0:n.toLowerCase())==null?r[2]:t:null}g(Ln,`ALT`,1),g(Ln,`CTRL`,2),g(Ln,`META`,4),g(Ln,`SHIFT`,8);var Bn=class e{get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return kt(e),R(this,`_colors`,e)}convert(t){let n=Ot(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?B.makeHexColor(...t):e}};g(Bn,`_colorsMapping`,new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]));var Vn=new WeakMap,Hn=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,Kn=new WeakMap,qn=new WeakMap,Jn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap,sr=new WeakMap,cr=new WeakMap,lr=new WeakMap,ur=new WeakMap,dr=new WeakMap,fr=new WeakMap,pr=new WeakMap,mr=new WeakMap,hr=new WeakMap,gr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,br=new WeakMap,xr=new WeakMap,Sr=new WeakMap,Cr=new WeakMap,wr=new WeakMap,Tr=new WeakMap,Er=new WeakMap,Dr=new WeakMap,Or=new WeakMap,kr=new WeakMap,Ar=new WeakMap,jr=new WeakMap,Mr=new WeakMap,Nr=new WeakMap,Pr=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,H=new WeakSet,Lr=class e{static get _keyboardManager(){let t=e.prototype,n=e=>x(Nr,e).contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return R(this,`_keyboardManager`,new Ln([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&x(Nr,e).contains(t)&&!e.isEnterHandled}],[[`Space`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&x(Nr,e).contains(document.activeElement)}],[[`Escape`],t.unselectAll],[[`ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,p,m,h,_){S(this,H),b(this,Vn,new AbortController),b(this,Hn,null),b(this,Un,null),b(this,Wn,new Map),b(this,Gn,new Map),b(this,Kn,null),b(this,qn,null),b(this,Jn,null),b(this,Yn,null),b(this,Xn,new In),b(this,Zn,null),b(this,Qn,null),b(this,$n,null),b(this,er,0),b(this,tr,new Set),b(this,nr,null),b(this,rr,null),b(this,ir,new Set),g(this,`_editorUndoBar`,null),b(this,ar,!1),b(this,or,!1),b(this,sr,!1),b(this,cr,null),b(this,lr,null),b(this,ur,null),b(this,dr,null),b(this,fr,!1),b(this,pr,null),b(this,mr,new Tn),b(this,hr,!1),b(this,gr,!1),b(this,_r,!1),b(this,vr,null),b(this,yr,null),b(this,br,null),b(this,xr,null),b(this,Sr,null),b(this,Cr,N.NONE),b(this,wr,new Set),b(this,Tr,null),b(this,Er,null),b(this,Dr,null),b(this,Or,null),b(this,kr,null),b(this,Ar,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),b(this,jr,[0,0]),b(this,Mr,null),b(this,Nr,null),b(this,Pr,null),b(this,Fr,null),b(this,Ir,null);let v=this._signal=x(Vn,this).signal;C(Nr,this,e),C(Pr,this,t),C(Fr,this,n),C(qn,this,r),C(Zn,this,i),C(Er,this,a),C(kr,this,s),this._eventBus=o;let y=T({signal:v},_n);o.on(`editingaction`,this.onEditingAction.bind(this),y),o.on(`pagechanging`,this.onPageChanging.bind(this),y),o.on(`scalechanging`,this.onScaleChanging.bind(this),y),o.on(`rotationchanging`,this.onRotationChanging.bind(this),y),o.on(`setpreference`,this.onSetPreference.bind(this),y),o.on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),y),window.addEventListener(`pointerdown`,()=>{C(gr,this,!0)},{capture:!0,signal:v}),window.addEventListener(`pointerup`,()=>{C(gr,this,!1)},{capture:!0,signal:v}),window.addEventListener(`beforeunload`,f(H,this,Br).bind(this),{capture:!0,signal:v}),f(H,this,Wr).call(this),f(H,this,Zr).call(this),f(H,this,qr).call(this),C(Jn,this,s.annotationStorage),C(cr,this,s.filterFactory),C(Dr,this,c),C(dr,this,l||null),C(ar,this,u),C(or,this,d),C(sr,this,p),C(Sr,this,m||null),this.viewParameters={realScale:ft.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=h||null,this._supportsPinchToZoom=_!==!1,i==null||i.setSidebarUiManager(this)}destroy(){var e,t,n,r,i,a,o,s,c;(e=x(Ir,this))==null||e.resolve(),C(Ir,this,null),(t=x(Vn,this))==null||t.abort(),C(Vn,this,null),this._signal=null;for(let e of x(Gn,this).values())e.destroy();x(Gn,this).clear(),x(Wn,this).clear(),x(ir,this).clear(),(n=x(xr,this))==null||n.clear(),C(Hn,this,null),x(wr,this).clear(),x(Xn,this).destroy(),(r=x(qn,this))==null||r.destroy(),(i=x(Zn,this))==null||i.destroy(),(a=x(Er,this))==null||a.destroy(),(o=x(pr,this))==null||o.hide(),C(pr,this,null),(s=x(br,this))==null||s.destroy(),C(br,this,null),C(Un,this,null),x(lr,this)&&(clearTimeout(x(lr,this)),C(lr,this,null)),x(Mr,this)&&(clearTimeout(x(Mr,this)),C(Mr,this,null)),(c=this._editorUndoBar)==null||c.destroy(),C(kr,this,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return x(Sr,this)}get useNewAltTextFlow(){return x(or,this)}get useNewAltTextWhenAddingImage(){return x(sr,this)}get hcmFilter(){return R(this,`hcmFilter`,x(Dr,this)?x(cr,this).addHCMFilter(x(Dr,this).foreground,x(Dr,this).background):`none`)}get direction(){return R(this,`direction`,getComputedStyle(x(Nr,this)).direction)}get _highlightColors(){return R(this,`_highlightColors`,x(dr,this)?new Map(x(dr,this).split(`,`).map(e=>(e=e.split(`=`).map(e=>e.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){let{_highlightColors:e}=this;if(!e)return R(this,`highlightColors`,null);let t=new Map,n=!!x(Dr,this);for(let[r,i]of e){let e=r.endsWith(`_HCM`);if(n&&e){t.set(r.replace(`_HCM`,``),i);continue}!n&&!e&&t.set(r,i)}return R(this,`highlightColors`,t)}get highlightColorNames(){return R(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;let t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),C($n,this,e)}setMainHighlightColorPicker(e){C(br,this,e)}editAltText(e,t=!1){var n;(n=x(qn,this))==null||n.editAltText(this,e,t)}hasCommentManager(){return!!x(Zn,this)}editComment(e,t,n,r){var i;(i=x(Zn,this))==null||i.showDialog(this,e,t,n,r)}selectComment(e,t){let n=x(Gn,this).get(e),r=n==null?void 0:n.getEditorByUID(t);r==null||r.toggleComment(!0,!0)}updateComment(e){var t;(t=x(Zn,this))==null||t.updateComment(e.getData())}updatePopupColor(e){var t;(t=x(Zn,this))==null||t.updatePopupColor(e)}removeComment(e){var t;(t=x(Zn,this))==null||t.removeComments([e.uid])}deleteComment(e,t){let n=()=>{e.comment=t};this.addCommands({cmd:()=>{var t;(t=this._editorUndoBar)==null||t.show(n,`comment`),this.toggleComment(null),e.comment=null},undo:n,mustExec:!0})}toggleComment(e,t,n=void 0){var r;(r=x(Zn,this))==null||r.toggleCommentPopup(e,t,n)}makeCommentColor(e,t){var n;return e&&((n=x(Zn,this))==null?void 0:n.makeCommentColor(e,t))||null}getCommentDialogElement(){var e;return((e=x(Zn,this))==null?void 0:e.dialogElement)||null}waitForEditorsRendered(e){var t=this;return v(function*(){if(x(Gn,t).has(e-1))return;let{resolve:n,promise:r}=Promise.withResolvers(),i=r=>{r.pageNumber===e&&(t._eventBus.off(`editorsrendered`,i),n())};t._eventBus.on(`editorsrendered`,i,_n),yield r})()}getSignature(e){var t;(t=x(Er,this))==null||t.getSignature({uiManager:this,editor:e})}get signatureManager(){return x(Er,this)}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,T({once:!0,signal:this._signal},_n)),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case`enableNewAltTextWhenAddingImage`:C(sr,this,t);break}}onPageChanging({pageNumber:e}){C(er,this,e-1)}deletePage(e){for(let t of this.getEditors(e))t.remove();x(Gn,this).delete(e),x(er,this)===e&&C(er,this,0)}focusMainContainer(){x(Nr,this).focus()}findParent(e,t){for(let n of x(Gn,this).values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){x(Pr,this).classList.toggle(`noUserSelect`,e)}addShouldRescale(e){x(ir,this).add(e)}removeShouldRescale(e){x(ir,this).delete(e)}onScaleChanging({scale:e}){var t;this.commitOrRemove(),this.viewParameters.realScale=e*ft.PDF_TO_CSS_UNITS;for(let e of x(ir,this))e.onScaleChanging();(t=x($n,this))==null||t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=``,t=!1){let n=document.getSelection();if(!n||n.isCollapsed)return;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n,s=n.toString(),c=f(H,this,Rr).call(this,n).closest(`.textLayer`),l=this.getSelectionBoxes(c);if(!l)return;n.empty();let u=f(H,this,zr).call(this,c),d=x(Cr,this)===N.NONE,p=()=>{let n=u==null?void 0:u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o,text:s});d&&this.showAllEditors(`highlight`,!0,!0),t&&(n==null||n.editComment())};if(d){this.switchToMode(N.HIGHLIGHT,p);return}p()}commentSelection(e=``){this.highlightSelection(e,!0)}getAndRemoveDataFromAnnotationStorage(e){if(!x(Jn,this))return null;let t=`${Te}${e}`,n=x(Jn,this).getRawValue(t);return n&&x(Jn,this).remove(t),n}addToAnnotationStorage(e){!e.isEmpty()&&x(Jn,this)&&!x(Jn,this).has(e.id)&&x(Jn,this).setValue(e.id,e)}a11yAlert(e,t=null){let n=x(Fr,this);n&&(n.setAttribute(`data-l10n-id`,e),t?n.setAttribute(`data-l10n-args`,JSON.stringify(t)):n.removeAttribute(`data-l10n-args`))}blur(){if(this.isShiftKeyDown=!1,x(fr,this)&&(C(fr,this,!1),f(H,this,Ur).call(this,`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of x(wr,this))if(t.div.contains(e)){C(yr,this,[t,e]),t._focusEventsAllowed=!1;break}}focus(){if(!x(yr,this))return;let[e,t]=x(yr,this);C(yr,this,null),t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){f(H,this,qr).call(this),this.setEditingState(!0)}removeEditListeners(){f(H,this,Jr).call(this),this.setEditingState(!1)}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of x(rr,this))if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of x(rr,this))if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){var t;if(e.preventDefault(),(t=x(Hn,this))==null||t.commitOrRemove(),!this.hasSelection)return;let n=[];for(let e of x(wr,this)){let t=e.serialize(!0);t&&n.push(t)}n.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(n))}cut(e){this.copy(e),this.delete()}paste(e){var t=this;return v(function*(){e.preventDefault();let{clipboardData:n}=e;for(let e of n.items)for(let n of x(rr,t))if(n.isHandlingMimeForPasting(e.type)){n.paste(e,t.currentLayer);return}let r=n.getData(`application/pdfjs`);if(!r)return;try{r=JSON.parse(r)}catch(e){I(`paste: "${e.message}".`);return}if(!Array.isArray(r))return;t.unselectAll();let i=t.currentLayer;try{let e=[];for(let t of r){let n=yield i.deserialize(t);if(!n)return;e.push(n)}t.addCommands({cmd:()=>{for(let n of e)f(H,t,ni).call(t,n);f(H,t,ai).call(t,e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){I(`paste: "${e.message}".`)}})()}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),x(Cr,this)!==N.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,x(fr,this)&&(C(fr,this,!1),f(H,this,Ur).call(this,`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break;case`commentSelection`:this.commentSelection(`context_menu`);break}}updatePageIndex(e,t){for(let n of this.getEditors(e))n.pageIndex=t;let n=x(Kn,this).get(e);n&&(n.pageIndex=t,x(Gn,this).set(t,n),x(hr,this)?n.enable():n.disable())}startUpdatePages(){C(Kn,this,new Map(x(Gn,this))),x(Gn,this).clear()}endUpdatePages(){C(Kn,this,null)}clonePage(e,t){for(let n of this.getEditors(e)){let e=n.serialize(n.mode!==N.HIGHLIGHT);e&&(e.pageIndex=t,e.id=this.getId(),e.isClone=!0,delete e.popupRef,x(Jn,this).setValue(e.id,e))}}findClonesForPage(e){let t=[],{pageIndex:n}=e;for(let[r,i]of x(Jn,this))i.pageIndex===n&&i.isClone&&(x(Jn,this).remove(r),t.push(e.deserialize(i).then(t=>{t&&(t.isClone=!0,e.addOrRebuild(t))})));return Promise.all(t)}setEditingState(e){e?(f(H,this,Gr).call(this),f(H,this,Yr).call(this),f(H,this,Qr).call(this,{isEditing:x(Cr,this)!==N.NONE,isEmpty:f(H,this,ii).call(this),hasSomethingToUndo:x(Xn,this).hasSomethingToUndo(),hasSomethingToRedo:x(Xn,this).hasSomethingToRedo(),hasSelectedEditor:!1})):(f(H,this,Kr).call(this),f(H,this,Xr).call(this),f(H,this,Qr).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!x(rr,this)){C(rr,this,e);for(let e of x(rr,this))f(H,this,$r).call(this,e.defaultPropertiesToUpdate)}}getId(){return x(mr,this).id}get currentLayer(){return x(Gn,this).get(x(er,this))}getLayer(e){return x(Gn,this).get(e)}get currentPageIndex(){return x(er,this)}addLayer(e){x(Gn,this).set(e.pageIndex,e),x(hr,this)?e.enable():e.disable()}removeLayer(e){x(Gn,this).delete(e.pageIndex)}updateMode(e,t=null,n=!1,r=!1,i=!1,a=!1){var o=this;return v(function*(){var s,c;if(x(Cr,o)!==e&&!(x(Ir,o)&&(yield x(Ir,o).promise,!x(Ir,o)))){if(C(Ir,o,Promise.withResolvers()),(s=x($n,o))==null||s.commitOrRemove(),x(Cr,o)===N.POPUP){var l;(l=x(Zn,o))==null||l.hideSidebar()}if((c=x(Zn,o))==null||c.destroyPopup(),C(Cr,o,e),e===N.NONE){var u;o.setEditingState(!1),f(H,o,ti).call(o);for(let e of x(Wn,o).values())e.hideStandaloneCommentButton();(u=o._editorUndoBar)==null||u.hide(),o.toggleComment(null),x(Ir,o).resolve();return}for(let e of x(Wn,o).values())e.addStandaloneCommentButton();if(e===N.SIGNATURE){var d;yield(d=x(Er,o))==null?void 0:d.loadSignatures()}n&&yn.clearPointerType(),o.setEditingState(!0),yield f(H,o,ei).call(o),o.unselectAll();for(let t of x(Gn,o).values())t.updateMode(e);if(e===N.POPUP){var p;x(Un,o)||C(Un,o,yield x(kr,o).getAnnotationsByType(new Set(x(rr,o).map(e=>e._editorType))));let e=new Set,t=[];for(let n of x(Wn,o).values()){let{annotationElementId:r,hasComment:i,deleted:a}=n;r&&e.add(r),i&&!a&&t.push(n.getData())}for(let n of x(Un,o)){let{id:r,popupRef:i,contentsObj:a}=n;i&&a!=null&&a.str&&!e.has(r)&&!x(tr,o).has(r)&&t.push(n)}(p=x(Zn,o))==null||p.showSidebar(t)}if(!t){r&&o.addNewEditorFromKeyboard(),x(Ir,o).resolve();return}for(let e of x(Wn,o).values())e.uid===t?(o.setSelected(e),a?e.editComment():i?e.enterInEditMode():e.focus()):e.unselect();x(Ir,o).resolve()}})()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==x(Cr,this)&&this._eventBus.dispatch(`switchannotationeditormode`,T({source:this},e))}updateParams(e,t){if(x(rr,this)){switch(e){case P.CREATE:this.currentLayer.addNewEditor(t);return;case P.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(x(Or,this)||C(Or,this,new Map)).set(e,t),this.showAllEditors(`highlight`,t);break}if(this.hasSelection)for(let n of x(wr,this))n.updateParams(e,t);else for(let n of x(rr,this))n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){var r,i;for(let n of x(Wn,this).values())n.editorType===e&&n.show(t);((r=(i=x(Or,this))==null?void 0:i.get(P.HIGHLIGHT_SHOW_ALL))==null||r)!==t&&f(H,this,$r).call(this,[[P.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(x(_r,this)!==e){C(_r,this,e);for(let t of x(Gn,this).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}*getEditors(e){for(let t of x(Wn,this).values())t.pageIndex===e&&(yield t)}getEditor(e){return x(Wn,this).get(e)}addEditor(e){x(Wn,this).set(e.id,e)}removeEditor(e){if(e.div.contains(document.activeElement)&&(x(lr,this)&&clearTimeout(x(lr,this)),C(lr,this,setTimeout(()=>{this.focusMainContainer(),C(lr,this,null)},0))),x(Wn,this).delete(e.id),e.annotationElementId){var t;(t=x(xr,this))==null||t.delete(e.annotationElementId)}if(this.unselect(e),!e.annotationElementId||!x(tr,this).has(e.annotationElementId)){var n;(n=x(Jn,this))==null||n.remove(e.id)}}addDeletedAnnotationElement(e){x(tr,this).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return x(tr,this).has(e)}removeDeletedAnnotationElement(e){x(tr,this).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){x(Hn,this)!==e&&(C(Hn,this,e),e&&f(H,this,$r).call(this,e.propertiesToUpdate))}updateUI(e){ri.call(f(H,this))===e&&f(H,this,$r).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){f(H,this,$r).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(x(wr,this).has(e)){x(wr,this).delete(e),e.unselect(),f(H,this,Qr).call(this,{hasSelectedEditor:this.hasSelection});return}x(wr,this).add(e),e.select(),f(H,this,$r).call(this,e.propertiesToUpdate),f(H,this,Qr).call(this,{hasSelectedEditor:!0})}setSelected(e){var t,n;this.updateToolbar({mode:e.mode,editId:e.uid}),(t=x($n,this))==null||t.commitOrRemove();for(let t of x(wr,this))t!==e&&t.unselect();(n=x(Zn,this))==null||n.destroyPopup(),x(wr,this).clear(),x(wr,this).add(e),e.select(),f(H,this,$r).call(this,e.propertiesToUpdate),f(H,this,Qr).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return x(wr,this).values().next().value}unselect(e){e.unselect(),x(wr,this).delete(e),f(H,this,Qr).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return x(wr,this).size!==0}get isEnterHandled(){return x(wr,this).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;x(Xn,this).undo(),f(H,this,Qr).call(this,{hasSomethingToUndo:x(Xn,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:f(H,this,ii).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){x(Xn,this).redo(),f(H,this,Qr).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:x(Xn,this).hasSomethingToRedo(),isEmpty:f(H,this,ii).call(this)})}addCommands(e){x(Xn,this).add(e),f(H,this,Qr).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:f(H,this,ii).call(this)})}cleanUndoStack(e){x(Xn,this).cleanType(e)}delete(){var e;this.commitOrRemove();let t=(e=this.currentLayer)==null?void 0:e.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let n=t?[t]:[...x(wr,this)],r=()=>{var e;(e=this._editorUndoBar)==null||e.show(i,n.length===1?n[0].editorType:n.length);for(let e of n)e.remove()},i=()=>{for(let e of n)f(H,this,ni).call(this,e)};this.addCommands({cmd:r,undo:i,mustExec:!0})}commitOrRemove(){var e;(e=x(Hn,this))==null||e.commitOrRemove()}hasSomethingToControl(){return x(Hn,this)||this.hasSelection}selectAll(){for(let e of x(wr,this))e.commit();f(H,this,ai).call(this,x(Wn,this).values())}unselectAll(){var e,t;if(!(x(Hn,this)&&(x(Hn,this).commitOrRemove(),x(Cr,this)!==N.NONE))&&!((e=x($n,this))!=null&&e.commitOrRemove())&&((t=x(Zn,this))==null||t.destroyPopup(),this.hasSelection)){for(let e of x(wr,this))e.unselect();x(wr,this).clear(),f(H,this,Qr).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;x(jr,this)[0]+=e,x(jr,this)[1]+=t;let[r,i]=x(jr,this),a=[...x(wr,this)];x(Mr,this)&&clearTimeout(x(Mr,this)),C(Mr,this,setTimeout(()=>{C(Mr,this,null),x(jr,this)[0]=x(jr,this)[1]=0,this.addCommands({cmd:()=>{for(let e of a)x(Wn,this).has(e.id)&&(e.translateInPage(r,i),e.translationDone())},undo:()=>{for(let e of a)x(Wn,this).has(e.id)&&(e.translateInPage(-r,-i),e.translationDone())},mustExec:!1})},1e3));for(let n of a)n.translateInPage(e,t),n.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),C(nr,this,new Map);for(let e of x(wr,this))x(nr,this).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!x(nr,this))return!1;this.disableUserSelect(!1);let e=x(nr,this);C(nr,this,null);let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||(t=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex);if(!t)return!1;let n=(e,t,n,r)=>{if(x(Wn,this).has(e.id)){let i=x(Gn,this).get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(x(nr,this))for(let n of x(nr,this).keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||x(wr,this).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return x(Hn,this)===e}getActive(){return x(Hn,this)}getMode(){return x(Cr,this)}isEditingMode(){return x(Cr,this)!==N.NONE}get imageManager(){return R(this,`imageManager`,new An)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a});break}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r===0||i===0||s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){(x(Yn,this)||C(Yn,this,new Map)).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){var t;(t=x(Yn,this))==null||t.delete(e)}renderAnnotationElement(e){var t;let n=(t=x(Yn,this))==null?void 0:t.get(e.data.id);if(!n)return;let r=x(Jn,this).getRawValue(n);r&&(x(Cr,this)===N.NONE&&!r.hasBeenModified||r.renderAnnotationElement(e))}setMissingCanvas(e,t,n){var r;let i=(r=x(xr,this))==null?void 0:r.get(e);i&&(i.setCanvas(t,n),x(xr,this).delete(e))}addMissingCanvas(e,t){(x(xr,this)||C(xr,this,new Map)).set(e,t)}};function Rr({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function zr(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of x(Gn,this).values())if(t.hasTextLayer(e))return t;return null}function Br(e){var t;this.commitOrRemove(),(t=this.currentLayer)==null||t.endDrawingSession(!1)}function Vr(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=f(H,this,Rr).call(this,e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(x(pr,this)||C(pr,this,new pn(this)),x(pr,this).show(t,n,this.direction===`ltr`))}function Hr(){var e;let t=document.getSelection();if(!t||t.isCollapsed){if(x(Tr,this)){var n;(n=x(pr,this))==null||n.hide(),C(Tr,this,null),f(H,this,Qr).call(this,{hasSelectedText:!1})}return}let{anchorNode:r}=t;if(r===x(Tr,this))return;let i=f(H,this,Rr).call(this,t).closest(`.textLayer`);if(!i){if(x(Tr,this)){var a;(a=x(pr,this))==null||a.hide(),C(Tr,this,null),f(H,this,Qr).call(this,{hasSelectedText:!1})}return}if((e=x(pr,this))==null||e.hide(),C(Tr,this,r),f(H,this,Qr).call(this,{hasSelectedText:!0}),!(x(Cr,this)!==N.HIGHLIGHT&&x(Cr,this)!==N.NONE)&&(x(Cr,this)===N.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),C(fr,this,this.isShiftKeyDown),!this.isShiftKeyDown)){let e=x(Cr,this)===N.HIGHLIGHT?f(H,this,zr).call(this,i):null;if(e==null||e.toggleDrawing(),x(gr,this)){let t=new AbortController,n=this.combinedSignal(t),r=n=>{n.type===`pointerup`&&n.button!==0||(t.abort(),e==null||e.toggleDrawing(!0),n.type===`pointerup`&&f(H,this,Ur).call(this,`main_toolbar`))};window.addEventListener(`pointerup`,r,{signal:n}),window.addEventListener(`blur`,r,{signal:n})}else e==null||e.toggleDrawing(!0),f(H,this,Ur).call(this,`main_toolbar`)}}function Ur(e=``){x(Cr,this)===N.HIGHLIGHT?this.highlightSelection(e):x(ar,this)&&f(H,this,Vr).call(this)}function Wr(){document.addEventListener(`selectionchange`,f(H,this,Hr).bind(this),{signal:this._signal})}function Gr(){if(x(ur,this))return;C(ur,this,new AbortController);let e=this.combinedSignal(x(ur,this));window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}function Kr(){var e;(e=x(ur,this))==null||e.abort(),C(ur,this,null)}function qr(){if(x(vr,this))return;C(vr,this,new AbortController);let e=this.combinedSignal(x(vr,this));window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}function Jr(){var e;(e=x(vr,this))==null||e.abort(),C(vr,this,null)}function Yr(){if(x(Qn,this))return;C(Qn,this,new AbortController);let e=this.combinedSignal(x(Qn,this));document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}function Xr(){var e;(e=x(Qn,this))==null||e.abort(),C(Qn,this,null)}function Zr(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}function Qr(e){Object.entries(e).some(([e,t])=>x(Ar,this)[e]!==t)&&(this._eventBus.dispatch(`editingstateschanged`,{source:this,details:Object.assign(x(Ar,this),e)}),x(Cr,this)===N.HIGHLIGHT&&e.hasSelectedEditor===!1&&f(H,this,$r).call(this,[[P.HIGHLIGHT_FREE,!0]]))}function $r(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}function ei(){var e=this;return v(function*(){if(!x(hr,e)){C(hr,e,!0);let t=[];for(let n of x(Gn,e).values())t.push(n.enable());yield Promise.all(t);for(let t of x(Wn,e).values())t.enable()}})()}function ti(){if(this.unselectAll(),x(hr,this)){C(hr,this,!1);for(let e of x(Gn,this).values())e.disable();for(let e of x(Wn,this).values())e.disable()}}function ni(e){let t=x(Gn,this).get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}function ri(){let e=null;for(e of x(wr,this));return e}function ii(){if(x(Wn,this).size===0)return!0;if(x(Wn,this).size===1)for(let e of x(Wn,this).values())return e.isEmpty();return!1}function ai(e){for(let e of x(wr,this))e.unselect();x(wr,this).clear();for(let t of e)t.isEmpty()||(x(wr,this).add(t),t.select());f(H,this,Qr).call(this,{hasSelectedEditor:this.hasSelection})}g(Lr,`TRANSLATE_SMALL`,1),g(Lr,`TRANSLATE_BIG`,10);var oi=new WeakMap,si=new WeakMap,ci=new WeakMap,li=new WeakMap,ui=new WeakMap,di=new WeakMap,fi=new WeakMap,pi=new WeakMap,mi=new WeakMap,hi=new WeakMap,gi=new WeakMap,_i=new WeakMap,vi=new WeakSet,yi=class e{constructor(e){S(this,vi),b(this,oi,null),b(this,si,!1),b(this,ci,null),b(this,li,null),b(this,ui,null),b(this,di,null),b(this,fi,!1),b(this,pi,null),b(this,mi,null),b(this,hi,null),b(this,gi,null),b(this,_i,!1),C(mi,this,e),C(_i,this,e._uiManager.useNewAltTextFlow),Si._||(Si._=Object.freeze({added:`pdfjs-editor-new-alt-text-added-button`,"added-label":`pdfjs-editor-new-alt-text-added-button-label`,missing:`pdfjs-editor-new-alt-text-missing-button`,"missing-label":`pdfjs-editor-new-alt-text-missing-button-label`,review:`pdfjs-editor-new-alt-text-to-review-button`,"review-label":`pdfjs-editor-new-alt-text-to-review-button-label`}))}static initialize(t){e._l10n!=null||(e._l10n=t)}render(){var e=this;return v(function*(){let t=C(ci,e,document.createElement(`button`));t.className=`altText`,t.tabIndex=`0`;let n=C(li,e,document.createElement(`span`));t.append(n),x(_i,e)?(t.classList.add(`new`),t.setAttribute(`data-l10n-id`,Si._.missing),n.setAttribute(`data-l10n-id`,Si._[`missing-label`])):(t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button`),n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button-label`));let r=x(mi,e)._uiManager._signal;t.addEventListener(`contextmenu`,Ct,{signal:r}),t.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:r});let i=t=>{t.preventDefault(),x(mi,e)._uiManager.editAltText(x(mi,e)),x(_i,e)&&x(mi,e)._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:bi.call(f(vi,e))}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,n=>{n.target===t&&n.key===`Enter`&&(C(fi,e,!0),i(n))},{signal:r}),yield f(vi,e,xi).call(e),t})()}finish(){x(ci,this)&&(x(ci,this).focus({focusVisible:x(fi,this)}),C(fi,this,!1))}isEmpty(){return x(_i,this)?x(oi,this)===null:!x(oi,this)&&!x(si,this)}hasData(){return x(_i,this)?x(oi,this)!==null||!!x(hi,this):this.isEmpty()}get guessedText(){return x(hi,this)}setGuessedText(t){var n=this;return v(function*(){x(oi,n)===null&&(C(hi,n,t),C(gi,n,yield e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t})),f(vi,n,xi).call(n))})()}toggleAltTextBadge(e=!1){if(!x(_i,this)||x(oi,this)){var t;(t=x(pi,this))==null||t.remove(),C(pi,this,null);return}if(!x(pi,this)){let e=C(pi,this,document.createElement(`div`));e.className=`noAltTextBadge`,x(mi,this).div.append(e)}x(pi,this).classList.toggle(`hidden`,!e)}serialize(e){let t=x(oi,this);return!e&&x(hi,this)===t&&(t=x(gi,this)),{altText:t,decorative:x(si,this),guessedText:x(hi,this),textWithDisclaimer:x(gi,this)}}get data(){return{altText:x(oi,this),decorative:x(si,this)}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(C(hi,this,n),C(gi,this,r)),!(x(oi,this)===e&&x(si,this)===t)&&(i||(C(oi,this,e),C(si,this,t)),f(vi,this,xi).call(this))}toggle(e=!1){x(ci,this)&&(!e&&x(di,this)&&(clearTimeout(x(di,this)),C(di,this,null)),x(ci,this).disabled=!e)}shown(){x(mi,this)._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:bi.call(f(vi,this))}})}destroy(){var e,t;(e=x(ci,this))==null||e.remove(),C(ci,this,null),C(li,this,null),C(ui,this,null),(t=x(pi,this))==null||t.remove(),C(pi,this,null)}};function bi(){return x(oi,this)&&`added`||x(oi,this)===null&&this.guessedText&&`review`||`missing`}function xi(){var e=this;return v(function*(){let t=x(ci,e);if(!t)return;if(x(_i,e)){var n;if(t.classList.toggle(`done`,!!x(oi,e)),t.setAttribute(`data-l10n-id`,Si._[bi.call(f(vi,e))]),(n=x(li,e))==null||n.setAttribute(`data-l10n-id`,Si._[`${bi.call(f(vi,e))}-label`]),!x(oi,e)){var r;(r=x(ui,e))==null||r.remove();return}}else{if(!x(oi,e)&&!x(si,e)){var i;t.classList.remove(`done`),(i=x(ui,e))==null||i.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let a=x(ui,e);if(!a){C(ui,e,a=document.createElement(`span`)),a.className=`tooltip`,a.setAttribute(`role`,`tooltip`),a.id=`alt-text-tooltip-${x(mi,e).id}`;let n=x(mi,e)._uiManager._signal;n.addEventListener(`abort`,()=>{clearTimeout(x(di,e)),C(di,e,null)},{once:!0}),t.addEventListener(`mouseenter`,()=>{C(di,e,setTimeout(()=>{C(di,e,null),x(ui,e).classList.add(`show`),x(mi,e)._reportTelemetry({action:`alt_text_tooltip`})},100))},{signal:n}),t.addEventListener(`mouseleave`,()=>{var t;x(di,e)&&(clearTimeout(x(di,e)),C(di,e,null)),(t=x(ui,e))==null||t.classList.remove(`show`)},{signal:n})}x(si,e)?a.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(a.removeAttribute(`data-l10n-id`),a.textContent=x(oi,e)),a.parentNode||t.append(a);let o=x(mi,e).getElementForAltText();o==null||o.setAttribute(`aria-describedby`,a.id)})()}var Si={_:null};g(yi,`_l10n`,null);var Ci=new WeakMap,wi=new WeakMap,Ti=new WeakMap,Ei=new WeakMap,Di=new WeakMap,Oi=new WeakMap,ki=new WeakMap,Ai=new WeakMap,ji=new WeakMap,Mi=new WeakMap,Ni=new WeakSet,Pi=class{constructor(e){S(this,Ni),b(this,Ci,null),b(this,wi,null),b(this,Ti,!1),b(this,Ei,null),b(this,Di,null),b(this,Oi,null),b(this,ki,null),b(this,Ai,null),b(this,ji,!1),b(this,Mi,null),C(Ei,this,e)}renderForToolbar(){let e=C(wi,this,document.createElement(`button`));return e.className=`comment`,f(Ni,this,Fi).call(this,e,!1)}renderForStandalone(){let e=C(Ci,this,document.createElement(`button`));e.className=`annotationCommentButton`;let t=x(Ei,this).commentButtonPosition;if(t){let{style:n}=e;n.insetInlineEnd=`calc(${100*(x(Ei,this)._uiManager.direction===`ltr`?1-t[0]:t[0])}% - var(--comment-button-dim))`,n.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;let r=x(Ei,this).commentButtonColor;r&&(n.backgroundColor=r)}return f(Ni,this,Fi).call(this,e,!0)}focusButton(){setTimeout(()=>{var e,t;(e=(t=x(Ci,this))==null?x(wi,this):t)==null||e.focus()},0)}onUpdatedColor(){if(!x(Ci,this))return;let e=x(Ei,this).commentButtonColor;e&&(x(Ci,this).style.backgroundColor=e),x(Ei,this)._uiManager.updatePopupColor(x(Ei,this))}get commentButtonWidth(){var e,t;return((e=(t=x(Ci,this))==null?void 0:t.getBoundingClientRect().width)==null?0:e)/x(Ei,this).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(x(Mi,this))return x(Mi,this);if(!x(Ci,this))return null;let{x:e,y:t,height:n}=x(Ci,this).getBoundingClientRect(),{x:r,y:i,width:a,height:o}=x(Ei,this).parent.boundingClientRect;return[(e-r)/a,(t+n-i)/o]}set commentPopupPositionInLayer(e){C(Mi,this,e)}hasDefaultPopupPosition(){return x(Mi,this)===null}removeStandaloneCommentButton(){var e;(e=x(Ci,this))==null||e.remove(),C(Ci,this,null)}removeToolbarCommentButton(){var e;(e=x(wi,this))==null||e.remove(),C(wi,this,null)}setCommentButtonStates({selected:e,hasPopup:t}){x(Ci,this)&&(x(Ci,this).classList.toggle(`selected`,e),x(Ci,this).ariaExpanded=t)}edit(e){let t=this.commentPopupPositionInLayer,n,r;if(t)[n,r]=t;else{[n,r]=x(Ei,this).commentButtonPosition;let{width:e,height:t,x:i,y:a}=x(Ei,this);n=i+n*e,r=a+r*t}let i=x(Ei,this).parent.boundingClientRect,{x:a,y:o,width:s,height:c}=i;x(Ei,this)._uiManager.editComment(x(Ei,this),a+n*s,o+r*c,T(T({},e),{},{parentDimensions:i}))}finish(){x(wi,this)&&(x(wi,this).focus({focusVisible:x(Ti,this)}),C(Ti,this,!1))}isDeleted(){return x(ji,this)||x(ki,this)===``}isEmpty(){return x(ki,this)===null}hasBeenEdited(){return this.isDeleted()||x(ki,this)!==x(Di,this)}serialize(){return this.data}get data(){return{text:x(ki,this),richText:x(Oi,this),date:x(Ai,this),deleted:this.isDeleted()}}set data(e){if(e!==x(ki,this)&&C(Oi,this,null),e===null){C(ki,this,``),C(ji,this,!0);return}C(ki,this,e),C(Ai,this,new Date),C(ji,this,!1)}restoreData({text:e,richText:t,date:n}){C(ki,this,e),C(Oi,this,t),C(Ai,this,n),C(ji,this,!1)}setInitialText(e,t=null){C(Di,this,e),this.data=e,C(Ai,this,null),C(Oi,this,t)}shown(){}destroy(){var e,t;(e=x(wi,this))==null||e.remove(),C(wi,this,null),(t=x(Ci,this))==null||t.remove(),C(Ci,this,null),C(ki,this,``),C(Oi,this,null),C(Ai,this,null),C(Ei,this,null),C(Ti,this,!1),C(ji,this,!1)}};function Fi(e,t){if(!x(Ei,this)._uiManager.hasCommentManager())return null;e.tabIndex=`0`,e.ariaHasPopup=`dialog`,t?(e.ariaControls=`commentPopup`,e.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`)):(e.ariaControlsElements=[x(Ei,this)._uiManager.getCommentDialogElement()],e.setAttribute(`data-l10n-id`,`pdfjs-editor-add-comment-button`));let n=x(Ei,this)._uiManager._signal;if(!(n instanceof AbortSignal)||n.aborted)return e;e.addEventListener(`contextmenu`,Ct,{signal:n}),t&&(e.addEventListener(`focusin`,e=>{x(Ei,this)._focusEventsAllowed=!1,wt(e)},{capture:!0,signal:n}),e.addEventListener(`focusout`,e=>{x(Ei,this)._focusEventsAllowed=!0,wt(e)},{capture:!0,signal:n})),e.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:n});let r=t=>{t.preventDefault(),e===x(wi,this)?this.edit():x(Ei,this).toggleComment(!0)};return e.addEventListener(`click`,r,{capture:!0,signal:n}),e.addEventListener(`keydown`,t=>{t.target===e&&t.key===`Enter`&&(C(Ti,this,!0),r(t))},{signal:n}),e.addEventListener(`pointerenter`,()=>{x(Ei,this).toggleComment(!1,!0)},{signal:n}),e.addEventListener(`pointerleave`,()=>{x(Ei,this).toggleComment(!1,!1)},{signal:n}),e}var Ii=new WeakMap,Li=new WeakMap,Ri=new WeakMap,zi=new WeakMap,Bi=new WeakMap,Vi=new WeakMap,Hi=new WeakMap,Ui=new WeakMap,Wi=new WeakMap,Gi=new WeakMap,Ki=new WeakMap,qi=new WeakMap,Ji=new WeakSet,Yi=class{constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){S(this,Ji),b(this,Ii,void 0),b(this,Li,!1),b(this,Ri,null),b(this,zi,void 0),b(this,Bi,void 0),b(this,Vi,void 0),b(this,Hi,void 0),b(this,Ui,null),b(this,Wi,void 0),b(this,Gi,null),b(this,Ki,void 0),b(this,qi,null),C(Ii,this,e),C(Ri,this,n),C(zi,this,t),C(Bi,this,r),C(Vi,this,i),C(Hi,this,a),C(Ki,this,new AbortController),C(Wi,this,AbortSignal.any([o,x(Ki,this).signal])),e.addEventListener(`touchstart`,f(Ji,this,Xi).bind(this),{passive:!1,signal:x(Wi,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Nt.pixelRatio}destroy(){var e,t;(e=x(Ki,this))==null||e.abort(),C(Ki,this,null),(t=x(Ui,this))==null||t.abort(),C(Ui,this,null)}};ne=Yi;function Xi(e){var t,n;if((t=x(zi,this))!=null&&t.call(this))return;if(e.touches.length===1){if(x(Ui,this))return;let e=C(Ui,this,new AbortController),t=AbortSignal.any([x(Wi,this),e.signal]),n=x(Ii,this),r={capture:!0,signal:t,passive:!1},i=e=>{if(e.pointerType===`touch`){var t;(t=x(Ui,this))==null||t.abort(),C(Ui,this,null)}};n.addEventListener(`pointerdown`,e=>{e.pointerType===`touch`&&(wt(e),i(e))},r),n.addEventListener(`pointerup`,i,r),n.addEventListener(`pointercancel`,i,r);return}if(!x(qi,this)){var r;C(qi,this,new AbortController);let e=AbortSignal.any([x(Wi,this),x(qi,this).signal]),t=x(Ii,this),n={signal:e,capture:!1,passive:!1};t.addEventListener(`touchmove`,f(Ji,this,Zi).bind(this),n);let i=f(Ji,this,Qi).bind(this);t.addEventListener(`touchend`,i,n),t.addEventListener(`touchcancel`,i,n),n.capture=!0,t.addEventListener(`pointerdown`,wt,n),t.addEventListener(`pointermove`,wt,n),t.addEventListener(`pointercancel`,wt,n),t.addEventListener(`pointerup`,wt,n),(r=x(Bi,this))==null||r.call(this)}if(wt(e),e.touches.length!==2||(n=x(Ri,this))!=null&&n.call(this)){C(Gi,this,null);return}let[i,a]=e.touches;i.identifier>a.identifier&&([i,a]=[a,i]),C(Gi,this,{touch0X:i.screenX,touch0Y:i.screenY,touch1X:a.screenX,touch1Y:a.screenY})}function Zi(e){var t;if(!x(Gi,this)||e.touches.length!==2)return;wt(e);let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=x(Gi,this),{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!x(Li,this)&&Math.abs(v-_)<=ne.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,!x(Li,this)){C(Li,this,!0);return}let y=[(i+o)/2,(a+s)/2];(t=x(Vi,this))==null||t.call(this,y,v,_)}function Qi(e){if(!(e.touches.length>=2)){if(x(qi,this)){var t;x(qi,this).abort(),C(qi,this,null),(t=x(Hi,this))==null||t.call(this)}x(Gi,this)&&(wt(e),C(Gi,this,null),C(Li,this,!1))}}var $i=new WeakMap,ea=new WeakMap,ta=new WeakMap,U=new WeakMap,na=new WeakMap,ra=new WeakMap,ia=new WeakMap,aa=new WeakMap,oa=new WeakMap,sa=new WeakMap,ca=new WeakMap,la=new WeakMap,ua=new WeakMap,da=new WeakMap,fa=new WeakMap,pa=new WeakMap,ma=new WeakMap,ha=new WeakMap,ga=new WeakMap,_a=new WeakMap,va=new WeakMap,ya=new WeakMap,ba=new WeakMap,xa=new WeakMap,Sa=new WeakMap,Ca=new WeakMap,W=new WeakSet,G=class e{static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=Lr.TRANSLATE_SMALL,r=Lr.TRANSLATE_BIG;return R(this,`_resizerKeyboardManager`,new Ln([[[`ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(t){S(this,W),b(this,$i,null),b(this,ea,null),b(this,ta,null),b(this,U,null),b(this,na,null),b(this,ra,!1),b(this,ia,null),b(this,aa,``),b(this,oa,null),b(this,sa,null),b(this,ca,null),b(this,la,null),b(this,ua,null),b(this,da,``),b(this,fa,!1),b(this,pa,null),b(this,ma,!1),b(this,ha,!1),b(this,ga,!1),b(this,_a,null),b(this,va,0),b(this,ya,0),b(this,ba,null),b(this,xa,null),g(this,`isSelected`,!1),g(this,`_isCopy`,!1),g(this,`_editToolbar`,null),g(this,`_initialOptions`,Object.create(null)),g(this,`_initialData`,null),g(this,`_isVisible`,!0),g(this,`_uiManager`,null),g(this,`_focusEventsAllowed`,!0),b(this,Sa,!1),b(this,Ca,e._zIndex++),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{rotation:n,rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,i],this.pageTranslation=[a,o];let[s,c]=this.parentDimensions;this.x=t.x/s,this.y=t.y/c,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return R(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new Ua({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n!=null||(e._l10n=t),e._l10nAlert!=null||(e._l10nAlert=Object.freeze({highlight:`pdfjs-editor-highlight-added-alert`,freetext:`pdfjs-editor-freetext-added-alert`,ink:`pdfjs-editor-ink-added-alert`,stamp:`pdfjs-editor-stamp-added-alert`,signature:`pdfjs-editor-signature-added-alert`})),e._l10nResizer!=null||(e._l10nResizer=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`})),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){L(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return x(Sa,this)}set _isDraggable(e){var t;C(Sa,this,e),(t=this.div)==null||t.classList.toggle(`draggable`,e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=x(Ca,this)}setParent(e){if(e!==null)this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions;else{var t;f(W,this,Ha).call(this),(t=x(la,this))==null||t.remove(),C(la,this,null)}this.parent=e}focusin(e){this._focusEventsAllowed&&(x(fa,this)?C(fa,this,!1):this.parent.setSelected(this))}focusout(e){var t;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let n=e.relatedTarget;n!=null&&n.closest(`#${this.id}`)||(e.preventDefault(),(t=this.parent)!=null&&t.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}let[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r),this._onTranslated()}translate(e,t){f(W,this,wa).call(this,this.parentDimensions,e,t)}translateInPage(e,t){x(pa,this)||C(pa,this,[this.x,this.y,this.width,this.height]),f(W,this,wa).call(this,this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){x(pa,this)||C(pa,this,[this.x,this.y,this.width,this.height]);let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!x(pa,this)&&(x(pa,this)[0]!==this.x||x(pa,this)[1]!==this.y)}get _hasBeenResized(){return!!x(pa,this)&&(x(pa,this)[2]!==this.width||x(pa,this)[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=V(i,0,n-o),a=V(a,0,r-s);break;case 90:i=V(i,0,n-s),a=V(a,o,r);break;case 180:i=V(i,o,n),a=V(a,s,r);break;case 270:i=V(i,s,n),a=V(a,0,r-o);break}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,n){return Ta.call(e,t,n,this.parentRotation)}pageTranslationToScreen(t,n){return Ta.call(e,t,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(){let{div:{style:e},width:t,height:n}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*n).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=x(ta,this))==null||e.finish()}get toolbarButtons(){return null}addEditToolbar(){var e=this;return v(function*(){if(e._editToolbar||x(ha,e))return e._editToolbar;e._editToolbar=new tn(e),e.div.append(e._editToolbar.render());let{toolbarButtons:t}=e;if(t)for(let[n,r]of t)yield e._editToolbar.addButton(n,r);return e.hasComment||e._editToolbar.addButton(`comment`,e.addCommentButton()),e._editToolbar.addButton(`delete`),e._editToolbar})()}addCommentButtonInToolbar(){var e;(e=this._editToolbar)==null||e.addButtonBefore(`comment`,this.addCommentButton(),`.deleteButton`)}removeCommentButtonFromToolbar(){var e;(e=this._editToolbar)==null||e.removeButton(`comment`)}removeEditToolbar(){var e,t;(e=this._editToolbar)==null||e.remove(),this._editToolbar=null,(t=x(ta,this))==null||t.destroy()}addContainer(e){var t;let n=(t=this._editToolbar)==null?void 0:t.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return x(ta,this)||(yi.initialize(e._l10n),C(ta,this,new yi(this)),x($i,this)&&(x(ta,this).data=x($i,this),C($i,this,null))),x(ta,this)}get altTextData(){var e;return(e=x(ta,this))==null?void 0:e.data}set altTextData(e){x(ta,this)&&(x(ta,this).data=e)}get guessedAltText(){var e;return(e=x(ta,this))==null?void 0:e.guessedText}setGuessedAltText(e){var t=this;return v(function*(){var n;yield(n=x(ta,t))==null?void 0:n.setGuessedText(e)})()}serializeAltText(e){var t;return(t=x(ta,this))==null?void 0:t.serialize(e)}hasAltText(){return!!x(ta,this)&&!x(ta,this).isEmpty()}hasAltTextData(){var e,t;return(e=(t=x(ta,this))==null?void 0:t.hasData())!=null&&e}focusCommentButton(){var e;(e=x(U,this))==null||e.focusButton()}addCommentButton(){return this.canAddComment?x(U,this)||C(U,this,new Pi(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(x(na,this)){this._uiManager.isEditingMode()&&x(na,this).classList.remove(`hidden`);return}this.hasComment&&(C(na,this,x(U,this).renderForStandalone()),this.div.append(x(na,this)))}}removeStandaloneCommentButton(){x(U,this).removeStandaloneCommentButton(),C(na,this,null)}hideStandaloneCommentButton(){var e;(e=x(na,this))==null||e.classList.add(`hidden`)}get comment(){var e;if(!x(U,this))return null;let{data:{richText:t,text:n,date:r,deleted:i}}=x(U,this);return{text:n,richText:t,date:r,deleted:i,color:this.getNonHCMColor(),opacity:(e=this.opacity)==null?1:e}}set comment(e){x(U,this)||C(U,this,new Pi(this)),typeof e==`object`&&e?x(U,this).restoreData(e):x(U,this).data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:t,richText:n}){if(!t||(x(U,this)||C(U,this,new Pi(this)),x(U,this).setInitialText(e,n),!this.annotationElementId))return;let r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){var e;return(e=x(U,this))==null?void 0:e.hasBeenEdited()}get hasDeletedComment(){var e;return(e=x(U,this))==null?void 0:e.isDeleted()}get hasComment(){return!!x(U,this)&&!x(U,this).isEmpty()&&!x(U,this).isDeleted()}editComment(e){var t=this;return v(function*(){x(U,t)||C(U,t,new Pi(t)),x(U,t).edit(e)})()}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){x(U,this).setSelectedButton(e)}addComment(e){if(this.hasEditedComment){let[,,,t]=e.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,i=r+n+1,a=t-100,o=i+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[i,a,o,t]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){x(U,this).data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var e;let t=this.div=document.createElement(`div`);t.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),t.className=this.name,t.setAttribute(`id`,this.id),t.tabIndex=x(ra,this)?-1:0,t.setAttribute(`role`,`application`),this.defaultL10nId&&t.setAttribute(`data-l10n-id`,this.defaultL10nId),this._isVisible||t.classList.add(`hidden`),this.setInForeground(),f(W,this,La).call(this);let[n,r]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*r/n).toFixed(2)}%`,t.style.maxHeight=`${(100*n/r).toFixed(2)}%`);let[i,a]=this.getInitialTranslation();return this.translate(i,a),vn(this,t,[`keydown`,`pointerdown`,`dblclick`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(x(xa,this)||C(xa,this,new Yi({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:f(W,this,Ma).bind(this),onPinching:f(W,this,Na).bind(this),onPinchEnd:f(W,this,Pa).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(e=this._uiManager._editorUndoBar)==null||e.hide(),t}pointerdown(e){let{isMac:t}=z.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(C(fa,this,!0),this._isDraggable){f(W,this,Ia).call(this,e);return}f(W,this,Fa).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){x(_a,this)&&clearTimeout(x(_a,this)),C(_a,this,setTimeout(()=>{var e;C(_a,this,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&e._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var e;(e=x(U,this))==null||e.onUpdatedColor()}getData(){let{comment:{text:e,color:t,date:n,opacity:r,deleted:i,richText:a},uid:o,pageIndex:s,creationDate:c,modificationDate:l}=this;return{id:o,pageIndex:s,rect:this.getPDFRect(),richText:a,contentsObj:{str:e},creationDate:c,modificationDate:n||l,popupRef:!i,color:t,opacity:r}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),C(ha,this,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),C(ha,this,!1),!0):!1}isInEditMode(){return x(ha,this)}shouldGetKeyboardEvents(){return x(ga,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t<a&&r>0&&e<i&&n>0}rebuild(){f(W,this,La).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||``}}serialize(e=!1,t=null){var n;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((n=this._initialData)==null?void 0:n.popupRef)||``}}static deserialize(e,t,n){var r=this;return v(function*(){let i=new r.prototype.constructor({parent:t,id:n.getId(),uiManager:n,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});i.rotation=e.rotation,C($i,i,e.accessibilityData),i._isCopy=e.isCopy||!1;let[a,o]=i.pageDimensions,[s,c,l,u]=i.getRectInCurrentCoords(e.rect,o);return i.x=s/a,i.y=c/o,i.width=l/a,i.height=u/o,i})()}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,t,n;if((e=x(ua,this))==null||e.abort(),C(ua,this,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),x(_a,this)&&(clearTimeout(x(_a,this)),C(_a,this,null)),f(W,this,Ha).call(this),this.removeEditToolbar(),x(ba,this)){for(let e of x(ba,this).values())clearTimeout(e);C(ba,this,null)}this.parent=null,(t=x(xa,this))==null||t.destroy(),C(xa,this,null),(n=x(la,this))==null||n.remove(),C(la,this,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(f(W,this,Da).call(this),x(oa,this).classList.remove(`hidden`))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction===`ltr`?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,n]}=this,[r,i,a,o]=this.getPDFRect();return[e._round(r+(a-r)*t),e._round(i+(o-i)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return x(U,this).commentPopupPositionInLayer}set commentPopupPosition(e){x(U,this).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return x(U,this).hasDefaultPopupPosition()}get commentButtonWidth(){return x(U,this).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){var t;(t=x(U,this))==null||t.setCommentButtonStates(e)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),C(ca,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});let n=x(oa,this).children;if(!x(ea,this)){C(ea,this,Array.from(n));let t=f(W,this,Ra).bind(this),r=f(W,this,za).bind(this),i=this._uiManager._signal;for(let n of x(ea,this)){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,f(W,this,Ba).bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=x(ea,this)[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(x(ea,this).length/4);if(a!==i){if(a<i)for(let e=0;e<i-a;e++)x(oa,this).append(x(oa,this).firstElementChild);else if(a>i)for(let e=0;e<a-i;e++)x(oa,this).firstElementChild.before(x(oa,this).lastElementChild);let t=0;for(let r of n){let n=x(ea,this)[t++].getAttribute(`data-resizer-name`);r.setAttribute(`data-l10n-id`,e._l10nResizer[n])}}f(W,this,Va).call(this,0),C(ga,this,!0),x(oa,this).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(e,t){x(ga,this)&&f(W,this,ja).call(this,x(da,this),{deltaX:e,deltaY:t,fromKeyboard:!0})}_stopResizingWithKeyboard(){f(W,this,Ha).call(this),this.div.focus()}select(){var e,t,n;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(e=this.div)==null||e.classList.add(`selectedEditor`),!this._editToolbar){this.addEditToolbar().then(()=>{var e;if((e=this.div)!=null&&e.classList.contains(`selectedEditor`)){var t;(t=this._editToolbar)==null||t.show()}});return}(t=this._editToolbar)==null||t.show(),(n=x(ta,this))==null||n.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var e;return(e=this.div)==null?void 0:e.focus({preventScroll:!0})},0)}unselect(){var e,t,n,r,i;this.isSelected&&(this.isSelected=!1,(e=x(oa,this))==null||e.classList.add(`hidden`),(t=this.div)==null||t.classList.remove(`selectedEditor`),(n=this.div)!=null&&n.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(r=this._editToolbar)==null||r.hide(),(i=x(ta,this))==null||i.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!==`BUTTON`&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return x(ma,this)}set isEditing(e){C(ma,this,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){x(ba,this)||C(ba,this,new Map);let{action:n}=t,r=x(ba,this).get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),x(ba,this).delete(n),x(ba,this).size===0&&C(ba,this,null)},e._telemetryTimeout),x(ba,this).set(n,r);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),C(ra,this,!1)}disable(){this.div&&(this.div.tabIndex=-1),C(ra,this,!0)}updateFakeAnnotationElement(e){if(!x(la,this)&&!this.deleted){C(la,this,e.addFakeAnnotation(this));return}if(this.deleted){x(la,this).remove(),C(la,this,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&x(la,this).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstElementChild:t}=e.container;(t==null?void 0:t.nodeName)===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}};M=G;function wa([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}function Ta(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}function Ea(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}function Da(){if(x(oa,this))return;C(oa,this,document.createElement(`div`)),x(oa,this).classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);x(oa,this).append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,f(W,this,Oa).bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,Ct,{signal:t}),e.tabIndex=-1}this.div.prepend(x(oa,this))}function Oa(e,t){var n;t.preventDefault();let{isMac:r}=z.platform;if(t.button!==0||t.ctrlKey&&r)return;(n=x(ta,this))==null||n.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,C(sa,this,[t.screenX,t.screenY]);let a=new AbortController,o=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,f(W,this,ja).bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener(`touchmove`,wt,{passive:!1,signal:o}),window.addEventListener(`contextmenu`,Ct,{signal:o}),C(ca,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});let s=this.parent.div.style.cursor,c=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let l=()=>{var e;a.abort(),this.parent.togglePointerEvents(!0),(e=x(ta,this))==null||e.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=s,this.div.style.cursor=c,f(W,this,Aa).call(this)};window.addEventListener(`pointerup`,l,{signal:o}),window.addEventListener(`blur`,l,{signal:o})}function ka(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()}function Aa(){if(!x(ca,this))return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=x(ca,this);C(ca,this,null);let i=this.x,a=this.y,o=this.width,s=this.height;i===e&&a===t&&o===n&&s===r||this.addCommands({cmd:f(W,this,ka).bind(this,i,a,o,s),undo:f(W,this,ka).bind(this,e,t,n,r),mustExec:!0})}function ja(e,t){let[n,r]=this.parentDimensions,i=this.x,a=this.y,o=this.width,s=this.height,c=M.MIN_SIZE/n,l=M.MIN_SIZE/r,u=f(W,this,Ea).call(this,this.rotation),d=(e,t)=>[u[0]*e+u[2]*t,u[1]*e+u[3]*t],p=f(W,this,Ea).call(this,360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(e){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2];break}let y=h(o,s),b=g(o,s),S=d(...b),w=M._round(i+S[0]),T=M._round(a+S[1]),E=1,D=1,O,k;if(t.fromKeyboard)({deltaX:O,deltaY:k}=t);else{let{screenX:e,screenY:n}=t,[r,i]=x(sa,this);[O,k]=this.screenToPageTranslation(e-r,n-i),x(sa,this)[0]=e,x(sa,this)[1]=n}if([O,k]=m(O/n,k/r),_){let e=Math.hypot(o,s);E=D=Math.max(Math.min(Math.hypot(b[0]-y[0]-O,b[1]-y[1]-k)/e,1/o,1/s),c/o,l/s)}else v?E=V(Math.abs(b[0]-y[0]-O),c,1)/o:D=V(Math.abs(b[1]-y[1]-k),l,1)/s;let A=M._round(o*E),ee=M._round(s*D);S=d(...g(A,ee));let j=w-S[0],te=T-S[1];x(pa,this)||C(pa,this,[this.x,this.y,this.width,this.height]),this.width=A,this.height=ee,this.x=j,this.y=te,this.setDims(),this.fixAndSetPosition(),this._onResizing()}function Ma(){var e;C(ca,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=x(ta,this))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)}function Na(e,t,n){let r=.7,i=n/t*r+1-r;if(i===1)return;let a=f(W,this,Ea).call(this,this.rotation),o=(e,t)=>[a[0]*e+a[2]*t,a[1]*e+a[3]*t],[s,c]=this.parentDimensions,l=this.x,u=this.y,d=this.width,p=this.height,m=M.MIN_SIZE/s,h=M.MIN_SIZE/c;i=Math.max(Math.min(i,1/d,1/p),m/d,h/p);let g=M._round(d*i),_=M._round(p*i);if(g===d&&_===p)return;x(pa,this)||C(pa,this,[l,u,d,p]);let v=o(d/2,p/2),y=M._round(l+v[0]),b=M._round(u+v[1]),S=o(g/2,_/2);this.x=y-S[0],this.y=b-S[1],this.width=g,this.height=_,this.setDims(),this.fixAndSetPosition(),this._onResizing()}function Pa(){var e;(e=x(ta,this))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),f(W,this,Aa).call(this)}function Fa(e){let{isMac:t}=z.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}function Ia(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),C(ia,this,null),C(fa,this,!1),this._uiManager.endDragSession()||f(W,this,Fa).call(this,e),n&&this._onStopDragging()};t&&(C(va,this,e.clientX),C(ya,this,e.clientY),C(ia,this,e.pointerId),C(aa,this,e.pointerType),window.addEventListener(`pointermove`,e=>{n||(n=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==x(ia,this)){wt(e);return}let[a,o]=this.screenToPageTranslation(t-x(va,this),r-x(ya,this));C(va,this,t),C(ya,this,r),this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,wt,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===x(aa,this)&&(x(xa,this)||e.isPrimary)&&o(e),wt(e)},a));let s=e=>{if(!x(ia,this)||x(ia,this)===e.pointerId){o(e);return}wt(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}function La(){if(x(ua,this)||!this.div)return;C(ua,this,new AbortController);let e=this._uiManager.combinedSignal(x(ua,this));this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}function Ra(e){M._resizerKeyboardManager.exec(this,e)}function za(e){var t;x(ga,this)&&((t=e.relatedTarget)==null?void 0:t.parentNode)!==x(oa,this)&&f(W,this,Ha).call(this)}function Ba(e){C(da,this,x(ga,this)?e:``)}function Va(e){if(x(ea,this))for(let t of x(ea,this))t.tabIndex=e}function Ha(){C(ga,this,!1),f(W,this,Va).call(this,-1),f(W,this,Aa).call(this)}g(G,`_l10n`,null),g(G,`_l10nAlert`,null),g(G,`_l10nResizer`,null),g(G,`_borderLineWidth`,-1),g(G,`_colorManager`,new Bn),g(G,`_zIndex`,1),g(G,`_telemetryTimeout`,1e3);var Ua=class extends G{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},Wa=3285377520,Ga=4294901760,Ka=65535,qa=class{constructor(e){this.h1=e?e&4294967295:Wa,this.h2=e?e&4294967295:Wa}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&Ga|o*f&Ka,o=o<<15|o>>>17,o=o*d&Ga|o*p&Ka,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&Ga|s*f&Ka,s=s<<15|s>>>17,s=s*d&Ga|s*p&Ka,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&Ga|o*f&Ka,o=o<<15|o>>>17,o=o*d&Ga|o*p&Ka,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&Ga|e*36045&Ka,t=t*4283543511&Ga|((t<<16|e>>>16)*2950163797&Ga)>>>16,e^=t>>>1,e=e*444984403&Ga|e*60499&Ka,t=t*3301882366&Ga|((t<<16|e>>>16)*3120437893&Ga)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},Ja=Object.freeze({map:null,hash:``,transfer:void 0}),Ya=new WeakMap,Xa=new WeakMap,Za=new WeakMap,Qa=new WeakMap,$a=new WeakSet;fe=Symbol.iterator;var eo=class{constructor(){S(this,$a),b(this,Ya,!1),b(this,Xa,null),b(this,Za,null),b(this,Qa,new Map),g(this,`onSetModified`,null),g(this,`onResetModified`,null),g(this,`onAnnotationEditor`,null)}getValue(e,t){let n=x(Qa,this).get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return x(Qa,this).get(e)}remove(e){var t;let n=x(Qa,this).get(e);n!==void 0&&(n instanceof G&&x(Za,this).delete(n.annotationElementId),x(Qa,this).delete(e),x(Qa,this).size===0&&this.resetModified(),!x(Qa,this).values().some(e=>e instanceof G)&&((t=this.onAnnotationEditor)==null||t.call(this,null)))}setValue(e,t){let n=x(Qa,this).get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,x(Qa,this).set(e,t);if(r&&f($a,this,to).call(this),t instanceof G){var i;(x(Za,this)||C(Za,this,new Map)).set(t.annotationElementId,t),(i=this.onAnnotationEditor)==null||i.call(this,t.constructor._type)}}has(e){return x(Qa,this).has(e)}get size(){return x(Qa,this).size}resetModified(){if(x(Ya,this)){var e;C(Ya,this,!1),(e=this.onResetModified)==null||e.call(this)}}get print(){return new ro(this)}get serializable(){if(x(Qa,this).size===0)return Ja;let e=new Map,t=new qa,n=[],r=Object.create(null),i=!1;for(let[n,a]of x(Qa,this)){let o=a instanceof G?a.serialize(!1,r):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||(i=!!o.bitmap))}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:Ja}get editorStats(){let e=null,t=new Map,n=0,r=0;for(let o of x(Qa,this).values()){var i;if(!(o instanceof G)){o.popup&&(o.popup.deleted?r+=1:n+=1);continue}o.isCommentDeleted?r+=1:o.hasEditedComment&&(n+=1);let s=o.telemetryFinalData;if(!s)continue;let{type:c}=s;t.getOrInsertComputed(c,()=>Object.getPrototypeOf(o).constructor),e||(e=Object.create(null));let l=(i=e)[c]||(i[c]=new Map);for(let[e,t]of Object.entries(s)){var a;if(e===`type`)continue;let n=l.getOrInsertComputed(e,st);n.set(t,((a=n.get(t))==null?0:a)+1)}}if((r>0||n>0)&&(e||(e=Object.create(null)),e.comments={deleted:r,edited:n}),!e)return null;for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){C(Xa,this,null)}updateEditor(e,t){var n;let r=(n=x(Za,this))==null?void 0:n.get(e);return r?(r.updateFromAnnotationLayer(t),!0):!1}getEditor(e){var t;return((t=x(Za,this))==null?void 0:t.get(e))||null}get modifiedIds(){if(x(Xa,this))return x(Xa,this);let e=[];if(x(Za,this))for(let t of x(Za,this).values())t.serialize()&&e.push(t.annotationElementId);let t=``;if(e.length){let n=new qa;n.update(e.join(`,`)),t=n.hexdigest()}return C(Xa,this,{ids:new Set(e),hash:t})}[fe](){return x(Qa,this).entries()}};function to(){if(!x(Ya,this)){var e;C(Ya,this,!0),(e=this.onSetModified)==null||e.call(this)}}var no=new WeakMap,ro=class extends eo{constructor(e){super(),b(this,no,Ja);let{serializable:t}=e;if(t===Ja)return;let{map:n,hash:r,transfer:i}=t,a=structuredClone(n,i?{transfer:i}:null);C(no,this,{map:a,hash:r,transfer:[]})}get print(){L(`Should not call PrintAnnotationStorage.print`)}get serializable(){return x(no,this)}get modifiedIds(){return R(this,`modifiedIds`,{ids:new Set,hash:``})}},io=`__forcedDependency`,{floor:ao,ceil:oo}=Math;function so(e,t,n,r,i,a){e[t*4+0]=Math.min(e[t*4+0],n),e[t*4+1]=Math.min(e[t*4+1],r),e[t*4+2]=Math.max(e[t*4+2],i),e[t*4+3]=Math.max(e[t*4+3],a)}function co(e,t,n,r,i){let a;e?(e<0&&(a=i[0],i[0]=i[2],i[2]=a),i[0]*=e,i[2]*=e,t<0&&(a=i[1],i[1]=i[3],i[3]=a),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=n,i[1]+=r,i[2]+=n,i[3]+=r}var lo=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0],uo=new WeakMap,fo=new WeakMap,po=class{constructor(e,t){b(this,uo,void 0),b(this,fo,void 0),C(uo,this,e),C(fo,this,t)}get length(){return x(uo,this).length}isEmpty(e){return x(uo,this)[e]===lo}minX(e){return x(fo,this)[e*4+0]/256}minY(e){return x(fo,this)[e*4+1]/256}maxX(e){return(x(fo,this)[e*4+2]+1)/256}maxY(e){return(x(fo,this)[e*4+3]+1)/256}},mo=(e,t)=>e==null?void 0:e.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1})),ho=new WeakMap,K=new WeakMap,go=new WeakMap,_o=new WeakMap,vo=new WeakMap,yo=new WeakMap,bo=new WeakMap,xo=new WeakSet,So=class{constructor(e,t){S(this,xo),b(this,ho,[[1,0,0,1,0,0]]),b(this,K,[-1/0,-1/0,1/0,1/0]),b(this,go,new Float64Array(_e)),g(this,`_pendingBBoxIdx`,-1),b(this,_o,void 0),b(this,vo,void 0),b(this,yo,void 0),b(this,bo,void 0),g(this,`_savesStack`,[]),g(this,`_markedContentStack`,[]),C(_o,this,e.width),C(vo,this,e.height),f(xo,this,Co).call(this,t)}growOperationsCount(e){e>=x(bo,this).length&&f(xo,this,Co).call(this,e,x(bo,this))}get clipBox(){return x(K,this)}save(e){return C(K,this,{__proto__:x(K,this)}),this._savesStack.push(e),this}restore(e,t){let n=Object.getPrototypeOf(x(K,this));if(n===null)return this;C(K,this,n);let r=this._savesStack.pop();return r!==void 0&&(t==null||t(r,e),x(bo,this)[e]=x(bo,this)[r]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,t){let n=this._savesStack.pop();return n!==void 0&&(t==null||t(n,e),x(bo,this)[e]=x(bo,this)[n]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){let n=this._markedContentStack.pop();return n!==void 0&&(t==null||t(n,e),x(bo,this)[e]=x(bo,this)[n]),this}pushBaseTransform(e){return x(ho,this).push(B.multiplyByDOMMatrix(x(ho,this).at(-1),e.getTransform())),this}popBaseTransform(){return x(ho,this).length>1&&x(ho,this).pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,x(go,this).set(_e,0)),this}recordClipBox(e,t,n,r,i,a){let o=B.multiplyByDOMMatrix(x(ho,this).at(-1),t.getTransform()),s=_e.slice();B.axialAlignedBoundingBox([n,i,r,a],o,s);let c=B.intersect(x(K,this),s);return c?(x(K,this)[0]=c[0],x(K,this)[1]=c[1],x(K,this)[2]=c[2],x(K,this)[3]=c[3]):(x(K,this)[0]=x(K,this)[1]=1/0,x(K,this)[2]=x(K,this)[3]=-1/0),this}recordBBox(e,t,n,r,i,a){let o=x(K,this);if(o[0]===1/0)return this;let s=B.multiplyByDOMMatrix(x(ho,this).at(-1),t.getTransform());if(o[0]===-1/0)return B.axialAlignedBoundingBox([n,i,r,a],s,x(go,this)),this;let c=_e.slice();return B.axialAlignedBoundingBox([n,i,r,a],s,c),x(go,this)[0]=V(c[0],o[0],x(go,this)[0]),x(go,this)[1]=V(c[1],o[1],x(go,this)[1]),x(go,this)[2]=V(c[2],x(go,this)[2],o[2]),x(go,this)[3]=V(c[3],x(go,this)[3],o[3]),this}recordFullPageBBox(e){return x(go,this)[0]=Math.max(0,x(K,this)[0]),x(go,this)[1]=Math.max(0,x(K,this)[1]),x(go,this)[2]=Math.min(x(_o,this),x(K,this)[2]),x(go,this)[3]=Math.min(x(vo,this),x(K,this)[3]),this}recordOperation(e,t=!1,n){if(this._pendingBBoxIdx!==e)return this;let r=ao(x(go,this)[0]*256/x(_o,this)),i=ao(x(go,this)[1]*256/x(vo,this)),a=oo(x(go,this)[2]*256/x(_o,this)),o=oo(x(go,this)[3]*256/x(vo,this));if(so(x(yo,this),e,r,i,a,o),n)for(let t of n)for(let n of t)n!==e&&so(x(yo,this),n,r,i,a,o);return t||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,x(K,this)[0]=Math.max(x(K,this)[0],x(go,this)[0]),x(K,this)[1]=Math.max(x(K,this)[1],x(go,this)[1]),x(K,this)[2]=Math.min(x(K,this)[2],x(go,this)[2]),x(K,this)[3]=Math.min(x(K,this)[3],x(go,this)[3])),this}take(){return new po(x(bo,this),x(yo,this))}takeDebugMetadata(){throw Error(`Unreachable`)}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}};function Co(e,t){let n=new ArrayBuffer(e*4);C(yo,this,new Uint8ClampedArray(n)),C(bo,this,new Uint32Array(n)),t&&t.length>0?(x(bo,this).set(t),x(bo,this).fill(lo,t.length)):x(bo,this).fill(lo)}var wo=new WeakMap,To=new WeakMap,Eo=new WeakMap,Do=new WeakMap,Oo=new WeakMap,ko=new WeakMap,Ao=new WeakMap,jo=new WeakMap,Mo=class{constructor(e,t=!1){b(this,wo,{__proto__:null}),b(this,To,{__proto__:null,transform:[],moveText:[],sameLineText:[],[io]:[]}),b(this,Eo,new Map),b(this,Do,new Set),b(this,Oo,new Map),b(this,ko,void 0),b(this,Ao,void 0),b(this,jo,void 0),C(jo,this,e),t&&(C(ko,this,new Map),C(Ao,this,(e,t)=>{mo(x(ko,this),t).dependencies.add(e)}))}get clipBox(){return x(jo,this).clipBox}growOperationsCount(e){x(jo,this).growOperationsCount(e)}save(e){return C(wo,this,{__proto__:x(wo,this)}),C(To,this,{__proto__:x(To,this),transform:{__proto__:x(To,this).transform},moveText:{__proto__:x(To,this).moveText},sameLineText:{__proto__:x(To,this).sameLineText},[io]:{__proto__:x(To,this)[io]}}),x(jo,this).save(e),this}restore(e){x(jo,this).restore(e,x(Ao,this));let t=Object.getPrototypeOf(x(wo,this));return t===null?this:(C(wo,this,t),C(To,this,Object.getPrototypeOf(x(To,this))),this)}recordOpenMarker(e){return x(jo,this).recordOpenMarker(e,x(Ao,this)),this}getOpenMarker(){return x(jo,this).getOpenMarker()}recordCloseMarker(e){return x(jo,this).recordCloseMarker(e,x(Ao,this)),this}beginMarkedContent(e){return x(jo,this).beginMarkedContent(e),this}endMarkedContent(e){return x(jo,this).endMarkedContent(e,x(Ao,this)),this}pushBaseTransform(e){return x(jo,this).pushBaseTransform(e),this}popBaseTransform(){return x(jo,this).popBaseTransform(),this}recordSimpleData(e,t){return x(wo,this)[e]=t,this}recordIncrementalData(e,t){return x(To,this)[e].push(t),this}resetIncrementalData(e,t){return x(To,this)[e].length=0,this}recordNamedData(e,t){return x(Eo,this).set(e,t),this}recordSimpleDataFromNamed(e,t,n){var r;x(wo,this)[e]=(r=x(Eo,this).get(t))==null?n:r}recordFutureForcedDependency(e,t){return this.recordIncrementalData(io,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(let t of e)t in x(wo,this)&&this.recordFutureForcedDependency(t,x(wo,this)[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let e of x(Do,this))this.recordFutureForcedDependency(io,e);return this}resetBBox(e){return x(jo,this).resetBBox(e),this}recordClipBox(e,t,n,r,i,a){return x(jo,this).recordClipBox(e,t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return x(jo,this).recordBBox(e,t,n,r,i,a),this}recordCharacterBBox(e,t,n,r=1,i=0,a=0,o){let s=n.bbox,c,l;if(s&&(c=s[2]!==s[0]&&s[3]!==s[1]&&x(Oo,this).get(n),c!==!1&&(l=[0,0,0,0],B.axialAlignedBoundingBox(s,n.fontMatrix,l),(r!==1||i!==0||a!==0)&&co(r,-r,i,a,l),c)))return this.recordBBox(e,t,l[0],l[2],l[1],l[3]);if(!o)return this.recordFullPageBBox(e);let u=o();return s&&l&&c===void 0&&(c=l[0]<=i-u.actualBoundingBoxLeft&&l[2]>=i+u.actualBoundingBoxRight&&l[1]<=a-u.actualBoundingBoxAscent&&l[3]>=a+u.actualBoundingBoxDescent,x(Oo,this).set(n,c),c)?this.recordBBox(e,t,l[0],l[2],l[1],l[3]):this.recordBBox(e,t,i-u.actualBoundingBoxLeft,i+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return x(jo,this).recordFullPageBBox(e),this}getSimpleIndex(e){return x(wo,this)[e]}recordDependencies(e,t){let n=x(Do,this),r=x(wo,this),i=x(To,this);for(let e of t)e in x(wo,this)?n.add(r[e]):e in i&&i[e].forEach(n.add,n);return this}recordNamedDependency(e,t){return x(Eo,this).has(t)&&x(Do,this).add(x(Eo,this).get(t)),this}recordOperation(e,t=!1){if(this.recordDependencies(e,[io]),x(ko,this)){let t=mo(x(ko,this),e),{dependencies:n}=t;x(Do,this).forEach(n.add,n),x(jo,this)._savesStack.forEach(n.add,n),x(jo,this)._markedContentStack.forEach(n.add,n),n.delete(e),t.isRenderingOperation=!0}let n=!t&&e===x(jo,this)._pendingBBoxIdx;return x(jo,this).recordOperation(e,t,[x(Do,this),x(jo,this)._savesStack,x(jo,this)._markedContentStack]),n&&x(Do,this).clear(),this}recordShowTextOperation(e,t=!1){let n=Array.from(x(Do,this));this.recordOperation(e,t),this.recordIncrementalData(`sameLineText`,e);for(let e of n)this.recordIncrementalData(`sameLineText`,e);return this}bboxToClipBoxDropOperation(e,t=!1){let n=!t&&e===x(jo,this)._pendingBBoxIdx;return x(jo,this).bboxToClipBoxDropOperation(e),n&&x(Do,this).clear(),this}take(){return x(Oo,this).clear(),x(jo,this).take()}takeDebugMetadata(){return x(ko,this)}},No=new WeakMap,Po=new WeakMap,Fo=new WeakMap,Io=new WeakMap,Lo=new WeakMap,Ro=class e{constructor(t,n,r){if(b(this,No,void 0),b(this,Po,void 0),b(this,Fo,void 0),b(this,Io,0),b(this,Lo,0),t instanceof e&&x(Fo,t)===!!r)return t;C(No,this,t),C(Po,this,n),C(Fo,this,!!r)}get clipBox(){return x(No,this).clipBox}growOperationsCount(){throw Error(`Unreachable`)}save(e){var t;return C(Lo,this,(t=x(Lo,this),t++,t)),x(No,this).save(x(Po,this)),this}restore(e){if(x(Lo,this)>0){var t;x(No,this).restore(x(Po,this)),C(Lo,this,(t=x(Lo,this),t--,t))}return this}recordOpenMarker(e){var t;return C(Io,this,(t=x(Io,this),t++,t)),this}getOpenMarker(){return x(Io,this)>0?x(Po,this):x(No,this).getOpenMarker()}recordCloseMarker(e){var t;return C(Io,this,(t=x(Io,this),t--,t)),this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return x(No,this).pushBaseTransform(e),this}popBaseTransform(){return x(No,this).popBaseTransform(),this}recordSimpleData(e,t){return x(No,this).recordSimpleData(e,x(Po,this)),this}recordIncrementalData(e,t){return x(No,this).recordIncrementalData(e,x(Po,this)),this}resetIncrementalData(e,t){return x(No,this).resetIncrementalData(e,x(Po,this)),this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,n){return x(No,this).recordSimpleDataFromNamed(e,t,x(Po,this)),this}recordFutureForcedDependency(e,t){return x(No,this).recordFutureForcedDependency(e,x(Po,this)),this}inheritSimpleDataAsFutureForcedDependencies(e){return x(No,this).inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return x(No,this).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return x(Fo,this)||x(No,this).resetBBox(x(Po,this)),this}recordClipBox(e,t,n,r,i,a){return x(Fo,this)||x(No,this).recordClipBox(x(Po,this),t,n,r,i,a),this}recordBBox(e,t,n,r,i,a){return x(Fo,this)||x(No,this).recordBBox(x(Po,this),t,n,r,i,a),this}recordCharacterBBox(e,t,n,r,i,a,o){return x(Fo,this)||x(No,this).recordCharacterBBox(x(Po,this),t,n,r,i,a,o),this}recordFullPageBBox(e){return x(Fo,this)||x(No,this).recordFullPageBBox(x(Po,this)),this}getSimpleIndex(e){return x(No,this).getSimpleIndex(e)}recordDependencies(e,t){return x(No,this).recordDependencies(x(Po,this),t),this}recordNamedDependency(e,t){return x(No,this).recordNamedDependency(x(Po,this),t),this}recordOperation(e){return x(No,this).recordOperation(x(Po,this),!0),this}recordShowTextOperation(e){return x(No,this).recordShowTextOperation(x(Po,this),!0),this}bboxToClipBoxDropOperation(e){return x(Fo,this)||x(No,this).bboxToClipBoxDropOperation(x(Po,this),!0),this}take(){throw Error(`Unreachable`)}takeDebugMetadata(){throw Error(`Unreachable`)}},zo={stroke:[`path`,`transform`,`filter`,`strokeColor`,`strokeAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`dash`],fill:[`path`,`transform`,`filter`,`fillColor`,`fillAlpha`,`globalCompositeOperation`,`SMask`],imageXObject:[`transform`,`SMask`,`filter`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`],rawFillPath:[`filter`,`fillColor`,`fillAlpha`],showText:[`transform`,`leading`,`charSpacing`,`wordSpacing`,`hScale`,`textRise`,`moveText`,`textMatrix`,`font`,`fontObj`,`filter`,`fillColor`,`textRenderingMode`,`SMask`,`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`,`sameLineText`],transform:[`transform`],transformAndFill:[`transform`,`fillColor`]},Bo=new WeakMap,Vo=new WeakMap,Ho=new WeakMap,Uo=new WeakMap,Wo=new WeakMap,Go=class{constructor(e){b(this,Bo,void 0),b(this,Vo,void 0),b(this,Ho,4),b(this,Uo,0),b(this,Wo,new Ko._(x(Ho,this)*6)),C(Bo,this,e.width),C(Vo,this,e.height)}record(e,t,n,r){var i;if(x(Uo,this)===x(Ho,this)){C(Ho,this,x(Ho,this)*2);let e=new Ko._(x(Ho,this)*6);e.set(x(Wo,this)),C(Wo,this,e)}let a=At(e),o;if(r[0]!==1/0){let e=_e.slice();B.axialAlignedBoundingBox([0,-n,t,0],a,e);let i=B.intersect(r,e);if(!i)return;let[s,c,l,u]=i;if(s!==e[0]||c!==e[1]||l!==e[2]||u!==e[3]){let e=Math.atan2(a[1],a[0]),t=Math.abs(Math.sin(e)),n=Math.abs(Math.cos(e));if(t<1e-6||n<1e-6||Math.abs(t-n)<1e-6)o=[s,c,s,u,l,c];else{let e=l-s,r=u-c,i=t*t,a=n*n,d=n*t,f=a-i,p=(r*a-e*d)/f;o=[s+(r*d-e*i)/f,c,s,c+p,l,u-p]}}}o||(o=[0,-n,0,0,t,-n],B.applyTransform(o,a,0),B.applyTransform(o,a,2),B.applyTransform(o,a,4)),o[0]/=x(Bo,this),o[1]/=x(Vo,this),o[2]/=x(Bo,this),o[3]/=x(Vo,this),o[4]/=x(Bo,this),o[5]/=x(Vo,this),x(Wo,this).set(o,x(Uo,this)*6),C(Uo,this,(i=x(Uo,this),i++,i))}take(){return x(Wo,this).subarray(0,x(Uo,this)*6)}},Ko={_:z.isFloat16ArraySupported?Float16Array:Float32Array},qo=new WeakMap,Jo=new WeakMap,Yo=new WeakSet,Xo=class{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){S(this,Yo),b(this,qo,new Set),b(this,Jo,null),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){let t=f(Yo,this,Zo).call(this);t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);if(this.nativeFontFaces.clear(),x(qo,this).clear(),x(Jo,this)){let{adoptedStyleSheets:e}=this._document;e!=null&&e.includes(x(Jo,this))&&(this._document.adoptedStyleSheets=e.filter(e=>e!==x(Jo,this))),C(Jo,this,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:n}){var r=this;return v(function*(){if(!(!e||x(qo,r).has(e.loadedName))){if(Re(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),r.isFontLoadingAPISupported){let{loadedName:t,src:i,style:a}=e,o=new FontFace(t,i,a);r.addNativeFontFace(o);try{yield o.load(),x(qo,r).add(t),n==null||n(e)}catch(t){I(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),r.removeNativeFontFace(o)}return}L(`Not implemented: loadSystemFont without the Font Loading API.`)}})()}bind(e){var t=this;return v(function*(){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){yield t.loadSystemFont(e);return}if(t.isFontLoadingAPISupported){let n=e.createNativeFontFace();if(n){t.addNativeFontFace(n);try{yield n.loaded}catch(t){throw I(`Failed to load font '${n.family}': '${t}'.`),e.disableFontFace=!0,t}}return}let n=e.createFontFaceRule();if(n){if(t.insertRule(n),t.isSyncFontLoadingSupported)return;yield new Promise(n=>{let r=t._queueLoadingCallback(n);t._prepareFontLoadEvent(e,r)})}})()}get isFontLoadingAPISupported(){var e;let t=!!((e=this._document)!=null&&e.fonts);return R(this,`isFontLoadingAPISupported`,t)}get isSyncFontLoadingSupported(){return R(this,`isSyncFontLoadingSupported`,ge||z.platform.isFirefox)}_queueLoadingCallback(e){function t(){for(Re(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return R(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function i(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let a,o,s=this._document.createElement(`canvas`);s.width=1,s.height=1;let c=s.getContext(`2d`),l=0;function u(e,t){if(++l>30){I(`Load test font never loaded.`),t();return}if(c.font=`30px `+e,c.fillText(`.`,0,20),c.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(u.bind(null,e,t))}let d=`lt${Date.now()}${this.loadTestFontId++}`,f=this._loadTestFont;f=i(f,976,d.length,d);let p=1482184792,m=n(f,16);for(a=0,o=d.length-3;a<o;a+=4)m=m-p+n(d,a)|0;a<d.length&&(m=m-p+n(d+`XXX`,a)|0),f=i(f,16,4,r(m));let h=`@font-face {font-family:"${d}";src:${`url(data:font/opentype;base64,${btoa(f)});`}}`;this.insertRule(h);let g=this._document.createElement(`div`);g.style.visibility=`hidden`,g.style.width=g.style.height=`10px`,g.style.position=`absolute`,g.style.top=g.style.left=`0px`;for(let t of[e.loadedName,d]){let e=this._document.createElement(`span`);e.textContent=`Hi`,e.style.fontFamily=t,g.append(e)}this._document.body.append(g),u(d,()=>{g.remove(),t.complete()})}};function Zo(){var e;if(x(Jo,this))return x(Jo,this);let t=((e=this._document.defaultView)==null?void 0:e.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&t){let{adoptedStyleSheets:e}=this._document;if(e){let n=new t;return e.push(n),C(Jo,this,n)}}return this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement)),C(Jo,this,this.styleElement.sheet)}var Qo=new WeakMap,$o=class{constructor(e,t=null,n,r){g(this,`compiledGlyphs`,Object.create(null)),b(this,Qo,void 0),C(Qo,this,e),this._inspectFont=t,n&&(this.charProcOperatorList=n),r&&Object.assign(this,r)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var e;if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}return(e=this._inspectFont)==null||e.call(this,this,t),n}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){I(`getPathGenerator - ignoring character: "${e}".`)}let i=Gt(r==null?void 0:r.path);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}get black(){return x(Qo,this).black}get bold(){return x(Qo,this).bold}get disableFontFace(){return x(Qo,this).disableFontFace}set disableFontFace(e){R(this,`disableFontFace`,!!e)}get fontExtraProperties(){return x(Qo,this).fontExtraProperties}get isInvalidPDFjsFont(){return x(Qo,this).isInvalidPDFjsFont}get isType3Font(){return x(Qo,this).isType3Font}get italic(){return x(Qo,this).italic}get missingFile(){return x(Qo,this).missingFile}get remeasure(){return x(Qo,this).remeasure}get vertical(){return x(Qo,this).vertical}get ascent(){return x(Qo,this).ascent}get defaultWidth(){return x(Qo,this).defaultWidth}get descent(){return x(Qo,this).descent}get bbox(){return x(Qo,this).bbox}get fontMatrix(){return x(Qo,this).fontMatrix}get fallbackName(){return x(Qo,this).fallbackName}get loadedName(){return x(Qo,this).loadedName}get mimetype(){return x(Qo,this).mimetype}get name(){return x(Qo,this).name}get data(){return x(Qo,this).data}clearData(){x(Qo,this).clearData()}get cssFontInfo(){return x(Qo,this).cssFontInfo}get systemFontInfo(){return x(Qo,this).systemFontInfo}get defaultVMetrics(){return x(Qo,this).defaultVMetrics}},es=class{};g(es,`strings`,[`fontFamily`,`fontWeight`,`italicAngle`]);var ts=class{};g(ts,`strings`,[`css`,`loadedName`,`baseFontName`,`src`]);var ns=class{};re=ns,g(ns,`bools`,[`black`,`bold`,`disableFontFace`,`fontExtraProperties`,`isInvalidPDFjsFont`,`isType3Font`,`italic`,`missingFile`,`remeasure`,`vertical`]),g(ns,`numbers`,[`ascent`,`defaultWidth`,`descent`]),g(ns,`strings`,[`fallbackName`,`loadedName`,`mimetype`,`name`]),g(ns,`OFFSET_NUMBERS`,Math.ceil(re.bools.length*2/8)),g(ns,`OFFSET_BBOX`,re.OFFSET_NUMBERS+re.numbers.length*8),g(ns,`OFFSET_FONT_MATRIX`,re.OFFSET_BBOX+1+8),g(ns,`OFFSET_DEFAULT_VMETRICS`,re.OFFSET_FONT_MATRIX+1+48),g(ns,`OFFSET_STRINGS`,re.OFFSET_DEFAULT_VMETRICS+1+6);var rs=class{};g(rs,`KIND`,0),g(rs,`HAS_BBOX`,1),g(rs,`HAS_BACKGROUND`,2),g(rs,`SHADING_TYPE`,3),g(rs,`N_COORD`,4),g(rs,`N_COLOR`,8),g(rs,`N_STOP`,12),g(rs,`N_FIGURES`,16);var is=new WeakMap,as=new WeakMap,os=new WeakMap,ss=new WeakSet,cs=class{constructor(e){S(this,ss),b(this,is,void 0),b(this,as,new TextDecoder),b(this,os,void 0),C(is,this,e),C(os,this,new DataView(e))}get fontFamily(){return f(ss,this,ls).call(this,0)}get fontWeight(){return f(ss,this,ls).call(this,1)}get italicAngle(){return f(ss,this,ls).call(this,2)}};function ls(e){Re(e<es.strings.length,`Invalid string index`);let t=0;for(let n=0;n<e;n++)t+=x(os,this).getUint32(t)+4;let n=x(os,this).getUint32(t);return x(as,this).decode(new Uint8Array(x(is,this),t+4,n))}var us=new WeakMap,ds=new WeakMap,fs=new WeakMap,ps=new WeakSet,ms=class{constructor(e){S(this,ps),b(this,us,void 0),b(this,ds,new TextDecoder),b(this,fs,void 0),C(us,this,e),C(fs,this,new DataView(e))}get guessFallback(){return x(fs,this).getUint8(0)!==0}get css(){return f(ps,this,hs).call(this,0)}get loadedName(){return f(ps,this,hs).call(this,1)}get baseFontName(){return f(ps,this,hs).call(this,2)}get src(){return f(ps,this,hs).call(this,3)}get style(){let e=1;e+=4+x(fs,this).getUint32(e);let t=x(fs,this).getUint32(e),n=x(ds,this).decode(new Uint8Array(x(us,this),e+4,t));e+=4+t;let r=x(fs,this).getUint32(e);return{style:n,weight:x(ds,this).decode(new Uint8Array(x(us,this),e+4,r))}}};function hs(e){Re(e<ts.strings.length,`Invalid string index`);let t=5;for(let n=0;n<e;n++)t+=x(fs,this).getUint32(t)+4;let n=x(fs,this).getUint32(t);return x(ds,this).decode(new Uint8Array(x(us,this),t+4,n))}var gs=new WeakMap,_s=new WeakMap,vs=new WeakMap,ys=new WeakSet,bs=class{constructor({buffer:e,extra:t}){S(this,ys),b(this,gs,void 0),b(this,_s,new TextDecoder),b(this,vs,void 0),C(gs,this,e),C(vs,this,new DataView(e)),t&&Object.assign(this,t)}get black(){return f(ys,this,xs).call(this,0)}get bold(){return f(ys,this,xs).call(this,1)}get disableFontFace(){return f(ys,this,xs).call(this,2)}get fontExtraProperties(){return f(ys,this,xs).call(this,3)}get isInvalidPDFjsFont(){return f(ys,this,xs).call(this,4)}get isType3Font(){return f(ys,this,xs).call(this,5)}get italic(){return f(ys,this,xs).call(this,6)}get missingFile(){return f(ys,this,xs).call(this,7)}get remeasure(){return f(ys,this,xs).call(this,8)}get vertical(){return f(ys,this,xs).call(this,9)}get ascent(){return f(ys,this,Ss).call(this,0)}get defaultWidth(){return f(ys,this,Ss).call(this,1)}get descent(){return f(ys,this,Ss).call(this,2)}get bbox(){return f(ys,this,Cs).call(this,ns.OFFSET_BBOX,4,`getInt16`,2)}get fontMatrix(){return f(ys,this,Cs).call(this,ns.OFFSET_FONT_MATRIX,6,`getFloat64`,8)}get defaultVMetrics(){return f(ys,this,Cs).call(this,ns.OFFSET_DEFAULT_VMETRICS,3,`getInt16`,2)}get fallbackName(){return f(ys,this,ws).call(this,0)}get loadedName(){return f(ys,this,ws).call(this,1)}get mimetype(){return f(ys,this,ws).call(this,2)}get name(){return f(ys,this,ws).call(this,3)}get data(){let{offset:e,length:t}=f(ys,this,Ts).call(this);return t===0?void 0:new Uint8Array(x(gs,this),e+4,t)}clearData(){let{offset:e,length:t}=f(ys,this,Ts).call(this);t!==0&&(x(vs,this).setUint32(e,0),C(gs,this,new Uint8Array(x(gs,this),0,e+4).slice().buffer),C(vs,this,new DataView(x(gs,this))))}get cssFontInfo(){let e=ns.OFFSET_STRINGS,t=x(vs,this).getUint32(e);e+=4+t;let n=x(vs,this).getUint32(e);e+=4+n;let r=x(vs,this).getUint32(e);if(r===0)return null;let i=new Uint8Array(r);return i.set(new Uint8Array(x(gs,this),e+4,r)),new cs(i.buffer)}get systemFontInfo(){let e=ns.OFFSET_STRINGS,t=x(vs,this).getUint32(e);e+=4+t;let n=x(vs,this).getUint32(e);if(n===0)return null;let r=new Uint8Array(n);return r.set(new Uint8Array(x(gs,this),e+4,n)),new ms(r.buffer)}};function xs(e){Re(e<ns.bools.length,`Invalid boolean index`);let t=Math.floor(e/4),n=e*2%8,r=x(vs,this).getUint8(t)>>n&3;return r===0?void 0:r===2}function Ss(e){return Re(e<ns.numbers.length,`Invalid number index`),x(vs,this).getFloat64(ns.OFFSET_NUMBERS+e*8)}function Cs(e,t,n,r){let i=x(vs,this).getUint8(e);if(i===0)return;Re(i===t,`Invalid array length.`),e+=1;let a=Array(i);for(let t=0;t<i;t++)a[t]=x(vs,this)[n](e,!0),e+=r;return a}function ws(e){Re(e<ns.strings.length,`Invalid string index`);let t=ns.OFFSET_STRINGS+4;for(let n=0;n<e;n++)t+=x(vs,this).getUint32(t)+4;let n=x(vs,this).getUint32(t);return x(_s,this).decode(new Uint8Array(x(gs,this),t+4,n))}function Ts(){let e=ns.OFFSET_STRINGS,t=x(vs,this).getUint32(e);e+=4+t;let n=x(vs,this).getUint32(e);e+=4+n;let r=x(vs,this).getUint32(e);e+=4+r;let i=x(vs,this).getUint32(e);return{offset:e,length:i}}var Es=class{constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){let e=this.view,t=this.data[rs.KIND],n=!!this.data[rs.HAS_BBOX],r=!!this.data[rs.HAS_BACKGROUND],i=e.getUint32(rs.N_COORD,!0),a=e.getUint32(rs.N_COLOR,!0),o=e.getUint32(rs.N_STOP,!0),s=20,c=new Float32Array(this.buffer,s,i*2);s+=i*8;let l=new Uint8Array(this.buffer,s,a*4);s+=a*4;let u=[];for(let t=0;t<o;++t){let t=e.getFloat32(s,!0);s+=4;let n=e.getUint32(s,!0);s+=4,u.push([t,`#${n.toString(16).padStart(6,`0`)}`])}let d=null;if(n){d=[];for(let t=0;t<4;++t)d.push(e.getFloat32(s,!0)),s+=4}let f=null;if(r&&(f=new Uint8Array(this.buffer,s,3),s+=3),t===1)return[`RadialAxial`,`axial`,d,u,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(t===2)return[`RadialAxial`,`radial`,d,u,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(t===3){let e=this.data[rs.SHADING_TYPE],t=null;if(c.length>0){t=_e.slice();for(let e=0,n=c.length;e<n;e+=2)B.pointBoundingBox(c[e],c[e+1],t)}return[`Mesh`,e,c,l,i,t,d,f]}throw Error(`Unsupported pattern kind: ${t}`)}},Ds=new WeakMap,Os=class{constructor(e){b(this,Ds,void 0),C(Ds,this,e)}get path(){return z.isFloat16ArraySupported?new Float16Array(x(Ds,this)):new Float32Array(x(Ds,this))}};function ks(e){if(e instanceof URL)return e;if(typeof e==`string`){if(ge){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);let t=process.getBuiltinModule(`url`);return new URL(t.pathToFileURL(e))}let t=URL.parse(e,window.location);if(t)return t}throw Error(`Invalid PDF url data: either string or URL-object is expected in the url property.`)}function As(e){if(ge&&typeof Buffer<`u`&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e==`string`)return Ze(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`object`&&!isNaN(e==null?void 0:e.length))return new Uint8Array(e);throw Error(`Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.`)}function js(e){if(typeof e!=`string`)return null;if(e.endsWith(`/`))return e;throw Error(`Invalid factory url: "${e}" must include trailing slash.`)}var Ms=e=>typeof e==`object`&&Number.isInteger(e==null?void 0:e.num)&&e.num>=0&&Number.isInteger(e==null?void 0:e.gen)&&e.gen>=0,Ns=at.bind(null,Ms,e=>typeof e==`object`&&typeof(e==null?void 0:e.name)==`string`),Ps=new WeakMap,Fs=new WeakMap,Is=class{constructor(){b(this,Ps,new Map),b(this,Fs,Promise.resolve())}postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};x(Fs,this).then(()=>{for(let[e]of x(Ps,this))e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if((n==null?void 0:n.signal)instanceof AbortSignal){let{signal:i}=n;if(i.aborted){I("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}x(Ps,this).set(t,r)}removeEventListener(e,t){let n=x(Ps,this).get(t);n==null||n(),x(Ps,this).delete(t)}terminate(){for(let[,e]of x(Ps,this))e==null||e();x(Ps,this).clear()}},Ls={DATA:1,ERROR:2},Rs={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function zs(){}function Bs(e){if(e instanceof Ye||e instanceof Ke||e instanceof We||e instanceof qe||e instanceof Ge)return e;switch(e instanceof Error||typeof e==`object`&&e||L(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new Ye(e.message);case`InvalidPDFException`:return new Ke(e.message);case`PasswordException`:return new We(e.message,e.code);case`ResponseException`:return new qe(e.message,e.status,e.missing);case`UnknownErrorException`:return new Ge(e.message,e.details)}return new Ge(e.message,e.toString())}var Vs=new WeakMap,Hs=new WeakSet,Us=class{constructor(e,t,n){S(this,Hs),b(this,Vs,new AbortController),this.sourceName=e,this.targetName=t,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`,f(Hs,this,Ws).bind(this),{signal:x(Vs,this).signal})}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:Rs.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{Re(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:Rs.CANCEL,streamId:i,reason:Bs(e)}),t.promise}},n)}destroy(){var e;(e=x(Vs,this))==null||e.abort(),C(Vs,this,null)}};function Ws({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){f(Hs,this,Ks).call(this,e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===Ls.DATA)n.resolve(e.data);else if(e.callback===Ls.ERROR)n.reject(Bs(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:Ls.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:Ls.ERROR,callbackId:e.callbackId,reason:Bs(t)})});return}if(e.streamId){f(Hs,this,Gs).call(this,e);return}t(e.data)}function Gs(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:Rs.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:Rs.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){Re(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:Rs.ERROR,streamId:t,reason:Bs(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:Rs.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:Rs.START_COMPLETE,streamId:t,reason:Bs(e)})})}function Ks(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case Rs.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(Bs(e.reason));break;case Rs.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(Bs(e.reason));break;case Rs.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:Rs.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||zs).then(function(){i.postMessage({sourceName:n,targetName:r,stream:Rs.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:Rs.PULL_COMPLETE,streamId:t,reason:Bs(e)})});break;case Rs.ENQUEUE:if(Re(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case Rs.CLOSE:if(Re(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),f(Hs,this,qs).call(this,a,t);break;case Rs.ERROR:Re(a,`error should have stream controller`),a.controller.error(Bs(e.reason)),f(Hs,this,qs).call(this,a,t);break;case Rs.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(Bs(e.reason)),f(Hs,this,qs).call(this,a,t);break;case Rs.CANCEL:if(!o)break;let s=Bs(e.reason);Promise.try(o.onCancel||zs,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:Rs.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:Rs.CANCEL_COMPLETE,streamId:t,reason:Bs(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}function qs(e,t){var n=this;return v(function*(){var r,i,a;yield Promise.allSettled([(r=e.startCall)==null?void 0:r.promise,(i=e.pullCall)==null?void 0:i.promise,(a=e.cancelCall)==null?void 0:a.promise]),delete n.streamControllers[t]})()}var Js=new WeakMap,Ys=class{constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:n=null}){b(this,Js,Object.freeze({cMapUrl:`CMap`,standardFontDataUrl:`font`,wasmUrl:`wasm`})),this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=n}fetch({kind:e,filename:t}){var n=this;return v(function*(){switch(e){case`cMapUrl`:case`standardFontDataUrl`:case`wasmUrl`:break;default:L(`Not implemented: ${e}`)}let r=n[e];if(!r)throw Error(`Ensure that the \`${e}\` API parameter is provided.`);let i=`${r}${t}`;return n._fetch(i,e).catch(t=>{throw Error(`Unable to load ${x(Js,n)[e]} data at: ${i}`)})})()}_fetch(e,t){return v(function*(){L("Abstract method `_fetch` called.")})()}},Xs=class extends Ys{_fetch(e,t){return v(function*(){let n=yield pt(e,t===`cMapUrl`&&!e.endsWith(`.bcmap`)?`text`:`bytes`);return n instanceof Uint8Array?n:Ze(n)})()}},Zs=new WeakMap,Qs=class{constructor({enableHWA:e=!1}){b(this,Zs,!1),C(Zs,this,e)}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!x(Zs,this)})}}reset({canvas:e},t,n){if(!e)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.width=t,e.height=n}destroy(e){let{canvas:t}=e;if(!t)throw Error(`Canvas is not specified`);t.width=t.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){L("Abstract method `_createCanvas` called.")}},$s=class extends Qs{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},ec=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addKnockoutFilter(e=0){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}addSelectionHCMFilter(e,t){return`none`}addSelectionFilter(){return`none`}createSelectionStyle(e=null){return null}destroy(e=!1){}},tc=new WeakMap,nc=new WeakMap,rc=new WeakMap,ic=new WeakMap,ac=new WeakMap,oc=new WeakMap,sc=new WeakMap,q=new WeakSet,cc=class extends ec{constructor({docId:e,ownerDocument:t=globalThis.document}){super(),S(this,q),b(this,tc,void 0),b(this,nc,void 0),b(this,rc,void 0),b(this,ic,void 0),b(this,ac,void 0),b(this,oc,void 0),b(this,sc,0),C(ic,this,e),C(ac,this,t)}addFilter(e){var t,n;if(!e)return`none`;let r=lc.call(f(q,this)).get(e);if(r)return r;let[i,a,o]=f(q,this,fc).call(this,e),s=e.length===1?i:`${i}${a}${o}`;if(r=lc.call(f(q,this)).get(s),r)return lc.call(f(q,this)).set(e,r),r;let c=`g_${x(ic,this)}_transfer_map_${C(sc,this,(t=x(sc,this),n=t++,t)),n}`,l=f(q,this,pc).call(this,c);lc.call(f(q,this)).set(e,l),lc.call(f(q,this)).set(s,l);let u=f(q,this,gc).call(this,c);return f(q,this,vc).call(this,i,a,o,u),l}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=uc.call(f(q,this)).get(r);if((i==null?void 0:i.key)===n)return i.url;if(i){var a;(a=i.filter)==null||a.remove(),i.key=n,i.url=`none`,i.filter=null}else i={key:n,url:`none`,filter:null},uc.call(f(q,this)).set(r,i);if(!e||!t)return i.url;let o=f(q,this,bc).call(this,e);e=B.makeHexColor(...o);let s=f(q,this,bc).call(this,t);if(t=B.makeHexColor(...s),dc.call(f(q,this)).style.color=``,e===`#000000`&&t===`#ffffff`||e===t)return i.url;let c=Array(256);for(let e=0;e<=255;e++){let t=e/255;c[e]=t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}let l=c.join(`,`),u=`g_${x(ic,this)}_hcm_filter`,d=i.filter=f(q,this,gc).call(this,u);f(q,this,vc).call(this,l,l,l,d),f(q,this,hc).call(this,d);let p=(e,t)=>{let n=o[e]/255,r=s[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return f(q,this,vc).call(this,p(0,5),p(1,5),p(2,5),d),i.url=f(q,this,pc).call(this,u),i.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter(`selection`,e,t,`HighlightText`,`Highlight`)}addSelectionFilter(){return this.addHighlightHCMFilter(`selection_default`,`black`,`white`,`HighlightText`,`Highlight`)}createSelectionStyle(e=null){let t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return t===`none`||!z.platform.isFirefox?null:{"backdrop-filter":t,"background-color":`transparent`}}addAlphaFilter(e){var t,n;let r=lc.call(f(q,this)).get(e);if(r)return r;let[i]=f(q,this,fc).call(this,[e]),a=`alpha_${i}`;if(r=lc.call(f(q,this)).get(a),r)return lc.call(f(q,this)).set(e,r),r;let o=`g_${x(ic,this)}_alpha_map_${C(sc,this,(t=x(sc,this),n=t++,t)),n}`,s=f(q,this,pc).call(this,o);lc.call(f(q,this)).set(e,s),lc.call(f(q,this)).set(a,s);let c=f(q,this,gc).call(this,o);return f(q,this,yc).call(this,i,c),s}addLuminosityFilter(e){var t,n;let r=lc.call(f(q,this)).get(e||`luminosity`);if(r)return r;let i,a;if(e?([i]=f(q,this,fc).call(this,[e]),a=`luminosity_${i}`):a=`luminosity`,r=lc.call(f(q,this)).get(a),r)return lc.call(f(q,this)).set(e,r),r;let o=`g_${x(ic,this)}_luminosity_map_${C(sc,this,(t=x(sc,this),n=t++,t)),n}`,s=f(q,this,pc).call(this,o);lc.call(f(q,this)).set(e,s),lc.call(f(q,this)).set(a,s);let c=f(q,this,gc).call(this,o);return f(q,this,mc).call(this,c),e&&f(q,this,yc).call(this,i,c),s}addKnockoutFilter(e=0){var t,n;let r=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${r}`,a=lc.call(f(q,this)).get(i);if(a)return a;let o=`g_${x(ic,this)}_knockout_filter_${C(sc,this,(t=x(sc,this),n=t++,t)),n}`,s=f(q,this,pc).call(this,o);lc.call(f(q,this)).set(i,s);let c=f(q,this,gc).call(this,o),l=x(ac,this).createElementNS(xe,`feComponentTransfer`);c.append(l);let u=x(ac,this).createElementNS(xe,`feFuncA`);return u.setAttribute(`type`,`linear`),u.setAttribute(`slope`,`${r}`),u.setAttribute(`intercept`,`0`),l.append(u),s}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=uc.call(f(q,this)).get(e);if((o==null?void 0:o.key)===a)return o.url;if(o){var s;(s=o.filter)==null||s.remove(),o.key=a,o.url=`none`,o.filter=null}else o={key:a,url:`none`,filter:null},uc.call(f(q,this)).set(e,o);if(!t||!n)return o.url;let[c,l]=[t,n].map(f(q,this,bc).bind(this)),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[p,m]=[r,i].map(f(q,this,Sc).bind(this));d<u&&([u,d,p,m]=[d,u,m,p]),dc.call(f(q,this)).style.color=``;let h=(e,t,n)=>{let r=Array(256),i=(d-u)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(u+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},g=`g_${x(ic,this)}_hcm_${e}_filter`,_=o.filter=f(q,this,gc).call(this,g);return f(q,this,hc).call(this,_),f(q,this,vc).call(this,h(p[0],m[0],5),h(p[1],m[1],5),h(p[2],m[2],5),_),o.url=f(q,this,pc).call(this,g),o.url}destroy(e=!1){var t,n,r,i;e&&(t=x(oc,this))!=null&&t.size||((n=x(rc,this))==null||n.parentNode.parentNode.remove(),C(rc,this,null),(r=x(nc,this))==null||r.clear(),C(nc,this,null),(i=x(oc,this))==null||i.clear(),C(oc,this,null),C(sc,this,0))}};function lc(){return x(nc,this)||C(nc,this,new Map)}function uc(){return x(oc,this)||C(oc,this,new Map)}function dc(){if(!x(rc,this)){let e=x(ac,this).createElement(`div`),{style:t}=e;t.colorScheme=`only light`,t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=x(ac,this).createElementNS(xe,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),C(rc,this,x(ac,this).createElementNS(xe,`defs`)),e.append(n),n.append(x(rc,this)),x(ac,this).body.append(e)}return x(rc,this)}function fc(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}function pc(e){if(x(tc,this)===void 0){C(tc,this,``);let e=x(ac,this).URL;e!==x(ac,this).baseURI&&(gt(e)?I(`#createUrl: ignore "data:"-URL for performance reasons.`):C(tc,this,Ve(e,``)))}return`url(${x(tc,this)}#${e})`}function mc(e){let t=x(ac,this).createElementNS(xe,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.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`),e.append(t)}function hc(e){let t=x(ac,this).createElementNS(xe,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.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`),e.append(t)}function gc(e){let t=x(ac,this).createElementNS(xe,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),dc.call(f(q,this)).append(t),t}function _c(e,t,n){let r=x(ac,this).createElementNS(xe,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}function vc(e,t,n,r){let i=x(ac,this).createElementNS(xe,`feComponentTransfer`);r.append(i),f(q,this,_c).call(this,i,`feFuncR`,e),f(q,this,_c).call(this,i,`feFuncG`,t),f(q,this,_c).call(this,i,`feFuncB`,n)}function yc(e,t){let n=x(ac,this).createElementNS(xe,`feComponentTransfer`);t.append(n),f(q,this,_c).call(this,n,`feFuncA`,e)}function bc(e){return dc.call(f(q,this)).style.color=e,Ot(getComputedStyle(dc.call(f(q,this))).getPropertyValue(`color`))}function xc(e){return dc.call(f(q,this)).style.color=e,Dt(getComputedStyle(dc.call(f(q,this))).getPropertyValue(`color`))}function Sc(e){let[t,n,r,i]=f(q,this,xc).call(this,e);if(i===1)return[t,n,r];let[a,o,s]=f(q,this,bc).call(this,`Canvas`);return[Cc(t,a,i),Cc(n,o,i),Cc(r,s,i)]}function Cc(e,t,n){return Math.round(n*e+(1-n)*t)}ge&&I("Please use the `legacy` build in Node.js environments.");function wc(e){return Tc.apply(this,arguments)}function Tc(){return Tc=v(function*(e){let t=yield process.getBuiltinModule(`fs/promises`).readFile(e);return new Uint8Array(t)}),Tc.apply(this,arguments)}var Ec=class extends ec{},Dc=class extends Qs{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire({}.url)(`@napi-rs/canvas`).createCanvas(e,t)}},Oc=class extends Ys{_fetch(e,t){return v(function*(){return wc(e)})()}};function kc({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=z.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=c^l,p=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r<i;++r){for(let r=t+u;t<r;++t,m+=8){let r=e[t];n[m]=c^-(r>>7&1)&f,n[m+1]=c^-(r>>6&1)&f,n[m+2]=c^-(r>>5&1)&f,n[m+3]=c^-(r>>4&1)&f,n[m+4]=c^-(r>>3&1)&f,n[m+5]=c^-(r>>2&1)&f,n[m+6]=c^-(r>>1&1)&f,n[m+7]=c^-(r&1)&f}if(d===0)continue;let r=t<p?e[t++]:255;for(let e=0;e<d;++e,++m)n[m]=c^-(r>>7-e&1)&f}return{srcPos:t,destPos:m}}function Ac({src:e,srcPos:t=0,dest:n,destPos:r=0,width:i,height:a}){let o=0,s=i*a*3,c=s>>2,l=new Uint32Array(e.buffer,t,c),u=z.isLittleEndian?4278190080:255;if(z.isLittleEndian){for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e>>>24|t<<8|u,n[r+2]=t>>>16|i<<16|u,n[r+3]=i>>>8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]|e[i+1]<<8|e[i+2]<<16|u}else{for(;o<c-2;o+=3,r+=4){let e=l[o],t=l[o+1],i=l[o+2];n[r]=e|u,n[r+1]=e<<24|t>>>8|u,n[r+2]=t<<16|i>>>16|u,n[r+3]=i<<8|u}for(let i=o*4,a=t+s;i<a;i+=3)n[r++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|u}return{srcPos:t+s,destPos:r}}var jc=`
|
|
2
2
|
struct Uniforms {
|
|
3
3
|
offsetX : f32,
|
|
4
4
|
offsetY : f32,
|
|
@@ -41,59 +41,159 @@ fn vs_main(in : VertexInput) -> VertexOutput {
|
|
|
41
41
|
fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
42
42
|
return vec4<f32>(in.color, 1.0);
|
|
43
43
|
}
|
|
44
|
-
`,Nc=new WeakMap,Pc=new WeakMap,Fc=new WeakMap,Ic=new WeakMap,Lc=new WeakSet,Rc=class{constructor(){S(this,Lc),b(this,Nc,null),b(this,Pc,null),b(this,Fc,null),b(this,Ic,null)}init(){return x(Nc,this)||C(Nc,this,f(Lc,this,zc).call(this))}get isReady(){return x(Pc,this)!==null}loadMeshShader(){if(!x(Pc,this)||x(Fc,this))return;let e=x(Pc,this).createShaderModule({code:Mc});C(Fc,this,x(Pc,this).createRenderPipeline({layout:`auto`,vertex:{module:e,entryPoint:`vs_main`,buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:`float32x2`}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:`unorm8x4`}]}]},fragment:{module:e,entryPoint:`fs_main`,targets:[{format:x(Ic,this)}]},primitive:{topology:`triangle-list`}}))}draw(e,t,n,r,i,a,o,s){this.loadMeshShader();let c=x(Pc,this),{offsetX:l,offsetY:u,scaleX:d,scaleY:f}=r,p=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(p,0,e);let m=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&c.queue.writeBuffer(m,0,t);let h=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(h,0,new Float32Array([l,u,d,f,a,o,s,0]));let g=c.createBindGroup({layout:x(Fc,this).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:h}}]}),_=new OffscreenCanvas(a,o),v=_.getContext(`webgpu`);v.configure({device:c,format:x(Ic,this),alphaMode:i?`opaque`:`premultiplied`});let y=i?{r:i[0]/255,g:i[1]/255,b:i[2]/255,a:1}:{r:0,g:0,b:0,a:0},b=c.createCommandEncoder(),S=b.beginRenderPass({colorAttachments:[{view:v.getCurrentTexture().createView(),clearValue:y,loadOp:`clear`,storeOp:`store`}]});return n>0&&(S.setPipeline(x(Fc,this)),S.setBindGroup(0,g),S.setVertexBuffer(0,p),S.setVertexBuffer(1,m),S.draw(n)),S.end(),c.queue.submit([b.finish()]),p.destroy(),m.destroy(),h.destroy(),_.transferToImageBitmap()}};function zc(){var e=this;return v(function*(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{let t=yield navigator.gpu.requestAdapter();return t?(C(Ic,e,navigator.gpu.getPreferredCanvasFormat()),C(Pc,e,yield t.requestDevice()),!0):!1}catch(e){return!1}})()}var Bc=new Rc;function Vc(){return Bc.init()}function Hc(){return Bc.isReady}function Uc(){Bc.loadMeshShader()}function Wc(e,t,n,r,i,a,o,s){return Bc.draw(e,t,n,r,i,a,o,s)}var Gc={FILL:`Fill`,STROKE:`Stroke`,SHADING:`Shading`};function Kc(e,t){if(!t)return;let n=t[2]-t[0],r=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],n,r),e.clip(i)}var qc=class{isModifyingCurrentTransform(){return!1}getPattern(){I("Abstract method `getPattern` called.")}},Jc=class extends qc{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type===`radial`}areConic(){if(!this.isRadial())return!1;let e=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return e+this._r1>this._r0&&e+this._r0>this._r1}_createGradient(e,t=null){let n,r=this._p0,i=this._p1;if(t&&(r=r.slice(),i=i.slice(),z.applyTransform(r,t),z.applyTransform(i,t)),this._type===`axial`)n=e.createLinearGradient(r[0],r[1],i[0],i[1]);else if(this._type===`radial`){let a=this._r0,o=this._r1;if(t){let e=new Float32Array(2);z.singularValueDecompose2dScale(t,e),a*=e[0],o*=e[0]}n=e.createRadialGradient(r[0],r[1],a,i[0],i[1],o)}for(let e of this._colorStops)n.addColorStop(e[0],e[1]);return n}_createReversedGradient(e,t=null){let n=this._p1,r=this._p0;t&&(n=n.slice(),r=r.slice(),z.applyTransform(n,t),z.applyTransform(r,t));let i=this._r1,a=this._r0;if(t){let e=new Float32Array(2);z.singularValueDecompose2dScale(t,e),i*=e[0],a*=e[0]}let o=e.createRadialGradient(n[0],n[1],i,r[0],r[1],a),s=this._colorStops.map(([e,t])=>[1-e,t]).reverse();for(let[e,t]of s)o.addColorStop(e,t);return o}getPattern(e,t,n,r){let i;if(r===Gc.STROKE||r===Gc.FILL){if(this.isOriginBased()){let r=z.transform(n,t.baseTransform);this.matrix&&(r=z.transform(r,this.matrix));let i=.001,a=Math.hypot(r[0],r[1]),o=Math.hypot(r[2],r[3]),s=(r[0]*r[2]+r[1]*r[3])/(a*o);if(Math.abs(s)<i)if(this.isRadial()){if(Math.abs(a-o)<i)return this._createGradient(e,r)}else return this._createGradient(e,r)}let a=t.current.getClippedPathBoundingBox(r,jt(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,s=Math.ceil(a[3]-a[1])||1,c=t.canvasFactory.create(o,s),l=c.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),n=z.transform(n,[1,0,0,1,a[0],a[1]]),l.transform(...t.baseTransform),this.matrix&&l.transform(...this.matrix),Kc(l,this._bbox),this.areConic()&&(l.fillStyle=this._createReversedGradient(l),l.fill()),l.fillStyle=this._createGradient(l),l.fill(),i=e.createPattern(c.canvas,`no-repeat`),t.canvasFactory.destroy(c);let u=new DOMMatrix(n);i.setTransform(u)}else this.areConic()&&(e.save(),Kc(e,this._bbox),e.fillStyle=this._createReversedGradient(e),e.fillRect(-1e10,-1e10,2e10,2e10),e.restore()),Kc(e,this._bbox),i=this._createGradient(e);return i}};function Yc(e,t,n,r,i,a,o,s){let c=t.coords,l=t.colors,u=e.data,d=e.width*4,f;c[n*2+1]>c[r*2+1]&&(f=n,n=r,r=f,f=a,a=o,o=f),c[r*2+1]>c[i*2+1]&&(f=r,r=i,i=f,f=o,o=s,s=f),c[n*2+1]>c[r*2+1]&&(f=n,n=r,r=f,f=a,a=o,o=f);let p=(c[n*2]+t.offsetX)*t.scaleX,m=(c[n*2+1]+t.offsetY)*t.scaleY,h=(c[r*2]+t.offsetX)*t.scaleX,g=(c[r*2+1]+t.offsetY)*t.scaleY,_=(c[i*2]+t.offsetX)*t.scaleX,v=(c[i*2+1]+t.offsetY)*t.scaleY;if(m>=v)return;let y=l[a*4],b=l[a*4+1],x=l[a*4+2],S=l[o*4],C=l[o*4+1],w=l[o*4+2],T=l[s*4],E=l[s*4+1],D=l[s*4+2],O=Math.round(m),k=Math.round(v),A,ee,te,ne,re,j,ie,ae;for(let e=O;e<=k;e++){if(e<g){let t=e<m?0:(m-e)/(m-g);A=p-(p-h)*t,ee=y-(y-S)*t,te=b-(b-C)*t,ne=x-(x-w)*t}else{let t;t=e>v?1:g===v?0:(g-e)/(g-v),A=h-(h-_)*t,ee=S-(S-T)*t,te=C-(C-E)*t,ne=w-(w-D)*t}let t;t=e<m?0:e>v?1:(m-e)/(m-v),re=p-(p-_)*t,j=y-(y-T)*t,ie=b-(b-E)*t,ae=x-(x-D)*t;let n=Math.round(Math.min(A,re)),r=Math.round(Math.max(A,re)),i=d*e+n*4;for(let e=n;e<=r;e++)t=(A-e)/(A-re),t<0?t=0:t>1&&(t=1),u[i++]=ee-(ee-j)*t|0,u[i++]=te-(te-ie)*t|0,u[i++]=ne-(ne-ae)*t|0,u[i++]=255}}var Xc=class extends qc{constructor(e){super(),this._posData=e[2],this._colData=e[3],this._vertexCount=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null,Uc()}_createMeshCanvas(e,t,n){let r=1.1,i=3e3,a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),s=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,l=Math.min(Math.ceil(Math.abs(s*e[0]*r)),i)||1,u=Math.min(Math.ceil(Math.abs(c*e[1]*r)),i)||1,d=s?s/l:1,f=c?c/u:1,p={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-o,scaleX:1/d,scaleY:1/f},m=l+4,h=u+4,g=n.create(m,h);if(Hc()&&this._vertexCount>48)g.context.drawImage(Wc(this._posData,this._colData,this._vertexCount,p,t,m,h,2),0,0);else{let e=g.context.createImageData(l,u);if(t){let n=e.data;for(let e=0,r=n.length;e<r;e+=4)n[e]=t[0],n[e+1]=t[1],n[e+2]=t[2],n[e+3]=255}for(let t=0,n=this._vertexCount;t<n;t+=3)Yc(e,p,t,t+1,t+2,t,t+1,t+2);g.context.putImageData(e,2,2)}return{canvas:g.canvas,offsetX:a-2*d,offsetY:o-2*f,scaleX:d,scaleY:f}}isModifyingCurrentTransform(){return!0}getPattern(e,t,n,r){Kc(e,this._bbox);let i=new Float32Array(2);if(r===Gc.SHADING)z.singularValueDecompose2dScale(jt(e),i);else if(this.matrix){z.singularValueDecompose2dScale(this.matrix,i);let[e,n]=i;z.singularValueDecompose2dScale(t.baseTransform,i),i[0]*=e,i[1]*=n}else z.singularValueDecompose2dScale(t.baseTransform,i);let a=this._createMeshCanvas(i,r===Gc.SHADING?null:this._background,t.canvasFactory);r!==Gc.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY);let o=e.createPattern(a.canvas,`no-repeat`);return t.canvasFactory.destroy(a),o}},Zc=class extends qc{getPattern(){return`hotpink`}};function Qc(e){switch(e[0]){case`RadialAxial`:return new Jc(e);case`Mesh`:return new Xc(e);case`Dummy`:return new Zc}throw Error(`Unknown IR type: ${e[0]}`)}var $c={COLORED:1,UNCOLORED:2},el=class e{constructor(e,t,n,r){var i;this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.needsIsolation=(i=e[9])==null||i,this.ctx=t,this.canvasGraphicsFactory=n,this.baseTransform=r,this.patternBaseMatrix=this.matrix?z.transform(r,this.matrix):r}canSkipPatternCanvas([e,t,n,r]){let[i,a,o,s]=this.bbox,c=Math.abs(this.xstep),l=Math.abs(this.ystep);if(e>c+1e-6||t>l+1e-6)return null;let u=Math.floor((n-o)/c)+1,d=Math.ceil((n+e-i)/c)-1,f=Math.floor((r-s)/l)+1,p=Math.ceil((r+t-a)/l)-1;return d<=u&&p<=f?[u,f]:null}updatePatternDims(e,t){let n=z.inverseTransform(this.patternBaseMatrix),r=[e[0],e[1]],i=[e[2],e[3]];z.applyTransform(r,n),z.applyTransform(i,n),t[0]=Math.abs(i[0]-r[0]),t[1]=Math.abs(i[1]-r[1]),t[2]=Math.min(r[0],i[0]),t[3]=Math.min(r[1],i[1])}_renderTileCanvas(e,t,n,r){var i,a;let[o,s,c,l]=this.bbox,u=e.canvasFactory.create(n.size,r.size),d=u.context,f=this.canvasGraphicsFactory.createCanvasGraphics(d,t);return f.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(f,this.paintType,this.color),d.translate(-n.scale*o,-r.scale*s),f.transform(0,n.scale,0,0,r.scale,0,0),d.save(),(i=f.dependencyTracker)==null||i.save(),this.clipBbox(f,o,s,c,l),f.baseTransform=jt(f.ctx),f.executeOperatorList(this.operatorList),f.endDrawing(),(a=f.dependencyTracker)==null||a.restore(),d.restore(),u}_getCombinedScales(){let e=new Float32Array(2);z.singularValueDecompose2dScale(this.matrix,e);let[t,n]=e;return z.singularValueDecompose2dScale(this.baseTransform,e),[t*e[0],n*e[1]]}drawPattern(e,t,n=!1,[r,i],a){let[o,s,c,l]=this.bbox,u=e.dependencyTracker;if(u&&(e.dependencyTracker=new zo(u,a)),e.save(),n?e.ctx.clip(t,`evenodd`):e.ctx.clip(t),e.ctx.setTransform(...this.patternBaseMatrix),e.ctx.translate(r*this.xstep,i*this.ystep),this.needsIsolation||e.ctx.globalAlpha!==1||e.ctx.globalCompositeOperation!==`source-over`||e.inSMaskMode){let t=c-o,n=l-s,[r,i]=this._getCombinedScales(),u=this.getSizeAndScale(t,this.ctx.canvas.width,r),d=this.getSizeAndScale(n,this.ctx.canvas.height,i),f=this._renderTileCanvas(e,a,u,d);e.ctx.drawImage(f.canvas,o,s,t,n),e.canvasFactory.destroy(f)}else this.setFillAndStrokeStyleToContext(e,this.paintType,this.color),this.clipBbox(e,o,s,c,l),e.baseTransformStack.push(e.baseTransform),e.baseTransform=jt(e.ctx),e.executeOperatorList(this.operatorList),e.baseTransform=e.baseTransformStack.pop();e.restore(),u&&(e.dependencyTracker=u)}createPatternCanvas(e,t){let[n,r,i,a]=this.bbox,o=i-n,s=a-r,{xstep:c,ystep:l}=this;c=Math.abs(c),l=Math.abs(l),Re(`TilingType: `+this.tilingType);let[u,d]=this._getCombinedScales(),f=o,p=s,m=!1,h=!1;Math.ceil(c*u)>=Math.ceil(o*u)?f=c:m=!0,Math.ceil(l*d)>=Math.ceil(s*d)?p=l:h=!0;let g=this.getSizeAndScale(f,this.ctx.canvas.width,u),_=this.getSizeAndScale(p,this.ctx.canvas.height,d),v=this._renderTileCanvas(e,t,g,_);if(m||h){let t=v.canvas;m&&(f=c),h&&(p=l);let i=this.getSizeAndScale(f,this.ctx.canvas.width,u),a=this.getSizeAndScale(p,this.ctx.canvas.height,d),g=i.size,_=a.size,y=e.canvasFactory.create(g,_),b=y.context,x=m?Math.floor(o/c):0,S=h?Math.floor(s/l):0;for(let e=0;e<=x;e++)for(let n=0;n<=S;n++)b.drawImage(t,g*e,_*n,g,_,0,0,g,_);return e.canvasFactory.destroy(v),{canvas:y.canvas,canvasEntry:y,scaleX:i.scale,scaleY:a.scale,offsetX:n,offsetY:r}}return{canvas:v.canvas,canvasEntry:v,scaleX:g.scale,scaleY:_.scale,offsetX:n,offsetY:r}}getSizeAndScale(t,n,r){let i=Math.max(e.MAX_PATTERN_SIZE,n),a=Math.ceil(t*r);return a>=i?a=i:r=a/t,{scale:r,size:a}}clipBbox(e,t,n,r,i){let a=r-t,o=i-n,s=new Path2D;s.rect(t,n,a,o),z.axialAlignedBoundingBox([t,n,r,i],jt(e.ctx),e.current.minMax),e.ctx.clip(s),e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,i=e.current;switch(i.patternFill=i.patternStroke=!1,t){case $c.COLORED:let{fillStyle:e,strokeStyle:a}=this.ctx;r.fillStyle=i.fillColor=e,r.strokeStyle=i.strokeColor=a;break;case $c.UNCOLORED:r.fillStyle=r.strokeStyle=n,i.fillColor=i.strokeColor=n;break;default:throw new Ye(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,n,r,i){let a=r===Gc.SHADING?n:z.transform(n,this.patternBaseMatrix),o=this.createPatternCanvas(t,i),s=new DOMMatrix(a);s=s.translate(o.offsetX,o.offsetY),s=s.scale(1/o.scaleX,1/o.scaleY);let c=e.createPattern(o.canvas,`repeat`);return t.canvasFactory.destroy(o.canvasEntry),c.setTransform(s),c}};g(el,`MAX_PATTERN_SIZE`,3e3);var tl=16,nl=100,rl=15,il=10,al=16,ol=new DOMMatrix,sl=new Float32Array(2);function cl(e,t){if(e._removeMirroring)throw Error(`Context is already forwarding operations.`);let n=new Map;for(let r of[`save`,`restore`,`rotate`,`scale`,`translate`,`transform`,`setTransform`,`resetTransform`,`clip`,`moveTo`,`lineTo`,`bezierCurveTo`,`quadraticCurveTo`,`arc`,`arcTo`,`ellipse`,`rect`,`roundRect`,`closePath`,`beginPath`]){let i=e[r];typeof i!=`function`||typeof t[r]!=`function`||(n.set(r,i),e[r]=function(...e){return t[r](...e),i.apply(this,e)})}e._removeMirroring=()=>{for(let[t,r]of n)e[t]=r;delete e._removeMirroring}}function ll(e,t,n,r,i,a,o,s,c,l){let[u,d,f,p,m,h]=jt(e);if(d===0&&f===0){let g=o*u+m,_=Math.round(g),v=s*p+h,y=Math.round(v),b=(o+c)*u+m,x=Math.abs(Math.round(b)-_)||1,S=(s+l)*p+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),_,y),e.drawImage(t,n,r,i,a,0,0,x,C),e.setTransform(u,d,f,p,m,h),[x,C]}if(u===0&&p===0){let g=s*f+m,_=Math.round(g),v=o*d+h,y=Math.round(v),b=(s+l)*f+m,x=Math.abs(Math.round(b)-_)||1,S=(o+c)*d+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(f),0,_,y),e.drawImage(t,n,r,i,a,0,0,C,x),e.setTransform(u,d,f,p,m,h),[C,x]}e.drawImage(t,n,r,i,a,o,s,c,l);let g=Math.hypot(u,d),_=Math.hypot(f,p);return[g*c,_*l]}var ul=class{constructor(e,t){g(this,`alphaIsShape`,!1),g(this,`fontSize`,0),g(this,`fontSizeScale`,1),g(this,`textMatrix`,null),g(this,`textMatrixScale`,1),g(this,`fontMatrix`,be),g(this,`leading`,0),g(this,`x`,0),g(this,`y`,0),g(this,`lineX`,0),g(this,`lineY`,0),g(this,`charSpacing`,0),g(this,`wordSpacing`,0),g(this,`textHScale`,1),g(this,`textRenderingMode`,Oe.FILL),g(this,`textRise`,0),g(this,`fillColor`,`#000000`),g(this,`strokeColor`,`#000000`),g(this,`tilingPatternDims`,null),g(this,`patternFill`,!1),g(this,`patternStroke`,!1),g(this,`fillAlpha`,1),g(this,`strokeAlpha`,1),g(this,`lineWidth`,1),g(this,`activeSMask`,null),g(this,`transferMaps`,`none`),g(this,`minMax`,ye.slice()),this.clipBox=new Float32Array([0,0,e,t])}clone(){var e;let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(e=Gc.FILL,t=null){let n=this.minMax.slice();if(e===Gc.STROKE){t||I(`Stroke bounding box must include transform.`),z.singularValueDecompose2dScale(t,sl);let e=sl[0]*this.lineWidth/2,r=sl[1]*this.lineWidth/2;n[0]-=e,n[1]-=r,n[2]+=e,n[3]+=r}return n}updateClipFromPath(){let e=z.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(ye,0)}getClippedPathBoundingBox(e=Gc.FILL,t=null){return z.intersect(this.clipBox,this.getPathBoundingBox(e,t))}};function dl(e,t){let{width:n,height:r,kind:i}=t,a=r%al,o=(r-a)/al,s=a===0?o:o+1,c=e.createImageData(n,al),l=0,u=t.data,d=c.data,f;if(i===ke.GRAYSCALE_1BPP)for(f=0;f<s;f++)({srcPos:l}=Ac({src:u,srcPos:l,dest:d,width:n,height:f<o?al:a})),e.putImageData(c,0,f*al);else if(i===ke.RGBA_32BPP){let t=0,r=n*al*4;for(f=0;f<o;f++)d.set(u.subarray(l,l+r)),l+=r,e.putImageData(c,0,t),t+=al;f<s&&(r=n*a*4,d.set(u.subarray(l,l+r)),e.putImageData(c,0,t))}else if(i===ke.RGB_24BPP)for(f=0;f<s;f++)({srcPos:l}=jc({src:u,srcPos:l,dest:new Uint32Array(d.buffer),width:n,height:f<o?al:a})),e.putImageData(c,0,f*al);else throw Error(`bad image kind: ${i}`)}function fl(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let{width:n,height:r}=t,i=r%al,a=(r-i)/al,o=i===0?a:a+1,s=e.createImageData(n,al),c=0,l=t.data,u=s.data;for(let t=0;t<o;t++)({srcPos:c}=Ac({src:l,srcPos:c,dest:u,width:n,height:t<a?al:i,nonBlackColor:0})),e.putImageData(s,0,t*al)}function pl(e,t){for(let n of[`strokeStyle`,`fillStyle`,`fillRule`,`globalAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`globalCompositeOperation`,`font`,`filter`])e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function ml(e){e.strokeStyle=e.fillStyle=`#000000`,e.fillRule=`nonzero`,e.globalAlpha=1,e.lineWidth=1,e.lineCap=`butt`,e.lineJoin=`miter`,e.miterLimit=10,e.globalCompositeOperation=`source-over`,e.font=`10px sans-serif`,e.setLineDash!==void 0&&(e.setLineDash([]),e.lineDashOffset=0);let{filter:t}=e;t!==`none`&&t!==``&&(e.filter=`none`)}function hl(e,t){if(t)return!0;z.singularValueDecompose2dScale(e,sl);let n=Math.fround(Pt.pixelRatio*pt.PDF_TO_CSS_UNITS);return sl[0]<=n&&sl[1]<=n}var gl=[`butt`,`round`,`square`],_l=[`miter`,`round`,`bevel`],vl={},yl={},bl=new WeakMap,xl=new WeakMap,Sl=new WeakMap,Cl=new WeakMap,wl=new WeakMap,Tl=new WeakMap,El=new WeakMap,Dl=new WeakMap,Ol=new WeakMap,kl=new WeakMap,q=new WeakSet,Al=class e{constructor(e,t,n,r,i,{optionalContentConfig:a,markedContentStack:o=null},s,c,l,u){S(this,q),b(this,bl,0),b(this,xl,0),b(this,Sl,null),b(this,Cl,null),b(this,wl,null),b(this,Tl,null),b(this,El,1),b(this,Dl,void 0),b(this,Ol,null),b(this,kl,[]),this.ctx=e,this.current=new ul(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=l==null?null:l,this.imagesTracker=u==null?null:u}getObject(e,t,n=null){if(typeof t==`string`){var r;return(r=this.dependencyTracker)==null||r.recordNamedDependency(e,t),t.startsWith(`g_`)?this.commonObjs.get(t):this.objs.get(t)}return n}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){let i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=r||`#ffffff`,this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,n){let e=this.transparentCanvasEntry=this.canvasFactory.create(i,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=e,this.ctx.save(),this.ctx.transform(...jt(this.compositeCtx))}this.ctx.save(),ml(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[3]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=jt(this.ctx)}executeOperatorList(e,t,n,r,i){let a=e.argsArray,o=e.fnArray,s=t||0,c=a.length;if(c===s)return s;let l=c-s>il&&typeof n==`function`,u=l?Date.now()+rl:0,d=0,f=this.commonObjs,p=this.objs,m,h;for(;;){if(r!==void 0){if(s===r.nextBreakPoint)return r.breakIt(s,n),s;if(r.shouldSkip(s)){if(++s===c)return s;continue}}if(!i||i(s)){var g;if(m=o[s],h=(g=a[s])==null?null:g,m!==P.dependency)h===null?this[m](s):this[m](s,...h);else for(let e of h){var _;(_=this.dependencyTracker)==null||_.recordNamedData(e,s);let t=e.startsWith(`g_`)?f:p;if(!t.has(e))return t.get(e,n),s}}if(s++,s===c)return s;if(l&&++d>il){if(Date.now()>u)return n(),s;d=0}}}endDrawing(){f(q,this,jl).call(this);for(let e of this.smaskGroupCanvases)this.canvasFactory.destroy(e);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(let e of x(kl,this))f(q,this,Bl).call(this,e);x(kl,this).length=0,C(Sl,this,null),C(Cl,this,null),C(wl,this,null),C(Tl,this,null),C(El,this,1),C(Ol,this,null),C(xl,this,0),C(bl,this,0),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),f(q,this,Ml).call(this)}_scaleImage(e,t){var n,r;let i=(n=e.width)==null?e.displayWidth:n,a=(r=e.height)==null?e.displayHeight:r,o=Math.max(Math.hypot(t[0],t[1]),1),s=Math.max(Math.hypot(t[2],t[3]),1),c=[],l=o,u=s,d=i,f=a;for(;l>2&&d>1||u>2&&f>1;){let e=d,t=f;l>2&&d>1&&(e=Math.ceil(d/2),l/=d/e),u>2&&f>1&&(t=Math.ceil(f/2),u/=f/t),c.push({newWidth:e,newHeight:t}),d=e,f=t}if(c.length===0)return{img:e,paintWidth:i,paintHeight:a,tmpCanvas:null};if(c.length===1){let{newWidth:t,newHeight:n}=c[0],r=this.canvasFactory.create(t,n);return r.context.drawImage(e,0,0,i,a,0,0,t,n),{img:r.canvas,paintWidth:t,paintHeight:n,tmpCanvas:r}}let p=this.canvasFactory.create(1,1),m=this.canvasFactory.create(1,1),h=i,g=a,_=e;for(let{newWidth:e,newHeight:t}of c)this.canvasFactory.reset(m,e,t),m.context.drawImage(_,0,0,h,g,0,0,e,t),[p,m]=[m,p],_=p.canvas,h=e,g=t;return this.canvasFactory.destroy(m),{img:p.canvas,paintWidth:h,paintHeight:g,tmpCanvas:p}}_createMaskCanvas(e,t){var n;let r=this.ctx,{width:i,height:a}=t,o=this.current.fillColor,s=this.current.patternFill,c=jt(r),l,u,d,f;if((t.bitmap||t.data)&&t.count>1){let n=t.bitmap||t.data.buffer;u=JSON.stringify(s?c:[c.slice(0,4),o]),l=this._cachedBitmapsMap.getOrInsertComputed(n,ct);let r=l.get(u);if(r&&!s){var p;let t=Math.round(Math.min(c[0],c[2])+c[4]),n=Math.round(Math.min(c[1],c[3])+c[5]);return(p=this.dependencyTracker)==null||p.recordDependencies(e,Bo.transformAndFill),{canvas:r,offsetX:t,offsetY:n}}d=r}d||(f=this.canvasFactory.create(i,a),fl(f.context,t));let m=z.transform(c,[1/i,0,0,-1/a,0,0]);m=z.transform(m,[1,0,0,1,0,-a]);let h=ye.slice();z.axialAlignedBoundingBox([0,0,i,a],m,h);let[g,_,v,y]=h,b=Math.round(v-g)||1,x=Math.round(y-_)||1,S=this.canvasFactory.create(b,x),C=S.context,w=g,T=_;C.translate(-w,-T),C.transform(...m);let E=null;if(!d){let e=this._scaleImage(f.canvas,Mt(C));d=e.img,E=e.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),l&&s&&(l.set(u,d),E=null,f=null)}C.imageSmoothingEnabled=hl(jt(C),t.interpolate),ll(C,d,0,0,d.width,d.height,0,0,i,a),E&&this.canvasFactory.destroy(E),f&&this.canvasFactory.destroy(f),C.globalCompositeOperation=`source-in`;let D=z.transform(Mt(C),[1,0,0,1,-w,-T]);return C.fillStyle=s?o.getPattern(r,this,D,Gc.FILL,e):o,C.fillRect(0,0,i,a),l&&!s&&l.set(u,S.canvas),(n=this.dependencyTracker)==null||n.recordDependencies(e,Bo.transformAndFill),{canvas:S.canvas,canvasEntry:l&&!s?null:S,offsetX:Math.round(w),offsetY:Math.round(T)}}setLineWidth(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`lineWidth`,e),t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`lineCap`,e),this.ctx.lineCap=gl[t]}setLineJoin(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`lineJoin`,e),this.ctx.lineJoin=_l[t]}setMiterLimit(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`miterLimit`,e),this.ctx.miterLimit=t}setDash(e,t,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData(`dash`,e);let i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(t),i.lineDashOffset=n)}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){for(let[s,c]of t)switch(s){case`LW`:this.setLineWidth(e,c);break;case`LC`:this.setLineCap(e,c);break;case`LJ`:this.setLineJoin(e,c);break;case`ML`:this.setMiterLimit(e,c);break;case`D`:this.setDash(e,c[0],c[1]);break;case`RI`:this.setRenderingIntent(e,c);break;case`FL`:this.setFlatness(e,c);break;case`Font`:this.setFont(e,c[0],c[1]);break;case`CA`:var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`strokeAlpha`,e),this.current.strokeAlpha=c;break;case`ca`:var r;(r=this.dependencyTracker)==null||r.recordSimpleData(`fillAlpha`,e),this.ctx.globalAlpha=this.current.fillAlpha=c;break;case`BM`:var i;(i=this.dependencyTracker)==null||i.recordSimpleData(`globalCompositeOperation`,e),this.ctx.globalCompositeOperation=c;break;case`SMask`:var a;(a=this.dependencyTracker)==null||a.recordSimpleData(`SMask`,e),this.current.activeSMask=c?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(e);break;case`TR`:var o;(o=this.dependencyTracker)==null||o.recordSimpleData(`filter`,e),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(c);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){e!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(e))}checkSMaskState(e){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode(e):!this.current.activeSMask&&t?this.endSMaskMode():this.current.activeSMask&&t&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){let{canvas:t,subtype:n,backdrop:r,transferMap:i}=e,a=n===`Luminosity`||n===`Alpha`&&i;if(!a&&!(n===`Luminosity`&&r)){this.smaskPreparedFor=e;return}let o;if(n===`Luminosity`&&r){var s;let[e,t,n]=Ot(r),a=Math.round(.3*e+.59*t+.11*n);o=(s=i==null?void 0:i[a])==null?a:s}else{var c;o=(c=i==null?void 0:i[0])==null?0:c}let{width:l,height:u}=this.ctx.canvas,d=t.width*t.height,f=l*u<4*d,p=a?{url:n===`Alpha`?this.filterFactory.addAlphaFilter(i):this.filterFactory.addLuminosityFilter(i),subtype:n,transferMap:i}:null,m=n===`Luminosity`?r:null,h,g,_;f?(h=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,l,u,m,p),g=0,_=0):(h=this._bakeSMaskCanvas(t,0,0,t.width,t.height,m,p),g=e.offsetX,_=e.offsetY),this.smaskPreparedEntry=h,this.smaskPreparedFor=e,this.smaskPreparedOffsetX=g,this.smaskPreparedOffsetY=_,this.smaskPreparedOOBAlpha=!f&&o!==0?o:null}_bakeSMaskCanvas(e,t,n,r,i,a,o){!a&&!o&&I(`_bakeSMaskCanvas with neither backdrop nor filter`);let s=this.canvasFactory.create(r,i),c=s.context;if(c.drawImage(e,t,n),a&&(c.globalCompositeOperation=`destination-atop`,c.fillStyle=a,c.fillRect(0,0,r,i)),!o)return s;let l=this.canvasFactory.create(r,i),u=l.context;u.filter=o.url;let d=R.isCanvasFilterSupported&&u.filter!==`none`&&u.filter!==``;if(u.drawImage(s.canvas,0,0),R.isCanvasFilterSupported&&(u.filter=`none`),!d){let e=u.getImageData(0,0,r,i),{data:t}=e,{transferMap:n}=o;if(o.subtype===`Luminosity`)for(let e=0,r=t.length;e<r;e+=4){var f;let r=.3*t[e]+.59*t[e+1]+.11*t[e+2]+.5|0;t[e]=t[e+1]=t[e+2]=0,t[e+3]=(f=n==null?void 0:n[r])==null?r:f}else for(let e=3,r=t.length;e<r;e+=4)t[e]=n[t[e]];u.putImageData(e,0,0)}return this.canvasFactory.destroy(s),l}beginSMaskMode(e){if(this.inSMaskMode)throw Error(`beginSMaskMode called while already in smask mode`);let{width:t,height:n}=this.ctx.canvas,r=this.canvasFactory.create(t,n);this.smaskScratchCanvas=r,this.suspendedCtx=this.ctx;let i=this.ctx=r.context;i.setTransform(this.suspendedCtx.getTransform()),pl(this.suspendedCtx,i),cl(i,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(e,[[`BM`,`source-over`]])}endSMaskMode(){if(!this.inSMaskMode)throw Error(`endSMaskMode called while not in smask mode`);this.ctx._removeMirroring(),pl(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}compose(e){if(!this.current.activeSMask)return;e=e?[Math.floor(e[0]),Math.floor(e[1]),Math.ceil(e[2]),Math.ceil(e[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,n=this.suspendedCtx,r=x(xl,this)>0&&n===this.ctx;this.composeSMask(r?null:n,t,this.ctx,e),!r&&(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(e,t,n,r){let i=r[0],a=r[1],o=r[2]-i,s=r[3]-a;if(o===0||s===0)return;let c=this.smaskPreparedEntry;if(c){let e=i,r=a,l=o,u=s,d=this.smaskPreparedOOBAlpha,f=d!==null;if(f){e=Math.max(i,t.offsetX),r=Math.max(a,t.offsetY);let n=Math.min(i+o,t.offsetX+t.canvas.width),c=Math.min(a+s,t.offsetY+t.canvas.height);l=n-e,u=c-r}if(l>0&&u>0){let t=e-this.smaskPreparedOffsetX,i=r-this.smaskPreparedOffsetY;n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0);let a=new Path2D;a.rect(e,r,l,u),n.clip(a),n.globalCompositeOperation=`destination-in`,n.drawImage(c.canvas,t,i,l,u,e,r,l,u),n.restore()}f&&d<255&&this._applySMaskOOBAlpha(n,i,a,o,s,e,r,e+l,r+u,d)}else this.genericComposeSMask(t,n,o,s,i,a);e&&(e.save(),e.globalAlpha=1,e.globalCompositeOperation=t.blendMode||`source-over`,e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,i,a,o,s,i,a,o,s),e.restore())}_applySMaskOOBAlpha(e,t,n,r,i,a,o,s,c,l){let u=a<s&&o<c;if(u&&a===t&&o===n&&s===t+r&&c===n+i)return;let d=new Path2D;d.rect(t,n,r,i),u&&d.rect(a,o,s-a,c-o),e.save(),e.globalAlpha=l/255,e.setTransform(1,0,0,1,0,0),e.clip(d,`evenodd`),e.globalCompositeOperation=`destination-in`,e.fillStyle=`#000000`,e.fillRect(t,n,r,i),e.restore()}genericComposeSMask(e,t,n,r,i,a){let{context:o,offsetX:s,offsetY:c}=e;t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let l=new Path2D;l.rect(i,a,n,r),t.clip(l),t.globalCompositeOperation=`destination-in`,t.drawImage(o.canvas,i-s,a-c,n,r,i,a,n,r),t.restore()}save(e){var t;this.inSMaskMode&&pl(this.ctx,this.suspendedCtx),this.ctx.save();let n=this.current;this.stateStack.push(n),this.current=n.clone(),(t=this.dependencyTracker)==null||t.save(e)}restore(e){var t;if((t=this.dependencyTracker)==null||t.restore(e),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(pl(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(e),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,t,n,r,i,a,o){var s;(s=this.dependencyTracker)==null||s.recordIncrementalData(`transform`,e),this.ctx.transform(t,n,r,i,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n,r){let[i]=n;if(!r){i||(i=n[0]=new Path2D),t!==P.stroke&&t!==P.closeStroke&&(this.current.tilingPatternDims=null),this[t](e,i);return}if(this.dependencyTracker!==null){let n=t===P.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,r[0]-n,r[2]+n,r[1]-n,r[3]+n).recordDependencies(e,[`transform`])}i instanceof Path2D||(i=n[0]=Kt(i)),z.axialAlignedBoundingBox(r,jt(this.ctx),this.current.minMax);let a=this.current.tilingPatternDims;if(a&&t!==P.stroke&&t!==P.closeStroke&&this.current.fillColor instanceof el){let e=z.intersect(this.current.clipBox,this.current.minMax);e?this.current.fillColor.updatePatternDims(e,a):this.current.tilingPatternDims=null}this[t](e,i),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t,n=!0){var r;let i=n&&f(q,this,Il).call(this,this.current.strokeAlpha),a=this.ctx,o=this.current.strokeColor;if(a.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof o==`object`&&o&&o.getPattern){let n=o.isModifyingCurrentTransform()?a.getTransform():null;if(a.save(),a.strokeStyle=o.getPattern(a,this,Mt(a),Gc.STROKE,e),n){let e=new Path2D;e.addPath(t,a.getTransform().invertSelf().multiplySelf(n)),t=e}this.rescaleAndStroke(t,!1),a.restore()}else this.rescaleAndStroke(t,!0);(r=this.dependencyTracker)==null||r.recordDependencies(e,Bo.stroke),n&&this.consumePath(e,t,this.current.getClippedPathBoundingBox(Gc.STROKE,jt(this.ctx))),a.globalAlpha=this.current.fillAlpha,f(q,this,Ll).call(this,i)}closeStroke(e,t){this.stroke(e,t)}fill(e,t,n=!0){var r;let i=n&&f(q,this,Il).call(this,this.current.fillAlpha),a=this.ctx,o=this.current.fillColor,s=this.current.patternFill,c=!1,l=this.current.getClippedPathBoundingBox();if((r=this.dependencyTracker)==null||r.recordDependencies(e,Bo.fill),s){var u;let r=this.current.tilingPatternDims,s=r&&o.canSkipPatternCanvas(r);if(s){o.drawPattern(this,t,this.pendingEOFill,s,e),this.pendingEOFill=!1,n&&this.consumePath(e,t,l),this.current.tilingPatternDims=null,f(q,this,Ll).call(this,i);return}let d=o.isModifyingCurrentTransform()?a.getTransform():null;if((u=this.dependencyTracker)==null||u.save(e),a.save(),a.fillStyle=o.getPattern(a,this,Mt(a),Gc.FILL,e),d){let e=new Path2D;e.addPath(t,a.getTransform().invertSelf().multiplySelf(d)),t=e}c=!0}if(this.contentVisible&&l!==null&&(this.pendingEOFill?(a.fill(t,`evenodd`),this.pendingEOFill=!1):a.fill(t)),c){var d;a.restore(),(d=this.dependencyTracker)==null||d.restore(e)}n&&this.consumePath(e,t,l),f(q,this,Ll).call(this,i)}eoFill(e,t){this.pendingEOFill=!0,this.fill(e,t)}fillStroke(e,t){let n=f(q,this,Il).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1),this.stroke(e,t,!1),this.consumePath(e,t),f(q,this,Ll).call(this,n)}eoFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}closeFillStroke(e,t){this.fillStroke(e,t)}closeEOFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}endPath(e,t){this.consumePath(e,t)}rawFillPath(e,t){var n;let r=f(q,this,Il).call(this,this.current.fillAlpha);this.ctx.fill(t),(n=this.dependencyTracker)==null||n.recordDependencies(e,Bo.rawFillPath).recordOperation(e),f(q,this,Ll).call(this,r)}clip(e){var t;(t=this.dependencyTracker)==null||t.recordFutureForcedDependency(`clipMode`,e),this.pendingClip=vl}eoClip(e){var t;(t=this.dependencyTracker)==null||t.recordFutureForcedDependency(`clipMode`,e),this.pendingClip=yl}beginText(e){var t;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(t=this.dependencyTracker)==null||t.recordOpenMarker(e).resetIncrementalData(`sameLineText`).resetIncrementalData(`moveText`,e)}endText(e){let t=this.pendingTextPaths,n=this.ctx;if(this.dependencyTracker){let{dependencyTracker:n}=this;t!==void 0&&n.recordFutureForcedDependency(`textClip`,n.getOpenMarker()).recordFutureForcedDependency(`textClip`,e),n.recordCloseMarker(e)}if(t!==void 0){let e=new Path2D,r=n.getTransform().invertSelf();for(let{transform:n,x:i,y:a,fontSize:o,path:s}of t)s&&e.addPath(s,new DOMMatrix(n).preMultiplySelf(r).translate(i,a).scale(o,-o));n.clip(e)}delete this.pendingTextPaths}setCharSpacing(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`charSpacing`,e),this.current.charSpacing=t}setWordSpacing(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`wordSpacing`,e),this.current.wordSpacing=t}setHScale(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`hScale`,e),this.current.textHScale=t/100}setLeading(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`leading`,e),this.current.leading=-t}setFont(e,t,n){var r,i;(r=this.dependencyTracker)==null||r.recordSimpleData(`font`,e).recordSimpleDataFromNamed(`fontObj`,t,e);let a=this.commonObjs.get(t),o=this.current;if(!a)throw Error(`Can't find font for ${t}`);if(o.fontMatrix=a.fontMatrix||be,(o.fontMatrix[0]===0||o.fontMatrix[3]===0)&&F(`Invalid font matrix for font `+t),n<0?(n=-n,o.fontDirection=-1):o.fontDirection=1,this.current.font=a,this.current.fontSize=n,a.isType3Font)return;let s=a.loadedName||`sans-serif`,c=((i=a.systemFontInfo)==null?void 0:i.css)||`"${s}", ${a.fallbackName}`,l=`normal`;a.black?l=`900`:a.bold&&(l=`bold`);let u=a.italic?`italic`:`normal`,d=B(n,tl,nl);this.current.fontSizeScale=n/d,this.ctx.font=`${u} ${l} ${d}px ${c}`}setTextRenderingMode(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`textRenderingMode`,e),this.current.textRenderingMode=t}setTextRise(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`textRise`,e),this.current.textRise=t}moveText(e,t,n){var r;(r=this.dependencyTracker)==null||r.resetIncrementalData(`sameLineText`).recordIncrementalData(`moveText`,e),this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=n}setLeadingMoveText(e,t,n){this.setLeading(e,-n),this.moveText(e,t,n)}setTextMatrix(e,t){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData(`sameLineText`).recordSimpleData(`textMatrix`,e);let{current:r}=this;r.textMatrix=t,r.textMatrixScale=Math.hypot(t[0],t[1]),r.x=r.lineX=0,r.y=r.lineY=0}nextLine(e){var t,n;this.moveText(e,0,this.current.leading),(t=this.dependencyTracker)==null||t.recordIncrementalData(`moveText`,(n=this.dependencyTracker.getSimpleIndex(`leading`))==null?e:n)}paintChar(e,t,n,r,i,a){let o=this.ctx,s=this.current,c=s.font,l=s.textRenderingMode,u=s.fontSize/s.fontSizeScale,d=l&Oe.FILL_STROKE_MASK,p=!!(l&Oe.ADD_TO_PATH_FLAG),m=s.patternFill&&!c.missingFile,h=s.patternStroke&&!c.missingFile,g;if((c.disableFontFace||p||m||h)&&!c.missingFile&&(g=c.getPathGenerator(this.commonObjs,t)),g&&(c.disableFontFace||m||h)){var _;o.save(),o.translate(n,r),o.scale(u,-u),(_=this.dependencyTracker)==null||_.recordCharacterBBox(e,o,c);let t;if(d===Oe.FILL||d===Oe.FILL_STROKE)if(i){t=o.getTransform(),o.setTransform(...i);let e=f(q,this,Rl).call(this,g,t,i);o.fill(e)}else o.fill(g);if(d===Oe.STROKE||d===Oe.FILL_STROKE)if(a){t||(t=o.getTransform()),o.setTransform(...a);let{a:e,b:n,c:r,d:i}=t,s=z.inverseTransform(a),c=z.transform([e,n,r,i,0,0],s);z.singularValueDecompose2dScale(c,sl),o.lineWidth*=Math.max(sl[0],sl[1])/u,o.stroke(f(q,this,Rl).call(this,g,t,a))}else o.lineWidth/=u,o.stroke(g);o.restore()}else{if(d===Oe.FILL||d===Oe.FILL_STROKE){var v;o.fillText(t,n,r),(v=this.dependencyTracker)==null||v.recordCharacterBBox(e,o,c,u,n,r,()=>o.measureText(t))}if(d===Oe.STROKE||d===Oe.FILL_STROKE){if(this.dependencyTracker){var y;(y=this.dependencyTracker)==null||y.recordCharacterBBox(e,o,c,u,n,r,()=>o.measureText(t)).recordDependencies(e,Bo.stroke)}o.strokeText(t,n,r)}}if(p){var b;(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:jt(o),x:n,y:r,fontSize:u,path:g}),(b=this.dependencyTracker)==null||b.recordCharacterBBox(e,o,c,u,n,r)}}get isFontSubpixelAAEnabled(){let e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1),t.fillText(`I`,0,10);let n=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let r=!1;for(let e=3;e<n.length;e+=4)if(n[e]>0&&n[e]<255){r=!0;break}return L(this,`isFontSubpixelAAEnabled`,r)}showText(e,t){var n;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(e,Bo.showText).resetBBox(e),this.current.textRenderingMode&Oe.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency(`textClip`,e).inheritPendingDependenciesAsFutureForcedDependencies());let r=this.current,i=r.font;if(i.isType3Font){var a;let n=f(q,this,Il).call(this,r.fillAlpha);this.showType3Text(e,t),(a=this.dependencyTracker)==null||a.recordShowTextOperation(e),f(q,this,Ll).call(this,n);return}let o=r.fontSize;if(o===0){var s;(s=this.dependencyTracker)==null||s.recordOperation(e);return}let c=f(q,this,Il).call(this,r.fillAlpha),l=this.ctx,u=r.fontSizeScale,d=r.charSpacing,p=r.wordSpacing,m=r.fontDirection,h=r.textHScale*m,g=t.length,_=i.vertical,v=_?1:-1,y=i.defaultVMetrics,b=o*r.fontMatrix[0],x=r.textRenderingMode===Oe.FILL&&!i.disableFontFace&&!r.patternFill;l.save(),r.textMatrix&&l.transform(...r.textMatrix),l.translate(r.x,r.y+r.textRise),m>0?l.scale(h,-1):l.scale(h,1);let S,C,w=r.textRenderingMode&Oe.FILL_STROKE_MASK,T=w===Oe.FILL||w===Oe.FILL_STROKE,E=w===Oe.STROKE||w===Oe.FILL_STROKE,D=r.lineWidth,O=r.textMatrixScale;if(O===0||D===0?E&&(D=this.getSinglePixelWidth()):D/=O,u!==1&&(l.scale(u,u),D/=u),l.lineWidth=D,T&&r.patternFill){l.save();let t=r.fillColor.getPattern(l,this,Mt(l),Gc.FILL,e);S=jt(l),l.restore(),l.fillStyle=t}if(E&&r.patternStroke){l.save();let t=r.strokeColor.getPattern(l,this,Mt(l),Gc.STROKE,e);C=jt(l),l.restore(),l.strokeStyle=t}if(i.isInvalidPDFjsFont){let n=[],i=0;for(let e of t)n.push(e.unicode),i+=e.width;let a=n.join(``);if(l.fillText(a,0,0),this.dependencyTracker!==null){let t=l.measureText(a);this.dependencyTracker.recordBBox(e,this.ctx,-t.actualBoundingBoxLeft,t.actualBoundingBoxRight,-t.actualBoundingBoxAscent,t.actualBoundingBoxDescent).recordShowTextOperation(e)}r.x+=i*b*h,l.restore(),this.compose(),f(q,this,Ll).call(this,c);return}let k=0,A;for(A=0;A<g;++A){let n=t[A];if(typeof n==`number`){k+=v*n*o/1e3;continue}let r=!1,a=(n.isSpace?p:0)+d,s=n.fontChar,c=n.accent,f,h,g=n.width;if(_){let e=n.vmetric||y,t=-(n.vmetric?e[1]:g*.5)*b,r=e[2]*b;g=e?-e[0]:g,f=t/u,h=(k+r)/u}else f=k/u,h=0;let w;if(i.remeasure&&g>0){w=l.measureText(s);let e=w.width*1e3/o*u;if(g<e&&this.isFontSubpixelAAEnabled){let t=g/e;r=!0,l.save(),l.scale(t,1),f/=t}else g!==e&&(f+=(g-e)/2e3*o/u)}if(this.contentVisible&&(n.isInFont||i.missingFile)){if(x&&!c){var ee;l.fillText(s,f,h),(ee=this.dependencyTracker)==null||ee.recordCharacterBBox(e,l,w?{bbox:null}:i,o/u,f,h,()=>{var e;return(e=w)==null?l.measureText(s):e})}else if(this.paintChar(e,s,f,h,S,C),c){let t=f+o*c.offset.x/u,n=h-o*c.offset.y/u;this.paintChar(e,c.fontChar,t,n,S,C)}}let T=_?g*b-a*m:g*b+a*m;k+=T,r&&l.restore()}_?r.y-=k:r.x+=k*h,l.restore(),this.compose(),(n=this.dependencyTracker)==null||n.recordShowTextOperation(e),f(q,this,Ll).call(this,c)}showType3Text(e,t){let n=this.ctx,r=this.current,i=r.font,a=r.fontSize,o=r.fontDirection,s=i.vertical?1:-1,c=r.charSpacing,l=r.wordSpacing,u=r.textHScale*o,d=r.fontMatrix||be,f=t.length,p=r.textRenderingMode===Oe.INVISIBLE,m,h,g,_;if(p||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,n.save(),r.textMatrix&&n.transform(...r.textMatrix),n.translate(r.x,r.y+r.textRise),n.scale(u,o);let v=this.dependencyTracker;for(this.dependencyTracker=v?new zo(v,e):null,m=0;m<f;++m){if(h=t[m],typeof h==`number`){_=s*h*a/1e3,this.ctx.translate(_,0),r.x+=_*u;continue}let e=(h.isSpace?l:0)+c,o=i.charProcOperatorList[h.operatorListId];o?this.contentVisible&&(this.save(),o.fnArray[0]===P.setCharWidth&&(r.fillAlpha=r.strokeAlpha=1,n.globalAlpha=1),n.scale(a,a),n.transform(...d),this.executeOperatorList(o),this.restore()):F(`Type3 character "${h.operatorListId}" is not available.`);let f=[h.width,0];z.applyTransform(f,d),g=f[0]*a+e,n.translate(g,0),r.x+=g*u}n.restore(),v&&(this.dependencyTracker=v)}setCharWidth(e,t,n){}setCharWidthAndBounds(e,t,n,r,i,a,o){var s;let c=new Path2D;c.rect(r,i,a-r,o-i),this.ctx.clip(c),(s=this.dependencyTracker)==null||s.recordBBox(e,this.ctx,r,a,i,o).recordClipBox(e,this.ctx,r,a,i,o),this.endPath(e)}getColorN_Pattern(t,n){let r;if(n[0]===`TilingPattern`){let t=this.baseTransform||jt(this.ctx);r=new el(n,this.ctx,{createCanvasGraphics:(t,n)=>new e(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new zo(this.dependencyTracker,n,!0):null)},t)}else r=this._getPattern(t,n[1],n[2]);return r}setStrokeColorN(e,...t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`strokeColor`,e),this.current.strokeColor=this.getColorN_Pattern(e,t),this.current.patternStroke=!0}setFillColorN(e,...t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`fillColor`,e);let r=this.current.fillColor=this.getColorN_Pattern(e,t);this.current.patternFill=!0,this.current.tilingPatternDims=r instanceof el?[0,0,0,0]:null}setStrokeRGBColor(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`strokeColor`,e),this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(e){var t;(t=this.dependencyTracker)==null||t.recordSimpleData(`strokeColor`,e),this.ctx.strokeStyle=this.current.strokeColor=`transparent`,this.current.patternStroke=!1}setFillRGBColor(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`fillColor`,e),this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(e){var t;(t=this.dependencyTracker)==null||t.recordSimpleData(`fillColor`,e),this.ctx.fillStyle=this.current.fillColor=`transparent`,this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(e,t,n=null){let r;return this.cachedPatterns.has(t)?r=this.cachedPatterns.get(t):(r=Qc(this.getObject(e,t)),this.cachedPatterns.set(t,r)),n&&(r.matrix=n),r}shadingFill(e,t){var n;if(!this.contentVisible)return;let r=f(q,this,Il).call(this,this.current.fillAlpha),i=this.ctx;this.save(e),i.fillStyle=this._getPattern(e,t).getPattern(i,this,Mt(i),Gc.SHADING,e);let a=Mt(i);if(a){let{width:e,height:t}=i.canvas,n=ye.slice();z.axialAlignedBoundingBox([0,0,e,t],a,n);let[r,o,s,c]=n;this.ctx.fillRect(r,o,s-r,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(n=this.dependencyTracker)==null||n.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,Bo.transform).recordDependencies(e,Bo.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e),f(q,this,Ll).call(this,r)}beginInlineImage(){I(`Should not call beginInlineImage`)}beginImageData(){I(`Should not call beginImageData`)}paintFormXObjectBegin(e,t,n){if(this.contentVisible&&(this.save(e),this.baseTransformStack.push(this.baseTransform),t&&this.transform(e,...t),this.baseTransform=jt(this.ctx),n)){var r;z.axialAlignedBoundingBox(n,this.baseTransform,this.current.minMax);let[t,i,a,o]=n,s=new Path2D;s.rect(t,i,a-t,o-i),this.ctx.clip(s),(r=this.dependencyTracker)==null||r.recordClipBox(e,this.ctx,t,a,i,o),this.endPath(e)}}paintFormXObjectEnd(e){this.contentVisible&&(this.restore(e),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e,t){var n;if(!this.contentVisible)return;this.save(e);let{inSMaskMode:r}=this;r&&(this.endSMaskMode(),this.current.activeSMask=null);let i=this.ctx;if((!t.needsIsolation||!t.isolated&&!t.hasSoftMask)&&!t.knockout&&!t.isGray&&x(bl,this)===0&&i.globalAlpha===1&&i.globalCompositeOperation===`source-over`&&!r){if(t.bbox){let e=new Path2D,[n,r,a,o]=t.bbox;if(e.rect(n,r,a-n,o-r),t.matrix){let n=new Path2D;n.addPath(e,new DOMMatrix(t.matrix)),e=n}i.clip(e)}this.groupStack.push(null),x(kl,this).push(null),this.groupLevel++;return}!t.isolated&&!t.knockout&&x(bl,this)===0&&Re(`TODO: Fully support non-isolated non-knockout groups.`);let a=jt(i);t.matrix&&i.transform(...t.matrix);let o=[0,0,i.canvas.width,i.canvas.height],s;t.bbox?(s=ye.slice(),z.axialAlignedBoundingBox(t.bbox,jt(i),s),s=z.intersect(s,o)||[0,0,0,0]):s=o;let c=Math.floor(s[0]),l=Math.floor(s[1]),u=Math.max(Math.ceil(s[2])-c,1),d=Math.max(Math.ceil(s[3])-l,1);this.current.startNewPathAndClipBox([0,0,u,d]);let f=this.canvasFactory.create(u,d);t.smask&&this.smaskGroupCanvases.push(f);let p=f.context,m=t.knockout&&!t.isolated?i:null,h=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&x(bl,this)>0,g=t.knockout?this.canvasFactory.create(u,d):null,_=x(bl,this);if(t.knockout){var v;C(bl,this,(v=x(bl,this),v++,v))}else C(bl,this,0);if(p.translate(-c,-l),p.transform(...a),!t.isolated&&!t.smask&&r&&t.needsIsolation&&(p.save(),p.setTransform(1,0,0,1,0,0),p.drawImage(i.canvas,-c,-l),p.restore()),t.bbox){let e=new Path2D,[n,r,i,a]=t.bbox;if(e.rect(n,r,i-n,a-r),t.matrix){let n=new Path2D;n.addPath(e,new DOMMatrix(t.matrix)),e=n}p.clip(e)}t.smask&&this.smaskStack.push({canvas:f.canvas,context:p,offsetX:c,offsetY:l,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null}),(!t.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(c,l),i.save()),pl(i,p),this.ctx=p,(n=this.dependencyTracker)==null||n.inheritSimpleDataAsFutureForcedDependencies([`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`]).pushBaseTransform(i),this.setGState(e,[[`BM`,`source-over`],[`ca`,1],[`CA`,1],[`TR`,null]]),this.groupStack.push(i),x(kl,this).push({backdropCtx:m,savedKnockoutLevel:_,offsetX:c,offsetY:l,hasInnerBackdrop:h,knockoutMaskEntry:g,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(e,t){var n;if(!this.contentVisible)return;this.groupLevel--;let r=this.ctx,i=this.groupStack.pop(),a=x(kl,this).pop();if(a&&C(bl,this,a.savedKnockoutLevel),i===null){this.restore(e);return}if(t.isGray&&f(q,this,zl).call(this,r),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(n=this.dependencyTracker)==null||n.popBaseTransform(),t.smask)this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),f(q,this,Bl).call(this,a);else{this.ctx.restore();let t=jt(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...t);let n=ye.slice();z.axialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],t,n);let c=x(kl,this).at(-1);if(x(bl,this)>0)if(a.hasInnerBackdrop){let{width:e,height:n}=r.canvas,o=this.canvasFactory.create(e,n),s=o.context;s.drawImage(i.canvas,a.offsetX,a.offsetY,e,n,0,0,e,n),s.globalCompositeOperation=`source-over`,s.drawImage(r.canvas,0,0);let c=f(q,this,Nl).call(this,r.canvas);s.globalCompositeOperation=`destination-in`,s.drawImage(c.canvas,0,0);let l=this.ctx.globalCompositeOperation,u=this.ctx.globalAlpha,d=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...t),this.ctx.globalAlpha=1,R.isCanvasFilterSupported&&(this.ctx.filter=`none`),this.ctx.globalCompositeOperation=`destination-out`,this.ctx.drawImage(c.canvas,0,0),this.ctx.globalCompositeOperation=l,this.ctx.globalAlpha=u,R.isCanvasFilterSupported&&(this.ctx.filter=d==null?`none`:d),this.ctx.drawImage(o.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(c),this.canvasFactory.destroy(o)}else{var o,s;let e=(o=c==null?void 0:c.backdropCtx)==null?null:o;f(q,this,Fl).call(this,this.ctx,r.canvas,{backdropCanvas:(s=e==null?void 0:e.canvas)==null?null:s,destTransform:t,backdropOffset:e?[c.offsetX+a.offsetX,c.offsetY+a.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(r.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:r.canvas,context:r}),f(q,this,Bl).call(this,a),this.compose(n)}}beginAnnotation(e,t,n,r,i,a,o){if(f(q,this,jl).call(this),ml(this.ctx),this.ctx.save(),this.save(e),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),n){let i=n[2]-n[0],s=n[3]-n[1];if(a&&this.annotationCanvasMap){r=r.slice(),r[4]-=n[0],r[5]-=n[1],n=n.slice(),n[0]=n[1]=0,n[2]=i,n[3]=s,z.singularValueDecompose2dScale(jt(this.ctx),sl);let{viewportScale:e}=this,a=Math.ceil(i*this.outputScaleX*e),c=Math.ceil(s*this.outputScaleY*e);this.annotationCanvas=this.canvasFactory.create(a,c);let{canvas:l,context:u}=this.annotationCanvas;if(o){let e=this.annotationCanvasMap.getOrInsertComputed(t,st);l.setAttribute(`data-canvas-name`,o);let n=e.findIndex(e=>e.getAttribute(`data-canvas-name`)===o);n===-1?e.push(l):e[n]=l}else this.annotationCanvasMap.set(t,l);this.annotationCanvas.savedCtx=this.ctx,this.ctx=u,this.ctx.save(),this.ctx.setTransform(sl[0],0,0,-sl[1],0,s*sl[1]),ml(this.ctx)}else{ml(this.ctx),this.endPath(e);let t=new Path2D;t.rect(n[0],n[1],i,s),this.ctx.clip(t)}}this.current=new ul(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(e,...r),this.transform(e,...i),this.baseTransform=jt(this.ctx)}endAnnotation(e){this.annotationCanvas&&(this.ctx.restore(),f(q,this,Ml).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(e,t){var n;if(!this.contentVisible)return;let r=t.count;t=this.getObject(e,t.data,t),t.count=r;let i=f(q,this,Il).call(this,this.current.fillAlpha),a=this.ctx,o=this._createMaskCanvas(e,t),s=o.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(s,o.offsetX,o.offsetY),(n=this.dependencyTracker)==null||n.resetBBox(e).recordBBox(e,this.ctx,o.offsetX,o.offsetX+s.width,o.offsetY,o.offsetY+s.height).recordOperation(e),a.restore(),o.canvasEntry&&this.canvasFactory.destroy(o.canvasEntry),this.compose(),f(q,this,Ll).call(this,i)}paintImageMaskXObjectRepeat(e,t,n,r=0,i=0,a,o){var s,c;if(!this.contentVisible)return;t=this.getObject(e,t.data,t);let l=f(q,this,Il).call(this,this.current.fillAlpha),u=this.ctx;u.save();let d=jt(u);u.transform(n,r,i,a,0,0);let p=this._createMaskCanvas(e,t);u.setTransform(1,0,0,1,p.offsetX-d[4],p.offsetY-d[5]),(s=this.dependencyTracker)==null||s.resetBBox(e);for(let t=0,s=o.length;t<s;t+=2){var m;let s=z.transform(d,[n,r,i,a,o[t],o[t+1]]);u.drawImage(p.canvas,s[4],s[5]),(m=this.dependencyTracker)==null||m.recordBBox(e,this.ctx,s[4],s[4]+p.canvas.width,s[5],s[5]+p.canvas.height)}u.restore(),p.canvasEntry&&this.canvasFactory.destroy(p.canvasEntry),this.compose(),(c=this.dependencyTracker)==null||c.recordOperation(e),f(q,this,Ll).call(this,l)}paintImageMaskXObjectGroup(e,t){var n,r;if(!this.contentVisible)return;let i=f(q,this,Il).call(this,this.current.fillAlpha),a=this.ctx,o=this.current.fillColor,s=this.current.patternFill;(n=this.dependencyTracker)==null||n.resetBBox(e).recordDependencies(e,Bo.transformAndFill);for(let n of t){var c;let{data:t,width:r,height:i,transform:l}=n,u=this.canvasFactory.create(r,i),d=u.context;d.save(),fl(d,this.getObject(e,t,n)),d.globalCompositeOperation=`source-in`,d.fillStyle=s?o.getPattern(d,this,Mt(a),Gc.FILL,e):o,d.fillRect(0,0,r,i),d.restore(),a.save(),a.transform(...l),a.scale(1,-1),ll(a,u.canvas,0,0,r,i,0,-1,1,1),this.canvasFactory.destroy(u),(c=this.dependencyTracker)==null||c.recordBBox(e,a,0,r,0,i),a.restore()}this.compose(),(r=this.dependencyTracker)==null||r.recordOperation(e),f(q,this,Ll).call(this,i)}paintImageXObject(e,t){if(!this.contentVisible)return;let n=this.getObject(e,t);if(!n){F(`Dependent image isn't ready yet`);return}this.paintInlineImageXObject(e,n)}paintImageXObjectRepeat(e,t,n,r,i){if(!this.contentVisible)return;let a=this.getObject(e,t);if(!a){F(`Dependent image isn't ready yet`);return}let o=a.width,s=a.height,c=[];for(let e=0,t=i.length;e<t;e+=2)c.push({transform:[n,0,0,r,i[e],i[e+1]],x:0,y:0,w:o,h:s});this.paintInlineImageXObjectGroup(e,a,c)}applyTransferMapsToCanvas(e){return this.current.transferMaps!==`none`&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter=`none`),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps===`none`)return{img:e.bitmap,canvasEntry:null};let{bitmap:t,width:n,height:r}=e,i=this.canvasFactory.create(n,r),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter=`none`,{img:i.canvas,canvasEntry:i}}paintInlineImageXObject(e,t){if(!this.contentVisible)return;let n=t.width,r=t.height,i=f(q,this,Il).call(this,this.current.fillAlpha),a=this.ctx;this.save(e);let{filter:o}=a;o!==`none`&&o!==``&&(a.filter=`none`),a.scale(1/n,-1/r);let s,c=null;if(t.bitmap){let e=this.applyTransferMapsToBitmap(t);s=e.img,c=e.canvasEntry}else{let e=this.canvasFactory.create(n,r);dl(e.context,t),s=this.applyTransferMapsToCanvas(e.context),c=e}let l=this._scaleImage(s,Mt(a));if(a.imageSmoothingEnabled=hl(jt(a),t.interpolate),this.dependencyTracker){var u;this.dependencyTracker.resetBBox(e).recordBBox(e,a,0,n,-r,0).recordDependencies(e,Bo.imageXObject).recordOperation(e),(u=this.imagesTracker)==null||u.record(a,n,r,this.dependencyTracker.clipBox)}ll(a,l.img,0,0,l.paintWidth,l.paintHeight,0,-r,n,r),l.tmpCanvas&&this.canvasFactory.destroy(l.tmpCanvas),c&&this.canvasFactory.destroy(c),this.compose(),this.restore(e),f(q,this,Ll).call(this,i)}paintInlineImageXObjectGroup(e,t,n){var r,i;if(!this.contentVisible)return;let a=f(q,this,Il).call(this,this.current.fillAlpha),o=this.ctx,s,c=null;if(t.bitmap)s=t.bitmap;else{let e=t.width,n=t.height,r=this.canvasFactory.create(e,n);dl(r.context,t),s=this.applyTransferMapsToCanvas(r.context),c=r}(r=this.dependencyTracker)==null||r.resetBBox(e);for(let t of n){var l;o.save(),o.transform(...t.transform),o.scale(1,-1),ll(o,s,t.x,t.y,t.w,t.h,0,-1,1,1),(l=this.dependencyTracker)==null||l.recordBBox(e,o,0,1,-1,0),o.restore()}c&&this.canvasFactory.destroy(c),(i=this.dependencyTracker)==null||i.recordOperation(e),this.compose(),f(q,this,Ll).call(this,a)}paintSolidColorImageMask(e){var t;if(!this.contentVisible)return;let n=f(q,this,Il).call(this,this.current.fillAlpha);(t=this.dependencyTracker)==null||t.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,Bo.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose(),f(q,this,Ll).call(this,n)}markPoint(e,t){}markPointProps(e,t,n){}beginMarkedContent(e,t){var n;(n=this.dependencyTracker)==null||n.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,n){var r;(r=this.dependencyTracker)==null||r.beginMarkedContent(e),t===`OC`?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(n)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(e){var t;(t=this.dependencyTracker)==null||t.endMarkedContent(e),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,t,n){let r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(n);let i=this.ctx;if(this.pendingClip){var a;r||(this.pendingClip===yl?i.clip(t,`evenodd`):i.clip(t)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(e).recordFutureForcedDependency(`clipPath`,e)}else{var o;(o=this.dependencyTracker)==null||o.recordOperation(e)}this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=jt(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:n,c:r,d:i}=this.ctx.getTransform(),a,o;if(n===0&&r===0){let n=Math.abs(t),r=Math.abs(i);if(n===r)if(e===0)a=o=1/n;else{let t=n*e;a=o=t<1?1/t:1}else if(e===0)a=1/n,o=1/r;else{let t=n*e,i=r*e;a=t<1?1/t:1,o=i<1?1/i:1}}else{let s=Math.abs(t*i-n*r),c=Math.hypot(t,n),l=Math.hypot(r,i);if(e===0)a=l/s,o=c/s;else{let t=e*s;a=l>t?l/t:1,o=c>t?c/t:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,t){let{ctx:n,current:{lineWidth:r}}=this,[i,a]=this.getScaleForStroking();if(i===a){n.lineWidth=(r||1)*i,n.stroke(e);return}let o=n.getLineDash();t&&n.save(),n.scale(i,a),ol.a=1/i,ol.d=1/a;let s=new Path2D;if(s.addPath(e,ol),o.length>0){let e=Math.max(i,a);n.setLineDash(o.map(t=>t/e)),n.lineDashOffset/=e}n.lineWidth=r||1,n.stroke(s),t&&n.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};function jl(){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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}function Ml(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!==`none`){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}function Nl(e,t=null,n=1){let{width:r,height:i}=e,a=t==null?this.canvasFactory.create(r,i):t,o=a.context;n=Math.round(n*255)/255;let s=n<1;s&&x(Dl,this)===void 0&&C(Dl,this,R.isCanvasFilterSupported?new Map:`none`);let c=`none`;if(s&&x(Dl,this)instanceof Map&&(c=x(Dl,this).getOrInsertComputed(n,()=>this.filterFactory.addKnockoutFilter(n))),!s||c!==`none`)return t&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,r,i),o.restore()),o.filter=c,o.drawImage(e,0,0),o.filter=`none`,a;let l=e.getContext(`2d`,{willReadFrequently:!0}).getImageData(0,0,r,i),u=o.createImageData(r,i),d=l.data,f=u.data,p=n>0?1/n:1e6;for(let e=3,t=d.length;e<t;e+=4)f[e]=Math.min(Math.round(d[e]*p),255);return o.putImageData(u,0,0),a}function Pl(e,t,n,r){var i;let a=(i=e==null?void 0:e[t])==null?null:i;if(a&&(a.canvas.width!==n||a.canvas.height!==r)&&(this.canvasFactory.destroy(a),a=null),!a)return a=this.canvasFactory.create(n,r),e&&(e[t]=a),a;let o=a.context;return o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,n,r),o.restore(),a}function Fl(e,t,n={}){let{backdropCanvas:r=null,destTransform:i=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:s=null,sourceAlpha:c=1,sourceFilter:l=`none`,knockoutAlpha:u=1}=n,{width:d,height:p}=t,m=f(q,this,Nl).call(this,t,o,u),h=e.globalCompositeOperation;if(e.save(),e.setTransform(...i),e.globalAlpha=1,R.isCanvasFilterSupported&&(e.filter=`none`),e.globalCompositeOperation=`destination-out`,e.drawImage(m.canvas,0,0),r){let[t,n]=a,i=f(q,this,Pl).call(this,s,`knockoutBackdropEntry`,d,p),o=i.context;o.drawImage(r,t,n,d,p,0,0,d,p),o.globalCompositeOperation=`destination-in`,o.drawImage(m.canvas,0,0),o.globalCompositeOperation=`source-over`,e.globalCompositeOperation=`destination-over`,e.drawImage(i.canvas,0,0),s||this.canvasFactory.destroy(i)}e.globalCompositeOperation=h,e.globalAlpha=c,R.isCanvasFilterSupported&&(e.filter=l==null?`none`:l),e.drawImage(t,0,0),e.restore(),o||this.canvasFactory.destroy(m)}function Il(e=1){var t;if(x(bl,this)===0||x(xl,this)>0||!this.contentVisible)return!1;C(xl,this,(t=x(xl,this),t++,t)),C(El,this,e);let n=x(kl,this).at(-1),{canvas:r}=this.ctx,i=f(q,this,Pl).call(this,n,`knockoutTempEntry`,r.width,r.height);C(Sl,this,i);let a=i.context;return a.save(),a.setTransform(this.ctx.getTransform()),pl(this.ctx,a),C(Tl,this,a.globalCompositeOperation),a.globalCompositeOperation=`source-over`,cl(a,this.ctx),C(Ol,this,n),C(Cl,this,this.ctx),C(wl,this,this.suspendedCtx),this.ctx=a,this.inSMaskMode&&(this.suspendedCtx=a),!0}function Ll(e){if(!e)return;let t=x(Sl,this),n=x(Cl,this),r=x(wl,this),i=t.context;C(Sl,this,null),C(Cl,this,null),C(wl,this,null),this.inSMaskMode&&this.suspendedCtx===i&&this.ctx!==i&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=r),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=x(Tl,this),C(Tl,this,null),pl(this.ctx,n),this.ctx=n;let a=x(Ol,this);C(Ol,this,null);let o=x(El,this);C(El,this,1);try{var s,c,l;f(q,this,Fl).call(this,r==null?n:r,t.canvas,{backdropCanvas:(s=a==null||(c=a.backdropCtx)==null?void 0:c.canvas)==null?null:s,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(l=a==null?void 0:a.knockoutMaskEntry)==null?null:l,poolMeta:a,knockoutAlpha:o})}finally{var u;i.restore(),C(xl,this,(u=x(xl,this),u--,u)),a||this.canvasFactory.destroy(t)}}function Rl(e,t,n){let r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}function zl(e){let{canvas:t}=e,{width:n,height:r}=t;if(R.isCanvasFilterSupported){e.save(),e.setTransform(1,0,0,1,0,0),e.filter=`grayscale(1)`,e.globalAlpha=1,e.globalCompositeOperation=`copy`,e.drawImage(t,0,0),e.restore();return}let i=e.getImageData(0,0,n,r),{data:a}=i;for(let e=0,t=a.length;e<t;e+=4){let t=a[e]*.2126+a[e+1]*.7152+a[e+2]*.0722+.5|0;a[e]=a[e+1]=a[e+2]=t}e.putImageData(i,0,0)}function Bl(e){e&&(e.knockoutMaskEntry&&(this.canvasFactory.destroy(e.knockoutMaskEntry),e.knockoutMaskEntry=null),e.knockoutTempEntry&&(this.canvasFactory.destroy(e.knockoutTempEntry),e.knockoutTempEntry=null),e.knockoutBackdropEntry&&(this.canvasFactory.destroy(e.knockoutBackdropEntry),e.knockoutBackdropEntry=null))}for(let e in P)Al.prototype[e]!==void 0&&(Al.prototype[P[e]]=Al.prototype[e]);var Vl=new WeakMap,Hl=new WeakMap,Ul=class{constructor(e,t,n){b(this,Vl,null),b(this,Hl,null),g(this,`_fullReader`,null),g(this,`_rangeReaders`,new Set),g(this,`_source`,null),this._source=e,C(Vl,this,t),C(Hl,this,n)}get _progressiveDataLength(){var e,t;return(e=(t=this._fullReader)==null?void 0:t._loaded)==null?0:e}getFullReader(){return ze(!this._fullReader,`BasePDFStream.getFullReader can only be called once.`),this._fullReader=new(x(Vl,this))(this)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new(x(Hl,this))(this,e,t);return this._rangeReaders.add(n),n}cancelAllRequests(e){var t;(t=this._fullReader)==null||t.cancel(e);for(let t of new Set(this._rangeReaders))t.cancel(e)}},Wl=class{constructor(e){g(this,`onProgress`,null),g(this,`_contentLength`,0),g(this,`_filename`,null),g(this,`_headersCapability`,Promise.withResolvers()),g(this,`_isRangeSupported`,!1),g(this,`_isStreamingSupported`,!1),g(this,`_loaded`,0),g(this,`_stream`,null),this._stream=e}_callOnProgress(){var e;(e=this.onProgress)==null||e.call(this,{loaded:this._loaded,total:this._contentLength})}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}read(){return v(function*(){I("Abstract method `read` called")})()}cancel(e){I("Abstract method `cancel` called")}},Gl=class{constructor(e,t,n){g(this,`_stream`,null),this._stream=e}read(){return v(function*(){I("Abstract method `read` called")})()}cancel(e){I("Abstract method `cancel` called")}};function Kl(e){let t=!0,n=r(`filename\\*`,`i`).exec(e);if(n){n=n[1];let e=s(n);return e=unescape(e),e=c(e),e=l(e),a(e)}if(n=o(e),n)return a(l(n));if(n=r(`filename`,`i`).exec(e),n){n=n[1];let e=s(n);return e=l(e),a(e)}function r(e,t){return RegExp(`(?:^|;)\\s*`+e+`\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)`,t)}function i(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let r=new TextDecoder(e,{fatal:!0}),i=Qe(n);n=r.decode(i),t=!1}catch(e){}}return n}function a(e){return t&&/[\x80-\xff]/.test(e)&&(e=i(`utf-8`,e),t&&(e=i(`iso-8859-1`,e))),e}function o(e){let t=[],n,i=r(`filename\\*((?!0\\d)\\d+)(\\*?)`,`ig`);for(;(n=i.exec(e))!==null;){let[,e,r,i]=n;if(e=parseInt(e,10),e in t){if(e===0)break;continue}t[e]=[r,i]}let a=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=s(r),n&&(r=unescape(r),e===0&&(r=c(r))),a.push(r)}return a.join(``)}function s(e){if(e.startsWith(`"`)){let t=e.slice(1).split(`\\"`);for(let e=0;e<t.length;++e){let n=t[e].indexOf(`"`);n!==-1&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,`$1`)}e=t.join(`"`)}return e}function c(e){let t=e.indexOf(`'`);return t===-1?e:i(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,``))}function l(e){return!e.startsWith(`=?`)||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(e,t,n,r){if(n===`q`||n===`Q`)return r=r.replaceAll(`_`,` `),r=r.replaceAll(/=([0-9a-f]{2})/gi,function(e,t){return String.fromCharCode(parseInt(t,16))}),i(t,r);try{r=atob(r)}catch(e){}return i(t,r)})}return``}function ql(e,t){let n=new Headers;if(!e||!t||typeof t!=`object`)return n;for(let e in t){let r=t[e];r!==void 0&&n.append(e,r)}return n}function Jl(e){var t,n;return(t=(n=URL.parse(e))==null?void 0:n.origin)==null?null:t}function Yl({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){let i={contentLength:0,isRangeSupported:!1},a=parseInt(e.get(`Content-Length`),10);return!Number.isInteger(a)||(i.contentLength=a,a<=2*n)||r||!t||e.get(`Accept-Ranges`)!==`bytes`||(e.get(`Content-Encoding`)||`identity`)===`identity`&&(i.isRangeSupported=!0),i}function Xl(e){let t=e.get(`Content-Disposition`);if(t){let e=Kl(t);if(e.includes(`%`))try{e=decodeURIComponent(e)}catch(e){}if(vt(e))return e}return null}function Zl(e,t){return new Je(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,e===404||e===0&&t.protocol===`file:`)}function Ql(e,t){if(e!==t)throw Error(`Expected range response-origin "${e}" to match "${t}".`)}function $l(e,t,n,r){return fetch(e,{method:`GET`,headers:t,signal:r.signal,mode:`cors`,credentials:n?`include`:`same-origin`,redirect:`follow`})}function eu(e,t){if(e!==200&&e!==206)throw Zl(e,t)}function tu(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw Error(`getArrayBuffer - unexpected data: ${e}`)}var nu=class extends Ul{constructor(e){super(e,ru,iu),g(this,`_responseOrigin`,null);let{httpHeaders:t,url:n}=e;ze(/https?:/.test(n.protocol),`PDFFetchStream only supports http(s):// URLs.`),this.headers=ql(!0,t)}},ru=class extends Wl{constructor(e){super(e),g(this,`_abortController`,new AbortController),g(this,`_reader`,null);let{disableRange:t,disableStream:n,rangeChunkSize:r,url:i,withCredentials:a}=e._source;this._isStreamingSupported=!n,$l(i,new Headers(e.headers),a,this._abortController).then(n=>{e._responseOrigin=Jl(n.url),eu(n.status,i),this._reader=n.body.getReader();let a=n.headers,{contentLength:o,isRangeSupported:s}=Yl({responseHeaders:a,isHttp:!0,rangeChunkSize:r,disableRange:t});this._contentLength=o,this._isRangeSupported=s,this._filename=Xl(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Xe(`Streaming is disabled.`)),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}read(){var e=this;return v(function*(){yield e._headersCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:(e._loaded+=t.byteLength,e._callOnProgress(),{value:tu(t),done:!1})})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}},iu=class extends Gl{constructor(e,t,n){super(e,t,n),g(this,`_abortController`,new AbortController),g(this,`_readCapability`,Promise.withResolvers()),g(this,`_reader`,null);let{url:r,withCredentials:i}=e._source,a=new Headers(e.headers);a.append(`Range`,`bytes=${t}-${n-1}`),$l(r,a,i,this._abortController).then(t=>{Ql(Jl(t.url),e._responseOrigin),eu(t.status,r),this._reader=t.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}read(){var e=this;return v(function*(){yield e._readCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:{value:tu(t),done:!1}})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}};function au(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function ou(){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}var su=new WeakSet,cu=class extends Ul{constructor(e){super(e,du,pu),S(this,su),g(this,`_progressiveDone`,!1),g(this,`_queuedChunks`,[]);let{pdfDataRangeTransport:t}=e,{initialData:n,progressiveDone:r}=t;if((n==null?void 0:n.length)>0){let e=au(n);this._queuedChunks.push(e)}this._progressiveDone=r,t.transportReady(e=>{switch(e.type){case`range`:case`progressiveRead`:f(su,this,lu).call(this,e.begin,e.chunk);break;case`progressiveDone`:var t;(t=this._fullReader)==null||t.progressiveDone(),this._progressiveDone=!0;break}})}getFullReader(){let e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,t){let n=super.getRangeReader(e,t);return n&&(n.onDone=()=>this._rangeReaders.delete(n),this._source.pdfDataRangeTransport.requestDataRange(e,t)),n}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}};function lu(e,t){let n=au(t);if(e===void 0)this._fullReader?this._fullReader._enqueue(n):this._queuedChunks.push(n);else{let t=this._rangeReaders.keys().find(t=>t._begin===e);ze(t,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),t._enqueue(n)}}var uu=new WeakMap,du=class extends Wl{constructor(e){super(e),b(this,uu,ou.bind(this)),g(this,`_done`,!1),g(this,`_queuedChunks`,null),g(this,`_requests`,[]);let{pdfDataRangeTransport:t,disableRange:n,disableStream:r}=e._source,{length:i,contentDispositionFilename:a}=t;this._queuedChunks=e._queuedChunks||[];for(let e of this._queuedChunks)this._loaded+=e.byteLength;this._done=e._progressiveDone,this._contentLength=i,this._isStreamingSupported=!r,this._isRangeSupported=!n,vt(a)&&(this._filename=a),this._headersCapability.resolve();let o=this._loaded;Promise.resolve().then(()=>{o>0&&this._loaded===o&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}read(){var e=this;return v(function*(){if(e._queuedChunks.length>0)return{value:e._queuedChunks.shift(),done:!1};if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){this._done=!0,x(uu,this).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&x(uu,this).call(this)}},fu=new WeakMap,pu=class extends Gl{constructor(e,t,n){super(e,t,n),b(this,fu,ou.bind(this)),g(this,`onDone`,null),g(this,`_begin`,-1),g(this,`_done`,!1),g(this,`_queuedChunk`,null),g(this,`_requests`,[]),this._begin=t}_enqueue(e){var t;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),x(fu,this).call(this)),this._done=!0,(t=this.onDone)==null||t.call(this))}read(){var e=this;return v(function*(){if(e._queuedChunk){let t=e._queuedChunk;return e._queuedChunk=null,{value:t,done:!1}}if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){var t;this._done=!0,x(fu,this).call(this),(t=this.onDone)==null||t.call(this)}},mu=200,hu=206;function gu(e){return typeof e==`string`?Qe(e).buffer:e}var _u=new WeakMap,vu=new WeakSet,yu=class extends Ul{constructor(e){super(e,wu,ju),S(this,vu),b(this,_u,new WeakMap),g(this,`_responseOrigin`,null);let{httpHeaders:t,url:n}=e;this.url=n,this.isHttp=/https?:/.test(n.protocol),this.headers=ql(this.isHttp,t)}_request(e){let t=new XMLHttpRequest,n={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};x(_u,this).set(t,n),t.open(`GET`,this.url),t.withCredentials=this._source.withCredentials;for(let[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&`begin`in e&&`end`in e?(t.setRequestHeader(`Range`,`bytes=${e.begin}-${e.end-1}`),n.validateStatus=e=>e===hu||e===mu):n.validateStatus=e=>e===mu,t.responseType=`arraybuffer`,ze(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>e.onError(t.status),t.onreadystatechange=f(vu,this,xu).bind(this,t),t.onprogress=f(vu,this,bu).bind(this,t),t.send(null),t}_abortRequest(e){x(_u,this).has(e)&&(x(_u,this).delete(e),e.abort())}getRangeReader(e,t){let n=super.getRangeReader(e,t);return n&&(n.onClosed=()=>this._rangeReaders.delete(n)),n}};function bu(e,t){var n;let r=x(_u,this).get(e);r==null||(n=r.onProgress)==null||n.call(r,t)}function xu(e,t){let n=x(_u,this).get(e);if(!n||(e.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),e.readyState!==4)||!x(_u,this).has(e))return;if(x(_u,this).delete(e),e.status===0&&this.isHttp){n.onError(e.status);return}let r=e.status||mu;if(!n.validateStatus(r)){n.onError(e.status);return}let i=gu(e.response);if(r===hu){let t=e.getResponseHeader(`Content-Range`);/bytes \d+-\d+\/\d+/.test(t)?n.onDone(i):(F(`Missing or invalid "Content-Range" header.`),n.onError(0))}else i?n.onDone(i):n.onError(e.status)}var Su=new WeakMap,Cu=new WeakSet,wu=class extends Wl{constructor(e){super(e),S(this,Cu),b(this,Su,ou.bind(this)),g(this,`_cachedChunks`,[]),g(this,`_done`,!1),g(this,`_requests`,[]),g(this,`_storedError`,null),this._fullRequestXhr=e._request({onHeadersReceived:f(Cu,this,Tu).bind(this),onDone:f(Cu,this,Eu).bind(this),onError:f(Cu,this,Du).bind(this),onProgress:f(Cu,this,Ou).bind(this)})}read(){var e=this;return v(function*(){if(yield e._headersCapability.promise,e._storedError)throw e._storedError;if(e._cachedChunks.length>0)return{value:e._cachedChunks.shift(),done:!1};if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){this._done=!0,this._headersCapability.reject(e),x(Su,this).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}};function Tu(){let e=this._stream,{disableRange:t,rangeChunkSize:n}=e._source,r=this._fullRequestXhr;e._responseOrigin=Jl(r.responseURL);let i=r.getAllResponseHeaders(),a=new Headers(i?i.trimStart().replace(/[^\S ]+$/,``).split(/[\r\n]+/).map(e=>{let[t,...n]=e.split(`: `);return[t,n.join(`: `)]}):[]),{contentLength:o,isRangeSupported:s}=Yl({responseHeaders:a,isHttp:e.isHttp,rangeChunkSize:n,disableRange:t});this._contentLength=o,this._isRangeSupported=s,this._filename=Xl(a),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()}function Eu(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&x(Su,this).call(this)}function Du(e){this._storedError=Zl(e,this._stream.url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}function Ou(e){var t;(t=this.onProgress)==null||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}var ku=new WeakMap,Au=new WeakSet,ju=class extends Gl{constructor(e,t,n){super(e,t,n),S(this,Au),b(this,ku,ou.bind(this)),g(this,`onClosed`,null),g(this,`_done`,!1),g(this,`_queuedChunk`,null),g(this,`_requests`,[]),g(this,`_storedError`,null),this._requestXhr=e._request({begin:t,end:n,onHeadersReceived:f(Au,this,Mu).bind(this),onDone:f(Au,this,Nu).bind(this),onError:f(Au,this,Pu).bind(this),onProgress:null})}read(){var e=this;return v(function*(){if(e._storedError)throw e._storedError;if(e._queuedChunk!==null){let t=e._queuedChunk;return e._queuedChunk=null,{value:t,done:!1}}if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){var t;this._done=!0,x(ku,this).call(this),this._stream._abortRequest(this._requestXhr),(t=this.onClosed)==null||t.call(this)}};function Mu(){var e;let t=Jl((e=this._requestXhr)==null?void 0:e.responseURL);try{Ql(t,this._stream._responseOrigin)}catch(e){this._storedError=e,f(Au,this,Pu).call(this,0)}}function Nu(e){var t;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,x(ku,this).call(this),(t=this.onClosed)==null||t.call(this)}function Pu(e){this._storedError!=null||(this._storedError=Zl(e,this._stream.url));for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}function Fu(e,t=null){let n=process.getBuiltinModule(`fs`),{Readable:r}=process.getBuiltinModule(`stream`),i=n.createReadStream(e,t);return r.toWeb(i)}var Iu=class extends Ul{constructor(e){super(e,Lu,Ru);let{url:t}=e;ze(t.protocol===`file:`,`PDFNodeStream only supports file:// URLs.`)}},Lu=class extends Wl{constructor(e){super(e),g(this,`_reader`,null);let{disableRange:t,disableStream:n,rangeChunkSize:r,url:i}=e._source;this._isStreamingSupported=!n,process.getBuiltinModule(`fs/promises`).lstat(i).then(e=>{let n=Fu(i);this._reader=n.getReader();let{size:a}=e;this._contentLength=a,this._isRangeSupported=!t&&a>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Xe(`Streaming is disabled.`)),this._headersCapability.resolve()}).catch(e=>{e.code===`ENOENT`&&(e=Zl(0,i)),this._headersCapability.reject(e)})}read(){var e=this;return v(function*(){yield e._headersCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:(e._loaded+=t.byteLength,e._callOnProgress(),{value:tu(t),done:!1})})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e)}},Ru=class extends Gl{constructor(e,t,n){super(e,t,n),g(this,`_readCapability`,Promise.withResolvers()),g(this,`_reader`,null);let{url:r}=e._source;try{let e=Fu(r,{start:t,end:n-1});this._reader=e.getReader(),this._readCapability.resolve()}catch(e){this._readCapability.reject(e)}}read(){var e=this;return v(function*(){yield e._readCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:{value:tu(t),done:!1}})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e)}};function zu(e){return Ct(e)?nu:_e?Iu:yu}var Bu=class e{static get workerPort(){return f(e,this,Vu)._}static set workerPort(t){if(!(typeof Worker<`u`&&t instanceof Worker)&&t!==null)throw Error("Invalid `workerPort` type.");Vu._=f(e,this,t)}static get workerSrc(){return f(e,this,Hu)._}static set workerSrc(t){if(typeof t!=`string`)throw Error("Invalid `workerSrc` type.");Hu._=f(e,this,t)}},Vu={_:null},Hu={_:``},Uu=new WeakMap,Wu=new WeakMap;me=Symbol.iterator;var Gu=class{constructor({parsedData:e,rawData:t}){b(this,Uu,void 0),b(this,Wu,void 0),C(Uu,this,e),C(Wu,this,t)}getRaw(){return x(Wu,this)}get(e){var t;return(t=x(Uu,this).get(e))==null?null:t}[me](){return x(Uu,this).entries()}},Ku=Symbol(`INTERNAL`),qu=new WeakMap,Ju=new WeakMap,Yu=new WeakMap,Xu=new WeakMap,Zu=class{constructor(e,{name:t,intent:n,usage:r,rbGroups:i}){b(this,qu,!1),b(this,Ju,!1),b(this,Yu,!1),b(this,Xu,!0),C(qu,this,!!(e&Ce.DISPLAY)),C(Ju,this,!!(e&Ce.PRINT)),this.name=t,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(x(Yu,this))return x(Xu,this);if(!x(Xu,this))return!1;let{print:e,view:t}=this.usage;return x(qu,this)?(t==null?void 0:t.viewState)!==`OFF`:!x(Ju,this)||(e==null?void 0:e.printState)!==`OFF`}_setVisible(e,t,n=!1){e!==Ku&&I("Internal method `_setVisible` called."),C(Yu,this,n),C(Xu,this,t)}get serializable(){return{userSet:x(Yu,this),visible:x(Xu,this)}}},Qu=new WeakMap,J=new WeakMap,$u=new WeakMap,ed=new WeakMap,td=new WeakMap,nd=new WeakSet;he=Symbol.iterator;var rd=class e{constructor(e,t=Ce.DISPLAY,n=null){if(S(this,nd),b(this,Qu,null),b(this,J,new Map),b(this,$u,null),b(this,ed,null),b(this,td,void 0),g(this,`creator`,null),g(this,`name`,null),C(td,this,e),this.renderingIntent=t,e!==null){this.name=e.name,this.creator=e.creator,C(ed,this,e.order);for(let n of e.groups)x(J,this).set(n.id,new Zu(t,n));if(n){n.size!==x(J,this).size&&I(`Incorrect serialized groupState.`);for(let[e,t]of n)x(J,this).get(e)._setVisible(Ku,t.visible,t.userSet)}else{if(e.baseState===`OFF`)for(let e of x(J,this).values())e._setVisible(Ku,!1);for(let t of e.on)x(J,this).get(t)._setVisible(Ku,!0);for(let t of e.off)x(J,this).get(t)._setVisible(Ku,!1)}C($u,this,this.getHash())}}isVisible(e){if(x(J,this).size===0)return!0;if(!e)return Re(`Optional content group not defined.`),!0;if(e.type===`OCG`)return x(J,this).has(e.id)?x(J,this).get(e.id).visible:(F(`Optional content group not found: ${e.id}`),!0);if(e.type===`OCMD`){if(e.expression)return f(nd,this,id).call(this,e.expression);if(!e.policy||e.policy===`AnyOn`){for(let t of e.ids){if(!x(J,this).has(t))return F(`Optional content group not found: ${t}`),!0;if(x(J,this).get(t).visible)return!0}return!1}else if(e.policy===`AllOn`){for(let t of e.ids){if(!x(J,this).has(t))return F(`Optional content group not found: ${t}`),!0;if(!x(J,this).get(t).visible)return!1}return!0}else if(e.policy===`AnyOff`){for(let t of e.ids){if(!x(J,this).has(t))return F(`Optional content group not found: ${t}`),!0;if(!x(J,this).get(t).visible)return!0}return!1}else if(e.policy===`AllOff`){for(let t of e.ids){if(!x(J,this).has(t))return F(`Optional content group not found: ${t}`),!0;if(x(J,this).get(t).visible)return!1}return!0}return F(`Unknown optional content policy ${e.policy}.`),!0}return F(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){let r=x(J,this).get(e);if(!r){F(`Optional content group not found: ${e}`);return}if(n&&t&&r.rbGroups.length){for(let t of r.rbGroups)for(let n of t)if(n!==e){var i;(i=x(J,this).get(n))==null||i._setVisible(Ku,!1,!0)}}r._setVisible(Ku,!!t,!0),C(Qu,this,null)}setOCGState({state:e,preserveRB:t}){let n;for(let r of e){switch(r){case`ON`:case`OFF`:case`Toggle`:n=r;continue}let e=x(J,this).get(r);if(e)switch(n){case`ON`:this.setVisibility(r,!0,t);break;case`OFF`:this.setVisibility(r,!1,t);break;case`Toggle`:this.setVisibility(r,!e.visible,t);break}}C(Qu,this,null)}get hasInitialVisibility(){return x($u,this)===null||this.getHash()===x($u,this)}getOrder(){return x(J,this).size?x(ed,this)?x(ed,this).slice():[...x(J,this).keys()]:null}getGroup(e){return x(J,this).get(e)||null}getHash(){if(x(Qu,this)!==null)return x(Qu,this);let e=new Ja;for(let[t,n]of x(J,this))e.update(`${t}:${n.visible}`);return C(Qu,this,e.hexdigest())}[he](){return x(J,this).entries()}get serializable(){let e=new Map;for(let[t,n]of x(J,this))e.set(t,n.serializable);return{data:x(td,this),renderingIntent:this.renderingIntent,groupState:e}}static fromSerializable({data:t,renderingIntent:n,groupState:r}){return new e(t,n,r)}};function id(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let r=1;r<t;r++){let t=e[r],i;if(Array.isArray(t))i=f(nd,this,id).call(this,t);else if(x(J,this).has(t))i=x(J,this).get(t).visible;else return F(`Optional content group not found: ${t}`),!0;switch(n){case`And`:if(!i)return!1;break;case`Or`:if(i)return!0;break;case`Not`:return!i;default:return!0}}return n===`And`}var ad=new WeakMap,od=new WeakMap,sd=new WeakMap,cd=new WeakMap,ld=new WeakMap,ud=new WeakSet,dd=class{constructor(){S(this,ud),b(this,ad,null),b(this,od,null),b(this,sd,0),b(this,cd,null),b(this,ld,null)}get pagesNumber(){return x(sd,this)}set pagesNumber(e){x(sd,this)!==e&&(C(sd,this,e),C(ad,this,null),C(od,this,null))}movePages(e,t,n){f(ud,this,fd).call(this);let r=x(ad,this),i=f(ud,this,pd).call(this),a=t.length,o=new Uint32Array(a),s=0;for(let e=0;e<a;e++){let i=t[e]-1;o[e]=r[i],i<n&&s++}let c=x(sd,this),l=c-a,u=B(n-s,0,l);for(let t=0,n=0;t<c;t++)e.has(t+1)||(r[n++]=r[t]);r.copyWithin(u+a,u,l),r.set(o,u),f(ud,this,md).call(this,i),r.every((e,t)=>e===t+1)&&C(ad,this,null)}deletePages(e){f(ud,this,fd).call(this);let t=x(ad,this),n=f(ud,this,pd).call(this);C(ld,this,{pageNumberToId:t.slice(),pagesNumber:x(sd,this),prevPageNumbers:x(od,this).slice()});let r=x(sd,this)-e.length;C(sd,this,r);let i=C(ad,this,new Uint32Array(r));C(od,this,new Int32Array(r));let a=0,o=0;for(let n of e){let e=n-1;e!==a&&(i.set(t.subarray(a,e),o),o+=e-a),a=e+1}a<t.length&&i.set(t.subarray(a),o),f(ud,this,md).call(this,n,new Set(e))}cancelDelete(){x(ld,this)&&(C(ad,this,x(ld,this).pageNumberToId),C(sd,this,x(ld,this).pagesNumber),C(od,this,x(ld,this).prevPageNumbers),C(ld,this,null))}cleanSavedData(){C(ld,this,null)}copyPages(e){f(ud,this,fd).call(this),C(cd,this,{pageNumbers:e,pageIds:e.map(e=>x(ad,this)[e-1])})}cancelCopy(){C(cd,this,null)}pastePages(e){f(ud,this,fd).call(this);let t=x(ad,this),n=f(ud,this,pd).call(this),{pageNumbers:r,pageIds:i}=x(cd,this),a=x(sd,this)+r.length;C(sd,this,a);let o=C(ad,this,new Uint32Array(a));C(od,this,new Int32Array(a)),o.set(t.subarray(0,e),0),o.set(i,e),o.set(t.subarray(e),e+r.length),f(ud,this,md).call(this,n,null,e,r),C(cd,this,null)}hasBeenAltered(){return x(ad,this)!==null}getPageMappingForSaving(e=null){e!=null||(e=f(ud,this,pd).call(this));let t=0;for(let n of e.values())t=Math.max(t,n.length);let n=Array(t);for(let e=0;e<t;e++)n[e]={document:null,pageIndices:[],includePages:[]};for(let[t,r]of e)for(let e=0,i=r.length;e<i;e++)n[e].includePages.push([t-1,r[e]-1]);for(let{includePages:e,pageIndices:t}of n){e.sort((e,t)=>e[0]-t[0]);for(let n=0,r=e.length;n<r;n++)t.push(e[n][1]),e[n]=e[n][0]}return n}extractPages(e){e=Array.from(e).sort((e,t)=>e-t);let t=new Map;for(let n=0,r=e.length;n<r;n++){let r=this.getPageId(e[n]);t.getOrInsertComputed(r,st).push(n+1)}return this.getPageMappingForSaving(t)}getPrevPageNumber(e){var t,n;return(t=(n=x(od,this))==null?void 0:n[e-1])==null?0:t}getPageNumber(e){if(!x(ad,this))return e;let t=x(ad,this);for(let n=0,r=x(sd,this);n<r;n++)if(t[n]===e)return n+1;return 0}getPageId(e){var t,n;return(t=(n=x(ad,this))==null?void 0:n[e-1])==null?e:t}getMapping(){var e;return(e=x(ad,this))==null?void 0:e.subarray(0,this.pagesNumber)}};function fd(){if(x(ad,this))return;let e=x(sd,this),t=C(ad,this,new Uint32Array(e));for(let n=0;n<e;n++)t[n]=n+1;C(od,this,new Int32Array(t))}function pd(){let e=new Map,t=x(ad,this);for(let n=0,r=x(sd,this);n<r;n++){let r=t[n],i=e.get(r);i?i.push(n+1):e.set(r,[n+1])}return e}function md(e,t=null,n=-1,r=null){var i;let a=x(od,this),o=x(ad,this),s=n+((i=r==null?void 0:r.length)==null?0:i),c=new Map;for(let i=0,l=x(sd,this);i<l;i++){if(i>=n&&i<s){a[i]=-r[i-n];continue}let l=o[i],u=e.get(l),d=c.get(l)||0;if(t&&u)for(;d<u.length&&t.has(u[d]);)d++;a[i]=u==null?void 0:u[d],c.set(l,d+1)}}var hd=Symbol(`INITIAL_DATA`),gd=()=>T(T({},Promise.withResolvers()),{},{data:hd}),_d=new WeakMap;ge=Symbol.iterator;var vd=class{constructor(){b(this,_d,new Map)}get(e,t=null){if(t){let n=x(_d,this).getOrInsertComputed(e,gd);return n.promise.then(()=>t(n.data)),null}let n=x(_d,this).get(e);if(!n||n.data===hd)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=x(_d,this).get(e);return!!t&&t.data!==hd}delete(e){let t=x(_d,this).get(e);return!t||t.data===hd?!1:(x(_d,this).delete(e),!0)}resolve(e,t=null){let n=x(_d,this).getOrInsertComputed(e,gd);if(n.data!==hd)throw Error(`Object already resolved ${e}.`);n.data=t,n.resolve()}clear(){for(let{data:t}of x(_d,this).values()){var e;t==null||(e=t.bitmap)==null||e.close()}x(_d,this).clear()}*[ge](){for(let[e,{data:t}]of x(_d,this))t!==hd&&(yield[e,t])}},yd=1e5,bd=30,xd=new WeakMap,Sd=new WeakMap,Cd=new WeakMap,wd=new WeakMap,Td=new WeakMap,Ed=new WeakMap,Dd=new WeakMap,Od=new WeakMap,kd=new WeakMap,Ad=new WeakMap,jd=new WeakMap,Md=new WeakMap,Nd=new WeakMap,Pd=new WeakMap,Fd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Rd=new WeakMap,zd=new WeakMap,Bd=new WeakSet,Vd=class e{constructor({textContentSource:t,images:n,container:r,viewport:i}){var a;if(S(this,Bd),b(this,xd,Promise.withResolvers()),b(this,Sd,null),b(this,Cd,!1),b(this,wd,!!((a=globalThis.FontInspector)!=null&&a.enabled)),b(this,Td,null),b(this,Ed,null),b(this,Dd,null),b(this,Od,0),b(this,kd,0),b(this,Ad,null),b(this,jd,null),b(this,Md,0),b(this,Nd,0),b(this,Pd,Object.create(null)),b(this,Fd,[]),b(this,Id,null),b(this,Ld,[]),b(this,Rd,new WeakMap),b(this,zd,null),t instanceof ReadableStream)C(Id,this,t);else if(typeof t==`object`)C(Id,this,new ReadableStream({start(e){e.enqueue(t),e.close()}}));else throw Error(`No "textContentSource" parameter specified.`);C(Sd,this,C(jd,this,r)),C(Td,this,n),C(Nd,this,i.scale*Pt.pixelRatio),C(Md,this,i.rotation),C(Dd,this,{div:null,properties:null,ctx:null});let{pageWidth:o,pageHeight:s,pageX:c,pageY:l}=i.rawDims;C(zd,this,[1,0,0,-1,-c,l+s]),C(kd,this,o),C(Od,this,s),qd.call(e),r.style.setProperty(`--min-font-size`,Qd._),Nt(r,i),x(xd,this).promise.finally(()=>{$d._.delete(this),C(Dd,this,null),C(Pd,this,null)}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=R.platform;return L(this,`fontFamilyMap`,new Map([[`sans-serif`,`${e&&t?`Calibri, `:``}sans-serif`],[`monospace`,`${e&&t?`Lucida Console, `:``}monospace`]]))}render(){x(Td,this)&&x(Sd,this).append(x(Td,this).render());let e=()=>{x(Ad,this).read().then(({value:t,done:n})=>{if(n){x(xd,this).resolve();return}x(Ed,this)!=null||C(Ed,this,t.lang),Object.assign(x(Pd,this),t.styles),f(Bd,this,Hd).call(this,t.items),e()},x(xd,this).reject)};return C(Ad,this,x(Id,this).getReader()),$d._.add(this),e(),x(xd,this).promise}update({viewport:t,onBefore:n=null}){let r=t.scale*Pt.pixelRatio,i=t.rotation;if(i!==x(Md,this)&&(n==null||n(),C(Md,this,i),Nt(x(jd,this),{rotation:i})),r!==x(Nd,this)){n==null||n(),C(Nd,this,r);let t={div:null,properties:null,ctx:Gd.call(e,x(Ed,this))};for(let e of x(Ld,this))t.properties=x(Rd,this).get(e),t.div=e,f(Bd,this,Wd).call(this,t)}}cancel(){var e;let t=new Xe(`TextLayer task cancelled.`);(e=x(Ad,this))==null||e.cancel(t).catch(()=>{}),C(Ad,this,null),x(xd,this).reject(t)}get textDivs(){return x(Ld,this)}get textContentItemsStr(){return x(Fd,this)}static cleanup(){if(!(f(e,this,$d)._.size>0)){f(e,this,Yd)._.clear();for(let{canvas:t}of f(e,this,Xd)._.values())t.remove();f(e,this,Xd)._.clear()}}};ae=Vd;function Hd(e){var t;if(x(Cd,this))return;(t=x(Dd,this)).ctx!=null||(t.ctx=Gd.call(ae,x(Ed,this)));let n=x(Ld,this),r=x(Fd,this);for(let t of e){if(n.length>yd){F(`Ignoring additional textDivs for performance reasons.`),C(Cd,this,!0);return}if(t.str===void 0){if(t.type===`beginMarkedContentProps`||t.type===`beginMarkedContent`){let e=x(Sd,this);C(Sd,this,document.createElement(`span`)),x(Sd,this).classList.add(`markedContent`),t.id&&x(Sd,this).setAttribute(`id`,`${t.id}`),t.tag===`Artifact`&&(x(Sd,this).ariaHidden=!0),e.append(x(Sd,this))}else t.type===`endMarkedContent`&&C(Sd,this,x(Sd,this).parentNode);continue}r.push(t.str),f(Bd,this,Ud).call(this,t)}}function Ud(e){let t=document.createElement(`span`),n={angle:0,canvasWidth:0,hasText:e.str!==``,hasEOL:e.hasEOL,fontSize:0};x(Ld,this).push(t);let r=z.transform(x(zd,this),e.transform),i=Math.atan2(r[1],r[0]),a=x(Pd,this)[e.fontName];a.vertical&&(i+=Math.PI/2);let o=x(wd,this)&&a.fontSubstitution||a.fontFamily;o=ae.fontFamilyMap.get(o)||o;let s=Math.hypot(r[2],r[3]),c=s*Jd.call(ae,o,a,x(Ed,this)),l,u;i===0?(l=r[4],u=r[5]-c):(l=r[4]+c*Math.sin(i),u=r[5]-c*Math.cos(i));let d=t.style;d.left=`${(100*l/x(kd,this)).toFixed(2)}%`,d.top=`${(100*u/x(Od,this)).toFixed(2)}%`,d.setProperty(`--font-height`,`${s.toFixed(2)}px`),d.fontFamily=o,n.fontSize=s,t.setAttribute(`role`,`presentation`),t.textContent=e.str,t.dir=e.dir,x(wd,this)&&(t.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),i!==0&&(n.angle=180/Math.PI*i);let p=!1;if(e.str.length>1)p=!0;else if(e.str!==` `&&e.transform[0]!==e.transform[3]){let t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(p=!0)}if(p&&(n.canvasWidth=a.vertical?e.height:e.width),x(Rd,this).set(t,n),x(Dd,this).div=t,x(Dd,this).properties=n,f(Bd,this,Wd).call(this,x(Dd,this)),n.hasText&&x(Sd,this).append(t),n.hasEOL){let e=document.createElement(`br`);e.setAttribute(`role`,`presentation`),x(Sd,this).append(e)}}function Wd(e){let{div:t,properties:n,ctx:r}=e,{style:i}=t;if(n.canvasWidth!==0&&n.hasText){let{fontFamily:e}=i,{canvasWidth:a,fontSize:o}=n;Kd.call(ae,r,o*x(Nd,this),e);let{width:s}=r.measureText(t.textContent);s>0&&i.setProperty(`--scale-x`,a*x(Nd,this)/s)}n.angle!==0&&i.setProperty(`--rotate`,`${n.angle}deg`)}function Gd(e=null){let t=f(ae,this,Xd)._.get(e||(e=``));if(!t){let n=document.createElement(`canvas`);n.style.cssText=`position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal`,n.lang=e,document.body.append(n),t=n.getContext(`2d`,{alpha:!1,willReadFrequently:!0}),f(ae,this,Xd)._.set(e,t),f(ae,this,Zd)._.set(t,{size:0,family:``})}return t}function Kd(e,t,n){let r=f(ae,this,Zd)._.get(e);t===r.size&&n===r.family||(e.font=`${t}px ${n}`,r.size=t,r.family=n)}function qd(){if(f(ae,this,Qd)._!==null)return;let e=document.createElement(`div`);e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize=`1px`,e.style.position=`absolute`,e.textContent=`X`,document.body.append(e),Qd._=f(ae,this,e.getBoundingClientRect().height),e.remove()}function Jd(e,t,n){let r=f(ae,this,Yd)._.get(e);if(r)return r;let i=f(ae,this,Gd).call(this,n);i.canvas.width=i.canvas.height=bd,f(ae,this,Kd).call(this,i,bd,e);let a=i.measureText(``),o=a.fontBoundingBoxAscent,s=Math.abs(a.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let c=.8;return o?c=o/(o+s):(R.platform.isFirefox&&F("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),t.ascent?c=t.ascent:t.descent&&(c=1+t.descent)),f(ae,this,Yd)._.set(e,c),c}var Yd={_:new Map},Xd={_:new Map},Zd={_:new WeakMap},Qd={_:null},$d={_:new Set},ef=100;function tf(e={}){var t;let n=new nf,{docId:r}=n,i=e.url?As(e.url):null,a=e.data?js(e.data):null,o=e.httpHeaders||null,s=e.withCredentials===!0,c=(t=e.password)==null?null:t,l=e.range instanceof sf?e.range:null,u=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:Math.pow(2,16),d=e.worker instanceof yf?e.worker:null,f=e.verbosity,p=typeof e.docBaseUrl==`string`&&!_t(e.docBaseUrl)?e.docBaseUrl:null,m=Ms(e.cMapUrl),h=e.cMapPacked!==!1,g=Ms(e.iccUrl),_=Ms(e.standardFontDataUrl),v=Ms(e.wasmUrl),y=e.stopAtErrors!==!0,b=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,x=typeof e.isOffscreenCanvasSupported==`boolean`?e.isOffscreenCanvasSupported:!_e,S=typeof e.isImageDecoderSupported==`boolean`?e.isImageDecoderSupported:!_e,C=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,w=typeof e.disableFontFace==`boolean`?e.disableFontFace:_e,T=e.fontExtraProperties===!0,E=e.enableXfa===!0,D=e.ownerDocument||globalThis.document,O=e.disableRange===!0,k=e.disableStream===!0,A=e.disableAutoFetch===!0,ee=e.pdfBug===!0,te=e.CanvasFactory||(_e?Oc:ec),ne=e.FilterFactory||(_e?Dc:lc),re=e.BinaryDataFactory||(_e?kc:Zs),j=e.enableHWA===!0,ie=e.enableWebGPU===!0?Vc():Promise.resolve(!1),ae=e.useWasm!==!1,oe=e.pagesMapper||new dd,se=typeof e.useSystemFonts==`boolean`?e.useSystemFonts:!_e&&!w,ce=typeof e.useWorkerFetch==`boolean`?e.useWorkerFetch:!!(re===Zs&&m&&h&&_&&v&&Ct(m,document.baseURI)&&Ct(_,document.baseURI)&&Ct(v,document.baseURI));Ie(f);let le={canvasFactory:new te({ownerDocument:D,enableHWA:j}),filterFactory:new ne({docId:r,ownerDocument:D}),binaryDataFactory:ce?null:new re({cMapUrl:m,standardFontDataUrl:_,wasmUrl:v})};d||(d=yf.create({verbosity:f,port:Bu.workerPort}),n._worker=d);let ue={docId:r,apiVersion:`6.1.200`,data:a,password:c,disableAutoFetch:A,rangeChunkSize:u,docBaseUrl:p,enableXfa:E,evaluatorOptions:{maxImageSize:b,disableFontFace:w,ignoreErrors:y,isOffscreenCanvasSupported:x,isImageDecoderSupported:S,canvasMaxAreaInBytes:C,fontExtraProperties:T,useSystemFonts:se,useWasm:ae,useWorkerFetch:ce,cMapUrl:m,cMapPacked:h,iccUrl:g,standardFontDataUrl:_,wasmUrl:v,hasGPU:!1}},de={ownerDocument:D,pdfBug:ee,styleElement:null,enableHWA:j,loadingParams:{disableAutoFetch:A,enableXfa:E}};return Promise.all([d.promise,ie]).then(function([,e]){if(d.destroyed)throw Error(`Worker was destroyed`);ue.evaluatorOptions.hasGPU=e;let t=d.messageHandler.sendWithPromise(`GetDocRequest`,ue,a?[a.buffer]:null),c;if(!a)if(l)c=new cu({pdfDataRangeTransport:l,disableRange:O,disableStream:k});else if(i)c=new(zu(i))({url:i,httpHeaders:o,withCredentials:s,rangeChunkSize:u,disableRange:O,disableStream:k});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return t.then(e=>{if(d.destroyed)throw Error(`Worker was destroyed`);let t=new Ws(r,e,d.port),i=new If(t,n,c,de,le,oe);if(n._transport=i,n.destroyed)throw Error(`Loading aborted`);t.send(`Ready`,null)})}).catch(n._capability.reject).finally(n._setupCapability.resolve),n}var nf=class{constructor(){var e,t;g(this,`_capability`,Promise.withResolvers()),g(this,`_setupCapability`,Promise.withResolvers()),g(this,`_transport`,null),g(this,`_worker`,null),g(this,`docId`,`d${rf._=(e=rf._,t=e++,e),t}`),g(this,`destroyed`,!1),g(this,`onPassword`,null),g(this,`onProgress`,null)}get promise(){return this._capability.promise}destroy(){var e=this;return v(function*(){var t;e.destroyed=!0,e._capability.promise.catch(()=>{});try{var n,r;(n=e._worker)!=null&&n.port&&(e._worker._pendingDestroy=!0),yield e._setupCapability.promise,yield(r=e._transport)==null?void 0:r.destroy()}catch(t){var i;throw(i=e._worker)!=null&&i.port&&delete e._worker._pendingDestroy,t}e._transport=null,(t=e._worker)==null||t.destroy(),e._worker=null})()}getData(){var e=this;return v(function*(){return e._transport.getData()})()}},rf={_:0},af=new WeakMap,of=new WeakMap,sf=class{constructor(e,t,n=!1,r=null){b(this,af,Promise.withResolvers()),b(this,of,null),this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r}onDataRange(e,t){x(of,this).call(this,{type:`range`,begin:e,chunk:t})}onDataProgressiveRead(e){x(af,this).promise.then(()=>{x(of,this).call(this,{type:`progressiveRead`,chunk:e})})}onDataProgressiveDone(){x(af,this).promise.then(()=>{x(of,this).call(this,{type:`progressiveDone`})})}transportReady(e){C(of,this,e),x(af,this).resolve()}requestDataRange(e,t){I(`Abstract method PDFDataRangeTransport.requestDataRange`)}abort(){}},cf=class{constructor(e,t){this._pdfInfo=e,this._transport=t}get pagesMapper(){return this._transport.pagesMapper}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 L(this,`isPureXfa`,!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}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()}getAttachmentContent(e){return this._transport.getAttachmentContent(e)}getAnnotationsByType(e,t){return this._transport.getAnnotationsByType(e,t)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}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()}extractPages(e){return this._transport.extractPages(e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(e){return this._transport.getRawData(e)}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}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()}},lf=new WeakMap,uf=new WeakMap,df=new WeakSet,ff=class e{constructor(e,t,n,r,i=!1){S(this,df),b(this,lf,!1),b(this,uf,null),this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=i?new St:null,this._pdfBug=i,this.commonObjs=n.commonObjs,this.objs=new vd,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,C(uf,this,r),this.imageCoordinates=null}clone(t){var n;let r=new e(t,this._pageInfo,this._transport,x(uf,this),this._pdfBug);return r.clonedFromIndex=(n=this.clonedFromIndex)==null?this._pageIndex:n,this._transport.updatePage(r),r}get pageNumber(){return this._pageIndex+1}set pageNumber(e){this._pageIndex=e-1,this._transport.updatePage(this)}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:e,rotation:t=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new ut({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:i})}getAnnotations({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return L(this,`isPureXfa`,!!this._transport._htmlForXfa)}getXfa(){var e=this;return v(function*(){var t;return((t=e._transport._htmlForXfa)==null?void 0:t.children[e._pageIndex])||null})()}render({canvasContext:e,canvas:t=e.canvas,viewport:n,intent:r=`display`,annotationMode:i=we.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:s=null,annotationCanvasMap:c=null,pageColors:l=null,printAnnotationStorage:u=null,isEditing:d=!1,recordImages:p=!1,recordOperations:m=!1,operationsFilter:h=null}){var g,_,v;(g=this._stats)==null||g.time(`Overall`);let y=this._transport.getRenderingIntent(r,i,u,d),{renderingIntent:b,cacheKey:x}=y;C(lf,this,!1),s||(s=this._transport.getOptionalContentConfig(b));let S=this._intentStates.getOrInsertComputed(x,lt);S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);let w=!!(b&Ce.PRINT);if(!S.displayReadyCapability){var T;S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(T=this._stats)==null||T.time(`Page Request`),this._pumpOperatorList(y)}let E=!!(this._pdfBug&&(_=globalThis.StepperManager)!=null&&_.enabled),D=!!t&&!this.recordedBBoxes&&(m||E),O=!!t&&!this.imageCoordinates&&p,k=e=>{if(S.renderTasks.delete(te),D){var t;let e=(t=te.gfx)==null?void 0:t.dependencyTracker.take();if(e){var n;(n=te.stepper)==null||n.setOperatorBBoxes(e,te.gfx.dependencyTracker.takeDebugMetadata()),m&&(this.recordedBBoxes=e)}}if(O&&!e){var r;this.imageCoordinates=(r=te.gfx)==null?void 0:r.imagesTracker.take()}if(w&&C(lf,this,!0),f(df,this,pf).call(this),e?(te.capability.reject(e),this._abortOperatorList({intentState:S,reason:e instanceof Error?e:Error(e)})):te.capability.resolve(),this._stats){var i;this._stats.timeEnd(`Rendering`),this._stats.timeEnd(`Overall`),(i=globalThis.Stats)!=null&&i.enabled&&globalThis.Stats.add(this.pageNumber,this._stats)}},A=null,ee=null;(D||O)&&(ee=new Co(t,S.operatorList.length)),D&&(A=new No(ee,E));let te=new Vf({callback:k,params:{canvas:t,canvasContext:e,dependencyTracker:(v=A)==null?ee:v,imagesTracker:O?new Ko(t):null,viewport:n,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:l,enableHWA:this._transport.enableHWA,operationsFilter:h});(S.renderTasks||(S.renderTasks=new Set)).add(te);let ne=te.task;return Promise.all([S.displayReadyCapability.promise,s]).then(([e,t])=>{var n;if(this.destroyed){k();return}if((n=this._stats)==null||n.time(`Rendering`),!(t.renderingIntent&b))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");te.initializeGraphics({transparency:e,optionalContentConfig:t}),te.operatorListChanged()}).catch(k),ne}getOperatorList({intent:e=`display`,annotationMode:t=we.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(s))}let a=this._transport.getRenderingIntent(e,t,n,r,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,lt),s;if(!o.opListReadCapability){var c;s=Object.create(null),s.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(s),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time(`Page Request`),this._pumpOperatorList(a)}return o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream(`GetTextContent`,{pageId:x(uf,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(e){return e.items.length}})}getTextContent(){var e=this;return v(function*(t={}){if(e._transport._htmlForXfa)return e.getXfa().then(e=>dt.textContent(e));let n=e.streamTextContent(t),r={items:[],styles:Object.create(null),lang:null};var i=!1,a=!1,o;try{for(var s=E(n),c;i=!(c=yield s.next()).done;i=!1){let e=c.value;r.lang!=null||(r.lang=e.lang),Object.assign(r.styles,e.styles),r.items.push(...e.items)}}catch(e){a=!0,o=e}finally{try{i&&s.return!=null&&(yield s.return())}finally{if(a)throw o}}return r}).apply(this,arguments)}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:Error(`Page was destroyed.`),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),C(lf,this,!1),Promise.all(e)}cleanup(e=!1){C(lf,this,!0);let t=f(df,this,pf).call(this);return e&&t&&this._stats&&(this._stats=new St),t}_startRenderPage(e,t){var n,r;let i=this._intentStates.get(t);i&&((n=this._stats)==null||n.timeEnd(`Page Request`),(r=i.displayReadyCapability)==null||r.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let e of t.renderTasks)e.operatorListChanged();e.lastChunk&&f(df,this,pf).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){let{map:i,transfer:a}=n,o=this._transport.messageHandler.sendWithStream(`GetOperatorList`,{pageId:x(uf,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i,modifiedIds:r},void 0,a).getReader(),s=this._intentStates.get(t);s.streamReader=o;let c=()=>{o.read().then(({value:e,done:t})=>{if(t){s.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(e,s),c())},e=>{if(s.streamReader=null,!this._transport.destroyed){if(s.operatorList){s.operatorList.lastChunk=!0;for(let e of s.renderTasks)e.operatorListChanged();f(df,this,pf).call(this)}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else if(s.opListReadCapability)s.opListReadCapability.reject(e);else throw e}})};c()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof gt){let n=ef;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new Xe(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}};function pf(){if(!x(lf,this)||this.destroyed)return!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),C(lf,this,!1),!0}var mf=new WeakMap,hf=new WeakMap,gf=new WeakMap,_f=new WeakMap,vf=new WeakSet,yf=class e{constructor({name:e=null,port:t=null,verbosity:n=Le()}={}){if(S(this,vf),b(this,mf,Promise.withResolvers()),b(this,hf,null),b(this,gf,null),b(this,_f,null),this.name=e,this.destroyed=!1,this.verbosity=n,t){if(Df._.has(t))throw Error(`Cannot use more than one PDFWorker per port.`);Df._.set(t,this),f(vf,this,xf).call(this,t)}else f(vf,this,Sf).call(this)}get promise(){return x(mf,this).promise}get port(){return x(gf,this)}get messageHandler(){return x(hf,this)}destroy(){var e,t;this.destroyed=!0,(e=x(_f,this))==null||e.terminate(),C(_f,this,null),Df._.delete(x(gf,this)),C(gf,this,null),(t=x(hf,this))==null||t.destroy(),C(hf,this,null)}static create(t){let n=f(e,this,Df)._.get(t==null?void 0:t.port);if(n){if(n._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new e(t)}static get workerSrc(){if(Bu.workerSrc)return Bu.workerSrc;throw Error(`No "GlobalWorkerOptions.workerSrc" specified.`)}static get _setupFakeWorkerGlobal(){var t=this;let n=function(){var n=v(function*(){return wf.call(f(e,t))?wf.call(f(e,t)):(yield import(t.workerSrc)).WorkerMessageHandler});return function(){return n.apply(this,arguments)}}();return L(this,`_setupFakeWorkerGlobal`,n())}};oe=yf;function bf(){x(mf,this).resolve(),x(hf,this).send(`configure`,{verbosity:this.verbosity})}function xf(e){C(gf,this,e),C(hf,this,new Ws(`main`,`worker`,e)),x(hf,this).on(`ready`,()=>{}),f(vf,this,bf).call(this)}function Sf(){if(Ef._||wf.call(oe)){f(vf,this,Cf).call(this);return}let{workerSrc:e}=oe;try{oe._isSameOrigin(window.location,e)||(e=oe._createCDNWrapper(new URL(e,window.location).href));let t=new Worker(e,{type:`module`}),n=new Ws(`main`,`worker`,t),r=()=>{i.abort(),n.destroy(),t.terminate(),this.destroyed?x(mf,this).reject(Error(`Worker was destroyed`)):f(vf,this,Cf).call(this)},i=new AbortController;t.addEventListener(`error`,()=>{x(_f,this)||r()},{signal:i.signal}),n.on(`test`,e=>{if(i.abort(),this.destroyed||!e){r();return}C(hf,this,n),C(gf,this,t),C(_f,this,t),f(vf,this,bf).call(this)}),n.on(`ready`,e=>{if(i.abort(),this.destroyed){r();return}try{a()}catch(e){f(vf,this,Cf).call(this)}});let a=()=>{let e=new Uint8Array;n.send(`test`,e,[e.buffer])};a();return}catch(e){Re(`The worker has been disabled.`)}f(vf,this,Cf).call(this)}function Cf(){Ef._||(F(`Setting up fake worker.`),Ef._=!0),oe._setupFakeWorkerGlobal.then(e=>{var t,n;if(this.destroyed){x(mf,this).reject(Error(`Worker was destroyed`));return}let r=new Ls;C(gf,this,r);let i=`fake${Tf._=(t=Tf._,n=t++,t),n}`,a=new Ws(i+`_worker`,i,r);e.setup(a,r),C(hf,this,new Ws(i,i+`_worker`,r)),f(vf,this,bf).call(this)}).catch(e=>{x(mf,this).reject(Error(`Setting up fake worker failed: "${e.message}".`))})}function wf(){try{var e;return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch(e){return null}}var Tf={_:0},Ef={_:!1},Df={_:new WeakMap};_e&&(Ef._=f(oe,oe,!0),Bu.workerSrc||(Bu.workerSrc=`./pdf.worker.mjs`)),oe._isSameOrigin=(e,t)=>{let n=URL.parse(e);if(!(n!=null&&n.origin)||n.origin===`null`)return!1;let r=new URL(t,n);return n.origin===r.origin},oe._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:`text/javascript`}))};var Of=new WeakMap,kf=new WeakMap,Af=new WeakMap,jf=new WeakMap,Mf=new WeakMap,Nf=new WeakMap,Pf=new WeakMap,Ff=new WeakSet,If=class{constructor(e,t,n,r,i,a){S(this,Ff),g(this,`downloadInfoCapability`,Promise.withResolvers()),b(this,Of,null),b(this,kf,new Map),b(this,Af,null),b(this,jf,new Map),b(this,Mf,new Map),b(this,Nf,new Map),b(this,Pf,null),this.messageHandler=e,this.loadingTask=t,C(Af,this,n),this.commonObjs=new vd,this.fontLoader=new Zo({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.enableHWA=r.enableHWA,this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.binaryDataFactory=i.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(e){let{_pageIndex:t}=e;x(jf,this).set(t,e),x(Mf,this).set(t,Promise.resolve(e))}get annotationStorage(){return L(this,`annotationStorage`,new to)}getRenderingIntent(e,t=we.ENABLE,n=null,r=!1,i=!1){let a=Ce.DISPLAY,o=Ya;switch(e){case`any`:a=Ce.ANY;break;case`display`:break;case`print`:a=Ce.PRINT;break;default:F(`getRenderingIntent - invalid intent: ${e}`)}let s=a&Ce.PRINT&&n instanceof io?n:this.annotationStorage;switch(t){case we.DISABLE:a+=Ce.ANNOTATIONS_DISABLE;break;case we.ENABLE:break;case we.ENABLE_FORMS:a+=Ce.ANNOTATIONS_FORMS;break;case we.ENABLE_STORAGE:a+=Ce.ANNOTATIONS_STORAGE,o=s.serializable;break;default:F(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(a+=Ce.IS_EDITING),i&&(a+=Ce.OPLIST);let{ids:c,hash:l}=s.modifiedIds,u=[a,o.hash,l];return{renderingIntent:a,cacheKey:u.join(`_`),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var e;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(e=x(Pf,this))==null||e.reject(Error(`Worker was destroyed during onPassword callback`));let t=[];for(let e of x(jf,this).values())t.push(e._destroy());x(jf,this).clear(),x(Mf,this).clear(),x(Nf,this).clear(),Object.hasOwn(this,`annotationStorage`)&&this.annotationStorage.resetModified();let n=this.messageHandler.sendWithPromise(`Terminate`,null);return t.push(n),Promise.all(t).then(()=>{var e,t;this.commonObjs.clear(),this.fontLoader.clear(),x(kf,this).clear(),this.filterFactory.destroy(),Vd.cleanup(),(e=x(Af,this))==null||e.cancelAllRequests(new Xe(`Worker was terminated.`)),(t=this.messageHandler)==null||t.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){var e=this;let{messageHandler:t,loadingTask:n}=this;t.on(`GetReader`,(e,t)=>{ze(x(Af,this),"GetReader - no `BasePDFStream` instance available."),C(Of,this,x(Af,this).getFullReader()),x(Of,this).onProgress=e=>f(Ff,this,Rf).call(this,e),t.onPull=()=>{x(Of,this).read().then(function({value:e,done:n}){if(n){t.close();return}ze(e instanceof ArrayBuffer,`GetReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{x(Of,this).cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),t.on(`ReaderHeadersReady`,function(){var t=v(function*(t){yield x(Of,e).headersReady;let{isStreamingSupported:n,isRangeSupported:r,contentLength:i}=x(Of,e);return n&&r&&(x(Of,e).onProgress=null),{isStreamingSupported:n,isRangeSupported:r,contentLength:i}});return function(e){return t.apply(this,arguments)}}()),t.on(`GetRangeReader`,(e,t)=>{ze(x(Af,this),"GetRangeReader - no `BasePDFStream` instance available.");let n=x(Af,this).getRangeReader(e.begin,e.end);if(!n){t.close();return}t.onPull=()=>{n.read().then(function({value:e,done:n}){if(n){t.close();return}ze(e instanceof ArrayBuffer,`GetRangeReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{n.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),t.on(`GetDoc`,({pdfInfo:e})=>{this.pagesMapper.pagesNumber=e.numPages,this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,n._capability.resolve(new cf(e,this))}),t.on(`DocException`,e=>{n._capability.reject(Vs(e))}),t.on(`PasswordRequest`,e=>{C(Pf,this,Promise.withResolvers());try{if(!n.onPassword)throw Vs(e);n.onPassword(e=>{e instanceof Error?x(Pf,this).reject(e):x(Pf,this).resolve({password:e})},e.code)}catch(e){x(Pf,this).reject(e)}return x(Pf,this).promise}),t.on(`DataLoaded`,e=>{f(Ff,this,Rf).call(this,{loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),t.on(`StartRenderPage`,e=>{this.destroyed||x(jf,this).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),t.on(`commonobj`,([e,n,r])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(n){case`Font`:var i;if(`error`in r){let t=r.error;F(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let a=new es(new xs(r),this._params.pdfBug&&(i=globalThis.FontInspector)!=null&&i.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,r.charProcOperatorList,r.extra);this.fontLoader.bind(a).catch(()=>t.sendWithPromise(`FontFallback`,{id:e})).finally(()=>{a.fontExtraProperties||a.clearData(),this.commonObjs.resolve(e,a)});break;case`CopyLocalImage`:let{imageRef:o}=r;ze(o,`The imageRef must be defined.`);for(let t of x(jf,this).values())for(let[,n]of t.objs){if((n==null?void 0:n.ref)!==o)continue;if(!n.dataLen)return null;let t=structuredClone(n);return this.commonObjs.resolve(e,t),n.dataLen}break;case`FontPath`:this.commonObjs.resolve(e,new ks(r));break;case`Image`:this.commonObjs.resolve(e,r);break;case`Pattern`:let s=new Ds(r);this.commonObjs.resolve(e,s.getIR());break;default:throw Error(`Got unknown common object type ${n}`)}return null}),t.on(`obj`,([e,t,n,r])=>{if(this.destroyed)return;let i=x(jf,this).get(t);if(!i.objs.has(e)){if(i._intentStates.size===0){var a;r==null||(a=r.bitmap)==null||a.close();return}switch(n){case`Image`:case`Pattern`:i.objs.resolve(e,r);break;default:throw Error(`Got unknown object type ${n}`)}}}),t.on(`DocProgress`,e=>{this.destroyed||f(Ff,this,Rf).call(this,e)}),t.on(`FetchBinaryData`,function(){var t=v(function*(t){if(e.destroyed)throw Error(`Worker was destroyed.`);if(!e.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return e.binaryDataFactory.fetch(t)});return function(e){return t.apply(this,arguments)}}())}getData(){return this.messageHandler.sendWithPromise(`GetData`,null)}saveDocument(){var e,t;this.annotationStorage.size<=0&&F("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:n,transfer:r}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise(`SaveDocument`,{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:n,filename:(e=(t=x(Of,this))==null?void 0:t.filename)==null?null:e},r).finally(()=>{this.annotationStorage.resetModified()})}extractPages(e){let t={pageInfos:e},n,r=globalThis.ImageBitmap;if(typeof r==`function`){let t=Array.isArray(e)?e:[e];for(let e of t)(e==null?void 0:e.image)instanceof r&&(n||(n=[])).push(e.image)}if(this.annotationStorage.size>0){var i;let e=this.annotationStorage.serializable,{map:r}=e;(i=e.transfer)!=null&&i.length&&(n?n.push(...e.transfer):n=e.transfer);let a=this.pagesMapper.getMapping();if(a){let e=new Map;for(let[t,n]of r){if((n==null?void 0:n.pageIndex)!==void 0&&n.pageIndex>=0&&n.pageIndex<a.length){let r=a[n.pageIndex]-1;if(r!==n.pageIndex){e.set(t,T(T({},n),{},{pageIndex:r}));continue}}e.set(t,n)}r=e}t.annotationStorage=r}return this.messageHandler.sendWithPromise(`ExtractPages`,t,n).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this.pagesMapper.pagesNumber)return Promise.reject(Error(`Invalid page request.`));let t=e-1,n=this.pagesMapper.getPageId(e)-1,r=x(Mf,this).get(t);if(r)return r;let i=this.messageHandler.sendWithPromise(`GetPage`,{pageIndex:n}).then(e=>{if(this.destroyed)throw Error(`Transport destroyed`);e.refStr&&x(Nf,this).set(e.refStr,n);let r=new ff(t,e,this,this.pagesMapper,this._params.pdfBug);return x(jf,this).set(t,r),r});return x(Mf,this).set(t,i),i}getPageIndex(e){var t=this;return v(function*(){if(!Ns(e))throw Error(`Invalid pageIndex request.`);let n=yield t.messageHandler.sendWithPromise(`GetPageIndex`,{num:e.num,gen:e.gen}),r=t.pagesMapper.getPageNumber(n+1);if(r===0)throw Error(`GetPageIndex: page has been removed.`);return r-1})()}getAnnotations(e,t){return this.messageHandler.sendWithPromise(`GetAnnotations`,{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return f(Ff,this,Lf).call(this,`GetFieldObjects`)}hasJSActions(){return f(Ff,this,Lf).call(this,`HasJSActions`)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise(`GetCalculationOrderIds`,null)}getDestinations(){return this.messageHandler.sendWithPromise(`GetDestinations`,null)}getDestination(e){return typeof e==`string`?this.messageHandler.sendWithPromise(`GetDestination`,{id:e}):Promise.reject(Error(`Invalid destination request.`))}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)}getAttachmentContent(e){return this.messageHandler.sendWithPromise(`GetAttachmentContent`,e)}getAnnotationsByType(e,t){return this.messageHandler.sendWithPromise(`GetAnnotationsByType`,{types:e,pageIndexesToSkip:t})}getDocJSActions(){return f(Ff,this,Lf).call(this,`GetDocJSActions`)}getPageJSActions(e){return this.messageHandler.sendWithPromise(`GetPageJSActions`,{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getStructTree(e){return this.messageHandler.sendWithPromise(`GetStructTree`,{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getOutline(){return this.messageHandler.sendWithPromise(`GetOutline`,null)}getOptionalContentConfig(e){return f(Ff,this,Lf).call(this,`GetOptionalContentConfig`).then(t=>new rd(t,e))}getPermissions(){return this.messageHandler.sendWithPromise(`GetPermissions`,null)}getMetadata(){let e=`GetMetadata`;return x(kf,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).then(e=>{var t,n,r,i;return{info:e[0],metadata:e[1]?new Gu(e[1]):null,contentDispositionFilename:(t=(n=x(Of,this))==null?void 0:n.filename)==null?null:t,contentLength:(r=(i=x(Of,this))==null?void 0:i.contentLength)==null?null:r,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise(`GetMarkInfo`,null)}getRawData(e){return this.messageHandler.sendWithPromise(`GetRawData`,e)}startCleanup(e=!1){var t=this;return v(function*(){if(!t.destroyed){yield t.messageHandler.sendWithPromise(`Cleanup`,null);for(let e of x(jf,t).values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);t.commonObjs.clear(),e||t.fontLoader.clear(),x(kf,t).clear(),t.filterFactory.destroy(!0),Vd.cleanup()}})()}cachedPageNumber(e){if(!Ns(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`,n=x(Nf,this).get(t);if(n>=0){let e=this.pagesMapper.getPageNumber(n+1);if(e!==0)return e}return null}};function Lf(e,t=null){return x(kf,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))}function Rf({loaded:e,total:t}){var n,r;(n=(r=this.loadingTask).onProgress)==null||n.call(r,{loaded:e,total:t,percent:t?B(Math.round(e/t*100),0,100):NaN})}var zf=class{constructor(e){g(this,`_internalRenderTask`,null),g(this,`onContinue`,null),g(this,`onError`,null),this._internalRenderTask=e}get promise(){return this._internalRenderTask.capability.promise}cancel(e=0){this._internalRenderTask.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this._internalRenderTask.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this._internalRenderTask;return e.form||e.canvas&&(t==null?void 0:t.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}},Bf=new WeakMap,Vf=class{constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:s,filterFactory:c,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:d=null,enableHWA:f=!1,operationsFilter:p=null}){b(this,Bf,null),this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=l===!0&&typeof window<`u`,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new zf(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=t.canvas,this._canvasContext=t.canvas?null:t.canvasContext,this._enableHWA=f,this._dependencyTracker=t.dependencyTracker,this._imagesTracker=t.imagesTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var n,r;if(this.cancelled)return;if(this._canvas){if(Hf._.has(this._canvas))throw Error(`Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.`);Hf._.add(this._canvas)}this._pdfBug&&(n=globalThis.StepperManager)!=null&&n.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{viewport:i,transform:a,background:o,dependencyTracker:s,imagesTracker:c}=this.params,l=this._canvasContext||this._canvas.getContext(`2d`,{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Al(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors,s,c),this.gfx.beginDrawing({transform:a,viewport:i,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,(r=this.graphicsReadyCallback)==null||r.call(this)}cancel(e=null,t=0){var n,r,i;this.running=!1,this.cancelled=!0,(n=this.gfx)==null||n.endDrawing(),x(Bf,this)&&(window.cancelAnimationFrame(x(Bf,this)),C(Bf,this,null)),Hf._.delete(this._canvas),e||(e=new gt(`Rendering cancelled, page ${this._pageIndex+1}`,t)),this.callback(e),(r=(i=this.task).onError)==null||r.call(i,e)}operatorListChanged(){var e,t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.gfx.dependencyTracker)==null||e.growOperationsCount(this.operatorList.fnArray.length),(t=this.stepper)==null||t.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?C(Bf,this,window.requestAnimationFrame(()=>{C(Bf,this,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){var e=this;return v(function*(){e.cancelled||(e.operatorListIdx=e.gfx.executeOperatorList(e.operatorList,e.operatorListIdx,e._continueBound,e.stepper,e._operationsFilter),e.operatorListIdx===e.operatorList.argsArray.length&&(e.running=!1,e.operatorList.lastChunk&&(e.gfx.endDrawing(),Hf._.delete(e._canvas),e.callback())))})()}},Hf={_:new WeakSet},Uf=`6.1.200`,Wf=`6353acefe`,Gf=new WeakMap,Kf=new WeakMap,qf=new WeakMap,Jf=new WeakMap,Yf=new WeakMap,Xf=new WeakMap,Zf=new WeakMap,Qf=new WeakMap,$f=new WeakMap,ep=new WeakMap,tp=new WeakSet,np=class e{static get _keyboardManager(){return L(this,`_keyboardManager`,new Rn([[[`Escape`],e.prototype._hideDropdownFromKeyboard],[[`Space`],e.prototype._colorSelectFromKeyboard],[[`ArrowDown`,`ArrowRight`],e.prototype._moveToNext],[[`ArrowUp`,`ArrowLeft`],e.prototype._moveToPrevious],[[`Home`],e.prototype._moveToBeginning],[[`End`],e.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){var n,r;S(this,tp),b(this,Gf,null),b(this,Kf,null),b(this,qf,void 0),b(this,Jf,null),b(this,Yf,!1),b(this,Xf,!1),b(this,Zf,null),b(this,Qf,void 0),b(this,$f,null),b(this,ep,null),e?(C(Xf,this,!1),C(Zf,this,e)):C(Xf,this,!0),C(ep,this,(e==null?void 0:e._uiManager)||t),C(Qf,this,x(ep,this)._eventBus),C(qf,this,(e==null||(n=e.color)==null?void 0:n.toUpperCase())||((r=x(ep,this))==null?void 0:r.highlightColors.values().next().value)||`#FFFF98`),lp._||(lp._=Object.freeze({blue:`pdfjs-editor-colorpicker-blue`,green:`pdfjs-editor-colorpicker-green`,pink:`pdfjs-editor-colorpicker-pink`,red:`pdfjs-editor-colorpicker-red`,yellow:`pdfjs-editor-colorpicker-yellow`}))}renderButton(){let e=C(Gf,this,document.createElement(`button`));e.className=`colorPicker`,e.tabIndex=`0`,e.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-button`),e.ariaHasPopup=`true`,x(Zf,this)&&(e.ariaControls=`${x(Zf,this).id}_colorpicker_dropdown`);let t=x(ep,this)._signal;e.addEventListener(`click`,f(tp,this,op).bind(this),{signal:t}),e.addEventListener(`keydown`,f(tp,this,ap).bind(this),{signal:t});let n=C(Kf,this,document.createElement(`span`));return n.className=`swatch`,n.ariaHidden=`true`,n.style.backgroundColor=x(qf,this),e.append(n),e}renderMainDropdown(){let e=C(Jf,this,f(tp,this,rp).call(this));return e.ariaOrientation=`horizontal`,e.ariaLabelledBy=`highlightColorPickerLabel`,e}_colorSelectFromKeyboard(e){if(e.target===x(Gf,this)){f(tp,this,op).call(this,e);return}let t=e.target.getAttribute(`data-color`);t&&f(tp,this,ip).call(this,t,e)}_moveToNext(e){var t;if(!cp.call(f(tp,this))){f(tp,this,op).call(this,e);return}if(e.target===x(Gf,this)){var n;(n=x(Jf,this).firstElementChild)==null||n.focus();return}(t=e.target.nextSibling)==null||t.focus()}_moveToPrevious(e){var t,n;if(e.target===((t=x(Jf,this))==null?void 0:t.firstElementChild)||e.target===x(Gf,this)){cp.call(f(tp,this))&&this._hideDropdownFromKeyboard();return}cp.call(f(tp,this))||f(tp,this,op).call(this,e),(n=e.target.previousSibling)==null||n.focus()}_moveToBeginning(e){var t;if(!cp.call(f(tp,this))){f(tp,this,op).call(this,e);return}(t=x(Jf,this).firstElementChild)==null||t.focus()}_moveToEnd(e){var t;if(!cp.call(f(tp,this))){f(tp,this,op).call(this,e);return}(t=x(Jf,this).lastElementChild)==null||t.focus()}hideDropdown(){var e,t;(e=x(Jf,this))==null||e.classList.add(`hidden`),x(Gf,this).ariaExpanded=`false`,(t=x($f,this))==null||t.abort(),C($f,this,null)}_hideDropdownFromKeyboard(){if(!x(Xf,this)){if(!cp.call(f(tp,this))){var e;(e=x(Zf,this))==null||e.unselect();return}this.hideDropdown(),x(Gf,this).focus({preventScroll:!0,focusVisible:x(Yf,this)})}}updateColor(e){if(x(Kf,this)&&(x(Kf,this).style.backgroundColor=e),!x(Jf,this))return;let t=x(ep,this).highlightColors.values();for(let n of x(Jf,this).children)n.ariaSelected=t.next().value===e.toUpperCase()}destroy(){var e,t;(e=x(Gf,this))==null||e.remove(),C(Gf,this,null),C(Kf,this,null),(t=x(Jf,this))==null||t.remove(),C(Jf,this,null)}};se=np;function rp(){let e=document.createElement(`div`),t=x(ep,this)._signal;e.addEventListener(`contextmenu`,wt,{signal:t}),e.className=`dropdown`,e.role=`listbox`,e.ariaMultiSelectable=`false`,e.ariaOrientation=`vertical`,e.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-dropdown`),x(Zf,this)&&(e.id=`${x(Zf,this).id}_colorpicker_dropdown`);for(let[n,r]of x(ep,this).highlightColors){let i=document.createElement(`button`);i.tabIndex=`0`,i.role=`option`,i.setAttribute(`data-color`,r),i.title=n,i.setAttribute(`data-l10n-id`,lp._[n]);let a=document.createElement(`span`);i.append(a),a.className=`swatch`,a.style.backgroundColor=r,i.ariaSelected=r===x(qf,this),i.addEventListener(`click`,f(tp,this,ip).bind(this,r),{signal:t}),e.append(i)}return e.addEventListener(`keydown`,f(tp,this,ap).bind(this),{signal:t}),e}function ip(e,t){t.stopPropagation(),x(Qf,this).dispatch(`switchannotationeditorparams`,{source:this,type:N.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)}function ap(e){se._keyboardManager.exec(this,e)}function op(e){if(cp.call(f(tp,this))){this.hideDropdown();return}if(C(Yf,this,e.detail===0),x($f,this)||(C($f,this,new AbortController),window.addEventListener(`pointerdown`,f(tp,this,sp).bind(this),{signal:x(ep,this).combinedSignal(x($f,this))})),x(Gf,this).ariaExpanded=`true`,x(Jf,this)){x(Jf,this).classList.remove(`hidden`);return}let t=C(Jf,this,f(tp,this,rp).call(this));x(Gf,this).append(t)}function sp(e){var t;(t=x(Jf,this))!=null&&t.contains(e.target)||this.hideDropdown()}function cp(){return x(Jf,this)&&!x(Jf,this).classList.contains(`hidden`)}var lp={_:null},up=new WeakMap,dp=new WeakMap,fp=new WeakMap,pp=new WeakMap,mp=class{constructor(e){b(this,up,null),b(this,dp,!1),b(this,fp,null),b(this,pp,null),C(fp,this,e),C(pp,this,e._uiManager),hp._||(hp._=Object.freeze({freetext:`pdfjs-editor-color-picker-free-text-input`,ink:`pdfjs-editor-color-picker-ink-input`}))}renderButton(){if(x(up,this))return x(up,this);let{editorType:e,colorType:t,colorAndOpacityType:n,opacityType:r,color:i,opacity:a}=x(fp,this),o=C(dp,this,R.isAlphaColorInputSupported&&r!==void 0),s=C(up,this,document.createElement(`input`));if(s.type=`color`,o){s.setAttribute(`alpha`,``);let e=z.hexNums[Math.round((a==null?1:a)*255)];s.value=(i||`#000000`)+e}else s.value=i||`#000000`;return s.className=`basicColorPicker`,s.tabIndex=0,s.setAttribute(`data-l10n-id`,hp._[e]),s.addEventListener(`input`,()=>{if(o){let e=Ot(s.value);if(!e)return;let[i,a,o,c]=e,l=z.makeHexColor(i,a,o);n===void 0?(x(pp,this).updateParams(t,l),x(pp,this).updateParams(r,c)):x(pp,this).updateParams(n,{color:l,opacity:c})}else x(pp,this).updateParams(t,s.value)},{signal:x(pp,this)._signal}),s}update(e){if(x(up,this))if(x(dp,this)){let t=z.hexNums[Math.round(x(fp,this).opacity*255)];x(up,this).value=e+t}else x(up,this).value=e}updateOpacity(e){if(!x(up,this)||!x(dp,this))return;let t=z.hexNums[Math.round(e*255)];x(up,this).value=x(fp,this).color+t}destroy(){var e;(e=x(up,this))==null||e.remove(),C(up,this,null)}hideDropdown(){}},hp={_:null};function gp(e){return Math.floor(B(e,0,1)*255).toString(16).padStart(2,`0`)}function _p(e){return B(e,0,1)*255}var vp=class{static CMYK_G([e,t,n,r]){return[`G`,1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return[`CMYK`,0,0,0,1-e]}static G_RGB([e]){return[`RGB`,e,e,e]}static G_rgb([e]){return e=_p(e),[e,e,e]}static G_HTML([e]){let t=gp(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return[`G`,.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(_p)}static RGB_HTML(e){return`#${e.map(gp).join(``)}`}static T_HTML(){return`#00000000`}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return[`RGB`,1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[_p(1-Math.min(1,e+r)),_p(1-Math.min(1,n+r)),_p(1-Math.min(1,t+r))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let r=1-e,i=1-t,a=1-n;return[`CMYK`,r,i,a,Math.min(r,i,a)]}},yp=class{create(e,t,n=!1){if(e<=0||t<=0)throw Error(`Invalid SVG dimensions`);let r=this._createSVG(`svg:svg`);return r.setAttribute(`version`,`1.1`),n||(r.setAttribute(`width`,`${e}px`),r.setAttribute(`height`,`${t}px`)),r.setAttribute(`preserveAspectRatio`,`none`),r.setAttribute(`viewBox`,`0 0 ${e} ${t}`),r}createElement(e){if(typeof e!=`string`)throw Error(`Invalid SVG element type`);return this._createSVG(e)}_createSVG(e){I("Abstract method `_createSVG` called.")}},bp=class extends yp{_createSVG(e){return document.createElementNS(Se,e)}},xp=9,Sp=new WeakSet,Cp=new Date().getTimezoneOffset()*60*1e3,wp=class{static create(e){switch(e.data.annotationType){case Ae.LINK:return new Np(e);case Ae.TEXT:return new Lp(e);case Ae.WIDGET:switch(e.data.fieldType){case`Tx`:return new zp(e);case`Btn`:return e.data.radioButton?new Hp(e):e.data.checkBox?new Vp(e):new Up(e);case`Ch`:return new Wp(e);case`Sig`:return new Bp(e)}return new Rp(e);case Ae.POPUP:return new Kp(e);case Ae.FREETEXT:return new Pm(e);case Ae.LINE:return new Im(e);case Ae.SQUARE:return new Rm(e);case Ae.CIRCLE:return new Bm(e);case Ae.POLYLINE:return new Hm(e);case Ae.CARET:return new Wm(e);case Ae.INK:return new Jm(e);case Ae.POLYGON:return new Um(e);case Ae.HIGHLIGHT:return new Xm(e);case Ae.UNDERLINE:return new Zm(e);case Ae.SQUIGGLY:return new Qm(e);case Ae.STRIKEOUT:return new $m(e);case Ae.STAMP:return new eh(e);case Ae.FILEATTACHMENT:return new rh(e);case Ae.RICHMEDIA:case Ae.SCREEN:return new lh(e);default:return new kp(e)}}},Tp=new WeakMap,Ep=new WeakMap,Dp=new WeakMap,Op=new WeakSet,kp=class e{constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){S(this,Op),b(this,Tp,null),b(this,Ep,!1),b(this,Dp,null),this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableComment=e.enableComment,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,this.hasOwnCommentButton=!1,t&&(this.contentElement=this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:t}){return!!(e!=null&&e.str||t!=null&&t.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var e;let{data:t}=this,n=(e=this.annotationStorage)==null?void 0:e.getEditor(t.id);return n?n.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var e;let t=(e=this.annotationStorage)==null?void 0:e.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:n,inkLists:r,rect:i}=this.data,a=-1/0,o=-1/0;if((n==null?void 0:n.length)>=8){for(let e=0;e<n.length;e+=8)n[e+1]>o?(o=n[e+1],a=n[e+2]):n[e+1]===o&&(a=Math.max(a,n[e+2]));return[a,o]}if((r==null?void 0:r.length)>=1){for(let e of r)for(let t=0,n=e.length;t<n;t+=2)e[t+1]>o?(o=e[t+1],a=e[t]):e[t+1]===o&&(a=Math.max(a,e[t]));if(a!==1/0)return[a,o]}return i?[i[2],i[3]]:null}_normalizePoint(e){let{page:{view:t},viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}}=this.parent;return e[1]=t[3]-e[1]+t[1],e[0]=100*(e[0]-i)/n,e[1]=100*(e[1]-a)/r,e}get commentText(){var e,t;let{data:n}=this;return((e=this.annotationStorage.getRawValue(`${Ee}${n.id}`))==null||(e=e.popup)==null?void 0:e.contents)||((t=n.contentsObj)==null?void 0:t.str)||``}set commentText(e){let{data:t}=this,n={deleted:!e,contents:e||``};this.annotationStorage.updateEditor(t.id,{popup:n})||this.annotationStorage.setValue(`${Ee}${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:n,popupRef:t.popupRef,modificationDate:new Date}),e||this.removePopup()}removePopup(){var e,t;(e=((t=x(Dp,this))==null?void 0:t.popup)||this.popup)==null||e.remove(),C(Dp,this,this.popup=null)}updateEdited(e){var t;if(!this.container)return;e.rect&&(x(Tp,this)||C(Tp,this,{rect:this.data.rect.slice(0)}));let{rect:n,popup:r}=e;n&&f(Op,this,Ap).call(this,n);let i=((t=x(Dp,this))==null?void 0:t.popup)||this.popup;!i&&r!=null&&r.text&&(this._createPopup(r),i=x(Dp,this).popup),i&&(i.updateEdited(e),r!=null&&r.deleted&&(i.remove(),C(Dp,this,null),this.popup=null))}resetEdited(){var e;x(Tp,this)&&(f(Op,this,Ap).call(this,x(Tp,this).rect),(e=x(Dp,this))==null||e.popup.resetEdited(),C(Tp,this,null))}_createContainer(e){let{data:t,parent:{page:n,viewport:r}}=this,i=document.createElement(`section`);i.setAttribute(`data-annotation-id`,t.id),!(this instanceof Rp)&&!(this instanceof Np)&&!(this instanceof lh)&&(i.tabIndex=0);let{style:a}=i;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,t.alternativeText&&(i.title=t.alternativeText),t.noRotate&&i.classList.add(`norotate`),!t.rect||this instanceof Kp){let{rotation:e}=t;return!t.hasOwnCanvas&&e!==0&&this.setRotation(e,i),i}let{width:o,height:s}=this;if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;switch((e>0||n>0)&&(a.borderRadius=`calc(${e}px * var(--total-scale-factor)) / calc(${n}px * var(--total-scale-factor))`),t.borderStyle.style){case je.SOLID:a.borderStyle=`solid`;break;case je.DASHED:a.borderStyle=`dashed`;break;case je.BEVELED:F(`Unimplemented border style: beveled`);break;case je.INSET:F(`Unimplemented border style: inset`);break;case je.UNDERLINE:a.borderBottomStyle=`solid`;break;default:break}let r=t.borderColor||null;r?(C(Ep,this,!0),a.borderColor=z.makeHexColor(...r)):a.borderWidth=0}let c=z.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:l,pageHeight:u,pageX:d,pageY:f}=r.rawDims;a.left=`${100*(c[0]-d)/l}%`,a.top=`${100*(c[1]-f)/u}%`;let{rotation:p}=t;return t.hasOwnCanvas||p===0?(a.width=`${100*o/l}%`,a.height=`${100*s/u}%`):this.setRotation(p,i),i}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=this;e%180!=0&&([i,a]=[a,i]),t.style.width=`${100*i/n}%`,t.style.height=`${100*a/r}%`,t.setAttribute(`data-main-rotation`,(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let r=n.detail[e],i=r[0],a=r.slice(1);n.target.style[t]=vp[`${i}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[t]:vp[`${i}_rgb`](a)})};return L(this,`_commonActions`,{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:t===1||t===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e(`bgColor`,`backgroundColor`,t)},fillColor:t=>{e(`fillColor`,`backgroundColor`,t)},fgColor:t=>{e(`fgColor`,`color`,t)},textColor:t=>{e(`textColor`,`color`,t)},borderColor:t=>{e(`borderColor`,`borderColor`,t)},strokeColor:t=>{e(`strokeColor`,`borderColor`,t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let r of Object.keys(t.detail)){let i=e[r]||n[r];i==null||i(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[r,i]of Object.entries(t)){let a=n[r];a&&(a({detail:{[r]:i},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,n,r,i]=this.data.rect.map(e=>Math.fround(e));if(e.length===8){let[a,o,s,c]=e.subarray(2,6);if(r===a&&i===o&&t===s&&n===c)return}let{style:a}=this.container,o;if(x(Ep,this)){let{borderColor:e,borderWidth:t}=a;a.borderWidth=0,o=[`url('data:image/svg+xml;utf8,`,`<svg xmlns="${Se}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add(`hasBorder`)}let s=r-t,c=i-n,{svgFactory:l}=this,u=l.createElement(`svg`);u.classList.add(`quadrilateralsContainer`),u.setAttribute(`width`,0),u.setAttribute(`height`,0),u.role=`none`;let d=l.createElement(`defs`);u.append(d);let f=l.createElement(`clipPath`),p=`clippath_${this.data.id}`;f.setAttribute(`id`,p),f.setAttribute(`clipPathUnits`,`objectBoundingBox`),d.append(f);for(let n=2,r=e.length;n<r;n+=8){let r=e[n],a=e[n+1],u=e[n+2],d=e[n+3],p=l.createElement(`rect`),m=(u-t)/s,h=(i-a)/c,g=(r-u)/s,_=(a-d)/c;p.setAttribute(`x`,m),p.setAttribute(`y`,h),p.setAttribute(`width`,g),p.setAttribute(`height`,_),f.append(p),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${m}" y="${h}" width="${g}" height="${_}"/>`)}x(Ep,this)&&(o.push(`</g></svg>')`),a.backgroundImage=o.join(``)),this.container.append(u),this.container.style.clipPath=`url(#${p})`}_createPopup(e=null){let{data:t}=this,n,r;e?(n={str:e.text},r=e.date):(n=t.contentsObj,r=t.modificationDate),C(Dp,this,new Kp({data:{color:t.color,titleObj:t.titleObj,modificationDate:r,contentsObj:n,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(x(Dp,this)||this.popup||this.data.popupRef)}get extraPopupElement(){return x(Dp,this)}render(){I("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[e];if(r)for(let{page:e,id:i,exportValues:a}of r){if(e===-1||i===t)continue;let r=typeof a==`string`?a:null,o=document.querySelector(`[data-element-id="${i}"]`);if(o&&!Sp.has(o)){F(`_getElementsByName - element not allowed: ${i}`);continue}n.push({id:i,exportValue:r,domElement:o})}return n}for(let r of document.getElementsByName(e)){let{exportValue:e}=r,i=r.getAttribute(`data-element-id`);i!==t&&Sp.has(r)&&n.push({id:i,exportValue:e,domElement:r})}return n}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add(`highlightArea`);else e.classList.add(`highlightArea`)}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener(`dblclick`,()=>{var n;(n=this.linkService.eventBus)==null||n.dispatch(`switchannotationeditormode`,{source:this,mode:e,editId:t,mustEnterInEditMode:!0})})}updateOC(e){!this.data.oc||!e||(e.isVisible(this.data.oc)?this.show():this.hide())}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?`transparent`:z.makeHexColor(...t)}};function Ap(e){let{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:s}}}}=this;n==null||n.splice(0,4,...e),t.left=`${100*(e[0]-o)/i}%`,t.top=`${100*(a-e[3]+s)/a}%`,r===0?(t.width=`${100*(e[2]-e[0])/i}%`,t.height=`${100*(e[3]-e[1])/a}%`):this.setRotation(r)}var jp=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.editor=e.editor}render(){return this.container.className=`editorAnnotation`,this.container}createOrUpdatePopup(){let{editor:e}=this;e.hasComment&&this._createPopup(e.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e,e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}},Mp=new WeakSet,Np=class extends kp{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!(t!=null&&t.ignoreBorder),createQuadrilaterals:!0}),S(this,Mp),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement(`a`);n.setAttribute(`data-element-id`,e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action,e.overlaidText),r=!0):e.attachment?(f(Mp,this,Fp).call(this,n,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(f(Mp,this,Ip).call(this,n,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(n,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions[`Mouse Up`]||e.actions[`Mouse Down`])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,``),r=!0)),this.container.classList.add(`linkAnnotation`),r&&(this.contentElement=n,this.container.append(n)),this.container}_bindLink(e,t,n=``){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t===``)&&f(Mp,this,Pp).call(this),n&&(e.title=n)}_bindNamedAction(e,t,n=``){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),n&&(e.title=n),f(Mp,this,Pp).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl(``);let n=new Map([[`Action`,`onclick`],[`Mouse Up`,`onmouseup`],[`Mouse Down`,`onmousedown`]]);for(let r of Object.keys(t.actions)){let i=n.get(r);i&&(e[i]=()=>{var e;return(e=this.linkService.eventBus)==null||e.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t.id,name:r}}),!1})}t.overlaidText&&(e.title=t.overlaidText),e.onclick||(e.onclick=()=>!1),f(Mp,this,Pp).call(this)}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl(``)),f(Mp,this,Pp).call(this),!this._fieldObjects){F('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{n==null||n();let{fields:e,refs:r,include:i}=t,a=[];if(e.length!==0||r.length!==0){let t=new Set(r);for(let n of e){let e=this._fieldObjects[n]||[];for(let{id:n}of e)t.add(n)}for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===i&&a.push(n)}else for(let e of Object.values(this._fieldObjects))a.push(...e);let o=this.annotationStorage,s=[];for(let e of a){let{id:t}=e;switch(s.push(t),e.type){case`text`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}case`checkbox`:case`radiobutton`:{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case`combobox`:case`listbox`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);if(n){if(!Sp.has(n)){F(`_bindResetFormAction - element not allowed: ${t}`);continue}n.dispatchEvent(new Event(`resetform`))}}if(this.enableScripting){var c;(c=this.linkService.eventBus)==null||c.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:`app`,ids:s,name:`ResetForm`}})}return!1}}};function Pp(){this.container.setAttribute(`data-internal-link`,``)}function Fp(e,t,n,r=``,i=null){var a=this;e.href=this.linkService.getAnchorUrl(``),n.description?e.title=n.description:r&&(e.title=r);let o=function(){var e=v(function*(){let e=yield a.linkService.getAttachmentContent(t);if(e){var r;(r=a.downloadManager)==null||r.openOrDownloadData(e,n.filename,i)}});return function(){return e.apply(this,arguments)}}();e.onclick=()=>(o(),!1),f(Mp,this,Pp).call(this)}function Ip(e,t,n=``){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),n&&(e.title=n),f(Mp,this,Pp).call(this)}var Lp=class extends kp{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add(`textAnnotation`);let e=document.createElement(`img`);return e.src=this.imageResourcesPath+`annotation-`+this.data.name.toLowerCase()+`.svg`,e.setAttribute(`data-l10n-id`,`pdfjs-text-annotation-type`),e.setAttribute(`data-l10n-args`,JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(e),this.container}},Rp=class extends kp{render(){return this.container}_getKeyModifier(e){return R.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,i){n.includes(`mouse`)?e.addEventListener(n,e=>{var t;(t=this.linkService.eventBus)==null||t.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{var a;if(n===`blur`){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if(n===`focus`){if(t.focused)return;t.focused=!0}i&&((a=this.linkService.eventBus)==null||a.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e)}}))})}_setEventListeners(e,t,n,r){for(let[s,c]of n){var i;if(c===`Action`||(i=this.data.actions)!=null&&i[c]){var a,o;(c===`Focus`||c===`Blur`)&&(t||(t={focused:!1})),this._setEventListener(e,t,s,c,r),c===`Focus`&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(e,t,`blur`,`Blur`,null):c===`Blur`&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(e,t,`focus`,`Focus`,null)}}}_setTextStyle(e){let t=[`left`,`center`,`right`],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||xp,i=e.style,a,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(xe*r))||1);a=Math.min(r,o(t/xe))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(r,o(e/xe))}i.fontSize=`calc(${a}px * var(--total-scale-factor))`,i.color=z.makeHexColor(...n),this.data.textAlignment!==null&&!this.data.comb&&(i.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}},zp=class extends Rp{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,n,r){let i=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),i.setValue(a.id,{[r]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add(`textWidgetAnnotation`);let n=null;if(this.renderForms){var r;let s=e.getValue(t,{value:this.data.fieldValue}),c=s.value||``,l=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;l&&c.length>l&&(c=c.slice(0,l));let u=s.formattedValue||((r=this.data.textContent)==null?void 0:r.join(`
|
|
45
|
-
`))||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,``));let d={userValue:c,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){var i;n=document.createElement(`textarea`),n.textContent=(i=u)==null?c:i,this.data.doNotScroll&&(n.style.overflowY=`hidden`)}else{var a;n=document.createElement(`input`),n.type=this.data.password?`password`:`text`,n.setAttribute(`value`,(a=u)==null?c:a),this.data.doNotScroll&&(n.style.overflowX=`hidden`)}this.data.hasOwnCanvas&&(this.container.classList.add(`hasOwnCanvas`),e.has(t)&&this.container.classList.add(`sandboxModified`)),Sp.add(n),this.contentElement=n,n.setAttribute(`data-element-id`,t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0;let{datetimeFormat:f,datetimeType:p,timeStep:m}=this.data,h=!!p&&this.enableScripting;f&&(n.title=f),this._setRequired(n,this.data.required),l&&(n.maxLength=l),n.addEventListener(`input`,r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,`value`,r.target.value,`value`),d.formattedValue=null}),n.addEventListener(`resetform`,e=>{var t;let r=(t=this.data.defaultFieldValue)==null?``:t;n.value=d.userValue=r,d.formattedValue=null});let g=e=>{let{formattedValue:t}=d;t!=null&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){var o;n.addEventListener(`focus`,e=>{var t;if(d.focused)return;let{target:n}=e;if(h&&(n.type=p,m&&(n.step=m)),d.userValue){let e=d.userValue;if(h)if(p===`time`){let t=new Date(e);n.value=[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>e.toString().padStart(2,`0`)).join(`:`)}else n.value=new Date(e-Cp).toISOString().split(p===`date`?`T`:`.`,1)[0];else n.value=e}d.lastCommittedValue=n.value,d.commitKey=1,(t=this.data.actions)!=null&&t.Focus||(d.focused=!0)}),n.addEventListener(`updatefromsandbox`,n=>{this.container.classList.add(`sandboxModified`),this._dispatchEventFromSandbox({value(n){var r;d.userValue=(r=n.detail.value)==null?``:r,h||e.setValue(t,{value:d.userValue.toString()}),n.target.value=d.userValue},formattedValue(n){let{formattedValue:r}=n.detail;d.formattedValue=r,r!=null&&n.target!==document.activeElement&&(n.target.value=r);let i={formattedValue:r};h&&(i.value=r),e.setValue(t,i)},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{var r;let{charLimit:i}=n.detail,{target:a}=n;if(i===0){a.removeAttribute(`maxLength`);return}a.setAttribute(`maxLength`,i);let o=d.userValue;!o||o.length<=i||(o=o.slice(0,i),a.value=d.userValue=o,e.setValue(t,{value:o}),(r=this.linkService.eventBus)==null||r.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:o,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}},n)}),n.addEventListener(`keydown`,e=>{var n;d.commitKey=1;let r=-1;if(e.key===`Escape`?r=0:e.key===`Enter`&&!this.data.multiLine?r=2:e.key===`Tab`&&(d.commitKey=3),r===-1)return;let{value:i}=e.target;d.lastCommittedValue!==i&&(d.lastCommittedValue=i,d.userValue=i,(n=this.linkService.eventBus)==null||n.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:i,willCommit:!0,commitKey:r,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))});let r=g;g=null,n.addEventListener(`blur`,e=>{var n;if(!d.focused||!e.relatedTarget)return;(n=this.data.actions)!=null&&n.Blur||(d.focused=!1);let{target:i}=e,{value:a}=i;if(h){if(a&&p===`time`){let e=a.split(`:`).map(e=>parseInt(e,10));a=new Date(2e3,0,1,e[0],e[1],e[2]||0).valueOf(),i.step=``}else a.includes(`T`)||(a=`${a}T00:00`),a=new Date(a).valueOf();i.type=`text`}if(d.userValue=a,d.lastCommittedValue!==a){var o;(o=this.linkService.eventBus)==null||o.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,willCommit:!0,commitKey:d.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})}r(e)}),(o=this.data.actions)!=null&&o.Keystroke&&n.addEventListener(`beforeinput`,e=>{var n;d.lastCommittedValue=null;let{data:r,target:i}=e,{value:a,selectionStart:o,selectionEnd:s}=i,c=o,l=s;switch(e.inputType){case`deleteWordBackward`:{let e=a.substring(0,o).match(/\w*\W*$/);e&&(c-=e[0].length);break}case`deleteWordForward`:{let e=a.substring(o).match(/^\W*\w*/);e&&(l+=e[0].length);break}case`deleteContentBackward`:o===s&&--c;break;case`deleteContentForward`:o===s&&(l+=1);break}e.preventDefault(),(n=this.linkService.eventBus)==null||n.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,change:r||``,willCommit:!1,selStart:c,selEnd:l}})}),this._setEventListeners(n,d,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.value)}if(g&&n.addEventListener(`blur`,g),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/l;n.classList.add(`comb`),n.style.setProperty(`--comb-width`,`calc(${e}px * var(--total-scale-factor))`);let t=this.data.textAlignment;if(t===1||t===2){let e=()=>{let e=l-n.value.length;n.style.setProperty(`--comb-offset`,`${t===1?e>>1:e}`)};e();for(let t of[`input`,`blur`,`resetform`,`updatefromsandbox`])n.addEventListener(t,e)}}}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}},Bp=class extends Rp{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}},Vp=class extends Rp{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;typeof r==`string`&&(r=r!==`Off`,e.setValue(n,{value:r})),this.container.classList.add(`buttonWidgetAnnotation`,`checkBox`);let i=document.createElement(`input`);return Sp.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`checkbox`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.setAttribute(`exportValue`,t.exportValue),i.tabIndex=0,i.addEventListener(`change`,r=>{let{name:i,checked:a}=r.target;for(let r of this._getElementsByName(i,n)){let n=a&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:a})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue||`Off`;e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value(t){t.target.checked=t.detail.value!==`Off`,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},Hp=class extends Rp{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`buttonWidgetAnnotation`,`radioButton`);let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.buttonValue!==null&&t.fieldValue===t.buttonValue}).value;if(typeof r==`string`&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(let r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});let i=document.createElement(`input`);if(Sp.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`radio`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.tabIndex=0,i.addEventListener(`change`,t=>{let{name:r,checked:i}=t.target;for(let t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:i})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue;e.target.checked=n!=null&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let r=t.buttonValue;i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value:t=>{let i=r===t.detail.value;for(let r of this._getElementsByName(t.target.name)){let t=i&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)}return this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},Up=class extends Np{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add(`buttonWidgetAnnotation`,`pushButton`);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener(`updatefromsandbox`,e=>{this._dispatchEventFromSandbox({},e)})),e}},Wp=class extends Rp{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`choiceWidgetAnnotation`);let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement(`select`);Sp.add(r),r.setAttribute(`data-element-id`,t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=0;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue;for(let e of r.options)e.selected=e.value===t});let a=(e,t)=>{let n=t.replaceAll(` `,`\xA0`);e.textContent=n,n!==t&&e.setAttribute(`display-value`,t)};for(let e of this.data.options){let t=document.createElement(`option`);a(t,e.displayValue),t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute(`selected`,!0),i=!1),r.append(t)}let o=null;if(i){let e=document.createElement(`option`);e.value=` `,e.setAttribute(`hidden`,!0),e.setAttribute(`selected`,!0),r.prepend(e),o=()=>{e.remove(),r.removeEventListener(`input`,o),o=null},r.addEventListener(`input`,o)}let s=e=>{let t=e?`value`:`textContent`,{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):n.selectedIndex===-1?null:n[n.selectedIndex][t]},c=s(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.getAttribute(`display-value`)||e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener(`updatefromsandbox`,n=>{this._dispatchEventFromSandbox({value(n){o==null||o();let i=n.detail.value,a=new Set(Array.isArray(i)?i:[i]);for(let e of r.options)e.selected=a.has(e.value);e.setValue(t,{value:s(!0)}),c=s(!1)},multipleSelection(e){r.multiple=!0},remove(n){let i=r.options,a=n.detail.remove;i[a].selected=!1,r.remove(a),i.length>0&&Array.prototype.findIndex.call(i,e=>e.selected)===-1&&(i[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},clear(n){for(;r.length!==0;)r.remove(0);e.setValue(t,{value:null,items:[]}),c=s(!1)},insert(n){let{index:i,displayValue:o,exportValue:u}=n.detail.insert,d=r.children[i],f=document.createElement(`option`);a(f,o),f.value=u,d?d.before(f):r.append(f),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},items(n){let{items:i}=n.detail;for(;r.length!==0;)r.remove(0);for(let e of i){let{displayValue:t,exportValue:n}=e,i=document.createElement(`option`);a(i,t),i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},indices(n){let r=new Set(n.detail.indices);for(let e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:s(!0)}),c=s(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),r.addEventListener(`input`,n=>{var r;let i=s(!0),a=s(!1);e.setValue(t,{value:i}),n.preventDefault(),(r=this.linkService.eventBus)==null||r.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:c,change:a,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`],[`input`,`Action`],[`input`,`Validate`]],e=>e.target.value)):r.addEventListener(`input`,function(n){e.setValue(t,{value:s(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},Gp=new WeakSet,Kp=class extends kp{constructor(e){let{data:t,elements:n,parent:r}=e,i=!!r._commentManager;if(super(e,{isRenderable:!i&&kp._hasPopupData(t)}),S(this,Gp),this.elements=n,i&&kp._hasPopupData(t)){let e=this.popup=f(Gp,this,qp).call(this);for(let t of n)t.popup=e}else this.popup=null}render(){let{container:e}=this;e.classList.add(`popupAnnotation`),e.role=`comment`;let t=this.popup=f(Gp,this,qp).call(this),n=[];for(let e of this.elements)e.popup=t,e.container.ariaHasPopup=`dialog`,n.push(e.data.id),e.addHighlightArea();return this.container.setAttribute(`aria-controls`,n.map(e=>`${Te}${e}`).join(`,`)),this.container}};function qp(){return new bm({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}var Jp=new WeakMap,Yp=new WeakMap,Xp=new WeakMap,Zp=new WeakMap,Qp=new WeakMap,$p=new WeakMap,em=new WeakMap,tm=new WeakMap,nm=new WeakMap,rm=new WeakMap,im=new WeakMap,am=new WeakMap,om=new WeakMap,sm=new WeakMap,cm=new WeakMap,lm=new WeakMap,um=new WeakMap,dm=new WeakMap,fm=new WeakMap,pm=new WeakMap,mm=new WeakMap,hm=new WeakMap,gm=new WeakMap,_m=new WeakMap,vm=new WeakMap,ym=new WeakMap,Y=new WeakSet,bm=class{constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:i,contentsObj:a,richText:o,parent:s,rect:c,parentRect:l,open:u,commentManager:d=null}){S(this,Y),b(this,Jp,null),b(this,Yp,f(Y,this,km).bind(this)),b(this,Xp,f(Y,this,Nm).bind(this)),b(this,Zp,f(Y,this,Mm).bind(this)),b(this,Qp,f(Y,this,jm).bind(this)),b(this,$p,null),b(this,em,null),b(this,tm,null),b(this,nm,null),b(this,rm,null),b(this,im,null),b(this,am,null),b(this,om,!1),b(this,sm,null),b(this,cm,null),b(this,lm,null),b(this,um,null),b(this,dm,null),b(this,fm,null),b(this,pm,null),b(this,mm,null),b(this,hm,null),b(this,gm,null),b(this,_m,!1),b(this,vm,null),b(this,ym,null),C(em,this,e),C(hm,this,r),C(tm,this,a),C(mm,this,o),C(im,this,s),C($p,this,t),C(pm,this,c),C(am,this,l),C(rm,this,n),C(Jp,this,d),C(vm,this,n[0]),C(nm,this,Et.toDateObject(i)),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup()),d||(f(Y,this,xm).call(this),x(em,this).hidden=!0,u&&f(Y,this,jm).call(this))}renderCommentButton(){if(x(um,this)){x(um,this).parentNode||x(vm,this).container.after(x(um,this));return}if(x(dm,this)||f(Y,this,Sm).call(this),!x(dm,this))return;let{signal:e}=C(cm,this,new AbortController),t=x(vm,this).hasOwnCommentButton,n=()=>{x(Jp,this).toggleCommentPopup(this,!0,void 0,!t)},r=()=>{x(Jp,this).toggleCommentPopup(this,!1,!0,!t)},i=()=>{x(Jp,this).toggleCommentPopup(this,!1,!1)};if(t){C(um,this,x(vm,this).container);for(let t of this.trigger)t.ariaHasPopup=`dialog`,t.ariaControls=`commentPopup`,t.addEventListener(`keydown`,x(Yp,this),{signal:e}),t.addEventListener(`click`,n,{signal:e}),t.addEventListener(`pointerenter`,r,{signal:e}),t.addEventListener(`pointerleave`,i,{signal:e}),t.classList.add(`popupTriggerArea`)}else{let t=C(um,this,document.createElement(`button`));t.className=`annotationCommentButton`;let a=x(vm,this).container;t.style.zIndex=parseInt(a.style.zIndex,10)+1,t.tabIndex=0,t.ariaHasPopup=`dialog`,t.ariaControls=`commentPopup`,t.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`),f(Y,this,wm).call(this),f(Y,this,Cm).call(this),t.addEventListener(`keydown`,x(Yp,this),{signal:e}),t.addEventListener(`click`,n,{signal:e}),t.addEventListener(`pointerenter`,r,{signal:e}),t.addEventListener(`pointerleave`,i,{signal:e}),a.after(t)}}get commentButtonColor(){let{color:e,opacity:t}=x(vm,this).commentData;return e?x(im,this)._commentManager.makeCommentColor(e,t):null}focusCommentButton(){setTimeout(()=>{var e;(e=x(um,this))==null||e.focus()},0)}getData(){let{richText:e,color:t,opacity:n,creationDate:r,modificationDate:i}=x(vm,this).commentData;return{contentsObj:{str:this.comment},richText:e,color:t,opacity:n,creationDate:r,modificationDate:i}}get elementBeforePopup(){return x(um,this)}get comment(){return x(ym,this)||C(ym,this,x(vm,this).commentText),x(ym,this)}set comment(e){e!==this.comment&&(x(vm,this).commentText=C(ym,this,e))}focus(){var e;(e=x(vm,this).container)==null||e.focus()}get parentBoundingClientRect(){return x(vm,this).layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:t}){x(um,this)&&(x(um,this).classList.toggle(`selected`,e),x(um,this).ariaExpanded=t)}setSelectedCommentButton(e){x(um,this).classList.toggle(`selected`,e)}get commentPopupPosition(){if(x(fm,this))return x(fm,this);let{x:e,y:t,height:n}=x(um,this).getBoundingClientRect(),{x:r,y:i,width:a,height:o}=x(vm,this).layer.getBoundingClientRect();return[(e-r)/a,(t+n-i)/o]}set commentPopupPosition(e){C(fm,this,e)}hasDefaultPopupPosition(){return x(fm,this)===null}get commentButtonPosition(){return x(dm,this)}get commentButtonWidth(){return x(um,this).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){let[t,n]=x(fm,this)||this.commentButtonPosition.map(e=>e/100),r=this.parentBoundingClientRect,{x:i,y:a,width:o,height:s}=r;x(Jp,this).showDialog(null,this,i+t*o,a+n*s,T(T({},e),{},{parentDimensions:r}))}render(){var e,t;if(x(sm,this))return;let n=C(sm,this,document.createElement(`div`));if(n.className=`popup`,x($p,this)){let e=n.style.outlineColor=z.makeHexColor(...x($p,this));n.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let r=document.createElement(`span`);if(r.className=`header`,(e=x(hm,this))!=null&&e.str){let e=document.createElement(`span`);e.className=`title`,r.append(e),{dir:e.dir,str:e.textContent}=x(hm,this)}if(n.append(r),x(nm,this)){let e=document.createElement(`time`);e.className=`popupDate`,e.setAttribute(`data-l10n-id`,`pdfjs-annotation-date-time-string`),e.setAttribute(`data-l10n-args`,JSON.stringify({dateObj:x(nm,this).valueOf()})),e.dateTime=x(nm,this).toISOString(),r.append(e)}Gt({html:Tm.call(f(Y,this))||x(tm,this).str,dir:(t=x(tm,this))==null?void 0:t.dir,className:`popupContent`},n),x(em,this).append(n)}updateEdited({rect:e,popup:t,deleted:n}){var r;if(x(Jp,this)){n?(this.remove(),C(ym,this,null)):t&&(t.deleted?this.remove():(f(Y,this,wm).call(this),C(ym,this,t.text))),e&&(C(dm,this,null),f(Y,this,Sm).call(this),f(Y,this,Cm).call(this));return}if(n||t!=null&&t.deleted){this.remove();return}f(Y,this,xm).call(this),x(gm,this)||C(gm,this,{contentsObj:x(tm,this),richText:x(mm,this)}),e&&C(lm,this,null),t&&t.text&&(C(mm,this,f(Y,this,Om).call(this,t.text)),C(nm,this,Et.toDateObject(t.date)),C(tm,this,null)),(r=x(sm,this))==null||r.remove(),C(sm,this,null)}resetEdited(){var e;x(gm,this)&&({contentsObj:O(C,[tm,this])._,richText:O(C,[mm,this])._}=x(gm,this),C(gm,this,null),(e=x(sm,this))==null||e.remove(),C(sm,this,null),C(lm,this,null))}remove(){var e,t,n;if((e=x(cm,this))==null||e.abort(),C(cm,this,null),(t=x(sm,this))==null||t.remove(),C(sm,this,null),C(_m,this,!1),C(om,this,!1),(n=x(um,this))==null||n.remove(),C(um,this,null),this.trigger)for(let e of this.trigger)e.classList.remove(`popupTriggerArea`)}forceHide(){C(_m,this,this.isVisible),x(_m,this)&&(x(em,this).hidden=!0)}maybeShow(){x(Jp,this)||(f(Y,this,xm).call(this),x(_m,this)&&(x(sm,this)||f(Y,this,Mm).call(this),C(_m,this,!1),x(em,this).hidden=!1))}get isVisible(){return!x(Jp,this)&&x(em,this).hidden===!1}};function xm(){if(x(cm,this))return;C(cm,this,new AbortController);let{signal:e}=x(cm,this);for(let t of this.trigger)t.addEventListener(`click`,x(Qp,this),{signal:e}),t.addEventListener(`pointerenter`,x(Zp,this),{signal:e}),t.addEventListener(`pointerleave`,x(Xp,this),{signal:e}),t.classList.add(`popupTriggerArea`);for(let n of x(rm,this)){var t;(t=n.container)==null||t.addEventListener(`keydown`,x(Yp,this),{signal:e})}}function Sm(){let e=x(rm,this).find(e=>e.hasCommentButton);e&&C(dm,this,e._normalizePoint(e.commentButtonPosition))}function Cm(){if(x(vm,this).extraPopupElement&&!x(vm,this).editor)return;x(um,this)||this.renderCommentButton();let[e,t]=x(dm,this),{style:n}=x(um,this);n.left=`calc(${e}%)`,n.top=`calc(${t}% - var(--comment-button-dim))`}function wm(){x(vm,this).extraPopupElement||(x(um,this)||this.renderCommentButton(),x(um,this).style.backgroundColor=this.commentButtonColor||``)}function Tm(){let e=x(mm,this),t=x(tm,this);return e!=null&&e.str&&(!(t!=null&&t.str)||t.str===e.str)&&x(mm,this).html||null}function Em(){var e;return((e=Tm.call(f(Y,this)))==null||(e=e.attributes)==null||(e=e.style)==null?void 0:e.fontSize)||0}function Dm(){var e;return((e=Tm.call(f(Y,this)))==null||(e=e.attributes)==null||(e=e.style)==null?void 0:e.color)||null}function Om(e){let t=[],n={str:e,html:{name:`div`,attributes:{dir:`auto`},children:[{name:`p`,children:t}]}},r={style:{color:Dm.call(f(Y,this)),fontSize:Em.call(f(Y,this))?`calc(${Em.call(f(Y,this))}px * var(--total-scale-factor))`:``}};for(let n of e.split(`
|
|
46
|
-
`))t.push({name:`span`,value:n,attributes:r});return n}function km(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key===`Enter`||e.key===`Escape`&&x(om,this))&&f(Y,this,jm).call(this)}function Am(){if(x(lm,this)!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:i}}}=x(im,this),a=!!x(am,this),o=x(a?am:pm,this);for(let e of x(rm,this))if(!o||z.intersect(e.data.rect,o)!==null){o=e.data.rect,a=!0;break}let s=z.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),c=a?o[2]-o[0]+5:0,l=s[0]+c,u=s[1];C(lm,this,[100*(l-r)/t,100*(u-i)/n]);let{style:d}=x(em,this);d.left=`${x(lm,this)[0]}%`,d.top=`${x(lm,this)[1]}%`}function jm(){if(x(Jp,this)){x(Jp,this).toggleCommentPopup(this,!1);return}C(om,this,!x(om,this)),x(om,this)?(f(Y,this,Mm).call(this),x(em,this).addEventListener(`click`,x(Qp,this)),x(em,this).addEventListener(`keydown`,x(Yp,this))):(f(Y,this,Nm).call(this),x(em,this).removeEventListener(`click`,x(Qp,this)),x(em,this).removeEventListener(`keydown`,x(Yp,this)))}function Mm(){x(sm,this)||this.render(),this.isVisible?x(om,this)&&x(em,this).classList.add(`focused`):(f(Y,this,Am).call(this),x(em,this).hidden=!1,x(em,this).style.zIndex=parseInt(x(em,this).style.zIndex,10)+1e3)}function Nm(){x(em,this).classList.remove(`focused`),!(x(om,this)||!this.isVisible)&&(x(em,this).hidden=!0,x(em,this).style.zIndex=parseInt(x(em,this).style.zIndex,10)-1e3)}var Pm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=M.FREETEXT}render(){if(this.container.classList.add(`freeTextAnnotation`),this.textContent){let e=this.contentElement=document.createElement(`div`);e.classList.add(`annotationTextContent`),e.setAttribute(`role`,`comment`);for(let t of this.textContent){let n=document.createElement(`span`);n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}},Fm=new WeakMap,Im=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,Fm,null)}render(){this.container.classList.add(`lineAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=C(Fm,this,this.svgFactory.createElement(`svg:line`));return i.setAttribute(`x1`,e.rect[2]-e.lineCoordinates[0]),i.setAttribute(`y1`,e.rect[3]-e.lineCoordinates[1]),i.setAttribute(`x2`,e.rect[2]-e.lineCoordinates[2]),i.setAttribute(`y2`,e.rect[3]-e.lineCoordinates[3]),i.setAttribute(`stroke-width`,e.borderStyle.width||1),i.setAttribute(`stroke`,`transparent`),i.setAttribute(`fill`,`transparent`),r.append(i),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(Fm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Lm=new WeakMap,Rm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,Lm,null)}render(){this.container.classList.add(`squareAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=C(Lm,this,this.svgFactory.createElement(`svg:rect`));return a.setAttribute(`x`,i/2),a.setAttribute(`y`,i/2),a.setAttribute(`width`,t-i),a.setAttribute(`height`,n-i),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(Lm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},zm=new WeakMap,Bm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,zm,null)}render(){this.container.classList.add(`circleAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=C(zm,this,this.svgFactory.createElement(`svg:ellipse`));return a.setAttribute(`cx`,t/2),a.setAttribute(`cy`,n/2),a.setAttribute(`rx`,t/2-i/2),a.setAttribute(`ry`,n/2-i/2),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(zm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Vm=new WeakMap,Hm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,Vm,null),this.containerClassName=`polylineAnnotation`,this.svgElementName=`svg:polyline`}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:n,popupRef:r},width:i,height:a}=this;if(!t)return this.container;let o=this.svgFactory.create(i,a,!0),s=[];for(let n=0,r=t.length;n<r;n+=2){let r=t[n]-e[0],i=e[3]-t[n+1];s.push(`${r},${i}`)}s=s.join(` `);let c=C(Vm,this,this.svgFactory.createElement(this.svgElementName));return c.setAttribute(`points`,s),c.setAttribute(`stroke-width`,n.width||1),c.setAttribute(`stroke`,`transparent`),c.setAttribute(`fill`,`transparent`),o.append(c),this.container.append(o),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(Vm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Um=class extends Hm{constructor(e){super(e),this.containerClassName=`polygonAnnotation`,this.svgElementName=`svg:polygon`}},Wm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add(`caretAnnotation`),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}},Gm=new WeakMap,Km=new WeakMap,qm=new WeakSet,Jm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),S(this,qm),b(this,Gm,null),b(this,Km,[]),this.containerClassName=`inkAnnotation`,this.svgElementName=`svg:polyline`,this.annotationEditorType=this.data.it===`InkHighlight`?M.HIGHLIGHT:M.INK}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,rotation:t,inkLists:n,borderStyle:r,popupRef:i}}=this,{transform:a,width:o,height:s}=f(qm,this,Ym).call(this,t,e),c=this.svgFactory.create(o,s,!0),l=C(Gm,this,this.svgFactory.createElement(`svg:g`));c.append(l),l.setAttribute(`stroke-width`,r.width||1),l.setAttribute(`stroke-linecap`,`round`),l.setAttribute(`stroke-linejoin`,`round`),l.setAttribute(`stroke-miterlimit`,10),l.setAttribute(`stroke`,`transparent`),l.setAttribute(`fill`,`transparent`),l.setAttribute(`transform`,a);for(let e=0,t=n.length;e<t;e++){let t=this.svgFactory.createElement(this.svgElementName);x(Km,this).push(t),t.setAttribute(`points`,n[e].join(`,`)),l.append(t)}return!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:n,rect:r}=e,i=x(Gm,this);if(t>=0&&i.setAttribute(`stroke-width`,t||1),n)for(let e=0,t=x(Km,this).length;e<t;e++)x(Km,this)[e].setAttribute(`points`,n[e].join(`,`));if(r){let{transform:e,width:t,height:n}=f(qm,this,Ym).call(this,this.data.rotation,r);i.parentElement.setAttribute(`viewBox`,`0 0 ${t} ${n}`),i.setAttribute(`transform`,e)}}getElementsToTriggerPopup(){return x(Km,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}};function Ym(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}var Xm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=M.HIGHLIGHT}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`highlightAnnotation`),this._editOnDoubleClick(),e){let t=document.createElement(`mark`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},Zm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`underlineAnnotation`),e){let t=document.createElement(`u`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},Qm=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`squigglyAnnotation`),e){let t=document.createElement(`u`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},$m=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`strikeoutAnnotation`),e){let t=document.createElement(`s`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},eh=class extends kp{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=M.STAMP}render(){return this.container.classList.add(`stampAnnotation`),this.container.setAttribute(`role`,`img`),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}},th=new WeakMap,nh=new WeakSet,rh=class extends kp{constructor(e){var t;super(e,{isRenderable:!0}),S(this,nh),b(this,th,null);let{fileId:n,file:r}=this.data;this.filename=r.filename,this.content=r.content,this.fileId=n,(t=this.linkService.eventBus)==null||t.dispatch(`fileattachmentannotation`,T({source:this,attachmentId:this.fileId},r))}render(){this.container.classList.add(`fileAttachmentAnnotation`);let{container:e,data:t}=this,n;t.hasAppearance||t.fillAlpha===0?n=document.createElement(`div`):(n=document.createElement(`img`),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?`paperclip`:`pushpin`}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`)),n.addEventListener(`dblclick`,f(nh,this,ih).bind(this)),C(th,this,n);let{isMac:r}=R.platform;return e.addEventListener(`keydown`,e=>{e.key===`Enter`&&(r?e.metaKey:e.ctrlKey)&&f(nh,this,ih).call(this)}),!t.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):n.classList.add(`popupTriggerArea`),e.append(n),e}getElementsToTriggerPopup(){return x(th,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}};function ih(){var e=this;return v(function*(){let{fileId:t,filename:n,content:r}=e,i=(yield e.linkService.getAttachmentContent(t))||r;if(i){var a;(a=e.downloadManager)==null||a.openOrDownloadData(i,n)}})()}var ah=new WeakMap,oh=new WeakMap,sh=new WeakMap,ch=new WeakSet,lh=class extends kp{constructor(e){super(e,{isRenderable:!!e.data.richMedia}),S(this,ch),b(this,ah,new AbortController),b(this,oh,null),b(this,sh,null)}render(){this.container.classList.add(`mediaAnnotation`);let{filename:e}=this.data.richMedia,t=document.createElement(`button`);return t.className=`mediaPlayButton`,t.type=`button`,t.title=t.ariaLabel=e,t.addEventListener(`click`,()=>f(ch,this,uh).call(this,t),{signal:x(ah,this).signal}),this.container.append(t),this.container}destroy(){x(ah,this).abort(),x(sh,this)&&(x(sh,this).pause(),x(sh,this).removeAttribute(`src`),x(sh,this).load(),C(sh,this,null)),f(ch,this,dh).call(this)}};function uh(e){var t=this;return v(function*(){let{fileId:n,filename:r,contentType:i}=t.data.richMedia;e.disabled=!0;let a;try{a=yield t.linkService.getAttachmentContent(n)}catch(e){return}finally{e.disabled=!1}if(!a||!e.isConnected)return;let{signal:o}=x(ah,t),s=URL.createObjectURL(new Blob([a],{type:i}));C(oh,t,s);let c=i.startsWith(`audio/`),l=document.createElement(c?`audio`:`video`);if(C(sh,t,l),l.className=`mediaContent`,t._setBackgroundColor(l),l.src=s,l.title=r,l.controls=!0,l.autoplay=!0,l.tabIndex=0,c){let e=!1,n=!1,r=()=>{l.controls=e||n};t.container.addEventListener(`pointerenter`,()=>{e=!0,r()},{signal:o}),t.container.addEventListener(`pointerleave`,()=>{e=!1,r()},{signal:o}),t.container.addEventListener(`focusin`,()=>{n=!0,r()},{signal:o}),t.container.addEventListener(`focusout`,()=>{n=!1,r()},{signal:o})}l.addEventListener(`emptied`,()=>f(ch,t,dh).call(t,s),{once:!0,signal:o}),e.replaceWith(l),l.play().catch(()=>{})})()}function dh(e=x(oh,this)){e&&e===x(oh,this)&&(URL.revokeObjectURL(e),C(oh,this,null))}var fh=new WeakMap,ph=new WeakMap,mh=new WeakMap,hh=new WeakMap,gh=new WeakMap,_h=new WeakMap,vh=new WeakMap,yh=new WeakMap,bh=new WeakSet,xh=class e{constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:a,structTreeLayer:o,commentManager:s,linkService:c,annotationStorage:l}){S(this,bh),b(this,fh,null),b(this,ph,null),b(this,mh,null),b(this,hh,new Map),b(this,gh,null),b(this,_h,null),b(this,vh,[]),b(this,yh,!1),g(this,`zIndex`,0),this.div=e,C(fh,this,t),C(ph,this,n),C(gh,this,o||null),C(_h,this,c||null),C(mh,this,l||new to),this.page=i,this.viewport=a,this._annotationEditorUIManager=r,this._commentManager=s||null}hasEditableAnnotations(){return x(hh,this).size>0}render(e){var t=this;return v(function*(){let{annotations:n,optionalContentConfig:r}=e,i=t.div;Nt(i,t.viewport);let a=new Map,o=[],s={data:null,layer:i,linkService:x(_h,t),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||``,renderForms:e.renderForms!==!1,svgFactory:new bp,annotationStorage:x(mh,t),enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:t,elements:null};for(let e of n){if(e.noHTML)continue;let n=e.annotationType===Ae.POPUP;if(n){let n=a.get(e.id);if(!n)continue;if(!t._commentManager){o.push(e);continue}s.elements=n}else if(e.rect[2]===e.rect[0]||e.rect[3]===e.rect[1])continue;s.data=e;let i=wp.create(s);if(!i.isRenderable)continue;n||(x(vh,t).push(i),e.popupRef&&a.getOrInsertComputed(e.popupRef,st).push(i));let l=i.render();if(e.hidden&&(l.style.visibility=`hidden`),i.updateOC(r),i._isEditable){var c;x(hh,t).set(i.data.id,i),(c=t._annotationEditorUIManager)==null||c.renderAnnotationElement(i)}}yield f(bh,t,Sh).call(t);for(let e of o){let t=s.elements=a.get(e.id);s.data=e;let n=wp.create(s);if(!n.isRenderable)continue;let r=n.render();n.contentElement.id=`${Te}${e.id}`,e.hidden&&(r.style.visibility=`hidden`),t.at(-1).container.after(r)}f(bh,t,Ch).call(t)})()}addLinkAnnotations(t){var n=this;return v(function*(){let r={data:null,layer:n.div,linkService:x(_h,n),svgFactory:new bp,parent:n};for(let i of t){i.borderStyle||(i.borderStyle=e._defaultBorderStyle),r.data=i;let t=wp.create(r);t.isRenderable&&(t.render(),t.contentElement.id=`${Te}${i.id}`,x(vh,n).push(t))}yield f(bh,n,Sh).call(n)})()}update({viewport:e,optionalContentConfig:t}){let n=this.div;this.viewport=e,Nt(n,{rotation:e.rotation});for(let e of x(vh,this))e.updateOC(t);f(bh,this,Ch).call(this),n.hidden=!1}destroy(){for(let n of x(vh,this)){var e,t;(e=n.destroy)==null||e.call(n),(t=x(fh,this))==null||t.removePointerInTextLayer(n.contentElement)}x(vh,this).length=0,x(hh,this).clear(),this.div.replaceChildren()}refreshCanvases(){f(bh,this,Ch).call(this)}getEditableAnnotations(){return x(hh,this).values()}getEditableAnnotation(e){return x(hh,this).get(e)}addFakeAnnotation(e){let{div:t}=this,{id:n,rotation:r}=e,i=new jp({data:{id:n,rect:e.getPDFRect(),rotation:r},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:x(_h,this),annotationStorage:x(mh,this)});return i.render(),i.contentElement.id=`${Te}${n}`,i.createOrUpdatePopup(),x(vh,this).push(i),i}removeAnnotation(e){var t;let n=x(vh,this).findIndex(t=>t.data.id===e);if(n<0)return;let[r]=x(vh,this).splice(n,1);(t=x(fh,this))==null||t.removePointerInTextLayer(r.contentElement)}updateFakeAnnotations(e){if(e.length!==0){for(let t of e)t.updateFakeAnnotationElement(this);f(bh,this,Sh).call(this)}}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}static get _defaultBorderStyle(){return L(this,`_defaultBorderStyle`,Object.freeze({width:1,rawWidth:1,style:je.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};function Sh(){var e=this;return v(function*(){if(x(vh,e).length===0)return;e.div.replaceChildren();let t=[];if(!x(yh,e)){C(yh,e,!0);for(let{contentElement:r,data:{id:i}}of x(vh,e)){var n;let a=r.id=`${Te}${i}`;t.push((n=x(gh,e))==null?void 0:n.getAriaAttributes(a).then(e=>{if(e)for(let[t,n]of e)r.setAttribute(t,n)}))}}x(vh,e).sort(({data:{rect:[e,t,n,r]}},{data:{rect:[i,a,o,s]}})=>{if(e===n&&t===r)return 1;if(i===o&&a===s)return-1;let c=r,l=t,u=(t+r)/2,d=s,f=a,p=(a+s)/2;return u>=d&&p<=l?-1:p>=c&&u<=f?1:(e+n)/2-(i+o)/2});let r=document.createDocumentFragment();for(let t of x(vh,e))if(r.append(t.container),e._commentManager){var i,a;(i=((a=t.extraPopupElement)==null?void 0:a.popup)||t.popup)==null||i.renderCommentButton()}else t.extraPopupElement&&r.append(t.extraPopupElement.render());if(e.div.append(r),yield Promise.all(t),x(fh,e))for(let t of x(vh,e))x(fh,e).addPointerInTextLayer(t.contentElement,!1)})()}function Ch(){if(!x(ph,this))return;let e=this.div;for(let[n,r]of x(ph,this)){let i=e.querySelector(`[data-annotation-id="${n}"]`);if(!i)continue;if(Array.isArray(r))for(let e of r)e.className=`annotationContent`,e.ariaHidden=!0;else r.className=`annotationContent`,r.ariaHidden=!0;let a=[];for(let e of i.children)e.nodeName===`CANVAS`&&a.push(e);for(let e of a)e.remove();let o=Array.isArray(r)?r[0]:r,{firstChild:s}=i;if(s?s.classList.contains(`annotationContent`)?s.after(o):s.before(o):i.append(o),Array.isArray(r)){let e=o;for(let t=1,n=r.length;t<n;t++)e.after(r[t]),e=r[t]}x(ph,this).delete(n);let c=x(hh,this).get(n);if(c)if(c._hasNoCanvas){var t;(t=this._annotationEditorUIManager)==null||t.setMissingCanvas(n,i.id,r),c._hasNoCanvas=!1}else c.canvas=r}}var wh=/\r\n?|\n/g,Th=new WeakMap,Eh=new WeakMap,Dh=new WeakMap,Oh=new WeakMap,kh=new WeakSet,Ah=class e extends W{static get _keyboardManager(){let t=e.prototype,n=e=>e.isEmpty(),r=Rr.TRANSLATE_SMALL,i=Rr.TRANSLATE_BIG;return L(this,`_keyboardManager`,new Rn([[[`ctrl+s`,`mac+meta+s`,`ctrl+p`,`mac+meta+p`],t.commitOrRemove,{bubbles:!0}],[[`ctrl+Enter`,`mac+meta+Enter`],t.commitOrRemove],[[`Escape`],t.commitOrRemove],[[`ArrowLeft`],t._translateEmpty,{args:[-r,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t._translateEmpty,{args:[-i,0],checker:n}],[[`ArrowRight`],t._translateEmpty,{args:[r,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t._translateEmpty,{args:[i,0],checker:n}],[[`ArrowUp`],t._translateEmpty,{args:[0,-r],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t._translateEmpty,{args:[0,-i],checker:n}],[[`ArrowDown`],t._translateEmpty,{args:[0,r],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t._translateEmpty,{args:[0,i],checker:n}]]))}constructor(t){super(T(T({},t),{},{name:`freeTextEditor`})),S(this,kh),b(this,Th,``),b(this,Eh,`${this.id}-editor`),b(this,Dh,null),b(this,Oh,void 0),g(this,`_colorPicker`,null),this.color=t.color||e._defaultColor||W._defaultLineColor,C(Oh,this,t.fontSize||e._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(W._l10nAlert.freetext),this.canAddComment=!1}static initialize(e,t){W.initialize(e,t);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue(`--freetext-padding`))}static updateDefaultParams(t,n){switch(t){case N.FREETEXT_SIZE:e._defaultFontSize=n;break;case N.FREETEXT_COLOR:e._defaultColor=n;break}}updateParams(e,t){switch(e){case N.FREETEXT_SIZE:f(kh,this,jh).call(this,t);break;case N.FREETEXT_COLOR:f(kh,this,Mh).call(this,t);break}}static get defaultPropertiesToUpdate(){return[[N.FREETEXT_SIZE,e._defaultFontSize],[N.FREETEXT_COLOR,e._defaultColor||W._defaultLineColor]]}get propertiesToUpdate(){return[[N.FREETEXT_SIZE,x(Oh,this)],[N.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new mp(this)),[[`colorPicker`,this._colorPicker]]}get colorType(){return N.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let t=this.parentScale;return[-e._internalPadding*t,-(e._internalPadding+x(Oh,this))*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove(`enabled`),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute(`aria-activedescendant`),C(Dh,this,new AbortController);let e=this._uiManager.combinedSignal(x(Dh,this));return this.editorDiv.addEventListener(`keydown`,this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener(`focus`,this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener(`blur`,this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener(`input`,this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener(`paste`,this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add(`enabled`),this.editorDiv.contentEditable=!1,this.div.setAttribute(`aria-activedescendant`,x(Eh,this)),this._isDraggable=!0,(e=x(Dh,this))==null||e.abort(),C(Dh,this,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add(`freetextEditing`),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var t;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(t=this._initialOptions)!=null&&t.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()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=x(Th,this),t=C(Th,this,f(kh,this,Nh).call(this).trimEnd());if(e===t)return;let n=e=>{if(C(Th,this,e),!e){this.remove();return}f(kh,this,Ih).call(this),this._uiManager.rebuild(this),f(kh,this,Ph).call(this)};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),f(kh,this,Ph).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key===`Enter`&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(t){e._keyboardManager.exec(this,t)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,t;(this._isCopy||this.annotationElementId)&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement(`div`),this.editorDiv.className=`internal`,this.editorDiv.setAttribute(`id`,x(Eh,this)),this.editorDiv.setAttribute(`data-l10n-id`,`pdfjs-free-text2`),this.editorDiv.setAttribute(`data-l10n-attrs`,`default-content`),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${x(Oh,this)}px * var(--total-scale-factor))`,n.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement(`div`),this.overlayDiv.classList.add(`overlay`,`enabled`),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[n,r]=this.parentDimensions;if(this.annotationElementId){let{position:i}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[s,c]=this.pageDimensions,[l,u]=this.pageTranslation,d,f;switch(this.rotation){case 0:d=e+(i[0]-l)/s,f=t+this.height-(i[1]-u)/c;break;case 90:d=e+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[o,-a];break;case 180:d=e-this.width+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[-a,-o];break;case 270:d=e+(i[0]-l-this.height*c)/s,f=t+(i[1]-u-this.width*s)/c,[a,o]=[-o,a];break}this.setAt(d*n,f*r,a,o)}else this._moveAfterPaste(e,t);f(kh,this,Ih).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){let n=t.clipboardData||window.clipboardData,{types:r}=n;if(r.length===1&&r[0]===`text/plain`)return;t.preventDefault();let i=Rh.call(e,n.getData(`text`)||``).replaceAll(wh,`
|
|
44
|
+
`,Mc=new WeakMap,Nc=new WeakMap,Pc=new WeakMap,Fc=new WeakMap,Ic=new WeakSet,Lc=class{constructor(){S(this,Ic),b(this,Mc,null),b(this,Nc,null),b(this,Pc,null),b(this,Fc,null)}init(){return x(Mc,this)||C(Mc,this,f(Ic,this,Rc).call(this))}get isReady(){return x(Nc,this)!==null}loadMeshShader(){if(!x(Nc,this)||x(Pc,this))return;let e=x(Nc,this).createShaderModule({code:jc});C(Pc,this,x(Nc,this).createRenderPipeline({layout:`auto`,vertex:{module:e,entryPoint:`vs_main`,buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:`float32x2`}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:`unorm8x4`}]}]},fragment:{module:e,entryPoint:`fs_main`,targets:[{format:x(Fc,this)}]},primitive:{topology:`triangle-list`}}))}draw(e,t,n,r,i,a,o,s){this.loadMeshShader();let c=x(Nc,this),{offsetX:l,offsetY:u,scaleX:d,scaleY:f}=r,p=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(p,0,e);let m=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&c.queue.writeBuffer(m,0,t);let h=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(h,0,new Float32Array([l,u,d,f,a,o,s,0]));let g=c.createBindGroup({layout:x(Pc,this).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:h}}]}),_=new OffscreenCanvas(a,o),v=_.getContext(`webgpu`);v.configure({device:c,format:x(Fc,this),alphaMode:i?`opaque`:`premultiplied`});let y=i?{r:i[0]/255,g:i[1]/255,b:i[2]/255,a:1}:{r:0,g:0,b:0,a:0},b=c.createCommandEncoder(),S=b.beginRenderPass({colorAttachments:[{view:v.getCurrentTexture().createView(),clearValue:y,loadOp:`clear`,storeOp:`store`}]});return n>0&&(S.setPipeline(x(Pc,this)),S.setBindGroup(0,g),S.setVertexBuffer(0,p),S.setVertexBuffer(1,m),S.draw(n)),S.end(),c.queue.submit([b.finish()]),p.destroy(),m.destroy(),h.destroy(),_.transferToImageBitmap()}};function Rc(){var e=this;return v(function*(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{let t=yield navigator.gpu.requestAdapter();return t?(C(Fc,e,navigator.gpu.getPreferredCanvasFormat()),C(Nc,e,yield t.requestDevice()),!0):!1}catch(e){return!1}})()}var zc=new Lc;function Bc(){return zc.init()}function Vc(){return zc.isReady}function Hc(){zc.loadMeshShader()}function Uc(e,t,n,r,i,a,o,s){return zc.draw(e,t,n,r,i,a,o,s)}var Wc={FILL:`Fill`,STROKE:`Stroke`,SHADING:`Shading`};function Gc(e,t){if(!t)return;let n=t[2]-t[0],r=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],n,r),e.clip(i)}var Kc=class{isModifyingCurrentTransform(){return!1}getPattern(){L("Abstract method `getPattern` called.")}},qc=class extends Kc{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type===`radial`}areConic(){if(!this.isRadial())return!1;let e=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return e+this._r1>this._r0&&e+this._r0>this._r1}_createGradient(e,t=null){let n,r=this._p0,i=this._p1;if(t&&(r=r.slice(),i=i.slice(),B.applyTransform(r,t),B.applyTransform(i,t)),this._type===`axial`)n=e.createLinearGradient(r[0],r[1],i[0],i[1]);else if(this._type===`radial`){let a=this._r0,o=this._r1;if(t){let e=new Float32Array(2);B.singularValueDecompose2dScale(t,e),a*=e[0],o*=e[0]}n=e.createRadialGradient(r[0],r[1],a,i[0],i[1],o)}for(let e of this._colorStops)n.addColorStop(e[0],e[1]);return n}_createReversedGradient(e,t=null){let n=this._p1,r=this._p0;t&&(n=n.slice(),r=r.slice(),B.applyTransform(n,t),B.applyTransform(r,t));let i=this._r1,a=this._r0;if(t){let e=new Float32Array(2);B.singularValueDecompose2dScale(t,e),i*=e[0],a*=e[0]}let o=e.createRadialGradient(n[0],n[1],i,r[0],r[1],a),s=this._colorStops.map(([e,t])=>[1-e,t]).reverse();for(let[e,t]of s)o.addColorStop(e,t);return o}getPattern(e,t,n,r){let i;if(r===Wc.STROKE||r===Wc.FILL){if(this.isOriginBased()){let r=B.transform(n,t.baseTransform);this.matrix&&(r=B.transform(r,this.matrix));let i=.001,a=Math.hypot(r[0],r[1]),o=Math.hypot(r[2],r[3]),s=(r[0]*r[2]+r[1]*r[3])/(a*o);if(Math.abs(s)<i)if(this.isRadial()){if(Math.abs(a-o)<i)return this._createGradient(e,r)}else return this._createGradient(e,r)}let a=t.current.getClippedPathBoundingBox(r,At(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,s=Math.ceil(a[3]-a[1])||1,c=t.canvasFactory.create(o,s),l=c.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),n=B.transform(n,[1,0,0,1,a[0],a[1]]),l.transform(...t.baseTransform),this.matrix&&l.transform(...this.matrix),Gc(l,this._bbox),this.areConic()&&(l.fillStyle=this._createReversedGradient(l),l.fill()),l.fillStyle=this._createGradient(l),l.fill(),i=e.createPattern(c.canvas,`no-repeat`),t.canvasFactory.destroy(c);let u=new DOMMatrix(n);i.setTransform(u)}else this.areConic()&&(e.save(),Gc(e,this._bbox),e.fillStyle=this._createReversedGradient(e),e.fillRect(-1e10,-1e10,2e10,2e10),e.restore()),Gc(e,this._bbox),i=this._createGradient(e);return i}};function Jc(e,t,n,r,i,a,o,s){let c=t.coords,l=t.colors,u=e.data,d=e.width*4,f;c[n*2+1]>c[r*2+1]&&(f=n,n=r,r=f,f=a,a=o,o=f),c[r*2+1]>c[i*2+1]&&(f=r,r=i,i=f,f=o,o=s,s=f),c[n*2+1]>c[r*2+1]&&(f=n,n=r,r=f,f=a,a=o,o=f);let p=(c[n*2]+t.offsetX)*t.scaleX,m=(c[n*2+1]+t.offsetY)*t.scaleY,h=(c[r*2]+t.offsetX)*t.scaleX,g=(c[r*2+1]+t.offsetY)*t.scaleY,_=(c[i*2]+t.offsetX)*t.scaleX,v=(c[i*2+1]+t.offsetY)*t.scaleY;if(m>=v)return;let y=l[a*4],b=l[a*4+1],x=l[a*4+2],S=l[o*4],C=l[o*4+1],w=l[o*4+2],T=l[s*4],E=l[s*4+1],D=l[s*4+2],O=Math.round(m),k=Math.round(v),A,ee,j,te,ne,M,re,ie;for(let e=O;e<=k;e++){if(e<g){let t=e<m?0:(m-e)/(m-g);A=p-(p-h)*t,ee=y-(y-S)*t,j=b-(b-C)*t,te=x-(x-w)*t}else{let t;t=e>v?1:g===v?0:(g-e)/(g-v),A=h-(h-_)*t,ee=S-(S-T)*t,j=C-(C-E)*t,te=w-(w-D)*t}let t;t=e<m?0:e>v?1:(m-e)/(m-v),ne=p-(p-_)*t,M=y-(y-T)*t,re=b-(b-E)*t,ie=x-(x-D)*t;let n=Math.round(Math.min(A,ne)),r=Math.round(Math.max(A,ne)),i=d*e+n*4;for(let e=n;e<=r;e++)t=(A-e)/(A-ne),t<0?t=0:t>1&&(t=1),u[i++]=ee-(ee-M)*t|0,u[i++]=j-(j-re)*t|0,u[i++]=te-(te-ie)*t|0,u[i++]=255}}var Yc=class extends Kc{constructor(e){super(),this._posData=e[2],this._colData=e[3],this._vertexCount=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null,Hc()}_createMeshCanvas(e,t,n){let r=1.1,i=3e3,a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),s=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,l=Math.min(Math.ceil(Math.abs(s*e[0]*r)),i)||1,u=Math.min(Math.ceil(Math.abs(c*e[1]*r)),i)||1,d=s?s/l:1,f=c?c/u:1,p={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-o,scaleX:1/d,scaleY:1/f},m=l+4,h=u+4,g=n.create(m,h);if(Vc()&&this._vertexCount>48)g.context.drawImage(Uc(this._posData,this._colData,this._vertexCount,p,t,m,h,2),0,0);else{let e=g.context.createImageData(l,u);if(t){let n=e.data;for(let e=0,r=n.length;e<r;e+=4)n[e]=t[0],n[e+1]=t[1],n[e+2]=t[2],n[e+3]=255}for(let t=0,n=this._vertexCount;t<n;t+=3)Jc(e,p,t,t+1,t+2,t,t+1,t+2);g.context.putImageData(e,2,2)}return{canvas:g.canvas,offsetX:a-2*d,offsetY:o-2*f,scaleX:d,scaleY:f}}isModifyingCurrentTransform(){return!0}getPattern(e,t,n,r){Gc(e,this._bbox);let i=new Float32Array(2);if(r===Wc.SHADING)B.singularValueDecompose2dScale(At(e),i);else if(this.matrix){B.singularValueDecompose2dScale(this.matrix,i);let[e,n]=i;B.singularValueDecompose2dScale(t.baseTransform,i),i[0]*=e,i[1]*=n}else B.singularValueDecompose2dScale(t.baseTransform,i);let a=this._createMeshCanvas(i,r===Wc.SHADING?null:this._background,t.canvasFactory);r!==Wc.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY);let o=e.createPattern(a.canvas,`no-repeat`);return t.canvasFactory.destroy(a),o}},Xc=class extends Kc{getPattern(){return`hotpink`}};function Zc(e){switch(e[0]){case`RadialAxial`:return new qc(e);case`Mesh`:return new Yc(e);case`Dummy`:return new Xc}throw Error(`Unknown IR type: ${e[0]}`)}var Qc={COLORED:1,UNCOLORED:2},$c=class e{constructor(e,t,n,r){var i;this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.needsIsolation=(i=e[9])==null||i,this.ctx=t,this.canvasGraphicsFactory=n,this.baseTransform=r,this.patternBaseMatrix=this.matrix?B.transform(r,this.matrix):r}canSkipPatternCanvas([e,t,n,r]){let[i,a,o,s]=this.bbox,c=Math.abs(this.xstep),l=Math.abs(this.ystep);if(e>c+1e-6||t>l+1e-6)return null;let u=Math.floor((n-o)/c)+1,d=Math.ceil((n+e-i)/c)-1,f=Math.floor((r-s)/l)+1,p=Math.ceil((r+t-a)/l)-1;return d<=u&&p<=f?[u,f]:null}updatePatternDims(e,t){let n=B.inverseTransform(this.patternBaseMatrix),r=[e[0],e[1]],i=[e[2],e[3]];B.applyTransform(r,n),B.applyTransform(i,n),t[0]=Math.abs(i[0]-r[0]),t[1]=Math.abs(i[1]-r[1]),t[2]=Math.min(r[0],i[0]),t[3]=Math.min(r[1],i[1])}_renderTileCanvas(e,t,n,r){var i,a;let[o,s,c,l]=this.bbox,u=e.canvasFactory.create(n.size,r.size),d=u.context,f=this.canvasGraphicsFactory.createCanvasGraphics(d,t);return f.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(f,this.paintType,this.color),d.translate(-n.scale*o,-r.scale*s),f.transform(0,n.scale,0,0,r.scale,0,0),d.save(),(i=f.dependencyTracker)==null||i.save(),this.clipBbox(f,o,s,c,l),f.baseTransform=At(f.ctx),f.executeOperatorList(this.operatorList),f.endDrawing(),(a=f.dependencyTracker)==null||a.restore(),d.restore(),u}_getCombinedScales(){let e=new Float32Array(2);B.singularValueDecompose2dScale(this.matrix,e);let[t,n]=e;return B.singularValueDecompose2dScale(this.baseTransform,e),[t*e[0],n*e[1]]}drawPattern(e,t,n=!1,[r,i],a){let[o,s,c,l]=this.bbox,u=e.dependencyTracker;if(u&&(e.dependencyTracker=new Ro(u,a)),e.save(),n?e.ctx.clip(t,`evenodd`):e.ctx.clip(t),e.ctx.setTransform(...this.patternBaseMatrix),e.ctx.translate(r*this.xstep,i*this.ystep),this.needsIsolation||e.ctx.globalAlpha!==1||e.ctx.globalCompositeOperation!==`source-over`||e.inSMaskMode){let t=c-o,n=l-s,[r,i]=this._getCombinedScales(),u=this.getSizeAndScale(t,this.ctx.canvas.width,r),d=this.getSizeAndScale(n,this.ctx.canvas.height,i),f=this._renderTileCanvas(e,a,u,d);e.ctx.drawImage(f.canvas,o,s,t,n),e.canvasFactory.destroy(f)}else this.setFillAndStrokeStyleToContext(e,this.paintType,this.color),this.clipBbox(e,o,s,c,l),e.baseTransformStack.push(e.baseTransform),e.baseTransform=At(e.ctx),e.executeOperatorList(this.operatorList),e.baseTransform=e.baseTransformStack.pop();e.restore(),u&&(e.dependencyTracker=u)}createPatternCanvas(e,t){let[n,r,i,a]=this.bbox,o=i-n,s=a-r,{xstep:c,ystep:l}=this;c=Math.abs(c),l=Math.abs(l),Le(`TilingType: `+this.tilingType);let[u,d]=this._getCombinedScales(),f=o,p=s,m=!1,h=!1;Math.ceil(c*u)>=Math.ceil(o*u)?f=c:m=!0,Math.ceil(l*d)>=Math.ceil(s*d)?p=l:h=!0;let g=this.getSizeAndScale(f,this.ctx.canvas.width,u),_=this.getSizeAndScale(p,this.ctx.canvas.height,d),v=this._renderTileCanvas(e,t,g,_);if(m||h){let t=v.canvas;m&&(f=c),h&&(p=l);let i=this.getSizeAndScale(f,this.ctx.canvas.width,u),a=this.getSizeAndScale(p,this.ctx.canvas.height,d),g=i.size,_=a.size,y=e.canvasFactory.create(g,_),b=y.context,x=m?Math.floor(o/c):0,S=h?Math.floor(s/l):0;for(let e=0;e<=x;e++)for(let n=0;n<=S;n++)b.drawImage(t,g*e,_*n,g,_,0,0,g,_);return e.canvasFactory.destroy(v),{canvas:y.canvas,canvasEntry:y,scaleX:i.scale,scaleY:a.scale,offsetX:n,offsetY:r}}return{canvas:v.canvas,canvasEntry:v,scaleX:g.scale,scaleY:_.scale,offsetX:n,offsetY:r}}getSizeAndScale(t,n,r){let i=Math.max(e.MAX_PATTERN_SIZE,n),a=Math.ceil(t*r);return a>=i?a=i:r=a/t,{scale:r,size:a}}clipBbox(e,t,n,r,i){let a=r-t,o=i-n,s=new Path2D;s.rect(t,n,a,o),B.axialAlignedBoundingBox([t,n,r,i],At(e.ctx),e.current.minMax),e.ctx.clip(s),e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,i=e.current;switch(i.patternFill=i.patternStroke=!1,t){case Qc.COLORED:let{fillStyle:e,strokeStyle:a}=this.ctx;r.fillStyle=i.fillColor=e,r.strokeStyle=i.strokeColor=a;break;case Qc.UNCOLORED:r.fillStyle=r.strokeStyle=n,i.fillColor=i.strokeColor=n;break;default:throw new Je(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,n,r,i){let a=r===Wc.SHADING?n:B.transform(n,this.patternBaseMatrix),o=this.createPatternCanvas(t,i),s=new DOMMatrix(a);s=s.translate(o.offsetX,o.offsetY),s=s.scale(1/o.scaleX,1/o.scaleY);let c=e.createPattern(o.canvas,`repeat`);return t.canvasFactory.destroy(o.canvasEntry),c.setTransform(s),c}};g($c,`MAX_PATTERN_SIZE`,3e3);var el=16,tl=100,nl=15,rl=10,il=16,al=new DOMMatrix,ol=new Float32Array(2);function sl(e,t){if(e._removeMirroring)throw Error(`Context is already forwarding operations.`);let n=new Map;for(let r of[`save`,`restore`,`rotate`,`scale`,`translate`,`transform`,`setTransform`,`resetTransform`,`clip`,`moveTo`,`lineTo`,`bezierCurveTo`,`quadraticCurveTo`,`arc`,`arcTo`,`ellipse`,`rect`,`roundRect`,`closePath`,`beginPath`]){let i=e[r];typeof i!=`function`||typeof t[r]!=`function`||(n.set(r,i),e[r]=function(...e){return t[r](...e),i.apply(this,e)})}e._removeMirroring=()=>{for(let[t,r]of n)e[t]=r;delete e._removeMirroring}}function cl(e,t,n,r,i,a,o,s,c,l){let[u,d,f,p,m,h]=At(e);if(d===0&&f===0){let g=o*u+m,_=Math.round(g),v=s*p+h,y=Math.round(v),b=(o+c)*u+m,x=Math.abs(Math.round(b)-_)||1,S=(s+l)*p+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),_,y),e.drawImage(t,n,r,i,a,0,0,x,C),e.setTransform(u,d,f,p,m,h),[x,C]}if(u===0&&p===0){let g=s*f+m,_=Math.round(g),v=o*d+h,y=Math.round(v),b=(s+l)*f+m,x=Math.abs(Math.round(b)-_)||1,S=(o+c)*d+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(f),0,_,y),e.drawImage(t,n,r,i,a,0,0,C,x),e.setTransform(u,d,f,p,m,h),[C,x]}e.drawImage(t,n,r,i,a,o,s,c,l);let g=Math.hypot(u,d),_=Math.hypot(f,p);return[g*c,_*l]}var ll=class{constructor(e,t){g(this,`alphaIsShape`,!1),g(this,`fontSize`,0),g(this,`fontSizeScale`,1),g(this,`textMatrix`,null),g(this,`textMatrixScale`,1),g(this,`fontMatrix`,ye),g(this,`leading`,0),g(this,`x`,0),g(this,`y`,0),g(this,`lineX`,0),g(this,`lineY`,0),g(this,`charSpacing`,0),g(this,`wordSpacing`,0),g(this,`textHScale`,1),g(this,`textRenderingMode`,De.FILL),g(this,`textRise`,0),g(this,`fillColor`,`#000000`),g(this,`strokeColor`,`#000000`),g(this,`tilingPatternDims`,null),g(this,`patternFill`,!1),g(this,`patternStroke`,!1),g(this,`fillAlpha`,1),g(this,`strokeAlpha`,1),g(this,`lineWidth`,1),g(this,`activeSMask`,null),g(this,`transferMaps`,`none`),g(this,`minMax`,ve.slice()),this.clipBox=new Float32Array([0,0,e,t])}clone(){var e;let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(e=Wc.FILL,t=null){let n=this.minMax.slice();if(e===Wc.STROKE){t||L(`Stroke bounding box must include transform.`),B.singularValueDecompose2dScale(t,ol);let e=ol[0]*this.lineWidth/2,r=ol[1]*this.lineWidth/2;n[0]-=e,n[1]-=r,n[2]+=e,n[3]+=r}return n}updateClipFromPath(){let e=B.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(ve,0)}getClippedPathBoundingBox(e=Wc.FILL,t=null){return B.intersect(this.clipBox,this.getPathBoundingBox(e,t))}};function ul(e,t){let{width:n,height:r,kind:i}=t,a=r%il,o=(r-a)/il,s=a===0?o:o+1,c=e.createImageData(n,il),l=0,u=t.data,d=c.data,f;if(i===Oe.GRAYSCALE_1BPP)for(f=0;f<s;f++)({srcPos:l}=kc({src:u,srcPos:l,dest:d,width:n,height:f<o?il:a})),e.putImageData(c,0,f*il);else if(i===Oe.RGBA_32BPP){let t=0,r=n*il*4;for(f=0;f<o;f++)d.set(u.subarray(l,l+r)),l+=r,e.putImageData(c,0,t),t+=il;f<s&&(r=n*a*4,d.set(u.subarray(l,l+r)),e.putImageData(c,0,t))}else if(i===Oe.RGB_24BPP)for(f=0;f<s;f++)({srcPos:l}=Ac({src:u,srcPos:l,dest:new Uint32Array(d.buffer),width:n,height:f<o?il:a})),e.putImageData(c,0,f*il);else throw Error(`bad image kind: ${i}`)}function dl(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let{width:n,height:r}=t,i=r%il,a=(r-i)/il,o=i===0?a:a+1,s=e.createImageData(n,il),c=0,l=t.data,u=s.data;for(let t=0;t<o;t++)({srcPos:c}=kc({src:l,srcPos:c,dest:u,width:n,height:t<a?il:i,nonBlackColor:0})),e.putImageData(s,0,t*il)}function fl(e,t){for(let n of[`strokeStyle`,`fillStyle`,`fillRule`,`globalAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`globalCompositeOperation`,`font`,`filter`])e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function pl(e){e.strokeStyle=e.fillStyle=`#000000`,e.fillRule=`nonzero`,e.globalAlpha=1,e.lineWidth=1,e.lineCap=`butt`,e.lineJoin=`miter`,e.miterLimit=10,e.globalCompositeOperation=`source-over`,e.font=`10px sans-serif`,e.setLineDash!==void 0&&(e.setLineDash([]),e.lineDashOffset=0);let{filter:t}=e;t!==`none`&&t!==``&&(e.filter=`none`)}function ml(e,t){if(t)return!0;B.singularValueDecompose2dScale(e,ol);let n=Math.fround(Nt.pixelRatio*ft.PDF_TO_CSS_UNITS);return ol[0]<=n&&ol[1]<=n}var hl=[`butt`,`round`,`square`],gl=[`miter`,`round`,`bevel`],_l={},vl={},yl=new WeakMap,bl=new WeakMap,xl=new WeakMap,Sl=new WeakMap,Cl=new WeakMap,wl=new WeakMap,Tl=new WeakMap,El=new WeakMap,Dl=new WeakMap,Ol=new WeakMap,J=new WeakSet,kl=class e{constructor(e,t,n,r,i,{optionalContentConfig:a,markedContentStack:o=null},s,c,l,u){S(this,J),b(this,yl,0),b(this,bl,0),b(this,xl,null),b(this,Sl,null),b(this,Cl,null),b(this,wl,null),b(this,Tl,1),b(this,El,void 0),b(this,Dl,null),b(this,Ol,[]),this.ctx=e,this.current=new ll(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=l==null?null:l,this.imagesTracker=u==null?null:u}getObject(e,t,n=null){if(typeof t==`string`){var r;return(r=this.dependencyTracker)==null||r.recordNamedDependency(e,t),t.startsWith(`g_`)?this.commonObjs.get(t):this.objs.get(t)}return n}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){let i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=r||`#ffffff`,this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,n){let e=this.transparentCanvasEntry=this.canvasFactory.create(i,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=e,this.ctx.save(),this.ctx.transform(...At(this.compositeCtx))}this.ctx.save(),pl(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[3]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=At(this.ctx)}executeOperatorList(e,t,n,r,i){let a=e.argsArray,o=e.fnArray,s=t||0,c=a.length;if(c===s)return s;let l=c-s>rl&&typeof n==`function`,u=l?Date.now()+nl:0,d=0,f=this.commonObjs,p=this.objs,m,h;for(;;){if(r!==void 0){if(s===r.nextBreakPoint)return r.breakIt(s,n),s;if(r.shouldSkip(s)){if(++s===c)return s;continue}}if(!i||i(s)){var g;if(m=o[s],h=(g=a[s])==null?null:g,m!==F.dependency)h===null?this[m](s):this[m](s,...h);else for(let e of h){var _;(_=this.dependencyTracker)==null||_.recordNamedData(e,s);let t=e.startsWith(`g_`)?f:p;if(!t.has(e))return t.get(e,n),s}}if(s++,s===c)return s;if(l&&++d>rl){if(Date.now()>u)return n(),s;d=0}}}endDrawing(){f(J,this,Al).call(this);for(let e of this.smaskGroupCanvases)this.canvasFactory.destroy(e);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(let e of x(Ol,this))f(J,this,zl).call(this,e);x(Ol,this).length=0,C(xl,this,null),C(Sl,this,null),C(Cl,this,null),C(wl,this,null),C(Tl,this,1),C(Dl,this,null),C(bl,this,0),C(yl,this,0),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),f(J,this,jl).call(this)}_scaleImage(e,t){var n,r;let i=(n=e.width)==null?e.displayWidth:n,a=(r=e.height)==null?e.displayHeight:r,o=Math.max(Math.hypot(t[0],t[1]),1),s=Math.max(Math.hypot(t[2],t[3]),1),c=[],l=o,u=s,d=i,f=a;for(;l>2&&d>1||u>2&&f>1;){let e=d,t=f;l>2&&d>1&&(e=Math.ceil(d/2),l/=d/e),u>2&&f>1&&(t=Math.ceil(f/2),u/=f/t),c.push({newWidth:e,newHeight:t}),d=e,f=t}if(c.length===0)return{img:e,paintWidth:i,paintHeight:a,tmpCanvas:null};if(c.length===1){let{newWidth:t,newHeight:n}=c[0],r=this.canvasFactory.create(t,n);return r.context.drawImage(e,0,0,i,a,0,0,t,n),{img:r.canvas,paintWidth:t,paintHeight:n,tmpCanvas:r}}let p=this.canvasFactory.create(1,1),m=this.canvasFactory.create(1,1),h=i,g=a,_=e;for(let{newWidth:e,newHeight:t}of c)this.canvasFactory.reset(m,e,t),m.context.drawImage(_,0,0,h,g,0,0,e,t),[p,m]=[m,p],_=p.canvas,h=e,g=t;return this.canvasFactory.destroy(m),{img:p.canvas,paintWidth:h,paintHeight:g,tmpCanvas:p}}_createMaskCanvas(e,t){var n;let r=this.ctx,{width:i,height:a}=t,o=this.current.fillColor,s=this.current.patternFill,c=At(r),l,u,d,f;if((t.bitmap||t.data)&&t.count>1){let n=t.bitmap||t.data.buffer;u=JSON.stringify(s?c:[c.slice(0,4),o]),l=this._cachedBitmapsMap.getOrInsertComputed(n,st);let r=l.get(u);if(r&&!s){var p;let t=Math.round(Math.min(c[0],c[2])+c[4]),n=Math.round(Math.min(c[1],c[3])+c[5]);return(p=this.dependencyTracker)==null||p.recordDependencies(e,zo.transformAndFill),{canvas:r,offsetX:t,offsetY:n}}d=r}d||(f=this.canvasFactory.create(i,a),dl(f.context,t));let m=B.transform(c,[1/i,0,0,-1/a,0,0]);m=B.transform(m,[1,0,0,1,0,-a]);let h=ve.slice();B.axialAlignedBoundingBox([0,0,i,a],m,h);let[g,_,v,y]=h,b=Math.round(v-g)||1,x=Math.round(y-_)||1,S=this.canvasFactory.create(b,x),C=S.context,w=g,T=_;C.translate(-w,-T),C.transform(...m);let E=null;if(!d){let e=this._scaleImage(f.canvas,jt(C));d=e.img,E=e.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),l&&s&&(l.set(u,d),E=null,f=null)}C.imageSmoothingEnabled=ml(At(C),t.interpolate),cl(C,d,0,0,d.width,d.height,0,0,i,a),E&&this.canvasFactory.destroy(E),f&&this.canvasFactory.destroy(f),C.globalCompositeOperation=`source-in`;let D=B.transform(jt(C),[1,0,0,1,-w,-T]);return C.fillStyle=s?o.getPattern(r,this,D,Wc.FILL,e):o,C.fillRect(0,0,i,a),l&&!s&&l.set(u,S.canvas),(n=this.dependencyTracker)==null||n.recordDependencies(e,zo.transformAndFill),{canvas:S.canvas,canvasEntry:l&&!s?null:S,offsetX:Math.round(w),offsetY:Math.round(T)}}setLineWidth(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`lineWidth`,e),t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`lineCap`,e),this.ctx.lineCap=hl[t]}setLineJoin(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`lineJoin`,e),this.ctx.lineJoin=gl[t]}setMiterLimit(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`miterLimit`,e),this.ctx.miterLimit=t}setDash(e,t,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData(`dash`,e);let i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(t),i.lineDashOffset=n)}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){for(let[s,c]of t)switch(s){case`LW`:this.setLineWidth(e,c);break;case`LC`:this.setLineCap(e,c);break;case`LJ`:this.setLineJoin(e,c);break;case`ML`:this.setMiterLimit(e,c);break;case`D`:this.setDash(e,c[0],c[1]);break;case`RI`:this.setRenderingIntent(e,c);break;case`FL`:this.setFlatness(e,c);break;case`Font`:this.setFont(e,c[0],c[1]);break;case`CA`:var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`strokeAlpha`,e),this.current.strokeAlpha=c;break;case`ca`:var r;(r=this.dependencyTracker)==null||r.recordSimpleData(`fillAlpha`,e),this.ctx.globalAlpha=this.current.fillAlpha=c;break;case`BM`:var i;(i=this.dependencyTracker)==null||i.recordSimpleData(`globalCompositeOperation`,e),this.ctx.globalCompositeOperation=c;break;case`SMask`:var a;(a=this.dependencyTracker)==null||a.recordSimpleData(`SMask`,e),this.current.activeSMask=c?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(e);break;case`TR`:var o;(o=this.dependencyTracker)==null||o.recordSimpleData(`filter`,e),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(c);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){e!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(e))}checkSMaskState(e){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode(e):!this.current.activeSMask&&t?this.endSMaskMode():this.current.activeSMask&&t&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){let{canvas:t,subtype:n,backdrop:r,transferMap:i}=e,a=n===`Luminosity`||n===`Alpha`&&i;if(!a&&!(n===`Luminosity`&&r)){this.smaskPreparedFor=e;return}let o;if(n===`Luminosity`&&r){var s;let[e,t,n]=Dt(r),a=Math.round(.3*e+.59*t+.11*n);o=(s=i==null?void 0:i[a])==null?a:s}else{var c;o=(c=i==null?void 0:i[0])==null?0:c}let{width:l,height:u}=this.ctx.canvas,d=t.width*t.height,f=l*u<4*d,p=a?{url:n===`Alpha`?this.filterFactory.addAlphaFilter(i):this.filterFactory.addLuminosityFilter(i),subtype:n,transferMap:i}:null,m=n===`Luminosity`?r:null,h,g,_;f?(h=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,l,u,m,p),g=0,_=0):(h=this._bakeSMaskCanvas(t,0,0,t.width,t.height,m,p),g=e.offsetX,_=e.offsetY),this.smaskPreparedEntry=h,this.smaskPreparedFor=e,this.smaskPreparedOffsetX=g,this.smaskPreparedOffsetY=_,this.smaskPreparedOOBAlpha=!f&&o!==0?o:null}_bakeSMaskCanvas(e,t,n,r,i,a,o){!a&&!o&&L(`_bakeSMaskCanvas with neither backdrop nor filter`);let s=this.canvasFactory.create(r,i),c=s.context;if(c.drawImage(e,t,n),a&&(c.globalCompositeOperation=`destination-atop`,c.fillStyle=a,c.fillRect(0,0,r,i)),!o)return s;let l=this.canvasFactory.create(r,i),u=l.context;u.filter=o.url;let d=z.isCanvasFilterSupported&&u.filter!==`none`&&u.filter!==``;if(u.drawImage(s.canvas,0,0),z.isCanvasFilterSupported&&(u.filter=`none`),!d){let e=u.getImageData(0,0,r,i),{data:t}=e,{transferMap:n}=o;if(o.subtype===`Luminosity`)for(let e=0,r=t.length;e<r;e+=4){var f;let r=.3*t[e]+.59*t[e+1]+.11*t[e+2]+.5|0;t[e]=t[e+1]=t[e+2]=0,t[e+3]=(f=n==null?void 0:n[r])==null?r:f}else for(let e=3,r=t.length;e<r;e+=4)t[e]=n[t[e]];u.putImageData(e,0,0)}return this.canvasFactory.destroy(s),l}beginSMaskMode(e){if(this.inSMaskMode)throw Error(`beginSMaskMode called while already in smask mode`);let{width:t,height:n}=this.ctx.canvas,r=this.canvasFactory.create(t,n);this.smaskScratchCanvas=r,this.suspendedCtx=this.ctx;let i=this.ctx=r.context;i.setTransform(this.suspendedCtx.getTransform()),fl(this.suspendedCtx,i),sl(i,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(e,[[`BM`,`source-over`]])}endSMaskMode(){if(!this.inSMaskMode)throw Error(`endSMaskMode called while not in smask mode`);this.ctx._removeMirroring(),fl(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}compose(e){if(!this.current.activeSMask)return;e=e?[Math.floor(e[0]),Math.floor(e[1]),Math.ceil(e[2]),Math.ceil(e[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,n=this.suspendedCtx,r=x(bl,this)>0&&n===this.ctx;this.composeSMask(r?null:n,t,this.ctx,e),!r&&(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(e,t,n,r){let i=r[0],a=r[1],o=r[2]-i,s=r[3]-a;if(o===0||s===0)return;let c=this.smaskPreparedEntry;if(c){let e=i,r=a,l=o,u=s,d=this.smaskPreparedOOBAlpha,f=d!==null;if(f){e=Math.max(i,t.offsetX),r=Math.max(a,t.offsetY);let n=Math.min(i+o,t.offsetX+t.canvas.width),c=Math.min(a+s,t.offsetY+t.canvas.height);l=n-e,u=c-r}if(l>0&&u>0){let t=e-this.smaskPreparedOffsetX,i=r-this.smaskPreparedOffsetY;n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0);let a=new Path2D;a.rect(e,r,l,u),n.clip(a),n.globalCompositeOperation=`destination-in`,n.drawImage(c.canvas,t,i,l,u,e,r,l,u),n.restore()}f&&d<255&&this._applySMaskOOBAlpha(n,i,a,o,s,e,r,e+l,r+u,d)}else this.genericComposeSMask(t,n,o,s,i,a);e&&(e.save(),e.globalAlpha=1,e.globalCompositeOperation=t.blendMode||`source-over`,e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,i,a,o,s,i,a,o,s),e.restore())}_applySMaskOOBAlpha(e,t,n,r,i,a,o,s,c,l){let u=a<s&&o<c;if(u&&a===t&&o===n&&s===t+r&&c===n+i)return;let d=new Path2D;d.rect(t,n,r,i),u&&d.rect(a,o,s-a,c-o),e.save(),e.globalAlpha=l/255,e.setTransform(1,0,0,1,0,0),e.clip(d,`evenodd`),e.globalCompositeOperation=`destination-in`,e.fillStyle=`#000000`,e.fillRect(t,n,r,i),e.restore()}genericComposeSMask(e,t,n,r,i,a){let{context:o,offsetX:s,offsetY:c}=e;t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let l=new Path2D;l.rect(i,a,n,r),t.clip(l),t.globalCompositeOperation=`destination-in`,t.drawImage(o.canvas,i-s,a-c,n,r,i,a,n,r),t.restore()}save(e){var t;this.inSMaskMode&&fl(this.ctx,this.suspendedCtx),this.ctx.save();let n=this.current;this.stateStack.push(n),this.current=n.clone(),(t=this.dependencyTracker)==null||t.save(e)}restore(e){var t;if((t=this.dependencyTracker)==null||t.restore(e),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(fl(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(e),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,t,n,r,i,a,o){var s;(s=this.dependencyTracker)==null||s.recordIncrementalData(`transform`,e),this.ctx.transform(t,n,r,i,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n,r){let[i]=n;if(!r){i||(i=n[0]=new Path2D),t!==F.stroke&&t!==F.closeStroke&&(this.current.tilingPatternDims=null),this[t](e,i);return}if(this.dependencyTracker!==null){let n=t===F.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,r[0]-n,r[2]+n,r[1]-n,r[3]+n).recordDependencies(e,[`transform`])}i instanceof Path2D||(i=n[0]=Gt(i)),B.axialAlignedBoundingBox(r,At(this.ctx),this.current.minMax);let a=this.current.tilingPatternDims;if(a&&t!==F.stroke&&t!==F.closeStroke&&this.current.fillColor instanceof $c){let e=B.intersect(this.current.clipBox,this.current.minMax);e?this.current.fillColor.updatePatternDims(e,a):this.current.tilingPatternDims=null}this[t](e,i),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t,n=!0){var r;let i=n&&f(J,this,Fl).call(this,this.current.strokeAlpha),a=this.ctx,o=this.current.strokeColor;if(a.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof o==`object`&&o&&o.getPattern){let n=o.isModifyingCurrentTransform()?a.getTransform():null;if(a.save(),a.strokeStyle=o.getPattern(a,this,jt(a),Wc.STROKE,e),n){let e=new Path2D;e.addPath(t,a.getTransform().invertSelf().multiplySelf(n)),t=e}this.rescaleAndStroke(t,!1),a.restore()}else this.rescaleAndStroke(t,!0);(r=this.dependencyTracker)==null||r.recordDependencies(e,zo.stroke),n&&this.consumePath(e,t,this.current.getClippedPathBoundingBox(Wc.STROKE,At(this.ctx))),a.globalAlpha=this.current.fillAlpha,f(J,this,Il).call(this,i)}closeStroke(e,t){this.stroke(e,t)}fill(e,t,n=!0){var r;let i=n&&f(J,this,Fl).call(this,this.current.fillAlpha),a=this.ctx,o=this.current.fillColor,s=this.current.patternFill,c=!1,l=this.current.getClippedPathBoundingBox();if((r=this.dependencyTracker)==null||r.recordDependencies(e,zo.fill),s){var u;let r=this.current.tilingPatternDims,s=r&&o.canSkipPatternCanvas(r);if(s){o.drawPattern(this,t,this.pendingEOFill,s,e),this.pendingEOFill=!1,n&&this.consumePath(e,t,l),this.current.tilingPatternDims=null,f(J,this,Il).call(this,i);return}let d=o.isModifyingCurrentTransform()?a.getTransform():null;if((u=this.dependencyTracker)==null||u.save(e),a.save(),a.fillStyle=o.getPattern(a,this,jt(a),Wc.FILL,e),d){let e=new Path2D;e.addPath(t,a.getTransform().invertSelf().multiplySelf(d)),t=e}c=!0}if(this.contentVisible&&l!==null&&(this.pendingEOFill?(a.fill(t,`evenodd`),this.pendingEOFill=!1):a.fill(t)),c){var d;a.restore(),(d=this.dependencyTracker)==null||d.restore(e)}n&&this.consumePath(e,t,l),f(J,this,Il).call(this,i)}eoFill(e,t){this.pendingEOFill=!0,this.fill(e,t)}fillStroke(e,t){let n=f(J,this,Fl).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1),this.stroke(e,t,!1),this.consumePath(e,t),f(J,this,Il).call(this,n)}eoFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}closeFillStroke(e,t){this.fillStroke(e,t)}closeEOFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}endPath(e,t){this.consumePath(e,t)}rawFillPath(e,t){var n;let r=f(J,this,Fl).call(this,this.current.fillAlpha);this.ctx.fill(t),(n=this.dependencyTracker)==null||n.recordDependencies(e,zo.rawFillPath).recordOperation(e),f(J,this,Il).call(this,r)}clip(e){var t;(t=this.dependencyTracker)==null||t.recordFutureForcedDependency(`clipMode`,e),this.pendingClip=_l}eoClip(e){var t;(t=this.dependencyTracker)==null||t.recordFutureForcedDependency(`clipMode`,e),this.pendingClip=vl}beginText(e){var t;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(t=this.dependencyTracker)==null||t.recordOpenMarker(e).resetIncrementalData(`sameLineText`).resetIncrementalData(`moveText`,e)}endText(e){let t=this.pendingTextPaths,n=this.ctx;if(this.dependencyTracker){let{dependencyTracker:n}=this;t!==void 0&&n.recordFutureForcedDependency(`textClip`,n.getOpenMarker()).recordFutureForcedDependency(`textClip`,e),n.recordCloseMarker(e)}if(t!==void 0){let e=new Path2D,r=n.getTransform().invertSelf();for(let{transform:n,x:i,y:a,fontSize:o,path:s}of t)s&&e.addPath(s,new DOMMatrix(n).preMultiplySelf(r).translate(i,a).scale(o,-o));n.clip(e)}delete this.pendingTextPaths}setCharSpacing(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`charSpacing`,e),this.current.charSpacing=t}setWordSpacing(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`wordSpacing`,e),this.current.wordSpacing=t}setHScale(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`hScale`,e),this.current.textHScale=t/100}setLeading(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`leading`,e),this.current.leading=-t}setFont(e,t,n){var r,i;(r=this.dependencyTracker)==null||r.recordSimpleData(`font`,e).recordSimpleDataFromNamed(`fontObj`,t,e);let a=this.commonObjs.get(t),o=this.current;if(!a)throw Error(`Can't find font for ${t}`);if(o.fontMatrix=a.fontMatrix||ye,(o.fontMatrix[0]===0||o.fontMatrix[3]===0)&&I(`Invalid font matrix for font `+t),n<0?(n=-n,o.fontDirection=-1):o.fontDirection=1,this.current.font=a,this.current.fontSize=n,a.isType3Font)return;let s=a.loadedName||`sans-serif`,c=((i=a.systemFontInfo)==null?void 0:i.css)||`"${s}", ${a.fallbackName}`,l=`normal`;a.black?l=`900`:a.bold&&(l=`bold`);let u=a.italic?`italic`:`normal`,d=V(n,el,tl);this.current.fontSizeScale=n/d,this.ctx.font=`${u} ${l} ${d}px ${c}`}setTextRenderingMode(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`textRenderingMode`,e),this.current.textRenderingMode=t}setTextRise(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`textRise`,e),this.current.textRise=t}moveText(e,t,n){var r;(r=this.dependencyTracker)==null||r.resetIncrementalData(`sameLineText`).recordIncrementalData(`moveText`,e),this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=n}setLeadingMoveText(e,t,n){this.setLeading(e,-n),this.moveText(e,t,n)}setTextMatrix(e,t){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData(`sameLineText`).recordSimpleData(`textMatrix`,e);let{current:r}=this;r.textMatrix=t,r.textMatrixScale=Math.hypot(t[0],t[1]),r.x=r.lineX=0,r.y=r.lineY=0}nextLine(e){var t,n;this.moveText(e,0,this.current.leading),(t=this.dependencyTracker)==null||t.recordIncrementalData(`moveText`,(n=this.dependencyTracker.getSimpleIndex(`leading`))==null?e:n)}paintChar(e,t,n,r,i,a){let o=this.ctx,s=this.current,c=s.font,l=s.textRenderingMode,u=s.fontSize/s.fontSizeScale,d=l&De.FILL_STROKE_MASK,p=!!(l&De.ADD_TO_PATH_FLAG),m=s.patternFill&&!c.missingFile,h=s.patternStroke&&!c.missingFile,g;if((c.disableFontFace||p||m||h)&&!c.missingFile&&(g=c.getPathGenerator(this.commonObjs,t)),g&&(c.disableFontFace||m||h)){var _;o.save(),o.translate(n,r),o.scale(u,-u),(_=this.dependencyTracker)==null||_.recordCharacterBBox(e,o,c);let t;if(d===De.FILL||d===De.FILL_STROKE)if(i){t=o.getTransform(),o.setTransform(...i);let e=f(J,this,Ll).call(this,g,t,i);o.fill(e)}else o.fill(g);if(d===De.STROKE||d===De.FILL_STROKE)if(a){t||(t=o.getTransform()),o.setTransform(...a);let{a:e,b:n,c:r,d:i}=t,s=B.inverseTransform(a),c=B.transform([e,n,r,i,0,0],s);B.singularValueDecompose2dScale(c,ol),o.lineWidth*=Math.max(ol[0],ol[1])/u,o.stroke(f(J,this,Ll).call(this,g,t,a))}else o.lineWidth/=u,o.stroke(g);o.restore()}else{if(d===De.FILL||d===De.FILL_STROKE){var v;o.fillText(t,n,r),(v=this.dependencyTracker)==null||v.recordCharacterBBox(e,o,c,u,n,r,()=>o.measureText(t))}if(d===De.STROKE||d===De.FILL_STROKE){if(this.dependencyTracker){var y;(y=this.dependencyTracker)==null||y.recordCharacterBBox(e,o,c,u,n,r,()=>o.measureText(t)).recordDependencies(e,zo.stroke)}o.strokeText(t,n,r)}}if(p){var b;(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:At(o),x:n,y:r,fontSize:u,path:g}),(b=this.dependencyTracker)==null||b.recordCharacterBBox(e,o,c,u,n,r)}}get isFontSubpixelAAEnabled(){let e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1),t.fillText(`I`,0,10);let n=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let r=!1;for(let e=3;e<n.length;e+=4)if(n[e]>0&&n[e]<255){r=!0;break}return R(this,`isFontSubpixelAAEnabled`,r)}showText(e,t){var n;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(e,zo.showText).resetBBox(e),this.current.textRenderingMode&De.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency(`textClip`,e).inheritPendingDependenciesAsFutureForcedDependencies());let r=this.current,i=r.font;if(i.isType3Font){var a;let n=f(J,this,Fl).call(this,r.fillAlpha);this.showType3Text(e,t),(a=this.dependencyTracker)==null||a.recordShowTextOperation(e),f(J,this,Il).call(this,n);return}let o=r.fontSize;if(o===0){var s;(s=this.dependencyTracker)==null||s.recordOperation(e);return}let c=f(J,this,Fl).call(this,r.fillAlpha),l=this.ctx,u=r.fontSizeScale,d=r.charSpacing,p=r.wordSpacing,m=r.fontDirection,h=r.textHScale*m,g=t.length,_=i.vertical,v=_?1:-1,y=i.defaultVMetrics,b=o*r.fontMatrix[0],x=r.textRenderingMode===De.FILL&&!i.disableFontFace&&!r.patternFill;l.save(),r.textMatrix&&l.transform(...r.textMatrix),l.translate(r.x,r.y+r.textRise),m>0?l.scale(h,-1):l.scale(h,1);let S,C,w=r.textRenderingMode&De.FILL_STROKE_MASK,T=w===De.FILL||w===De.FILL_STROKE,E=w===De.STROKE||w===De.FILL_STROKE,D=r.lineWidth,O=r.textMatrixScale;if(O===0||D===0?E&&(D=this.getSinglePixelWidth()):D/=O,u!==1&&(l.scale(u,u),D/=u),l.lineWidth=D,T&&r.patternFill){l.save();let t=r.fillColor.getPattern(l,this,jt(l),Wc.FILL,e);S=At(l),l.restore(),l.fillStyle=t}if(E&&r.patternStroke){l.save();let t=r.strokeColor.getPattern(l,this,jt(l),Wc.STROKE,e);C=At(l),l.restore(),l.strokeStyle=t}if(i.isInvalidPDFjsFont){let n=[],i=0;for(let e of t)n.push(e.unicode),i+=e.width;let a=n.join(``);if(l.fillText(a,0,0),this.dependencyTracker!==null){let t=l.measureText(a);this.dependencyTracker.recordBBox(e,this.ctx,-t.actualBoundingBoxLeft,t.actualBoundingBoxRight,-t.actualBoundingBoxAscent,t.actualBoundingBoxDescent).recordShowTextOperation(e)}r.x+=i*b*h,l.restore(),this.compose(),f(J,this,Il).call(this,c);return}let k=0,A;for(A=0;A<g;++A){let n=t[A];if(typeof n==`number`){k+=v*n*o/1e3;continue}let r=!1,a=(n.isSpace?p:0)+d,s=n.fontChar,c=n.accent,f,h,g=n.width;if(_){let e=n.vmetric||y,t=-(n.vmetric?e[1]:g*.5)*b,r=e[2]*b;g=e?-e[0]:g,f=t/u,h=(k+r)/u}else f=k/u,h=0;let w;if(i.remeasure&&g>0){w=l.measureText(s);let e=w.width*1e3/o*u;if(g<e&&this.isFontSubpixelAAEnabled){let t=g/e;r=!0,l.save(),l.scale(t,1),f/=t}else g!==e&&(f+=(g-e)/2e3*o/u)}if(this.contentVisible&&(n.isInFont||i.missingFile)){if(x&&!c){var ee;l.fillText(s,f,h),(ee=this.dependencyTracker)==null||ee.recordCharacterBBox(e,l,w?{bbox:null}:i,o/u,f,h,()=>{var e;return(e=w)==null?l.measureText(s):e})}else if(this.paintChar(e,s,f,h,S,C),c){let t=f+o*c.offset.x/u,n=h-o*c.offset.y/u;this.paintChar(e,c.fontChar,t,n,S,C)}}let T=_?g*b-a*m:g*b+a*m;k+=T,r&&l.restore()}_?r.y-=k:r.x+=k*h,l.restore(),this.compose(),(n=this.dependencyTracker)==null||n.recordShowTextOperation(e),f(J,this,Il).call(this,c)}showType3Text(e,t){let n=this.ctx,r=this.current,i=r.font,a=r.fontSize,o=r.fontDirection,s=i.vertical?1:-1,c=r.charSpacing,l=r.wordSpacing,u=r.textHScale*o,d=r.fontMatrix||ye,f=t.length,p=r.textRenderingMode===De.INVISIBLE,m,h,g,_;if(p||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,n.save(),r.textMatrix&&n.transform(...r.textMatrix),n.translate(r.x,r.y+r.textRise),n.scale(u,o);let v=this.dependencyTracker;for(this.dependencyTracker=v?new Ro(v,e):null,m=0;m<f;++m){if(h=t[m],typeof h==`number`){_=s*h*a/1e3,this.ctx.translate(_,0),r.x+=_*u;continue}let e=(h.isSpace?l:0)+c,o=i.charProcOperatorList[h.operatorListId];o?this.contentVisible&&(this.save(),o.fnArray[0]===F.setCharWidth&&(r.fillAlpha=r.strokeAlpha=1,n.globalAlpha=1),n.scale(a,a),n.transform(...d),this.executeOperatorList(o),this.restore()):I(`Type3 character "${h.operatorListId}" is not available.`);let f=[h.width,0];B.applyTransform(f,d),g=f[0]*a+e,n.translate(g,0),r.x+=g*u}n.restore(),v&&(this.dependencyTracker=v)}setCharWidth(e,t,n){}setCharWidthAndBounds(e,t,n,r,i,a,o){var s;let c=new Path2D;c.rect(r,i,a-r,o-i),this.ctx.clip(c),(s=this.dependencyTracker)==null||s.recordBBox(e,this.ctx,r,a,i,o).recordClipBox(e,this.ctx,r,a,i,o),this.endPath(e)}getColorN_Pattern(t,n){let r;if(n[0]===`TilingPattern`){let t=this.baseTransform||At(this.ctx);r=new $c(n,this.ctx,{createCanvasGraphics:(t,n)=>new e(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Ro(this.dependencyTracker,n,!0):null)},t)}else r=this._getPattern(t,n[1],n[2]);return r}setStrokeColorN(e,...t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`strokeColor`,e),this.current.strokeColor=this.getColorN_Pattern(e,t),this.current.patternStroke=!0}setFillColorN(e,...t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`fillColor`,e);let r=this.current.fillColor=this.getColorN_Pattern(e,t);this.current.patternFill=!0,this.current.tilingPatternDims=r instanceof $c?[0,0,0,0]:null}setStrokeRGBColor(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`strokeColor`,e),this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(e){var t;(t=this.dependencyTracker)==null||t.recordSimpleData(`strokeColor`,e),this.ctx.strokeStyle=this.current.strokeColor=`transparent`,this.current.patternStroke=!1}setFillRGBColor(e,t){var n;(n=this.dependencyTracker)==null||n.recordSimpleData(`fillColor`,e),this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(e){var t;(t=this.dependencyTracker)==null||t.recordSimpleData(`fillColor`,e),this.ctx.fillStyle=this.current.fillColor=`transparent`,this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(e,t,n=null){let r;return this.cachedPatterns.has(t)?r=this.cachedPatterns.get(t):(r=Zc(this.getObject(e,t)),this.cachedPatterns.set(t,r)),n&&(r.matrix=n),r}shadingFill(e,t){var n;if(!this.contentVisible)return;let r=f(J,this,Fl).call(this,this.current.fillAlpha),i=this.ctx;this.save(e),i.fillStyle=this._getPattern(e,t).getPattern(i,this,jt(i),Wc.SHADING,e);let a=jt(i);if(a){let{width:e,height:t}=i.canvas,n=ve.slice();B.axialAlignedBoundingBox([0,0,e,t],a,n);let[r,o,s,c]=n;this.ctx.fillRect(r,o,s-r,c-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(n=this.dependencyTracker)==null||n.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,zo.transform).recordDependencies(e,zo.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e),f(J,this,Il).call(this,r)}beginInlineImage(){L(`Should not call beginInlineImage`)}beginImageData(){L(`Should not call beginImageData`)}paintFormXObjectBegin(e,t,n){if(this.contentVisible&&(this.save(e),this.baseTransformStack.push(this.baseTransform),t&&this.transform(e,...t),this.baseTransform=At(this.ctx),n)){var r;B.axialAlignedBoundingBox(n,this.baseTransform,this.current.minMax);let[t,i,a,o]=n,s=new Path2D;s.rect(t,i,a-t,o-i),this.ctx.clip(s),(r=this.dependencyTracker)==null||r.recordClipBox(e,this.ctx,t,a,i,o),this.endPath(e)}}paintFormXObjectEnd(e){this.contentVisible&&(this.restore(e),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e,t){var n;if(!this.contentVisible)return;this.save(e);let{inSMaskMode:r}=this;r&&(this.endSMaskMode(),this.current.activeSMask=null);let i=this.ctx;if((!t.needsIsolation||!t.isolated&&!t.hasSoftMask)&&!t.knockout&&!t.isGray&&x(yl,this)===0&&i.globalAlpha===1&&i.globalCompositeOperation===`source-over`&&!r){if(t.bbox){let e=new Path2D,[n,r,a,o]=t.bbox;if(e.rect(n,r,a-n,o-r),t.matrix){let n=new Path2D;n.addPath(e,new DOMMatrix(t.matrix)),e=n}i.clip(e)}this.groupStack.push(null),x(Ol,this).push(null),this.groupLevel++;return}!t.isolated&&!t.knockout&&x(yl,this)===0&&Le(`TODO: Fully support non-isolated non-knockout groups.`);let a=At(i);t.matrix&&i.transform(...t.matrix);let o=[0,0,i.canvas.width,i.canvas.height],s;t.bbox?(s=ve.slice(),B.axialAlignedBoundingBox(t.bbox,At(i),s),s=B.intersect(s,o)||[0,0,0,0]):s=o;let c=Math.floor(s[0]),l=Math.floor(s[1]),u=Math.max(Math.ceil(s[2])-c,1),d=Math.max(Math.ceil(s[3])-l,1);this.current.startNewPathAndClipBox([0,0,u,d]);let f=this.canvasFactory.create(u,d);t.smask&&this.smaskGroupCanvases.push(f);let p=f.context,m=t.knockout&&!t.isolated?i:null,h=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&x(yl,this)>0,g=t.knockout?this.canvasFactory.create(u,d):null,_=x(yl,this);if(t.knockout){var v;C(yl,this,(v=x(yl,this),v++,v))}else C(yl,this,0);if(p.translate(-c,-l),p.transform(...a),!t.isolated&&!t.smask&&r&&t.needsIsolation&&(p.save(),p.setTransform(1,0,0,1,0,0),p.drawImage(i.canvas,-c,-l),p.restore()),t.bbox){let e=new Path2D,[n,r,i,a]=t.bbox;if(e.rect(n,r,i-n,a-r),t.matrix){let n=new Path2D;n.addPath(e,new DOMMatrix(t.matrix)),e=n}p.clip(e)}t.smask&&this.smaskStack.push({canvas:f.canvas,context:p,offsetX:c,offsetY:l,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null}),(!t.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(c,l),i.save()),fl(i,p),this.ctx=p,(n=this.dependencyTracker)==null||n.inheritSimpleDataAsFutureForcedDependencies([`fillAlpha`,`strokeAlpha`,`globalCompositeOperation`]).pushBaseTransform(i),this.setGState(e,[[`BM`,`source-over`],[`ca`,1],[`CA`,1],[`TR`,null]]),this.groupStack.push(i),x(Ol,this).push({backdropCtx:m,savedKnockoutLevel:_,offsetX:c,offsetY:l,hasInnerBackdrop:h,knockoutMaskEntry:g,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(e,t){var n;if(!this.contentVisible)return;this.groupLevel--;let r=this.ctx,i=this.groupStack.pop(),a=x(Ol,this).pop();if(a&&C(yl,this,a.savedKnockoutLevel),i===null){this.restore(e);return}if(t.isGray&&f(J,this,Rl).call(this,r),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(n=this.dependencyTracker)==null||n.popBaseTransform(),t.smask)this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),f(J,this,zl).call(this,a);else{this.ctx.restore();let t=At(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...t);let n=ve.slice();B.axialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],t,n);let c=x(Ol,this).at(-1);if(x(yl,this)>0)if(a.hasInnerBackdrop){let{width:e,height:n}=r.canvas,o=this.canvasFactory.create(e,n),s=o.context;s.drawImage(i.canvas,a.offsetX,a.offsetY,e,n,0,0,e,n),s.globalCompositeOperation=`source-over`,s.drawImage(r.canvas,0,0);let c=f(J,this,Ml).call(this,r.canvas);s.globalCompositeOperation=`destination-in`,s.drawImage(c.canvas,0,0);let l=this.ctx.globalCompositeOperation,u=this.ctx.globalAlpha,d=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...t),this.ctx.globalAlpha=1,z.isCanvasFilterSupported&&(this.ctx.filter=`none`),this.ctx.globalCompositeOperation=`destination-out`,this.ctx.drawImage(c.canvas,0,0),this.ctx.globalCompositeOperation=l,this.ctx.globalAlpha=u,z.isCanvasFilterSupported&&(this.ctx.filter=d==null?`none`:d),this.ctx.drawImage(o.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(c),this.canvasFactory.destroy(o)}else{var o,s;let e=(o=c==null?void 0:c.backdropCtx)==null?null:o;f(J,this,Pl).call(this,this.ctx,r.canvas,{backdropCanvas:(s=e==null?void 0:e.canvas)==null?null:s,destTransform:t,backdropOffset:e?[c.offsetX+a.offsetX,c.offsetY+a.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(r.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:r.canvas,context:r}),f(J,this,zl).call(this,a),this.compose(n)}}beginAnnotation(e,t,n,r,i,a,o){if(f(J,this,Al).call(this),pl(this.ctx),this.ctx.save(),this.save(e),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),n){let i=n[2]-n[0],s=n[3]-n[1];if(a&&this.annotationCanvasMap){r=r.slice(),r[4]-=n[0],r[5]-=n[1],n=n.slice(),n[0]=n[1]=0,n[2]=i,n[3]=s,B.singularValueDecompose2dScale(At(this.ctx),ol);let{viewportScale:e}=this,a=Math.ceil(i*this.outputScaleX*e),c=Math.ceil(s*this.outputScaleY*e);this.annotationCanvas=this.canvasFactory.create(a,c);let{canvas:l,context:u}=this.annotationCanvas;if(o){let e=this.annotationCanvasMap.getOrInsertComputed(t,ot);l.setAttribute(`data-canvas-name`,o);let n=e.findIndex(e=>e.getAttribute(`data-canvas-name`)===o);n===-1?e.push(l):e[n]=l}else this.annotationCanvasMap.set(t,l);this.annotationCanvas.savedCtx=this.ctx,this.ctx=u,this.ctx.save(),this.ctx.setTransform(ol[0],0,0,-ol[1],0,s*ol[1]),pl(this.ctx)}else{pl(this.ctx),this.endPath(e);let t=new Path2D;t.rect(n[0],n[1],i,s),this.ctx.clip(t)}}this.current=new ll(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(e,...r),this.transform(e,...i),this.baseTransform=At(this.ctx)}endAnnotation(e){this.annotationCanvas&&(this.ctx.restore(),f(J,this,jl).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(e,t){var n;if(!this.contentVisible)return;let r=t.count;t=this.getObject(e,t.data,t),t.count=r;let i=f(J,this,Fl).call(this,this.current.fillAlpha),a=this.ctx,o=this._createMaskCanvas(e,t),s=o.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(s,o.offsetX,o.offsetY),(n=this.dependencyTracker)==null||n.resetBBox(e).recordBBox(e,this.ctx,o.offsetX,o.offsetX+s.width,o.offsetY,o.offsetY+s.height).recordOperation(e),a.restore(),o.canvasEntry&&this.canvasFactory.destroy(o.canvasEntry),this.compose(),f(J,this,Il).call(this,i)}paintImageMaskXObjectRepeat(e,t,n,r=0,i=0,a,o){var s,c;if(!this.contentVisible)return;t=this.getObject(e,t.data,t);let l=f(J,this,Fl).call(this,this.current.fillAlpha),u=this.ctx;u.save();let d=At(u);u.transform(n,r,i,a,0,0);let p=this._createMaskCanvas(e,t);u.setTransform(1,0,0,1,p.offsetX-d[4],p.offsetY-d[5]),(s=this.dependencyTracker)==null||s.resetBBox(e);for(let t=0,s=o.length;t<s;t+=2){var m;let s=B.transform(d,[n,r,i,a,o[t],o[t+1]]);u.drawImage(p.canvas,s[4],s[5]),(m=this.dependencyTracker)==null||m.recordBBox(e,this.ctx,s[4],s[4]+p.canvas.width,s[5],s[5]+p.canvas.height)}u.restore(),p.canvasEntry&&this.canvasFactory.destroy(p.canvasEntry),this.compose(),(c=this.dependencyTracker)==null||c.recordOperation(e),f(J,this,Il).call(this,l)}paintImageMaskXObjectGroup(e,t){var n,r;if(!this.contentVisible)return;let i=f(J,this,Fl).call(this,this.current.fillAlpha),a=this.ctx,o=this.current.fillColor,s=this.current.patternFill;(n=this.dependencyTracker)==null||n.resetBBox(e).recordDependencies(e,zo.transformAndFill);for(let n of t){var c;let{data:t,width:r,height:i,transform:l}=n,u=this.canvasFactory.create(r,i),d=u.context;d.save(),dl(d,this.getObject(e,t,n)),d.globalCompositeOperation=`source-in`,d.fillStyle=s?o.getPattern(d,this,jt(a),Wc.FILL,e):o,d.fillRect(0,0,r,i),d.restore(),a.save(),a.transform(...l),a.scale(1,-1),cl(a,u.canvas,0,0,r,i,0,-1,1,1),this.canvasFactory.destroy(u),(c=this.dependencyTracker)==null||c.recordBBox(e,a,0,r,0,i),a.restore()}this.compose(),(r=this.dependencyTracker)==null||r.recordOperation(e),f(J,this,Il).call(this,i)}paintImageXObject(e,t){if(!this.contentVisible)return;let n=this.getObject(e,t);if(!n){I(`Dependent image isn't ready yet`);return}this.paintInlineImageXObject(e,n)}paintImageXObjectRepeat(e,t,n,r,i){if(!this.contentVisible)return;let a=this.getObject(e,t);if(!a){I(`Dependent image isn't ready yet`);return}let o=a.width,s=a.height,c=[];for(let e=0,t=i.length;e<t;e+=2)c.push({transform:[n,0,0,r,i[e],i[e+1]],x:0,y:0,w:o,h:s});this.paintInlineImageXObjectGroup(e,a,c)}applyTransferMapsToCanvas(e){return this.current.transferMaps!==`none`&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter=`none`),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps===`none`)return{img:e.bitmap,canvasEntry:null};let{bitmap:t,width:n,height:r}=e,i=this.canvasFactory.create(n,r),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter=`none`,{img:i.canvas,canvasEntry:i}}paintInlineImageXObject(e,t){if(!this.contentVisible)return;let n=t.width,r=t.height,i=f(J,this,Fl).call(this,this.current.fillAlpha),a=this.ctx;this.save(e);let{filter:o}=a;o!==`none`&&o!==``&&(a.filter=`none`),a.scale(1/n,-1/r);let s,c=null;if(t.bitmap){let e=this.applyTransferMapsToBitmap(t);s=e.img,c=e.canvasEntry}else{let e=this.canvasFactory.create(n,r);ul(e.context,t),s=this.applyTransferMapsToCanvas(e.context),c=e}let l=this._scaleImage(s,jt(a));if(a.imageSmoothingEnabled=ml(At(a),t.interpolate),this.dependencyTracker){var u;this.dependencyTracker.resetBBox(e).recordBBox(e,a,0,n,-r,0).recordDependencies(e,zo.imageXObject).recordOperation(e),(u=this.imagesTracker)==null||u.record(a,n,r,this.dependencyTracker.clipBox)}cl(a,l.img,0,0,l.paintWidth,l.paintHeight,0,-r,n,r),l.tmpCanvas&&this.canvasFactory.destroy(l.tmpCanvas),c&&this.canvasFactory.destroy(c),this.compose(),this.restore(e),f(J,this,Il).call(this,i)}paintInlineImageXObjectGroup(e,t,n){var r,i;if(!this.contentVisible)return;let a=f(J,this,Fl).call(this,this.current.fillAlpha),o=this.ctx,s,c=null;if(t.bitmap)s=t.bitmap;else{let e=t.width,n=t.height,r=this.canvasFactory.create(e,n);ul(r.context,t),s=this.applyTransferMapsToCanvas(r.context),c=r}(r=this.dependencyTracker)==null||r.resetBBox(e);for(let t of n){var l;o.save(),o.transform(...t.transform),o.scale(1,-1),cl(o,s,t.x,t.y,t.w,t.h,0,-1,1,1),(l=this.dependencyTracker)==null||l.recordBBox(e,o,0,1,-1,0),o.restore()}c&&this.canvasFactory.destroy(c),(i=this.dependencyTracker)==null||i.recordOperation(e),this.compose(),f(J,this,Il).call(this,a)}paintSolidColorImageMask(e){var t;if(!this.contentVisible)return;let n=f(J,this,Fl).call(this,this.current.fillAlpha);(t=this.dependencyTracker)==null||t.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,zo.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose(),f(J,this,Il).call(this,n)}markPoint(e,t){}markPointProps(e,t,n){}beginMarkedContent(e,t){var n;(n=this.dependencyTracker)==null||n.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,n){var r;(r=this.dependencyTracker)==null||r.beginMarkedContent(e),t===`OC`?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(n)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(e){var t;(t=this.dependencyTracker)==null||t.endMarkedContent(e),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,t,n){let r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(n);let i=this.ctx;if(this.pendingClip){var a;r||(this.pendingClip===vl?i.clip(t,`evenodd`):i.clip(t)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(e).recordFutureForcedDependency(`clipPath`,e)}else{var o;(o=this.dependencyTracker)==null||o.recordOperation(e)}this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=At(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:n,c:r,d:i}=this.ctx.getTransform(),a,o;if(n===0&&r===0){let n=Math.abs(t),r=Math.abs(i);if(n===r)if(e===0)a=o=1/n;else{let t=n*e;a=o=t<1?1/t:1}else if(e===0)a=1/n,o=1/r;else{let t=n*e,i=r*e;a=t<1?1/t:1,o=i<1?1/i:1}}else{let s=Math.abs(t*i-n*r),c=Math.hypot(t,n),l=Math.hypot(r,i);if(e===0)a=l/s,o=c/s;else{let t=e*s;a=l>t?l/t:1,o=c>t?c/t:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,t){let{ctx:n,current:{lineWidth:r}}=this,[i,a]=this.getScaleForStroking();if(i===a){n.lineWidth=(r||1)*i,n.stroke(e);return}let o=n.getLineDash();t&&n.save(),n.scale(i,a),al.a=1/i,al.d=1/a;let s=new Path2D;if(s.addPath(e,al),o.length>0){let e=Math.max(i,a);n.setLineDash(o.map(t=>t/e)),n.lineDashOffset/=e}n.lineWidth=r||1,n.stroke(s),t&&n.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};function Al(){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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}function jl(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!==`none`){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}function Ml(e,t=null,n=1){let{width:r,height:i}=e,a=t==null?this.canvasFactory.create(r,i):t,o=a.context;n=Math.round(n*255)/255;let s=n<1;s&&x(El,this)===void 0&&C(El,this,z.isCanvasFilterSupported?new Map:`none`);let c=`none`;if(s&&x(El,this)instanceof Map&&(c=x(El,this).getOrInsertComputed(n,()=>this.filterFactory.addKnockoutFilter(n))),!s||c!==`none`)return t&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,r,i),o.restore()),o.filter=c,o.drawImage(e,0,0),o.filter=`none`,a;let l=e.getContext(`2d`,{willReadFrequently:!0}).getImageData(0,0,r,i),u=o.createImageData(r,i),d=l.data,f=u.data,p=n>0?1/n:1e6;for(let e=3,t=d.length;e<t;e+=4)f[e]=Math.min(Math.round(d[e]*p),255);return o.putImageData(u,0,0),a}function Nl(e,t,n,r){var i;let a=(i=e==null?void 0:e[t])==null?null:i;if(a&&(a.canvas.width!==n||a.canvas.height!==r)&&(this.canvasFactory.destroy(a),a=null),!a)return a=this.canvasFactory.create(n,r),e&&(e[t]=a),a;let o=a.context;return o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,n,r),o.restore(),a}function Pl(e,t,n={}){let{backdropCanvas:r=null,destTransform:i=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:s=null,sourceAlpha:c=1,sourceFilter:l=`none`,knockoutAlpha:u=1}=n,{width:d,height:p}=t,m=f(J,this,Ml).call(this,t,o,u),h=e.globalCompositeOperation;if(e.save(),e.setTransform(...i),e.globalAlpha=1,z.isCanvasFilterSupported&&(e.filter=`none`),e.globalCompositeOperation=`destination-out`,e.drawImage(m.canvas,0,0),r){let[t,n]=a,i=f(J,this,Nl).call(this,s,`knockoutBackdropEntry`,d,p),o=i.context;o.drawImage(r,t,n,d,p,0,0,d,p),o.globalCompositeOperation=`destination-in`,o.drawImage(m.canvas,0,0),o.globalCompositeOperation=`source-over`,e.globalCompositeOperation=`destination-over`,e.drawImage(i.canvas,0,0),s||this.canvasFactory.destroy(i)}e.globalCompositeOperation=h,e.globalAlpha=c,z.isCanvasFilterSupported&&(e.filter=l==null?`none`:l),e.drawImage(t,0,0),e.restore(),o||this.canvasFactory.destroy(m)}function Fl(e=1){var t;if(x(yl,this)===0||x(bl,this)>0||!this.contentVisible)return!1;C(bl,this,(t=x(bl,this),t++,t)),C(Tl,this,e);let n=x(Ol,this).at(-1),{canvas:r}=this.ctx,i=f(J,this,Nl).call(this,n,`knockoutTempEntry`,r.width,r.height);C(xl,this,i);let a=i.context;return a.save(),a.setTransform(this.ctx.getTransform()),fl(this.ctx,a),C(wl,this,a.globalCompositeOperation),a.globalCompositeOperation=`source-over`,sl(a,this.ctx),C(Dl,this,n),C(Sl,this,this.ctx),C(Cl,this,this.suspendedCtx),this.ctx=a,this.inSMaskMode&&(this.suspendedCtx=a),!0}function Il(e){if(!e)return;let t=x(xl,this),n=x(Sl,this),r=x(Cl,this),i=t.context;C(xl,this,null),C(Sl,this,null),C(Cl,this,null),this.inSMaskMode&&this.suspendedCtx===i&&this.ctx!==i&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=r),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=x(wl,this),C(wl,this,null),fl(this.ctx,n),this.ctx=n;let a=x(Dl,this);C(Dl,this,null);let o=x(Tl,this);C(Tl,this,1);try{var s,c,l;f(J,this,Pl).call(this,r==null?n:r,t.canvas,{backdropCanvas:(s=a==null||(c=a.backdropCtx)==null?void 0:c.canvas)==null?null:s,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(l=a==null?void 0:a.knockoutMaskEntry)==null?null:l,poolMeta:a,knockoutAlpha:o})}finally{var u;i.restore(),C(bl,this,(u=x(bl,this),u--,u)),a||this.canvasFactory.destroy(t)}}function Ll(e,t,n){let r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}function Rl(e){let{canvas:t}=e,{width:n,height:r}=t;if(z.isCanvasFilterSupported){e.save(),e.setTransform(1,0,0,1,0,0),e.filter=`grayscale(1)`,e.globalAlpha=1,e.globalCompositeOperation=`copy`,e.drawImage(t,0,0),e.restore();return}let i=e.getImageData(0,0,n,r),{data:a}=i;for(let e=0,t=a.length;e<t;e+=4){let t=a[e]*.2126+a[e+1]*.7152+a[e+2]*.0722+.5|0;a[e]=a[e+1]=a[e+2]=t}e.putImageData(i,0,0)}function zl(e){e&&(e.knockoutMaskEntry&&(this.canvasFactory.destroy(e.knockoutMaskEntry),e.knockoutMaskEntry=null),e.knockoutTempEntry&&(this.canvasFactory.destroy(e.knockoutTempEntry),e.knockoutTempEntry=null),e.knockoutBackdropEntry&&(this.canvasFactory.destroy(e.knockoutBackdropEntry),e.knockoutBackdropEntry=null))}for(let e in F)kl.prototype[e]!==void 0&&(kl.prototype[F[e]]=kl.prototype[e]);var Bl=new WeakMap,Vl=new WeakMap,Hl=class{constructor(e,t,n){b(this,Bl,null),b(this,Vl,null),g(this,`_fullReader`,null),g(this,`_rangeReaders`,new Set),g(this,`_source`,null),this._source=e,C(Bl,this,t),C(Vl,this,n)}get _progressiveDataLength(){var e,t;return(e=(t=this._fullReader)==null?void 0:t._loaded)==null?0:e}getFullReader(){return Re(!this._fullReader,`BasePDFStream.getFullReader can only be called once.`),this._fullReader=new(x(Bl,this))(this)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new(x(Vl,this))(this,e,t);return this._rangeReaders.add(n),n}cancelAllRequests(e){var t;(t=this._fullReader)==null||t.cancel(e);for(let t of new Set(this._rangeReaders))t.cancel(e)}},Ul=class{constructor(e){g(this,`onProgress`,null),g(this,`_contentLength`,0),g(this,`_filename`,null),g(this,`_headersCapability`,Promise.withResolvers()),g(this,`_isRangeSupported`,!1),g(this,`_isStreamingSupported`,!1),g(this,`_loaded`,0),g(this,`_stream`,null),this._stream=e}_callOnProgress(){var e;(e=this.onProgress)==null||e.call(this,{loaded:this._loaded,total:this._contentLength})}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}read(){return v(function*(){L("Abstract method `read` called")})()}cancel(e){L("Abstract method `cancel` called")}},Wl=class{constructor(e,t,n){g(this,`_stream`,null),this._stream=e}read(){return v(function*(){L("Abstract method `read` called")})()}cancel(e){L("Abstract method `cancel` called")}};function Gl(e){let t=!0,n=r(`filename\\*`,`i`).exec(e);if(n){n=n[1];let e=s(n);return e=unescape(e),e=c(e),e=l(e),a(e)}if(n=o(e),n)return a(l(n));if(n=r(`filename`,`i`).exec(e),n){n=n[1];let e=s(n);return e=l(e),a(e)}function r(e,t){return RegExp(`(?:^|;)\\s*`+e+`\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)`,t)}function i(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let r=new TextDecoder(e,{fatal:!0}),i=Ze(n);n=r.decode(i),t=!1}catch(e){}}return n}function a(e){return t&&/[\x80-\xff]/.test(e)&&(e=i(`utf-8`,e),t&&(e=i(`iso-8859-1`,e))),e}function o(e){let t=[],n,i=r(`filename\\*((?!0\\d)\\d+)(\\*?)`,`ig`);for(;(n=i.exec(e))!==null;){let[,e,r,i]=n;if(e=parseInt(e,10),e in t){if(e===0)break;continue}t[e]=[r,i]}let a=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=s(r),n&&(r=unescape(r),e===0&&(r=c(r))),a.push(r)}return a.join(``)}function s(e){if(e.startsWith(`"`)){let t=e.slice(1).split(`\\"`);for(let e=0;e<t.length;++e){let n=t[e].indexOf(`"`);n!==-1&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,`$1`)}e=t.join(`"`)}return e}function c(e){let t=e.indexOf(`'`);return t===-1?e:i(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,``))}function l(e){return!e.startsWith(`=?`)||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(e,t,n,r){if(n===`q`||n===`Q`)return r=r.replaceAll(`_`,` `),r=r.replaceAll(/=([0-9a-f]{2})/gi,function(e,t){return String.fromCharCode(parseInt(t,16))}),i(t,r);try{r=atob(r)}catch(e){}return i(t,r)})}return``}function Kl(e,t){let n=new Headers;if(!e||!t||typeof t!=`object`)return n;for(let e in t){let r=t[e];r!==void 0&&n.append(e,r)}return n}function ql(e){var t,n;return(t=(n=URL.parse(e))==null?void 0:n.origin)==null?null:t}function Jl({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){let i={contentLength:0,isRangeSupported:!1},a=parseInt(e.get(`Content-Length`),10);return!Number.isInteger(a)||(i.contentLength=a,a<=2*n)||r||!t||e.get(`Accept-Ranges`)!==`bytes`||(e.get(`Content-Encoding`)||`identity`)===`identity`&&(i.isRangeSupported=!0),i}function Yl(e){let t=e.get(`Content-Disposition`);if(t){let e=Gl(t);if(e.includes(`%`))try{e=decodeURIComponent(e)}catch(e){}if(_t(e))return e}return null}function Xl(e,t){return new qe(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,e===404||e===0&&t.protocol===`file:`)}function Zl(e,t){if(e!==t)throw Error(`Expected range response-origin "${e}" to match "${t}".`)}function Ql(e,t,n,r){return fetch(e,{method:`GET`,headers:t,signal:r.signal,mode:`cors`,credentials:n?`include`:`same-origin`,redirect:`follow`})}function $l(e,t){if(e!==200&&e!==206)throw Xl(e,t)}function eu(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw Error(`getArrayBuffer - unexpected data: ${e}`)}var tu=class extends Hl{constructor(e){super(e,nu,ru),g(this,`_responseOrigin`,null);let{httpHeaders:t,url:n}=e;Re(/https?:/.test(n.protocol),`PDFFetchStream only supports http(s):// URLs.`),this.headers=Kl(!0,t)}},nu=class extends Ul{constructor(e){super(e),g(this,`_abortController`,new AbortController),g(this,`_reader`,null);let{disableRange:t,disableStream:n,rangeChunkSize:r,url:i,withCredentials:a}=e._source;this._isStreamingSupported=!n,Ql(i,new Headers(e.headers),a,this._abortController).then(n=>{e._responseOrigin=ql(n.url),$l(n.status,i),this._reader=n.body.getReader();let a=n.headers,{contentLength:o,isRangeSupported:s}=Jl({responseHeaders:a,isHttp:!0,rangeChunkSize:r,disableRange:t});this._contentLength=o,this._isRangeSupported=s,this._filename=Yl(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ye(`Streaming is disabled.`)),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}read(){var e=this;return v(function*(){yield e._headersCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:(e._loaded+=t.byteLength,e._callOnProgress(),{value:eu(t),done:!1})})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}},ru=class extends Wl{constructor(e,t,n){super(e,t,n),g(this,`_abortController`,new AbortController),g(this,`_readCapability`,Promise.withResolvers()),g(this,`_reader`,null);let{url:r,withCredentials:i}=e._source,a=new Headers(e.headers);a.append(`Range`,`bytes=${t}-${n-1}`),Ql(r,a,i,this._abortController).then(t=>{Zl(ql(t.url),e._responseOrigin),$l(t.status,r),this._reader=t.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}read(){var e=this;return v(function*(){yield e._readCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:{value:eu(t),done:!1}})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e),this._abortController.abort()}};function iu(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function au(){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}var ou=new WeakSet,su=class extends Hl{constructor(e){super(e,uu,fu),S(this,ou),g(this,`_progressiveDone`,!1),g(this,`_queuedChunks`,[]);let{pdfDataRangeTransport:t}=e,{initialData:n,progressiveDone:r}=t;if((n==null?void 0:n.length)>0){let e=iu(n);this._queuedChunks.push(e)}this._progressiveDone=r,t.transportReady(e=>{switch(e.type){case`range`:case`progressiveRead`:f(ou,this,cu).call(this,e.begin,e.chunk);break;case`progressiveDone`:var t;(t=this._fullReader)==null||t.progressiveDone(),this._progressiveDone=!0;break}})}getFullReader(){let e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,t){let n=super.getRangeReader(e,t);return n&&(n.onDone=()=>this._rangeReaders.delete(n),this._source.pdfDataRangeTransport.requestDataRange(e,t)),n}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}};function cu(e,t){let n=iu(t);if(e===void 0)this._fullReader?this._fullReader._enqueue(n):this._queuedChunks.push(n);else{let t=this._rangeReaders.keys().find(t=>t._begin===e);Re(t,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),t._enqueue(n)}}var lu=new WeakMap,uu=class extends Ul{constructor(e){super(e),b(this,lu,au.bind(this)),g(this,`_done`,!1),g(this,`_queuedChunks`,null),g(this,`_requests`,[]);let{pdfDataRangeTransport:t,disableRange:n,disableStream:r}=e._source,{length:i,contentDispositionFilename:a}=t;this._queuedChunks=e._queuedChunks||[];for(let e of this._queuedChunks)this._loaded+=e.byteLength;this._done=e._progressiveDone,this._contentLength=i,this._isStreamingSupported=!r,this._isRangeSupported=!n,_t(a)&&(this._filename=a),this._headersCapability.resolve();let o=this._loaded;Promise.resolve().then(()=>{o>0&&this._loaded===o&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}read(){var e=this;return v(function*(){if(e._queuedChunks.length>0)return{value:e._queuedChunks.shift(),done:!1};if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){this._done=!0,x(lu,this).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&x(lu,this).call(this)}},du=new WeakMap,fu=class extends Wl{constructor(e,t,n){super(e,t,n),b(this,du,au.bind(this)),g(this,`onDone`,null),g(this,`_begin`,-1),g(this,`_done`,!1),g(this,`_queuedChunk`,null),g(this,`_requests`,[]),this._begin=t}_enqueue(e){var t;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),x(du,this).call(this)),this._done=!0,(t=this.onDone)==null||t.call(this))}read(){var e=this;return v(function*(){if(e._queuedChunk){let t=e._queuedChunk;return e._queuedChunk=null,{value:t,done:!1}}if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){var t;this._done=!0,x(du,this).call(this),(t=this.onDone)==null||t.call(this)}},pu=200,mu=206;function hu(e){return typeof e==`string`?Ze(e).buffer:e}var gu=new WeakMap,_u=new WeakSet,vu=class extends Hl{constructor(e){super(e,Cu,Au),S(this,_u),b(this,gu,new WeakMap),g(this,`_responseOrigin`,null);let{httpHeaders:t,url:n}=e;this.url=n,this.isHttp=/https?:/.test(n.protocol),this.headers=Kl(this.isHttp,t)}_request(e){let t=new XMLHttpRequest,n={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};x(gu,this).set(t,n),t.open(`GET`,this.url),t.withCredentials=this._source.withCredentials;for(let[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&`begin`in e&&`end`in e?(t.setRequestHeader(`Range`,`bytes=${e.begin}-${e.end-1}`),n.validateStatus=e=>e===mu||e===pu):n.validateStatus=e=>e===pu,t.responseType=`arraybuffer`,Re(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>e.onError(t.status),t.onreadystatechange=f(_u,this,bu).bind(this,t),t.onprogress=f(_u,this,yu).bind(this,t),t.send(null),t}_abortRequest(e){x(gu,this).has(e)&&(x(gu,this).delete(e),e.abort())}getRangeReader(e,t){let n=super.getRangeReader(e,t);return n&&(n.onClosed=()=>this._rangeReaders.delete(n)),n}};function yu(e,t){var n;let r=x(gu,this).get(e);r==null||(n=r.onProgress)==null||n.call(r,t)}function bu(e,t){let n=x(gu,this).get(e);if(!n||(e.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),e.readyState!==4)||!x(gu,this).has(e))return;if(x(gu,this).delete(e),e.status===0&&this.isHttp){n.onError(e.status);return}let r=e.status||pu;if(!n.validateStatus(r)){n.onError(e.status);return}let i=hu(e.response);if(r===mu){let t=e.getResponseHeader(`Content-Range`);/bytes \d+-\d+\/\d+/.test(t)?n.onDone(i):(I(`Missing or invalid "Content-Range" header.`),n.onError(0))}else i?n.onDone(i):n.onError(e.status)}var xu=new WeakMap,Su=new WeakSet,Cu=class extends Ul{constructor(e){super(e),S(this,Su),b(this,xu,au.bind(this)),g(this,`_cachedChunks`,[]),g(this,`_done`,!1),g(this,`_requests`,[]),g(this,`_storedError`,null),this._fullRequestXhr=e._request({onHeadersReceived:f(Su,this,wu).bind(this),onDone:f(Su,this,Tu).bind(this),onError:f(Su,this,Eu).bind(this),onProgress:f(Su,this,Du).bind(this)})}read(){var e=this;return v(function*(){if(yield e._headersCapability.promise,e._storedError)throw e._storedError;if(e._cachedChunks.length>0)return{value:e._cachedChunks.shift(),done:!1};if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){this._done=!0,this._headersCapability.reject(e),x(xu,this).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}};function wu(){let e=this._stream,{disableRange:t,rangeChunkSize:n}=e._source,r=this._fullRequestXhr;e._responseOrigin=ql(r.responseURL);let i=r.getAllResponseHeaders(),a=new Headers(i?i.trimStart().replace(/[^\S ]+$/,``).split(/[\r\n]+/).map(e=>{let[t,...n]=e.split(`: `);return[t,n.join(`: `)]}):[]),{contentLength:o,isRangeSupported:s}=Jl({responseHeaders:a,isHttp:e.isHttp,rangeChunkSize:n,disableRange:t});this._contentLength=o,this._isRangeSupported=s,this._filename=Yl(a),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()}function Tu(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&x(xu,this).call(this)}function Eu(e){this._storedError=Xl(e,this._stream.url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}function Du(e){var t;(t=this.onProgress)==null||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}var Ou=new WeakMap,ku=new WeakSet,Au=class extends Wl{constructor(e,t,n){super(e,t,n),S(this,ku),b(this,Ou,au.bind(this)),g(this,`onClosed`,null),g(this,`_done`,!1),g(this,`_queuedChunk`,null),g(this,`_requests`,[]),g(this,`_storedError`,null),this._requestXhr=e._request({begin:t,end:n,onHeadersReceived:f(ku,this,ju).bind(this),onDone:f(ku,this,Mu).bind(this),onError:f(ku,this,Nu).bind(this),onProgress:null})}read(){var e=this;return v(function*(){if(e._storedError)throw e._storedError;if(e._queuedChunk!==null){let t=e._queuedChunk;return e._queuedChunk=null,{value:t,done:!1}}if(e._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return e._requests.push(t),t.promise})()}cancel(e){var t;this._done=!0,x(Ou,this).call(this),this._stream._abortRequest(this._requestXhr),(t=this.onClosed)==null||t.call(this)}};function ju(){var e;let t=ql((e=this._requestXhr)==null?void 0:e.responseURL);try{Zl(t,this._stream._responseOrigin)}catch(e){this._storedError=e,f(ku,this,Nu).call(this,0)}}function Mu(e){var t;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,x(Ou,this).call(this),(t=this.onClosed)==null||t.call(this)}function Nu(e){this._storedError!=null||(this._storedError=Xl(e,this._stream.url));for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}function Pu(e,t=null){let n=process.getBuiltinModule(`fs`),{Readable:r}=process.getBuiltinModule(`stream`),i=n.createReadStream(e,t);return r.toWeb(i)}var Fu=class extends Hl{constructor(e){super(e,Iu,Lu);let{url:t}=e;Re(t.protocol===`file:`,`PDFNodeStream only supports file:// URLs.`)}},Iu=class extends Ul{constructor(e){super(e),g(this,`_reader`,null);let{disableRange:t,disableStream:n,rangeChunkSize:r,url:i}=e._source;this._isStreamingSupported=!n,process.getBuiltinModule(`fs/promises`).lstat(i).then(e=>{let n=Pu(i);this._reader=n.getReader();let{size:a}=e;this._contentLength=a,this._isRangeSupported=!t&&a>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ye(`Streaming is disabled.`)),this._headersCapability.resolve()}).catch(e=>{e.code===`ENOENT`&&(e=Xl(0,i)),this._headersCapability.reject(e)})}read(){var e=this;return v(function*(){yield e._headersCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:(e._loaded+=t.byteLength,e._callOnProgress(),{value:eu(t),done:!1})})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e)}},Lu=class extends Wl{constructor(e,t,n){super(e,t,n),g(this,`_readCapability`,Promise.withResolvers()),g(this,`_reader`,null);let{url:r}=e._source;try{let e=Pu(r,{start:t,end:n-1});this._reader=e.getReader(),this._readCapability.resolve()}catch(e){this._readCapability.reject(e)}}read(){var e=this;return v(function*(){yield e._readCapability.promise;let{value:t,done:n}=yield e._reader.read();return n?{value:t,done:n}:{value:eu(t),done:!1}})()}cancel(e){var t;(t=this._reader)==null||t.cancel(e)}};function Ru(e){return St(e)?tu:ge?Fu:vu}var zu=class e{static get workerPort(){return f(e,this,Bu)._}static set workerPort(t){if(!(typeof Worker<`u`&&t instanceof Worker)&&t!==null)throw Error("Invalid `workerPort` type.");Bu._=f(e,this,t)}static get workerSrc(){return f(e,this,Vu)._}static set workerSrc(t){if(typeof t!=`string`)throw Error("Invalid `workerSrc` type.");Vu._=f(e,this,t)}},Bu={_:null},Vu={_:``},Hu=new WeakMap,Uu=new WeakMap;pe=Symbol.iterator;var Wu=class{constructor({parsedData:e,rawData:t}){b(this,Hu,void 0),b(this,Uu,void 0),C(Hu,this,e),C(Uu,this,t)}getRaw(){return x(Uu,this)}get(e){var t;return(t=x(Hu,this).get(e))==null?null:t}[pe](){return x(Hu,this).entries()}},Gu=Symbol(`INTERNAL`),Ku=new WeakMap,qu=new WeakMap,Ju=new WeakMap,Yu=new WeakMap,Xu=class{constructor(e,{name:t,intent:n,usage:r,rbGroups:i}){b(this,Ku,!1),b(this,qu,!1),b(this,Ju,!1),b(this,Yu,!0),C(Ku,this,!!(e&Se.DISPLAY)),C(qu,this,!!(e&Se.PRINT)),this.name=t,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(x(Ju,this))return x(Yu,this);if(!x(Yu,this))return!1;let{print:e,view:t}=this.usage;return x(Ku,this)?(t==null?void 0:t.viewState)!==`OFF`:!x(qu,this)||(e==null?void 0:e.printState)!==`OFF`}_setVisible(e,t,n=!1){e!==Gu&&L("Internal method `_setVisible` called."),C(Ju,this,n),C(Yu,this,t)}get serializable(){return{userSet:x(Ju,this),visible:x(Yu,this)}}},Zu=new WeakMap,Y=new WeakMap,Qu=new WeakMap,$u=new WeakMap,ed=new WeakMap,td=new WeakSet;me=Symbol.iterator;var nd=class e{constructor(e,t=Se.DISPLAY,n=null){if(S(this,td),b(this,Zu,null),b(this,Y,new Map),b(this,Qu,null),b(this,$u,null),b(this,ed,void 0),g(this,`creator`,null),g(this,`name`,null),C(ed,this,e),this.renderingIntent=t,e!==null){this.name=e.name,this.creator=e.creator,C($u,this,e.order);for(let n of e.groups)x(Y,this).set(n.id,new Xu(t,n));if(n){n.size!==x(Y,this).size&&L(`Incorrect serialized groupState.`);for(let[e,t]of n)x(Y,this).get(e)._setVisible(Gu,t.visible,t.userSet)}else{if(e.baseState===`OFF`)for(let e of x(Y,this).values())e._setVisible(Gu,!1);for(let t of e.on)x(Y,this).get(t)._setVisible(Gu,!0);for(let t of e.off)x(Y,this).get(t)._setVisible(Gu,!1)}C(Qu,this,this.getHash())}}isVisible(e){if(x(Y,this).size===0)return!0;if(!e)return Le(`Optional content group not defined.`),!0;if(e.type===`OCG`)return x(Y,this).has(e.id)?x(Y,this).get(e.id).visible:(I(`Optional content group not found: ${e.id}`),!0);if(e.type===`OCMD`){if(e.expression)return f(td,this,rd).call(this,e.expression);if(!e.policy||e.policy===`AnyOn`){for(let t of e.ids){if(!x(Y,this).has(t))return I(`Optional content group not found: ${t}`),!0;if(x(Y,this).get(t).visible)return!0}return!1}else if(e.policy===`AllOn`){for(let t of e.ids){if(!x(Y,this).has(t))return I(`Optional content group not found: ${t}`),!0;if(!x(Y,this).get(t).visible)return!1}return!0}else if(e.policy===`AnyOff`){for(let t of e.ids){if(!x(Y,this).has(t))return I(`Optional content group not found: ${t}`),!0;if(!x(Y,this).get(t).visible)return!0}return!1}else if(e.policy===`AllOff`){for(let t of e.ids){if(!x(Y,this).has(t))return I(`Optional content group not found: ${t}`),!0;if(x(Y,this).get(t).visible)return!1}return!0}return I(`Unknown optional content policy ${e.policy}.`),!0}return I(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){let r=x(Y,this).get(e);if(!r){I(`Optional content group not found: ${e}`);return}if(n&&t&&r.rbGroups.length){for(let t of r.rbGroups)for(let n of t)if(n!==e){var i;(i=x(Y,this).get(n))==null||i._setVisible(Gu,!1,!0)}}r._setVisible(Gu,!!t,!0),C(Zu,this,null)}setOCGState({state:e,preserveRB:t}){let n;for(let r of e){switch(r){case`ON`:case`OFF`:case`Toggle`:n=r;continue}let e=x(Y,this).get(r);if(e)switch(n){case`ON`:this.setVisibility(r,!0,t);break;case`OFF`:this.setVisibility(r,!1,t);break;case`Toggle`:this.setVisibility(r,!e.visible,t);break}}C(Zu,this,null)}get hasInitialVisibility(){return x(Qu,this)===null||this.getHash()===x(Qu,this)}getOrder(){return x(Y,this).size?x($u,this)?x($u,this).slice():[...x(Y,this).keys()]:null}getGroup(e){return x(Y,this).get(e)||null}getHash(){if(x(Zu,this)!==null)return x(Zu,this);let e=new qa;for(let[t,n]of x(Y,this))e.update(`${t}:${n.visible}`);return C(Zu,this,e.hexdigest())}[me](){return x(Y,this).entries()}get serializable(){let e=new Map;for(let[t,n]of x(Y,this))e.set(t,n.serializable);return{data:x(ed,this),renderingIntent:this.renderingIntent,groupState:e}}static fromSerializable({data:t,renderingIntent:n,groupState:r}){return new e(t,n,r)}};function rd(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let r=1;r<t;r++){let t=e[r],i;if(Array.isArray(t))i=f(td,this,rd).call(this,t);else if(x(Y,this).has(t))i=x(Y,this).get(t).visible;else return I(`Optional content group not found: ${t}`),!0;switch(n){case`And`:if(!i)return!1;break;case`Or`:if(i)return!0;break;case`Not`:return!i;default:return!0}}return n===`And`}var id=new WeakMap,ad=new WeakMap,od=new WeakMap,sd=new WeakMap,cd=new WeakMap,ld=new WeakSet,ud=class{constructor(){S(this,ld),b(this,id,null),b(this,ad,null),b(this,od,0),b(this,sd,null),b(this,cd,null)}get pagesNumber(){return x(od,this)}set pagesNumber(e){x(od,this)!==e&&(C(od,this,e),C(id,this,null),C(ad,this,null))}movePages(e,t,n){f(ld,this,dd).call(this);let r=x(id,this),i=f(ld,this,fd).call(this),a=t.length,o=new Uint32Array(a),s=0;for(let e=0;e<a;e++){let i=t[e]-1;o[e]=r[i],i<n&&s++}let c=x(od,this),l=c-a,u=V(n-s,0,l);for(let t=0,n=0;t<c;t++)e.has(t+1)||(r[n++]=r[t]);r.copyWithin(u+a,u,l),r.set(o,u),f(ld,this,pd).call(this,i),r.every((e,t)=>e===t+1)&&C(id,this,null)}deletePages(e){f(ld,this,dd).call(this);let t=x(id,this),n=f(ld,this,fd).call(this);C(cd,this,{pageNumberToId:t.slice(),pagesNumber:x(od,this),prevPageNumbers:x(ad,this).slice()});let r=x(od,this)-e.length;C(od,this,r);let i=C(id,this,new Uint32Array(r));C(ad,this,new Int32Array(r));let a=0,o=0;for(let n of e){let e=n-1;e!==a&&(i.set(t.subarray(a,e),o),o+=e-a),a=e+1}a<t.length&&i.set(t.subarray(a),o),f(ld,this,pd).call(this,n,new Set(e))}cancelDelete(){x(cd,this)&&(C(id,this,x(cd,this).pageNumberToId),C(od,this,x(cd,this).pagesNumber),C(ad,this,x(cd,this).prevPageNumbers),C(cd,this,null))}cleanSavedData(){C(cd,this,null)}copyPages(e){f(ld,this,dd).call(this),C(sd,this,{pageNumbers:e,pageIds:e.map(e=>x(id,this)[e-1])})}cancelCopy(){C(sd,this,null)}pastePages(e){f(ld,this,dd).call(this);let t=x(id,this),n=f(ld,this,fd).call(this),{pageNumbers:r,pageIds:i}=x(sd,this),a=x(od,this)+r.length;C(od,this,a);let o=C(id,this,new Uint32Array(a));C(ad,this,new Int32Array(a)),o.set(t.subarray(0,e),0),o.set(i,e),o.set(t.subarray(e),e+r.length),f(ld,this,pd).call(this,n,null,e,r),C(sd,this,null)}hasBeenAltered(){return x(id,this)!==null}getPageMappingForSaving(e=null){e!=null||(e=f(ld,this,fd).call(this));let t=0;for(let n of e.values())t=Math.max(t,n.length);let n=Array(t);for(let e=0;e<t;e++)n[e]={document:null,pageIndices:[],includePages:[]};for(let[t,r]of e)for(let e=0,i=r.length;e<i;e++)n[e].includePages.push([t-1,r[e]-1]);for(let{includePages:e,pageIndices:t}of n){e.sort((e,t)=>e[0]-t[0]);for(let n=0,r=e.length;n<r;n++)t.push(e[n][1]),e[n]=e[n][0]}return n}extractPages(e){e=Array.from(e).sort((e,t)=>e-t);let t=new Map;for(let n=0,r=e.length;n<r;n++){let r=this.getPageId(e[n]);t.getOrInsertComputed(r,ot).push(n+1)}return this.getPageMappingForSaving(t)}getPrevPageNumber(e){var t,n;return(t=(n=x(ad,this))==null?void 0:n[e-1])==null?0:t}getPageNumber(e){if(!x(id,this))return e;let t=x(id,this);for(let n=0,r=x(od,this);n<r;n++)if(t[n]===e)return n+1;return 0}getPageId(e){var t,n;return(t=(n=x(id,this))==null?void 0:n[e-1])==null?e:t}getMapping(){var e;return(e=x(id,this))==null?void 0:e.subarray(0,this.pagesNumber)}};function dd(){if(x(id,this))return;let e=x(od,this),t=C(id,this,new Uint32Array(e));for(let n=0;n<e;n++)t[n]=n+1;C(ad,this,new Int32Array(t))}function fd(){let e=new Map,t=x(id,this);for(let n=0,r=x(od,this);n<r;n++){let r=t[n],i=e.get(r);i?i.push(n+1):e.set(r,[n+1])}return e}function pd(e,t=null,n=-1,r=null){var i;let a=x(ad,this),o=x(id,this),s=n+((i=r==null?void 0:r.length)==null?0:i),c=new Map;for(let i=0,l=x(od,this);i<l;i++){if(i>=n&&i<s){a[i]=-r[i-n];continue}let l=o[i],u=e.get(l),d=c.get(l)||0;if(t&&u)for(;d<u.length&&t.has(u[d]);)d++;a[i]=u==null?void 0:u[d],c.set(l,d+1)}}var md=Symbol(`INITIAL_DATA`),hd=()=>T(T({},Promise.withResolvers()),{},{data:md}),gd=new WeakMap;he=Symbol.iterator;var _d=class{constructor(){b(this,gd,new Map)}get(e,t=null){if(t){let n=x(gd,this).getOrInsertComputed(e,hd);return n.promise.then(()=>t(n.data)),null}let n=x(gd,this).get(e);if(!n||n.data===md)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=x(gd,this).get(e);return!!t&&t.data!==md}delete(e){let t=x(gd,this).get(e);return!t||t.data===md?!1:(x(gd,this).delete(e),!0)}resolve(e,t=null){let n=x(gd,this).getOrInsertComputed(e,hd);if(n.data!==md)throw Error(`Object already resolved ${e}.`);n.data=t,n.resolve()}clear(){for(let{data:t}of x(gd,this).values()){var e;t==null||(e=t.bitmap)==null||e.close()}x(gd,this).clear()}*[he](){for(let[e,{data:t}]of x(gd,this))t!==md&&(yield[e,t])}},vd=1e5,yd=30,bd=new WeakMap,xd=new WeakMap,Sd=new WeakMap,Cd=new WeakMap,wd=new WeakMap,Td=new WeakMap,Ed=new WeakMap,Dd=new WeakMap,Od=new WeakMap,kd=new WeakMap,Ad=new WeakMap,jd=new WeakMap,Md=new WeakMap,Nd=new WeakMap,Pd=new WeakMap,Fd=new WeakMap,Id=new WeakMap,Ld=new WeakMap,Rd=new WeakMap,zd=new WeakSet,Bd=class e{constructor({textContentSource:t,images:n,container:r,viewport:i}){var a;if(S(this,zd),b(this,bd,Promise.withResolvers()),b(this,xd,null),b(this,Sd,!1),b(this,Cd,!!((a=globalThis.FontInspector)!=null&&a.enabled)),b(this,wd,null),b(this,Td,null),b(this,Ed,null),b(this,Dd,0),b(this,Od,0),b(this,kd,null),b(this,Ad,null),b(this,jd,0),b(this,Md,0),b(this,Nd,Object.create(null)),b(this,Pd,[]),b(this,Fd,null),b(this,Id,[]),b(this,Ld,new WeakMap),b(this,Rd,null),t instanceof ReadableStream)C(Fd,this,t);else if(typeof t==`object`)C(Fd,this,new ReadableStream({start(e){e.enqueue(t),e.close()}}));else throw Error(`No "textContentSource" parameter specified.`);C(xd,this,C(Ad,this,r)),C(wd,this,n),C(Md,this,i.scale*Nt.pixelRatio),C(jd,this,i.rotation),C(Ed,this,{div:null,properties:null,ctx:null});let{pageWidth:o,pageHeight:s,pageX:c,pageY:l}=i.rawDims;C(Rd,this,[1,0,0,-1,-c,l+s]),C(Od,this,o),C(Dd,this,s),Kd.call(e),r.style.setProperty(`--min-font-size`,Zd._),Mt(r,i),x(bd,this).promise.finally(()=>{Qd._.delete(this),C(Ed,this,null),C(Nd,this,null)}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=z.platform;return R(this,`fontFamilyMap`,new Map([[`sans-serif`,`${e&&t?`Calibri, `:``}sans-serif`],[`monospace`,`${e&&t?`Lucida Console, `:``}monospace`]]))}render(){x(wd,this)&&x(xd,this).append(x(wd,this).render());let e=()=>{x(kd,this).read().then(({value:t,done:n})=>{if(n){x(bd,this).resolve();return}x(Td,this)!=null||C(Td,this,t.lang),Object.assign(x(Nd,this),t.styles),f(zd,this,Vd).call(this,t.items),e()},x(bd,this).reject)};return C(kd,this,x(Fd,this).getReader()),Qd._.add(this),e(),x(bd,this).promise}update({viewport:t,onBefore:n=null}){let r=t.scale*Nt.pixelRatio,i=t.rotation;if(i!==x(jd,this)&&(n==null||n(),C(jd,this,i),Mt(x(Ad,this),{rotation:i})),r!==x(Md,this)){n==null||n(),C(Md,this,r);let t={div:null,properties:null,ctx:Wd.call(e,x(Td,this))};for(let e of x(Id,this))t.properties=x(Ld,this).get(e),t.div=e,f(zd,this,Ud).call(this,t)}}cancel(){var e;let t=new Ye(`TextLayer task cancelled.`);(e=x(kd,this))==null||e.cancel(t).catch(()=>{}),C(kd,this,null),x(bd,this).reject(t)}get textDivs(){return x(Id,this)}get textContentItemsStr(){return x(Pd,this)}static cleanup(){if(!(f(e,this,Qd)._.size>0)){f(e,this,Jd)._.clear();for(let{canvas:t}of f(e,this,Yd)._.values())t.remove();f(e,this,Yd)._.clear()}}};ie=Bd;function Vd(e){var t;if(x(Sd,this))return;(t=x(Ed,this)).ctx!=null||(t.ctx=Wd.call(ie,x(Td,this)));let n=x(Id,this),r=x(Pd,this);for(let t of e){if(n.length>vd){I(`Ignoring additional textDivs for performance reasons.`),C(Sd,this,!0);return}if(t.str===void 0){if(t.type===`beginMarkedContentProps`||t.type===`beginMarkedContent`){let e=x(xd,this);C(xd,this,document.createElement(`span`)),x(xd,this).classList.add(`markedContent`),t.id&&x(xd,this).setAttribute(`id`,`${t.id}`),t.tag===`Artifact`&&(x(xd,this).ariaHidden=!0),e.append(x(xd,this))}else t.type===`endMarkedContent`&&C(xd,this,x(xd,this).parentNode);continue}r.push(t.str),f(zd,this,Hd).call(this,t)}}function Hd(e){let t=document.createElement(`span`),n={angle:0,canvasWidth:0,hasText:e.str!==``,hasEOL:e.hasEOL,fontSize:0};x(Id,this).push(t);let r=B.transform(x(Rd,this),e.transform),i=Math.atan2(r[1],r[0]),a=x(Nd,this)[e.fontName];a.vertical&&(i+=Math.PI/2);let o=x(Cd,this)&&a.fontSubstitution||a.fontFamily;o=ie.fontFamilyMap.get(o)||o;let s=Math.hypot(r[2],r[3]),c=s*qd.call(ie,o,a,x(Td,this)),l,u;i===0?(l=r[4],u=r[5]-c):(l=r[4]+c*Math.sin(i),u=r[5]-c*Math.cos(i));let d=t.style;d.left=`${(100*l/x(Od,this)).toFixed(2)}%`,d.top=`${(100*u/x(Dd,this)).toFixed(2)}%`,d.setProperty(`--font-height`,`${s.toFixed(2)}px`),d.fontFamily=o,n.fontSize=s,t.setAttribute(`role`,`presentation`),t.textContent=e.str,t.dir=e.dir,x(Cd,this)&&(t.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),i!==0&&(n.angle=180/Math.PI*i);let p=!1;if(e.str.length>1)p=!0;else if(e.str!==` `&&e.transform[0]!==e.transform[3]){let t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(p=!0)}if(p&&(n.canvasWidth=a.vertical?e.height:e.width),x(Ld,this).set(t,n),x(Ed,this).div=t,x(Ed,this).properties=n,f(zd,this,Ud).call(this,x(Ed,this)),n.hasText&&x(xd,this).append(t),n.hasEOL){let e=document.createElement(`br`);e.setAttribute(`role`,`presentation`),x(xd,this).append(e)}}function Ud(e){let{div:t,properties:n,ctx:r}=e,{style:i}=t;if(n.canvasWidth!==0&&n.hasText){let{fontFamily:e}=i,{canvasWidth:a,fontSize:o}=n;Gd.call(ie,r,o*x(Md,this),e);let{width:s}=r.measureText(t.textContent);s>0&&i.setProperty(`--scale-x`,a*x(Md,this)/s)}n.angle!==0&&i.setProperty(`--rotate`,`${n.angle}deg`)}function Wd(e=null){let t=f(ie,this,Yd)._.get(e||(e=``));if(!t){let n=document.createElement(`canvas`);n.style.cssText=`position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal`,n.lang=e,document.body.append(n),t=n.getContext(`2d`,{alpha:!1,willReadFrequently:!0}),f(ie,this,Yd)._.set(e,t),f(ie,this,Xd)._.set(t,{size:0,family:``})}return t}function Gd(e,t,n){let r=f(ie,this,Xd)._.get(e);t===r.size&&n===r.family||(e.font=`${t}px ${n}`,r.size=t,r.family=n)}function Kd(){if(f(ie,this,Zd)._!==null)return;let e=document.createElement(`div`);e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize=`1px`,e.style.position=`absolute`,e.textContent=`X`,document.body.append(e),Zd._=f(ie,this,e.getBoundingClientRect().height),e.remove()}function qd(e,t,n){let r=f(ie,this,Jd)._.get(e);if(r)return r;let i=f(ie,this,Wd).call(this,n);i.canvas.width=i.canvas.height=yd,f(ie,this,Gd).call(this,i,yd,e);let a=i.measureText(``),o=a.fontBoundingBoxAscent,s=Math.abs(a.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let c=.8;return o?c=o/(o+s):(z.platform.isFirefox&&I("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),t.ascent?c=t.ascent:t.descent&&(c=1+t.descent)),f(ie,this,Jd)._.set(e,c),c}var Jd={_:new Map},Yd={_:new Map},Xd={_:new WeakMap},Zd={_:null},Qd={_:new Set},$d=100;function ef(e={}){var t;let n=new tf,{docId:r}=n,i=e.url?ks(e.url):null,a=e.data?As(e.data):null,o=e.httpHeaders||null,s=e.withCredentials===!0,c=(t=e.password)==null?null:t,l=e.range instanceof of?e.range:null,u=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:Math.pow(2,16),d=e.worker instanceof vf?e.worker:null,f=e.verbosity,p=typeof e.docBaseUrl==`string`&&!gt(e.docBaseUrl)?e.docBaseUrl:null,m=js(e.cMapUrl),h=e.cMapPacked!==!1,g=js(e.iccUrl),_=js(e.standardFontDataUrl),v=js(e.wasmUrl),y=e.stopAtErrors!==!0,b=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,x=typeof e.isOffscreenCanvasSupported==`boolean`?e.isOffscreenCanvasSupported:!ge,S=typeof e.isImageDecoderSupported==`boolean`?e.isImageDecoderSupported:!ge,C=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,w=typeof e.disableFontFace==`boolean`?e.disableFontFace:ge,T=e.fontExtraProperties===!0,E=e.enableXfa===!0,D=e.ownerDocument||globalThis.document,O=e.disableRange===!0,k=e.disableStream===!0,A=e.disableAutoFetch===!0,ee=e.pdfBug===!0,j=e.CanvasFactory||(ge?Dc:$s),te=e.FilterFactory||(ge?Ec:cc),ne=e.BinaryDataFactory||(ge?Oc:Xs),M=e.enableHWA===!0,re=e.enableWebGPU===!0?Bc():Promise.resolve(!1),ie=e.useWasm!==!1,ae=e.pagesMapper||new ud,oe=typeof e.useSystemFonts==`boolean`?e.useSystemFonts:!ge&&!w,se=typeof e.useWorkerFetch==`boolean`?e.useWorkerFetch:!!(ne===Xs&&m&&h&&_&&v&&St(m,document.baseURI)&&St(_,document.baseURI)&&St(v,document.baseURI));Fe(f);let ce={canvasFactory:new j({ownerDocument:D,enableHWA:M}),filterFactory:new te({docId:r,ownerDocument:D}),binaryDataFactory:se?null:new ne({cMapUrl:m,standardFontDataUrl:_,wasmUrl:v})};d||(d=vf.create({verbosity:f,port:zu.workerPort}),n._worker=d);let le={docId:r,apiVersion:`6.1.200`,data:a,password:c,disableAutoFetch:A,rangeChunkSize:u,docBaseUrl:p,enableXfa:E,evaluatorOptions:{maxImageSize:b,disableFontFace:w,ignoreErrors:y,isOffscreenCanvasSupported:x,isImageDecoderSupported:S,canvasMaxAreaInBytes:C,fontExtraProperties:T,useSystemFonts:oe,useWasm:ie,useWorkerFetch:se,cMapUrl:m,cMapPacked:h,iccUrl:g,standardFontDataUrl:_,wasmUrl:v,hasGPU:!1}},ue={ownerDocument:D,pdfBug:ee,styleElement:null,enableHWA:M,loadingParams:{disableAutoFetch:A,enableXfa:E}};return Promise.all([d.promise,re]).then(function([,e]){if(d.destroyed)throw Error(`Worker was destroyed`);le.evaluatorOptions.hasGPU=e;let t=d.messageHandler.sendWithPromise(`GetDocRequest`,le,a?[a.buffer]:null),c;if(!a)if(l)c=new su({pdfDataRangeTransport:l,disableRange:O,disableStream:k});else if(i)c=new(Ru(i))({url:i,httpHeaders:o,withCredentials:s,rangeChunkSize:u,disableRange:O,disableStream:k});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return t.then(e=>{if(d.destroyed)throw Error(`Worker was destroyed`);let t=new Us(r,e,d.port),i=new Ff(t,n,c,ue,ce,ae);if(n._transport=i,n.destroyed)throw Error(`Loading aborted`);t.send(`Ready`,null)})}).catch(n._capability.reject).finally(n._setupCapability.resolve),n}var tf=class{constructor(){var e,t;g(this,`_capability`,Promise.withResolvers()),g(this,`_setupCapability`,Promise.withResolvers()),g(this,`_transport`,null),g(this,`_worker`,null),g(this,`docId`,`d${nf._=(e=nf._,t=e++,e),t}`),g(this,`destroyed`,!1),g(this,`onPassword`,null),g(this,`onProgress`,null)}get promise(){return this._capability.promise}destroy(){var e=this;return v(function*(){var t;e.destroyed=!0,e._capability.promise.catch(()=>{});try{var n,r;(n=e._worker)!=null&&n.port&&(e._worker._pendingDestroy=!0),yield e._setupCapability.promise,yield(r=e._transport)==null?void 0:r.destroy()}catch(t){var i;throw(i=e._worker)!=null&&i.port&&delete e._worker._pendingDestroy,t}e._transport=null,(t=e._worker)==null||t.destroy(),e._worker=null})()}getData(){var e=this;return v(function*(){return e._transport.getData()})()}},nf={_:0},rf=new WeakMap,af=new WeakMap,of=class{constructor(e,t,n=!1,r=null){b(this,rf,Promise.withResolvers()),b(this,af,null),this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r}onDataRange(e,t){x(af,this).call(this,{type:`range`,begin:e,chunk:t})}onDataProgressiveRead(e){x(rf,this).promise.then(()=>{x(af,this).call(this,{type:`progressiveRead`,chunk:e})})}onDataProgressiveDone(){x(rf,this).promise.then(()=>{x(af,this).call(this,{type:`progressiveDone`})})}transportReady(e){C(af,this,e),x(rf,this).resolve()}requestDataRange(e,t){L(`Abstract method PDFDataRangeTransport.requestDataRange`)}abort(){}},sf=class{constructor(e,t){this._pdfInfo=e,this._transport=t}get pagesMapper(){return this._transport.pagesMapper}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 R(this,`isPureXfa`,!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}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()}getAttachmentContent(e){return this._transport.getAttachmentContent(e)}getAnnotationsByType(e,t){return this._transport.getAnnotationsByType(e,t)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}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()}extractPages(e){return this._transport.extractPages(e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(e){return this._transport.getRawData(e)}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}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()}},cf=new WeakMap,lf=new WeakMap,uf=new WeakSet,df=class e{constructor(e,t,n,r,i=!1){S(this,uf),b(this,cf,!1),b(this,lf,null),this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=i?new xt:null,this._pdfBug=i,this.commonObjs=n.commonObjs,this.objs=new _d,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,C(lf,this,r),this.imageCoordinates=null}clone(t){var n;let r=new e(t,this._pageInfo,this._transport,x(lf,this),this._pdfBug);return r.clonedFromIndex=(n=this.clonedFromIndex)==null?this._pageIndex:n,this._transport.updatePage(r),r}get pageNumber(){return this._pageIndex+1}set pageNumber(e){this._pageIndex=e-1,this._transport.updatePage(this)}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:e,rotation:t=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new lt({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:i})}getAnnotations({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return R(this,`isPureXfa`,!!this._transport._htmlForXfa)}getXfa(){var e=this;return v(function*(){var t;return((t=e._transport._htmlForXfa)==null?void 0:t.children[e._pageIndex])||null})()}render({canvasContext:e,canvas:t=e.canvas,viewport:n,intent:r=`display`,annotationMode:i=Ce.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:s=null,annotationCanvasMap:c=null,pageColors:l=null,printAnnotationStorage:u=null,isEditing:d=!1,recordImages:p=!1,recordOperations:m=!1,operationsFilter:h=null}){var g,_,v;(g=this._stats)==null||g.time(`Overall`);let y=this._transport.getRenderingIntent(r,i,u,d),{renderingIntent:b,cacheKey:x}=y;C(cf,this,!1),s||(s=this._transport.getOptionalContentConfig(b));let S=this._intentStates.getOrInsertComputed(x,ct);S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);let w=!!(b&Se.PRINT);if(!S.displayReadyCapability){var T;S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(T=this._stats)==null||T.time(`Page Request`),this._pumpOperatorList(y)}let E=!!(this._pdfBug&&(_=globalThis.StepperManager)!=null&&_.enabled),D=!!t&&!this.recordedBBoxes&&(m||E),O=!!t&&!this.imageCoordinates&&p,k=e=>{if(S.renderTasks.delete(j),D){var t;let e=(t=j.gfx)==null?void 0:t.dependencyTracker.take();if(e){var n;(n=j.stepper)==null||n.setOperatorBBoxes(e,j.gfx.dependencyTracker.takeDebugMetadata()),m&&(this.recordedBBoxes=e)}}if(O&&!e){var r;this.imageCoordinates=(r=j.gfx)==null?void 0:r.imagesTracker.take()}if(w&&C(cf,this,!0),f(uf,this,ff).call(this),e?(j.capability.reject(e),this._abortOperatorList({intentState:S,reason:e instanceof Error?e:Error(e)})):j.capability.resolve(),this._stats){var i;this._stats.timeEnd(`Rendering`),this._stats.timeEnd(`Overall`),(i=globalThis.Stats)!=null&&i.enabled&&globalThis.Stats.add(this.pageNumber,this._stats)}},A=null,ee=null;(D||O)&&(ee=new So(t,S.operatorList.length)),D&&(A=new Mo(ee,E));let j=new Bf({callback:k,params:{canvas:t,canvasContext:e,dependencyTracker:(v=A)==null?ee:v,imagesTracker:O?new Go(t):null,viewport:n,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:l,enableHWA:this._transport.enableHWA,operationsFilter:h});(S.renderTasks||(S.renderTasks=new Set)).add(j);let te=j.task;return Promise.all([S.displayReadyCapability.promise,s]).then(([e,t])=>{var n;if(this.destroyed){k();return}if((n=this._stats)==null||n.time(`Rendering`),!(t.renderingIntent&b))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");j.initializeGraphics({transparency:e,optionalContentConfig:t}),j.operatorListChanged()}).catch(k),te}getOperatorList({intent:e=`display`,annotationMode:t=Ce.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(s))}let a=this._transport.getRenderingIntent(e,t,n,r,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,ct),s;if(!o.opListReadCapability){var c;s=Object.create(null),s.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(s),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time(`Page Request`),this._pumpOperatorList(a)}return o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream(`GetTextContent`,{pageId:x(lf,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(e){return e.items.length}})}getTextContent(){var e=this;return v(function*(t={}){if(e._transport._htmlForXfa)return e.getXfa().then(e=>ut.textContent(e));let n=e.streamTextContent(t),r={items:[],styles:Object.create(null),lang:null};var i=!1,a=!1,o;try{for(var s=E(n),c;i=!(c=yield s.next()).done;i=!1){let e=c.value;r.lang!=null||(r.lang=e.lang),Object.assign(r.styles,e.styles),r.items.push(...e.items)}}catch(e){a=!0,o=e}finally{try{i&&s.return!=null&&(yield s.return())}finally{if(a)throw o}}return r}).apply(this,arguments)}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:Error(`Page was destroyed.`),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),C(cf,this,!1),Promise.all(e)}cleanup(e=!1){C(cf,this,!0);let t=f(uf,this,ff).call(this);return e&&t&&this._stats&&(this._stats=new xt),t}_startRenderPage(e,t){var n,r;let i=this._intentStates.get(t);i&&((n=this._stats)==null||n.timeEnd(`Page Request`),(r=i.displayReadyCapability)==null||r.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let e of t.renderTasks)e.operatorListChanged();e.lastChunk&&f(uf,this,ff).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){let{map:i,transfer:a}=n,o=this._transport.messageHandler.sendWithStream(`GetOperatorList`,{pageId:x(lf,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i,modifiedIds:r},void 0,a).getReader(),s=this._intentStates.get(t);s.streamReader=o;let c=()=>{o.read().then(({value:e,done:t})=>{if(t){s.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(e,s),c())},e=>{if(s.streamReader=null,!this._transport.destroyed){if(s.operatorList){s.operatorList.lastChunk=!0;for(let e of s.renderTasks)e.operatorListChanged();f(uf,this,ff).call(this)}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else if(s.opListReadCapability)s.opListReadCapability.reject(e);else throw e}})};c()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof ht){let n=$d;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new Ye(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}};function ff(){if(!x(cf,this)||this.destroyed)return!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),C(cf,this,!1),!0}var pf=new WeakMap,mf=new WeakMap,hf=new WeakMap,gf=new WeakMap,_f=new WeakSet,vf=class e{constructor({name:e=null,port:t=null,verbosity:n=Ie()}={}){if(S(this,_f),b(this,pf,Promise.withResolvers()),b(this,mf,null),b(this,hf,null),b(this,gf,null),this.name=e,this.destroyed=!1,this.verbosity=n,t){if(Ef._.has(t))throw Error(`Cannot use more than one PDFWorker per port.`);Ef._.set(t,this),f(_f,this,bf).call(this,t)}else f(_f,this,xf).call(this)}get promise(){return x(pf,this).promise}get port(){return x(hf,this)}get messageHandler(){return x(mf,this)}destroy(){var e,t;this.destroyed=!0,(e=x(gf,this))==null||e.terminate(),C(gf,this,null),Ef._.delete(x(hf,this)),C(hf,this,null),(t=x(mf,this))==null||t.destroy(),C(mf,this,null)}static create(t){let n=f(e,this,Ef)._.get(t==null?void 0:t.port);if(n){if(n._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new e(t)}static get workerSrc(){if(zu.workerSrc)return zu.workerSrc;throw Error(`No "GlobalWorkerOptions.workerSrc" specified.`)}static get _setupFakeWorkerGlobal(){var t=this;let n=function(){var n=v(function*(){return Cf.call(f(e,t))?Cf.call(f(e,t)):(yield import(t.workerSrc)).WorkerMessageHandler});return function(){return n.apply(this,arguments)}}();return R(this,`_setupFakeWorkerGlobal`,n())}};ae=vf;function yf(){x(pf,this).resolve(),x(mf,this).send(`configure`,{verbosity:this.verbosity})}function bf(e){C(hf,this,e),C(mf,this,new Us(`main`,`worker`,e)),x(mf,this).on(`ready`,()=>{}),f(_f,this,yf).call(this)}function xf(){if(Tf._||Cf.call(ae)){f(_f,this,Sf).call(this);return}let{workerSrc:e}=ae;try{ae._isSameOrigin(window.location,e)||(e=ae._createCDNWrapper(new URL(e,window.location).href));let t=new Worker(e,{type:`module`}),n=new Us(`main`,`worker`,t),r=()=>{i.abort(),n.destroy(),t.terminate(),this.destroyed?x(pf,this).reject(Error(`Worker was destroyed`)):f(_f,this,Sf).call(this)},i=new AbortController;t.addEventListener(`error`,()=>{x(gf,this)||r()},{signal:i.signal}),n.on(`test`,e=>{if(i.abort(),this.destroyed||!e){r();return}C(mf,this,n),C(hf,this,t),C(gf,this,t),f(_f,this,yf).call(this)}),n.on(`ready`,e=>{if(i.abort(),this.destroyed){r();return}try{a()}catch(e){f(_f,this,Sf).call(this)}});let a=()=>{let e=new Uint8Array;n.send(`test`,e,[e.buffer])};a();return}catch(e){Le(`The worker has been disabled.`)}f(_f,this,Sf).call(this)}function Sf(){Tf._||(I(`Setting up fake worker.`),Tf._=!0),ae._setupFakeWorkerGlobal.then(e=>{var t,n;if(this.destroyed){x(pf,this).reject(Error(`Worker was destroyed`));return}let r=new Is;C(hf,this,r);let i=`fake${wf._=(t=wf._,n=t++,t),n}`,a=new Us(i+`_worker`,i,r);e.setup(a,r),C(mf,this,new Us(i,i+`_worker`,r)),f(_f,this,yf).call(this)}).catch(e=>{x(pf,this).reject(Error(`Setting up fake worker failed: "${e.message}".`))})}function Cf(){try{var e;return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch(e){return null}}var wf={_:0},Tf={_:!1},Ef={_:new WeakMap};ge&&(Tf._=f(ae,ae,!0),zu.workerSrc||(zu.workerSrc=`./pdf.worker.mjs`)),ae._isSameOrigin=(e,t)=>{let n=URL.parse(e);if(!(n!=null&&n.origin)||n.origin===`null`)return!1;let r=new URL(t,n);return n.origin===r.origin},ae._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:`text/javascript`}))};var Df=new WeakMap,Of=new WeakMap,kf=new WeakMap,Af=new WeakMap,jf=new WeakMap,Mf=new WeakMap,Nf=new WeakMap,Pf=new WeakSet,Ff=class{constructor(e,t,n,r,i,a){S(this,Pf),g(this,`downloadInfoCapability`,Promise.withResolvers()),b(this,Df,null),b(this,Of,new Map),b(this,kf,null),b(this,Af,new Map),b(this,jf,new Map),b(this,Mf,new Map),b(this,Nf,null),this.messageHandler=e,this.loadingTask=t,C(kf,this,n),this.commonObjs=new _d,this.fontLoader=new Xo({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.enableHWA=r.enableHWA,this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.binaryDataFactory=i.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(e){let{_pageIndex:t}=e;x(Af,this).set(t,e),x(jf,this).set(t,Promise.resolve(e))}get annotationStorage(){return R(this,`annotationStorage`,new eo)}getRenderingIntent(e,t=Ce.ENABLE,n=null,r=!1,i=!1){let a=Se.DISPLAY,o=Ja;switch(e){case`any`:a=Se.ANY;break;case`display`:break;case`print`:a=Se.PRINT;break;default:I(`getRenderingIntent - invalid intent: ${e}`)}let s=a&Se.PRINT&&n instanceof ro?n:this.annotationStorage;switch(t){case Ce.DISABLE:a+=Se.ANNOTATIONS_DISABLE;break;case Ce.ENABLE:break;case Ce.ENABLE_FORMS:a+=Se.ANNOTATIONS_FORMS;break;case Ce.ENABLE_STORAGE:a+=Se.ANNOTATIONS_STORAGE,o=s.serializable;break;default:I(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(a+=Se.IS_EDITING),i&&(a+=Se.OPLIST);let{ids:c,hash:l}=s.modifiedIds,u=[a,o.hash,l];return{renderingIntent:a,cacheKey:u.join(`_`),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var e;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(e=x(Nf,this))==null||e.reject(Error(`Worker was destroyed during onPassword callback`));let t=[];for(let e of x(Af,this).values())t.push(e._destroy());x(Af,this).clear(),x(jf,this).clear(),x(Mf,this).clear(),Object.hasOwn(this,`annotationStorage`)&&this.annotationStorage.resetModified();let n=this.messageHandler.sendWithPromise(`Terminate`,null);return t.push(n),Promise.all(t).then(()=>{var e,t;this.commonObjs.clear(),this.fontLoader.clear(),x(Of,this).clear(),this.filterFactory.destroy(),Bd.cleanup(),(e=x(kf,this))==null||e.cancelAllRequests(new Ye(`Worker was terminated.`)),(t=this.messageHandler)==null||t.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){var e=this;let{messageHandler:t,loadingTask:n}=this;t.on(`GetReader`,(e,t)=>{Re(x(kf,this),"GetReader - no `BasePDFStream` instance available."),C(Df,this,x(kf,this).getFullReader()),x(Df,this).onProgress=e=>f(Pf,this,Lf).call(this,e),t.onPull=()=>{x(Df,this).read().then(function({value:e,done:n}){if(n){t.close();return}Re(e instanceof ArrayBuffer,`GetReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{x(Df,this).cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),t.on(`ReaderHeadersReady`,function(){var t=v(function*(t){yield x(Df,e).headersReady;let{isStreamingSupported:n,isRangeSupported:r,contentLength:i}=x(Df,e);return n&&r&&(x(Df,e).onProgress=null),{isStreamingSupported:n,isRangeSupported:r,contentLength:i}});return function(e){return t.apply(this,arguments)}}()),t.on(`GetRangeReader`,(e,t)=>{Re(x(kf,this),"GetRangeReader - no `BasePDFStream` instance available.");let n=x(kf,this).getRangeReader(e.begin,e.end);if(!n){t.close();return}t.onPull=()=>{n.read().then(function({value:e,done:n}){if(n){t.close();return}Re(e instanceof ArrayBuffer,`GetRangeReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{n.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),t.on(`GetDoc`,({pdfInfo:e})=>{this.pagesMapper.pagesNumber=e.numPages,this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,n._capability.resolve(new sf(e,this))}),t.on(`DocException`,e=>{n._capability.reject(Bs(e))}),t.on(`PasswordRequest`,e=>{C(Nf,this,Promise.withResolvers());try{if(!n.onPassword)throw Bs(e);n.onPassword(e=>{e instanceof Error?x(Nf,this).reject(e):x(Nf,this).resolve({password:e})},e.code)}catch(e){x(Nf,this).reject(e)}return x(Nf,this).promise}),t.on(`DataLoaded`,e=>{f(Pf,this,Lf).call(this,{loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),t.on(`StartRenderPage`,e=>{this.destroyed||x(Af,this).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),t.on(`commonobj`,([e,n,r])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(n){case`Font`:var i;if(`error`in r){let t=r.error;I(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let a=new $o(new bs(r),this._params.pdfBug&&(i=globalThis.FontInspector)!=null&&i.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,r.charProcOperatorList,r.extra);this.fontLoader.bind(a).catch(()=>t.sendWithPromise(`FontFallback`,{id:e})).finally(()=>{a.fontExtraProperties||a.clearData(),this.commonObjs.resolve(e,a)});break;case`CopyLocalImage`:let{imageRef:o}=r;Re(o,`The imageRef must be defined.`);for(let t of x(Af,this).values())for(let[,n]of t.objs){if((n==null?void 0:n.ref)!==o)continue;if(!n.dataLen)return null;let t=structuredClone(n);return this.commonObjs.resolve(e,t),n.dataLen}break;case`FontPath`:this.commonObjs.resolve(e,new Os(r));break;case`Image`:this.commonObjs.resolve(e,r);break;case`Pattern`:let s=new Es(r);this.commonObjs.resolve(e,s.getIR());break;default:throw Error(`Got unknown common object type ${n}`)}return null}),t.on(`obj`,([e,t,n,r])=>{if(this.destroyed)return;let i=x(Af,this).get(t);if(!i.objs.has(e)){if(i._intentStates.size===0){var a;r==null||(a=r.bitmap)==null||a.close();return}switch(n){case`Image`:case`Pattern`:i.objs.resolve(e,r);break;default:throw Error(`Got unknown object type ${n}`)}}}),t.on(`DocProgress`,e=>{this.destroyed||f(Pf,this,Lf).call(this,e)}),t.on(`FetchBinaryData`,function(){var t=v(function*(t){if(e.destroyed)throw Error(`Worker was destroyed.`);if(!e.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return e.binaryDataFactory.fetch(t)});return function(e){return t.apply(this,arguments)}}())}getData(){return this.messageHandler.sendWithPromise(`GetData`,null)}saveDocument(){var e,t;this.annotationStorage.size<=0&&I("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:n,transfer:r}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise(`SaveDocument`,{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:n,filename:(e=(t=x(Df,this))==null?void 0:t.filename)==null?null:e},r).finally(()=>{this.annotationStorage.resetModified()})}extractPages(e){let t={pageInfos:e},n,r=globalThis.ImageBitmap;if(typeof r==`function`){let t=Array.isArray(e)?e:[e];for(let e of t)(e==null?void 0:e.image)instanceof r&&(n||(n=[])).push(e.image)}if(this.annotationStorage.size>0){var i;let e=this.annotationStorage.serializable,{map:r}=e;(i=e.transfer)!=null&&i.length&&(n?n.push(...e.transfer):n=e.transfer);let a=this.pagesMapper.getMapping();if(a){let e=new Map;for(let[t,n]of r){if((n==null?void 0:n.pageIndex)!==void 0&&n.pageIndex>=0&&n.pageIndex<a.length){let r=a[n.pageIndex]-1;if(r!==n.pageIndex){e.set(t,T(T({},n),{},{pageIndex:r}));continue}}e.set(t,n)}r=e}t.annotationStorage=r}return this.messageHandler.sendWithPromise(`ExtractPages`,t,n).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this.pagesMapper.pagesNumber)return Promise.reject(Error(`Invalid page request.`));let t=e-1,n=this.pagesMapper.getPageId(e)-1,r=x(jf,this).get(t);if(r)return r;let i=this.messageHandler.sendWithPromise(`GetPage`,{pageIndex:n}).then(e=>{if(this.destroyed)throw Error(`Transport destroyed`);e.refStr&&x(Mf,this).set(e.refStr,n);let r=new df(t,e,this,this.pagesMapper,this._params.pdfBug);return x(Af,this).set(t,r),r});return x(jf,this).set(t,i),i}getPageIndex(e){var t=this;return v(function*(){if(!Ms(e))throw Error(`Invalid pageIndex request.`);let n=yield t.messageHandler.sendWithPromise(`GetPageIndex`,{num:e.num,gen:e.gen}),r=t.pagesMapper.getPageNumber(n+1);if(r===0)throw Error(`GetPageIndex: page has been removed.`);return r-1})()}getAnnotations(e,t){return this.messageHandler.sendWithPromise(`GetAnnotations`,{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return f(Pf,this,If).call(this,`GetFieldObjects`)}hasJSActions(){return f(Pf,this,If).call(this,`HasJSActions`)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise(`GetCalculationOrderIds`,null)}getDestinations(){return this.messageHandler.sendWithPromise(`GetDestinations`,null)}getDestination(e){return typeof e==`string`?this.messageHandler.sendWithPromise(`GetDestination`,{id:e}):Promise.reject(Error(`Invalid destination request.`))}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)}getAttachmentContent(e){return this.messageHandler.sendWithPromise(`GetAttachmentContent`,e)}getAnnotationsByType(e,t){return this.messageHandler.sendWithPromise(`GetAnnotationsByType`,{types:e,pageIndexesToSkip:t})}getDocJSActions(){return f(Pf,this,If).call(this,`GetDocJSActions`)}getPageJSActions(e){return this.messageHandler.sendWithPromise(`GetPageJSActions`,{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getStructTree(e){return this.messageHandler.sendWithPromise(`GetStructTree`,{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getOutline(){return this.messageHandler.sendWithPromise(`GetOutline`,null)}getOptionalContentConfig(e){return f(Pf,this,If).call(this,`GetOptionalContentConfig`).then(t=>new nd(t,e))}getPermissions(){return this.messageHandler.sendWithPromise(`GetPermissions`,null)}getMetadata(){let e=`GetMetadata`;return x(Of,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).then(e=>{var t,n,r,i;return{info:e[0],metadata:e[1]?new Wu(e[1]):null,contentDispositionFilename:(t=(n=x(Df,this))==null?void 0:n.filename)==null?null:t,contentLength:(r=(i=x(Df,this))==null?void 0:i.contentLength)==null?null:r,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise(`GetMarkInfo`,null)}getRawData(e){return this.messageHandler.sendWithPromise(`GetRawData`,e)}startCleanup(e=!1){var t=this;return v(function*(){if(!t.destroyed){yield t.messageHandler.sendWithPromise(`Cleanup`,null);for(let e of x(Af,t).values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);t.commonObjs.clear(),e||t.fontLoader.clear(),x(Of,t).clear(),t.filterFactory.destroy(!0),Bd.cleanup()}})()}cachedPageNumber(e){if(!Ms(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`,n=x(Mf,this).get(t);if(n>=0){let e=this.pagesMapper.getPageNumber(n+1);if(e!==0)return e}return null}};function If(e,t=null){return x(Of,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))}function Lf({loaded:e,total:t}){var n,r;(n=(r=this.loadingTask).onProgress)==null||n.call(r,{loaded:e,total:t,percent:t?V(Math.round(e/t*100),0,100):NaN})}var Rf=class{constructor(e){g(this,`_internalRenderTask`,null),g(this,`onContinue`,null),g(this,`onError`,null),this._internalRenderTask=e}get promise(){return this._internalRenderTask.capability.promise}cancel(e=0){this._internalRenderTask.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this._internalRenderTask.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this._internalRenderTask;return e.form||e.canvas&&(t==null?void 0:t.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}},zf=new WeakMap,Bf=class{constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:s,filterFactory:c,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:d=null,enableHWA:f=!1,operationsFilter:p=null}){b(this,zf,null),this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=l===!0&&typeof window<`u`,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Rf(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=t.canvas,this._canvasContext=t.canvas?null:t.canvasContext,this._enableHWA=f,this._dependencyTracker=t.dependencyTracker,this._imagesTracker=t.imagesTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var n,r;if(this.cancelled)return;if(this._canvas){if(Vf._.has(this._canvas))throw Error(`Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.`);Vf._.add(this._canvas)}this._pdfBug&&(n=globalThis.StepperManager)!=null&&n.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{viewport:i,transform:a,background:o,dependencyTracker:s,imagesTracker:c}=this.params,l=this._canvasContext||this._canvas.getContext(`2d`,{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new kl(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors,s,c),this.gfx.beginDrawing({transform:a,viewport:i,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,(r=this.graphicsReadyCallback)==null||r.call(this)}cancel(e=null,t=0){var n,r,i;this.running=!1,this.cancelled=!0,(n=this.gfx)==null||n.endDrawing(),x(zf,this)&&(window.cancelAnimationFrame(x(zf,this)),C(zf,this,null)),Vf._.delete(this._canvas),e||(e=new ht(`Rendering cancelled, page ${this._pageIndex+1}`,t)),this.callback(e),(r=(i=this.task).onError)==null||r.call(i,e)}operatorListChanged(){var e,t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.gfx.dependencyTracker)==null||e.growOperationsCount(this.operatorList.fnArray.length),(t=this.stepper)==null||t.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?C(zf,this,window.requestAnimationFrame(()=>{C(zf,this,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){var e=this;return v(function*(){e.cancelled||(e.operatorListIdx=e.gfx.executeOperatorList(e.operatorList,e.operatorListIdx,e._continueBound,e.stepper,e._operationsFilter),e.operatorListIdx===e.operatorList.argsArray.length&&(e.running=!1,e.operatorList.lastChunk&&(e.gfx.endDrawing(),Vf._.delete(e._canvas),e.callback())))})()}},Vf={_:new WeakSet},Hf=`6.1.200`,Uf=`6353acefe`,Wf=new WeakMap,Gf=new WeakMap,Kf=new WeakMap,qf=new WeakMap,Jf=new WeakMap,Yf=new WeakMap,Xf=new WeakMap,Zf=new WeakMap,Qf=new WeakMap,$f=new WeakMap,ep=new WeakSet,tp=class e{static get _keyboardManager(){return R(this,`_keyboardManager`,new Ln([[[`Escape`],e.prototype._hideDropdownFromKeyboard],[[`Space`],e.prototype._colorSelectFromKeyboard],[[`ArrowDown`,`ArrowRight`],e.prototype._moveToNext],[[`ArrowUp`,`ArrowLeft`],e.prototype._moveToPrevious],[[`Home`],e.prototype._moveToBeginning],[[`End`],e.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){var n,r;S(this,ep),b(this,Wf,null),b(this,Gf,null),b(this,Kf,void 0),b(this,qf,null),b(this,Jf,!1),b(this,Yf,!1),b(this,Xf,null),b(this,Zf,void 0),b(this,Qf,null),b(this,$f,null),e?(C(Yf,this,!1),C(Xf,this,e)):C(Yf,this,!0),C($f,this,(e==null?void 0:e._uiManager)||t),C(Zf,this,x($f,this)._eventBus),C(Kf,this,(e==null||(n=e.color)==null?void 0:n.toUpperCase())||((r=x($f,this))==null?void 0:r.highlightColors.values().next().value)||`#FFFF98`),cp._||(cp._=Object.freeze({blue:`pdfjs-editor-colorpicker-blue`,green:`pdfjs-editor-colorpicker-green`,pink:`pdfjs-editor-colorpicker-pink`,red:`pdfjs-editor-colorpicker-red`,yellow:`pdfjs-editor-colorpicker-yellow`}))}renderButton(){let e=C(Wf,this,document.createElement(`button`));e.className=`colorPicker`,e.tabIndex=`0`,e.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-button`),e.ariaHasPopup=`true`,x(Xf,this)&&(e.ariaControls=`${x(Xf,this).id}_colorpicker_dropdown`);let t=x($f,this)._signal;e.addEventListener(`click`,f(ep,this,ap).bind(this),{signal:t}),e.addEventListener(`keydown`,f(ep,this,ip).bind(this),{signal:t});let n=C(Gf,this,document.createElement(`span`));return n.className=`swatch`,n.ariaHidden=`true`,n.style.backgroundColor=x(Kf,this),e.append(n),e}renderMainDropdown(){let e=C(qf,this,f(ep,this,np).call(this));return e.ariaOrientation=`horizontal`,e.ariaLabelledBy=`highlightColorPickerLabel`,e}_colorSelectFromKeyboard(e){if(e.target===x(Wf,this)){f(ep,this,ap).call(this,e);return}let t=e.target.getAttribute(`data-color`);t&&f(ep,this,rp).call(this,t,e)}_moveToNext(e){var t;if(!sp.call(f(ep,this))){f(ep,this,ap).call(this,e);return}if(e.target===x(Wf,this)){var n;(n=x(qf,this).firstElementChild)==null||n.focus();return}(t=e.target.nextSibling)==null||t.focus()}_moveToPrevious(e){var t,n;if(e.target===((t=x(qf,this))==null?void 0:t.firstElementChild)||e.target===x(Wf,this)){sp.call(f(ep,this))&&this._hideDropdownFromKeyboard();return}sp.call(f(ep,this))||f(ep,this,ap).call(this,e),(n=e.target.previousSibling)==null||n.focus()}_moveToBeginning(e){var t;if(!sp.call(f(ep,this))){f(ep,this,ap).call(this,e);return}(t=x(qf,this).firstElementChild)==null||t.focus()}_moveToEnd(e){var t;if(!sp.call(f(ep,this))){f(ep,this,ap).call(this,e);return}(t=x(qf,this).lastElementChild)==null||t.focus()}hideDropdown(){var e,t;(e=x(qf,this))==null||e.classList.add(`hidden`),x(Wf,this).ariaExpanded=`false`,(t=x(Qf,this))==null||t.abort(),C(Qf,this,null)}_hideDropdownFromKeyboard(){if(!x(Yf,this)){if(!sp.call(f(ep,this))){var e;(e=x(Xf,this))==null||e.unselect();return}this.hideDropdown(),x(Wf,this).focus({preventScroll:!0,focusVisible:x(Jf,this)})}}updateColor(e){if(x(Gf,this)&&(x(Gf,this).style.backgroundColor=e),!x(qf,this))return;let t=x($f,this).highlightColors.values();for(let n of x(qf,this).children)n.ariaSelected=t.next().value===e.toUpperCase()}destroy(){var e,t;(e=x(Wf,this))==null||e.remove(),C(Wf,this,null),C(Gf,this,null),(t=x(qf,this))==null||t.remove(),C(qf,this,null)}};oe=tp;function np(){let e=document.createElement(`div`),t=x($f,this)._signal;e.addEventListener(`contextmenu`,Ct,{signal:t}),e.className=`dropdown`,e.role=`listbox`,e.ariaMultiSelectable=`false`,e.ariaOrientation=`vertical`,e.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-dropdown`),x(Xf,this)&&(e.id=`${x(Xf,this).id}_colorpicker_dropdown`);for(let[n,r]of x($f,this).highlightColors){let i=document.createElement(`button`);i.tabIndex=`0`,i.role=`option`,i.setAttribute(`data-color`,r),i.title=n,i.setAttribute(`data-l10n-id`,cp._[n]);let a=document.createElement(`span`);i.append(a),a.className=`swatch`,a.style.backgroundColor=r,i.ariaSelected=r===x(Kf,this),i.addEventListener(`click`,f(ep,this,rp).bind(this,r),{signal:t}),e.append(i)}return e.addEventListener(`keydown`,f(ep,this,ip).bind(this),{signal:t}),e}function rp(e,t){t.stopPropagation(),x(Zf,this).dispatch(`switchannotationeditorparams`,{source:this,type:P.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)}function ip(e){oe._keyboardManager.exec(this,e)}function ap(e){if(sp.call(f(ep,this))){this.hideDropdown();return}if(C(Jf,this,e.detail===0),x(Qf,this)||(C(Qf,this,new AbortController),window.addEventListener(`pointerdown`,f(ep,this,op).bind(this),{signal:x($f,this).combinedSignal(x(Qf,this))})),x(Wf,this).ariaExpanded=`true`,x(qf,this)){x(qf,this).classList.remove(`hidden`);return}let t=C(qf,this,f(ep,this,np).call(this));x(Wf,this).append(t)}function op(e){var t;(t=x(qf,this))!=null&&t.contains(e.target)||this.hideDropdown()}function sp(){return x(qf,this)&&!x(qf,this).classList.contains(`hidden`)}var cp={_:null},lp=new WeakMap,up=new WeakMap,dp=new WeakMap,fp=new WeakMap,pp=class{constructor(e){b(this,lp,null),b(this,up,!1),b(this,dp,null),b(this,fp,null),C(dp,this,e),C(fp,this,e._uiManager),mp._||(mp._=Object.freeze({freetext:`pdfjs-editor-color-picker-free-text-input`,ink:`pdfjs-editor-color-picker-ink-input`}))}renderButton(){if(x(lp,this))return x(lp,this);let{editorType:e,colorType:t,colorAndOpacityType:n,opacityType:r,color:i,opacity:a}=x(dp,this),o=C(up,this,z.isAlphaColorInputSupported&&r!==void 0),s=C(lp,this,document.createElement(`input`));if(s.type=`color`,o){s.setAttribute(`alpha`,``);let e=B.hexNums[Math.round((a==null?1:a)*255)];s.value=(i||`#000000`)+e}else s.value=i||`#000000`;return s.className=`basicColorPicker`,s.tabIndex=0,s.setAttribute(`data-l10n-id`,mp._[e]),s.addEventListener(`input`,()=>{if(o){let e=Dt(s.value);if(!e)return;let[i,a,o,c]=e,l=B.makeHexColor(i,a,o);n===void 0?(x(fp,this).updateParams(t,l),x(fp,this).updateParams(r,c)):x(fp,this).updateParams(n,{color:l,opacity:c})}else x(fp,this).updateParams(t,s.value)},{signal:x(fp,this)._signal}),s}update(e){if(x(lp,this))if(x(up,this)){let t=B.hexNums[Math.round(x(dp,this).opacity*255)];x(lp,this).value=e+t}else x(lp,this).value=e}updateOpacity(e){if(!x(lp,this)||!x(up,this))return;let t=B.hexNums[Math.round(e*255)];x(lp,this).value=x(dp,this).color+t}destroy(){var e;(e=x(lp,this))==null||e.remove(),C(lp,this,null)}hideDropdown(){}},mp={_:null};function hp(e){return Math.floor(V(e,0,1)*255).toString(16).padStart(2,`0`)}function gp(e){return V(e,0,1)*255}var _p=class{static CMYK_G([e,t,n,r]){return[`G`,1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return[`CMYK`,0,0,0,1-e]}static G_RGB([e]){return[`RGB`,e,e,e]}static G_rgb([e]){return e=gp(e),[e,e,e]}static G_HTML([e]){let t=hp(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return[`G`,.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(gp)}static RGB_HTML(e){return`#${e.map(hp).join(``)}`}static T_HTML(){return`#00000000`}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return[`RGB`,1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[gp(1-Math.min(1,e+r)),gp(1-Math.min(1,n+r)),gp(1-Math.min(1,t+r))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let r=1-e,i=1-t,a=1-n;return[`CMYK`,r,i,a,Math.min(r,i,a)]}},vp=class{create(e,t,n=!1){if(e<=0||t<=0)throw Error(`Invalid SVG dimensions`);let r=this._createSVG(`svg:svg`);return r.setAttribute(`version`,`1.1`),n||(r.setAttribute(`width`,`${e}px`),r.setAttribute(`height`,`${t}px`)),r.setAttribute(`preserveAspectRatio`,`none`),r.setAttribute(`viewBox`,`0 0 ${e} ${t}`),r}createElement(e){if(typeof e!=`string`)throw Error(`Invalid SVG element type`);return this._createSVG(e)}_createSVG(e){L("Abstract method `_createSVG` called.")}},yp=class extends vp{_createSVG(e){return document.createElementNS(xe,e)}},bp=9,xp=new WeakSet,Sp=new Date().getTimezoneOffset()*60*1e3,Cp=class{static create(e){switch(e.data.annotationType){case ke.LINK:return new Mp(e);case ke.TEXT:return new Ip(e);case ke.WIDGET:switch(e.data.fieldType){case`Tx`:return new Rp(e);case`Btn`:return e.data.radioButton?new Vp(e):e.data.checkBox?new Bp(e):new Hp(e);case`Ch`:return new Up(e);case`Sig`:return new zp(e)}return new Lp(e);case ke.POPUP:return new Gp(e);case ke.FREETEXT:return new Pm(e);case ke.LINE:return new Im(e);case ke.SQUARE:return new Rm(e);case ke.CIRCLE:return new Bm(e);case ke.POLYLINE:return new Hm(e);case ke.CARET:return new Wm(e);case ke.INK:return new Jm(e);case ke.POLYGON:return new Um(e);case ke.HIGHLIGHT:return new Xm(e);case ke.UNDERLINE:return new Zm(e);case ke.SQUIGGLY:return new Qm(e);case ke.STRIKEOUT:return new $m(e);case ke.STAMP:return new eh(e);case ke.FILEATTACHMENT:return new rh(e);case ke.RICHMEDIA:case ke.SCREEN:return new lh(e);default:return new Op(e)}}},wp=new WeakMap,Tp=new WeakMap,Ep=new WeakMap,Dp=new WeakSet,Op=class e{constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){S(this,Dp),b(this,wp,null),b(this,Tp,!1),b(this,Ep,null),this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableComment=e.enableComment,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,this.hasOwnCommentButton=!1,t&&(this.contentElement=this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:t}){return!!(e!=null&&e.str||t!=null&&t.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var e;let{data:t}=this,n=(e=this.annotationStorage)==null?void 0:e.getEditor(t.id);return n?n.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var e;let t=(e=this.annotationStorage)==null?void 0:e.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:n,inkLists:r,rect:i}=this.data,a=-1/0,o=-1/0;if((n==null?void 0:n.length)>=8){for(let e=0;e<n.length;e+=8)n[e+1]>o?(o=n[e+1],a=n[e+2]):n[e+1]===o&&(a=Math.max(a,n[e+2]));return[a,o]}if((r==null?void 0:r.length)>=1){for(let e of r)for(let t=0,n=e.length;t<n;t+=2)e[t+1]>o?(o=e[t+1],a=e[t]):e[t+1]===o&&(a=Math.max(a,e[t]));if(a!==1/0)return[a,o]}return i?[i[2],i[3]]:null}_normalizePoint(e){let{page:{view:t},viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}}=this.parent;return e[1]=t[3]-e[1]+t[1],e[0]=100*(e[0]-i)/n,e[1]=100*(e[1]-a)/r,e}get commentText(){var e,t;let{data:n}=this;return((e=this.annotationStorage.getRawValue(`${Te}${n.id}`))==null||(e=e.popup)==null?void 0:e.contents)||((t=n.contentsObj)==null?void 0:t.str)||``}set commentText(e){let{data:t}=this,n={deleted:!e,contents:e||``};this.annotationStorage.updateEditor(t.id,{popup:n})||this.annotationStorage.setValue(`${Te}${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:n,popupRef:t.popupRef,modificationDate:new Date}),e||this.removePopup()}removePopup(){var e,t;(e=((t=x(Ep,this))==null?void 0:t.popup)||this.popup)==null||e.remove(),C(Ep,this,this.popup=null)}updateEdited(e){var t;if(!this.container)return;e.rect&&(x(wp,this)||C(wp,this,{rect:this.data.rect.slice(0)}));let{rect:n,popup:r}=e;n&&f(Dp,this,kp).call(this,n);let i=((t=x(Ep,this))==null?void 0:t.popup)||this.popup;!i&&r!=null&&r.text&&(this._createPopup(r),i=x(Ep,this).popup),i&&(i.updateEdited(e),r!=null&&r.deleted&&(i.remove(),C(Ep,this,null),this.popup=null))}resetEdited(){var e;x(wp,this)&&(f(Dp,this,kp).call(this,x(wp,this).rect),(e=x(Ep,this))==null||e.popup.resetEdited(),C(wp,this,null))}_createContainer(e){let{data:t,parent:{page:n,viewport:r}}=this,i=document.createElement(`section`);i.setAttribute(`data-annotation-id`,t.id),!(this instanceof Lp)&&!(this instanceof Mp)&&!(this instanceof lh)&&(i.tabIndex=0);let{style:a}=i;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,t.alternativeText&&(i.title=t.alternativeText),t.noRotate&&i.classList.add(`norotate`),!t.rect||this instanceof Gp){let{rotation:e}=t;return!t.hasOwnCanvas&&e!==0&&this.setRotation(e,i),i}let{width:o,height:s}=this;if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;switch((e>0||n>0)&&(a.borderRadius=`calc(${e}px * var(--total-scale-factor)) / calc(${n}px * var(--total-scale-factor))`),t.borderStyle.style){case Ae.SOLID:a.borderStyle=`solid`;break;case Ae.DASHED:a.borderStyle=`dashed`;break;case Ae.BEVELED:I(`Unimplemented border style: beveled`);break;case Ae.INSET:I(`Unimplemented border style: inset`);break;case Ae.UNDERLINE:a.borderBottomStyle=`solid`;break;default:break}let r=t.borderColor||null;r?(C(Tp,this,!0),a.borderColor=B.makeHexColor(...r)):a.borderWidth=0}let c=B.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:l,pageHeight:u,pageX:d,pageY:f}=r.rawDims;a.left=`${100*(c[0]-d)/l}%`,a.top=`${100*(c[1]-f)/u}%`;let{rotation:p}=t;return t.hasOwnCanvas||p===0?(a.width=`${100*o/l}%`,a.height=`${100*s/u}%`):this.setRotation(p,i),i}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=this;e%180!=0&&([i,a]=[a,i]),t.style.width=`${100*i/n}%`,t.style.height=`${100*a/r}%`,t.setAttribute(`data-main-rotation`,(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let r=n.detail[e],i=r[0],a=r.slice(1);n.target.style[t]=_p[`${i}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[t]:_p[`${i}_rgb`](a)})};return R(this,`_commonActions`,{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:t===1||t===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e(`bgColor`,`backgroundColor`,t)},fillColor:t=>{e(`fillColor`,`backgroundColor`,t)},fgColor:t=>{e(`fgColor`,`color`,t)},textColor:t=>{e(`textColor`,`color`,t)},borderColor:t=>{e(`borderColor`,`borderColor`,t)},strokeColor:t=>{e(`strokeColor`,`borderColor`,t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let r of Object.keys(t.detail)){let i=e[r]||n[r];i==null||i(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[r,i]of Object.entries(t)){let a=n[r];a&&(a({detail:{[r]:i},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,n,r,i]=this.data.rect.map(e=>Math.fround(e));if(e.length===8){let[a,o,s,c]=e.subarray(2,6);if(r===a&&i===o&&t===s&&n===c)return}let{style:a}=this.container,o;if(x(Tp,this)){let{borderColor:e,borderWidth:t}=a;a.borderWidth=0,o=[`url('data:image/svg+xml;utf8,`,`<svg xmlns="${xe}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add(`hasBorder`)}let s=r-t,c=i-n,{svgFactory:l}=this,u=l.createElement(`svg`);u.classList.add(`quadrilateralsContainer`),u.setAttribute(`width`,0),u.setAttribute(`height`,0),u.role=`none`;let d=l.createElement(`defs`);u.append(d);let f=l.createElement(`clipPath`),p=`clippath_${this.data.id}`;f.setAttribute(`id`,p),f.setAttribute(`clipPathUnits`,`objectBoundingBox`),d.append(f);for(let n=2,r=e.length;n<r;n+=8){let r=e[n],a=e[n+1],u=e[n+2],d=e[n+3],p=l.createElement(`rect`),m=(u-t)/s,h=(i-a)/c,g=(r-u)/s,_=(a-d)/c;p.setAttribute(`x`,m),p.setAttribute(`y`,h),p.setAttribute(`width`,g),p.setAttribute(`height`,_),f.append(p),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${m}" y="${h}" width="${g}" height="${_}"/>`)}x(Tp,this)&&(o.push(`</g></svg>')`),a.backgroundImage=o.join(``)),this.container.append(u),this.container.style.clipPath=`url(#${p})`}_createPopup(e=null){let{data:t}=this,n,r;e?(n={str:e.text},r=e.date):(n=t.contentsObj,r=t.modificationDate),C(Ep,this,new Gp({data:{color:t.color,titleObj:t.titleObj,modificationDate:r,contentsObj:n,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(x(Ep,this)||this.popup||this.data.popupRef)}get extraPopupElement(){return x(Ep,this)}render(){L("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[e];if(r)for(let{page:e,id:i,exportValues:a}of r){if(e===-1||i===t)continue;let r=typeof a==`string`?a:null,o=document.querySelector(`[data-element-id="${i}"]`);if(o&&!xp.has(o)){I(`_getElementsByName - element not allowed: ${i}`);continue}n.push({id:i,exportValue:r,domElement:o})}return n}for(let r of document.getElementsByName(e)){let{exportValue:e}=r,i=r.getAttribute(`data-element-id`);i!==t&&xp.has(r)&&n.push({id:i,exportValue:e,domElement:r})}return n}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add(`highlightArea`);else e.classList.add(`highlightArea`)}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener(`dblclick`,()=>{var n;(n=this.linkService.eventBus)==null||n.dispatch(`switchannotationeditormode`,{source:this,mode:e,editId:t,mustEnterInEditMode:!0})})}updateOC(e){!this.data.oc||!e||(e.isVisible(this.data.oc)?this.show():this.hide())}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?`transparent`:B.makeHexColor(...t)}};function kp(e){let{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:s}}}}=this;n==null||n.splice(0,4,...e),t.left=`${100*(e[0]-o)/i}%`,t.top=`${100*(a-e[3]+s)/a}%`,r===0?(t.width=`${100*(e[2]-e[0])/i}%`,t.height=`${100*(e[3]-e[1])/a}%`):this.setRotation(r)}var Ap=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.editor=e.editor}render(){return this.container.className=`editorAnnotation`,this.container}createOrUpdatePopup(){let{editor:e}=this;e.hasComment&&this._createPopup(e.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e,e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}},jp=new WeakSet,Mp=class extends Op{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!(t!=null&&t.ignoreBorder),createQuadrilaterals:!0}),S(this,jp),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement(`a`);n.setAttribute(`data-element-id`,e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action,e.overlaidText),r=!0):e.attachment?(f(jp,this,Pp).call(this,n,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(f(jp,this,Fp).call(this,n,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(n,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions[`Mouse Up`]||e.actions[`Mouse Down`])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,``),r=!0)),this.container.classList.add(`linkAnnotation`),r&&(this.contentElement=n,this.container.append(n)),this.container}_bindLink(e,t,n=``){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t===``)&&f(jp,this,Np).call(this),n&&(e.title=n)}_bindNamedAction(e,t,n=``){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),n&&(e.title=n),f(jp,this,Np).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl(``);let n=new Map([[`Action`,`onclick`],[`Mouse Up`,`onmouseup`],[`Mouse Down`,`onmousedown`]]);for(let r of Object.keys(t.actions)){let i=n.get(r);i&&(e[i]=()=>{var e;return(e=this.linkService.eventBus)==null||e.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t.id,name:r}}),!1})}t.overlaidText&&(e.title=t.overlaidText),e.onclick||(e.onclick=()=>!1),f(jp,this,Np).call(this)}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl(``)),f(jp,this,Np).call(this),!this._fieldObjects){I('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{n==null||n();let{fields:e,refs:r,include:i}=t,a=[];if(e.length!==0||r.length!==0){let t=new Set(r);for(let n of e){let e=this._fieldObjects[n]||[];for(let{id:n}of e)t.add(n)}for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===i&&a.push(n)}else for(let e of Object.values(this._fieldObjects))a.push(...e);let o=this.annotationStorage,s=[];for(let e of a){let{id:t}=e;switch(s.push(t),e.type){case`text`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}case`checkbox`:case`radiobutton`:{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case`combobox`:case`listbox`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);if(n){if(!xp.has(n)){I(`_bindResetFormAction - element not allowed: ${t}`);continue}n.dispatchEvent(new Event(`resetform`))}}if(this.enableScripting){var c;(c=this.linkService.eventBus)==null||c.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:`app`,ids:s,name:`ResetForm`}})}return!1}}};function Np(){this.container.setAttribute(`data-internal-link`,``)}function Pp(e,t,n,r=``,i=null){var a=this;e.href=this.linkService.getAnchorUrl(``),n.description?e.title=n.description:r&&(e.title=r);let o=function(){var e=v(function*(){let e=yield a.linkService.getAttachmentContent(t);if(e){var r;(r=a.downloadManager)==null||r.openOrDownloadData(e,n.filename,i)}});return function(){return e.apply(this,arguments)}}();e.onclick=()=>(o(),!1),f(jp,this,Np).call(this)}function Fp(e,t,n=``){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),n&&(e.title=n),f(jp,this,Np).call(this)}var Ip=class extends Op{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add(`textAnnotation`);let e=document.createElement(`img`);return e.src=this.imageResourcesPath+`annotation-`+this.data.name.toLowerCase()+`.svg`,e.setAttribute(`data-l10n-id`,`pdfjs-text-annotation-type`),e.setAttribute(`data-l10n-args`,JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(e),this.container}},Lp=class extends Op{render(){return this.container}_getKeyModifier(e){return z.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,i){n.includes(`mouse`)?e.addEventListener(n,e=>{var t;(t=this.linkService.eventBus)==null||t.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{var a;if(n===`blur`){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if(n===`focus`){if(t.focused)return;t.focused=!0}i&&((a=this.linkService.eventBus)==null||a.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e)}}))})}_setEventListeners(e,t,n,r){for(let[s,c]of n){var i;if(c===`Action`||(i=this.data.actions)!=null&&i[c]){var a,o;(c===`Focus`||c===`Blur`)&&(t||(t={focused:!1})),this._setEventListener(e,t,s,c,r),c===`Focus`&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(e,t,`blur`,`Blur`,null):c===`Blur`&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(e,t,`focus`,`Focus`,null)}}}_setTextStyle(e){let t=[`left`,`center`,`right`],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||bp,i=e.style,a,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(be*r))||1);a=Math.min(r,o(t/be))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(r,o(e/be))}i.fontSize=`calc(${a}px * var(--total-scale-factor))`,i.color=B.makeHexColor(...n),this.data.textAlignment!==null&&!this.data.comb&&(i.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}},Rp=class extends Lp{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,n,r){let i=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),i.setValue(a.id,{[r]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add(`textWidgetAnnotation`);let n=null;if(this.renderForms){var r;let s=e.getValue(t,{value:this.data.fieldValue}),c=s.value||``,l=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;l&&c.length>l&&(c=c.slice(0,l));let u=s.formattedValue||((r=this.data.textContent)==null?void 0:r.join(`
|
|
45
|
+
`))||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,``));let d={userValue:c,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){var i;n=document.createElement(`textarea`),n.textContent=(i=u)==null?c:i,this.data.doNotScroll&&(n.style.overflowY=`hidden`)}else{var a;n=document.createElement(`input`),n.type=this.data.password?`password`:`text`,n.setAttribute(`value`,(a=u)==null?c:a),this.data.doNotScroll&&(n.style.overflowX=`hidden`)}this.data.hasOwnCanvas&&(this.container.classList.add(`hasOwnCanvas`),e.has(t)&&this.container.classList.add(`sandboxModified`)),xp.add(n),this.contentElement=n,n.setAttribute(`data-element-id`,t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0;let{datetimeFormat:f,datetimeType:p,timeStep:m}=this.data,h=!!p&&this.enableScripting;f&&(n.title=f),this._setRequired(n,this.data.required),l&&(n.maxLength=l),n.addEventListener(`input`,r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,`value`,r.target.value,`value`),d.formattedValue=null}),n.addEventListener(`resetform`,e=>{var t;let r=(t=this.data.defaultFieldValue)==null?``:t;n.value=d.userValue=r,d.formattedValue=null});let g=e=>{let{formattedValue:t}=d;t!=null&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){var o;n.addEventListener(`focus`,e=>{var t;if(d.focused)return;let{target:n}=e;if(h&&(n.type=p,m&&(n.step=m)),d.userValue){let e=d.userValue;if(h)if(p===`time`){let t=new Date(e);n.value=[t.getHours(),t.getMinutes(),t.getSeconds()].map(e=>e.toString().padStart(2,`0`)).join(`:`)}else n.value=new Date(e-Sp).toISOString().split(p===`date`?`T`:`.`,1)[0];else n.value=e}d.lastCommittedValue=n.value,d.commitKey=1,(t=this.data.actions)!=null&&t.Focus||(d.focused=!0)}),n.addEventListener(`updatefromsandbox`,n=>{this.container.classList.add(`sandboxModified`),this._dispatchEventFromSandbox({value(n){var r;d.userValue=(r=n.detail.value)==null?``:r,h||e.setValue(t,{value:d.userValue.toString()}),n.target.value=d.userValue},formattedValue(n){let{formattedValue:r}=n.detail;d.formattedValue=r,r!=null&&n.target!==document.activeElement&&(n.target.value=r);let i={formattedValue:r};h&&(i.value=r),e.setValue(t,i)},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{var r;let{charLimit:i}=n.detail,{target:a}=n;if(i===0){a.removeAttribute(`maxLength`);return}a.setAttribute(`maxLength`,i);let o=d.userValue;!o||o.length<=i||(o=o.slice(0,i),a.value=d.userValue=o,e.setValue(t,{value:o}),(r=this.linkService.eventBus)==null||r.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:o,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}},n)}),n.addEventListener(`keydown`,e=>{var n;d.commitKey=1;let r=-1;if(e.key===`Escape`?r=0:e.key===`Enter`&&!this.data.multiLine?r=2:e.key===`Tab`&&(d.commitKey=3),r===-1)return;let{value:i}=e.target;d.lastCommittedValue!==i&&(d.lastCommittedValue=i,d.userValue=i,(n=this.linkService.eventBus)==null||n.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:i,willCommit:!0,commitKey:r,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))});let r=g;g=null,n.addEventListener(`blur`,e=>{var n;if(!d.focused||!e.relatedTarget)return;(n=this.data.actions)!=null&&n.Blur||(d.focused=!1);let{target:i}=e,{value:a}=i;if(h){if(a&&p===`time`){let e=a.split(`:`).map(e=>parseInt(e,10));a=new Date(2e3,0,1,e[0],e[1],e[2]||0).valueOf(),i.step=``}else a.includes(`T`)||(a=`${a}T00:00`),a=new Date(a).valueOf();i.type=`text`}if(d.userValue=a,d.lastCommittedValue!==a){var o;(o=this.linkService.eventBus)==null||o.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,willCommit:!0,commitKey:d.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})}r(e)}),(o=this.data.actions)!=null&&o.Keystroke&&n.addEventListener(`beforeinput`,e=>{var n;d.lastCommittedValue=null;let{data:r,target:i}=e,{value:a,selectionStart:o,selectionEnd:s}=i,c=o,l=s;switch(e.inputType){case`deleteWordBackward`:{let e=a.substring(0,o).match(/\w*\W*$/);e&&(c-=e[0].length);break}case`deleteWordForward`:{let e=a.substring(o).match(/^\W*\w*/);e&&(l+=e[0].length);break}case`deleteContentBackward`:o===s&&--c;break;case`deleteContentForward`:o===s&&(l+=1);break}e.preventDefault(),(n=this.linkService.eventBus)==null||n.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,change:r||``,willCommit:!1,selStart:c,selEnd:l}})}),this._setEventListeners(n,d,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.value)}if(g&&n.addEventListener(`blur`,g),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/l;n.classList.add(`comb`),n.style.setProperty(`--comb-width`,`calc(${e}px * var(--total-scale-factor))`);let t=this.data.textAlignment;if(t===1||t===2){let e=()=>{let e=l-n.value.length;n.style.setProperty(`--comb-offset`,`${t===1?e>>1:e}`)};e();for(let t of[`input`,`blur`,`resetform`,`updatefromsandbox`])n.addEventListener(t,e)}}}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}},zp=class extends Lp{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}},Bp=class extends Lp{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;typeof r==`string`&&(r=r!==`Off`,e.setValue(n,{value:r})),this.container.classList.add(`buttonWidgetAnnotation`,`checkBox`);let i=document.createElement(`input`);return xp.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`checkbox`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.setAttribute(`exportValue`,t.exportValue),i.tabIndex=0,i.addEventListener(`change`,r=>{let{name:i,checked:a}=r.target;for(let r of this._getElementsByName(i,n)){let n=a&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:a})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue||`Off`;e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value(t){t.target.checked=t.detail.value!==`Off`,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},Vp=class extends Lp{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`buttonWidgetAnnotation`,`radioButton`);let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.buttonValue!==null&&t.fieldValue===t.buttonValue}).value;if(typeof r==`string`&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(let r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});let i=document.createElement(`input`);if(xp.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`radio`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.tabIndex=0,i.addEventListener(`change`,t=>{let{name:r,checked:i}=t.target;for(let t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:i})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue;e.target.checked=n!=null&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let r=t.buttonValue;i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value:t=>{let i=r===t.detail.value;for(let r of this._getElementsByName(t.target.name)){let t=i&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)}return this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},Hp=class extends Mp{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add(`buttonWidgetAnnotation`,`pushButton`);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener(`updatefromsandbox`,e=>{this._dispatchEventFromSandbox({},e)})),e}},Up=class extends Lp{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`choiceWidgetAnnotation`);let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement(`select`);xp.add(r),r.setAttribute(`data-element-id`,t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=0;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue;for(let e of r.options)e.selected=e.value===t});let a=(e,t)=>{let n=t.replaceAll(` `,`\xA0`);e.textContent=n,n!==t&&e.setAttribute(`display-value`,t)};for(let e of this.data.options){let t=document.createElement(`option`);a(t,e.displayValue),t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute(`selected`,!0),i=!1),r.append(t)}let o=null;if(i){let e=document.createElement(`option`);e.value=` `,e.setAttribute(`hidden`,!0),e.setAttribute(`selected`,!0),r.prepend(e),o=()=>{e.remove(),r.removeEventListener(`input`,o),o=null},r.addEventListener(`input`,o)}let s=e=>{let t=e?`value`:`textContent`,{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):n.selectedIndex===-1?null:n[n.selectedIndex][t]},c=s(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.getAttribute(`display-value`)||e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener(`updatefromsandbox`,n=>{this._dispatchEventFromSandbox({value(n){o==null||o();let i=n.detail.value,a=new Set(Array.isArray(i)?i:[i]);for(let e of r.options)e.selected=a.has(e.value);e.setValue(t,{value:s(!0)}),c=s(!1)},multipleSelection(e){r.multiple=!0},remove(n){let i=r.options,a=n.detail.remove;i[a].selected=!1,r.remove(a),i.length>0&&Array.prototype.findIndex.call(i,e=>e.selected)===-1&&(i[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},clear(n){for(;r.length!==0;)r.remove(0);e.setValue(t,{value:null,items:[]}),c=s(!1)},insert(n){let{index:i,displayValue:o,exportValue:u}=n.detail.insert,d=r.children[i],f=document.createElement(`option`);a(f,o),f.value=u,d?d.before(f):r.append(f),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},items(n){let{items:i}=n.detail;for(;r.length!==0;)r.remove(0);for(let e of i){let{displayValue:t,exportValue:n}=e,i=document.createElement(`option`);a(i,t),i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),c=s(!1)},indices(n){let r=new Set(n.detail.indices);for(let e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:s(!0)}),c=s(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),r.addEventListener(`input`,n=>{var r;let i=s(!0),a=s(!1);e.setValue(t,{value:i}),n.preventDefault(),(r=this.linkService.eventBus)==null||r.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:c,change:a,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`],[`input`,`Action`],[`input`,`Validate`]],e=>e.target.value)):r.addEventListener(`input`,function(n){e.setValue(t,{value:s(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},Wp=new WeakSet,Gp=class extends Op{constructor(e){let{data:t,elements:n,parent:r}=e,i=!!r._commentManager;if(super(e,{isRenderable:!i&&Op._hasPopupData(t)}),S(this,Wp),this.elements=n,i&&Op._hasPopupData(t)){let e=this.popup=f(Wp,this,Kp).call(this);for(let t of n)t.popup=e}else this.popup=null}render(){let{container:e}=this;e.classList.add(`popupAnnotation`),e.role=`comment`;let t=this.popup=f(Wp,this,Kp).call(this),n=[];for(let e of this.elements)e.popup=t,e.container.ariaHasPopup=`dialog`,n.push(e.data.id),e.addHighlightArea();return this.container.setAttribute(`aria-controls`,n.map(e=>`${we}${e}`).join(`,`)),this.container}};function Kp(){return new bm({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}var qp=new WeakMap,Jp=new WeakMap,Yp=new WeakMap,Xp=new WeakMap,Zp=new WeakMap,Qp=new WeakMap,$p=new WeakMap,em=new WeakMap,tm=new WeakMap,nm=new WeakMap,rm=new WeakMap,im=new WeakMap,am=new WeakMap,om=new WeakMap,sm=new WeakMap,cm=new WeakMap,lm=new WeakMap,um=new WeakMap,dm=new WeakMap,fm=new WeakMap,pm=new WeakMap,mm=new WeakMap,hm=new WeakMap,gm=new WeakMap,_m=new WeakMap,vm=new WeakMap,ym=new WeakSet,bm=class{constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:i,contentsObj:a,richText:o,parent:s,rect:c,parentRect:l,open:u,commentManager:d=null}){S(this,ym),b(this,qp,null),b(this,Jp,f(ym,this,km).bind(this)),b(this,Yp,f(ym,this,Nm).bind(this)),b(this,Xp,f(ym,this,Mm).bind(this)),b(this,Zp,f(ym,this,jm).bind(this)),b(this,Qp,null),b(this,$p,null),b(this,em,null),b(this,tm,null),b(this,nm,null),b(this,rm,null),b(this,im,null),b(this,am,!1),b(this,om,null),b(this,sm,null),b(this,cm,null),b(this,lm,null),b(this,um,null),b(this,dm,null),b(this,fm,null),b(this,pm,null),b(this,mm,null),b(this,hm,null),b(this,gm,!1),b(this,_m,null),b(this,vm,null),C($p,this,e),C(mm,this,r),C(em,this,a),C(pm,this,o),C(rm,this,s),C(Qp,this,t),C(fm,this,c),C(im,this,l),C(nm,this,n),C(qp,this,d),C(_m,this,n[0]),C(tm,this,Tt.toDateObject(i)),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup()),d||(f(ym,this,xm).call(this),x($p,this).hidden=!0,u&&f(ym,this,jm).call(this))}renderCommentButton(){if(x(lm,this)){x(lm,this).parentNode||x(_m,this).container.after(x(lm,this));return}if(x(um,this)||f(ym,this,Sm).call(this),!x(um,this))return;let{signal:e}=C(sm,this,new AbortController),t=x(_m,this).hasOwnCommentButton,n=()=>{x(qp,this).toggleCommentPopup(this,!0,void 0,!t)},r=()=>{x(qp,this).toggleCommentPopup(this,!1,!0,!t)},i=()=>{x(qp,this).toggleCommentPopup(this,!1,!1)};if(t){C(lm,this,x(_m,this).container);for(let t of this.trigger)t.ariaHasPopup=`dialog`,t.ariaControls=`commentPopup`,t.addEventListener(`keydown`,x(Jp,this),{signal:e}),t.addEventListener(`click`,n,{signal:e}),t.addEventListener(`pointerenter`,r,{signal:e}),t.addEventListener(`pointerleave`,i,{signal:e}),t.classList.add(`popupTriggerArea`)}else{let t=C(lm,this,document.createElement(`button`));t.className=`annotationCommentButton`;let a=x(_m,this).container;t.style.zIndex=parseInt(a.style.zIndex,10)+1,t.tabIndex=0,t.ariaHasPopup=`dialog`,t.ariaControls=`commentPopup`,t.setAttribute(`data-l10n-id`,`pdfjs-show-comment-button`),f(ym,this,wm).call(this),f(ym,this,Cm).call(this),t.addEventListener(`keydown`,x(Jp,this),{signal:e}),t.addEventListener(`click`,n,{signal:e}),t.addEventListener(`pointerenter`,r,{signal:e}),t.addEventListener(`pointerleave`,i,{signal:e}),a.after(t)}}get commentButtonColor(){let{color:e,opacity:t}=x(_m,this).commentData;return e?x(rm,this)._commentManager.makeCommentColor(e,t):null}focusCommentButton(){setTimeout(()=>{var e;(e=x(lm,this))==null||e.focus()},0)}getData(){let{richText:e,color:t,opacity:n,creationDate:r,modificationDate:i}=x(_m,this).commentData;return{contentsObj:{str:this.comment},richText:e,color:t,opacity:n,creationDate:r,modificationDate:i}}get elementBeforePopup(){return x(lm,this)}get comment(){return x(vm,this)||C(vm,this,x(_m,this).commentText),x(vm,this)}set comment(e){e!==this.comment&&(x(_m,this).commentText=C(vm,this,e))}focus(){var e;(e=x(_m,this).container)==null||e.focus()}get parentBoundingClientRect(){return x(_m,this).layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:t}){x(lm,this)&&(x(lm,this).classList.toggle(`selected`,e),x(lm,this).ariaExpanded=t)}setSelectedCommentButton(e){x(lm,this).classList.toggle(`selected`,e)}get commentPopupPosition(){if(x(dm,this))return x(dm,this);let{x:e,y:t,height:n}=x(lm,this).getBoundingClientRect(),{x:r,y:i,width:a,height:o}=x(_m,this).layer.getBoundingClientRect();return[(e-r)/a,(t+n-i)/o]}set commentPopupPosition(e){C(dm,this,e)}hasDefaultPopupPosition(){return x(dm,this)===null}get commentButtonPosition(){return x(um,this)}get commentButtonWidth(){return x(lm,this).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){let[t,n]=x(dm,this)||this.commentButtonPosition.map(e=>e/100),r=this.parentBoundingClientRect,{x:i,y:a,width:o,height:s}=r;x(qp,this).showDialog(null,this,i+t*o,a+n*s,T(T({},e),{},{parentDimensions:r}))}render(){var e,t;if(x(om,this))return;let n=C(om,this,document.createElement(`div`));if(n.className=`popup`,x(Qp,this)){let e=n.style.outlineColor=B.makeHexColor(...x(Qp,this));n.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let r=document.createElement(`span`);if(r.className=`header`,(e=x(mm,this))!=null&&e.str){let e=document.createElement(`span`);e.className=`title`,r.append(e),{dir:e.dir,str:e.textContent}=x(mm,this)}if(n.append(r),x(tm,this)){let e=document.createElement(`time`);e.className=`popupDate`,e.setAttribute(`data-l10n-id`,`pdfjs-annotation-date-time-string`),e.setAttribute(`data-l10n-args`,JSON.stringify({dateObj:x(tm,this).valueOf()})),e.dateTime=x(tm,this).toISOString(),r.append(e)}Wt({html:Tm.call(f(ym,this))||x(em,this).str,dir:(t=x(em,this))==null?void 0:t.dir,className:`popupContent`},n),x($p,this).append(n)}updateEdited({rect:e,popup:t,deleted:n}){var r;if(x(qp,this)){n?(this.remove(),C(vm,this,null)):t&&(t.deleted?this.remove():(f(ym,this,wm).call(this),C(vm,this,t.text))),e&&(C(um,this,null),f(ym,this,Sm).call(this),f(ym,this,Cm).call(this));return}if(n||t!=null&&t.deleted){this.remove();return}f(ym,this,xm).call(this),x(hm,this)||C(hm,this,{contentsObj:x(em,this),richText:x(pm,this)}),e&&C(cm,this,null),t&&t.text&&(C(pm,this,f(ym,this,Om).call(this,t.text)),C(tm,this,Tt.toDateObject(t.date)),C(em,this,null)),(r=x(om,this))==null||r.remove(),C(om,this,null)}resetEdited(){var e;x(hm,this)&&({contentsObj:O(C,[em,this])._,richText:O(C,[pm,this])._}=x(hm,this),C(hm,this,null),(e=x(om,this))==null||e.remove(),C(om,this,null),C(cm,this,null))}remove(){var e,t,n;if((e=x(sm,this))==null||e.abort(),C(sm,this,null),(t=x(om,this))==null||t.remove(),C(om,this,null),C(gm,this,!1),C(am,this,!1),(n=x(lm,this))==null||n.remove(),C(lm,this,null),this.trigger)for(let e of this.trigger)e.classList.remove(`popupTriggerArea`)}forceHide(){C(gm,this,this.isVisible),x(gm,this)&&(x($p,this).hidden=!0)}maybeShow(){x(qp,this)||(f(ym,this,xm).call(this),x(gm,this)&&(x(om,this)||f(ym,this,Mm).call(this),C(gm,this,!1),x($p,this).hidden=!1))}get isVisible(){return!x(qp,this)&&x($p,this).hidden===!1}};function xm(){if(x(sm,this))return;C(sm,this,new AbortController);let{signal:e}=x(sm,this);for(let t of this.trigger)t.addEventListener(`click`,x(Zp,this),{signal:e}),t.addEventListener(`pointerenter`,x(Xp,this),{signal:e}),t.addEventListener(`pointerleave`,x(Yp,this),{signal:e}),t.classList.add(`popupTriggerArea`);for(let n of x(nm,this)){var t;(t=n.container)==null||t.addEventListener(`keydown`,x(Jp,this),{signal:e})}}function Sm(){let e=x(nm,this).find(e=>e.hasCommentButton);e&&C(um,this,e._normalizePoint(e.commentButtonPosition))}function Cm(){if(x(_m,this).extraPopupElement&&!x(_m,this).editor)return;x(lm,this)||this.renderCommentButton();let[e,t]=x(um,this),{style:n}=x(lm,this);n.left=`calc(${e}%)`,n.top=`calc(${t}% - var(--comment-button-dim))`}function wm(){x(_m,this).extraPopupElement||(x(lm,this)||this.renderCommentButton(),x(lm,this).style.backgroundColor=this.commentButtonColor||``)}function Tm(){let e=x(pm,this),t=x(em,this);return e!=null&&e.str&&(!(t!=null&&t.str)||t.str===e.str)&&x(pm,this).html||null}function Em(){var e;return((e=Tm.call(f(ym,this)))==null||(e=e.attributes)==null||(e=e.style)==null?void 0:e.fontSize)||0}function Dm(){var e;return((e=Tm.call(f(ym,this)))==null||(e=e.attributes)==null||(e=e.style)==null?void 0:e.color)||null}function Om(e){let t=[],n={str:e,html:{name:`div`,attributes:{dir:`auto`},children:[{name:`p`,children:t}]}},r={style:{color:Dm.call(f(ym,this)),fontSize:Em.call(f(ym,this))?`calc(${Em.call(f(ym,this))}px * var(--total-scale-factor))`:``}};for(let n of e.split(`
|
|
46
|
+
`))t.push({name:`span`,value:n,attributes:r});return n}function km(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key===`Enter`||e.key===`Escape`&&x(am,this))&&f(ym,this,jm).call(this)}function Am(){if(x(cm,this)!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:i}}}=x(rm,this),a=!!x(im,this),o=x(a?im:fm,this);for(let e of x(nm,this))if(!o||B.intersect(e.data.rect,o)!==null){o=e.data.rect,a=!0;break}let s=B.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),c=a?o[2]-o[0]+5:0,l=s[0]+c,u=s[1];C(cm,this,[100*(l-r)/t,100*(u-i)/n]);let{style:d}=x($p,this);d.left=`${x(cm,this)[0]}%`,d.top=`${x(cm,this)[1]}%`}function jm(){if(x(qp,this)){x(qp,this).toggleCommentPopup(this,!1);return}C(am,this,!x(am,this)),x(am,this)?(f(ym,this,Mm).call(this),x($p,this).addEventListener(`click`,x(Zp,this)),x($p,this).addEventListener(`keydown`,x(Jp,this))):(f(ym,this,Nm).call(this),x($p,this).removeEventListener(`click`,x(Zp,this)),x($p,this).removeEventListener(`keydown`,x(Jp,this)))}function Mm(){x(om,this)||this.render(),this.isVisible?x(am,this)&&x($p,this).classList.add(`focused`):(f(ym,this,Am).call(this),x($p,this).hidden=!1,x($p,this).style.zIndex=parseInt(x($p,this).style.zIndex,10)+1e3)}function Nm(){x($p,this).classList.remove(`focused`),!(x(am,this)||!this.isVisible)&&(x($p,this).hidden=!0,x($p,this).style.zIndex=parseInt(x($p,this).style.zIndex,10)-1e3)}var Pm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=N.FREETEXT}render(){if(this.container.classList.add(`freeTextAnnotation`),this.textContent){let e=this.contentElement=document.createElement(`div`);e.classList.add(`annotationTextContent`),e.setAttribute(`role`,`comment`);for(let t of this.textContent){let n=document.createElement(`span`);n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}},Fm=new WeakMap,Im=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,Fm,null)}render(){this.container.classList.add(`lineAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=C(Fm,this,this.svgFactory.createElement(`svg:line`));return i.setAttribute(`x1`,e.rect[2]-e.lineCoordinates[0]),i.setAttribute(`y1`,e.rect[3]-e.lineCoordinates[1]),i.setAttribute(`x2`,e.rect[2]-e.lineCoordinates[2]),i.setAttribute(`y2`,e.rect[3]-e.lineCoordinates[3]),i.setAttribute(`stroke-width`,e.borderStyle.width||1),i.setAttribute(`stroke`,`transparent`),i.setAttribute(`fill`,`transparent`),r.append(i),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(Fm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Lm=new WeakMap,Rm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,Lm,null)}render(){this.container.classList.add(`squareAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=C(Lm,this,this.svgFactory.createElement(`svg:rect`));return a.setAttribute(`x`,i/2),a.setAttribute(`y`,i/2),a.setAttribute(`width`,t-i),a.setAttribute(`height`,n-i),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(Lm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},zm=new WeakMap,Bm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,zm,null)}render(){this.container.classList.add(`circleAnnotation`);let{data:e,width:t,height:n}=this,r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=C(zm,this,this.svgFactory.createElement(`svg:ellipse`));return a.setAttribute(`cx`,t/2),a.setAttribute(`cy`,n/2),a.setAttribute(`rx`,t/2-i/2),a.setAttribute(`ry`,n/2-i/2),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(zm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Vm=new WeakMap,Hm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),b(this,Vm,null),this.containerClassName=`polylineAnnotation`,this.svgElementName=`svg:polyline`}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:n,popupRef:r},width:i,height:a}=this;if(!t)return this.container;let o=this.svgFactory.create(i,a,!0),s=[];for(let n=0,r=t.length;n<r;n+=2){let r=t[n]-e[0],i=e[3]-t[n+1];s.push(`${r},${i}`)}s=s.join(` `);let c=C(Vm,this,this.svgFactory.createElement(this.svgElementName));return c.setAttribute(`points`,s),c.setAttribute(`stroke-width`,n.width||1),c.setAttribute(`stroke`,`transparent`),c.setAttribute(`fill`,`transparent`),o.append(c),this.container.append(o),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return x(Vm,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Um=class extends Hm{constructor(e){super(e),this.containerClassName=`polygonAnnotation`,this.svgElementName=`svg:polygon`}},Wm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add(`caretAnnotation`),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}},Gm=new WeakMap,Km=new WeakMap,qm=new WeakSet,Jm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),S(this,qm),b(this,Gm,null),b(this,Km,[]),this.containerClassName=`inkAnnotation`,this.svgElementName=`svg:polyline`,this.annotationEditorType=this.data.it===`InkHighlight`?N.HIGHLIGHT:N.INK}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,rotation:t,inkLists:n,borderStyle:r,popupRef:i}}=this,{transform:a,width:o,height:s}=f(qm,this,Ym).call(this,t,e),c=this.svgFactory.create(o,s,!0),l=C(Gm,this,this.svgFactory.createElement(`svg:g`));c.append(l),l.setAttribute(`stroke-width`,r.width||1),l.setAttribute(`stroke-linecap`,`round`),l.setAttribute(`stroke-linejoin`,`round`),l.setAttribute(`stroke-miterlimit`,10),l.setAttribute(`stroke`,`transparent`),l.setAttribute(`fill`,`transparent`),l.setAttribute(`transform`,a);for(let e=0,t=n.length;e<t;e++){let t=this.svgFactory.createElement(this.svgElementName);x(Km,this).push(t),t.setAttribute(`points`,n[e].join(`,`)),l.append(t)}return!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:n,rect:r}=e,i=x(Gm,this);if(t>=0&&i.setAttribute(`stroke-width`,t||1),n)for(let e=0,t=x(Km,this).length;e<t;e++)x(Km,this)[e].setAttribute(`points`,n[e].join(`,`));if(r){let{transform:e,width:t,height:n}=f(qm,this,Ym).call(this,this.data.rotation,r);i.parentElement.setAttribute(`viewBox`,`0 0 ${t} ${n}`),i.setAttribute(`transform`,e)}}getElementsToTriggerPopup(){return x(Km,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}};function Ym(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}var Xm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=N.HIGHLIGHT}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`highlightAnnotation`),this._editOnDoubleClick(),e){let t=document.createElement(`mark`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},Zm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`underlineAnnotation`),e){let t=document.createElement(`u`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},Qm=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`squigglyAnnotation`),e){let t=document.createElement(`u`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},$m=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add(`strikeoutAnnotation`),e){let t=document.createElement(`s`);t.classList.add(`overlaidText`),t.textContent=e,this.container.append(t)}return this.container}},eh=class extends Op{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=N.STAMP}render(){return this.container.classList.add(`stampAnnotation`),this.container.setAttribute(`role`,`img`),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}},th=new WeakMap,nh=new WeakSet,rh=class extends Op{constructor(e){var t;super(e,{isRenderable:!0}),S(this,nh),b(this,th,null);let{fileId:n,file:r}=this.data;this.filename=r.filename,this.content=r.content,this.fileId=n,(t=this.linkService.eventBus)==null||t.dispatch(`fileattachmentannotation`,T({source:this,attachmentId:this.fileId},r))}render(){this.container.classList.add(`fileAttachmentAnnotation`);let{container:e,data:t}=this,n;t.hasAppearance||t.fillAlpha===0?n=document.createElement(`div`):(n=document.createElement(`img`),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?`paperclip`:`pushpin`}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`)),n.addEventListener(`dblclick`,f(nh,this,ih).bind(this)),C(th,this,n);let{isMac:r}=z.platform;return e.addEventListener(`keydown`,e=>{e.key===`Enter`&&(r?e.metaKey:e.ctrlKey)&&f(nh,this,ih).call(this)}),!t.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):n.classList.add(`popupTriggerArea`),e.append(n),e}getElementsToTriggerPopup(){return x(th,this)}addHighlightArea(){this.container.classList.add(`highlightArea`)}};function ih(){var e=this;return v(function*(){let{fileId:t,filename:n,content:r}=e,i=(yield e.linkService.getAttachmentContent(t))||r;if(i){var a;(a=e.downloadManager)==null||a.openOrDownloadData(i,n)}})()}var ah=new WeakMap,oh=new WeakMap,sh=new WeakMap,ch=new WeakSet,lh=class extends Op{constructor(e){super(e,{isRenderable:!!e.data.richMedia}),S(this,ch),b(this,ah,new AbortController),b(this,oh,null),b(this,sh,null)}render(){this.container.classList.add(`mediaAnnotation`);let{filename:e}=this.data.richMedia,t=document.createElement(`button`);return t.className=`mediaPlayButton`,t.type=`button`,t.title=t.ariaLabel=e,t.addEventListener(`click`,()=>f(ch,this,uh).call(this,t),{signal:x(ah,this).signal}),this.container.append(t),this.container}destroy(){x(ah,this).abort(),x(sh,this)&&(x(sh,this).pause(),x(sh,this).removeAttribute(`src`),x(sh,this).load(),C(sh,this,null)),f(ch,this,dh).call(this)}};function uh(e){var t=this;return v(function*(){let{fileId:n,filename:r,contentType:i}=t.data.richMedia;e.disabled=!0;let a;try{a=yield t.linkService.getAttachmentContent(n)}catch(e){return}finally{e.disabled=!1}if(!a||!e.isConnected)return;let{signal:o}=x(ah,t),s=URL.createObjectURL(new Blob([a],{type:i}));C(oh,t,s);let c=i.startsWith(`audio/`),l=document.createElement(c?`audio`:`video`);if(C(sh,t,l),l.className=`mediaContent`,t._setBackgroundColor(l),l.src=s,l.title=r,l.controls=!0,l.autoplay=!0,l.tabIndex=0,c){let e=!1,n=!1,r=()=>{l.controls=e||n};t.container.addEventListener(`pointerenter`,()=>{e=!0,r()},{signal:o}),t.container.addEventListener(`pointerleave`,()=>{e=!1,r()},{signal:o}),t.container.addEventListener(`focusin`,()=>{n=!0,r()},{signal:o}),t.container.addEventListener(`focusout`,()=>{n=!1,r()},{signal:o})}l.addEventListener(`emptied`,()=>f(ch,t,dh).call(t,s),{once:!0,signal:o}),e.replaceWith(l),l.play().catch(()=>{})})()}function dh(e=x(oh,this)){e&&e===x(oh,this)&&(URL.revokeObjectURL(e),C(oh,this,null))}var fh=new WeakMap,ph=new WeakMap,mh=new WeakMap,hh=new WeakMap,gh=new WeakMap,_h=new WeakMap,vh=new WeakMap,yh=new WeakMap,bh=new WeakSet,xh=class e{constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:a,structTreeLayer:o,commentManager:s,linkService:c,annotationStorage:l}){S(this,bh),b(this,fh,null),b(this,ph,null),b(this,mh,null),b(this,hh,new Map),b(this,gh,null),b(this,_h,null),b(this,vh,[]),b(this,yh,!1),g(this,`zIndex`,0),this.div=e,C(fh,this,t),C(ph,this,n),C(gh,this,o||null),C(_h,this,c||null),C(mh,this,l||new eo),this.page=i,this.viewport=a,this._annotationEditorUIManager=r,this._commentManager=s||null}hasEditableAnnotations(){return x(hh,this).size>0}render(e){var t=this;return v(function*(){let{annotations:n,optionalContentConfig:r}=e,i=t.div;Mt(i,t.viewport);let a=new Map,o=[],s={data:null,layer:i,linkService:x(_h,t),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||``,renderForms:e.renderForms!==!1,svgFactory:new yp,annotationStorage:x(mh,t),enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:t,elements:null};for(let e of n){if(e.noHTML)continue;let n=e.annotationType===ke.POPUP;if(n){let n=a.get(e.id);if(!n)continue;if(!t._commentManager){o.push(e);continue}s.elements=n}else if(e.rect[2]===e.rect[0]||e.rect[3]===e.rect[1])continue;s.data=e;let i=Cp.create(s);if(!i.isRenderable)continue;n||(x(vh,t).push(i),e.popupRef&&a.getOrInsertComputed(e.popupRef,ot).push(i));let l=i.render();if(e.hidden&&(l.style.visibility=`hidden`),i.updateOC(r),i._isEditable){var c;x(hh,t).set(i.data.id,i),(c=t._annotationEditorUIManager)==null||c.renderAnnotationElement(i)}}yield f(bh,t,Sh).call(t);for(let e of o){let t=s.elements=a.get(e.id);s.data=e;let n=Cp.create(s);if(!n.isRenderable)continue;let r=n.render();n.contentElement.id=`${we}${e.id}`,e.hidden&&(r.style.visibility=`hidden`),t.at(-1).container.after(r)}f(bh,t,Ch).call(t)})()}addLinkAnnotations(t){var n=this;return v(function*(){let r={data:null,layer:n.div,linkService:x(_h,n),svgFactory:new yp,parent:n};for(let i of t){i.borderStyle||(i.borderStyle=e._defaultBorderStyle),r.data=i;let t=Cp.create(r);t.isRenderable&&(t.render(),t.contentElement.id=`${we}${i.id}`,x(vh,n).push(t))}yield f(bh,n,Sh).call(n)})()}update({viewport:e,optionalContentConfig:t}){let n=this.div;this.viewport=e,Mt(n,{rotation:e.rotation});for(let e of x(vh,this))e.updateOC(t);f(bh,this,Ch).call(this),n.hidden=!1}destroy(){for(let n of x(vh,this)){var e,t;(e=n.destroy)==null||e.call(n),(t=x(fh,this))==null||t.removePointerInTextLayer(n.contentElement)}x(vh,this).length=0,x(hh,this).clear(),this.div.replaceChildren()}refreshCanvases(){f(bh,this,Ch).call(this)}getEditableAnnotations(){return x(hh,this).values()}getEditableAnnotation(e){return x(hh,this).get(e)}addFakeAnnotation(e){let{div:t}=this,{id:n,rotation:r}=e,i=new Ap({data:{id:n,rect:e.getPDFRect(),rotation:r},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:x(_h,this),annotationStorage:x(mh,this)});return i.render(),i.contentElement.id=`${we}${n}`,i.createOrUpdatePopup(),x(vh,this).push(i),i}removeAnnotation(e){var t;let n=x(vh,this).findIndex(t=>t.data.id===e);if(n<0)return;let[r]=x(vh,this).splice(n,1);(t=x(fh,this))==null||t.removePointerInTextLayer(r.contentElement)}updateFakeAnnotations(e){if(e.length!==0){for(let t of e)t.updateFakeAnnotationElement(this);f(bh,this,Sh).call(this)}}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}static get _defaultBorderStyle(){return R(this,`_defaultBorderStyle`,Object.freeze({width:1,rawWidth:1,style:Ae.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};function Sh(){var e=this;return v(function*(){if(x(vh,e).length===0)return;e.div.replaceChildren();let t=[];if(!x(yh,e)){C(yh,e,!0);for(let{contentElement:r,data:{id:i}}of x(vh,e)){var n;let a=r.id=`${we}${i}`;t.push((n=x(gh,e))==null?void 0:n.getAriaAttributes(a).then(e=>{if(e)for(let[t,n]of e)r.setAttribute(t,n)}))}}x(vh,e).sort(({data:{rect:[e,t,n,r]}},{data:{rect:[i,a,o,s]}})=>{if(e===n&&t===r)return 1;if(i===o&&a===s)return-1;let c=r,l=t,u=(t+r)/2,d=s,f=a,p=(a+s)/2;return u>=d&&p<=l?-1:p>=c&&u<=f?1:(e+n)/2-(i+o)/2});let r=document.createDocumentFragment();for(let t of x(vh,e))if(r.append(t.container),e._commentManager){var i,a;(i=((a=t.extraPopupElement)==null?void 0:a.popup)||t.popup)==null||i.renderCommentButton()}else t.extraPopupElement&&r.append(t.extraPopupElement.render());if(e.div.append(r),yield Promise.all(t),x(fh,e))for(let t of x(vh,e))x(fh,e).addPointerInTextLayer(t.contentElement,!1)})()}function Ch(){if(!x(ph,this))return;let e=this.div;for(let[n,r]of x(ph,this)){let i=e.querySelector(`[data-annotation-id="${n}"]`);if(!i)continue;if(Array.isArray(r))for(let e of r)e.className=`annotationContent`,e.ariaHidden=!0;else r.className=`annotationContent`,r.ariaHidden=!0;let a=[];for(let e of i.children)e.nodeName===`CANVAS`&&a.push(e);for(let e of a)e.remove();let o=Array.isArray(r)?r[0]:r,{firstChild:s}=i;if(s?s.classList.contains(`annotationContent`)?s.after(o):s.before(o):i.append(o),Array.isArray(r)){let e=o;for(let t=1,n=r.length;t<n;t++)e.after(r[t]),e=r[t]}x(ph,this).delete(n);let c=x(hh,this).get(n);if(c)if(c._hasNoCanvas){var t;(t=this._annotationEditorUIManager)==null||t.setMissingCanvas(n,i.id,r),c._hasNoCanvas=!1}else c.canvas=r}}var wh=/\r\n?|\n/g,Th=new WeakMap,Eh=new WeakMap,Dh=new WeakMap,Oh=new WeakMap,kh=new WeakSet,Ah=class e extends G{static get _keyboardManager(){let t=e.prototype,n=e=>e.isEmpty(),r=Lr.TRANSLATE_SMALL,i=Lr.TRANSLATE_BIG;return R(this,`_keyboardManager`,new Ln([[[`ctrl+s`,`mac+meta+s`,`ctrl+p`,`mac+meta+p`],t.commitOrRemove,{bubbles:!0}],[[`ctrl+Enter`,`mac+meta+Enter`],t.commitOrRemove],[[`Escape`],t.commitOrRemove],[[`ArrowLeft`],t._translateEmpty,{args:[-r,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t._translateEmpty,{args:[-i,0],checker:n}],[[`ArrowRight`],t._translateEmpty,{args:[r,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t._translateEmpty,{args:[i,0],checker:n}],[[`ArrowUp`],t._translateEmpty,{args:[0,-r],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t._translateEmpty,{args:[0,-i],checker:n}],[[`ArrowDown`],t._translateEmpty,{args:[0,r],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t._translateEmpty,{args:[0,i],checker:n}]]))}constructor(t){super(T(T({},t),{},{name:`freeTextEditor`})),S(this,kh),b(this,Th,``),b(this,Eh,`${this.id}-editor`),b(this,Dh,null),b(this,Oh,void 0),g(this,`_colorPicker`,null),this.color=t.color||e._defaultColor||G._defaultLineColor,C(Oh,this,t.fontSize||e._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(G._l10nAlert.freetext),this.canAddComment=!1}static initialize(e,t){G.initialize(e,t);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue(`--freetext-padding`))}static updateDefaultParams(t,n){switch(t){case P.FREETEXT_SIZE:e._defaultFontSize=n;break;case P.FREETEXT_COLOR:e._defaultColor=n;break}}updateParams(e,t){switch(e){case P.FREETEXT_SIZE:f(kh,this,jh).call(this,t);break;case P.FREETEXT_COLOR:f(kh,this,Mh).call(this,t);break}}static get defaultPropertiesToUpdate(){return[[P.FREETEXT_SIZE,e._defaultFontSize],[P.FREETEXT_COLOR,e._defaultColor||G._defaultLineColor]]}get propertiesToUpdate(){return[[P.FREETEXT_SIZE,x(Oh,this)],[P.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new pp(this)),[[`colorPicker`,this._colorPicker]]}get colorType(){return P.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let t=this.parentScale;return[-e._internalPadding*t,-(e._internalPadding+x(Oh,this))*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove(`enabled`),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute(`aria-activedescendant`),C(Dh,this,new AbortController);let e=this._uiManager.combinedSignal(x(Dh,this));return this.editorDiv.addEventListener(`keydown`,this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener(`focus`,this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener(`blur`,this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener(`input`,this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener(`paste`,this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add(`enabled`),this.editorDiv.contentEditable=!1,this.div.setAttribute(`aria-activedescendant`,x(Eh,this)),this._isDraggable=!0,(e=x(Dh,this))==null||e.abort(),C(Dh,this,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add(`freetextEditing`),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var t;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(t=this._initialOptions)!=null&&t.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()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=x(Th,this),t=C(Th,this,f(kh,this,Nh).call(this).trimEnd());if(e===t)return;let n=e=>{if(C(Th,this,e),!e){this.remove();return}f(kh,this,Ih).call(this),this._uiManager.rebuild(this),f(kh,this,Ph).call(this)};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),f(kh,this,Ph).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key===`Enter`&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(t){e._keyboardManager.exec(this,t)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,t;(this._isCopy||this.annotationElementId)&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement(`div`),this.editorDiv.className=`internal`,this.editorDiv.setAttribute(`id`,x(Eh,this)),this.editorDiv.setAttribute(`data-l10n-id`,`pdfjs-free-text2`),this.editorDiv.setAttribute(`data-l10n-attrs`,`default-content`),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${x(Oh,this)}px * var(--total-scale-factor))`,n.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement(`div`),this.overlayDiv.classList.add(`overlay`,`enabled`),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[n,r]=this.parentDimensions;if(this.annotationElementId){let{position:i}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[s,c]=this.pageDimensions,[l,u]=this.pageTranslation,d,f;switch(this.rotation){case 0:d=e+(i[0]-l)/s,f=t+this.height-(i[1]-u)/c;break;case 90:d=e+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[o,-a];break;case 180:d=e-this.width+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[-a,-o];break;case 270:d=e+(i[0]-l-this.height*c)/s,f=t+(i[1]-u-this.width*s)/c,[a,o]=[-o,a];break}this.setAt(d*n,f*r,a,o)}else this._moveAfterPaste(e,t);f(kh,this,Ih).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){let n=t.clipboardData||window.clipboardData,{types:r}=n;if(r.length===1&&r[0]===`text/plain`)return;t.preventDefault();let i=Rh.call(e,n.getData(`text`)||``).replaceAll(wh,`
|
|
47
47
|
`);if(!i)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let o=a.getRangeAt(0);if(!i.includes(`
|
|
48
48
|
`)){o.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:s,startOffset:c}=o,l=[],u=[];if(s.nodeType===Node.TEXT_NODE){let t=s.parentElement;if(u.push(s.nodeValue.slice(c).replaceAll(wh,``)),t!==this.editorDiv){let n=l;for(let r of this.editorDiv.childNodes){if(r===t){n=u;continue}n.push(Fh.call(e,r))}}l.push(s.nodeValue.slice(0,c).replaceAll(wh,``))}else if(s===this.editorDiv){let t=l,n=0;for(let r of this.editorDiv.childNodes)n++===c&&(t=u),t.push(Fh.call(e,r))}C(Th,this,`${l.join(`
|
|
49
49
|
`)}${i}${u.join(`
|
|
50
|
-
`)}`),f(kh,this,Ih).call(this);let d=new Range,p=Math.sumPrecise(l.map(e=>e.length));for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(p<=t){d.setStart(e,p),d.setEnd(e,p);break}p-=t}a.removeAllRanges(),a.addRange(d)}get contentDiv(){return this.editorDiv}getPDFRect(){let t=e._internalPadding*this.parentScale;return this.getRect(t,t)}static deserialize(t,n,r){var i=()=>super.deserialize,a=this;return v(function*(){let o=null;if(t instanceof Pm){let{data:{defaultAppearanceData:{fontSize:e,fontColor:n},rect:r,rotation:i,id:a,popupRef:s,richText:c,contentsObj:l,creationDate:u,modificationDate:d},textContent:f,textPosition:p,parent:{page:{pageNumber:m}}}=t;if(!(f!=null&&f.length))return null;o=t={annotationType:
|
|
51
|
-
`),position:p,pageIndex:m-1,rect:r.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:s,comment:(l==null?void 0:l.str)||null,richText:c,creationDate:u,modificationDate:d}}let s=yield i().call(a,t,n,r);return C(Oh,s,t.fontSize),s.color=
|
|
52
|
-
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`)),t.append(n)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:x(Th,this)}}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};
|
|
50
|
+
`)}`),f(kh,this,Ih).call(this);let d=new Range,p=Math.sumPrecise(l.map(e=>e.length));for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(p<=t){d.setStart(e,p),d.setEnd(e,p);break}p-=t}a.removeAllRanges(),a.addRange(d)}get contentDiv(){return this.editorDiv}getPDFRect(){let t=e._internalPadding*this.parentScale;return this.getRect(t,t)}static deserialize(t,n,r){var i=()=>super.deserialize,a=this;return v(function*(){let o=null;if(t instanceof Pm){let{data:{defaultAppearanceData:{fontSize:e,fontColor:n},rect:r,rotation:i,id:a,popupRef:s,richText:c,contentsObj:l,creationDate:u,modificationDate:d},textContent:f,textPosition:p,parent:{page:{pageNumber:m}}}=t;if(!(f!=null&&f.length))return null;o=t={annotationType:N.FREETEXT,color:Array.from(n),fontSize:e,value:f.join(`
|
|
51
|
+
`),position:p,pageIndex:m-1,rect:r.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:s,comment:(l==null?void 0:l.str)||null,richText:c,creationDate:u,modificationDate:d}}let s=yield i().call(a,t,n,r);return C(Oh,s,t.fontSize),s.color=B.makeHexColor(...t.color),C(Th,s,Rh.call(e,t.value)),s._initialData=o,t.comment&&s.setCommentData(t),s})()}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let t=G._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:t,fontSize:x(Oh,this),value:f(kh,this,Lh).call(this)});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!f(kh,this,zh).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(!t)return null;let{style:n}=t;n.fontSize=`calc(${x(Oh,this)}px * var(--total-scale-factor))`,n.color=this.color,t.replaceChildren();for(let e of x(Th,this).split(`
|
|
52
|
+
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`)),t.append(n)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:x(Th,this)}}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};se=Ah;function jh(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--total-scale-factor))`,this.translate(0,-(e-x(Oh,this))*this.parentScale),C(Oh,this,e),f(kh,this,Ph).call(this)},n=x(Oh,this);this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}function Mh(e){let t=e=>{this.color=e,this.onUpdatedColor()},n=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}function Nh(){let e=[];this.editorDiv.normalize();let t=null;for(let n of this.editorDiv.childNodes)(t==null?void 0:t.nodeType)===Node.TEXT_NODE&&n.nodeName===`BR`||(e.push(Fh.call(se,n)),t=n);return e.join(`
|
|
53
53
|
`)}function Ph(){let[e,t]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:e,div:t}=this,r=t.style.display,i=t.classList.contains(`hidden`);t.classList.remove(`hidden`),t.style.display=`hidden`,e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=r,t.classList.toggle(`hidden`,i)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}function Fh(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(wh,``)}function Ih(){if(this.editorDiv.replaceChildren(),x(Th,this))for(let e of x(Th,this).split(`
|
|
54
|
-
`)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`)),this.editorDiv.append(t)}}function Lh(){return x(Th,this).replaceAll(`\xA0`,` `)}function Rh(e){return e.replaceAll(` `,`\xA0`)}function zh(e){let{value:t,fontSize:n,color:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==r[t])||e.pageIndex!==i}g(Ah,`_freeTextDefaultContent`,``),g(Ah,`_internalPadding`,0),g(Ah,`_defaultColor`,null),g(Ah,`_defaultFontSize`,10),g(Ah,`_type`,`freetext`),g(Ah,`_editorType`,M.FREETEXT);var X=class{toSVGPath(){I("Abstract method `toSVGPath` must be implemented.")}get box(){I("Abstract getter `box` must be implemented.")}serialize(e,t){I("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||(a=new Float32Array(e.length));for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o]*r,a[o+1]=n+e[o+1]*i;return a}static _rescaleAndSwap(e,t,n,r,i,a){a||(a=new Float32Array(e.length));for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o+1]*r,a[o+1]=n+e[o]*i;return a}static _translate(e,t,n,r){r||(r=new Float32Array(e.length));for(let i=0,a=e.length;i<a;i+=2)r[i]=t+e[i],r[i+1]=n+e[i+1];return r}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}};g(X,`PRECISION`,1e-4);var Bh=new WeakMap,Vh=new WeakMap,Hh=new WeakMap,Uh=new WeakMap,Wh=new WeakMap,Z=new WeakMap,Gh=new WeakMap,Kh=new WeakMap,qh=new WeakMap,Jh=new WeakMap,Yh=new WeakMap,Xh=new WeakMap,Zh=new WeakMap,Qh=new WeakSet,$h=class{constructor({x:e,y:t},n,r,i,a,o=0){S(this,Qh),b(this,Bh,void 0),b(this,Vh,[]),b(this,Hh,void 0),b(this,Uh,void 0),b(this,Wh,[]),b(this,Z,new Float32Array(18)),b(this,Gh,void 0),b(this,Kh,void 0),b(this,qh,void 0),b(this,Jh,void 0),b(this,Yh,void 0),b(this,Xh,void 0),b(this,Zh,[]),C(Bh,this,n),C(Xh,this,i*r),C(Uh,this,a),x(Z,this).set([NaN,NaN,NaN,NaN,e,t],6),C(Hh,this,o),C(Jh,this,sg._*r),C(qh,this,cg._*r),C(Yh,this,r),x(Zh,this).push(e,t)}isEmpty(){return isNaN(x(Z,this)[8])}add({x:e,y:t}){var n;C(Gh,this,e),C(Kh,this,t);let[r,i,a,o]=x(Bh,this),[s,c,l,u]=x(Z,this).subarray(8,12),d=e-l,f=t-u,p=Math.hypot(d,f);if(p<x(qh,this))return!1;let m=p-x(Jh,this),h=m/p,g=h*d,_=h*f,v=s,y=c;s=l,c=u,l+=g,u+=_,(n=x(Zh,this))==null||n.push(e,t);let b=-_/m,S=g/m,w=b*x(Xh,this),T=S*x(Xh,this);return x(Z,this).set(x(Z,this).subarray(2,8),0),x(Z,this).set([l+w,u+T],4),x(Z,this).set(x(Z,this).subarray(14,18),12),x(Z,this).set([l-w,u-T],16),isNaN(x(Z,this)[6])?(x(Wh,this).length===0&&(x(Z,this).set([s+w,c+T],2),x(Wh,this).push(NaN,NaN,NaN,NaN,(s+w-r)/a,(c+T-i)/o),x(Z,this).set([s-w,c-T],14),x(Vh,this).push(NaN,NaN,NaN,NaN,(s-w-r)/a,(c-T-i)/o)),x(Z,this).set([v,y,s,c,l,u],6),!this.isEmpty()):(x(Z,this).set([v,y,s,c,l,u],6),Math.abs(Math.atan2(y-c,v-s)-Math.atan2(_,g))<Math.PI/2?([s,c,l,u]=x(Z,this).subarray(2,6),x(Wh,this).push(NaN,NaN,NaN,NaN,((s+l)/2-r)/a,((c+u)/2-i)/o),[s,c,v,y]=x(Z,this).subarray(14,18),x(Vh,this).push(NaN,NaN,NaN,NaN,((v+s)/2-r)/a,((y+c)/2-i)/o),!0):([v,y,s,c,l,u]=x(Z,this).subarray(0,6),x(Wh,this).push(((v+5*s)/6-r)/a,((y+5*c)/6-i)/o,((5*s+l)/6-r)/a,((5*c+u)/6-i)/o,((s+l)/2-r)/a,((c+u)/2-i)/o),[l,u,s,c,v,y]=x(Z,this).subarray(12,18),x(Vh,this).push(((v+5*s)/6-r)/a,((y+5*c)/6-i)/o,((5*s+l)/6-r)/a,((5*c+u)/6-i)/o,((s+l)/2-r)/a,((c+u)/2-i)/o),!0))}toSVGPath(){if(this.isEmpty())return``;let e=x(Wh,this),t=x(Vh,this);if(isNaN(x(Z,this)[6])&&!this.isEmpty())return f(Qh,this,tg).call(this);let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;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]}`);f(Qh,this,rg).call(this,n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return f(Qh,this,ng).call(this,n),n.join(` `)}newFreeDrawOutline(e,t,n,r,i,a){return new _g(e,t,n,r,i,a)}getOutlines(){var e,t;let n=x(Wh,this),r=x(Vh,this),i=x(Z,this),[a,o,s,c]=x(Bh,this),l=new Float32Array(((e=(t=x(Zh,this))==null?void 0:t.length)==null?0:e)+2);for(let e=0,t=l.length-2;e<t;e+=2)l[e]=(x(Zh,this)[e]-a)/s,l[e+1]=(x(Zh,this)[e+1]-o)/c;if(l[l.length-2]=(x(Gh,this)-a)/s,l[l.length-1]=(x(Kh,this)-o)/c,isNaN(i[6])&&!this.isEmpty())return f(Qh,this,ig).call(this,l);let u=new Float32Array(x(Wh,this).length+24+x(Vh,this).length),d=n.length;for(let e=0;e<d;e+=2){if(isNaN(n[e])){u[e]=u[e+1]=NaN;continue}u[e]=n[e],u[e+1]=n[e+1]}d=f(Qh,this,og).call(this,u,d);for(let e=r.length-6;e>=6;e-=6)for(let t=0;t<6;t+=2){if(isNaN(r[e+t])){u[d]=u[d+1]=NaN,d+=2;continue}u[d]=r[e+t],u[d+1]=r[e+t+1],d+=2}return f(Qh,this,ag).call(this,u,d),this.newFreeDrawOutline(u,l,x(Bh,this),x(Yh,this),x(Hh,this),x(Uh,this))}};function eg(){let e=x(Z,this).subarray(4,6),t=x(Z,this).subarray(16,18),[n,r,i,a]=x(Bh,this);return[(x(Gh,this)+(e[0]-t[0])/2-n)/i,(x(Kh,this)+(e[1]-t[1])/2-r)/a,(x(Gh,this)+(t[0]-e[0])/2-n)/i,(x(Kh,this)+(t[1]-e[1])/2-r)/a]}function tg(){let[e,t,n,r]=x(Bh,this),[i,a,o,s]=f(Qh,this,eg).call(this);return`M${(x(Z,this)[2]-e)/n} ${(x(Z,this)[3]-t)/r} L${(x(Z,this)[4]-e)/n} ${(x(Z,this)[5]-t)/r} L${i} ${a} L${o} ${s} L${(x(Z,this)[16]-e)/n} ${(x(Z,this)[17]-t)/r} L${(x(Z,this)[14]-e)/n} ${(x(Z,this)[15]-t)/r} Z`}function ng(e){let t=x(Vh,this);e.push(`L${t[4]} ${t[5]} Z`)}function rg(e){let[t,n,r,i]=x(Bh,this),a=x(Z,this).subarray(4,6),o=x(Z,this).subarray(16,18),[s,c,l,u]=f(Qh,this,eg).call(this);e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}function ig(e){let t=x(Z,this),[n,r,i,a]=x(Bh,this),[o,s,c,l]=f(Qh,this,eg).call(this),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0),this.newFreeDrawOutline(u,e,x(Bh,this),x(Yh,this),x(Hh,this),x(Uh,this))}function ag(e,t){let n=x(Vh,this);return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+=6}function og(e,t){let n=x(Z,this).subarray(4,6),r=x(Z,this).subarray(16,18),[i,a,o,s]=x(Bh,this),[c,l,u,d]=f(Qh,this,eg).call(this);return e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t),t+=24}var sg={_:8},cg={_:sg._+{_:2}._},lg=new WeakMap,ug=new WeakMap,dg=new WeakMap,fg=new WeakMap,pg=new WeakMap,mg=new WeakMap,hg=new WeakMap,gg=new WeakSet,_g=class extends X{constructor(e,t,n,r,i,a){super(),S(this,gg),b(this,lg,void 0),b(this,ug,new Float32Array(4)),b(this,dg,void 0),b(this,fg,void 0),b(this,pg,void 0),b(this,mg,void 0),b(this,hg,void 0),C(hg,this,e),C(pg,this,t),C(lg,this,n),C(mg,this,r),C(dg,this,i),C(fg,this,a),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],f(gg,this,vg).call(this,a);let[o,s,c,l]=x(ug,this);for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-o)/c,e[t+1]=(e[t+1]-s)/l;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-o)/c,t[e+1]=(t[e+1]-s)/l}toSVGPath(){let e=[`M${x(hg,this)[4]} ${x(hg,this)[5]}`];for(let t=6,n=x(hg,this).length;t<n;t+=6){if(isNaN(x(hg,this)[t])){e.push(`L${x(hg,this)[t+4]} ${x(hg,this)[t+5]}`);continue}e.push(`C${x(hg,this)[t]} ${x(hg,this)[t+1]} ${x(hg,this)[t+2]} ${x(hg,this)[t+3]} ${x(hg,this)[t+4]} ${x(hg,this)[t+5]}`)}return e.push(`Z`),e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=X._rescale(x(hg,this),e,r,a,-o),c=X._rescale(x(pg,this),e,r,a,-o);break;case 90:s=X._rescaleAndSwap(x(hg,this),e,t,a,o),c=X._rescaleAndSwap(x(pg,this),e,t,a,o);break;case 180:s=X._rescale(x(hg,this),n,t,-a,o),c=X._rescale(x(pg,this),n,t,-a,o);break;case 270:s=X._rescaleAndSwap(x(hg,this),n,r,-a,-o),c=X._rescaleAndSwap(x(pg,this),n,r,-a,-o);break}return{outline:Array.from(s),points:[Array.from(c)]}}get box(){return x(ug,this)}newOutliner(e,t,n,r,i,a=0){return new $h(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=x(ug,this),[o,s,c,l]=x(lg,this),u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:x(pg,this)[0]*u+f,y:x(pg,this)[1]*d+p},x(lg,this),x(mg,this),e,x(fg,this),t==null?x(dg,this):t);for(let e=2;e<x(pg,this).length;e+=2)m.add({x:x(pg,this)[e]*u+f,y:x(pg,this)[e+1]*d+p});return m.getOutlines()}};function vg(e){let t=x(hg,this),n=t[4],r=t[5],i=[n,r,n,r],a=n,o=r,s=n,c=r,l=e?Math.max:Math.min,u=new Float32Array(4);for(let e=6,d=t.length;e<d;e+=6){let d=t[e+4],f=t[e+5];isNaN(t[e])?(z.pointBoundingBox(d,f,i),o>f?(a=d,o=f):o===f&&(a=l(a,d)),c<f?(s=d,c=f):c===f&&(s=l(s,d))):(u.set(ve,0),z.bezierBoundingBox(n,r,...t.slice(e,e+6),u),z.rectBoundingBox(...u,i),o>u[1]?(a=u[0],o=u[1]):o===u[1]&&(a=l(a,u[0])),c<u[3]?(s=u[2],c=u[3]):c===u[3]&&(s=l(s,u[2]))),n=d,r=f}let d=x(ug,this);d[0]=i[0]-x(dg,this),d[1]=i[1]-x(dg,this),d[2]=i[2]-i[0]+2*x(dg,this),d[3]=i[3]-i[1]+2*x(dg,this),this.firstPoint=[a,o],this.lastPoint=[s,c]}var yg=new WeakMap,bg=new WeakMap,xg=new WeakMap,Sg=new WeakMap,Cg=new WeakMap,wg=new WeakSet,Tg=class{constructor(e,t=0,n=0,r=!0){S(this,wg),b(this,yg,void 0),b(this,bg,void 0),b(this,xg,void 0),b(this,Sg,[]),b(this,Cg,[]);let i=ve.slice(),a=Math.pow(10,-4);for(let{x:n,y:r,width:o,height:s}of e){let e=Math.floor((n-t)/a)*a,c=Math.ceil((n+o+t)/a)*a,l=Math.floor((r-t)/a)*a,u=Math.ceil((r+s+t)/a)*a,d=[e,l,u,!0],f=[c,l,u,!1];x(Sg,this).push(d,f),z.rectBoundingBox(e,l,c,u,i)}let o=i[2]-i[0]+2*n,s=i[3]-i[1]+2*n,c=i[0]-n,l=i[1]-n,u=r?-1/0:1/0,d=1/0,f=x(Sg,this).at(r?-1:-2),p=[f[0],f[2]];for(let e of x(Sg,this)){let[t,n,i,a]=e;!a&&r?n<d?(d=n,u=t):n===d&&(u=Math.max(u,t)):a&&!r&&(n<d?(d=n,u=t):n===d&&(u=Math.min(u,t))),e[0]=(t-c)/o,e[1]=(n-l)/s,e[2]=(i-l)/s}C(yg,this,new Float32Array([c,l,o,s])),C(bg,this,[u,d]),C(xg,this,p)}getOutlines(){x(Sg,this).sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of x(Sg,this))t[3]?(e.push(...f(wg,this,Ag).call(this,t)),f(wg,this,Og).call(this,t)):(f(wg,this,kg).call(this,t),e.push(...f(wg,this,Ag).call(this,t)));return f(wg,this,Eg).call(this,e)}};function Eg(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i),i.push(r),n.add(r),n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;for(i=[t,o],r.push(i);;){let e;if(n.has(s))e=s;else if(n.has(c))e=c;else break;n.delete(e),[t,a,o,s,c]=e,l!==t&&(i.push(l,u,t,u===a?a:o),l=t),u=u===a?o:a}i.push(l,u)}return new Ng(r,x(yg,this),x(bg,this),x(xg,this))}function Dg(e){let t=x(Cg,this),n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}function Og([,e,t]){let n=f(wg,this,Dg).call(this,e);x(Cg,this).splice(n,0,[e,t])}function kg([,e,t]){let n=f(wg,this,Dg).call(this,e);for(let r=n;r<x(Cg,this).length;r++){let[n,i]=x(Cg,this)[r];if(n!==e)break;if(n===e&&i===t){x(Cg,this).splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=x(Cg,this)[r];if(n!==e)break;if(n===e&&i===t){x(Cg,this).splice(r,1);return}}}function Ag(e){let[t,n,r]=e,i=[[t,n,r]],a=f(wg,this,Dg).call(this,r);for(let e=0;e<a;e++){let[n,r]=x(Cg,this)[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1),e--,a--}continue}i[e][2]=n,s>r&&i.push([t,r,s])}}}return i}var jg=new WeakMap,Mg=new WeakMap,Ng=class extends X{constructor(e,t,n,r){super(),b(this,jg,void 0),b(this,Mg,void 0),C(Mg,this,e),C(jg,this,t),this.firstPoint=n,this.lastPoint=r}toSVGPath(){let e=[];for(let t of x(Mg,this)){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];a===n?(e.push(`V${o}`),r=o):o===r&&(e.push(`H${a}`),n=a)}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of x(Mg,this)){let n=Array(t.length);for(let i=0;i<t.length;i+=2)n[i]=e+t[i]*o,n[i+1]=r-t[i+1]*s;a.push(n)}return a}get box(){return x(jg,this)}},Pg=class extends $h{newFreeDrawOutline(e,t,n,r,i,a){return new Fg(e,t,n,r,i,a)}},Fg=class extends _g{newOutliner(e,t,n,r,i,a=0){return new Pg(e,t,n,r,i,a)}},Ig=new WeakMap,Lg=new WeakMap,Rg=new WeakMap,zg=new WeakMap,Bg=new WeakMap,Vg=new WeakMap,Hg=new WeakMap,Ug=new WeakMap,Wg=new WeakMap,Gg=new WeakMap,Kg=new WeakMap,qg=new WeakMap,Jg=new WeakMap,Yg=new WeakMap,Xg=new WeakMap,Zg=new WeakMap,Qg=new WeakMap,$g=new WeakMap,Q=new WeakSet,e_=class e extends W{static get _keyboardManager(){let t=e.prototype;return L(this,`_keyboardManager`,new Rn([[[`ArrowLeft`],t._moveCaret,{args:[0]}],[[`ArrowRight`],t._moveCaret,{args:[1]}],[[`ArrowUp`],t._moveCaret,{args:[2]}],[[`ArrowDown`],t._moveCaret,{args:[3]}]]))}constructor(t){super(T(T({},t),{},{name:`highlightEditor`})),S(this,Q),b(this,Ig,null),b(this,Lg,0),b(this,Rg,void 0),b(this,zg,null),b(this,Bg,null),b(this,Vg,null),b(this,Hg,null),b(this,Ug,0),b(this,Wg,null),b(this,Gg,null),b(this,Kg,null),b(this,qg,!1),b(this,Jg,null),b(this,Yg,null),b(this,Xg,null),b(this,Zg,``),b(this,Qg,void 0),b(this,$g,``),this.color=t.color||e._defaultColor,C(Qg,this,t.thickness||e._defaultThickness),this.opacity=t.opacity||e._defaultOpacity,C(Rg,this,t.boxes||null),C($g,this,t.methodOfCreation||``),C(Zg,this,t.text||``),this._isDraggable=!1,this.defaultL10nId=`pdfjs-editor-highlight-editor`,t.highlightId>-1?(C(qg,this,!0),f(Q,this,n_).call(this,t),f(Q,this,s_).call(this)):x(Rg,this)&&(C(Ig,this,t.anchorNode),C(Lg,this,t.anchorOffset),C(Hg,this,t.focusNode),C(Ug,this,t.focusOffset),f(Q,this,t_).call(this),f(Q,this,s_).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(W._l10nAlert.highlight)}get telemetryInitialData(){return{action:`added`,type:x(qg,this)?`free_highlight`:`highlight`,color:this._uiManager.getNonHCMColorName(this.color),thickness:x(Qg,this),methodOfCreation:x($g,this)}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}static initialize(t,n){var r;W.initialize(t,n),e._defaultColor||(e._defaultColor=((r=n.highlightColors)==null?void 0:r.values().next().value)||`#fff066`)}static updateDefaultParams(t,n){switch(t){case N.HIGHLIGHT_COLOR:e._defaultColor=n;break;case N.HIGHLIGHT_THICKNESS:e._defaultThickness=n;break}}translateInPage(e,t){}get toolbarPosition(){return x(Yg,this)}get commentButtonPosition(){return x(Jg,this)}updateParams(e,t){switch(e){case N.HIGHLIGHT_COLOR:f(Q,this,r_).call(this,t);break;case N.HIGHLIGHT_THICKNESS:f(Q,this,i_).call(this,t);break}}static get defaultPropertiesToUpdate(){return[[N.HIGHLIGHT_COLOR,e._defaultColor],[N.HIGHLIGHT_THICKNESS,e._defaultThickness]]}get propertiesToUpdate(){return[[N.HIGHLIGHT_COLOR,this.color||e._defaultColor],[N.HIGHLIGHT_THICKNESS,x(Qg,this)||e._defaultThickness],[N.HIGHLIGHT_FREE,x(qg,this)]]}onUpdatedColor(){var e,t;(e=this.parent)==null||e.drawLayer.updateProperties(x(Kg,this),{root:{fill:this.color,"fill-opacity":this.opacity}}),(t=x(Bg,this))==null||t.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[[`colorPicker`,C(Bg,this,new np({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle(`disabled`,!1)}fixAndSetPosition(){return super.fixAndSetPosition(f(Q,this,d_).call(this))}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,f(Q,this,d_).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){f(Q,this,o_).call(this),this._reportTelemetry({action:`deleted`}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(Q,this,s_).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;if(this.parent&&!e)f(Q,this,o_).call(this);else if(e){var n;f(Q,this,s_).call(this,e),t=!this.parent&&((n=this.div)==null?void 0:n.classList.contains(`selectedEditor`))}super.setParent(e),this.show(this._isVisible),t&&this.select()}rotate(t){let{drawLayer:n}=this.parent,r;x(qg,this)?(t=(t-this.rotation+360)%360,r=c_.call(e,x(Gg,this).box,t)):r=c_.call(e,[this.x,this.y,this.width,this.height],t),n.updateProperties(x(Kg,this),{bbox:r,root:{"data-main-rotation":t}}),n.updateProperties(x(Xg,this),{bbox:c_.call(e,x(Vg,this).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let e=super.render();x(Zg,this)&&(e.setAttribute(`aria-label`,x(Zg,this)),e.setAttribute(`role`,`mark`)),x(qg,this)?e.classList.add(`free`):this.div.addEventListener(`keydown`,f(Q,this,l_).bind(this),{signal:this._uiManager._signal});let t=C(Wg,this,document.createElement(`div`));return e.append(t),t.setAttribute(`aria-hidden`,`true`),t.className=`internal`,t.style.clipPath=x(zg,this),this.setDims(),yn(this,x(Wg,this),[`pointerover`,`pointerleave`]),this.enableEditing(),e}pointerover(){if(!this.isSelected){var e;(e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{hovered:!0}})}}pointerleave(){if(!this.isSelected){var e;(e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{hovered:!1}})}}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:f(Q,this,u_).call(this,!0);break;case 1:case 3:f(Q,this,u_).call(this,!1);break}}select(){var e;super.select(),x(Xg,this)&&((e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),x(Xg,this)&&((e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{selected:!1}}),x(qg,this)||f(Q,this,u_).call(this,!1))}get _mustFixPosition(){return!x(qg,this)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(x(Kg,this),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(x(Xg,this),{rootClass:{hidden:!e}}))}static startHighlighting(t,n,{target:r,x:i,y:a}){let{x:o,y:s,width:c,height:l}=r.getBoundingClientRect(),u=new AbortController,d=t.combinedSignal(u),p=n=>{u.abort(),f(e,this,h_).call(this,t,n)};window.addEventListener(`blur`,p,{signal:d}),window.addEventListener(`pointerup`,p,{signal:d}),window.addEventListener(`pointerdown`,Tt,{capture:!0,passive:!1,signal:d}),window.addEventListener(`contextmenu`,wt,{signal:d}),r.addEventListener(`pointermove`,f(e,this,m_).bind(this,t),{signal:d}),this._freeHighlight=new Pg({x:i,y:a},[o,s,c,l],t.scale,this._defaultThickness/2,n,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let a=null;if(e instanceof Xm){let{data:{quadPoints:t,rect:n,rotation:r,id:i,color:o,opacity:s,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;a=e={annotationType:M.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:c,richText:l,comment:(u==null?void 0:u.str)||null,creationDate:d,modificationDate:f}}else if(e instanceof Jm){let{data:{inkLists:t,rect:n,rotation:r,id:i,color:o,borderStyle:{rawWidth:s},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;a=e={annotationType:M.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:c,richText:l,comment:(u==null?void 0:u.str)||null,creationDate:d,modificationDate:f}}let{color:o,quadPoints:s,inkLists:c,outlines:l,opacity:u}=e,d=yield r().call(i,e,t,n);d.color=z.makeHexColor(...o),d.opacity=u||1,c&&C(Qg,d,e.thickness),d._initialData=a,e.comment&&d.setCommentData(e);let[p,m]=d.pageDimensions,[h,g]=d.pageTranslation;if(s){let e=C(Rg,d,[]);for(let t=0;t<s.length;t+=8)e.push({x:(s[t]-h)/p,y:1-(s[t+1]-g)/m,width:(s[t+2]-s[t])/p,height:(s[t+1]-s[t+5])/m});f(Q,d,t_).call(d),f(Q,d,s_).call(d),d.rotate(d.rotation)}else if(c||l){C(qg,d,!0);let e=(c||l.points)[0],n={x:e[0]-h,y:m-(e[1]-g)},r=new Pg(n,[0,0,p,m],1,x(Qg,d)/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2)n.x=e[t]-h,n.y=m-(e[t+1]-g),r.add(n);let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);f(Q,d,n_).call(d,{highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a}),f(Q,d,s_).call(d),d.rotate(d.parentRotation)}return d})()}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=W._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:t,opacity:this.opacity,thickness:x(Qg,this),quadPoints:f(Q,this,f_).call(this),outlines:f(Q,this,p_).call(this,n.rect)}),this.addComment(n),this.annotationElementId&&!f(Q,this,g_).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};le=e_;function t_(){let e=new Tg(x(Rg,this),.001);C(Gg,this,e.getOutlines()),[this.x,this.y,this.width,this.height]=x(Gg,this).box;let t=new Tg(x(Rg,this),.0025,.001,this._uiManager.direction===`ltr`);C(Vg,this,t.getOutlines());let{firstPoint:n}=x(Gg,this);C(Jg,this,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);let{lastPoint:r}=x(Vg,this);C(Yg,this,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])}function n_({highlightOutlines:e,highlightId:t,clipPathId:n}){if(C(Gg,this,e),C(Vg,this,e.getNewOutline(x(Qg,this)/2+1.5,.0025)),t>=0)C(Kg,this,t),C(zg,this,n),this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),C(Xg,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:x(Vg,this).box,path:{d:x(Vg,this).toSVGPath()}},!0));else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(x(Kg,this),{bbox:c_.call(le,x(Gg,this).box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(x(Xg,this),{bbox:c_.call(le,x(Vg,this).box,t),path:{d:x(Vg,this).toSVGPath()}})}let[r,i,a,o]=e.box;switch(this.rotation){case 0:this.x=r,this.y=i,this.width=a,this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=i,this.y=1-r,this.width=a*t/e,this.height=o*e/t;break}case 180:this.x=1-r,this.y=1-i,this.width=a,this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-i,this.y=r,this.width=a*t/e,this.height=o*e/t;break}}let{firstPoint:s}=e;C(Jg,this,[(s[0]-r)/a,(s[1]-i)/o]);let{lastPoint:c}=x(Vg,this);C(Yg,this,[(c[0]-r)/a,(c[1]-i)/o])}function r_(e){let t=(e,t)=>{this.color=e,this.opacity=t,this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,e,le._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`color_changed`,color:this._uiManager.getNonHCMColorName(e)},!0)}function i_(e){let t=x(Qg,this),n=e=>{C(Qg,this,e),f(Q,this,a_).call(this,e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}function a_(e){x(qg,this)&&(f(Q,this,n_).call(this,{highlightOutlines:x(Gg,this).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())}function o_(){x(Kg,this)===null||!this.parent||(this.parent.drawLayer.remove(x(Kg,this)),C(Kg,this,null),this.parent.drawLayer.remove(x(Xg,this)),C(Xg,this,null))}function s_(e=this.parent){x(Kg,this)===null&&({id:O(C,[Kg,this])._,clipPathId:O(C,[zg,this])._}=e.drawLayer.draw({bbox:x(Gg,this).box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:x(qg,this)},path:{d:x(Gg,this).toSVGPath()}},!1,!0),C(Xg,this,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:x(qg,this)},bbox:x(Vg,this).box,path:{d:x(Vg,this).toSVGPath()}},x(qg,this))),x(Wg,this)&&(x(Wg,this).style.clipPath=x(zg,this)))}function c_([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}function l_(e){le._keyboardManager.exec(this,e)}function u_(e){if(!x(Ig,this))return;let t=window.getSelection();e?t.setPosition(x(Ig,this),x(Lg,this)):t.setPosition(x(Hg,this),x(Ug,this))}function d_(){return x(qg,this)?this.rotation:0}function f_(){if(x(qg,this))return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=x(Rg,this),a=new Float32Array(i.length*8),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i,a[o+1]=a[o+3]=d,a[o+2]=a[o+6]=i+l*e,a[o+5]=a[o+7]=d-u*t,o+=8}return a}function p_(e){return x(Gg,this).serialize(e,f(Q,this,d_).call(this))}function m_(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function h_(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=``}function g_(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,n)=>e!==t[n])}g(e_,`_defaultColor`,null),g(e_,`_defaultOpacity`,1),g(e_,`_defaultThickness`,12),g(e_,`_type`,`highlight`),g(e_,`_editorType`,M.HIGHLIGHT),g(e_,`_freeHighlightId`,-1),g(e_,`_freeHighlight`,null),g(e_,`_freeHighlightClipId`,``);var __=new WeakMap,v_=class{constructor(){b(this,__,Object.create(null))}updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))t.startsWith(`_`)||this.updateProperty(t,n)}updateSVGProperty(e,t){x(__,this)[e]=t}toSVGProperties(){let e=x(__,this);return C(__,this,Object.create(null)),{root:e}}reset(){C(__,this,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){I(`Not implemented`)}},y_=new WeakMap,b_=new WeakMap,x_=new WeakSet,S_=class e extends W{constructor(e){super(e),S(this,x_),b(this,y_,null),b(this,b_,void 0),g(this,`_colorPicker`,null),g(this,`_drawId`,null),C(b_,this,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,t;(e=this._colorPicker)==null||(t=e.updateOpacity)==null||t.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(f(x_,this,C_).call(this,e),f(x_,this,E_).call(this))}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){I(`Not implemented`)}static get typesMap(){I(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){let n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t),this._currentParent&&(j_._.updateProperty(n,t),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=n=>{var i;r.updateProperty(t,n);let a=x(y_,this).updateProperty(t,n);a&&f(x_,this,k_).call(this,a),(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),i=this._drawingOptions,a=i[n],o=i[r],s=(e,t)=>{var a;i.updateProperty(n,e),i.updateProperty(r,t),x(y_,this).updateProperty(n,e),x(y_,this).updateProperty(r,t),(a=this.parent)==null||a.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:s.bind(this,e,t),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:N.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(x(y_,this).getPathResizingSVGProperties(f(x_,this,O_).call(this)),{bbox:f(x_,this,A_).call(this)}))}_onResized(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(x(y_,this).getPathResizedSVGProperties(f(x_,this,O_).call(this)),{bbox:f(x_,this,A_).call(this)}))}_onTranslating(e,t){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{bbox:f(x_,this,A_).call(this)})}_onTranslated(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(x(y_,this).getPathTranslatedSVGProperties(f(x_,this,O_).call(this),this.parentDimensions),{bbox:f(x_,this,A_).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle(`disabled`,!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,x(b_,this)&&(C(b_,this,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){f(x_,this,T_).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(x_,this,E_).call(this),f(x_,this,k_).call(this,x(y_,this).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;if(this.parent&&!e)this._uiManager.removeShouldRescale(this),f(x_,this,T_).call(this);else if(e){var n;this._uiManager.addShouldRescale(this),f(x_,this,E_).call(this,e),t=!this.parent&&((n=this.div)==null?void 0:n.classList.contains(`selectedEditor`))}super.setParent(e),t&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties({bbox:f(x_,this,A_).call(this)},x(y_,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&f(x_,this,k_).call(this,x(y_,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;this._isCopy&&(e=this.x,t=this.y);let n=super.render();n.classList.add(`draw`);let r=document.createElement(`div`);return n.append(r),r.setAttribute(`aria-hidden`,`true`),r.className=`internal`,this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,t),n}static createDrawerInstance(e,t,n,r,i){I(`Not implemented`)}static startDrawing(e,t,n,r){var i;let{target:a,offsetX:o,offsetY:s,pointerId:c,pointerType:l}=r;if(bn.isInitializedAndDifferentPointerType(l))return;let{viewport:{rotation:u}}=e,{width:d,height:f}=a.getBoundingClientRect(),p=M_._=new AbortController,m=e.combinedSignal(p);if(bn.setPointer(l,c),window.addEventListener(`pointerup`,e=>{bn.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:m}),window.addEventListener(`pointercancel`,e=>{bn.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:m}),window.addEventListener(`pointerdown`,e=>{bn.isSamePointerType(e.pointerType)&&(bn.initializeAndAddPointerId(e.pointerId),j_._.isCancellable()&&(j_._.removeLastElement(),j_._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener(`contextmenu`,wt,{signal:m}),a.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:m}),a.addEventListener(`touchmove`,e=>{bn.isSameTimeStamp(e.timeStamp)&&Tt(e)},{signal:m}),e.toggleDrawing(),(i=t._editorUndoBar)==null||i.hide(),j_._){e.drawLayer.updateProperties(this._currentDrawId,j_._.startNew(o,s,d,f,u));return}t.updateUIForDefaultProperties(this),j_._=this.createDrawerInstance(o,s,d,f,u),N_._=this.getDefaultDrawingOptions(),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(N_._.toSVGProperties(),j_._.defaultSVGProperties),!0,!1)}static _drawMove(e){if(bn.isSameTimeStamp(e.timeStamp),!j_._)return;let{offsetX:t,offsetY:n,pointerId:r}=e;if(bn.isSamePointerId(r)){if(bn.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,j_._.add(t,n)),bn.setTimeStamp(e.timeStamp),Tt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,j_._=null,N_._=null,bn.clearTimeStamp()),M_._&&(M_._.abort(),M_._=null,bn.clearPointerIds())}static _endDraw(e){let t=this._currentParent;if(t){if(t.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===t.div&&t.drawLayer.updateProperties(this._currentDrawId,j_._.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){let e=j_._,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:N.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){let t=this._currentParent;if(!t)return null;if(t.toggleDrawing(!0),t.cleanUndoStack(N.DRAW_STEP),!j_._.isEmpty()){let{pageDimensions:[n,r],scale:i}=t,a=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:j_._.getOutlines(n*i,r*i,i,this._INNER_MARGIN),drawingOptions:N_._,mustBeCommitted:!e});return this._cleanup(!0),a}return t.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){I(`Not implemented`)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let{rawDims:{pageWidth:a,pageHeight:o,pageX:s,pageY:c}}=t.viewport,l=i.deserializeDraw(s,c,a,o,i._INNER_MARGIN,e),u=yield r().call(i,e,t,n);return u.createDrawingOptions(e),f(x_,u,C_).call(u,{drawOutlines:l}),f(x_,u,E_).call(u),u.onScaleChanging(),u.rotate(),u})()}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return x(y_,this).serialize([t,n,r,i],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};ue=S_;function C_({drawOutlines:e,drawId:t,drawingOptions:n}){C(y_,this,e),this._drawingOptions||(this._drawingOptions=n),this.annotationElementId||this._uiManager.a11yAlert(W._l10nAlert[this.editorType]),t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=f(x_,this,w_).call(this,e,this.parent),f(x_,this,k_).call(this,e.box)}function w_(e,t){let{id:n}=t.drawLayer.draw(ue._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}function T_(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}function E_(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=f(x_,this,w_).call(this,x(y_,this),e)}}function D_([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}function O_(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}function k_(e){[this.x,this.y,this.width,this.height]=f(x_,this,D_).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}function A_(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((i*4+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}g(S_,`_currentDrawId`,-1),g(S_,`_currentParent`,null);var j_={_:null},M_={_:null},N_={_:null};g(S_,`_INNER_MARGIN`,3);var P_=new WeakMap,F_=new WeakMap,I_=new WeakMap,L_=new WeakMap,R_=new WeakMap,z_=new WeakMap,B_=new WeakMap,V_=new WeakMap,H_=new WeakMap,U_=new WeakMap,W_=new WeakMap,G_=new WeakSet,K_=class{constructor(e,t,n,r,i,a){S(this,G_),b(this,P_,new Float64Array(6)),b(this,F_,void 0),b(this,I_,void 0),b(this,L_,void 0),b(this,R_,void 0),b(this,z_,void 0),b(this,B_,``),b(this,V_,0),b(this,H_,new iv),b(this,U_,void 0),b(this,W_,void 0),C(U_,this,n),C(W_,this,r),C(L_,this,i),C(R_,this,a),[e,t]=f(G_,this,q_).call(this,e,t);let o=C(F_,this,[NaN,NaN,NaN,NaN,e,t]);C(z_,this,[e,t]),C(I_,this,[{line:o,points:x(z_,this)}]),x(P_,this).set(o,0)}updateProperty(e,t){e===`stroke-width`&&C(R_,this,t)}isEmpty(){var e;return!((e=x(I_,this))!=null&&e.length)}isCancellable(){return x(z_,this).length<=10}add(e,t){[e,t]=f(G_,this,q_).call(this,e,t);let[n,r,i,a]=x(P_,this).subarray(2,6),o=e-i,s=t-a;return Math.hypot(x(U_,this)*o,x(W_,this)*s)<=2?null:(x(z_,this).push(e,t),isNaN(n)?(x(P_,this).set([i,a,e,t],2),x(F_,this).push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(x(P_,this)[0])&&x(F_,this).splice(6,6),x(P_,this).set([n,r,i,a,e,t],0),x(F_,this).push(...X.createBezierPoints(n,r,i,a,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(x(z_,this).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){C(U_,this,n),C(W_,this,r),C(L_,this,i),[e,t]=f(G_,this,q_).call(this,e,t);let a=C(F_,this,[NaN,NaN,NaN,NaN,e,t]);C(z_,this,[e,t]);let o=x(I_,this).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),x(I_,this).push({line:a,points:x(z_,this)}),x(P_,this).set(a,0),C(V_,this,0),this.toSVGPath(),null}getLastElement(){return x(I_,this).at(-1)}setLastElement(e){return x(I_,this)?(x(I_,this).push(e),C(F_,this,e.line),C(z_,this,e.points),C(V_,this,0),{path:{d:this.toSVGPath()}}):x(H_,this).setLastElement(e)}removeLastElement(){if(!x(I_,this))return x(H_,this).removeLastElement();x(I_,this).pop(),C(B_,this,``);for(let e=0,t=x(I_,this).length;e<t;e++){let{line:t,points:n}=x(I_,this)[e];C(F_,this,t),C(z_,this,n),C(V_,this,0),this.toSVGPath()}return{path:{d:x(B_,this)}}}toSVGPath(){let e=X.svgRound(x(F_,this)[4]),t=X.svgRound(x(F_,this)[5]);if(x(z_,this).length===2)return C(B_,this,`${x(B_,this)} M ${e} ${t} Z`),x(B_,this);if(x(z_,this).length<=6){let n=x(B_,this).lastIndexOf(`M`);C(B_,this,`${x(B_,this).slice(0,n)} M ${e} ${t}`),C(V_,this,6)}if(x(z_,this).length===4){let e=X.svgRound(x(F_,this)[10]),t=X.svgRound(x(F_,this)[11]);return C(B_,this,`${x(B_,this)} L ${e} ${t}`),C(V_,this,12),x(B_,this)}let n=[];x(V_,this)===0&&(n.push(`M ${e} ${t}`),C(V_,this,6));for(let e=x(V_,this),t=x(F_,this).length;e<t;e+=6){let[t,r,i,a,o,s]=x(F_,this).slice(e,e+6).map(X.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}return C(B_,this,x(B_,this)+n.join(` `)),C(V_,this,x(F_,this).length),x(B_,this)}getOutlines(e,t,n,r){let i=x(I_,this).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),x(H_,this).build(x(I_,this),e,t,n,x(L_,this),x(R_,this),r),C(P_,this,null),C(F_,this,null),C(I_,this,null),C(B_,this,null),x(H_,this)}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}};function q_(e,t){return X._normalizePoint(e,t,x(U_,this),x(W_,this),x(L_,this))}var J_=new WeakMap,Y_=new WeakMap,X_=new WeakMap,Z_=new WeakMap,Q_=new WeakMap,$_=new WeakMap,ev=new WeakMap,tv=new WeakMap,nv=new WeakMap,rv=new WeakSet,iv=class extends X{constructor(...e){super(...e),S(this,rv),b(this,J_,void 0),b(this,Y_,0),b(this,X_,void 0),b(this,Z_,void 0),b(this,Q_,void 0),b(this,$_,void 0),b(this,ev,void 0),b(this,tv,void 0),b(this,nv,void 0)}build(e,t,n,r,i,a,o){C(Q_,this,t),C($_,this,n),C(ev,this,r),C(tv,this,i),C(nv,this,a),C(X_,this,o==null?0:o),C(Z_,this,e),f(rv,this,sv).call(this)}get thickness(){return x(nv,this)}setLastElement(e){return x(Z_,this).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return x(Z_,this).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of x(Z_,this)){if(e.push(`M${X.svgRound(t[4])} ${X.svgRound(t[5])}`),t.length===6){e.push(`Z`);continue}if(t.length===12&&isNaN(t[6])){e.push(`L${X.svgRound(t[10])} ${X.svgRound(t[11])}`);continue}for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(X.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=f(rv,this,ov).call(this),d,p,m,h,g,_,v,y,b;switch(x(tv,this)){case 0:b=X._rescale,d=e,p=t+r,m=n,h=-r,g=e+s*n,_=t+(1-c-u)*r,v=e+(s+l)*n,y=t+(1-c)*r;break;case 90:b=X._rescaleAndSwap,d=e,p=t,m=n,h=r,g=e+c*n,_=t+s*r,v=e+(c+u)*n,y=t+(s+l)*r;break;case 180:b=X._rescale,d=e+n,p=t,m=-n,h=r,g=e+(1-s-l)*n,_=t+c*r,v=e+(1-s)*n,y=t+(c+u)*r;break;case 270:b=X._rescaleAndSwap,d=e+n,p=t+r,m=-n,h=-r,g=e+(1-c-u)*n,_=t+(1-s-l)*r,v=e+(1-c)*n,y=t+(1-s)*r;break}for(let{line:e,points:t}of x(Z_,this))a.push(b(e,d,p,m,h,i?Array(e.length):null)),o.push(b(t,d,p,m,h,i?Array(t.length):null));return{lines:a,points:o,rect:[g,_,v,y]}}static deserialize(e,t,n,r,i,{paths:{lines:a,points:o},rotation:s,thickness:c}){let l=[],u,d,f,p,m;switch(s){case 0:m=X._rescale,u=-e/n,d=t/r+1,f=1/n,p=-1/r;break;case 90:m=X._rescaleAndSwap,u=-t/r,d=-e/n,f=1/r,p=1/n;break;case 180:m=X._rescale,u=e/n+1,d=-t/r,f=-1/n,p=1/r;break;case 270:m=X._rescaleAndSwap,u=t/r+1,d=e/n+1,f=-1/r,p=-1/n;break}if(!a){a=[];for(let e of o){let t=e.length;if(t===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));a.push(n);let[r,i,o,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let a=4;a<t;a+=2){let t=e[a],c=e[a+1];n.set(X.createBezierPoints(r,i,o,s,t,c),(a-2)*3),[r,i,o,s]=[o,s,t,c]}}}for(let e=0,t=a.length;e<t;e++)l.push({line:m(a[e].map(e=>e==null?NaN:e),u,d,f,p),points:m(o[e].map(e=>e==null?NaN:e),u,d,f,p)});let h=new this.prototype.constructor;return h.build(l,n,r,1,s,c,i),h}get box(){return x(J_,this)}updateProperty(e,t){return e===`stroke-width`?f(rv,this,cv).call(this,t):null}updateParentDimensions([e,t],n){let[r,i]=f(rv,this,av).call(this);C(Q_,this,e),C($_,this,t),C(ev,this,n);let[a,o]=f(rv,this,av).call(this),s=a-r,c=o-i,l=x(J_,this);return l[0]-=s,l[1]-=c,l[2]+=2*s,l[3]+=2*c,l}updateRotation(e){return C(Y_,this,e),{path:{transform:this.rotationTransform}}}get viewBox(){return x(J_,this).map(X.svgRound).join(` `)}get defaultProperties(){let[e,t]=x(J_,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=x(J_,this),n=0,r=0,i=0,a=0,o=0,s=0;switch(x(Y_,this)){case 90:r=t/e,i=-e/t,o=e;break;case 180:n=-1,a=-1,o=e,s=t;break;case 270:r=-t/e,i=e/t,s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${X.svgRound(o)} ${X.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=f(rv,this,av).call(this),[o,s,c,l]=x(J_,this);if(Math.abs(c-i)<=X.PRECISION||Math.abs(l-a)<=X.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),p=c/n,m=l/r;return{path:{"transform-origin":`${X.svgRound(o)} ${X.svgRound(s)}`,transform:`${this.rotationTransform} scale(${p} ${m}) translate(${X.svgRound(i)} ${X.svgRound(a)}) scale(${u} ${d}) translate(${X.svgRound(-i)} ${X.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=f(rv,this,av).call(this),o=x(J_,this),[s,c,l,u]=o;if(o[0]=e,o[1]=t,o[2]=n,o[3]=r,Math.abs(l-i)<=X.PRECISION||Math.abs(u-a)<=X.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of x(Z_,this))X._translate(e,i,a,e),X._translate(t,i,a,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),p=(r-2*a)/(u-2*a),m=-d*(s+i)+e+i,h=-p*(c+a)+t+a;if(d!==1||p!==1||m!==0||h!==0)for(let{line:e,points:t}of x(Z_,this))X._rescale(e,m,h,d,p,e),X._rescale(t,m,h,d,p,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=x(J_,this),o=e-a[0],s=t-a[1];if(x(Q_,this)===r&&x($_,this)===i)for(let{line:e,points:t}of x(Z_,this))X._translate(e,o,s,e),X._translate(t,o,s,t);else{let e=x(Q_,this)/r,t=x($_,this)/i;C(Q_,this,r),C($_,this,i);for(let{line:n,points:r}of x(Z_,this))X._rescale(n,o,s,e,t,n),X._rescale(r,o,s,e,t,r);a[2]*=e,a[3]*=t}return a[0]=e,a[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`}}}get defaultSVGProperties(){let e=x(J_,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e[0])} ${X.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}};function av(e=x(nv,this)){let t=x(X_,this)+e/2*x(ev,this);return x(tv,this)%180==0?[t/x(Q_,this),t/x($_,this)]:[t/x($_,this),t/x(Q_,this)]}function ov(){let[e,t,n,r]=x(J_,this),[i,a]=f(rv,this,av).call(this,0);return[e+i,t+a,n-2*i,r-2*a]}function sv(){let e=C(J_,this,ye.slice());for(let{line:t}of x(Z_,this)){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6)z.pointBoundingBox(t[n],t[n+1],e);continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);z.bezierBoundingBox(n,r,a,o,s,c,l,u,e),n=l,r=u}}let[t,n]=f(rv,this,av).call(this);e[0]=B(e[0]-t,0,1),e[1]=B(e[1]-n,0,1),e[2]=B(e[2]+t,0,1),e[3]=B(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]}function cv(e){let[t,n]=f(rv,this,av).call(this);C(nv,this,e);let[r,i]=f(rv,this,av).call(this),[a,o]=[r-t,i-n],s=x(J_,this);return s[0]-=a,s[1]-=o,s[2]+=2*a,s[3]+=2*o,s}var lv=class e extends v_{constructor(e){super(),this._viewParameters=e,super.updateProperties({fill:`none`,stroke:W._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){e===`stroke-width`&&(t!=null||(t=this[`stroke-width`]),t*=this._viewParameters.realScale),super.updateSVGProperty(e,t)}clone(){let t=new e(this._viewParameters);return t.updateAll(this),t}},uv=new WeakSet,dv=class e extends S_{constructor(e){super(T(T({},e),{},{name:`inkEditor`})),S(this,uv),this._willKeepAspectRatio=!0,this.defaultL10nId=`pdfjs-editor-ink-editor`}static initialize(e,t){W.initialize(e,t),this._defaultDrawingOptions=new lv(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return L(this,`typesMap`,new Map([[N.INK_THICKNESS,`stroke-width`],[N.INK_COLOR,`stroke`],[N.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new K_(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return iv.deserialize(e,t,n,r,i,a)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let a=null;if(e instanceof Jm){let{data:{inkLists:t,rect:n,rotation:r,id:i,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},parent:{page:{pageNumber:m}}}=e;a=e={annotationType:M.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:m-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:l,richText:u,comment:(d==null?void 0:d.str)||null,creationDate:f,modificationDate:p}}let o=yield r().call(i,e,t,n);return o._initialData=a,e.comment&&o.setCommentData(e),o})()}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new mp(this)),[[`colorPicker`,this._colorPicker]]}get colorType(){return N.INK_COLOR}get colorAndOpacityType(){return N.INK_COLOR_AND_OPACITY}get opacityType(){return N.INK_OPACITY}updateParams(e,t){if(e===N.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(t.color,t.opacity);return}super.updateParams(e,t)}static updateDefaultParams(e,t){if(e===N.INK_COLOR_AND_OPACITY){super.updateDefaultParams(N.INK_COLOR,t.color),super.updateDefaultParams(N.INK_OPACITY,t.opacity);return}super.updateDefaultParams(e,t)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions[`stroke-opacity`]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty(`stroke-width`),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty(`stroke-width`),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:n,opacity:r}){this._drawingOptions=e.getDefaultDrawingOptions({stroke:z.makeHexColor(...t),"stroke-width":n,"stroke-opacity":r})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":i,"stroke-width":a}}=this,o=Object.assign(super.serialize(e),{color:W._colorManager.convert(r),opacity:i,thickness:a,paths:{lines:t,points:n}});return this.addComment(o),e?(o.isCopy=!0,o):this.annotationElementId&&!f(uv,this,fv).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t,popup:this.comment}),null}};function fv(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}g(dv,`_type`,`ink`),g(dv,`_editorType`,M.INK),g(dv,`_defaultDrawingOptions`,null);var pv=class extends iv{toSVGPath(){let e=super.toSVGPath();return e.endsWith(`Z`)||(e+=`Z`),e}},mv=8,hv=3,gv=class e{static extractContoursFromText(t,{fontFamily:n,fontStyle:r,fontWeight:i},a,o,s,c){let l=new OffscreenCanvas(1,1),u=l.getContext(`2d`,{alpha:!1}),d=u.font=`${r} ${i} 200px ${n}`,{actualBoundingBoxLeft:p,actualBoundingBoxRight:m,actualBoundingBoxAscent:h,actualBoundingBoxDescent:g,fontBoundingBoxAscent:_,fontBoundingBoxDescent:v,width:y}=u.measureText(t),b=1.5,x=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||0,y)*b),S=Math.ceil(Math.max(Math.abs(h)+Math.abs(g)||200,Math.abs(_)+Math.abs(v)||200)*b);l=new OffscreenCanvas(x,S),u=l.getContext(`2d`,{alpha:!0,willReadFrequently:!0}),u.font=d,u.filter=`grayscale(1)`,u.fillStyle=`white`,u.fillRect(0,0,x,S),u.fillStyle=`black`,u.fillText(t,x*(b-1)/2,S*(3-b)/2);let C=f(e,this,Tv).call(this,u.getImageData(0,0,x,S).data),w=f(e,this,wv).call(this,C),T=f(e,this,Ev).call(this,w),E=f(e,this,bv).call(this,C,x,S,T);return this.processDrawnLines({lines:{curves:E,width:x,height:S},pageWidth:a,pageHeight:o,rotation:s,innerMargin:c,mustSmooth:!0,areContours:!0})}static process(t,n,r,i,a){let[o,s,c]=f(e,this,Dv).call(this,t),[l,u]=f(e,this,Cv).call(this,o,s,c,Math.hypot(s,c)*f(e,this,Ov)._.sigmaSFactor,f(e,this,Ov)._.sigmaR,f(e,this,Ov)._.kernelSize),d=f(e,this,Ev).call(this,u),p=f(e,this,bv).call(this,l,s,c,d);return this.processDrawnLines({lines:{curves:p,width:s,height:c},pageWidth:n,pageHeight:r,rotation:i,innerMargin:a,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:n,pageHeight:r,rotation:i,innerMargin:a,mustSmooth:o,areContours:s}){var c;i%180!=0&&([n,r]=[r,n]);let{curves:l,width:u,height:d}=t,p=(c=t.thickness)==null?0:c,m=[],h=Math.min(n/u,r/d),g=h/n,_=h/r,v=[];for(let{points:t}of l){let n=o?f(e,this,Sv).call(this,t):t;if(!n)continue;v.push(n);let r=n.length,i=new Float32Array(r),a=new Float32Array(3*(r===2?2:r-2));if(m.push({line:a,points:i}),r===2){i[0]=n[0]*g,i[1]=n[1]*_,a.set([NaN,NaN,NaN,NaN,i[0],i[1]],0);continue}let[s,c,l,u]=n;s*=g,c*=_,l*=g,u*=_,i.set([s,c,l,u],0),a.set([NaN,NaN,NaN,NaN,s,c],0);for(let e=4;e<r;e+=2){let t=i[e]=n[e]*g,r=i[e+1]=n[e+1]*_;a.set(X.createBezierPoints(s,c,l,u,t,r),(e-2)*3),[s,c,l,u]=[l,u,t,r]}}if(m.length===0)return null;let y=s?new pv:new iv;return y.build(m,n,r,1,i,s?0:p,a),{outline:y,newCurves:v,areContours:s,thickness:p,width:u,height:d}}static compressSignature({outlines:e,areContours:t,thickness:n,width:r,height:i}){return v(function*(){let a=1/0,o=-1/0,s=0;for(let t of e){s+=t.length;for(let e=2,n=t.length;e<n;e++){let n=t[e]-t[e-2];a=Math.min(a,n),o=Math.max(o,n)}}let c;c=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let l=e.length,u=mv+hv*l,d=new Uint32Array(u),f=0;d[f++]=u*Uint32Array.BYTES_PER_ELEMENT+(s-2*l)*c.BYTES_PER_ELEMENT,d[f++]=0,d[f++]=r,d[f++]=i,d[f++]=+!t,d[f++]=Math.max(0,Math.floor(n==null?0:n)),d[f++]=l,d[f++]=c.BYTES_PER_ELEMENT;for(let t of e)d[f++]=t.length-2,d[f++]=t[0],d[f++]=t[1];let p=new CompressionStream(`deflate-raw`),m=p.writable.getWriter();yield m.ready,m.write(d);let h=c.prototype.constructor;for(let t of e){let e=new h(t.length-2);for(let n=2,r=t.length;n<r;n++)e[n-2]=t[n]-t[n-2];m.write(e)}return m.close(),(yield new Response(p.readable).bytes()).toBase64()})()}static decompressSignature(e){return v(function*(){try{let o=Uint8Array.fromBase64(e),{readable:s,writable:c}=new DecompressionStream(`deflate-raw`),l=c.getWriter();yield l.ready,l.write(o).then(v(function*(){yield l.ready,yield l.close()})).catch(()=>{});let u=null,d=0;var t=!1,n=!1,r;try{for(var i=E(s),a;t=!(a=yield i.next()).done;t=!1){let e=a.value;u||(u=new Uint8Array(new Uint32Array(e.buffer,0,4)[0])),u.set(e,d),d+=e.length}}catch(e){n=!0,r=e}finally{try{t&&i.return!=null&&(yield i.return())}finally{if(n)throw r}}let f=new Uint32Array(u.buffer,0,u.length>>2),p=f[1];if(p!==0)throw Error(`Invalid version: ${p}`);let m=f[2],h=f[3],g=f[4]===0,_=f[5],y=f[6],b=f[7],x=[],S=(mv+hv*y)*Uint32Array.BYTES_PER_ELEMENT,C;switch(b){case Int8Array.BYTES_PER_ELEMENT:C=new Int8Array(u.buffer,S);break;case Int16Array.BYTES_PER_ELEMENT:C=new Int16Array(u.buffer,S);break;case Int32Array.BYTES_PER_ELEMENT:C=new Int32Array(u.buffer,S);break}d=0;for(let e=0;e<y;e++){let t=f[hv*e+mv],n=new Float32Array(t+2);x.push(n);for(let t=0;t<hv-1;t++)n[t]=f[hv*e+mv+t+1];for(let e=0;e<t;e++)n[e+2]=n[e]+C[d++]}return{areContours:g,thickness:_,outlines:x,width:m,height:h}}catch(e){return F(`decompressSignature: ${e}`),null}})()}};de=gv;function _v(e,t,n,r){return n-=e,r-=t,n===0?r>0?0:4:n===1?r+6:2-r}function vv(e,t,n,r,i,a,o){let s=f(de,this,_v).call(this,n,r,i,a);for(let i=0;i<8;i++){let a=(-i+s-o+16)%8,c=f(de,this,kv)._[2*a],l=f(de,this,kv)._[2*a+1];if(e[(n+c)*t+(r+l)]!==0)return a}return-1}function yv(e,t,n,r,i,a,o){let s=f(de,this,_v).call(this,n,r,i,a);for(let i=0;i<8;i++){let a=(i+s+o+16)%8,c=f(de,this,kv)._[2*a],l=f(de,this,kv)._[2*a+1];if(e[(n+c)*t+(r+l)]!==0)return a}return-1}function bv(e,t,n,r){let i=e.length,a=new Int32Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]<=r);for(let e=1;e<n-1;e++)a[e*t]=a[e*t+t-1]=0;for(let e=0;e<t;e++)a[e]=a[t*n-1-e]=0;let o=1,s,c=[];for(let e=1;e<n-1;e++){s=1;for(let n=1;n<t-1;n++){let r=e*t+n,i=a[r];if(i===0)continue;let l=e,u=n;if(i===1&&a[r-1]===0)o+=1,--u;else if(i>=1&&a[r+1]===0)o+=1,u+=1,i>1&&(s=i);else{i!==1&&(s=Math.abs(i));continue}let d=[n,e],p=u===n+1,m={isHole:p,points:d,id:o,parent:0};c.push(m);let h;for(let e of c)if(e.id===s){h=e;break}h?h.isHole?m.parent=p?h.parent:s:m.parent=p?s:h.parent:m.parent=p?s:0;let g=f(de,this,vv).call(this,a,t,e,n,l,u,0);if(g===-1){a[r]=-o,a[r]!==1&&(s=Math.abs(a[r]));continue}let _=f(de,this,kv)._[2*g],v=f(de,this,kv)._[2*g+1],y=e+_,b=n+v;l=y,u=b;let x=e,S=n;for(;;){let i=f(de,this,yv).call(this,a,t,x,S,l,u,1);_=f(de,this,kv)._[2*i],v=f(de,this,kv)._[2*i+1];let c=x+_,p=S+v;d.push(p,c);let m=x*t+S;if(a[m+1]===0?a[m]=-o:a[m]===1&&(a[m]=o),c===e&&p===n&&x===y&&S===b){a[r]!==1&&(s=Math.abs(a[r]));break}else l=x,u=S,x=c,S=p}}}return c}function xv(e,t,n,r){if(n-t<=4){for(let i=t;i<n-2;i+=2)r.push(e[i],e[i+1]);return}let i=e[t],a=e[t+1],o=e[n-4]-i,s=e[n-3]-a,c=Math.hypot(o,s),l=o/c,u=s/c,d=l*a-u*i,p=s/o,m=1/c,h=Math.atan(p),g=Math.cos(h),_=Math.sin(h),v=m*(Math.abs(g)+Math.abs(_)),y=m*(1-v+Math.pow(v,2)),b=Math.max(Math.atan(Math.abs(_+g)*y),Math.atan(Math.abs(_-g)*y)),x=0,S=t;for(let r=t+2;r<n-2;r+=2){let t=Math.abs(d-l*e[r+1]+u*e[r]);t>x&&(S=r,x=t)}x>Math.pow(c*b,2)?(f(de,this,xv).call(this,e,t,S+2,r),f(de,this,xv).call(this,e,S,n,r)):r.push(i,a)}function Sv(e){let t=[],n=e.length;return f(de,this,xv).call(this,e,0,n,t),t.push(e[n-2],e[n-1]),t.length<=4?null:t}function Cv(e,t,n,r,i,a){let o=new Float32Array(Math.pow(a,2)),s=-2*Math.pow(r,2),c=a>>1;for(let e=0;e<a;e++){let t=Math.pow(e-c,2);for(let n=0;n<a;n++)o[e*a+n]=Math.exp((t+Math.pow(n-c,2))/s)}let l=new Float32Array(256),u=-2*Math.pow(i,2);for(let e=0;e<256;e++)l[e]=Math.exp(Math.pow(e,2)/u);let d=e.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let r=0;r<n;r++)for(let i=0;i<t;i++){let s=r*t+i,u=e[s],d=0,m=0;for(let s=0;s<a;s++){let f=r+s-c;if(!(f<0||f>=n))for(let n=0;n<a;n++){let r=i+n-c;if(r<0||r>=t)continue;let p=e[f*t+r],h=o[s*a+n]*l[Math.abs(p-u)];d+=p*h,m+=h}}let h=f[s]=Math.round(d/m);p[h]++}return[f,p]}function wv(e){let t=new Uint32Array(256);for(let n of e)t[n]++;return t}function Tv(e){let t=e.length,n=new Uint8ClampedArray(t>>2),r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t]=e[t<<2];r=Math.max(r,a),i=Math.min(i,a)}let a=255/(r-i);for(let e=0,t=n.length;e<t;e++)n[e]=(n[e]-i)*a;return n}function Ev(e){let t,n=-1/0,r=-1/0,i=e.findIndex(e=>e!==0),a=i,o=i;for(t=i;t<256;t++){let i=e[t];i>n&&(t-a>r&&(r=t-a,o=t-1),n=i,a=t)}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t}function Dv(e){let t=e,{width:n,height:r}=e,{maxDim:i}=f(de,this,Ov)._,a=n,o=r;if(n>i||r>i){let s=n,c=r,l=Math.log2(Math.max(n,r)/i),u=Math.floor(l);l=l===u?u-1:u;for(let n=0;n<l;n++){a=Math.ceil(s/2),o=Math.ceil(c/2);let n=new OffscreenCanvas(a,o);n.getContext(`2d`).drawImage(e,0,0,s,c,0,0,a,o),s=a,c=o,e!==t&&e.close(),e=n.transferToImageBitmap()}let d=Math.min(i/a,i/o);a=Math.round(a*d),o=Math.round(o*d)}let s=new OffscreenCanvas(a,o).getContext(`2d`,{willReadFrequently:!0});s.fillStyle=`white`,s.fillRect(0,0,a,o),s.filter=`grayscale(1)`,s.drawImage(e,0,0,e.width,e.height,0,0,a,o);let c=s.getImageData(0,0,a,o).data;return[f(de,this,Tv).call(this,c),a,o]}var Ov={_:{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}},kv={_:new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1])},Av=class e extends v_{constructor(){super(),super.updateProperties({fill:W._defaultLineColor,"stroke-width":0})}clone(){let t=new e;return t.updateAll(this),t}},jv=class e extends lv{constructor(e){super(e),super.updateProperties({stroke:W._defaultLineColor,"stroke-width":1})}clone(){let t=new e(this._viewParameters);return t.updateAll(this),t}},Mv=new WeakMap,Nv=new WeakMap,Pv=new WeakMap,Fv=new WeakMap,Iv=class e extends S_{constructor(e){super(T(T({},e),{},{mustBeCommitted:!0,name:`signatureEditor`})),b(this,Mv,!1),b(this,Nv,null),b(this,Pv,null),b(this,Fv,null),this._willKeepAspectRatio=!0,C(Pv,this,e.signatureData||null),C(Nv,this,null),this.defaultL10nId=`pdfjs-editor-signature-editor1`}static initialize(e,t){W.initialize(e,t),this._defaultDrawingOptions=new Av,this._defaultDrawnSignatureOptions=new jv(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!1}static get typesMap(){return L(this,`typesMap`,new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:`signature`,hasDescription:!!x(Nv,this)}}static computeTelemetryFinalData(e){var t,n;let r=e.get(`hasDescription`);return{hasAltText:(t=r.get(!0))==null?0:t,hasNoAltText:(n=r.get(!1))==null?0:n}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,n,{_isCopy:r}=this;if(r&&(this._isCopy=!1,t=this.x,n=this.y),super.render(),this._drawId===null)if(x(Pv,this)){let{lines:t,mustSmooth:n,areContours:r,description:i,uuid:a,heightInPage:o}=x(Pv,this),{rawDims:{pageWidth:s,pageHeight:c},rotation:l}=this.parent.viewport,u=gv.processDrawnLines({lines:t,pageWidth:s,pageHeight:c,rotation:l,innerMargin:e._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(u,o,i,a)}else this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:``})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:x(Nv,this)||``}));return r&&(this._isCopy=!0,this._moveAfterPaste(t,n)),this.div}setUuid(e){C(Fv,this,e),this.addEditToolbar()}getUuid(){return x(Fv,this)}get description(){return x(Nv,this)}set description(e){C(Nv,this,e),this.div&&(this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:e})),super.addEditToolbar().then(t=>{t==null||t.updateEditSignatureButton(e)}))}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:n,width:r,height:i}=x(Pv,this),a=Math.max(r,i);return{areContours:t,outline:gv.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:n,width:r,height:i},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[[`editSignature`,this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,n,r,i){let{x:a,y:o}=this,{outline:s}=C(Pv,this,t);C(Mv,this,s instanceof pv),this.description=r;let c;x(Mv,this)?c=e.getDefaultDrawingOptions():(c=e._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":s.thickness})),this._addOutlines({drawOutlines:s,drawingOptions:c});let[,l]=this.pageDimensions,u=n/l;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:`pdfjs.signature.inserted`,data:{hasBeenSaved:!!i,hasDescription:!!r}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return gv.process(t,n,r,i,e._INNER_MARGIN)}getFromText(t,n){let{rawDims:{pageWidth:r,pageHeight:i},rotation:a}=this.parent.viewport;return gv.extractContoursFromText(t,n,r,i,a,e._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return gv.processDrawnLines({lines:t,pageWidth:n,pageHeight:r,rotation:i,innerMargin:e._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:n}){t?this._drawingOptions=e.getDefaultDrawingOptions():(this._drawingOptions=e._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":n}))}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,i=Object.assign(super.serialize(e),{isSignature:!0,areContours:x(Mv,this),color:[0,0,0],thickness:x(Mv,this)?0:r});return this.addComment(i),e?(i.paths={lines:t,points:n},i.uuid=x(Fv,this),i.isCopy=!0):i.lines=t,x(Nv,this)&&(i.accessibilityData={type:`Figure`,alt:x(Nv,this)}),i}static deserializeDraw(e,t,n,r,i,a){return a.areContours?pv.deserialize(e,t,n,r,i,a):iv.deserialize(e,t,n,r,i,a)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){var a;let o=yield r().call(i,e,t,n);return C(Mv,o,e.areContours),o.description=((a=e.accessibilityData)==null?void 0:a.alt)||``,C(Fv,o,e.uuid),o})()}};g(Iv,`_type`,`signature`),g(Iv,`_editorType`,M.SIGNATURE),g(Iv,`_defaultDrawingOptions`,null);var Lv=new WeakMap,Rv=new WeakMap,zv=new WeakMap,Bv=new WeakMap,Vv=new WeakMap,Hv=new WeakMap,Uv=new WeakMap,Wv=new WeakMap,Gv=new WeakMap,Kv=new WeakMap,qv=new WeakMap,Jv=new WeakSet,Yv=class extends W{constructor(e){super(T(T({},e),{},{name:`stampEditor`})),S(this,Jv),b(this,Lv,null),b(this,Rv,null),b(this,zv,null),b(this,Bv,null),b(this,Vv,null),b(this,Hv,``),b(this,Uv,null),b(this,Wv,!1),b(this,Gv,null),b(this,Kv,!1),b(this,qv,!1),C(Bv,this,e.bitmapUrl),C(Vv,this,e.bitmapFile),this.defaultL10nId=`pdfjs-editor-stamp-editor`}static initialize(e,t){W.initialize(e,t)}static isHandlingMimeForPasting(e){return Ft.includes(e)}static paste(e,t){t.pasteEditor({mode:M.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:`stamp`,hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){var t,n;let r=e.get(`hasAltText`);return{hasAltText:(t=r.get(!0))==null?0:t,hasNoAltText:(n=r.get(!1))==null?0:n}}mlGuessAltText(e=null,t=!0){var n=this;return v(function*(){if(n.hasAltTextData())return null;let{mlManager:r}=n._uiManager;if(!r)throw Error(`No ML.`);if(!(yield r.isEnabledFor(`altText`)))throw Error(`ML isn't enabled for alt text.`);let{data:i,width:a,height:o}=e||n.copyCanvas(null,null,!0).imageData,s=yield r.guess({name:`altText`,request:{data:i,width:a,height:o,channels:i.length/(a*o)}});if(!s)throw Error(`No response from the AI service.`);if(s.error)throw Error(`Error from the AI service.`);if(s.cancel)return null;if(!s.output)throw Error(`No valid response from the AI service.`);let c=s.output;return yield n.setGuessedAltText(c),t&&!n.hasAltTextData()&&(n.altTextData={alt:c,decorative:!1}),c})()}remove(){if(x(Rv,this)){var e;C(Lv,this,null),this._uiManager.imageManager.deleteId(x(Rv,this)),(e=x(Uv,this))==null||e.remove(),C(Uv,this,null),x(Gv,this)&&(clearTimeout(x(Gv,this)),C(Gv,this,null))}super.remove()}rebuild(){if(!this.parent){x(Rv,this)&&f(Jv,this,Qv).call(this);return}super.rebuild(),this.div!==null&&(x(Rv,this)&&x(Uv,this)===null&&f(Jv,this,Qv).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(x(zv,this)||x(Lv,this)||x(Bv,this)||x(Vv,this)||x(Rv,this)||x(Wv,this))}get toolbarButtons(){return[[`altText`,this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;return this._isCopy&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.createAltText(),x(Wv,this)||(x(Lv,this)?f(Jv,this,$v).call(this):f(Jv,this,Qv).call(this)),this._isCopy&&this._moveAfterPaste(e,t),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,t){let{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(C(Rv,this,n),r&&C(Lv,this,r),C(Wv,this,!1),f(Jv,this,$v).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(x(Gv,this)!==null&&clearTimeout(x(Gv,this)),C(Gv,this,setTimeout(()=>{C(Gv,this,null),f(Jv,this,ty).call(this)},200)))}copyCanvas(e,t,n=!1){e||(e=224);let{width:r,height:i}=x(Lv,this),a=new Pt,o=x(Lv,this),s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e),c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);x(Kv,this)||(o=f(Jv,this,ey).call(this,e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,p=`#cfcfd8`;this._uiManager.hcmFilter===`none`?It.isDarkMode&&(d=`#8f8f9d`,p=`#42414d`):p=`black`;let m=15*a.sx,h=15*a.sy,g=new OffscreenCanvas(m*2,h*2),_=g.getContext(`2d`);_.fillStyle=d,_.fillRect(0,0,m*2,h*2),_.fillStyle=p,_.fillRect(0,0,m,h),_.fillRect(m,h,m,h),u.fillStyle=u.createPattern(g,`repeat`),u.fillRect(0,0,e,n),u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e)t=o.width,n=o.height;else if(o=x(Lv,this),r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a),n=Math.floor(i*a),x(Kv,this)||(o=f(Jv,this,ey).call(this,t,n))}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n),u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let a=null,o=!1;if(e instanceof eh){var s;let{data:{rect:r,rotation:i,id:c,structParent:l,popupRef:u,richText:d,contentsObj:f,creationDate:p,modificationDate:m},container:h,parent:{page:{pageNumber:g}},canvas:_}=e,v,y;_?(delete e.canvas,{id:v,bitmap:y}=n.imageManager.getFromCanvas(h.id,_),_.remove()):(o=!0,e._hasNoCanvas=!0);let b=((s=yield t._structTree.getAriaAttributes(`${Te}${c}`))==null?void 0:s.get(`aria-label`))||``;a=e={annotationType:M.STAMP,bitmapId:v,bitmap:y,pageIndex:g-1,rect:r.slice(0),rotation:i,annotationElementId:c,id:c,deleted:!1,accessibilityData:{decorative:!1,altText:b},isSvg:!1,structParent:l,popupRef:u,richText:d,comment:(f==null?void 0:f.str)||null,creationDate:p,modificationDate:m}}let c=yield r().call(i,e,t,n),{rect:l,bitmap:u,bitmapUrl:d,bitmapId:f,isSvg:p,accessibilityData:m}=e;o?(n.addMissingCanvas(e.id,c),C(Wv,c,!0)):f&&n.imageManager.isValidId(f)?(C(Rv,c,f),u&&C(Lv,c,u)):C(Bv,c,d),C(Kv,c,p);let[h,g]=c.pageDimensions;return c.width=(l[2]-l[0])/h,c.height=(l[3]-l[1])/g,m&&(c.altTextData=m),c._initialData=a,e.comment&&c.setCommentData(e),C(qv,c,!!a),c})()}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=Object.assign(super.serialize(e),{bitmapId:x(Rv,this),isSvg:x(Kv,this)});if(this.addComment(n),e)return n.bitmapUrl=f(Jv,this,ny).call(this,!0),n.accessibilityData=this.serializeAltText(!0),n.isCopy=!0,n;let{decorative:r,altText:i}=this.serializeAltText(!1);if(!r&&i&&(n.accessibilityData={type:`Figure`,alt:i}),this.annotationElementId){let e=f(Jv,this,ry).call(this,n);if(e.isSame)return null;if(e.isSameAltText)delete n.accessibilityData;else{var a;n.accessibilityData.structParent=(a=this._initialData.structParent)==null?-1:a}return n.id=this.annotationElementId,delete n.bitmapId,n}if(t===null)return n;t.stamps||(t.stamps=new Map);let o=x(Kv,this)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!t.stamps.has(x(Rv,this)))t.stamps.set(x(Rv,this),{area:o,serialized:n}),n.bitmap=f(Jv,this,ny).call(this,!1);else if(x(Kv,this)){let e=t.stamps.get(x(Rv,this));o>e.area&&(e.area=o,e.serialized.bitmap.close(),e.serialized.bitmap=f(Jv,this,ny).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}};function Xv(e,t=!1){if(!e){this.remove();return}C(Lv,this,e.bitmap),t||(C(Rv,this,e.id),C(Kv,this,e.isSvg)),e.file&&C(Hv,this,e.file.name),f(Jv,this,$v).call(this)}function Zv(){if(C(zv,this,null),this._uiManager.enableWaiting(!1),x(Uv,this)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&x(Lv,this)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&x(Lv,this)){this._reportTelemetry({action:`pdfjs.image.image_added`,data:{alt_text_modal:!1,alt_text_type:`empty`}});try{this.mlGuessAltText()}catch(e){}}this.div.focus()}}function Qv(){var e=this;if(x(Rv,this)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(x(Rv,this)).then(e=>f(Jv,this,Xv).call(this,e,!0)).finally(()=>f(Jv,this,Zv).call(this));return}if(x(Bv,this)){let e=x(Bv,this);C(Bv,this,null),this._uiManager.enableWaiting(!0),C(zv,this,this._uiManager.imageManager.getFromUrl(e).then(e=>f(Jv,this,Xv).call(this,e)).finally(()=>f(Jv,this,Zv).call(this)));return}if(x(Vv,this)){let e=x(Vv,this);C(Vv,this,null),this._uiManager.enableWaiting(!0),C(zv,this,this._uiManager.imageManager.getFromFile(e).then(e=>f(Jv,this,Xv).call(this,e)).finally(()=>f(Jv,this,Zv).call(this)));return}let t=document.createElement(`input`);t.type=`file`,t.accept=Ft.join(`,`);let n=this._uiManager._signal;C(zv,this,new Promise(r=>{t.addEventListener(`change`,v(function*(){if(!t.files||t.files.length===0)e.remove();else{e._uiManager.enableWaiting(!0);let n=yield e._uiManager.imageManager.getFromFile(t.files[0]);e._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:e._uiManager.useNewAltTextFlow}}),f(Jv,e,Xv).call(e,n)}r()}),{signal:n}),t.addEventListener(`cancel`,()=>{this.remove(),r()},{signal:n})}).finally(()=>f(Jv,this,Zv).call(this))),t.click()}function $v(){var e;let{div:t}=this,{width:n,height:r}=x(Lv,this),[i,a]=this.pageDimensions,o=.75;if(this.width)n=this.width*i,r=this.height*a;else if(n>o*i||r>o*a){let e=Math.min(o*i/n,o*a/r);n*=e,r*=e}this._uiManager.enableWaiting(!1);let s=C(Uv,this,document.createElement(`canvas`));s.setAttribute(`role`,`img`),this.addContainer(s),this.width=n/i,this.height=r/a,this.setDims(),(e=this._initialOptions)!=null&&e.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),f(Jv,this,ty).call(this),x(qv,this)||(this.parent.addUndoableEditor(this),C(qv,this,!0)),this._reportTelemetry({action:`inserted_image`}),x(Hv,this)&&this.div.setAttribute(`aria-description`,x(Hv,this)),this.annotationElementId||this._uiManager.a11yAlert(W._l10nAlert.stamp)}function ey(e,t){let{width:n,height:r}=x(Lv,this),i=n,a=r,o=x(Lv,this);for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=Math.ceil(i/2)),a>2*t&&(a=Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a),o=s.transferToImageBitmap()}return o}function ty(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new Pt,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=x(Uv,this);if(!s||s.width===a&&s.height===o)return;s.width=a,s.height=o;let c=x(Kv,this)?x(Lv,this):f(Jv,this,ey).call(this,a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter,l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}function ny(e){if(e){if(x(Kv,this)){let e=this._uiManager.imageManager.getSvgUrl(x(Rv,this));if(e)return e}let e=document.createElement(`canvas`);return{width:e.width,height:e.height}=x(Lv,this),e.getContext(`2d`).drawImage(x(Lv,this),0,0),e.toDataURL()}if(x(Kv,this)){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*pt.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*pt.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);return i.getContext(`2d`).drawImage(x(Lv,this),0,0,x(Lv,this).width,x(Lv,this).height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(x(Lv,this))}function ry(e){var t;let{pageIndex:n,accessibilityData:{altText:r}}=this._initialData,i=e.pageIndex===n,a=(((t=e.accessibilityData)==null?void 0:t.alt)||``)===r;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}}g(Yv,`_type`,`stamp`),g(Yv,`_editorType`,M.STAMP);var iy=new WeakMap,ay=new WeakMap,oy=new WeakMap,sy=new WeakMap,cy=new WeakMap,ly=new WeakMap,uy=new WeakMap,dy=new WeakMap,fy=new WeakMap,py=new WeakMap,my=new WeakMap,hy=new WeakMap,gy=new WeakMap,_y=new WeakMap,vy=new WeakMap,$=new WeakMap,yy=new WeakSet,by=class e{constructor({uiManager:t,pageIndex:n,div:r,structTreeLayer:i,accessibilityManager:a,annotationLayer:o,drawLayer:s,textLayer:c,viewport:l,l10n:u}){S(this,yy),b(this,iy,void 0),b(this,ay,!1),b(this,oy,null),b(this,sy,null),b(this,cy,null),b(this,ly,new Map),b(this,uy,!1),b(this,dy,!1),b(this,fy,!1),b(this,py,null),b(this,my,null),b(this,hy,null),b(this,gy,null),b(this,_y,null),b(this,vy,-1),b(this,$,void 0);let d=[...Dy._.values()];if(!e._initialized){e._initialized=!0;for(let e of d)e.initialize(u,t)}t.registerEditorTypes(d),C($,this,t),this.pageIndex=n,this.div=r,C(iy,this,a),C(oy,this,o),this.viewport=l,C(hy,this,c),this.drawLayer=s,this._structTree=i,x($,this).addLayer(this)}get isEmpty(){return x(ly,this).size===0}get isInvisible(){return this.isEmpty&&x($,this).getMode()===M.NONE}updateToolbar(e){x($,this).updateToolbar(e)}updateMode(e=x($,this).getMode()){switch(f(yy,this,Ey).call(this),e){case M.NONE:this.div.classList.toggle(`nonEditing`,!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case M.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case M.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;if(t.toggle(`nonEditing`,!1),e===M.POPUP)t.toggle(`commentEditing`,!0);else{t.toggle(`commentEditing`,!1);for(let n of Dy._.values())t.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=x(hy,this))==null?void 0:t.div)}setEditingState(e){x($,this).setEditingState(e)}addCommands(e){x($,this).addCommands(e)}cleanUndoStack(e){x($,this).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=x(oy,this))==null||t.togglePointerEvents(e)}enable(){var e=this;return v(function*(){var t;C(fy,e,!0),e.div.tabIndex=0,e.togglePointerEvents(!0),e.div.classList.toggle(`nonEditing`,!1),(t=x(_y,e))==null||t.abort(),C(_y,e,null);let n=new Set;for(let t of xy.call(f(yy,e)))t.enableEditing(),t.show(!0),t.annotationElementId&&(x($,e).removeChangedExistingAnnotation(t),n.add(t.annotationElementId));let r=x(oy,e);if(r)for(let t of r.getEditableAnnotations()){if(t.hide(),x($,e).isDeletedAnnotationElement(t.data.id)||n.has(t.data.id))continue;let r=yield e.deserialize(t);r&&(e.addOrRebuild(r),r.enableEditing())}C(fy,e,!1),x($,e)._eventBus.dispatch(`editorsrendered`,{source:e,pageNumber:e.pageIndex+1})})()}disable(){if(C(dy,this,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle(`nonEditing`,!0),x(hy,this)&&!x(_y,this)){C(_y,this,new AbortController);let e=x($,this).combinedSignal(x(_y,this));x(hy,this).div.addEventListener(`pointerdown`,e=>{let{clientX:t,clientY:n,timeStamp:r}=e;if(r-x(vy,this)>500){C(vy,this,r);return}C(vy,this,-1);let{classList:i}=this.div;i.toggle(`getElements`,!0);let a=document.elementsFromPoint(t,n);if(i.toggle(`getElements`,!1),!this.div.contains(a[0]))return;let o,s=RegExp(`^${Ee}[0-9]+$`);for(let e of a)if(s.test(e.id)){o=e.id;break}if(!o)return;let c=x(ly,this).get(o);(c==null?void 0:c.annotationElementId)===null&&(Tt(e),c.dblclick(e))},{signal:e,capture:!0})}let e=x(oy,this),t=[];if(e){let r=new Map,i=new Map;for(let e of xy.call(f(yy,this))){var n;if(e.disableEditing(),!e.annotationElementId){t.push(e);continue}if(e.serialize()!==null){r.set(e.annotationElementId,e);continue}else i.set(e.annotationElementId,e);(n=this.getEditableAnnotation(e.annotationElementId))==null||n.show(),e.remove()}for(let t of e.getEditableAnnotations()){let{id:e}=t.data;if(x($,this).isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let n=i.get(e);if(n){n.resetAnnotationElement(t),n.show(!1),t.show();continue}n=r.get(e),n&&(x($,this).addChangedExistingAnnotation(n),n.renderAnnotationElement(t)&&n.show(!1)),t.show()}}f(yy,this,Ey).call(this),this.isEmpty&&(this.div.hidden=!0);let{classList:r}=this.div;for(let e of Dy._.values())r.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e==null||e.updateFakeAnnotations(t),C(dy,this,!1)}getEditableAnnotation(e){var t;return((t=x(oy,this))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){x($,this).getActive()!==e&&x($,this).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=x(hy,this))!=null&&e.div&&!x(gy,this)){C(gy,this,new AbortController);let e=x($,this).combinedSignal(x(gy,this));x(hy,this).div.addEventListener(`pointerdown`,f(yy,this,Sy).bind(this),{signal:e}),x(hy,this).div.classList.add(`highlighting`)}}disableTextSelection(){var e;this.div.tabIndex=0,(e=x(hy,this))!=null&&e.div&&x(gy,this)&&(x(gy,this).abort(),C(gy,this,null),x(hy,this).div.classList.remove(`highlighting`))}enableClick(){if(x(sy,this))return;C(sy,this,new AbortController);let e=x($,this).combinedSignal(x(sy,this));this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener(`pointerup`,t,{signal:e}),this.div.addEventListener(`pointercancel`,t,{signal:e})}disableClick(){var e;(e=x(sy,this))==null||e.abort(),C(sy,this,null)}attach(e){x(ly,this).set(e.id,e);let{annotationElementId:t}=e;t&&x($,this).isDeletedAnnotationElement(t)&&x($,this).removeDeletedAnnotationElement(e)}detach(e){var t;x(ly,this).delete(e.id),(t=x(iy,this))==null||t.removePointerInTextLayer(e.contentDiv),!x(dy,this)&&e.annotationElementId&&x($,this).addDeletedAnnotationElement(e)}remove(e){this.detach(e),x($,this).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(x($,this).addDeletedAnnotationElement(e),W.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),x($,this).addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!x(fy,this)),x($,this).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var t;if(!e.isAttachedToDOM)return;let{activeElement:n}=document;e.div.contains(n)&&!x(cy,this)&&(e._focusEventsAllowed=!1,C(cy,this,setTimeout(()=>{C(cy,this,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:x($,this)._signal}),n.focus())},0))),e._structTreeParentId=(t=x(iy,this))==null?void 0:t.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(let t of x(ly,this).values())if(t.uid===e)return t;return null}combinedSignal(e){return x($,this).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=Cy.call(f(yy,this)))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){var n=this;return v(function*(){n.updateToolbar(e),yield x($,n).updateMode(e.mode);let{offsetX:r,offsetY:i}=f(yy,n,Ty).call(n),a=x($,n).getId(),o=f(yy,n,wy).call(n,T({parent:n,id:a,x:r,y:i,uiManager:x($,n),isCentered:!0},t));o&&n.add(o)})()}deserialize(e){var t=this;return v(function*(){var n,r;return(yield(n=Dy._.get((r=e.annotationType)==null?e.annotationEditorType:r))==null?void 0:n.deserialize(e,t,x($,t)))||null})()}createAndAddNewEditor(e,t,n={}){let r=x($,this).getId(),i=f(yy,this,wy).call(this,T({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:x($,this),isCentered:t},n));return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(e={}){this.createAndAddNewEditor(f(yy,this,Ty).call(this),!0,e)}setSelected(e){x($,this).setSelected(e)}toggleSelected(e){x($,this).toggleSelected(e)}unselect(e){x($,this).unselect(e)}pointerup(e){var t;let{isMac:n}=R.platform;if(e.button!==0||e.ctrlKey&&n||e.target!==this.div||!x(uy,this)||(C(uy,this,!1),(t=Cy.call(f(yy,this)))!=null&&t.isDrawer&&Cy.call(f(yy,this)).supportMultipleDrawings))return;if(!x(ay,this)){C(ay,this,!0);return}let r=x($,this).getMode();if(r===M.STAMP||r===M.POPUP||r===M.SIGNATURE){x($,this).unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){var t;if(x($,this).getMode()===M.HIGHLIGHT&&this.enableTextSelection(),x(uy,this)){C(uy,this,!1);return}let{isMac:n}=R.platform;if(e.button!==0||e.ctrlKey&&n||e.target!==this.div)return;if(C(uy,this,!0),(t=Cy.call(f(yy,this)))!=null&&t.isDrawer){this.startDrawingSession(e);return}let r=x($,this).getActive();C(ay,this,!r||r.isEmpty())}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),x(py,this)){Cy.call(f(yy,this)).startDrawing(this,x($,this),!1,e);return}x($,this).setCurrentDrawingSession(this),C(py,this,new AbortController);let t=x($,this).combinedSignal(x(py,this));this.div.addEventListener(`blur`,({relatedTarget:e})=>{e&&!this.div.contains(e)&&(C(my,this,null),this.commitOrRemove())},{signal:t}),Cy.call(f(yy,this)).startDrawing(this,x($,this),!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&C(my,this,e);return}x(my,this)&&setTimeout(()=>{var e;(e=x(my,this))==null||e.focus(),C(my,this,null)},0)}endDrawingSession(e=!1){return x(py,this)?(x($,this).setCurrentDrawingSession(null),x(py,this).abort(),C(py,this,null),C(my,this,null),Cy.call(f(yy,this)).endDrawing(e)):null}findNewParent(e,t,n){let r=x($,this).findParent(t,n);return r===null||r===this?!1:(r.changeParent(e),!0)}commitOrRemove(){return x(py,this)?(this.endDrawingSession(),!0):!1}onScaleChanging(){x(py,this)&&Cy.call(f(yy,this)).onScaleChangingWhenDrawing(this)}destroy(){var e;this.commitOrRemove(),((e=x($,this).getActive())==null?void 0:e.parent)===this&&(x($,this).commitOrRemove(),x($,this).setActiveEditor(null)),x(cy,this)&&(clearTimeout(x(cy,this)),C(cy,this,null));for(let e of x(ly,this).values()){var t;(t=x(iy,this))==null||t.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove()}this.div=null,x(ly,this).clear(),x($,this).removeLayer(this)}render({viewport:e}){var t=this;return v(function*(){t.viewport=e,Nt(t.div,e);for(let e of x($,t).getEditors(t.pageIndex))t.add(e),e.rebuild();yield x($,t).findClonesForPage(t),t.div.hidden=t.isEmpty,t.updateMode()})()}update({viewport:e}){x($,this).commitOrRemove(),f(yy,this,Ey).call(this);let t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Nt(this.div,{rotation:n}),t!==n)for(let e of x(ly,this).values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return x($,this).viewParameters.realScale}};function xy(){return x(ly,this).size===0?x($,this).getEditors(this.pageIndex):x(ly,this).values()}function Sy(e){x($,this).unselectAll();let{target:t}=e;if(t===x(hy,this).div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`)||t.classList.contains(`textLayerImages`)||t.classList.contains(`textLayerImagePlaceholder`))&&x(hy,this).div.contains(t)){let{isMac:t}=R.platform;if(e.button!==0||e.ctrlKey&&t)return;x($,this).showAllEditors(`highlight`,!0,!0),x(hy,this).div.classList.add(`free`),this.toggleDrawing(),e_.startHighlighting(this,x($,this).direction===`ltr`,{target:x(hy,this).div,x:e.x,y:e.y}),x(hy,this).div.addEventListener(`pointerup`,()=>{x(hy,this).div.classList.remove(`free`),this.toggleDrawing(!0)},{once:!0,signal:x($,this)._signal}),e.preventDefault()}}function Cy(){return Dy._.get(x($,this).getMode())}function wy(e){let t=Cy.call(f(yy,this));return t?new t.prototype.constructor(e):null}function Ty(){let{x:e,y:t,width:n,height:r}=this.boundingClientRect,i=Math.max(0,e),a=Math.max(0,t),o=Math.min(window.innerWidth,e+n),s=Math.min(window.innerHeight,t+r),c=(i+o)/2-e,l=(a+s)/2-t,[u,d]=this.viewport.rotation%180==0?[c,l]:[l,c];return{offsetX:u,offsetY:d}}function Ey(){for(let e of x(ly,this).values())e.isEmpty()&&e.remove()}g(by,`_initialized`,!1);var Dy={_:new Map([Ah,dv,Yv,e_,Iv].map(e=>[e._editorType,e]))};function Oy(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ky(e){var t;return e?e.nodeType===Node.ELEMENT_NODE?e.closest(`.textLayer`):((t=e.parentElement)==null?void 0:t.closest(`.textLayer`))||null:null}function Ay(e,t,n,r){if(e===n)return t<=r;let i=e.compareDocumentPosition(n);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function jy(e,t,n){if(e.nodeType!==Node.ELEMENT_NODE||!e.classList.contains(`textLayer`)||t!==e.childNodes.length)return{container:e,offset:t};let r=e.lastChild;return(r==null?void 0:r.nodeType)===Node.ELEMENT_NODE&&r.classList.contains(`endOfContent`)&&(r=r.previousSibling),!r||!n.contains(r)?null:r.nodeType===Node.TEXT_NODE?{container:r,offset:r.textContent.length}:{container:r,offset:r.childNodes.length}}var My=new WeakMap,Ny=new WeakMap,Py=new WeakMap,Fy=new WeakMap,Iy=new WeakMap,Ly=new WeakMap,Ry=new WeakMap,zy=new WeakSet,By=class e{constructor({filterFactory:t=null,pageColors:n=null,pageIndex:r,textLayer:i=null}){if(S(this,zy),b(this,My,null),b(this,Ny,new Map),b(this,Py,null),b(this,Fy,null),b(this,Iy,null),b(this,Ly,null),b(this,Ry,new Map),this.pageIndex=r,C(Fy,this,t),C(Iy,this,n),i){let t=tb._.get(i);if(t!=null&&t.selectionDiv&&(t.selectionDiv.remove(),Qy._.delete(t.selectionDiv)),tb._.set(i,{drawLayer:this}),eb._.add(i),C(Py,this,i),C(Ly,this,new MutationObserver(t=>{var n;if(!(!x(My,this)||!((n=x(Py,this))!=null&&n.isConnected)||!Hy.call(e))){for(let{addedNodes:n}of t)for(let t of n)if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains(`endOfContent`)){Wy.call(e);return}}})),x(Ly,this).observe(i,{childList:!0}),Zy._===null){Zy._=new AbortController;let{signal:t}=Zy._;document.addEventListener(`selectionchange`,Wy.bind(e),{signal:t}),document.addEventListener(`pointerdown`,()=>{$y._=!0},{signal:t}),document.addEventListener(`pointerup`,()=>{$y._=!1},{signal:t}),window.addEventListener(`blur`,()=>{$y._=!1},{signal:t})}}}setParent(t){if(!x(My,this)){var n;C(My,this,t),(n=x(Py,this))!=null&&n.isConnected&&Hy.call(e)&&Wy.call(e);return}if(x(My,this)!==t){if(x(Ny,this).size>0)for(let e of x(Ny,this).values())e.remove(),t.append(e);C(My,this,t)}}static get _svgFactory(){return L(this,`_svgFactory`,new bp)}draw(t,n=!1,r=!1){var i,a;let o=(Yy._=(i=Yy._,a=i++,i),a),s=f(zy,this,Ky).call(this),c=e._svgFactory.createElement(`defs`);s.append(c);let l=e._svgFactory.createElement(`path`);c.append(l);let u=`path_${o}`;l.setAttribute(`id`,u),l.setAttribute(`vector-effect`,`non-scaling-stroke`),n&&x(Ry,this).set(o,l);let d=r?f(zy,this,qy).call(this,c,u):null,p=e._svgFactory.createElement(`use`);return s.append(p),p.setAttribute(`href`,`#${u}`),this.updateProperties(s,t),x(Ny,this).set(o,s),{id:o,clipPathId:`url(#${d})`}}drawOutline(t,n){var r,i;let a=(Yy._=(r=Yy._,i=r++,r),i),o=f(zy,this,Ky).call(this),s=e._svgFactory.createElement(`defs`);o.append(s);let c=e._svgFactory.createElement(`path`);s.append(c);let l=`path_${a}`;c.setAttribute(`id`,l),c.setAttribute(`vector-effect`,`non-scaling-stroke`);let u;if(n){let t=e._svgFactory.createElement(`mask`);s.append(t),u=`mask_${a}`,t.setAttribute(`id`,u),t.setAttribute(`maskUnits`,`objectBoundingBox`);let n=e._svgFactory.createElement(`rect`);t.append(n),n.setAttribute(`width`,`1`),n.setAttribute(`height`,`1`),n.setAttribute(`fill`,`white`);let r=e._svgFactory.createElement(`use`);t.append(r),r.setAttribute(`href`,`#${l}`),r.setAttribute(`stroke`,`none`),r.setAttribute(`fill`,`black`),r.setAttribute(`fill-rule`,`nonzero`),r.classList.add(`mask`)}let d=e._svgFactory.createElement(`use`);o.append(d),d.setAttribute(`href`,`#${l}`),u&&d.setAttribute(`mask`,`url(#${u})`);let p=d.cloneNode();return o.append(p),d.classList.add(`mainOutline`),p.classList.add(`secondaryOutline`),this.updateProperties(o,t),x(Ny,this).set(a,o),a}finalizeDraw(e,t){x(Ry,this).delete(e),this.updateProperties(e,t)}updateProperties(t,n){if(!n)return;let{root:r,bbox:i,rootClass:a,path:o}=n,s=typeof t==`number`?x(Ny,this).get(t):t;if(s){if(r&&f(zy,this,Jy).call(this,s,r),i&&Gy.call(e,s,i),a){let{classList:e}=s;for(let[t,n]of Object.entries(a))e.toggle(t,n)}if(o){let e=s.firstElementChild.firstElementChild;f(zy,this,Jy).call(this,e,o)}}}updateParent(e,t){if(t===this)return;let n=x(Ny,this).get(e);n&&(x(My,t).append(n),x(Ny,this).delete(e),x(Ny,t).set(e,n))}remove(e){x(Ry,this).delete(e),x(My,this)!==null&&(x(Ny,this).get(e).remove(),x(Ny,this).delete(e))}destroy(){var t;C(My,this,null);for(let e of x(Ny,this).values())e.remove();if(x(Ny,this).clear(),x(Ry,this).clear(),(t=x(Ly,this))==null||t.disconnect(),C(Ly,this,null),x(Py,this)){let t=tb._.get(x(Py,this));if((t==null?void 0:t.drawLayer)===this&&(Vy.call(e,x(Py,this)),tb._.delete(x(Py,this)),eb._.delete(x(Py,this)),eb._.size===0)){var n;(n=Zy._)==null||n.abort(),Zy._=null,$y._=!1}C(Py,this,null)}}};fe=By;function Vy(e){let t=f(fe,this,tb)._.get(e);t!=null&&t.selectionDiv&&(t.selectionDiv.remove(),f(fe,this,Qy)._.delete(t.selectionDiv),t.selectionDiv=null,t.path=null)}function Hy(){let e=document.getSelection();return!!e&&!e.isCollapsed}function Uy(){return[...f(fe,this,eb)._].filter(e=>e.isConnected).sort(Oy)}function Wy(){let e=document.getSelection();if(!e||e.isCollapsed){for(let e of f(fe,this,Qy)._)e.remove();f(fe,this,Qy)._.clear();return}let t=new WeakMap,n=f(fe,this,Uy).call(this),r=[];for(let t=0,i=e.rangeCount;t<i;t++){let i=e.getRangeAt(t);if(i.collapsed)continue;let{startContainer:a,startOffset:o,endContainer:s,endOffset:c}=i,l=ky(a),u=ky(s),d=l===null,p=u===null;if(f(fe,this,$y)._&&d!==p)return;if(e.rangeCount===1){let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:i}=e,d=ky(t),f=ky(r),p=Ay(t,n,r,i);d&&f&&p!==null&&(p?(a=t,o=n,l=d,s=r,c=i,u=f):(a=r,o=i,l=f,s=t,c=n,u=d))}let m=n.filter(e=>i.intersectsNode(e));if(m.length===0)continue;let h=!1;if(l||(l=m[0],a=l,o=0,h=!0),u||(u=m.at(-1),s=u,c=u.childNodes.length,h=!0),s.nodeType===Node.ELEMENT_NODE){if(s.classList.contains(`endOfContent`)){let e=s.previousSibling;if(!e)continue;s=e,c=e.nodeType===Node.TEXT_NODE?e.textContent.length:e.childNodes.length}else if(s.classList.contains(`textLayer`)&&s.childNodes.length===c){let e=jy(s,c,u);if(!e)continue;s=e.container,c=e.offset}}if(a.nodeType===Node.ELEMENT_NODE){let e=jy(a,o,l);if(!e)continue;a=e.container,o=e.offset}if(l===u&&!h&&m.includes(l)){r.push([i,l]);continue}for(let e of m){let t=e.firstChild;if(!t)continue;let n=document.createRange();if(e===l?n.setStart(a,o):n.setStartBefore(t),e===u)n.setEnd(s,c);else{let t=e.lastChild;if(!t)continue;if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains(`endOfContent`)){let e=t.previousSibling;if(!e)continue;n.setEndAfter(e)}else n.setEndAfter(t)}n.collapsed||r.push([n,e])}}let i=new Set(r.map(e=>e[1]));for(let e of f(fe,this,eb)._)i.has(e)||f(fe,this,Vy).call(this,e);for(let[e,n]of r){let r=tb._.get(n);if(!r)continue;let i=t.get(n);if(!i){let e=n.getBoundingClientRect();i=(t,n,r,i)=>({x:(t-e.x)/e.width,y:(n-e.y)/e.height,width:r/e.width,height:i/e.height}),t.set(n,i)}let c=[];for(let{x:t,y:n,width:r,height:a}of e.getClientRects())r===0||a===0||({x:t,y:n,width:r,height:a}=i(t,n,r,a),!(r===1&&a===1)&&c.push(`M${t} ${n} h${r} v${a} h-${r} Z`));if(c.length===0)continue;let l=r.drawLayer,u=r.selectionDiv,d=r.path;if(!u){var a,o,s;let e=`clip_selection_${Xy._=(a=Xy._,o=a++,a),o}`;u=document.createElement(`div`),u.className=`selection`,u.style.clipPath=`url(#${e})`;let t=(s=x(Fy,l))==null?void 0:s.createSelectionStyle(x(Iy,l));if(t)for(let[e,n]of Object.entries(t))u.style.setProperty(e,n);let n=fe._svgFactory.create(1,1,!0);n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`width`,`100%`),n.setAttribute(`height`,`100%`);let i=fe._svgFactory.createElement(`clipPath`);i.setAttribute(`id`,e),i.setAttribute(`clipPathUnits`,`objectBoundingBox`),d=fe._svgFactory.createElement(`path`),i.append(d),n.append(i),u.append(n),r.path=d,r.selectionDiv=u}!u.parentNode&&x(My,l)&&(x(My,l).append(u),f(fe,this,Qy)._.add(u)),d.setAttribute(`d`,c.join(` `))}}function Gy(e,[t,n,r,i]){let{style:a}=e;a.top=`${100*n}%`,a.left=`${100*t}%`,a.width=`${100*r}%`,a.height=`${100*i}%`}function Ky(){let e=fe._svgFactory.create(1,1,!0);return x(My,this).append(e),e.setAttribute(`aria-hidden`,`true`),e}function qy(e,t){let n=fe._svgFactory.createElement(`clipPath`);e.append(n);let r=`clip_${t}`;n.setAttribute(`id`,r),n.setAttribute(`clipPathUnits`,`objectBoundingBox`);let i=fe._svgFactory.createElement(`use`);return n.append(i),i.setAttribute(`href`,`#${t}`),i.classList.add(`clip`),r}function Jy(e,t){for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r)}var Yy={_:0},Xy={_:0},Zy={_:null},Qy={_:new Set},$y={_:!1},eb={_:new Set},tb={_:new WeakMap};function nb(e){return`${(e*100).toFixed(2)}%`}var rb=new WeakMap,ib=new WeakMap,ab=new WeakMap,ob=new WeakMap,sb=new WeakMap,cb=new WeakMap,lb=new WeakSet,ub=class{constructor(e,t,n,r){S(this,lb),b(this,rb,[]),b(this,ib,new Map),b(this,ab,null),b(this,ob,0),b(this,sb,0),b(this,cb,0),C(ob,this,e),C(rb,this,t),C(sb,this,n.rawDims.pageWidth),C(cb,this,n.rawDims.pageHeight),C(ab,this,r)}render(){let e=document.createElement(`div`);e.className=`textLayerImages`;for(let t=0;t<x(rb,this).length;t+=6){let n=f(lb,this,db).call(this,x(rb,this).subarray(t,t+6));n&&e.append(n)}return e.addEventListener(`contextmenu`,e=>{var t;if(!(e.target instanceof HTMLCanvasElement))return;let n=e.target,r=x(ib,this).get(n);if(!r)return;let i=(t=fb._)==null?void 0:t.deref();if(i===n)return;i&&(i.width=0,i.height=0),fb._=new WeakRef(n);let{inverseTransform:a,x1:o,y1:s,width:c,height:l}=r,u=x(ab,this).call(this),d=Math.ceil(o*u.width),f=Math.ceil(s*u.height),p=Math.floor((o+c/x(sb,this))*u.width),m=Math.floor((s+l/x(cb,this))*u.height);n.width=p-d,n.height=m-f;let h=n.getContext(`2d`);h.setTransform(...a),h.translate(-d,-f),h.drawImage(u,0,0)}),e}};function db([e,t,n,r,i,a]){let o=Math.hypot((i-e)*x(sb,this),(a-t)*x(cb,this)),s=Math.hypot((n-e)*x(sb,this),(r-t)*x(cb,this));if(o<x(ob,this)||s<x(ob,this))return null;let c=[(i-e)*x(sb,this)/o,(a-t)*x(cb,this)/o,(n-e)*x(sb,this)/s,(r-t)*x(cb,this)/s,0,0],l=z.inverseTransform(c),u=document.createElement(`canvas`);return u.className=`textLayerImagePlaceholder`,u.width=0,u.height=0,Object.assign(u.style,{opacity:0,position:`absolute`,left:nb(e),top:nb(t),width:nb(o/x(sb,this)),height:nb(s/x(cb,this)),transformOrigin:`0% 0%`,transform:`matrix(${c.join(`,`)})`}),x(ib,this).set(u,{inverseTransform:l,width:o,height:s,x1:e,y1:t}),u}var fb={_:null};globalThis._pdfjsTestingUtils={HighlightOutliner:Tg},globalThis.pdfjsLib={AbortException:Xe,AnnotationEditorLayer:by,AnnotationEditorParamsType:N,AnnotationEditorType:M,AnnotationEditorUIManager:Rr,AnnotationLayer:xh,AnnotationMode:we,AnnotationType:Ae,applyOpacity:Rt,build:Wf,ColorPicker:np,createValidAbsoluteUrl:Ve,CSSConstants:Lt,DOMSVGFactory:bp,DrawLayer:By,FeatureTest:R,fetchData:mt,findContrastColor:Wt,getDocument:tf,getFilenameFromUrl:yt,getPdfFilenameFromUrl:bt,getRGB:kt,getRGBA:Ot,getUuid:at,GlobalWorkerOptions:Bu,ImageKind:ke,InvalidPDFException:qe,isDataScheme:_t,isPdfFile:vt,isValidExplicitDest:Ps,makeArr:st,makeMap:ct,makeObj:lt,MathClamp:B,noContextMenu:wt,normalizeUnicode:it,OPS:P,OutputScale:Pt,PasswordException:Ge,PasswordResponses:Pe,PDFDataRangeTransport:sf,PDFDateString:Et,PDFWorker:yf,PermissionFlag:De,PixelsPerInch:pt,RenderingCancelledException:gt,renderRichText:Gt,ResponseException:Je,setLayerDimensions:Nt,shadow:L,SignatureExtractor:gv,stopEvent:Tt,SupportedImageMimeTypes:Ft,TextLayer:Vd,TextLayerImages:ub,TouchManager:Xi,updateUrlHash:He,Util:z,VerbosityLevel:Me,version:Uf,XfaLayer:ft};var pb=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`,mb=[`#000000`,`#475569`,`#dc2626`,`#f97316`,`#eab308`,`#16a34a`,`#2563eb`,`#7c3aed`,`#db2777`,`#ffffff`],hb=[`transparent`,`#f8fafc`,`#fee2e2`,`#ffedd5`,`#fef9c3`,`#dcfce7`,`#dbeafe`,`#f3e8ff`,`#fce7f3`,`#ffffff`],gb=e=>{let t=`font-size: ${e.fontSize}; color: ${e.color}; text-align: ${e.textAlign};`;e.fontFamily&&(t+=` font-family: ${e.fontFamily};`),t+=` font-weight: ${e.fontWeight};`,e.bold&&(t+=` font-weight: bold;`),e.italic&&(t+=` font-style: italic;`);let n=[];e.underline&&n.push(`underline`),e.strikethrough&&n.push(`line-through`),n.length>0&&(t+=` text-decoration: ${n.join(` `)};`);let r=[`fontSize`,`fontWeight`,`color`,`textAlign`,`fontFamily`,`bold`,`italic`,`underline`,`strikethrough`,`customCss`,`sameRow`];return Object.entries(e).forEach(([e,n])=>{if(r.includes(e)||n==null||n===``)return;let i=e.replace(/([A-Z])/g,`-$1`).toLowerCase();t+=` ${i}: ${n};`}),e.customCss&&(t+=` ${e.customCss}`),t},_b=e=>{if(!e||!e.trim())return{};let t={};return e.split(`;`).forEach(e=>{let n=e.split(`:`);if(n.length>=2){let e=n[0].trim().replace(/-([a-z])/g,e=>e[1].toUpperCase()),r=n.slice(1).join(`:`).trim();e&&r&&(t[e]=r)}}),t},vb=e=>{let t={0:`1010011`,1:`1101001`,2:`1100101`,3:`1001101`,4:`1011001`,5:`1010011`,6:`1101011`,7:`1101101`,8:`1001111`,9:`1110011`,A:`1100010`,B:`1000110`,C:`1100011`,D:`1011100`,E:`1001110`,F:`1110100`,G:`1110010`,H:`1101110`,I:`1100111`,J:`1011000`,K:`1000111`,L:`1100011`,M:`1011110`,N:`1111010`,O:`1110110`,P:`1110011`,Q:`1110010`,R:`1101110`,S:`1100111`,T:`1011000`,U:`1000111`,V:`1100011`,W:`1011110`,X:`1111010`,Y:`1110110`,Z:`1110011`,"-":`1001011`,_:`1101001`,".":`1100101`," ":`1001101`},n=e||`BARCODE`,r=n.toUpperCase().replace(/[^0-9A-Z\-_\. ]/g,``),i=`1101001000`;for(let e=0;e<r.length;e++){let n=r[e];i+=t[n]||`1010011`}i+=`1100011101011`;let a=i.length*2,o=``;for(let e=0;e<i.length;e++)i[e]===`1`&&(o+=`<rect x="${e*2}" y="5" width="2" height="50" fill="black" />`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} 70" width="100%" height="100%" style="display: block; margin: 0 auto;">
|
|
54
|
+
`)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`)),this.editorDiv.append(t)}}function Lh(){return x(Th,this).replaceAll(`\xA0`,` `)}function Rh(e){return e.replaceAll(` `,`\xA0`)}function zh(e){let{value:t,fontSize:n,color:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==r[t])||e.pageIndex!==i}g(Ah,`_freeTextDefaultContent`,``),g(Ah,`_internalPadding`,0),g(Ah,`_defaultColor`,null),g(Ah,`_defaultFontSize`,10),g(Ah,`_type`,`freetext`),g(Ah,`_editorType`,N.FREETEXT);var X=class{toSVGPath(){L("Abstract method `toSVGPath` must be implemented.")}get box(){L("Abstract getter `box` must be implemented.")}serialize(e,t){L("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||(a=new Float32Array(e.length));for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o]*r,a[o+1]=n+e[o+1]*i;return a}static _rescaleAndSwap(e,t,n,r,i,a){a||(a=new Float32Array(e.length));for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o+1]*r,a[o+1]=n+e[o]*i;return a}static _translate(e,t,n,r){r||(r=new Float32Array(e.length));for(let i=0,a=e.length;i<a;i+=2)r[i]=t+e[i],r[i+1]=n+e[i+1];return r}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}};g(X,`PRECISION`,1e-4);var Bh=new WeakMap,Vh=new WeakMap,Hh=new WeakMap,Uh=new WeakMap,Wh=new WeakMap,Z=new WeakMap,Gh=new WeakMap,Kh=new WeakMap,qh=new WeakMap,Jh=new WeakMap,Yh=new WeakMap,Xh=new WeakMap,Zh=new WeakMap,Qh=new WeakSet,$h=class{constructor({x:e,y:t},n,r,i,a,o=0){S(this,Qh),b(this,Bh,void 0),b(this,Vh,[]),b(this,Hh,void 0),b(this,Uh,void 0),b(this,Wh,[]),b(this,Z,new Float32Array(18)),b(this,Gh,void 0),b(this,Kh,void 0),b(this,qh,void 0),b(this,Jh,void 0),b(this,Yh,void 0),b(this,Xh,void 0),b(this,Zh,[]),C(Bh,this,n),C(Xh,this,i*r),C(Uh,this,a),x(Z,this).set([NaN,NaN,NaN,NaN,e,t],6),C(Hh,this,o),C(Jh,this,sg._*r),C(qh,this,cg._*r),C(Yh,this,r),x(Zh,this).push(e,t)}isEmpty(){return isNaN(x(Z,this)[8])}add({x:e,y:t}){var n;C(Gh,this,e),C(Kh,this,t);let[r,i,a,o]=x(Bh,this),[s,c,l,u]=x(Z,this).subarray(8,12),d=e-l,f=t-u,p=Math.hypot(d,f);if(p<x(qh,this))return!1;let m=p-x(Jh,this),h=m/p,g=h*d,_=h*f,v=s,y=c;s=l,c=u,l+=g,u+=_,(n=x(Zh,this))==null||n.push(e,t);let b=-_/m,S=g/m,w=b*x(Xh,this),T=S*x(Xh,this);return x(Z,this).set(x(Z,this).subarray(2,8),0),x(Z,this).set([l+w,u+T],4),x(Z,this).set(x(Z,this).subarray(14,18),12),x(Z,this).set([l-w,u-T],16),isNaN(x(Z,this)[6])?(x(Wh,this).length===0&&(x(Z,this).set([s+w,c+T],2),x(Wh,this).push(NaN,NaN,NaN,NaN,(s+w-r)/a,(c+T-i)/o),x(Z,this).set([s-w,c-T],14),x(Vh,this).push(NaN,NaN,NaN,NaN,(s-w-r)/a,(c-T-i)/o)),x(Z,this).set([v,y,s,c,l,u],6),!this.isEmpty()):(x(Z,this).set([v,y,s,c,l,u],6),Math.abs(Math.atan2(y-c,v-s)-Math.atan2(_,g))<Math.PI/2?([s,c,l,u]=x(Z,this).subarray(2,6),x(Wh,this).push(NaN,NaN,NaN,NaN,((s+l)/2-r)/a,((c+u)/2-i)/o),[s,c,v,y]=x(Z,this).subarray(14,18),x(Vh,this).push(NaN,NaN,NaN,NaN,((v+s)/2-r)/a,((y+c)/2-i)/o),!0):([v,y,s,c,l,u]=x(Z,this).subarray(0,6),x(Wh,this).push(((v+5*s)/6-r)/a,((y+5*c)/6-i)/o,((5*s+l)/6-r)/a,((5*c+u)/6-i)/o,((s+l)/2-r)/a,((c+u)/2-i)/o),[l,u,s,c,v,y]=x(Z,this).subarray(12,18),x(Vh,this).push(((v+5*s)/6-r)/a,((y+5*c)/6-i)/o,((5*s+l)/6-r)/a,((5*c+u)/6-i)/o,((s+l)/2-r)/a,((c+u)/2-i)/o),!0))}toSVGPath(){if(this.isEmpty())return``;let e=x(Wh,this),t=x(Vh,this);if(isNaN(x(Z,this)[6])&&!this.isEmpty())return f(Qh,this,tg).call(this);let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;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]}`);f(Qh,this,rg).call(this,n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return f(Qh,this,ng).call(this,n),n.join(` `)}newFreeDrawOutline(e,t,n,r,i,a){return new _g(e,t,n,r,i,a)}getOutlines(){var e,t;let n=x(Wh,this),r=x(Vh,this),i=x(Z,this),[a,o,s,c]=x(Bh,this),l=new Float32Array(((e=(t=x(Zh,this))==null?void 0:t.length)==null?0:e)+2);for(let e=0,t=l.length-2;e<t;e+=2)l[e]=(x(Zh,this)[e]-a)/s,l[e+1]=(x(Zh,this)[e+1]-o)/c;if(l[l.length-2]=(x(Gh,this)-a)/s,l[l.length-1]=(x(Kh,this)-o)/c,isNaN(i[6])&&!this.isEmpty())return f(Qh,this,ig).call(this,l);let u=new Float32Array(x(Wh,this).length+24+x(Vh,this).length),d=n.length;for(let e=0;e<d;e+=2){if(isNaN(n[e])){u[e]=u[e+1]=NaN;continue}u[e]=n[e],u[e+1]=n[e+1]}d=f(Qh,this,og).call(this,u,d);for(let e=r.length-6;e>=6;e-=6)for(let t=0;t<6;t+=2){if(isNaN(r[e+t])){u[d]=u[d+1]=NaN,d+=2;continue}u[d]=r[e+t],u[d+1]=r[e+t+1],d+=2}return f(Qh,this,ag).call(this,u,d),this.newFreeDrawOutline(u,l,x(Bh,this),x(Yh,this),x(Hh,this),x(Uh,this))}};function eg(){let e=x(Z,this).subarray(4,6),t=x(Z,this).subarray(16,18),[n,r,i,a]=x(Bh,this);return[(x(Gh,this)+(e[0]-t[0])/2-n)/i,(x(Kh,this)+(e[1]-t[1])/2-r)/a,(x(Gh,this)+(t[0]-e[0])/2-n)/i,(x(Kh,this)+(t[1]-e[1])/2-r)/a]}function tg(){let[e,t,n,r]=x(Bh,this),[i,a,o,s]=f(Qh,this,eg).call(this);return`M${(x(Z,this)[2]-e)/n} ${(x(Z,this)[3]-t)/r} L${(x(Z,this)[4]-e)/n} ${(x(Z,this)[5]-t)/r} L${i} ${a} L${o} ${s} L${(x(Z,this)[16]-e)/n} ${(x(Z,this)[17]-t)/r} L${(x(Z,this)[14]-e)/n} ${(x(Z,this)[15]-t)/r} Z`}function ng(e){let t=x(Vh,this);e.push(`L${t[4]} ${t[5]} Z`)}function rg(e){let[t,n,r,i]=x(Bh,this),a=x(Z,this).subarray(4,6),o=x(Z,this).subarray(16,18),[s,c,l,u]=f(Qh,this,eg).call(this);e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}function ig(e){let t=x(Z,this),[n,r,i,a]=x(Bh,this),[o,s,c,l]=f(Qh,this,eg).call(this),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0),this.newFreeDrawOutline(u,e,x(Bh,this),x(Yh,this),x(Hh,this),x(Uh,this))}function ag(e,t){let n=x(Vh,this);return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+=6}function og(e,t){let n=x(Z,this).subarray(4,6),r=x(Z,this).subarray(16,18),[i,a,o,s]=x(Bh,this),[c,l,u,d]=f(Qh,this,eg).call(this);return e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t),t+=24}var sg={_:8},cg={_:sg._+{_:2}._},lg=new WeakMap,ug=new WeakMap,dg=new WeakMap,fg=new WeakMap,pg=new WeakMap,mg=new WeakMap,hg=new WeakMap,gg=new WeakSet,_g=class extends X{constructor(e,t,n,r,i,a){super(),S(this,gg),b(this,lg,void 0),b(this,ug,new Float32Array(4)),b(this,dg,void 0),b(this,fg,void 0),b(this,pg,void 0),b(this,mg,void 0),b(this,hg,void 0),C(hg,this,e),C(pg,this,t),C(lg,this,n),C(mg,this,r),C(dg,this,i),C(fg,this,a),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],f(gg,this,vg).call(this,a);let[o,s,c,l]=x(ug,this);for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-o)/c,e[t+1]=(e[t+1]-s)/l;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-o)/c,t[e+1]=(t[e+1]-s)/l}toSVGPath(){let e=[`M${x(hg,this)[4]} ${x(hg,this)[5]}`];for(let t=6,n=x(hg,this).length;t<n;t+=6){if(isNaN(x(hg,this)[t])){e.push(`L${x(hg,this)[t+4]} ${x(hg,this)[t+5]}`);continue}e.push(`C${x(hg,this)[t]} ${x(hg,this)[t+1]} ${x(hg,this)[t+2]} ${x(hg,this)[t+3]} ${x(hg,this)[t+4]} ${x(hg,this)[t+5]}`)}return e.push(`Z`),e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=X._rescale(x(hg,this),e,r,a,-o),c=X._rescale(x(pg,this),e,r,a,-o);break;case 90:s=X._rescaleAndSwap(x(hg,this),e,t,a,o),c=X._rescaleAndSwap(x(pg,this),e,t,a,o);break;case 180:s=X._rescale(x(hg,this),n,t,-a,o),c=X._rescale(x(pg,this),n,t,-a,o);break;case 270:s=X._rescaleAndSwap(x(hg,this),n,r,-a,-o),c=X._rescaleAndSwap(x(pg,this),n,r,-a,-o);break}return{outline:Array.from(s),points:[Array.from(c)]}}get box(){return x(ug,this)}newOutliner(e,t,n,r,i,a=0){return new $h(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=x(ug,this),[o,s,c,l]=x(lg,this),u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:x(pg,this)[0]*u+f,y:x(pg,this)[1]*d+p},x(lg,this),x(mg,this),e,x(fg,this),t==null?x(dg,this):t);for(let e=2;e<x(pg,this).length;e+=2)m.add({x:x(pg,this)[e]*u+f,y:x(pg,this)[e+1]*d+p});return m.getOutlines()}};function vg(e){let t=x(hg,this),n=t[4],r=t[5],i=[n,r,n,r],a=n,o=r,s=n,c=r,l=e?Math.max:Math.min,u=new Float32Array(4);for(let e=6,d=t.length;e<d;e+=6){let d=t[e+4],f=t[e+5];isNaN(t[e])?(B.pointBoundingBox(d,f,i),o>f?(a=d,o=f):o===f&&(a=l(a,d)),c<f?(s=d,c=f):c===f&&(s=l(s,d))):(u.set(_e,0),B.bezierBoundingBox(n,r,...t.slice(e,e+6),u),B.rectBoundingBox(...u,i),o>u[1]?(a=u[0],o=u[1]):o===u[1]&&(a=l(a,u[0])),c<u[3]?(s=u[2],c=u[3]):c===u[3]&&(s=l(s,u[2]))),n=d,r=f}let d=x(ug,this);d[0]=i[0]-x(dg,this),d[1]=i[1]-x(dg,this),d[2]=i[2]-i[0]+2*x(dg,this),d[3]=i[3]-i[1]+2*x(dg,this),this.firstPoint=[a,o],this.lastPoint=[s,c]}var yg=new WeakMap,bg=new WeakMap,xg=new WeakMap,Sg=new WeakMap,Cg=new WeakMap,wg=new WeakSet,Tg=class{constructor(e,t=0,n=0,r=!0){S(this,wg),b(this,yg,void 0),b(this,bg,void 0),b(this,xg,void 0),b(this,Sg,[]),b(this,Cg,[]);let i=_e.slice(),a=Math.pow(10,-4);for(let{x:n,y:r,width:o,height:s}of e){let e=Math.floor((n-t)/a)*a,c=Math.ceil((n+o+t)/a)*a,l=Math.floor((r-t)/a)*a,u=Math.ceil((r+s+t)/a)*a,d=[e,l,u,!0],f=[c,l,u,!1];x(Sg,this).push(d,f),B.rectBoundingBox(e,l,c,u,i)}let o=i[2]-i[0]+2*n,s=i[3]-i[1]+2*n,c=i[0]-n,l=i[1]-n,u=r?-1/0:1/0,d=1/0,f=x(Sg,this).at(r?-1:-2),p=[f[0],f[2]];for(let e of x(Sg,this)){let[t,n,i,a]=e;!a&&r?n<d?(d=n,u=t):n===d&&(u=Math.max(u,t)):a&&!r&&(n<d?(d=n,u=t):n===d&&(u=Math.min(u,t))),e[0]=(t-c)/o,e[1]=(n-l)/s,e[2]=(i-l)/s}C(yg,this,new Float32Array([c,l,o,s])),C(bg,this,[u,d]),C(xg,this,p)}getOutlines(){x(Sg,this).sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of x(Sg,this))t[3]?(e.push(...f(wg,this,Ag).call(this,t)),f(wg,this,Og).call(this,t)):(f(wg,this,kg).call(this,t),e.push(...f(wg,this,Ag).call(this,t)));return f(wg,this,Eg).call(this,e)}};function Eg(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i),i.push(r),n.add(r),n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;for(i=[t,o],r.push(i);;){let e;if(n.has(s))e=s;else if(n.has(c))e=c;else break;n.delete(e),[t,a,o,s,c]=e,l!==t&&(i.push(l,u,t,u===a?a:o),l=t),u=u===a?o:a}i.push(l,u)}return new Ng(r,x(yg,this),x(bg,this),x(xg,this))}function Dg(e){let t=x(Cg,this),n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}function Og([,e,t]){let n=f(wg,this,Dg).call(this,e);x(Cg,this).splice(n,0,[e,t])}function kg([,e,t]){let n=f(wg,this,Dg).call(this,e);for(let r=n;r<x(Cg,this).length;r++){let[n,i]=x(Cg,this)[r];if(n!==e)break;if(n===e&&i===t){x(Cg,this).splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=x(Cg,this)[r];if(n!==e)break;if(n===e&&i===t){x(Cg,this).splice(r,1);return}}}function Ag(e){let[t,n,r]=e,i=[[t,n,r]],a=f(wg,this,Dg).call(this,r);for(let e=0;e<a;e++){let[n,r]=x(Cg,this)[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1),e--,a--}continue}i[e][2]=n,s>r&&i.push([t,r,s])}}}return i}var jg=new WeakMap,Mg=new WeakMap,Ng=class extends X{constructor(e,t,n,r){super(),b(this,jg,void 0),b(this,Mg,void 0),C(Mg,this,e),C(jg,this,t),this.firstPoint=n,this.lastPoint=r}toSVGPath(){let e=[];for(let t of x(Mg,this)){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];a===n?(e.push(`V${o}`),r=o):o===r&&(e.push(`H${a}`),n=a)}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of x(Mg,this)){let n=Array(t.length);for(let i=0;i<t.length;i+=2)n[i]=e+t[i]*o,n[i+1]=r-t[i+1]*s;a.push(n)}return a}get box(){return x(jg,this)}},Pg=class extends $h{newFreeDrawOutline(e,t,n,r,i,a){return new Fg(e,t,n,r,i,a)}},Fg=class extends _g{newOutliner(e,t,n,r,i,a=0){return new Pg(e,t,n,r,i,a)}},Ig=new WeakMap,Lg=new WeakMap,Rg=new WeakMap,zg=new WeakMap,Bg=new WeakMap,Vg=new WeakMap,Hg=new WeakMap,Ug=new WeakMap,Wg=new WeakMap,Gg=new WeakMap,Kg=new WeakMap,qg=new WeakMap,Jg=new WeakMap,Yg=new WeakMap,Xg=new WeakMap,Zg=new WeakMap,Qg=new WeakMap,$g=new WeakMap,Q=new WeakSet,e_=class e extends G{static get _keyboardManager(){let t=e.prototype;return R(this,`_keyboardManager`,new Ln([[[`ArrowLeft`],t._moveCaret,{args:[0]}],[[`ArrowRight`],t._moveCaret,{args:[1]}],[[`ArrowUp`],t._moveCaret,{args:[2]}],[[`ArrowDown`],t._moveCaret,{args:[3]}]]))}constructor(t){super(T(T({},t),{},{name:`highlightEditor`})),S(this,Q),b(this,Ig,null),b(this,Lg,0),b(this,Rg,void 0),b(this,zg,null),b(this,Bg,null),b(this,Vg,null),b(this,Hg,null),b(this,Ug,0),b(this,Wg,null),b(this,Gg,null),b(this,Kg,null),b(this,qg,!1),b(this,Jg,null),b(this,Yg,null),b(this,Xg,null),b(this,Zg,``),b(this,Qg,void 0),b(this,$g,``),this.color=t.color||e._defaultColor,C(Qg,this,t.thickness||e._defaultThickness),this.opacity=t.opacity||e._defaultOpacity,C(Rg,this,t.boxes||null),C($g,this,t.methodOfCreation||``),C(Zg,this,t.text||``),this._isDraggable=!1,this.defaultL10nId=`pdfjs-editor-highlight-editor`,t.highlightId>-1?(C(qg,this,!0),f(Q,this,n_).call(this,t),f(Q,this,s_).call(this)):x(Rg,this)&&(C(Ig,this,t.anchorNode),C(Lg,this,t.anchorOffset),C(Hg,this,t.focusNode),C(Ug,this,t.focusOffset),f(Q,this,t_).call(this),f(Q,this,s_).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(G._l10nAlert.highlight)}get telemetryInitialData(){return{action:`added`,type:x(qg,this)?`free_highlight`:`highlight`,color:this._uiManager.getNonHCMColorName(this.color),thickness:x(Qg,this),methodOfCreation:x($g,this)}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}static initialize(t,n){var r;G.initialize(t,n),e._defaultColor||(e._defaultColor=((r=n.highlightColors)==null?void 0:r.values().next().value)||`#fff066`)}static updateDefaultParams(t,n){switch(t){case P.HIGHLIGHT_COLOR:e._defaultColor=n;break;case P.HIGHLIGHT_THICKNESS:e._defaultThickness=n;break}}translateInPage(e,t){}get toolbarPosition(){return x(Yg,this)}get commentButtonPosition(){return x(Jg,this)}updateParams(e,t){switch(e){case P.HIGHLIGHT_COLOR:f(Q,this,r_).call(this,t);break;case P.HIGHLIGHT_THICKNESS:f(Q,this,i_).call(this,t);break}}static get defaultPropertiesToUpdate(){return[[P.HIGHLIGHT_COLOR,e._defaultColor],[P.HIGHLIGHT_THICKNESS,e._defaultThickness]]}get propertiesToUpdate(){return[[P.HIGHLIGHT_COLOR,this.color||e._defaultColor],[P.HIGHLIGHT_THICKNESS,x(Qg,this)||e._defaultThickness],[P.HIGHLIGHT_FREE,x(qg,this)]]}onUpdatedColor(){var e,t;(e=this.parent)==null||e.drawLayer.updateProperties(x(Kg,this),{root:{fill:this.color,"fill-opacity":this.opacity}}),(t=x(Bg,this))==null||t.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[[`colorPicker`,C(Bg,this,new tp({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle(`disabled`,!1)}fixAndSetPosition(){return super.fixAndSetPosition(f(Q,this,d_).call(this))}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,f(Q,this,d_).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){f(Q,this,o_).call(this),this._reportTelemetry({action:`deleted`}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(Q,this,s_).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;if(this.parent&&!e)f(Q,this,o_).call(this);else if(e){var n;f(Q,this,s_).call(this,e),t=!this.parent&&((n=this.div)==null?void 0:n.classList.contains(`selectedEditor`))}super.setParent(e),this.show(this._isVisible),t&&this.select()}rotate(t){let{drawLayer:n}=this.parent,r;x(qg,this)?(t=(t-this.rotation+360)%360,r=c_.call(e,x(Gg,this).box,t)):r=c_.call(e,[this.x,this.y,this.width,this.height],t),n.updateProperties(x(Kg,this),{bbox:r,root:{"data-main-rotation":t}}),n.updateProperties(x(Xg,this),{bbox:c_.call(e,x(Vg,this).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let e=super.render();x(Zg,this)&&(e.setAttribute(`aria-label`,x(Zg,this)),e.setAttribute(`role`,`mark`)),x(qg,this)?e.classList.add(`free`):this.div.addEventListener(`keydown`,f(Q,this,l_).bind(this),{signal:this._uiManager._signal});let t=C(Wg,this,document.createElement(`div`));return e.append(t),t.setAttribute(`aria-hidden`,`true`),t.className=`internal`,t.style.clipPath=x(zg,this),this.setDims(),vn(this,x(Wg,this),[`pointerover`,`pointerleave`]),this.enableEditing(),e}pointerover(){if(!this.isSelected){var e;(e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{hovered:!0}})}}pointerleave(){if(!this.isSelected){var e;(e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{hovered:!1}})}}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:f(Q,this,u_).call(this,!0);break;case 1:case 3:f(Q,this,u_).call(this,!1);break}}select(){var e;super.select(),x(Xg,this)&&((e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),x(Xg,this)&&((e=this.parent)==null||e.drawLayer.updateProperties(x(Xg,this),{rootClass:{selected:!1}}),x(qg,this)||f(Q,this,u_).call(this,!1))}get _mustFixPosition(){return!x(qg,this)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(x(Kg,this),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(x(Xg,this),{rootClass:{hidden:!e}}))}static startHighlighting(t,n,{target:r,x:i,y:a}){let{x:o,y:s,width:c,height:l}=r.getBoundingClientRect(),u=new AbortController,d=t.combinedSignal(u),p=n=>{u.abort(),f(e,this,h_).call(this,t,n)};window.addEventListener(`blur`,p,{signal:d}),window.addEventListener(`pointerup`,p,{signal:d}),window.addEventListener(`pointerdown`,wt,{capture:!0,passive:!1,signal:d}),window.addEventListener(`contextmenu`,Ct,{signal:d}),r.addEventListener(`pointermove`,f(e,this,m_).bind(this,t),{signal:d}),this._freeHighlight=new Pg({x:i,y:a},[o,s,c,l],t.scale,this._defaultThickness/2,n,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let a=null;if(e instanceof Xm){let{data:{quadPoints:t,rect:n,rotation:r,id:i,color:o,opacity:s,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;a=e={annotationType:N.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:c,richText:l,comment:(u==null?void 0:u.str)||null,creationDate:d,modificationDate:f}}else if(e instanceof Jm){let{data:{inkLists:t,rect:n,rotation:r,id:i,color:o,borderStyle:{rawWidth:s},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;a=e={annotationType:N.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:c,richText:l,comment:(u==null?void 0:u.str)||null,creationDate:d,modificationDate:f}}let{color:o,quadPoints:s,inkLists:c,outlines:l,opacity:u}=e,d=yield r().call(i,e,t,n);d.color=B.makeHexColor(...o),d.opacity=u||1,c&&C(Qg,d,e.thickness),d._initialData=a,e.comment&&d.setCommentData(e);let[p,m]=d.pageDimensions,[h,g]=d.pageTranslation;if(s){let e=C(Rg,d,[]);for(let t=0;t<s.length;t+=8)e.push({x:(s[t]-h)/p,y:1-(s[t+1]-g)/m,width:(s[t+2]-s[t])/p,height:(s[t+1]-s[t+5])/m});f(Q,d,t_).call(d),f(Q,d,s_).call(d),d.rotate(d.rotation)}else if(c||l){C(qg,d,!0);let e=(c||l.points)[0],n={x:e[0]-h,y:m-(e[1]-g)},r=new Pg(n,[0,0,p,m],1,x(Qg,d)/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2)n.x=e[t]-h,n.y=m-(e[t+1]-g),r.add(n);let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);f(Q,d,n_).call(d,{highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a}),f(Q,d,s_).call(d),d.rotate(d.parentRotation)}return d})()}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=G._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:t,opacity:this.opacity,thickness:x(Qg,this),quadPoints:f(Q,this,f_).call(this),outlines:f(Q,this,p_).call(this,n.rect)}),this.addComment(n),this.annotationElementId&&!f(Q,this,g_).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};ce=e_;function t_(){let e=new Tg(x(Rg,this),.001);C(Gg,this,e.getOutlines()),[this.x,this.y,this.width,this.height]=x(Gg,this).box;let t=new Tg(x(Rg,this),.0025,.001,this._uiManager.direction===`ltr`);C(Vg,this,t.getOutlines());let{firstPoint:n}=x(Gg,this);C(Jg,this,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);let{lastPoint:r}=x(Vg,this);C(Yg,this,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])}function n_({highlightOutlines:e,highlightId:t,clipPathId:n}){if(C(Gg,this,e),C(Vg,this,e.getNewOutline(x(Qg,this)/2+1.5,.0025)),t>=0)C(Kg,this,t),C(zg,this,n),this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),C(Xg,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:x(Vg,this).box,path:{d:x(Vg,this).toSVGPath()}},!0));else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(x(Kg,this),{bbox:c_.call(ce,x(Gg,this).box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(x(Xg,this),{bbox:c_.call(ce,x(Vg,this).box,t),path:{d:x(Vg,this).toSVGPath()}})}let[r,i,a,o]=e.box;switch(this.rotation){case 0:this.x=r,this.y=i,this.width=a,this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=i,this.y=1-r,this.width=a*t/e,this.height=o*e/t;break}case 180:this.x=1-r,this.y=1-i,this.width=a,this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-i,this.y=r,this.width=a*t/e,this.height=o*e/t;break}}let{firstPoint:s}=e;C(Jg,this,[(s[0]-r)/a,(s[1]-i)/o]);let{lastPoint:c}=x(Vg,this);C(Yg,this,[(c[0]-r)/a,(c[1]-i)/o])}function r_(e){let t=(e,t)=>{this.color=e,this.opacity=t,this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,e,ce._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`color_changed`,color:this._uiManager.getNonHCMColorName(e)},!0)}function i_(e){let t=x(Qg,this),n=e=>{C(Qg,this,e),f(Q,this,a_).call(this,e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}function a_(e){x(qg,this)&&(f(Q,this,n_).call(this,{highlightOutlines:x(Gg,this).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())}function o_(){x(Kg,this)===null||!this.parent||(this.parent.drawLayer.remove(x(Kg,this)),C(Kg,this,null),this.parent.drawLayer.remove(x(Xg,this)),C(Xg,this,null))}function s_(e=this.parent){x(Kg,this)===null&&({id:O(C,[Kg,this])._,clipPathId:O(C,[zg,this])._}=e.drawLayer.draw({bbox:x(Gg,this).box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:x(qg,this)},path:{d:x(Gg,this).toSVGPath()}},!1,!0),C(Xg,this,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:x(qg,this)},bbox:x(Vg,this).box,path:{d:x(Vg,this).toSVGPath()}},x(qg,this))),x(Wg,this)&&(x(Wg,this).style.clipPath=x(zg,this)))}function c_([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}function l_(e){ce._keyboardManager.exec(this,e)}function u_(e){if(!x(Ig,this))return;let t=window.getSelection();e?t.setPosition(x(Ig,this),x(Lg,this)):t.setPosition(x(Hg,this),x(Ug,this))}function d_(){return x(qg,this)?this.rotation:0}function f_(){if(x(qg,this))return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=x(Rg,this),a=new Float32Array(i.length*8),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i,a[o+1]=a[o+3]=d,a[o+2]=a[o+6]=i+l*e,a[o+5]=a[o+7]=d-u*t,o+=8}return a}function p_(e){return x(Gg,this).serialize(e,f(Q,this,d_).call(this))}function m_(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function h_(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=``}function g_(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,n)=>e!==t[n])}g(e_,`_defaultColor`,null),g(e_,`_defaultOpacity`,1),g(e_,`_defaultThickness`,12),g(e_,`_type`,`highlight`),g(e_,`_editorType`,N.HIGHLIGHT),g(e_,`_freeHighlightId`,-1),g(e_,`_freeHighlight`,null),g(e_,`_freeHighlightClipId`,``);var __=new WeakMap,v_=class{constructor(){b(this,__,Object.create(null))}updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))t.startsWith(`_`)||this.updateProperty(t,n)}updateSVGProperty(e,t){x(__,this)[e]=t}toSVGProperties(){let e=x(__,this);return C(__,this,Object.create(null)),{root:e}}reset(){C(__,this,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){L(`Not implemented`)}},y_=new WeakMap,b_=new WeakMap,x_=new WeakSet,S_=class e extends G{constructor(e){super(e),S(this,x_),b(this,y_,null),b(this,b_,void 0),g(this,`_colorPicker`,null),g(this,`_drawId`,null),C(b_,this,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,t;(e=this._colorPicker)==null||(t=e.updateOpacity)==null||t.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(f(x_,this,C_).call(this,e),f(x_,this,E_).call(this))}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){L(`Not implemented`)}static get typesMap(){L(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){let n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t),this._currentParent&&(j_._.updateProperty(n,t),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=n=>{var i;r.updateProperty(t,n);let a=x(y_,this).updateProperty(t,n);a&&f(x_,this,k_).call(this,a),(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),i=this._drawingOptions,a=i[n],o=i[r],s=(e,t)=>{var a;i.updateProperty(n,e),i.updateProperty(r,t),x(y_,this).updateProperty(n,e),x(y_,this).updateProperty(r,t),(a=this.parent)==null||a.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:s.bind(this,e,t),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:P.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(x(y_,this).getPathResizingSVGProperties(f(x_,this,O_).call(this)),{bbox:f(x_,this,A_).call(this)}))}_onResized(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(x(y_,this).getPathResizedSVGProperties(f(x_,this,O_).call(this)),{bbox:f(x_,this,A_).call(this)}))}_onTranslating(e,t){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{bbox:f(x_,this,A_).call(this)})}_onTranslated(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(x(y_,this).getPathTranslatedSVGProperties(f(x_,this,O_).call(this),this.parentDimensions),{bbox:f(x_,this,A_).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle(`disabled`,!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,x(b_,this)&&(C(b_,this,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){f(x_,this,T_).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(f(x_,this,E_).call(this),f(x_,this,k_).call(this,x(y_,this).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;if(this.parent&&!e)this._uiManager.removeShouldRescale(this),f(x_,this,T_).call(this);else if(e){var n;this._uiManager.addShouldRescale(this),f(x_,this,E_).call(this,e),t=!this.parent&&((n=this.div)==null?void 0:n.classList.contains(`selectedEditor`))}super.setParent(e),t&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties({bbox:f(x_,this,A_).call(this)},x(y_,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&f(x_,this,k_).call(this,x(y_,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;this._isCopy&&(e=this.x,t=this.y);let n=super.render();n.classList.add(`draw`);let r=document.createElement(`div`);return n.append(r),r.setAttribute(`aria-hidden`,`true`),r.className=`internal`,this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,t),n}static createDrawerInstance(e,t,n,r,i){L(`Not implemented`)}static startDrawing(e,t,n,r){var i;let{target:a,offsetX:o,offsetY:s,pointerId:c,pointerType:l}=r;if(yn.isInitializedAndDifferentPointerType(l))return;let{viewport:{rotation:u}}=e,{width:d,height:f}=a.getBoundingClientRect(),p=M_._=new AbortController,m=e.combinedSignal(p);if(yn.setPointer(l,c),window.addEventListener(`pointerup`,e=>{yn.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:m}),window.addEventListener(`pointercancel`,e=>{yn.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:m}),window.addEventListener(`pointerdown`,e=>{yn.isSamePointerType(e.pointerType)&&(yn.initializeAndAddPointerId(e.pointerId),j_._.isCancellable()&&(j_._.removeLastElement(),j_._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener(`contextmenu`,Ct,{signal:m}),a.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:m}),a.addEventListener(`touchmove`,e=>{yn.isSameTimeStamp(e.timeStamp)&&wt(e)},{signal:m}),e.toggleDrawing(),(i=t._editorUndoBar)==null||i.hide(),j_._){e.drawLayer.updateProperties(this._currentDrawId,j_._.startNew(o,s,d,f,u));return}t.updateUIForDefaultProperties(this),j_._=this.createDrawerInstance(o,s,d,f,u),N_._=this.getDefaultDrawingOptions(),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(N_._.toSVGProperties(),j_._.defaultSVGProperties),!0,!1)}static _drawMove(e){if(yn.isSameTimeStamp(e.timeStamp),!j_._)return;let{offsetX:t,offsetY:n,pointerId:r}=e;if(yn.isSamePointerId(r)){if(yn.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,j_._.add(t,n)),yn.setTimeStamp(e.timeStamp),wt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,j_._=null,N_._=null,yn.clearTimeStamp()),M_._&&(M_._.abort(),M_._=null,yn.clearPointerIds())}static _endDraw(e){let t=this._currentParent;if(t){if(t.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===t.div&&t.drawLayer.updateProperties(this._currentDrawId,j_._.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){let e=j_._,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:P.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){let t=this._currentParent;if(!t)return null;if(t.toggleDrawing(!0),t.cleanUndoStack(P.DRAW_STEP),!j_._.isEmpty()){let{pageDimensions:[n,r],scale:i}=t,a=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:j_._.getOutlines(n*i,r*i,i,this._INNER_MARGIN),drawingOptions:N_._,mustBeCommitted:!e});return this._cleanup(!0),a}return t.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){L(`Not implemented`)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let{rawDims:{pageWidth:a,pageHeight:o,pageX:s,pageY:c}}=t.viewport,l=i.deserializeDraw(s,c,a,o,i._INNER_MARGIN,e),u=yield r().call(i,e,t,n);return u.createDrawingOptions(e),f(x_,u,C_).call(u,{drawOutlines:l}),f(x_,u,E_).call(u),u.onScaleChanging(),u.rotate(),u})()}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return x(y_,this).serialize([t,n,r,i],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};le=S_;function C_({drawOutlines:e,drawId:t,drawingOptions:n}){C(y_,this,e),this._drawingOptions||(this._drawingOptions=n),this.annotationElementId||this._uiManager.a11yAlert(G._l10nAlert[this.editorType]),t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=f(x_,this,w_).call(this,e,this.parent),f(x_,this,k_).call(this,e.box)}function w_(e,t){let{id:n}=t.drawLayer.draw(le._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}function T_(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}function E_(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=f(x_,this,w_).call(this,x(y_,this),e)}}function D_([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}function O_(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}function k_(e){[this.x,this.y,this.width,this.height]=f(x_,this,D_).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}function A_(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((i*4+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}g(S_,`_currentDrawId`,-1),g(S_,`_currentParent`,null);var j_={_:null},M_={_:null},N_={_:null};g(S_,`_INNER_MARGIN`,3);var P_=new WeakMap,F_=new WeakMap,I_=new WeakMap,L_=new WeakMap,R_=new WeakMap,z_=new WeakMap,B_=new WeakMap,V_=new WeakMap,H_=new WeakMap,U_=new WeakMap,W_=new WeakMap,G_=new WeakSet,K_=class{constructor(e,t,n,r,i,a){S(this,G_),b(this,P_,new Float64Array(6)),b(this,F_,void 0),b(this,I_,void 0),b(this,L_,void 0),b(this,R_,void 0),b(this,z_,void 0),b(this,B_,``),b(this,V_,0),b(this,H_,new iv),b(this,U_,void 0),b(this,W_,void 0),C(U_,this,n),C(W_,this,r),C(L_,this,i),C(R_,this,a),[e,t]=f(G_,this,q_).call(this,e,t);let o=C(F_,this,[NaN,NaN,NaN,NaN,e,t]);C(z_,this,[e,t]),C(I_,this,[{line:o,points:x(z_,this)}]),x(P_,this).set(o,0)}updateProperty(e,t){e===`stroke-width`&&C(R_,this,t)}isEmpty(){var e;return!((e=x(I_,this))!=null&&e.length)}isCancellable(){return x(z_,this).length<=10}add(e,t){[e,t]=f(G_,this,q_).call(this,e,t);let[n,r,i,a]=x(P_,this).subarray(2,6),o=e-i,s=t-a;return Math.hypot(x(U_,this)*o,x(W_,this)*s)<=2?null:(x(z_,this).push(e,t),isNaN(n)?(x(P_,this).set([i,a,e,t],2),x(F_,this).push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(x(P_,this)[0])&&x(F_,this).splice(6,6),x(P_,this).set([n,r,i,a,e,t],0),x(F_,this).push(...X.createBezierPoints(n,r,i,a,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(x(z_,this).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){C(U_,this,n),C(W_,this,r),C(L_,this,i),[e,t]=f(G_,this,q_).call(this,e,t);let a=C(F_,this,[NaN,NaN,NaN,NaN,e,t]);C(z_,this,[e,t]);let o=x(I_,this).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),x(I_,this).push({line:a,points:x(z_,this)}),x(P_,this).set(a,0),C(V_,this,0),this.toSVGPath(),null}getLastElement(){return x(I_,this).at(-1)}setLastElement(e){return x(I_,this)?(x(I_,this).push(e),C(F_,this,e.line),C(z_,this,e.points),C(V_,this,0),{path:{d:this.toSVGPath()}}):x(H_,this).setLastElement(e)}removeLastElement(){if(!x(I_,this))return x(H_,this).removeLastElement();x(I_,this).pop(),C(B_,this,``);for(let e=0,t=x(I_,this).length;e<t;e++){let{line:t,points:n}=x(I_,this)[e];C(F_,this,t),C(z_,this,n),C(V_,this,0),this.toSVGPath()}return{path:{d:x(B_,this)}}}toSVGPath(){let e=X.svgRound(x(F_,this)[4]),t=X.svgRound(x(F_,this)[5]);if(x(z_,this).length===2)return C(B_,this,`${x(B_,this)} M ${e} ${t} Z`),x(B_,this);if(x(z_,this).length<=6){let n=x(B_,this).lastIndexOf(`M`);C(B_,this,`${x(B_,this).slice(0,n)} M ${e} ${t}`),C(V_,this,6)}if(x(z_,this).length===4){let e=X.svgRound(x(F_,this)[10]),t=X.svgRound(x(F_,this)[11]);return C(B_,this,`${x(B_,this)} L ${e} ${t}`),C(V_,this,12),x(B_,this)}let n=[];x(V_,this)===0&&(n.push(`M ${e} ${t}`),C(V_,this,6));for(let e=x(V_,this),t=x(F_,this).length;e<t;e+=6){let[t,r,i,a,o,s]=x(F_,this).slice(e,e+6).map(X.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}return C(B_,this,x(B_,this)+n.join(` `)),C(V_,this,x(F_,this).length),x(B_,this)}getOutlines(e,t,n,r){let i=x(I_,this).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),x(H_,this).build(x(I_,this),e,t,n,x(L_,this),x(R_,this),r),C(P_,this,null),C(F_,this,null),C(I_,this,null),C(B_,this,null),x(H_,this)}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}};function q_(e,t){return X._normalizePoint(e,t,x(U_,this),x(W_,this),x(L_,this))}var J_=new WeakMap,Y_=new WeakMap,X_=new WeakMap,Z_=new WeakMap,Q_=new WeakMap,$_=new WeakMap,ev=new WeakMap,tv=new WeakMap,nv=new WeakMap,rv=new WeakSet,iv=class extends X{constructor(...e){super(...e),S(this,rv),b(this,J_,void 0),b(this,Y_,0),b(this,X_,void 0),b(this,Z_,void 0),b(this,Q_,void 0),b(this,$_,void 0),b(this,ev,void 0),b(this,tv,void 0),b(this,nv,void 0)}build(e,t,n,r,i,a,o){C(Q_,this,t),C($_,this,n),C(ev,this,r),C(tv,this,i),C(nv,this,a),C(X_,this,o==null?0:o),C(Z_,this,e),f(rv,this,sv).call(this)}get thickness(){return x(nv,this)}setLastElement(e){return x(Z_,this).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return x(Z_,this).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of x(Z_,this)){if(e.push(`M${X.svgRound(t[4])} ${X.svgRound(t[5])}`),t.length===6){e.push(`Z`);continue}if(t.length===12&&isNaN(t[6])){e.push(`L${X.svgRound(t[10])} ${X.svgRound(t[11])}`);continue}for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(X.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=f(rv,this,ov).call(this),d,p,m,h,g,_,v,y,b;switch(x(tv,this)){case 0:b=X._rescale,d=e,p=t+r,m=n,h=-r,g=e+s*n,_=t+(1-c-u)*r,v=e+(s+l)*n,y=t+(1-c)*r;break;case 90:b=X._rescaleAndSwap,d=e,p=t,m=n,h=r,g=e+c*n,_=t+s*r,v=e+(c+u)*n,y=t+(s+l)*r;break;case 180:b=X._rescale,d=e+n,p=t,m=-n,h=r,g=e+(1-s-l)*n,_=t+c*r,v=e+(1-s)*n,y=t+(c+u)*r;break;case 270:b=X._rescaleAndSwap,d=e+n,p=t+r,m=-n,h=-r,g=e+(1-c-u)*n,_=t+(1-s-l)*r,v=e+(1-c)*n,y=t+(1-s)*r;break}for(let{line:e,points:t}of x(Z_,this))a.push(b(e,d,p,m,h,i?Array(e.length):null)),o.push(b(t,d,p,m,h,i?Array(t.length):null));return{lines:a,points:o,rect:[g,_,v,y]}}static deserialize(e,t,n,r,i,{paths:{lines:a,points:o},rotation:s,thickness:c}){let l=[],u,d,f,p,m;switch(s){case 0:m=X._rescale,u=-e/n,d=t/r+1,f=1/n,p=-1/r;break;case 90:m=X._rescaleAndSwap,u=-t/r,d=-e/n,f=1/r,p=1/n;break;case 180:m=X._rescale,u=e/n+1,d=-t/r,f=-1/n,p=1/r;break;case 270:m=X._rescaleAndSwap,u=t/r+1,d=e/n+1,f=-1/r,p=-1/n;break}if(!a){a=[];for(let e of o){let t=e.length;if(t===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));a.push(n);let[r,i,o,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let a=4;a<t;a+=2){let t=e[a],c=e[a+1];n.set(X.createBezierPoints(r,i,o,s,t,c),(a-2)*3),[r,i,o,s]=[o,s,t,c]}}}for(let e=0,t=a.length;e<t;e++)l.push({line:m(a[e].map(e=>e==null?NaN:e),u,d,f,p),points:m(o[e].map(e=>e==null?NaN:e),u,d,f,p)});let h=new this.prototype.constructor;return h.build(l,n,r,1,s,c,i),h}get box(){return x(J_,this)}updateProperty(e,t){return e===`stroke-width`?f(rv,this,cv).call(this,t):null}updateParentDimensions([e,t],n){let[r,i]=f(rv,this,av).call(this);C(Q_,this,e),C($_,this,t),C(ev,this,n);let[a,o]=f(rv,this,av).call(this),s=a-r,c=o-i,l=x(J_,this);return l[0]-=s,l[1]-=c,l[2]+=2*s,l[3]+=2*c,l}updateRotation(e){return C(Y_,this,e),{path:{transform:this.rotationTransform}}}get viewBox(){return x(J_,this).map(X.svgRound).join(` `)}get defaultProperties(){let[e,t]=x(J_,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=x(J_,this),n=0,r=0,i=0,a=0,o=0,s=0;switch(x(Y_,this)){case 90:r=t/e,i=-e/t,o=e;break;case 180:n=-1,a=-1,o=e,s=t;break;case 270:r=-t/e,i=e/t,s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${X.svgRound(o)} ${X.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=f(rv,this,av).call(this),[o,s,c,l]=x(J_,this);if(Math.abs(c-i)<=X.PRECISION||Math.abs(l-a)<=X.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),p=c/n,m=l/r;return{path:{"transform-origin":`${X.svgRound(o)} ${X.svgRound(s)}`,transform:`${this.rotationTransform} scale(${p} ${m}) translate(${X.svgRound(i)} ${X.svgRound(a)}) scale(${u} ${d}) translate(${X.svgRound(-i)} ${X.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=f(rv,this,av).call(this),o=x(J_,this),[s,c,l,u]=o;if(o[0]=e,o[1]=t,o[2]=n,o[3]=r,Math.abs(l-i)<=X.PRECISION||Math.abs(u-a)<=X.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of x(Z_,this))X._translate(e,i,a,e),X._translate(t,i,a,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),p=(r-2*a)/(u-2*a),m=-d*(s+i)+e+i,h=-p*(c+a)+t+a;if(d!==1||p!==1||m!==0||h!==0)for(let{line:e,points:t}of x(Z_,this))X._rescale(e,m,h,d,p,e),X._rescale(t,m,h,d,p,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=x(J_,this),o=e-a[0],s=t-a[1];if(x(Q_,this)===r&&x($_,this)===i)for(let{line:e,points:t}of x(Z_,this))X._translate(e,o,s,e),X._translate(t,o,s,t);else{let e=x(Q_,this)/r,t=x($_,this)/i;C(Q_,this,r),C($_,this,i);for(let{line:n,points:r}of x(Z_,this))X._rescale(n,o,s,e,t,n),X._rescale(r,o,s,e,t,r);a[2]*=e,a[3]*=t}return a[0]=e,a[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e)} ${X.svgRound(t)}`}}}get defaultSVGProperties(){let e=x(J_,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e[0])} ${X.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}};function av(e=x(nv,this)){let t=x(X_,this)+e/2*x(ev,this);return x(tv,this)%180==0?[t/x(Q_,this),t/x($_,this)]:[t/x($_,this),t/x(Q_,this)]}function ov(){let[e,t,n,r]=x(J_,this),[i,a]=f(rv,this,av).call(this,0);return[e+i,t+a,n-2*i,r-2*a]}function sv(){let e=C(J_,this,ve.slice());for(let{line:t}of x(Z_,this)){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6)B.pointBoundingBox(t[n],t[n+1],e);continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);B.bezierBoundingBox(n,r,a,o,s,c,l,u,e),n=l,r=u}}let[t,n]=f(rv,this,av).call(this);e[0]=V(e[0]-t,0,1),e[1]=V(e[1]-n,0,1),e[2]=V(e[2]+t,0,1),e[3]=V(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]}function cv(e){let[t,n]=f(rv,this,av).call(this);C(nv,this,e);let[r,i]=f(rv,this,av).call(this),[a,o]=[r-t,i-n],s=x(J_,this);return s[0]-=a,s[1]-=o,s[2]+=2*a,s[3]+=2*o,s}var lv=class e extends v_{constructor(e){super(),this._viewParameters=e,super.updateProperties({fill:`none`,stroke:G._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){e===`stroke-width`&&(t!=null||(t=this[`stroke-width`]),t*=this._viewParameters.realScale),super.updateSVGProperty(e,t)}clone(){let t=new e(this._viewParameters);return t.updateAll(this),t}},uv=new WeakSet,dv=class e extends S_{constructor(e){super(T(T({},e),{},{name:`inkEditor`})),S(this,uv),this._willKeepAspectRatio=!0,this.defaultL10nId=`pdfjs-editor-ink-editor`}static initialize(e,t){G.initialize(e,t),this._defaultDrawingOptions=new lv(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return R(this,`typesMap`,new Map([[P.INK_THICKNESS,`stroke-width`],[P.INK_COLOR,`stroke`],[P.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new K_(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return iv.deserialize(e,t,n,r,i,a)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let a=null;if(e instanceof Jm){let{data:{inkLists:t,rect:n,rotation:r,id:i,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},parent:{page:{pageNumber:m}}}=e;a=e={annotationType:N.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:m-1,rect:n.slice(0),rotation:r,annotationElementId:i,id:i,deleted:!1,popupRef:l,richText:u,comment:(d==null?void 0:d.str)||null,creationDate:f,modificationDate:p}}let o=yield r().call(i,e,t,n);return o._initialData=a,e.comment&&o.setCommentData(e),o})()}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new pp(this)),[[`colorPicker`,this._colorPicker]]}get colorType(){return P.INK_COLOR}get colorAndOpacityType(){return P.INK_COLOR_AND_OPACITY}get opacityType(){return P.INK_OPACITY}updateParams(e,t){if(e===P.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(t.color,t.opacity);return}super.updateParams(e,t)}static updateDefaultParams(e,t){if(e===P.INK_COLOR_AND_OPACITY){super.updateDefaultParams(P.INK_COLOR,t.color),super.updateDefaultParams(P.INK_OPACITY,t.opacity);return}super.updateDefaultParams(e,t)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions[`stroke-opacity`]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty(`stroke-width`),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty(`stroke-width`),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:n,opacity:r}){this._drawingOptions=e.getDefaultDrawingOptions({stroke:B.makeHexColor(...t),"stroke-width":n,"stroke-opacity":r})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":i,"stroke-width":a}}=this,o=Object.assign(super.serialize(e),{color:G._colorManager.convert(r),opacity:i,thickness:a,paths:{lines:t,points:n}});return this.addComment(o),e?(o.isCopy=!0,o):this.annotationElementId&&!f(uv,this,fv).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t,popup:this.comment}),null}};function fv(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}g(dv,`_type`,`ink`),g(dv,`_editorType`,N.INK),g(dv,`_defaultDrawingOptions`,null);var pv=class extends iv{toSVGPath(){let e=super.toSVGPath();return e.endsWith(`Z`)||(e+=`Z`),e}},mv=8,hv=3,gv=class e{static extractContoursFromText(t,{fontFamily:n,fontStyle:r,fontWeight:i},a,o,s,c){let l=new OffscreenCanvas(1,1),u=l.getContext(`2d`,{alpha:!1}),d=u.font=`${r} ${i} 200px ${n}`,{actualBoundingBoxLeft:p,actualBoundingBoxRight:m,actualBoundingBoxAscent:h,actualBoundingBoxDescent:g,fontBoundingBoxAscent:_,fontBoundingBoxDescent:v,width:y}=u.measureText(t),b=1.5,x=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||0,y)*b),S=Math.ceil(Math.max(Math.abs(h)+Math.abs(g)||200,Math.abs(_)+Math.abs(v)||200)*b);l=new OffscreenCanvas(x,S),u=l.getContext(`2d`,{alpha:!0,willReadFrequently:!0}),u.font=d,u.filter=`grayscale(1)`,u.fillStyle=`white`,u.fillRect(0,0,x,S),u.fillStyle=`black`,u.fillText(t,x*(b-1)/2,S*(3-b)/2);let C=f(e,this,Tv).call(this,u.getImageData(0,0,x,S).data),w=f(e,this,wv).call(this,C),T=f(e,this,Ev).call(this,w),E=f(e,this,bv).call(this,C,x,S,T);return this.processDrawnLines({lines:{curves:E,width:x,height:S},pageWidth:a,pageHeight:o,rotation:s,innerMargin:c,mustSmooth:!0,areContours:!0})}static process(t,n,r,i,a){let[o,s,c]=f(e,this,Dv).call(this,t),[l,u]=f(e,this,Cv).call(this,o,s,c,Math.hypot(s,c)*f(e,this,Ov)._.sigmaSFactor,f(e,this,Ov)._.sigmaR,f(e,this,Ov)._.kernelSize),d=f(e,this,Ev).call(this,u),p=f(e,this,bv).call(this,l,s,c,d);return this.processDrawnLines({lines:{curves:p,width:s,height:c},pageWidth:n,pageHeight:r,rotation:i,innerMargin:a,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:n,pageHeight:r,rotation:i,innerMargin:a,mustSmooth:o,areContours:s}){var c;i%180!=0&&([n,r]=[r,n]);let{curves:l,width:u,height:d}=t,p=(c=t.thickness)==null?0:c,m=[],h=Math.min(n/u,r/d),g=h/n,_=h/r,v=[];for(let{points:t}of l){let n=o?f(e,this,Sv).call(this,t):t;if(!n)continue;v.push(n);let r=n.length,i=new Float32Array(r),a=new Float32Array(3*(r===2?2:r-2));if(m.push({line:a,points:i}),r===2){i[0]=n[0]*g,i[1]=n[1]*_,a.set([NaN,NaN,NaN,NaN,i[0],i[1]],0);continue}let[s,c,l,u]=n;s*=g,c*=_,l*=g,u*=_,i.set([s,c,l,u],0),a.set([NaN,NaN,NaN,NaN,s,c],0);for(let e=4;e<r;e+=2){let t=i[e]=n[e]*g,r=i[e+1]=n[e+1]*_;a.set(X.createBezierPoints(s,c,l,u,t,r),(e-2)*3),[s,c,l,u]=[l,u,t,r]}}if(m.length===0)return null;let y=s?new pv:new iv;return y.build(m,n,r,1,i,s?0:p,a),{outline:y,newCurves:v,areContours:s,thickness:p,width:u,height:d}}static compressSignature({outlines:e,areContours:t,thickness:n,width:r,height:i}){return v(function*(){let a=1/0,o=-1/0,s=0;for(let t of e){s+=t.length;for(let e=2,n=t.length;e<n;e++){let n=t[e]-t[e-2];a=Math.min(a,n),o=Math.max(o,n)}}let c;c=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let l=e.length,u=mv+hv*l,d=new Uint32Array(u),f=0;d[f++]=u*Uint32Array.BYTES_PER_ELEMENT+(s-2*l)*c.BYTES_PER_ELEMENT,d[f++]=0,d[f++]=r,d[f++]=i,d[f++]=+!t,d[f++]=Math.max(0,Math.floor(n==null?0:n)),d[f++]=l,d[f++]=c.BYTES_PER_ELEMENT;for(let t of e)d[f++]=t.length-2,d[f++]=t[0],d[f++]=t[1];let p=new CompressionStream(`deflate-raw`),m=p.writable.getWriter();yield m.ready,m.write(d);let h=c.prototype.constructor;for(let t of e){let e=new h(t.length-2);for(let n=2,r=t.length;n<r;n++)e[n-2]=t[n]-t[n-2];m.write(e)}return m.close(),(yield new Response(p.readable).bytes()).toBase64()})()}static decompressSignature(e){return v(function*(){try{let o=Uint8Array.fromBase64(e),{readable:s,writable:c}=new DecompressionStream(`deflate-raw`),l=c.getWriter();yield l.ready,l.write(o).then(v(function*(){yield l.ready,yield l.close()})).catch(()=>{});let u=null,d=0;var t=!1,n=!1,r;try{for(var i=E(s),a;t=!(a=yield i.next()).done;t=!1){let e=a.value;u||(u=new Uint8Array(new Uint32Array(e.buffer,0,4)[0])),u.set(e,d),d+=e.length}}catch(e){n=!0,r=e}finally{try{t&&i.return!=null&&(yield i.return())}finally{if(n)throw r}}let f=new Uint32Array(u.buffer,0,u.length>>2),p=f[1];if(p!==0)throw Error(`Invalid version: ${p}`);let m=f[2],h=f[3],g=f[4]===0,_=f[5],y=f[6],b=f[7],x=[],S=(mv+hv*y)*Uint32Array.BYTES_PER_ELEMENT,C;switch(b){case Int8Array.BYTES_PER_ELEMENT:C=new Int8Array(u.buffer,S);break;case Int16Array.BYTES_PER_ELEMENT:C=new Int16Array(u.buffer,S);break;case Int32Array.BYTES_PER_ELEMENT:C=new Int32Array(u.buffer,S);break}d=0;for(let e=0;e<y;e++){let t=f[hv*e+mv],n=new Float32Array(t+2);x.push(n);for(let t=0;t<hv-1;t++)n[t]=f[hv*e+mv+t+1];for(let e=0;e<t;e++)n[e+2]=n[e]+C[d++]}return{areContours:g,thickness:_,outlines:x,width:m,height:h}}catch(e){return I(`decompressSignature: ${e}`),null}})()}};ue=gv;function _v(e,t,n,r){return n-=e,r-=t,n===0?r>0?0:4:n===1?r+6:2-r}function vv(e,t,n,r,i,a,o){let s=f(ue,this,_v).call(this,n,r,i,a);for(let i=0;i<8;i++){let a=(-i+s-o+16)%8,c=f(ue,this,kv)._[2*a],l=f(ue,this,kv)._[2*a+1];if(e[(n+c)*t+(r+l)]!==0)return a}return-1}function yv(e,t,n,r,i,a,o){let s=f(ue,this,_v).call(this,n,r,i,a);for(let i=0;i<8;i++){let a=(i+s+o+16)%8,c=f(ue,this,kv)._[2*a],l=f(ue,this,kv)._[2*a+1];if(e[(n+c)*t+(r+l)]!==0)return a}return-1}function bv(e,t,n,r){let i=e.length,a=new Int32Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]<=r);for(let e=1;e<n-1;e++)a[e*t]=a[e*t+t-1]=0;for(let e=0;e<t;e++)a[e]=a[t*n-1-e]=0;let o=1,s,c=[];for(let e=1;e<n-1;e++){s=1;for(let n=1;n<t-1;n++){let r=e*t+n,i=a[r];if(i===0)continue;let l=e,u=n;if(i===1&&a[r-1]===0)o+=1,--u;else if(i>=1&&a[r+1]===0)o+=1,u+=1,i>1&&(s=i);else{i!==1&&(s=Math.abs(i));continue}let d=[n,e],p=u===n+1,m={isHole:p,points:d,id:o,parent:0};c.push(m);let h;for(let e of c)if(e.id===s){h=e;break}h?h.isHole?m.parent=p?h.parent:s:m.parent=p?s:h.parent:m.parent=p?s:0;let g=f(ue,this,vv).call(this,a,t,e,n,l,u,0);if(g===-1){a[r]=-o,a[r]!==1&&(s=Math.abs(a[r]));continue}let _=f(ue,this,kv)._[2*g],v=f(ue,this,kv)._[2*g+1],y=e+_,b=n+v;l=y,u=b;let x=e,S=n;for(;;){let i=f(ue,this,yv).call(this,a,t,x,S,l,u,1);_=f(ue,this,kv)._[2*i],v=f(ue,this,kv)._[2*i+1];let c=x+_,p=S+v;d.push(p,c);let m=x*t+S;if(a[m+1]===0?a[m]=-o:a[m]===1&&(a[m]=o),c===e&&p===n&&x===y&&S===b){a[r]!==1&&(s=Math.abs(a[r]));break}else l=x,u=S,x=c,S=p}}}return c}function xv(e,t,n,r){if(n-t<=4){for(let i=t;i<n-2;i+=2)r.push(e[i],e[i+1]);return}let i=e[t],a=e[t+1],o=e[n-4]-i,s=e[n-3]-a,c=Math.hypot(o,s),l=o/c,u=s/c,d=l*a-u*i,p=s/o,m=1/c,h=Math.atan(p),g=Math.cos(h),_=Math.sin(h),v=m*(Math.abs(g)+Math.abs(_)),y=m*(1-v+Math.pow(v,2)),b=Math.max(Math.atan(Math.abs(_+g)*y),Math.atan(Math.abs(_-g)*y)),x=0,S=t;for(let r=t+2;r<n-2;r+=2){let t=Math.abs(d-l*e[r+1]+u*e[r]);t>x&&(S=r,x=t)}x>Math.pow(c*b,2)?(f(ue,this,xv).call(this,e,t,S+2,r),f(ue,this,xv).call(this,e,S,n,r)):r.push(i,a)}function Sv(e){let t=[],n=e.length;return f(ue,this,xv).call(this,e,0,n,t),t.push(e[n-2],e[n-1]),t.length<=4?null:t}function Cv(e,t,n,r,i,a){let o=new Float32Array(Math.pow(a,2)),s=-2*Math.pow(r,2),c=a>>1;for(let e=0;e<a;e++){let t=Math.pow(e-c,2);for(let n=0;n<a;n++)o[e*a+n]=Math.exp((t+Math.pow(n-c,2))/s)}let l=new Float32Array(256),u=-2*Math.pow(i,2);for(let e=0;e<256;e++)l[e]=Math.exp(Math.pow(e,2)/u);let d=e.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let r=0;r<n;r++)for(let i=0;i<t;i++){let s=r*t+i,u=e[s],d=0,m=0;for(let s=0;s<a;s++){let f=r+s-c;if(!(f<0||f>=n))for(let n=0;n<a;n++){let r=i+n-c;if(r<0||r>=t)continue;let p=e[f*t+r],h=o[s*a+n]*l[Math.abs(p-u)];d+=p*h,m+=h}}let h=f[s]=Math.round(d/m);p[h]++}return[f,p]}function wv(e){let t=new Uint32Array(256);for(let n of e)t[n]++;return t}function Tv(e){let t=e.length,n=new Uint8ClampedArray(t>>2),r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t]=e[t<<2];r=Math.max(r,a),i=Math.min(i,a)}let a=255/(r-i);for(let e=0,t=n.length;e<t;e++)n[e]=(n[e]-i)*a;return n}function Ev(e){let t,n=-1/0,r=-1/0,i=e.findIndex(e=>e!==0),a=i,o=i;for(t=i;t<256;t++){let i=e[t];i>n&&(t-a>r&&(r=t-a,o=t-1),n=i,a=t)}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t}function Dv(e){let t=e,{width:n,height:r}=e,{maxDim:i}=f(ue,this,Ov)._,a=n,o=r;if(n>i||r>i){let s=n,c=r,l=Math.log2(Math.max(n,r)/i),u=Math.floor(l);l=l===u?u-1:u;for(let n=0;n<l;n++){a=Math.ceil(s/2),o=Math.ceil(c/2);let n=new OffscreenCanvas(a,o);n.getContext(`2d`).drawImage(e,0,0,s,c,0,0,a,o),s=a,c=o,e!==t&&e.close(),e=n.transferToImageBitmap()}let d=Math.min(i/a,i/o);a=Math.round(a*d),o=Math.round(o*d)}let s=new OffscreenCanvas(a,o).getContext(`2d`,{willReadFrequently:!0});s.fillStyle=`white`,s.fillRect(0,0,a,o),s.filter=`grayscale(1)`,s.drawImage(e,0,0,e.width,e.height,0,0,a,o);let c=s.getImageData(0,0,a,o).data;return[f(ue,this,Tv).call(this,c),a,o]}var Ov={_:{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}},kv={_:new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1])},Av=class e extends v_{constructor(){super(),super.updateProperties({fill:G._defaultLineColor,"stroke-width":0})}clone(){let t=new e;return t.updateAll(this),t}},jv=class e extends lv{constructor(e){super(e),super.updateProperties({stroke:G._defaultLineColor,"stroke-width":1})}clone(){let t=new e(this._viewParameters);return t.updateAll(this),t}},Mv=new WeakMap,Nv=new WeakMap,Pv=new WeakMap,Fv=new WeakMap,Iv=class e extends S_{constructor(e){super(T(T({},e),{},{mustBeCommitted:!0,name:`signatureEditor`})),b(this,Mv,!1),b(this,Nv,null),b(this,Pv,null),b(this,Fv,null),this._willKeepAspectRatio=!0,C(Pv,this,e.signatureData||null),C(Nv,this,null),this.defaultL10nId=`pdfjs-editor-signature-editor1`}static initialize(e,t){G.initialize(e,t),this._defaultDrawingOptions=new Av,this._defaultDrawnSignatureOptions=new jv(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!1}static get typesMap(){return R(this,`typesMap`,new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:`signature`,hasDescription:!!x(Nv,this)}}static computeTelemetryFinalData(e){var t,n;let r=e.get(`hasDescription`);return{hasAltText:(t=r.get(!0))==null?0:t,hasNoAltText:(n=r.get(!1))==null?0:n}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,n,{_isCopy:r}=this;if(r&&(this._isCopy=!1,t=this.x,n=this.y),super.render(),this._drawId===null)if(x(Pv,this)){let{lines:t,mustSmooth:n,areContours:r,description:i,uuid:a,heightInPage:o}=x(Pv,this),{rawDims:{pageWidth:s,pageHeight:c},rotation:l}=this.parent.viewport,u=gv.processDrawnLines({lines:t,pageWidth:s,pageHeight:c,rotation:l,innerMargin:e._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(u,o,i,a)}else this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:``})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:x(Nv,this)||``}));return r&&(this._isCopy=!0,this._moveAfterPaste(t,n)),this.div}setUuid(e){C(Fv,this,e),this.addEditToolbar()}getUuid(){return x(Fv,this)}get description(){return x(Nv,this)}set description(e){C(Nv,this,e),this.div&&(this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:e})),super.addEditToolbar().then(t=>{t==null||t.updateEditSignatureButton(e)}))}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:n,width:r,height:i}=x(Pv,this),a=Math.max(r,i);return{areContours:t,outline:gv.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:n,width:r,height:i},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[[`editSignature`,this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,n,r,i){let{x:a,y:o}=this,{outline:s}=C(Pv,this,t);C(Mv,this,s instanceof pv),this.description=r;let c;x(Mv,this)?c=e.getDefaultDrawingOptions():(c=e._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":s.thickness})),this._addOutlines({drawOutlines:s,drawingOptions:c});let[,l]=this.pageDimensions,u=n/l;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:`pdfjs.signature.inserted`,data:{hasBeenSaved:!!i,hasDescription:!!r}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return gv.process(t,n,r,i,e._INNER_MARGIN)}getFromText(t,n){let{rawDims:{pageWidth:r,pageHeight:i},rotation:a}=this.parent.viewport;return gv.extractContoursFromText(t,n,r,i,a,e._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return gv.processDrawnLines({lines:t,pageWidth:n,pageHeight:r,rotation:i,innerMargin:e._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:n}){t?this._drawingOptions=e.getDefaultDrawingOptions():(this._drawingOptions=e._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":n}))}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,i=Object.assign(super.serialize(e),{isSignature:!0,areContours:x(Mv,this),color:[0,0,0],thickness:x(Mv,this)?0:r});return this.addComment(i),e?(i.paths={lines:t,points:n},i.uuid=x(Fv,this),i.isCopy=!0):i.lines=t,x(Nv,this)&&(i.accessibilityData={type:`Figure`,alt:x(Nv,this)}),i}static deserializeDraw(e,t,n,r,i,a){return a.areContours?pv.deserialize(e,t,n,r,i,a):iv.deserialize(e,t,n,r,i,a)}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){var a;let o=yield r().call(i,e,t,n);return C(Mv,o,e.areContours),o.description=((a=e.accessibilityData)==null?void 0:a.alt)||``,C(Fv,o,e.uuid),o})()}};g(Iv,`_type`,`signature`),g(Iv,`_editorType`,N.SIGNATURE),g(Iv,`_defaultDrawingOptions`,null);var Lv=new WeakMap,Rv=new WeakMap,zv=new WeakMap,Bv=new WeakMap,Vv=new WeakMap,Hv=new WeakMap,Uv=new WeakMap,Wv=new WeakMap,Gv=new WeakMap,Kv=new WeakMap,qv=new WeakMap,Jv=new WeakSet,Yv=class extends G{constructor(e){super(T(T({},e),{},{name:`stampEditor`})),S(this,Jv),b(this,Lv,null),b(this,Rv,null),b(this,zv,null),b(this,Bv,null),b(this,Vv,null),b(this,Hv,``),b(this,Uv,null),b(this,Wv,!1),b(this,Gv,null),b(this,Kv,!1),b(this,qv,!1),C(Bv,this,e.bitmapUrl),C(Vv,this,e.bitmapFile),this.defaultL10nId=`pdfjs-editor-stamp-editor`}static initialize(e,t){G.initialize(e,t)}static isHandlingMimeForPasting(e){return Pt.includes(e)}static paste(e,t){t.pasteEditor({mode:N.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:`stamp`,hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){var t,n;let r=e.get(`hasAltText`);return{hasAltText:(t=r.get(!0))==null?0:t,hasNoAltText:(n=r.get(!1))==null?0:n}}mlGuessAltText(e=null,t=!0){var n=this;return v(function*(){if(n.hasAltTextData())return null;let{mlManager:r}=n._uiManager;if(!r)throw Error(`No ML.`);if(!(yield r.isEnabledFor(`altText`)))throw Error(`ML isn't enabled for alt text.`);let{data:i,width:a,height:o}=e||n.copyCanvas(null,null,!0).imageData,s=yield r.guess({name:`altText`,request:{data:i,width:a,height:o,channels:i.length/(a*o)}});if(!s)throw Error(`No response from the AI service.`);if(s.error)throw Error(`Error from the AI service.`);if(s.cancel)return null;if(!s.output)throw Error(`No valid response from the AI service.`);let c=s.output;return yield n.setGuessedAltText(c),t&&!n.hasAltTextData()&&(n.altTextData={alt:c,decorative:!1}),c})()}remove(){if(x(Rv,this)){var e;C(Lv,this,null),this._uiManager.imageManager.deleteId(x(Rv,this)),(e=x(Uv,this))==null||e.remove(),C(Uv,this,null),x(Gv,this)&&(clearTimeout(x(Gv,this)),C(Gv,this,null))}super.remove()}rebuild(){if(!this.parent){x(Rv,this)&&f(Jv,this,Qv).call(this);return}super.rebuild(),this.div!==null&&(x(Rv,this)&&x(Uv,this)===null&&f(Jv,this,Qv).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(x(zv,this)||x(Lv,this)||x(Bv,this)||x(Vv,this)||x(Rv,this)||x(Wv,this))}get toolbarButtons(){return[[`altText`,this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;return this._isCopy&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.createAltText(),x(Wv,this)||(x(Lv,this)?f(Jv,this,$v).call(this):f(Jv,this,Qv).call(this)),this._isCopy&&this._moveAfterPaste(e,t),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,t){let{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(C(Rv,this,n),r&&C(Lv,this,r),C(Wv,this,!1),f(Jv,this,$v).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(x(Gv,this)!==null&&clearTimeout(x(Gv,this)),C(Gv,this,setTimeout(()=>{C(Gv,this,null),f(Jv,this,ty).call(this)},200)))}copyCanvas(e,t,n=!1){e||(e=224);let{width:r,height:i}=x(Lv,this),a=new Nt,o=x(Lv,this),s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e),c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);x(Kv,this)||(o=f(Jv,this,ey).call(this,e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,p=`#cfcfd8`;this._uiManager.hcmFilter===`none`?Ft.isDarkMode&&(d=`#8f8f9d`,p=`#42414d`):p=`black`;let m=15*a.sx,h=15*a.sy,g=new OffscreenCanvas(m*2,h*2),_=g.getContext(`2d`);_.fillStyle=d,_.fillRect(0,0,m*2,h*2),_.fillStyle=p,_.fillRect(0,0,m,h),_.fillRect(m,h,m,h),u.fillStyle=u.createPattern(g,`repeat`),u.fillRect(0,0,e,n),u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e)t=o.width,n=o.height;else if(o=x(Lv,this),r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a),n=Math.floor(i*a),x(Kv,this)||(o=f(Jv,this,ey).call(this,t,n))}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n),u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}static deserialize(e,t,n){var r=()=>super.deserialize,i=this;return v(function*(){let a=null,o=!1;if(e instanceof eh){var s;let{data:{rect:r,rotation:i,id:c,structParent:l,popupRef:u,richText:d,contentsObj:f,creationDate:p,modificationDate:m},container:h,parent:{page:{pageNumber:g}},canvas:_}=e,v,y;_?(delete e.canvas,{id:v,bitmap:y}=n.imageManager.getFromCanvas(h.id,_),_.remove()):(o=!0,e._hasNoCanvas=!0);let b=((s=yield t._structTree.getAriaAttributes(`${we}${c}`))==null?void 0:s.get(`aria-label`))||``;a=e={annotationType:N.STAMP,bitmapId:v,bitmap:y,pageIndex:g-1,rect:r.slice(0),rotation:i,annotationElementId:c,id:c,deleted:!1,accessibilityData:{decorative:!1,altText:b},isSvg:!1,structParent:l,popupRef:u,richText:d,comment:(f==null?void 0:f.str)||null,creationDate:p,modificationDate:m}}let c=yield r().call(i,e,t,n),{rect:l,bitmap:u,bitmapUrl:d,bitmapId:f,isSvg:p,accessibilityData:m}=e;o?(n.addMissingCanvas(e.id,c),C(Wv,c,!0)):f&&n.imageManager.isValidId(f)?(C(Rv,c,f),u&&C(Lv,c,u)):C(Bv,c,d),C(Kv,c,p);let[h,g]=c.pageDimensions;return c.width=(l[2]-l[0])/h,c.height=(l[3]-l[1])/g,m&&(c.altTextData=m),c._initialData=a,e.comment&&c.setCommentData(e),C(qv,c,!!a),c})()}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=Object.assign(super.serialize(e),{bitmapId:x(Rv,this),isSvg:x(Kv,this)});if(this.addComment(n),e)return n.bitmapUrl=f(Jv,this,ny).call(this,!0),n.accessibilityData=this.serializeAltText(!0),n.isCopy=!0,n;let{decorative:r,altText:i}=this.serializeAltText(!1);if(!r&&i&&(n.accessibilityData={type:`Figure`,alt:i}),this.annotationElementId){let e=f(Jv,this,ry).call(this,n);if(e.isSame)return null;if(e.isSameAltText)delete n.accessibilityData;else{var a;n.accessibilityData.structParent=(a=this._initialData.structParent)==null?-1:a}return n.id=this.annotationElementId,delete n.bitmapId,n}if(t===null)return n;t.stamps||(t.stamps=new Map);let o=x(Kv,this)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!t.stamps.has(x(Rv,this)))t.stamps.set(x(Rv,this),{area:o,serialized:n}),n.bitmap=f(Jv,this,ny).call(this,!1);else if(x(Kv,this)){let e=t.stamps.get(x(Rv,this));o>e.area&&(e.area=o,e.serialized.bitmap.close(),e.serialized.bitmap=f(Jv,this,ny).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}};function Xv(e,t=!1){if(!e){this.remove();return}C(Lv,this,e.bitmap),t||(C(Rv,this,e.id),C(Kv,this,e.isSvg)),e.file&&C(Hv,this,e.file.name),f(Jv,this,$v).call(this)}function Zv(){if(C(zv,this,null),this._uiManager.enableWaiting(!1),x(Uv,this)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&x(Lv,this)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&x(Lv,this)){this._reportTelemetry({action:`pdfjs.image.image_added`,data:{alt_text_modal:!1,alt_text_type:`empty`}});try{this.mlGuessAltText()}catch(e){}}this.div.focus()}}function Qv(){var e=this;if(x(Rv,this)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(x(Rv,this)).then(e=>f(Jv,this,Xv).call(this,e,!0)).finally(()=>f(Jv,this,Zv).call(this));return}if(x(Bv,this)){let e=x(Bv,this);C(Bv,this,null),this._uiManager.enableWaiting(!0),C(zv,this,this._uiManager.imageManager.getFromUrl(e).then(e=>f(Jv,this,Xv).call(this,e)).finally(()=>f(Jv,this,Zv).call(this)));return}if(x(Vv,this)){let e=x(Vv,this);C(Vv,this,null),this._uiManager.enableWaiting(!0),C(zv,this,this._uiManager.imageManager.getFromFile(e).then(e=>f(Jv,this,Xv).call(this,e)).finally(()=>f(Jv,this,Zv).call(this)));return}let t=document.createElement(`input`);t.type=`file`,t.accept=Pt.join(`,`);let n=this._uiManager._signal;C(zv,this,new Promise(r=>{t.addEventListener(`change`,v(function*(){if(!t.files||t.files.length===0)e.remove();else{e._uiManager.enableWaiting(!0);let n=yield e._uiManager.imageManager.getFromFile(t.files[0]);e._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:e._uiManager.useNewAltTextFlow}}),f(Jv,e,Xv).call(e,n)}r()}),{signal:n}),t.addEventListener(`cancel`,()=>{this.remove(),r()},{signal:n})}).finally(()=>f(Jv,this,Zv).call(this))),t.click()}function $v(){var e;let{div:t}=this,{width:n,height:r}=x(Lv,this),[i,a]=this.pageDimensions,o=.75;if(this.width)n=this.width*i,r=this.height*a;else if(n>o*i||r>o*a){let e=Math.min(o*i/n,o*a/r);n*=e,r*=e}this._uiManager.enableWaiting(!1);let s=C(Uv,this,document.createElement(`canvas`));s.setAttribute(`role`,`img`),this.addContainer(s),this.width=n/i,this.height=r/a,this.setDims(),(e=this._initialOptions)!=null&&e.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),f(Jv,this,ty).call(this),x(qv,this)||(this.parent.addUndoableEditor(this),C(qv,this,!0)),this._reportTelemetry({action:`inserted_image`}),x(Hv,this)&&this.div.setAttribute(`aria-description`,x(Hv,this)),this.annotationElementId||this._uiManager.a11yAlert(G._l10nAlert.stamp)}function ey(e,t){let{width:n,height:r}=x(Lv,this),i=n,a=r,o=x(Lv,this);for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=Math.ceil(i/2)),a>2*t&&(a=Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a),o=s.transferToImageBitmap()}return o}function ty(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new Nt,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=x(Uv,this);if(!s||s.width===a&&s.height===o)return;s.width=a,s.height=o;let c=x(Kv,this)?x(Lv,this):f(Jv,this,ey).call(this,a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter,l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}function ny(e){if(e){if(x(Kv,this)){let e=this._uiManager.imageManager.getSvgUrl(x(Rv,this));if(e)return e}let e=document.createElement(`canvas`);return{width:e.width,height:e.height}=x(Lv,this),e.getContext(`2d`).drawImage(x(Lv,this),0,0),e.toDataURL()}if(x(Kv,this)){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*ft.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*ft.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);return i.getContext(`2d`).drawImage(x(Lv,this),0,0,x(Lv,this).width,x(Lv,this).height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(x(Lv,this))}function ry(e){var t;let{pageIndex:n,accessibilityData:{altText:r}}=this._initialData,i=e.pageIndex===n,a=(((t=e.accessibilityData)==null?void 0:t.alt)||``)===r;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}}g(Yv,`_type`,`stamp`),g(Yv,`_editorType`,N.STAMP);var iy=new WeakMap,ay=new WeakMap,oy=new WeakMap,sy=new WeakMap,cy=new WeakMap,ly=new WeakMap,uy=new WeakMap,dy=new WeakMap,fy=new WeakMap,py=new WeakMap,my=new WeakMap,hy=new WeakMap,gy=new WeakMap,_y=new WeakMap,vy=new WeakMap,$=new WeakMap,yy=new WeakSet,by=class e{constructor({uiManager:t,pageIndex:n,div:r,structTreeLayer:i,accessibilityManager:a,annotationLayer:o,drawLayer:s,textLayer:c,viewport:l,l10n:u}){S(this,yy),b(this,iy,void 0),b(this,ay,!1),b(this,oy,null),b(this,sy,null),b(this,cy,null),b(this,ly,new Map),b(this,uy,!1),b(this,dy,!1),b(this,fy,!1),b(this,py,null),b(this,my,null),b(this,hy,null),b(this,gy,null),b(this,_y,null),b(this,vy,-1),b(this,$,void 0);let d=[...Dy._.values()];if(!e._initialized){e._initialized=!0;for(let e of d)e.initialize(u,t)}t.registerEditorTypes(d),C($,this,t),this.pageIndex=n,this.div=r,C(iy,this,a),C(oy,this,o),this.viewport=l,C(hy,this,c),this.drawLayer=s,this._structTree=i,x($,this).addLayer(this)}get isEmpty(){return x(ly,this).size===0}get isInvisible(){return this.isEmpty&&x($,this).getMode()===N.NONE}updateToolbar(e){x($,this).updateToolbar(e)}updateMode(e=x($,this).getMode()){switch(f(yy,this,Ey).call(this),e){case N.NONE:this.div.classList.toggle(`nonEditing`,!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case N.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case N.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;if(t.toggle(`nonEditing`,!1),e===N.POPUP)t.toggle(`commentEditing`,!0);else{t.toggle(`commentEditing`,!1);for(let n of Dy._.values())t.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=x(hy,this))==null?void 0:t.div)}setEditingState(e){x($,this).setEditingState(e)}addCommands(e){x($,this).addCommands(e)}cleanUndoStack(e){x($,this).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=x(oy,this))==null||t.togglePointerEvents(e)}enable(){var e=this;return v(function*(){var t;C(fy,e,!0),e.div.tabIndex=0,e.togglePointerEvents(!0),e.div.classList.toggle(`nonEditing`,!1),(t=x(_y,e))==null||t.abort(),C(_y,e,null);let n=new Set;for(let t of xy.call(f(yy,e)))t.enableEditing(),t.show(!0),t.annotationElementId&&(x($,e).removeChangedExistingAnnotation(t),n.add(t.annotationElementId));let r=x(oy,e);if(r)for(let t of r.getEditableAnnotations()){if(t.hide(),x($,e).isDeletedAnnotationElement(t.data.id)||n.has(t.data.id))continue;let r=yield e.deserialize(t);r&&(e.addOrRebuild(r),r.enableEditing())}C(fy,e,!1),x($,e)._eventBus.dispatch(`editorsrendered`,{source:e,pageNumber:e.pageIndex+1})})()}disable(){if(C(dy,this,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle(`nonEditing`,!0),x(hy,this)&&!x(_y,this)){C(_y,this,new AbortController);let e=x($,this).combinedSignal(x(_y,this));x(hy,this).div.addEventListener(`pointerdown`,e=>{let{clientX:t,clientY:n,timeStamp:r}=e;if(r-x(vy,this)>500){C(vy,this,r);return}C(vy,this,-1);let{classList:i}=this.div;i.toggle(`getElements`,!0);let a=document.elementsFromPoint(t,n);if(i.toggle(`getElements`,!1),!this.div.contains(a[0]))return;let o,s=RegExp(`^${Te}[0-9]+$`);for(let e of a)if(s.test(e.id)){o=e.id;break}if(!o)return;let c=x(ly,this).get(o);(c==null?void 0:c.annotationElementId)===null&&(wt(e),c.dblclick(e))},{signal:e,capture:!0})}let e=x(oy,this),t=[];if(e){let r=new Map,i=new Map;for(let e of xy.call(f(yy,this))){var n;if(e.disableEditing(),!e.annotationElementId){t.push(e);continue}if(e.serialize()!==null){r.set(e.annotationElementId,e);continue}else i.set(e.annotationElementId,e);(n=this.getEditableAnnotation(e.annotationElementId))==null||n.show(),e.remove()}for(let t of e.getEditableAnnotations()){let{id:e}=t.data;if(x($,this).isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let n=i.get(e);if(n){n.resetAnnotationElement(t),n.show(!1),t.show();continue}n=r.get(e),n&&(x($,this).addChangedExistingAnnotation(n),n.renderAnnotationElement(t)&&n.show(!1)),t.show()}}f(yy,this,Ey).call(this),this.isEmpty&&(this.div.hidden=!0);let{classList:r}=this.div;for(let e of Dy._.values())r.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e==null||e.updateFakeAnnotations(t),C(dy,this,!1)}getEditableAnnotation(e){var t;return((t=x(oy,this))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){x($,this).getActive()!==e&&x($,this).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=x(hy,this))!=null&&e.div&&!x(gy,this)){C(gy,this,new AbortController);let e=x($,this).combinedSignal(x(gy,this));x(hy,this).div.addEventListener(`pointerdown`,f(yy,this,Sy).bind(this),{signal:e}),x(hy,this).div.classList.add(`highlighting`)}}disableTextSelection(){var e;this.div.tabIndex=0,(e=x(hy,this))!=null&&e.div&&x(gy,this)&&(x(gy,this).abort(),C(gy,this,null),x(hy,this).div.classList.remove(`highlighting`))}enableClick(){if(x(sy,this))return;C(sy,this,new AbortController);let e=x($,this).combinedSignal(x(sy,this));this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener(`pointerup`,t,{signal:e}),this.div.addEventListener(`pointercancel`,t,{signal:e})}disableClick(){var e;(e=x(sy,this))==null||e.abort(),C(sy,this,null)}attach(e){x(ly,this).set(e.id,e);let{annotationElementId:t}=e;t&&x($,this).isDeletedAnnotationElement(t)&&x($,this).removeDeletedAnnotationElement(e)}detach(e){var t;x(ly,this).delete(e.id),(t=x(iy,this))==null||t.removePointerInTextLayer(e.contentDiv),!x(dy,this)&&e.annotationElementId&&x($,this).addDeletedAnnotationElement(e)}remove(e){this.detach(e),x($,this).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(x($,this).addDeletedAnnotationElement(e),G.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),x($,this).addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!x(fy,this)),x($,this).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var t;if(!e.isAttachedToDOM)return;let{activeElement:n}=document;e.div.contains(n)&&!x(cy,this)&&(e._focusEventsAllowed=!1,C(cy,this,setTimeout(()=>{C(cy,this,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:x($,this)._signal}),n.focus())},0))),e._structTreeParentId=(t=x(iy,this))==null?void 0:t.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(let t of x(ly,this).values())if(t.uid===e)return t;return null}combinedSignal(e){return x($,this).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=Cy.call(f(yy,this)))==null?void 0:e.canCreateNewEmptyEditor()}pasteEditor(e,t){var n=this;return v(function*(){n.updateToolbar(e),yield x($,n).updateMode(e.mode);let{offsetX:r,offsetY:i}=f(yy,n,Ty).call(n),a=x($,n).getId(),o=f(yy,n,wy).call(n,T({parent:n,id:a,x:r,y:i,uiManager:x($,n),isCentered:!0},t));o&&n.add(o)})()}deserialize(e){var t=this;return v(function*(){var n,r;return(yield(n=Dy._.get((r=e.annotationType)==null?e.annotationEditorType:r))==null?void 0:n.deserialize(e,t,x($,t)))||null})()}createAndAddNewEditor(e,t,n={}){let r=x($,this).getId(),i=f(yy,this,wy).call(this,T({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:x($,this),isCentered:t},n));return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(e={}){this.createAndAddNewEditor(f(yy,this,Ty).call(this),!0,e)}setSelected(e){x($,this).setSelected(e)}toggleSelected(e){x($,this).toggleSelected(e)}unselect(e){x($,this).unselect(e)}pointerup(e){var t;let{isMac:n}=z.platform;if(e.button!==0||e.ctrlKey&&n||e.target!==this.div||!x(uy,this)||(C(uy,this,!1),(t=Cy.call(f(yy,this)))!=null&&t.isDrawer&&Cy.call(f(yy,this)).supportMultipleDrawings))return;if(!x(ay,this)){C(ay,this,!0);return}let r=x($,this).getMode();if(r===N.STAMP||r===N.POPUP||r===N.SIGNATURE){x($,this).unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){var t;if(x($,this).getMode()===N.HIGHLIGHT&&this.enableTextSelection(),x(uy,this)){C(uy,this,!1);return}let{isMac:n}=z.platform;if(e.button!==0||e.ctrlKey&&n||e.target!==this.div)return;if(C(uy,this,!0),(t=Cy.call(f(yy,this)))!=null&&t.isDrawer){this.startDrawingSession(e);return}let r=x($,this).getActive();C(ay,this,!r||r.isEmpty())}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),x(py,this)){Cy.call(f(yy,this)).startDrawing(this,x($,this),!1,e);return}x($,this).setCurrentDrawingSession(this),C(py,this,new AbortController);let t=x($,this).combinedSignal(x(py,this));this.div.addEventListener(`blur`,({relatedTarget:e})=>{e&&!this.div.contains(e)&&(C(my,this,null),this.commitOrRemove())},{signal:t}),Cy.call(f(yy,this)).startDrawing(this,x($,this),!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&C(my,this,e);return}x(my,this)&&setTimeout(()=>{var e;(e=x(my,this))==null||e.focus(),C(my,this,null)},0)}endDrawingSession(e=!1){return x(py,this)?(x($,this).setCurrentDrawingSession(null),x(py,this).abort(),C(py,this,null),C(my,this,null),Cy.call(f(yy,this)).endDrawing(e)):null}findNewParent(e,t,n){let r=x($,this).findParent(t,n);return r===null||r===this?!1:(r.changeParent(e),!0)}commitOrRemove(){return x(py,this)?(this.endDrawingSession(),!0):!1}onScaleChanging(){x(py,this)&&Cy.call(f(yy,this)).onScaleChangingWhenDrawing(this)}destroy(){var e;this.commitOrRemove(),((e=x($,this).getActive())==null?void 0:e.parent)===this&&(x($,this).commitOrRemove(),x($,this).setActiveEditor(null)),x(cy,this)&&(clearTimeout(x(cy,this)),C(cy,this,null));for(let e of x(ly,this).values()){var t;(t=x(iy,this))==null||t.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove()}this.div=null,x(ly,this).clear(),x($,this).removeLayer(this)}render({viewport:e}){var t=this;return v(function*(){t.viewport=e,Mt(t.div,e);for(let e of x($,t).getEditors(t.pageIndex))t.add(e),e.rebuild();yield x($,t).findClonesForPage(t),t.div.hidden=t.isEmpty,t.updateMode()})()}update({viewport:e}){x($,this).commitOrRemove(),f(yy,this,Ey).call(this);let t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Mt(this.div,{rotation:n}),t!==n)for(let e of x(ly,this).values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return x($,this).viewParameters.realScale}};function xy(){return x(ly,this).size===0?x($,this).getEditors(this.pageIndex):x(ly,this).values()}function Sy(e){x($,this).unselectAll();let{target:t}=e;if(t===x(hy,this).div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`)||t.classList.contains(`textLayerImages`)||t.classList.contains(`textLayerImagePlaceholder`))&&x(hy,this).div.contains(t)){let{isMac:t}=z.platform;if(e.button!==0||e.ctrlKey&&t)return;x($,this).showAllEditors(`highlight`,!0,!0),x(hy,this).div.classList.add(`free`),this.toggleDrawing(),e_.startHighlighting(this,x($,this).direction===`ltr`,{target:x(hy,this).div,x:e.x,y:e.y}),x(hy,this).div.addEventListener(`pointerup`,()=>{x(hy,this).div.classList.remove(`free`),this.toggleDrawing(!0)},{once:!0,signal:x($,this)._signal}),e.preventDefault()}}function Cy(){return Dy._.get(x($,this).getMode())}function wy(e){let t=Cy.call(f(yy,this));return t?new t.prototype.constructor(e):null}function Ty(){let{x:e,y:t,width:n,height:r}=this.boundingClientRect,i=Math.max(0,e),a=Math.max(0,t),o=Math.min(window.innerWidth,e+n),s=Math.min(window.innerHeight,t+r),c=(i+o)/2-e,l=(a+s)/2-t,[u,d]=this.viewport.rotation%180==0?[c,l]:[l,c];return{offsetX:u,offsetY:d}}function Ey(){for(let e of x(ly,this).values())e.isEmpty()&&e.remove()}g(by,`_initialized`,!1);var Dy={_:new Map([Ah,dv,Yv,e_,Iv].map(e=>[e._editorType,e]))};function Oy(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ky(e){var t;return e?e.nodeType===Node.ELEMENT_NODE?e.closest(`.textLayer`):((t=e.parentElement)==null?void 0:t.closest(`.textLayer`))||null:null}function Ay(e,t,n,r){if(e===n)return t<=r;let i=e.compareDocumentPosition(n);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function jy(e,t,n){if(e.nodeType!==Node.ELEMENT_NODE||!e.classList.contains(`textLayer`)||t!==e.childNodes.length)return{container:e,offset:t};let r=e.lastChild;return(r==null?void 0:r.nodeType)===Node.ELEMENT_NODE&&r.classList.contains(`endOfContent`)&&(r=r.previousSibling),!r||!n.contains(r)?null:r.nodeType===Node.TEXT_NODE?{container:r,offset:r.textContent.length}:{container:r,offset:r.childNodes.length}}var My=new WeakMap,Ny=new WeakMap,Py=new WeakMap,Fy=new WeakMap,Iy=new WeakMap,Ly=new WeakMap,Ry=new WeakMap,zy=new WeakSet,By=class e{constructor({filterFactory:t=null,pageColors:n=null,pageIndex:r,textLayer:i=null}){if(S(this,zy),b(this,My,null),b(this,Ny,new Map),b(this,Py,null),b(this,Fy,null),b(this,Iy,null),b(this,Ly,null),b(this,Ry,new Map),this.pageIndex=r,C(Fy,this,t),C(Iy,this,n),i){let t=tb._.get(i);if(t!=null&&t.selectionDiv&&(t.selectionDiv.remove(),Qy._.delete(t.selectionDiv)),tb._.set(i,{drawLayer:this}),eb._.add(i),C(Py,this,i),C(Ly,this,new MutationObserver(t=>{var n;if(!(!x(My,this)||!((n=x(Py,this))!=null&&n.isConnected)||!Hy.call(e))){for(let{addedNodes:n}of t)for(let t of n)if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains(`endOfContent`)){Wy.call(e);return}}})),x(Ly,this).observe(i,{childList:!0}),Zy._===null){Zy._=new AbortController;let{signal:t}=Zy._;document.addEventListener(`selectionchange`,Wy.bind(e),{signal:t}),document.addEventListener(`pointerdown`,()=>{$y._=!0},{signal:t}),document.addEventListener(`pointerup`,()=>{$y._=!1},{signal:t}),window.addEventListener(`blur`,()=>{$y._=!1},{signal:t})}}}setParent(t){if(!x(My,this)){var n;C(My,this,t),(n=x(Py,this))!=null&&n.isConnected&&Hy.call(e)&&Wy.call(e);return}if(x(My,this)!==t){if(x(Ny,this).size>0)for(let e of x(Ny,this).values())e.remove(),t.append(e);C(My,this,t)}}static get _svgFactory(){return R(this,`_svgFactory`,new yp)}draw(t,n=!1,r=!1){var i,a;let o=(Yy._=(i=Yy._,a=i++,i),a),s=f(zy,this,Ky).call(this),c=e._svgFactory.createElement(`defs`);s.append(c);let l=e._svgFactory.createElement(`path`);c.append(l);let u=`path_${o}`;l.setAttribute(`id`,u),l.setAttribute(`vector-effect`,`non-scaling-stroke`),n&&x(Ry,this).set(o,l);let d=r?f(zy,this,qy).call(this,c,u):null,p=e._svgFactory.createElement(`use`);return s.append(p),p.setAttribute(`href`,`#${u}`),this.updateProperties(s,t),x(Ny,this).set(o,s),{id:o,clipPathId:`url(#${d})`}}drawOutline(t,n){var r,i;let a=(Yy._=(r=Yy._,i=r++,r),i),o=f(zy,this,Ky).call(this),s=e._svgFactory.createElement(`defs`);o.append(s);let c=e._svgFactory.createElement(`path`);s.append(c);let l=`path_${a}`;c.setAttribute(`id`,l),c.setAttribute(`vector-effect`,`non-scaling-stroke`);let u;if(n){let t=e._svgFactory.createElement(`mask`);s.append(t),u=`mask_${a}`,t.setAttribute(`id`,u),t.setAttribute(`maskUnits`,`objectBoundingBox`);let n=e._svgFactory.createElement(`rect`);t.append(n),n.setAttribute(`width`,`1`),n.setAttribute(`height`,`1`),n.setAttribute(`fill`,`white`);let r=e._svgFactory.createElement(`use`);t.append(r),r.setAttribute(`href`,`#${l}`),r.setAttribute(`stroke`,`none`),r.setAttribute(`fill`,`black`),r.setAttribute(`fill-rule`,`nonzero`),r.classList.add(`mask`)}let d=e._svgFactory.createElement(`use`);o.append(d),d.setAttribute(`href`,`#${l}`),u&&d.setAttribute(`mask`,`url(#${u})`);let p=d.cloneNode();return o.append(p),d.classList.add(`mainOutline`),p.classList.add(`secondaryOutline`),this.updateProperties(o,t),x(Ny,this).set(a,o),a}finalizeDraw(e,t){x(Ry,this).delete(e),this.updateProperties(e,t)}updateProperties(t,n){if(!n)return;let{root:r,bbox:i,rootClass:a,path:o}=n,s=typeof t==`number`?x(Ny,this).get(t):t;if(s){if(r&&f(zy,this,Jy).call(this,s,r),i&&Gy.call(e,s,i),a){let{classList:e}=s;for(let[t,n]of Object.entries(a))e.toggle(t,n)}if(o){let e=s.firstElementChild.firstElementChild;f(zy,this,Jy).call(this,e,o)}}}updateParent(e,t){if(t===this)return;let n=x(Ny,this).get(e);n&&(x(My,t).append(n),x(Ny,this).delete(e),x(Ny,t).set(e,n))}remove(e){x(Ry,this).delete(e),x(My,this)!==null&&(x(Ny,this).get(e).remove(),x(Ny,this).delete(e))}destroy(){var t;C(My,this,null);for(let e of x(Ny,this).values())e.remove();if(x(Ny,this).clear(),x(Ry,this).clear(),(t=x(Ly,this))==null||t.disconnect(),C(Ly,this,null),x(Py,this)){let t=tb._.get(x(Py,this));if((t==null?void 0:t.drawLayer)===this&&(Vy.call(e,x(Py,this)),tb._.delete(x(Py,this)),eb._.delete(x(Py,this)),eb._.size===0)){var n;(n=Zy._)==null||n.abort(),Zy._=null,$y._=!1}C(Py,this,null)}}};de=By;function Vy(e){let t=f(de,this,tb)._.get(e);t!=null&&t.selectionDiv&&(t.selectionDiv.remove(),f(de,this,Qy)._.delete(t.selectionDiv),t.selectionDiv=null,t.path=null)}function Hy(){let e=document.getSelection();return!!e&&!e.isCollapsed}function Uy(){return[...f(de,this,eb)._].filter(e=>e.isConnected).sort(Oy)}function Wy(){let e=document.getSelection();if(!e||e.isCollapsed){for(let e of f(de,this,Qy)._)e.remove();f(de,this,Qy)._.clear();return}let t=new WeakMap,n=f(de,this,Uy).call(this),r=[];for(let t=0,i=e.rangeCount;t<i;t++){let i=e.getRangeAt(t);if(i.collapsed)continue;let{startContainer:a,startOffset:o,endContainer:s,endOffset:c}=i,l=ky(a),u=ky(s),d=l===null,p=u===null;if(f(de,this,$y)._&&d!==p)return;if(e.rangeCount===1){let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:i}=e,d=ky(t),f=ky(r),p=Ay(t,n,r,i);d&&f&&p!==null&&(p?(a=t,o=n,l=d,s=r,c=i,u=f):(a=r,o=i,l=f,s=t,c=n,u=d))}let m=n.filter(e=>i.intersectsNode(e));if(m.length===0)continue;let h=!1;if(l||(l=m[0],a=l,o=0,h=!0),u||(u=m.at(-1),s=u,c=u.childNodes.length,h=!0),s.nodeType===Node.ELEMENT_NODE){if(s.classList.contains(`endOfContent`)){let e=s.previousSibling;if(!e)continue;s=e,c=e.nodeType===Node.TEXT_NODE?e.textContent.length:e.childNodes.length}else if(s.classList.contains(`textLayer`)&&s.childNodes.length===c){let e=jy(s,c,u);if(!e)continue;s=e.container,c=e.offset}}if(a.nodeType===Node.ELEMENT_NODE){let e=jy(a,o,l);if(!e)continue;a=e.container,o=e.offset}if(l===u&&!h&&m.includes(l)){r.push([i,l]);continue}for(let e of m){let t=e.firstChild;if(!t)continue;let n=document.createRange();if(e===l?n.setStart(a,o):n.setStartBefore(t),e===u)n.setEnd(s,c);else{let t=e.lastChild;if(!t)continue;if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains(`endOfContent`)){let e=t.previousSibling;if(!e)continue;n.setEndAfter(e)}else n.setEndAfter(t)}n.collapsed||r.push([n,e])}}let i=new Set(r.map(e=>e[1]));for(let e of f(de,this,eb)._)i.has(e)||f(de,this,Vy).call(this,e);for(let[e,n]of r){let r=tb._.get(n);if(!r)continue;let i=t.get(n);if(!i){let e=n.getBoundingClientRect();i=(t,n,r,i)=>({x:(t-e.x)/e.width,y:(n-e.y)/e.height,width:r/e.width,height:i/e.height}),t.set(n,i)}let c=[];for(let{x:t,y:n,width:r,height:a}of e.getClientRects())r===0||a===0||({x:t,y:n,width:r,height:a}=i(t,n,r,a),!(r===1&&a===1)&&c.push(`M${t} ${n} h${r} v${a} h-${r} Z`));if(c.length===0)continue;let l=r.drawLayer,u=r.selectionDiv,d=r.path;if(!u){var a,o,s;let e=`clip_selection_${Xy._=(a=Xy._,o=a++,a),o}`;u=document.createElement(`div`),u.className=`selection`,u.style.clipPath=`url(#${e})`;let t=(s=x(Fy,l))==null?void 0:s.createSelectionStyle(x(Iy,l));if(t)for(let[e,n]of Object.entries(t))u.style.setProperty(e,n);let n=de._svgFactory.create(1,1,!0);n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`width`,`100%`),n.setAttribute(`height`,`100%`);let i=de._svgFactory.createElement(`clipPath`);i.setAttribute(`id`,e),i.setAttribute(`clipPathUnits`,`objectBoundingBox`),d=de._svgFactory.createElement(`path`),i.append(d),n.append(i),u.append(n),r.path=d,r.selectionDiv=u}!u.parentNode&&x(My,l)&&(x(My,l).append(u),f(de,this,Qy)._.add(u)),d.setAttribute(`d`,c.join(` `))}}function Gy(e,[t,n,r,i]){let{style:a}=e;a.top=`${100*n}%`,a.left=`${100*t}%`,a.width=`${100*r}%`,a.height=`${100*i}%`}function Ky(){let e=de._svgFactory.create(1,1,!0);return x(My,this).append(e),e.setAttribute(`aria-hidden`,`true`),e}function qy(e,t){let n=de._svgFactory.createElement(`clipPath`);e.append(n);let r=`clip_${t}`;n.setAttribute(`id`,r),n.setAttribute(`clipPathUnits`,`objectBoundingBox`);let i=de._svgFactory.createElement(`use`);return n.append(i),i.setAttribute(`href`,`#${t}`),i.classList.add(`clip`),r}function Jy(e,t){for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r)}var Yy={_:0},Xy={_:0},Zy={_:null},Qy={_:new Set},$y={_:!1},eb={_:new Set},tb={_:new WeakMap};function nb(e){return`${(e*100).toFixed(2)}%`}var rb=new WeakMap,ib=new WeakMap,ab=new WeakMap,ob=new WeakMap,sb=new WeakMap,cb=new WeakMap,lb=new WeakSet,ub=class{constructor(e,t,n,r){S(this,lb),b(this,rb,[]),b(this,ib,new Map),b(this,ab,null),b(this,ob,0),b(this,sb,0),b(this,cb,0),C(ob,this,e),C(rb,this,t),C(sb,this,n.rawDims.pageWidth),C(cb,this,n.rawDims.pageHeight),C(ab,this,r)}render(){let e=document.createElement(`div`);e.className=`textLayerImages`;for(let t=0;t<x(rb,this).length;t+=6){let n=f(lb,this,db).call(this,x(rb,this).subarray(t,t+6));n&&e.append(n)}return e.addEventListener(`contextmenu`,e=>{var t;if(!(e.target instanceof HTMLCanvasElement))return;let n=e.target,r=x(ib,this).get(n);if(!r)return;let i=(t=fb._)==null?void 0:t.deref();if(i===n)return;i&&(i.width=0,i.height=0),fb._=new WeakRef(n);let{inverseTransform:a,x1:o,y1:s,width:c,height:l}=r,u=x(ab,this).call(this),d=Math.ceil(o*u.width),f=Math.ceil(s*u.height),p=Math.floor((o+c/x(sb,this))*u.width),m=Math.floor((s+l/x(cb,this))*u.height);n.width=p-d,n.height=m-f;let h=n.getContext(`2d`);h.setTransform(...a),h.translate(-d,-f),h.drawImage(u,0,0)}),e}};function db([e,t,n,r,i,a]){let o=Math.hypot((i-e)*x(sb,this),(a-t)*x(cb,this)),s=Math.hypot((n-e)*x(sb,this),(r-t)*x(cb,this));if(o<x(ob,this)||s<x(ob,this))return null;let c=[(i-e)*x(sb,this)/o,(a-t)*x(cb,this)/o,(n-e)*x(sb,this)/s,(r-t)*x(cb,this)/s,0,0],l=B.inverseTransform(c),u=document.createElement(`canvas`);return u.className=`textLayerImagePlaceholder`,u.width=0,u.height=0,Object.assign(u.style,{opacity:0,position:`absolute`,left:nb(e),top:nb(t),width:nb(o/x(sb,this)),height:nb(s/x(cb,this)),transformOrigin:`0% 0%`,transform:`matrix(${c.join(`,`)})`}),x(ib,this).set(u,{inverseTransform:l,width:o,height:s,x1:e,y1:t}),u}var fb={_:null};globalThis._pdfjsTestingUtils={HighlightOutliner:Tg},globalThis.pdfjsLib={AbortException:Ye,AnnotationEditorLayer:by,AnnotationEditorParamsType:P,AnnotationEditorType:N,AnnotationEditorUIManager:Lr,AnnotationLayer:xh,AnnotationMode:Ce,AnnotationType:ke,applyOpacity:Lt,build:Uf,ColorPicker:tp,createValidAbsoluteUrl:Be,CSSConstants:It,DOMSVGFactory:yp,DrawLayer:By,FeatureTest:z,fetchData:pt,findContrastColor:Ut,getDocument:ef,getFilenameFromUrl:vt,getPdfFilenameFromUrl:yt,getRGB:Ot,getRGBA:Dt,getUuid:it,GlobalWorkerOptions:zu,ImageKind:Oe,InvalidPDFException:Ke,isDataScheme:gt,isPdfFile:_t,isValidExplicitDest:Ns,makeArr:ot,makeMap:st,makeObj:ct,MathClamp:V,noContextMenu:Ct,normalizeUnicode:rt,OPS:F,OutputScale:Nt,PasswordException:We,PasswordResponses:Ne,PDFDataRangeTransport:of,PDFDateString:Tt,PDFWorker:vf,PermissionFlag:Ee,PixelsPerInch:ft,RenderingCancelledException:ht,renderRichText:Wt,ResponseException:qe,setLayerDimensions:Mt,shadow:R,SignatureExtractor:gv,stopEvent:wt,SupportedImageMimeTypes:Pt,TextLayer:Bd,TextLayerImages:ub,TouchManager:Yi,updateUrlHash:Ve,Util:B,VerbosityLevel:je,version:Hf,XfaLayer:dt};var pb=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`,mb=[`#000000`,`#475569`,`#dc2626`,`#f97316`,`#eab308`,`#16a34a`,`#2563eb`,`#7c3aed`,`#db2777`,`#ffffff`],hb=[`transparent`,`#f8fafc`,`#fee2e2`,`#ffedd5`,`#fef9c3`,`#dcfce7`,`#dbeafe`,`#f3e8ff`,`#fce7f3`,`#ffffff`],gb=e=>{let t=`font-size: ${e.fontSize}; color: ${e.color}; text-align: ${e.textAlign};`;e.fontFamily&&(t+=` font-family: ${e.fontFamily};`),t+=` font-weight: ${e.fontWeight};`,e.bold&&(t+=` font-weight: bold;`),e.italic&&(t+=` font-style: italic;`);let n=[];e.underline&&n.push(`underline`),e.strikethrough&&n.push(`line-through`),n.length>0&&(t+=` text-decoration: ${n.join(` `)};`);let r=[`fontSize`,`fontWeight`,`color`,`textAlign`,`fontFamily`,`bold`,`italic`,`underline`,`strikethrough`,`customCss`,`sameRow`];return Object.entries(e).forEach(([e,n])=>{if(r.includes(e)||n==null||n===``)return;let i=e.replace(/([A-Z])/g,`-$1`).toLowerCase();t+=` ${i}: ${n};`}),e.customCss&&(t+=` ${e.customCss}`),t},_b=e=>{if(!e||!e.trim())return{};let t={};return e.split(`;`).forEach(e=>{let n=e.split(`:`);if(n.length>=2){let e=n[0].trim().replace(/-([a-z])/g,e=>e[1].toUpperCase()),r=n.slice(1).join(`:`).trim();e&&r&&(t[e]=r)}}),t},vb=e=>{let t={0:`1010011`,1:`1101001`,2:`1100101`,3:`1001101`,4:`1011001`,5:`1010011`,6:`1101011`,7:`1101101`,8:`1001111`,9:`1110011`,A:`1100010`,B:`1000110`,C:`1100011`,D:`1011100`,E:`1001110`,F:`1110100`,G:`1110010`,H:`1101110`,I:`1100111`,J:`1011000`,K:`1000111`,L:`1100011`,M:`1011110`,N:`1111010`,O:`1110110`,P:`1110011`,Q:`1110010`,R:`1101110`,S:`1100111`,T:`1011000`,U:`1000111`,V:`1100011`,W:`1011110`,X:`1111010`,Y:`1110110`,Z:`1110011`,"-":`1001011`,_:`1101001`,".":`1100101`," ":`1001101`},n=e||`BARCODE`,r=n.toUpperCase().replace(/[^0-9A-Z\-_\. ]/g,``),i=`1101001000`;for(let e=0;e<r.length;e++){let n=r[e];i+=t[n]||`1010011`}i+=`1100011101011`;let a=i.length*2,o=``;for(let e=0;e<i.length;e++)i[e]===`1`&&(o+=`<rect x="${e*2}" y="5" width="2" height="50" fill="black" />`);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${a} 70" width="100%" height="100%" style="display: block; margin: 0 auto;">
|
|
55
55
|
<rect width="100%" height="100%" fill="white" />
|
|
56
56
|
<g>${o}</g>
|
|
57
57
|
<text x="${a/2}" y="67" font-family="monospace" font-size="10" text-anchor="middle" fill="black">${n}</text>
|
|
58
|
-
</svg>`},yb=(e,t)=>{let n=`11px`,r=`400`;return e===`h1`?(n=`24px`,r=`700`):e===`h2`?(n=`20px`,r=`700`):e===`h3`?(n=`16px`,r=`600`):e===`h4`?(n=`14px`,r=`600`):e===`h5`?(n=`12px`,r=`600`):e===`h6`?(n=`10px`,r=`600`):e===`title`?(n=`28px`,r=`800`):e===`subtitle`?(n=`14px`,r=`300`):e===`caption`&&(n=`9px`,r=`400`),{id:`block-${Math.random().toString(36).substr(2,9)}`,type:e,content:t,style:{fontSize:n,fontWeight:r,color:`#1e293b`,backgroundColor:`transparent`,textAlign:`left`,bold:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`title`].includes(e),italic:!1,underline:!1,strikethrough:!1,width:`100%`,marginBottom:`8px`,padding:`8px`,minHeight:`auto`}}},bb=e=>{let t=new DOMParser().parseFromString(e,`text/html`),n=[],r=Array.from(t.body.children);if(r.length===0){let e=t.body.innerText||t.body.textContent||``;e.trim()&&n.push(yb(`p`,e.trim()))}else{let e=t.querySelectorAll(`style`),i=[];e.forEach(e=>{let t=e.textContent||``,n=/([^{]+)\{([^}]+)\}/g,r;for(;(r=n.exec(t))!==null;){let e=r[1].trim(),t=r[2].trim(),n={};t.split(`;`).forEach(e=>{let t=e.split(`:`);t.length===2&&(n[t[0].trim().toLowerCase()]=t[1].trim())}),i.push({selector:e,styles:n})}});let a=e=>{let t={fontSize:`11px`,fontWeight:`400`,color:`#1e293b`,backgroundColor:`transparent`,textAlign:`left`,bold:!1,italic:!1,underline:!1,strikethrough:!1,width:`100%`,marginBottom:`8px`,padding:`8px`},n=e.style;return n.fontSize&&(t.fontSize=n.fontSize),n.fontWeight&&(t.fontWeight=n.fontWeight),n.color&&(t.color=n.color),n.backgroundColor&&(t.backgroundColor=n.backgroundColor),n.textAlign&&(t.textAlign=n.textAlign),n.padding&&(t.padding=n.padding),n.marginBottom&&(t.marginBottom=n.marginBottom),n.width&&(t.width=n.width),i.forEach(n=>{try{e.matches(n.selector)&&(n.styles[`font-size`]&&(t.fontSize=n.styles[`font-size`]),n.styles[`font-weight`]&&(t.fontWeight=n.styles[`font-weight`]),n.styles.color&&(t.color=n.styles.color),n.styles[`background-color`]&&(t.backgroundColor=n.styles[`background-color`]),n.styles[`text-align`]&&(t.textAlign=n.styles[`text-align`]),n.styles.padding&&(t.padding=n.styles.padding),n.styles[`margin-bottom`]&&(t.marginBottom=n.styles[`margin-bottom`]),n.styles.width&&(t.width=n.styles.width))}catch(e){}}),(t.fontWeight===`bold`||parseInt(t.fontWeight)>=600)&&(t.bold=!0),t};r.forEach(e=>{let t=e;if(t.tagName===`STYLE`)return;let r=t.querySelector(`table, img, h1, h2, h3, h4, h5, h6, p, span, div`)||t,i=r.tagName.toLowerCase(),o=a(r);if(i===`table`){let e=Array.from(r.querySelectorAll(`thead th`));e.length===0&&(e=Array.from(r.querySelectorAll(`tr:first-child th, tr:first-child td`)));let t=e.map(e=>{var t,n;return{columnName:((t=e.textContent)==null?void 0:t.trim())||`Header`,placeholder:`{{item.${((n=e.textContent)==null?void 0:n.trim().toLowerCase().replace(/\s+/g,`_`))||`field`}}}`,enabled:!0}});n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:`table`,content:``,style:o,tableInfo:{tableName:`imported_table`,columns:t,loop:!0,isNestable:!1,parentPath:`items`,maxNestingDepth:5,nestingPrefix:` `,showNestingLevel:!1}})}else if(i===`img`)n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:`image`,content:``,style:o,imageInfo:{imageType:`logo`,url:r.getAttribute(`src`)||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`}});else if(i===`svg`)n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:`image`,content:``,style:o,imageInfo:{imageType:`barcode`,barcodeValue:`SHIP-99201`,barcodePlaceholder:`{{barcode}}`}});else{let e=`p`;[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(i)?e=i:i===`span`&&(e=`caption`),n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:e,content:r.innerHTML||r.textContent||``,style:o})}})}return n},xb=function(){var e=v(function*(e,t){let n=yield t.getDocument({data:new Uint8Array(e)}).promise,r=[],i=Math.min(n.numPages,3);for(let e=1;e<=i;e++){let t=(yield(yield n.getPage(e)).getTextContent()).items.map(e=>({text:e.str,x:e.transform[4],y:e.transform[5],fontSize:e.transform[3]})).filter(e=>e.text.trim()!==``);if(t.length===0)continue;t.sort((e,t)=>Math.abs(e.y-t.y)<6?e.x-t.x:t.y-e.y);let i=[],a=[];if(t.forEach(e=>{if(a.length===0)a.push(e);else{let t=a[a.length-1];if(Math.abs(e.y-t.y)<6)a.push(e);else{let t=a.map(e=>e.text).join(` `),n=a.reduce((e,t)=>e+t.y,0)/a.length,r=Math.max(...a.map(e=>e.fontSize));i.push({y:n,fontSize:r,text:t}),a=[e]}}}),a.length>0){let e=a.map(e=>e.text).join(` `),t=a.reduce((e,t)=>e+t.y,0)/a.length,n=Math.max(...a.map(e=>e.fontSize));i.push({y:t,fontSize:n,text:e})}i.forEach(e=>{let t=`p`,n=e.fontSize>16;n?t=e.fontSize>26?`h1`:e.fontSize>20?`h2`:`h3`:e.fontSize<10&&(t=`caption`);let i=Math.round(e.fontSize*1.15)+`px`;r.push({id:`pdf-block-${Math.random().toString(36).substr(2,9)}`,type:t,content:e.text,style:{fontSize:i,fontWeight:n?`700`:`400`,color:`#1e293b`,backgroundColor:`transparent`,textAlign:`left`,bold:n,italic:!1,underline:!1,strikethrough:!1}})})}return r});return function(t,n){return e.apply(this,arguments)}}();function Sb({initialBlocks:e,defaultStyles:t,defaultLogo:n,defaultBanner:r,onChange:i}={}){let[a,o]=(0,l.useState)(e||[]),[s,c]=(0,l.useState)(null);(0,l.useEffect)(()=>{i&&i(a)},[a,i]);let u=()=>a.find(e=>e.id===s)||null,d=(e,t,n)=>{let r={};return e===`title`?r={fontSize:`24px`,fontWeight:`800`}:e===`subtitle`?r={fontSize:`14px`,fontWeight:`700`,color:`#64748b`}:e===`h1`?r={fontSize:`20px`,fontWeight:`800`}:e===`h2`?r={fontSize:`18px`,fontWeight:`700`}:e===`h3`?r={fontSize:`16px`,fontWeight:`600`}:e===`caption`&&(r={fontSize:`10px`,color:`#94a3b8`}),{id:Math.random().toString(36).substring(2,11),type:e,content:t,style:T(T({fontSize:`12px`,fontWeight:`normal`,textAlign:`left`,color:`#1e293b`,backgroundColor:`transparent`,marginBottom:`0px`,padding:`0px`,bold:!1,italic:!1,underline:!1,strikethrough:!1},r),n)}},f=e=>T(T({},e),{},{columns:e.columns?e.columns.map(f):void 0});return{blocks:a,setBlocks:o,selectedBlockId:s,setSelectedBlockId:c,getSelectedBlock:u,createTextBlock:d,createTableBlock:e=>({id:Math.random().toString(36).substring(2,11),type:`table`,content:``,style:T({fontSize:`11px`,fontWeight:`normal`,textAlign:`left`,color:`#334155`,backgroundColor:`transparent`,marginBottom:`0px`,padding:`0px`,bold:!1,italic:!1,underline:!1,strikethrough:!1},(t==null?void 0:t.table)||{}),tableInfo:T(T({},e),{},{columns:e.columns.map(f),mockRows:[]})}),createImageBlock:e=>{let i=`100%`,a=`120px`;return e===`logo`?(i=`120px`,a=`60px`):e===`banner`?(i=`100%`,a=`150px`):e===`barcode`?(i=`200px`,a=`80px`):e===`watermark`&&(i=`300px`,a=`300px`),{id:Math.random().toString(36).substring(2,11),type:`image`,content:``,style:T(T({fontSize:`12px`,fontWeight:`normal`,color:`#000055`,backgroundColor:`transparent`,textAlign:`center`,marginBottom:`0px`,padding:`0px`,width:`100%`,imageWidth:i,height:a,minHeight:a,bold:!1,italic:!1,underline:!1,strikethrough:!1},(t==null?void 0:t.image)||{}),e===`watermark`?{opacity:`0.2`,position:`absolute`,top:`0`,left:`0`,zIndex:10,height:`100%`}:{}),imageInfo:{imageType:e,url:e===`logo`?n||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`:e===`banner`?r||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`:pb,barcodeValue:e===`barcode`?`SHIP-99201`:void 0,barcodePlaceholder:e===`barcode`?`{{barcode}}`:void 0}}},handleDeleteBlock:e=>{o(t=>t.filter(t=>t.id!==e)),s===e&&c(null)},handleDuplicateBlock:e=>{let t=a.find(t=>t.id===e);if(!t)return;let n=T(T({},t),{},{id:Math.random().toString(36).substring(2,11),style:T({},t.style),tableInfo:t.tableInfo?T(T({},t.tableInfo),{},{columns:t.tableInfo.columns.map(f),mockRows:t.tableInfo.mockRows?[...t.tableInfo.mockRows]:void 0}):void 0,imageInfo:t.imageInfo?T({},t.imageInfo):void 0}),r=a.findIndex(t=>t.id===e);o(e=>{let t=[...e];return t.splice(r+1,0,n),t}),c(n.id)},handleMoveBlockUp:e=>{e!==0&&o(t=>{let n=[...t],r=n[e];return n[e]=n[e-1],n[e-1]=r,n})},handleMoveBlockDown:e=>{e!==a.length-1&&o(t=>{let n=[...t],r=n[e];return n[e]=n[e+1],n[e+1]=r,n})},updateSelectedStyle:(e,t)=>{s&&o(n=>n.map(n=>n.id===s?T(T({},n),{},{style:T(T({},n.style),{},{[e]:t})}):n))},updateSelectedImageInfo:(e,t)=>{s&&o(i=>i.map(i=>{if(i.id===s&&i.type===`image`){let a={};return e===`imageType`&&(a=t===`logo`?{url:n||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`}:t===`banner`?{url:r||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`}:t===`barcode`?{barcodeValue:`SHIP-99201`,barcodePlaceholder:`{{barcode}}`}:{url:pb}),T(T({},i),{},{imageInfo:T(T({},i.imageInfo),{},{[e]:t},a)})}return i}))},handleRemoveTableColumn:(e,t)=>{s&&o(n=>n.map(n=>{if(n.id===s&&n.type===`table`&&n.tableInfo){var r;let i=[...n.tableInfo.columns];if(t!==void 0&&(r=i[e])!=null&&r.columns){let n=i[e].columns.filter((e,n)=>n!==t);i[e]=T(T({},i[e]),{},{columns:n})}else i.splice(e,1);return T(T({},n),{},{tableInfo:T(T({},n.tableInfo),{},{columns:i})})}return n}))},handleAddTableColumn:(e,t,n,r)=>{!s||!e.trim()||o(i=>i.map(i=>{if(i.id===s&&i.type===`table`&&i.tableInfo){let a=[...i.tableInfo.columns];if(r!==void 0&&a[r]){let n=a[r].columns||[];a[r]=T(T({},a[r]),{},{loop:!0,columns:[...n,{columnName:e.trim(),placeholder:t.trim(),enabled:!0}]})}else n?a.push({columnName:e.trim(),placeholder:t.trim(),enabled:!0,loop:!0,columns:[]}):a.push({columnName:e.trim(),placeholder:t.trim(),enabled:!0});return T(T({},i),{},{tableInfo:T(T({},i.tableInfo),{},{columns:a})})}return i}))},handleUpdateTableColumn:(e,t,n,r)=>{s&&o(i=>i.map(i=>{if(i.id===s&&i.type===`table`&&i.tableInfo){var a;let o=[...i.tableInfo.columns];if(r!==void 0&&(a=o[e])!=null&&a.columns){let i=[...o[e].columns];i[r]=T(T({},i[r]),{},{columnName:t.trim(),placeholder:n.trim()}),o[e]=T(T({},o[e]),{},{columns:i})}else o[e]&&(o[e]=T(T({},o[e]),{},{columnName:t.trim(),placeholder:n.trim()}));return T(T({},i),{},{tableInfo:T(T({},i.tableInfo),{},{columns:o})})}return i}))},handleReorderTableColumn:(e,t,n)=>{s&&o(r=>r.map(r=>{if(r.id===s&&r.type===`table`&&r.tableInfo){var i;let a=[...r.tableInfo.columns];if(n!==void 0&&(i=a[e])!=null&&i.columns){let r=[...a[e].columns],i=t===`up`?n-1:n+1;if(i>=0&&i<r.length){let t=r[n];r[n]=r[i],r[i]=t,a[e]=T(T({},a[e]),{},{columns:r})}}else{let n=t===`up`?e-1:e+1;if(n>=0&&n<a.length){let t=a[e];a[e]=a[n],a[n]=t}}return T(T({},r),{},{tableInfo:T(T({},r.tableInfo),{},{columns:a})})}return r}))},handleAddTableRow:e=>{let t=e||s;t&&o(e=>e.map(e=>{if(e.id===t&&e.type===`table`&&e.tableInfo){let t=e.tableInfo.columns||[],n=e.tableInfo.mockRows&&e.tableInfo.mockRows.length>0?e.tableInfo.mockRows:[{}],r={};return t.forEach(e=>{e.columnName&&(r[e.columnName]=e.placeholder||``)}),T(T({},e),{},{tableInfo:T(T({},e.tableInfo),{},{mockRows:[...n,r]})})}return e}))},handleRemoveTableRow:(e,t)=>{let n=t||s;n&&o(t=>t.map(t=>{if(t.id===n&&t.type===`table`&&t.tableInfo){let n=t.tableInfo.mockRows&&t.tableInfo.mockRows.length>0?t.tableInfo.mockRows:[{}];if(n.length<=1)return T(T({},t),{},{tableInfo:T(T({},t.tableInfo),{},{mockRows:[{}]})});let r=n.filter((t,n)=>n!==e);return T(T({},t),{},{tableInfo:T(T({},t.tableInfo),{},{mockRows:r})})}return t}))}}}function Cb(){let[e,t]=(0,l.useState)(.7),[n,r]=(0,l.useState)({x:0,y:0}),[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(1123),d=(0,l.useRef)({x:0,y:0}),f=(0,l.useRef)(null),p=(0,l.useRef)(null);return(0,l.useEffect)(()=>{let e=e=>{let t=document.activeElement,n=t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.getAttribute(`contenteditable`)===`true`);e.code===`Space`&&!n&&(s(!0),e.preventDefault())},t=e=>{e.code===`Space`&&s(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]),(0,l.useEffect)(()=>{if(!p.current)return;let e=new ResizeObserver(e=>{for(let t of e)u(t.target.scrollHeight)});return e.observe(p.current),()=>e.disconnect()},[]),{zoom:e,setZoom:t,panOffset:n,setPanOffset:r,isPanning:i,setIsPanning:a,spacePressed:o,setSpacePressed:s,canvasHeight:c,setCanvasHeight:u,viewportRef:f,canvasContainerRef:p,handleMouseDown:e=>{o&&(a(!0),d.current={x:e.clientX-n.x,y:e.clientY-n.y})},handleMouseMove:e=>{i&&o&&r({x:e.clientX-d.current.x,y:e.clientY-d.current.y})},handleMouseUp:()=>{a(!1)},handleZoomIn:()=>t(e=>Math.min(e+.1,2)),handleZoomOut:()=>t(e=>Math.max(e-.1,.5)),handleZoomReset:()=>{t(1),r({x:0,y:0})}}}function wb({tableSchemas:e}={}){let[t,n]=(0,l.useState)(`invoice_items`),[r,i]=(0,l.useState)(`{% for item in invoice.items %}`),[a,o]=(0,l.useState)(`{% endfor %}`),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)([]),[g,_]=(0,l.useState)(!1),[v,y]=(0,l.useState)(``),[b,x]=(0,l.useState)(null),[S,C]=(0,l.useState)(``),[w,E]=(0,l.useState)(null),[D,O]=(0,l.useState)(null),[k,A]=(0,l.useState)(``),[ee,te]=(0,l.useState)([]),ne=e=>({columnName:e.columnName||e.columnNameEn||e.columnNameDe||``,placeholder:e.placeholder||``,enabled:e.enabled!==!1,loop:!!e.loop,columns:Array.isArray(e.columns)?e.columns.map(ne):void 0});(0,l.useEffect)(()=>{e&&e.length>0?h(e.map(e=>T(T({},e),{},{columns:e.columns.map(ne)}))):h([])},[e]);let re=()=>{if(!t.trim())return;let e={tableName:t.trim().replace(/\s+/g,`_`).toLowerCase(),columns:[{columnName:`Description`,placeholder:`{{description}}`,enabled:!0},{columnName:`Qty`,placeholder:`{{quantity}}`,enabled:!0},{columnName:`Total Price`,placeholder:`{{total_price}}`,enabled:!0}],loop:!0,isNestable:!1,parentPath:`items`,maxNestingDepth:5,nestingPrefix:` `,showNestingLevel:!1,loopStartTag:r,loopEndTag:a};h(t=>[...t,e]),n(``)},j=()=>{if(!k.trim())return;let e=k.trim().toLowerCase().replace(/\s+/g,`_`);if(ee.some(t=>t.imageType===e)){A(``);return}te(t=>[...t,{label:k.trim(),imageType:e,description:`Placeholder container for ${k.trim()}`}]),A(``)},ie=(e,t,n)=>{h(r=>r.map((r,i)=>{if(i===e){var a;let e=[...r.columns];if(n!==void 0&&(a=e[t])!=null&&a.columns){let r=[...e[t].columns];r[n]=T(T({},r[n]),{},{enabled:r[n].enabled===!1}),e[t]=T(T({},e[t]),{},{columns:r})}else e[t]=T(T({},e[t]),{},{enabled:e[t].enabled===!1});return T(T({},r),{},{columns:e})}return r}))},[ae,oe]=(0,l.useState)(null);return{customTableName:t,setCustomTableName:n,customLoopStart:r,setCustomLoopStart:i,customLoopEnd:a,setCustomLoopEnd:o,newColName:s,setNewColName:c,newColPlaceholder:u,setNewColPlaceholder:d,bubbleCoords:f,setBubbleCoords:p,schemas:m,setSchemas:h,isParsing:g,setIsParsing:_,parseStatusText:v,setParseStatusText:y,parseError:b,setParseError:x,draggedSidebarItem:w,setDraggedSidebarItem:E,dragOverIndex:D,setDragOverIndex:O,newImgTypeName:k,setNewImgTypeName:A,customImageTypes:ee,setCustomImageTypes:te,searchPlaceholder:S,setSearchPlaceholder:C,handleAddCustomTable:re,handleAddCustomImageType:j,toggleSchemaColumn:ie,applySelectionFormat:(e,t=``)=>{if(ae){let e=window.getSelection();e==null||e.removeAllRanges(),e==null||e.addRange(ae)}document.execCommand(e,!1,t),p(null)},setSavedRange:oe}}var Tb=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Eb=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Db=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Ob=e=>{let t=Db(e);return t.charAt(0).toUpperCase()+t.slice(1)},kb={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ab=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},jb=(0,l.createContext)({}),Mb=()=>(0,l.useContext)(jb);function Nb(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Pb(e,t){if(e==null)return{};var n,r,i=Nb(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Fb=[`color`,`size`,`strokeWidth`,`absoluteStrokeWidth`,`className`,`children`,`iconNode`],Ib=(0,l.forwardRef)((e,t)=>{var n,r,i;let{color:a,size:o,strokeWidth:s,absoluteStrokeWidth:c,className:u=``,children:d,iconNode:f}=e,p=Pb(e,Fb),{size:m=24,strokeWidth:h=2,absoluteStrokeWidth:g=!1,color:_=`currentColor`,className:v=``}=(n=Mb())==null?{}:n,y=(c==null?g:c)?Number(s==null?h:s)*24/Number(o==null?m:o):s==null?h:s;return(0,l.createElement)(`svg`,T(T(T({ref:t},kb),{},{width:(r=o==null?m:o)==null?kb.width:r,height:(i=o==null?m:o)==null?kb.height:i,stroke:a==null?_:a,strokeWidth:y,className:Tb(`lucide`,v,u)},!d&&!Ab(p)&&{"aria-hidden":`true`}),p),[...f.map(([e,t])=>(0,l.createElement)(e,t)),...Array.isArray(d)?d:[d]])}),Lb=[`className`],Rb=(e,t)=>{let n=(0,l.forwardRef)((n,r)=>{let{className:i}=n,a=Pb(n,Lb);return(0,l.createElement)(Ib,T({ref:r,iconNode:t,className:Tb(`lucide-${Eb(Ob(e))}`,`lucide-${e}`,i)},a))});return n.displayName=Ob(e),n},zb=Rb(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Bb=Rb(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Vb=Rb(`barcode`,[[`path`,{d:`M3 5v14`,key:`1nt18q`}],[`path`,{d:`M8 5v14`,key:`1ybrkv`}],[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`M17 5v14`,key:`ycjyhj`}],[`path`,{d:`M21 5v14`,key:`nzette`}]]),Hb=Rb(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ub=Rb(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Wb=Rb(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Gb=Rb(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Kb=Rb(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),qb=Rb(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Jb=Rb(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Yb=Rb(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Xb=Rb(`printer`,[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]),Zb=Rb(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Qb=Rb(`sliders-vertical`,[[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M12 21v-9`,key:`17s77i`}],[`path`,{d:`M12 8V3`,key:`13r4qs`}],[`path`,{d:`M17 16h4`,key:`h1uq16`}],[`path`,{d:`M19 12V3`,key:`o1uvq1`}],[`path`,{d:`M19 21v-5`,key:`qua636`}],[`path`,{d:`M3 14h4`,key:`bcjad9`}],[`path`,{d:`M5 10V3`,key:`cb8scm`}],[`path`,{d:`M5 21v-7`,key:`1w1uti`}]]),$b=Rb(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),ex=Rb(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),tx=Rb(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),nx=Rb(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),rx=Rb(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),ix=Rb(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),ax=Rb(`text-align-justify`,[[`path`,{d:`M3 5h18`,key:`1u36vt`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 19h18`,key:`awlh7x`}]]),ox=Rb(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),sx=Rb(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),cx=Rb(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),lx=Rb(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),ux=Rb(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function dx({headerLogo:e,headerTitle:t,headerSubtitle:n,parseError:r,isParsing:i,parseStatusText:a}){return(0,d.jsxs)(`header`,{className:`bg-white border-b border-gray-200 px-6 py-3.5 flex items-center justify-between sticky top-0 z-10 shadow-xs gap-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[e||(0,d.jsx)(`div`,{className:`h-9 w-9 bg-orange-600 rounded-xl flex items-center justify-center text-white shadow-md shadow-orange-600/20`,children:(0,d.jsx)($b,{className:`h-5 w-5`})}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h1`,{className:`text-lg font-bold tracking-tight text-slate-800`,children:t}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:n})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[r&&(0,d.jsxs)(`span`,{className:`text-[10px] text-red-500 font-bold bg-red-50 px-2 py-0.5 rounded inline-block border border-red-100`,children:[`Error: `,r]}),i&&(0,d.jsx)(`span`,{className:`text-[10px] text-orange-600 font-bold bg-orange-50 px-2 py-0.5 rounded inline-block border border-orange-100 animate-pulse`,children:a||`Parsing...`})]})]})}function fx({handleSidebarDragStart:e,createTextBlock:t,setBlocks:n,setSelectedBlockId:r,setActiveTab:i,defaultStyles:a}){return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Typography Elements`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Select standard headings or paragraphs to structure your page layout.`})]}),(0,d.jsx)(`div`,{className:`grid grid-cols-1 gap-3 select-none`,children:[{label:`Document Title`,type:`title`,style:`text-2xl font-extrabold text-slate-900 tracking-tight`},{label:`Document Subtitle`,type:`subtitle`,style:`text-sm font-bold text-slate-500`},{label:`Heading 1`,type:`h1`,style:`text-xl font-extrabold text-slate-850`},{label:`Heading 2`,type:`h2`,style:`text-lg font-bold text-slate-800`},{label:`Heading 3`,type:`h3`,style:`text-md font-semibold text-slate-750`},{label:`Normal Paragraph`,type:`p`,style:`text-xs text-slate-600 leading-relaxed`},{label:`Caption Note`,type:`caption`,style:`text-[10px] text-slate-400 font-mono italic`}].map(o=>(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>e(t,o.type),className:`border border-gray-200 rounded-xl p-3 bg-white hover:border-slate-350 transition-all flex flex-col space-y-2 cursor-grab shadow-xs group`,children:[(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-slate-400 uppercase tracking-wide`,children:o.type}),(0,d.jsx)(`div`,{className:`${o.style} truncate pr-4`,children:o.label}),(0,d.jsx)(`button`,{onClick:()=>{let e=t(o.type,o.label,a==null?void 0:a[o.type]);n(t=>[...t,e]),r(e.id),i(`styles`)},className:`w-full py-1 bg-slate-50 hover:bg-slate-200 text-slate-600 rounded-lg text-[9px] font-semibold transition-all text-center border border-gray-150`,children:`Insert at End`})]},o.type))})]})}function px({schemas:e,toggleSchemaColumn:t,customTableName:n,setCustomTableName:r,customLoopStart:i,setCustomLoopStart:a,customLoopEnd:o,setCustomLoopEnd:s,handleAddCustomTable:c,handleSidebarDragStart:l,setBlocks:u,setSelectedBlockId:f,setActiveTab:p,defaultStyles:m,isTablesLoading:h,tablesLoading:g}){return h||g?(0,d.jsxs)(`div`,{className:`space-y-6`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Dynamic Tables`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Configure loop table templates and drag onto the canvas.`})]}),(0,d.jsx)(`div`,{className:`space-y-4 animate-pulse`,children:[1,2].map(e=>(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-2xl p-4 bg-white space-y-3 shadow-xs`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`div`,{className:`h-4 bg-slate-200 rounded w-1/3`}),(0,d.jsx)(`div`,{className:`h-3 bg-slate-100 rounded w-16`})]}),(0,d.jsx)(`div`,{className:`h-9 bg-slate-100 rounded-lg w-full`}),(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`div`,{className:`h-3 bg-slate-100 rounded w-1/4`}),(0,d.jsxs)(`div`,{className:`h-20 bg-slate-50 border border-gray-100 rounded-lg w-full p-2 space-y-2`,children:[(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-200/70 rounded w-3/4`}),(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-200/70 rounded w-2/3`})]})]})]},e))})]}):(0,d.jsxs)(`div`,{className:`space-y-6`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Dynamic Tables`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Configure loop table templates and drag onto the canvas.`})]}),(0,d.jsx)(`div`,{className:`space-y-4`,children:e.map((e,n)=>(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-2xl p-4 bg-white space-y-3 shadow-xs`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(nx,{className:`h-4 w-4 text-slate-650`}),(0,d.jsx)(`h4`,{className:`font-bold text-xs uppercase text-slate-700 tracking-wider`,children:e.tableName})]}),(0,d.jsx)(`span`,{className:`px-1.5 py-0.5 bg-slate-100 text-[8px] font-bold text-slate-600 rounded`,children:`loop = true`})]}),(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>l(t,`table`,e),className:`bg-slate-50 border border-slate-200 hover:border-slate-400 rounded-lg p-2.5 flex items-center justify-between cursor-grab`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`div`,{className:`h-5 w-5 bg-slate-200 rounded flex items-center justify-center`,children:(0,d.jsx)(Yb,{className:`h-3 w-3 text-slate-600`})}),(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700`,children:`Drag to Canvas`})]}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400 italic`,children:`Drag & Drop`})]}),(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400 font-bold uppercase tracking-wider block`,children:`Columns:`}),(0,d.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto border border-gray-150 rounded-lg p-2 space-y-1.5 bg-slate-50/50`,children:e.columns.map((e,r)=>{let i=e.loop&&e.columns&&e.columns.length>0;return(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsxs)(`button`,{onClick:()=>t(n,r),className:`flex items-center space-x-2 w-full text-left py-0.5 text-xs text-slate-600 hover:text-slate-800 transition-colors font-medium`,children:[e.enabled===!1?(0,d.jsx)(tx,{className:`h-3.5 w-3.5 text-slate-300 flex-shrink-0`}):(0,d.jsx)(ex,{className:`h-3.5 w-3.5 text-slate-700 flex-shrink-0`}),(0,d.jsxs)(`span`,{className:`truncate flex items-center gap-1`,children:[(0,d.jsx)(`span`,{children:e.columnName}),i&&(0,d.jsx)(`span`,{className:`px-1 bg-slate-200 text-slate-600 rounded text-[8px] font-mono`,children:`(sub-table)`})]})]}),i&&e.enabled!==!1&&(0,d.jsxs)(`div`,{className:`ml-4 pl-2.5 border-l-2 border-slate-200 space-y-1 my-1`,children:[(0,d.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold uppercase tracking-wider block`,children:`Sub Columns:`}),e.columns.map((e,i)=>(0,d.jsxs)(`button`,{onClick:()=>t(n,r,i),className:`flex items-center space-x-2 w-full text-left py-0.5 text-[11px] text-slate-500 hover:text-slate-800 transition-colors`,children:[e.enabled===!1?(0,d.jsx)(tx,{className:`h-3 w-3 text-slate-300 flex-shrink-0`}):(0,d.jsx)(ex,{className:`h-3 w-3 text-slate-600 flex-shrink-0`}),(0,d.jsxs)(`span`,{className:`truncate`,children:[e.columnName,` `,(0,d.jsxs)(`span`,{className:`text-[8px] text-slate-400`,children:[`(`,e.placeholder,`)`]})]})]},i))]})]},r)})})]}),(0,d.jsx)(`button`,{onClick:()=>{let t={id:Math.random().toString(36).substring(2,11),type:`table`,content:``,style:T({fontSize:`10px`,fontWeight:`400`,color:`#334155`,backgroundColor:`transparent`,textAlign:`left`,bold:!1,italic:!1,underline:!1,strikethrough:!1,width:`100%`,marginBottom:`12px`,padding:`8px`},m==null?void 0:m.table),tableInfo:T(T({},e),{},{columns:e.columns.map(e=>T({},e))})};u(e=>[...e,t]),f(t.id),p(`styles`)},className:`w-full py-1 bg-slate-50 hover:bg-slate-200 text-slate-600 rounded-lg text-[9px] font-semibold transition-all text-center border border-gray-150`,children:`Insert at End`})]},e.tableName))}),(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-2xl p-4 bg-slate-50/20 border-dashed space-y-4 mt-6`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 pb-2 border-b border-gray-150`,children:[(0,d.jsx)($b,{className:`h-4 w-4 text-slate-655`}),(0,d.jsx)(`h4`,{className:`font-bold text-xs uppercase text-slate-800 tracking-wider`,children:`Custom Table Builder`})]}),(0,d.jsxs)(`div`,{className:`space-y-3`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block mb-1`,children:`Table Name`}),(0,d.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`invoice_items`,className:`w-full px-3 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block mb-1`,children:`Loop Start tag`}),(0,d.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`{% for item in invoice.items %}`,className:`w-full px-3 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500 bg-white text-slate-600 font-bold`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block mb-1`,children:`Loop End tag`}),(0,d.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`{% endfor %}`,className:`w-full px-3 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500 bg-white text-slate-600 font-bold`})]}),(0,d.jsxs)(`button`,{onClick:c,className:`w-full py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-xl text-xs font-bold transition-all shadow-sm flex items-center justify-center space-x-1.5 shadow-orange-600/10`,children:[(0,d.jsx)(Yb,{className:`h-4 w-4`}),(0,d.jsx)(`span`,{children:`Add Custom Loop Table`})]})]})]})]})}function mx({customImageTypes:e,newImgTypeName:t,setNewImgTypeName:n,handleAddCustomImageType:r,handleSidebarDragStart:i,createImageBlock:a,setBlocks:o,setSelectedBlockId:s,setActiveTab:c}){let l=[{label:`Brand Logo`,imageType:`logo`,description:`Standard document vector logo`,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})},{label:`Campaign Banner`,imageType:`banner`,description:`Wide horizontal graphics banner`,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})},{label:`Dynamic Barcode`,imageType:`barcode`,description:`Barcode replaced dynamically`,icon:(0,d.jsx)(Vb,{className:`h-4 w-4 text-slate-550`})},{label:`Watermark`,imageType:`watermark`,description:`Background graphic with low opacity`,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})},...e.map(e=>({label:e.label,imageType:e.imageType,description:e.description,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})}))];return(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Image & Barcode Elements`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Drag elements onto the canvas, or insert below.`})]}),(0,d.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-xl p-3 bg-white space-y-3 shadow-xs`,children:[(0,d.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[e.icon,(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h4`,{className:`font-bold text-xs text-slate-700`,children:e.label}),(0,d.jsx)(`p`,{className:`text-[9px] text-slate-400`,children:e.description})]})]})}),(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>i(t,`image`,void 0,e.imageType),className:`bg-slate-50 border border-slate-200 hover:border-slate-450 rounded-lg p-2 flex items-center justify-between cursor-grab transition-all`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`div`,{className:`h-5 w-5 bg-slate-200 rounded flex items-center justify-center`,children:(0,d.jsx)(Yb,{className:`h-3 w-3 text-slate-750`})}),(0,d.jsx)(`span`,{className:`text-[11px] font-bold text-slate-700`,children:`Drag to Canvas`})]}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400 italic`,children:`Drag`})]}),(0,d.jsx)(`button`,{onClick:()=>{let t=a(e.imageType);o(e=>[...e,t]),s(t.id),c(`styles`)},className:`w-full py-1 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-lg text-[10px] font-semibold transition-all text-center border border-gray-150`,children:`Insert at End`})]},e.imageType))}),(0,d.jsxs)(`div`,{className:`border border-dashed border-gray-200 rounded-xl p-3 space-y-2 bg-slate-50/50 mt-4`,children:[(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Add Custom Image Type`}),(0,d.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`e.g. Signature`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs focus:outline-none focus:border-slate-500 bg-white`}),(0,d.jsxs)(`button`,{onClick:r,className:`w-full py-1.5 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-bold transition-all flex items-center justify-center space-x-1`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Add Custom Category`})]})]})]})}function hx({placeholders:e,schemas:t,searchPlaceholder:n,setSearchPlaceholder:r,selectedBlockId:i,setBlocks:a,isPlaceholdersLoading:o,placeholdersLoading:s}){if(o||s)return(0,d.jsxs)(`div`,{className:`space-y-4 flex-1 flex flex-col min-h-0`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Variables Palette`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Click to copy, or drag variables into text areas or table cells.`})]}),(0,d.jsx)(`div`,{className:`h-9 bg-slate-100 rounded-xl w-full animate-pulse`}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-2 pr-1 animate-pulse`,children:[1,2,3,4].map(e=>(0,d.jsxs)(`div`,{className:`w-full border border-gray-200 p-2.5 rounded-xl bg-white shadow-xs space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-200 rounded w-1/2`}),(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-100 rounded w-1/4`})]}),(0,d.jsx)(`div`,{className:`h-6 bg-slate-50 rounded border border-gray-100 w-full`})]},e))})]});let c=()=>{let t=[];return(e||[]).forEach(e=>{t.push({label:e.label,placeholder:e.placeholder,category:e.category||`General`})}),t.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())||e.placeholder.toLowerCase().includes(n.toLowerCase()))},l=e=>{if(i){let t=`{{${e.replace(/[{}]/g,``)}}}`;a(e=>e.map(e=>e.id===i&&e.type!==`table`?T(T({},e),{},{content:e.content+t}):e))}},u=c();return(0,d.jsxs)(`div`,{className:`space-y-4 flex-1 flex flex-col min-h-0`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Variables Palette`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Click to copy, or drag variables into text areas or table cells.`})]}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(Zb,{className:`absolute left-3 top-2.5 h-4 w-4 text-slate-400`}),(0,d.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Search variables...`,className:`w-full pl-9 pr-4 py-2 border border-gray-200 rounded-xl text-xs focus:outline-none focus:border-slate-500 transition-colors`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-2 pr-1`,children:u.length===0?(0,d.jsx)(`div`,{className:`text-xs text-slate-400 italic text-center py-4`,children:`No variables available.`}):u.map((e,t)=>{let n=e.placeholder.replace(/[{}]/g,``);return(0,d.jsx)(`div`,{className:`w-full border border-gray-200 p-2.5 rounded-xl bg-white shadow-xs cursor-grab active:cursor-grabbing hover:bg-slate-50 transition-colors`,draggable:!0,onDragStart:e=>{e.dataTransfer.setData(`placeholder`,n),e.dataTransfer.effectAllowed=`copy`},onClick:()=>l(e.placeholder),title:`Drag into text or cells, or click to insert`,children:(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold text-slate-700 truncate mr-2`,children:e.label}),(0,d.jsx)(`code`,{className:`text-[9px] bg-slate-100 px-1.5 py-0.5 rounded text-slate-800 font-bold shrink-0 border border-slate-200/50`,children:e.placeholder})]})},t)})})]})}var gx=e=>{if(!e)return 100;if(e.endsWith(`%`)){let t=parseInt(e,10);return isNaN(t)?100:Math.min(100,Math.max(10,t))}return 100};function _x({selectedBlockId:e,getSelectedBlock:t,updateSelectedStyle:n,updateSelectedImageInfo:r,fontSizesState:i,fontFamiliesState:a,fontWeightsState:o,handleDeleteBlock:s,newColName:c,setNewColName:u,newColPlaceholder:f,setNewColPlaceholder:p,handleAddTableColumn:m,handleRemoveTableColumn:h,handleUpdateTableColumn:g,handleReorderTableColumn:_,handleAddTableRow:v,handleRemoveTableRow:y,setBlocks:b}){var x;let[S,C]=(0,l.useState)(null),[w,E]=(0,l.useState)(``),[D,O]=(0,l.useState)(``),[k,A]=(0,l.useState)(null),[ee,te]=(0,l.useState)(``),[ne,re]=(0,l.useState)(``),j=t();if(!e||!j)return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Formatting Panel`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Customize the styles of the selected block.`})]}),(0,d.jsxs)(`div`,{className:`border border-dashed border-gray-200 rounded-xl p-6 text-center bg-slate-50/50`,children:[(0,d.jsx)(Qb,{className:`h-8 w-8 text-slate-350 mx-auto mb-2`}),(0,d.jsx)(`span`,{className:`text-xs font-semibold text-slate-500 block`,children:`No block selected`}),(0,d.jsx)(`p`,{className:`text-[10px] text-slate-400 mt-1`,children:`Select any element inside the canvas to configure typography, sizing, colors, or templating loop engines.`})]})]});let ie=j.type===`table`,ae=()=>{c.trim()&&(m(c,f),u(``),p(``))};if(j.type===`image`){let e=j.imageInfo||{imageType:`logo`};return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Formatting Panel`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Customize the styles of the selected block.`})]}),(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 pb-3 border-b border-gray-100`,children:[(0,d.jsx)(`div`,{className:`h-6 w-6 bg-slate-100 rounded flex items-center justify-center text-slate-700`,children:(0,d.jsx)(qb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 capitalize`,children:`Editing Image Element`})]}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-slate-50 border border-gray-200 rounded-xl select-none`,children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 block`,children:`Row Alignment`}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400`,children:`Display side-by-side`})]}),(0,d.jsx)(`button`,{onClick:()=>{let e=!j.style.sameRow;n(`sameRow`,e),e?(n(`width`,`48%`),b(e=>{let t=e.findIndex(e=>e.id===j.id);return t>0?e.map((e,n)=>n===t-1&&(!e.style.width||e.style.width===`100%`)?T(T({},e),{},{style:T(T({},e.style),{},{width:`48%`})}):e):e})):n(`width`,`100%`)},className:`w-10 h-6 flex items-center rounded-full p-1 transition-colors duration-150 ${j.style.sameRow?`bg-orange-600 justify-end`:`bg-slate-300 justify-start`}`,children:(0,d.jsx)(`span`,{className:`bg-white w-4 h-4 rounded-full shadow-md`})})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Image Category`}),(0,d.jsx)(`div`,{className:`grid grid-cols-4 gap-1 bg-slate-50 p-1 border border-gray-200 rounded-lg`,children:[`logo`,`banner`,`barcode`,`watermark`].map(t=>(0,d.jsx)(`button`,{onClick:()=>r(`imageType`,t),className:`py-1 text-[9px] font-bold rounded capitalize transition-all ${e.imageType===t?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:t},t))})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Alignment (Position)`}),(0,d.jsx)(`div`,{className:`flex items-center space-x-1 border border-gray-200 rounded-lg p-1 bg-slate-50 w-fit`,children:[{value:`left`,icon:(0,d.jsx)(ox,{className:`h-3.5 w-3.5`})},{value:`center`,icon:(0,d.jsx)(rx,{className:`h-3.5 w-3.5`})},{value:`right`,icon:(0,d.jsx)(ix,{className:`h-3.5 w-3.5`})}].map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`textAlign`,e.value),type:`button`,className:`p-1.5 rounded transition-all ${j.style.textAlign===e.value?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:e.icon},e.value))})]}),(0,d.jsxs)(`div`,{className:`space-y-1 pt-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Block Width (%)`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:[gx(j.style.width),`%`]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`input`,{type:`range`,min:`10`,max:`100`,step:`5`,value:gx(j.style.width),onChange:e=>n(`width`,`${Math.min(100,Math.max(10,parseInt(e.target.value,10)))}%`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 w-10 text-right`,children:[gx(j.style.width),`%`]})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1 pt-1 mt-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Image Element Width (px)`}),(0,d.jsx)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:j.style.imageWidth||(j.style.width&&j.style.width.endsWith(`px`)?j.style.width:`100%`)})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`input`,{type:`range`,min:`10`,max:`1000`,step:`5`,value:parseInt(j.style.imageWidth||(j.style.width&&j.style.width.endsWith(`px`)?j.style.width:`100`))||100,onChange:e=>n(`imageWidth`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 w-10 text-right`,children:[parseInt(j.style.imageWidth||(j.style.width&&j.style.width.endsWith(`px`)?j.style.width:`100`))||100,`px`]})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1 pt-1 mt-3`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block mb-1`,children:`Object Fit`}),(0,d.jsxs)(`select`,{value:j.style.objectFit||`contain`,onChange:e=>n(`objectFit`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:[(0,d.jsx)(`option`,{value:`contain`,children:`Contain`}),(0,d.jsx)(`option`,{value:`cover`,children:`Cover`}),(0,d.jsx)(`option`,{value:`fill`,children:`Fill`}),(0,d.jsx)(`option`,{value:`none`,children:`None`})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Image Height`}),(0,d.jsx)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:j.style.height||j.style.minHeight||`auto`})]}),(0,d.jsx)(`div`,{className:`flex items-center space-x-2`,children:(0,d.jsx)(`input`,{type:`range`,min:`20`,max:`400`,step:`10`,value:parseInt(j.style.height||j.style.minHeight||`100`)||100,onChange:e=>{n(`height`,`${e.target.value}px`),n(`minHeight`,`${e.target.value}px`)},className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`})})]}),e.imageType===`barcode`?(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-150`,children:[(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Barcode Configuration`}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500`,children:`Mock Barcode Value`}),(0,d.jsx)(`input`,{type:`text`,value:e.barcodeValue||``,onChange:e=>r(`barcodeValue`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500`})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500`,children:`Backend Variable`}),(0,d.jsx)(`input`,{type:`text`,value:e.barcodePlaceholder||``,onChange:e=>r(`barcodePlaceholder`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500 text-slate-700 font-bold`})]})]}):(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-150`,children:[(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Image Asset Upload`}),(0,d.jsxs)(`div`,{className:`flex flex-col items-center p-3 border border-dashed border-gray-200 rounded-lg bg-slate-50/50 hover:bg-slate-50 transition-all cursor-pointer relative`,children:[(0,d.jsx)(lx,{className:`h-5 w-5 text-slate-400 mb-1`}),(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-650`,children:`Choose local image file`}),(0,d.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:e=>{var t;let n=(t=e.target.files)==null?void 0:t[0];if(!n)return;let i=new FileReader;i.onload=e=>{var t;r(`url`,(t=e.target)==null?void 0:t.result)},i.readAsDataURL(n)},className:`absolute inset-0 opacity-0 cursor-pointer`})]})]}),(0,d.jsx)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Bottom Margin`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(j.style.marginBottom||`0px`),onChange:e=>n(`marginBottom`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200`})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Padding`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(j.style.padding||`0px`),onChange:e=>n(`padding`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200`})]})]})}),(0,d.jsx)(`div`,{className:`pt-4 border-t border-red-100 flex items-center justify-between`,children:(0,d.jsxs)(`button`,{onClick:()=>s(j.id),className:`w-full py-2 bg-red-50 hover:bg-red-100 border border-red-200 text-red-650 rounded-xl text-xs font-bold transition-all flex items-center justify-center space-x-1 shadow-xs cursor-pointer`,children:[(0,d.jsx)(sx,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Delete Element`})]})})]})]})}return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Formatting Panel`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Customize the styles of the selected block.`})]}),(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 pb-3 border-b border-gray-100`,children:[(0,d.jsx)(`div`,{className:`h-6 px-3 bg-slate-100 rounded flex items-center justify-center text-slate-700 font-bold text-[10px] uppercase`,children:j.type}),(0,d.jsxs)(`span`,{className:`text-xs font-bold text-slate-700 capitalize`,children:[`Editing `,j.type===`table`?`Table Block`:`Typography Element`]})]}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-slate-50 border border-gray-200 rounded-xl select-none`,children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 block`,children:`Row Alignment`}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400`,children:`Display side-by-side`})]}),(0,d.jsx)(`button`,{onClick:()=>{let e=!j.style.sameRow;n(`sameRow`,e),e?(n(`width`,`48%`),b(e=>{let t=e.findIndex(e=>e.id===j.id);return t>0?e.map((e,n)=>n===t-1&&(!e.style.width||e.style.width===`100%`)?T(T({},e),{},{style:T(T({},e.style),{},{width:`48%`})}):e):e})):n(`width`,`100%`)},className:`w-10 h-6 flex items-center rounded-full p-1 transition-colors duration-150 ${j.style.sameRow?`bg-orange-600 justify-end`:`bg-slate-300 justify-start`}`,children:(0,d.jsx)(`span`,{className:`bg-white w-4 h-4 rounded-full shadow-md`})})]}),j.style.sameRow&&(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-slate-50 border border-gray-200 rounded-xl select-none`,children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 block`,children:`Row Direction`}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400`,children:`Layout stacked or side-by-side`})]}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-1 bg-slate-100 p-0.5 border border-gray-200 rounded-lg w-[180px]`,children:[`row`,`column`].map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>{n(`flexDirection`,e),b(t=>{let n=t.findIndex(e=>e.id===j.id);if(n===-1)return t;let r=n;for(;r>0&&t[r].style.sameRow;)r--;let i=[r],a=r+1;for(;a<t.length&&t[a].style.sameRow;)i.push(a),a++;return t.map((t,n)=>i.includes(n)?T(T({},t),{},{style:T(T({},t.style),{},{flexDirection:e})}):t)})},className:`px-2 py-1 text-[9px] font-bold rounded capitalize transition-all text-center ${j.style.flexDirection===e||e===`row`&&!j.style.flexDirection?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:e===`row`?`Side-by-side`:`Stacked`},e))})]}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Font Size`}),(0,d.jsx)(`select`,{value:j.style.fontSize,onChange:e=>n(`fontSize`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:i.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),!ie&&(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Weight`}),(0,d.jsx)(`select`,{value:j.style.fontWeight,onChange:e=>n(`fontWeight`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:o.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),!ie&&(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Font Family`}),(0,d.jsxs)(`select`,{value:j.style.fontFamily||``,onChange:e=>n(`fontFamily`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:[(0,d.jsx)(`option`,{value:``,children:`Default Font (Global)`}),a.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),!ie&&(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Alignment & Formatting`}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border border-gray-200 rounded-lg p-1 bg-slate-50`,children:[(0,d.jsx)(`div`,{className:`flex items-center space-x-0.5`,children:[{value:`left`,icon:(0,d.jsx)(ox,{className:`h-3.5 w-3.5`})},{value:`center`,icon:(0,d.jsx)(rx,{className:`h-3.5 w-3.5`})},{value:`right`,icon:(0,d.jsx)(ix,{className:`h-3.5 w-3.5`})},{value:`justify`,icon:(0,d.jsx)(ax,{className:`h-3.5 w-3.5`})}].map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`textAlign`,e.value),className:`p-1.5 rounded transition-all ${j.style.textAlign===e.value?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:e.icon},e.value))}),(0,d.jsx)(`div`,{className:`h-5 w-[1px] bg-slate-200 mx-1`}),(0,d.jsx)(`div`,{className:`flex items-center space-x-0.5`,children:[{key:`bold`,label:`B`,className:`font-bold`},{key:`italic`,label:`I`,className:`italic`},{key:`underline`,label:`U`,className:`underline`},{key:`strikethrough`,label:`S`,className:`line-through`}].map(e=>{let t=j.style[e.key]===!0;return(0,d.jsx)(`button`,{onClick:()=>n(e.key,!t),className:`h-7 w-7 rounded text-xs transition-all ${t?`bg-white text-slate-800 shadow-xs border border-gray-200 font-bold`:`text-slate-500 hover:text-slate-800`}`,children:(0,d.jsx)(`span`,{className:e.className,children:e.label})},e.key)})})]})]}),(0,d.jsxs)(`div`,{className:`space-y-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Text Color`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[mb.map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`color`,e),className:`h-5 w-5 rounded-full border border-gray-200 shadow-xs transition-transform ${j.style.color===e?`scale-120 ring-2 ring-slate-800`:`hover:scale-110`}`,style:{backgroundColor:e}},e)),(0,d.jsx)(`input`,{type:`color`,value:j.style.color,onChange:e=>n(`color`,e.target.value),className:`h-5 w-5 rounded-full border border-gray-200 cursor-pointer overflow-hidden p-0`})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Background Color`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[hb.map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`backgroundColor`,e),className:`h-5 w-5 rounded-full border border-gray-200 shadow-xs transition-transform ${j.style.backgroundColor===e?`scale-120 ring-2 ring-slate-800`:`hover:scale-110`}`,style:{backgroundColor:e===`transparent`?`#ffffff`:e},children:e===`transparent`&&(0,d.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold block leading-5 text-center`,children:`T`})},e)),(0,d.jsx)(`input`,{type:`color`,value:j.style.backgroundColor===`transparent`?`#ffffff`:j.style.backgroundColor,onChange:e=>n(`backgroundColor`,e.target.value),className:`h-5 w-5 rounded-full border border-gray-200 cursor-pointer overflow-hidden p-0`})]})]})]}),(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Block Width (%)`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:[gx(j.style.width),`%`]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`input`,{type:`range`,min:`10`,max:`100`,step:`5`,value:gx(j.style.width),onChange:e=>n(`width`,`${Math.min(100,Math.max(10,parseInt(e.target.value,10)))}%`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 w-10 text-right`,children:[gx(j.style.width),`%`]})]})]}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Bottom Margin`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(j.style.marginBottom||`0px`),onChange:e=>n(`marginBottom`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg`})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Padding`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(j.style.padding||`0px`),onChange:e=>n(`padding`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg`})]})]})]}),ie&&j.tableInfo&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Table Rows`}),(0,d.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-medium`,children:[((x=j.tableInfo.mockRows)==null?void 0:x.length)||1,` row(s) configured`]})]}),(0,d.jsxs)(`button`,{type:`button`,onClick:()=>v&&v(j.id),className:`px-3 py-1.5 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-bold transition-all flex items-center space-x-1 shadow-xs`,title:`Add a new row to table`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Add Row`})]})]}),(0,d.jsx)(`div`,{className:`space-y-1.5 max-h-[140px] overflow-y-auto pr-1`,children:(j.tableInfo.mockRows&&j.tableInfo.mockRows.length>0?j.tableInfo.mockRows:[{}]).map((e,t)=>{var n;return(0,d.jsxs)(`div`,{className:`flex items-center justify-between bg-slate-50 border border-gray-200 rounded-lg p-2 text-xs`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-slate-700`,children:[`Row #`,t+1]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>y&&y(t,j.id),disabled:(((n=j.tableInfo)==null||(n=n.mockRows)==null?void 0:n.length)||1)<=1,className:`p-1 text-slate-400 hover:text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:hover:bg-transparent rounded transition-colors`,title:`Remove row`,children:(0,d.jsx)(sx,{className:`h-3.5 w-3.5`})})]},t)})})]}),(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Table Columns`}),(0,d.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1`,children:j.tableInfo.columns.map((e,t)=>{var n,r;let i=e.loop&&e.columns&&e.columns.length>0;return(0,d.jsxs)(`div`,{className:`bg-slate-50 border border-gray-200 rounded-lg p-2 space-y-1.5 text-xs`,children:[S===String(t)?(0,d.jsxs)(`div`,{className:`space-y-1.5 p-1 bg-white border border-orange-300 rounded`,children:[(0,d.jsx)(`div`,{className:`text-[9px] font-bold text-orange-600 uppercase`,children:`Edit Column`}),(0,d.jsx)(`input`,{type:`text`,value:w,onChange:e=>E(e.target.value),placeholder:`Header Name`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-xs bg-white`}),(0,d.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Value (e.g. {{item.sku}})`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-xs font-mono bg-white`}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,d.jsxs)(`button`,{onClick:()=>{g&&g(t,w,D),C(null)},className:`p-1 px-2 bg-orange-600 text-white hover:bg-orange-700 rounded text-[10px] flex items-center gap-1 font-bold`,children:[(0,d.jsx)(Hb,{className:`h-3 w-3`}),(0,d.jsx)(`span`,{children:`Save`})]}),(0,d.jsxs)(`button`,{onClick:()=>C(null),className:`p-1 px-2 bg-gray-200 text-slate-700 hover:bg-gray-300 rounded text-[10px] flex items-center gap-1`,children:[(0,d.jsx)(ux,{className:`h-3 w-3`}),(0,d.jsx)(`span`,{children:`Cancel`})]})]})]}):(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{className:`truncate mr-2`,children:[(0,d.jsxs)(`span`,{className:`font-bold text-slate-700 block truncate flex items-center gap-1`,children:[(0,d.jsx)(`span`,{children:e.columnName}),i&&(0,d.jsx)(`span`,{className:`px-1 bg-blue-100 text-blue-700 rounded text-[8px] font-mono`,children:`loop (sub-table)`})]}),(0,d.jsx)(`code`,{className:`text-[9px] font-mono text-slate-500 truncate block`,children:e.placeholder})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`up`),disabled:t===0,className:`p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-200 disabled:opacity-30 disabled:hover:bg-transparent rounded transition-colors`,title:`Move Up`,children:(0,d.jsx)(Bb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`down`),disabled:t===(((n=j.tableInfo)==null?void 0:n.columns.length)||0)-1,className:`p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-200 disabled:opacity-30 disabled:hover:bg-transparent rounded transition-colors`,title:`Move Down`,children:(0,d.jsx)(zb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{onClick:()=>{C(String(t)),E(e.columnName),O(e.placeholder)},className:`p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-200 rounded transition-colors`,title:`Edit column`,children:(0,d.jsx)(Jb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{onClick:()=>h(t),className:`p-1 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded transition-colors border border-transparent`,disabled:!j.tableInfo||j.tableInfo.columns.length<=1,title:`Delete column`,children:(0,d.jsx)(sx,{className:`h-3.5 w-3.5`})})]})]}),i&&(0,d.jsxs)(`div`,{className:`ml-2 pl-2 border-l-2 border-blue-200 space-y-1.5 pt-1 mt-1`,children:[(0,d.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,d.jsxs)(`span`,{className:`text-[8px] font-bold text-blue-600 uppercase tracking-wider block`,children:[`Sub-Table Columns (`,((r=e.columns)==null?void 0:r.length)||0,`):`]})}),e.columns.map((n,r)=>{let i=`${t}-${r}`;return S===i?(0,d.jsxs)(`div`,{className:`space-y-1 p-1.5 bg-white border border-blue-300 rounded`,children:[(0,d.jsx)(`div`,{className:`text-[8px] font-bold text-blue-600 uppercase`,children:`Edit Sub-Column`}),(0,d.jsx)(`input`,{type:`text`,value:w,onChange:e=>E(e.target.value),placeholder:`Header Name`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-[11px] bg-white`}),(0,d.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Value`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-[11px] font-mono bg-white`}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-1 pt-0.5`,children:[(0,d.jsxs)(`button`,{onClick:()=>{g&&g(t,w,D,r),C(null)},className:`p-0.5 px-1.5 bg-blue-600 text-white hover:bg-blue-700 rounded text-[9px] flex items-center gap-1 font-bold`,children:[(0,d.jsx)(Hb,{className:`h-2.5 w-2.5`}),(0,d.jsx)(`span`,{children:`Save`})]}),(0,d.jsxs)(`button`,{onClick:()=>C(null),className:`p-0.5 px-1.5 bg-gray-200 text-slate-700 hover:bg-gray-300 rounded text-[9px] flex items-center gap-1`,children:[(0,d.jsx)(ux,{className:`h-2.5 w-2.5`}),(0,d.jsx)(`span`,{children:`Cancel`})]})]})]},r):(0,d.jsxs)(`div`,{className:`flex items-center justify-between bg-white border border-gray-150 rounded px-2 py-1 text-[11px]`,children:[(0,d.jsxs)(`div`,{className:`truncate mr-1`,children:[(0,d.jsx)(`span`,{className:`font-semibold text-slate-700 block truncate`,children:n.columnName}),(0,d.jsx)(`code`,{className:`text-[8px] font-mono text-slate-400 truncate block`,children:n.placeholder})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`up`,r),disabled:r===0,className:`p-0.5 text-slate-400 hover:text-slate-700 hover:bg-slate-100 disabled:opacity-30 disabled:hover:bg-transparent rounded`,title:`Move Sub-Column Up`,children:(0,d.jsx)(Bb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`down`,r),disabled:r===e.columns.length-1,className:`p-0.5 text-slate-400 hover:text-slate-700 hover:bg-slate-100 disabled:opacity-30 disabled:hover:bg-transparent rounded`,title:`Move Sub-Column Down`,children:(0,d.jsx)(zb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>{C(i),E(n.columnName),O(n.placeholder)},className:`p-0.5 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded`,title:`Edit sub-column`,children:(0,d.jsx)(Jb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>h(t,r),className:`p-0.5 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded`,title:`Delete sub-column`,children:(0,d.jsx)(sx,{className:`h-3 w-3`})})]})]},r)}),k===t?(0,d.jsxs)(`div`,{className:`bg-white border border-blue-200 rounded p-2 space-y-1.5 mt-1`,children:[(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-blue-600 block`,children:`Add Sub-Column`}),(0,d.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),placeholder:`Header Name (e.g. Price)`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs bg-white`}),(0,d.jsx)(`input`,{type:`text`,value:ne,onChange:e=>re(e.target.value),placeholder:`Value (e.g. {{item.price}})`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs font-mono bg-white`}),(0,d.jsxs)(`div`,{className:`flex gap-1 pt-1`,children:[(0,d.jsx)(`button`,{onClick:()=>{ee.trim()&&(m(ee,ne||`{{item.value}}`,!1,t),te(``),re(``),A(null))},className:`flex-1 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded text-[10px] font-bold`,children:`Add`}),(0,d.jsx)(`button`,{onClick:()=>{A(null),te(``),re(``)},className:`py-1 px-2 bg-gray-100 hover:bg-gray-200 text-slate-600 rounded text-[10px]`,children:`Cancel`})]})]}):(0,d.jsxs)(`button`,{onClick:()=>A(t),className:`w-full py-1 text-[10px] font-bold text-blue-600 hover:bg-blue-50 border border-dashed border-blue-200 rounded flex items-center justify-center space-x-1 transition-colors mt-1`,children:[(0,d.jsx)(Yb,{className:`h-3 w-3`}),(0,d.jsx)(`span`,{children:`Add Sub-Column`})]})]})]},t)})}),(0,d.jsxs)(`div`,{className:`bg-slate-50 border border-gray-200 border-dashed rounded-xl p-3 space-y-3`,children:[(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Add New Column`}),(0,d.jsx)(`div`,{children:(0,d.jsx)(`input`,{type:`text`,value:c,onChange:e=>u(e.target.value),placeholder:`Header Name`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs focus:outline-none focus:border-slate-500 bg-white`})}),(0,d.jsx)(`div`,{children:(0,d.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Value (e.g. {{item.sku}})`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs font-mono focus:outline-none focus:border-orange-655 bg-white`})}),(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsxs)(`button`,{onClick:ae,className:`flex-1 py-1.5 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-bold transition-all flex items-center justify-center space-x-1`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Column`})]}),(0,d.jsxs)(`button`,{onClick:()=>{c.trim()&&(m(c,f||`{{item.price}}`,!0),u(``),p(``))},className:`flex-1 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-xs font-bold transition-all flex items-center justify-center space-x-1`,title:`Add column as nested sub-table`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Sub-Table`})]})]})]})]})]}),(0,d.jsx)(`div`,{className:`pt-4 border-t border-red-100 flex items-center justify-between`,children:(0,d.jsxs)(`button`,{onClick:()=>s(j.id),className:`w-full py-2 bg-red-50 hover:bg-red-100 border border-red-200 text-red-650 rounded-xl text-xs font-bold transition-all flex items-center justify-center space-x-1 shadow-xs cursor-pointer`,children:[(0,d.jsx)(sx,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Delete Element`})]})})]})]})}function vx({activeTab:e,setActiveTab:t,setBlocks:n,selectedBlockId:r,setSelectedBlockId:i,getSelectedBlock:a,defaultStyles:o,createTextBlock:s,createImageBlock:c,updateSelectedStyle:l,updateSelectedImageInfo:u,handleDeleteBlock:f,handleRemoveTableColumn:p,handleAddTableColumn:m,handleUpdateTableColumn:h,handleReorderTableColumn:g,handleAddTableRow:_,handleRemoveTableRow:v,schemas:y,toggleSchemaColumn:b,customTableName:x,setCustomTableName:S,customLoopStart:C,setCustomLoopStart:w,customLoopEnd:T,setCustomLoopEnd:E,handleAddCustomTable:D,newColName:O,setNewColName:k,newColPlaceholder:A,setNewColPlaceholder:ee,customImageTypes:te,newImgTypeName:ne,setNewImgTypeName:re,handleAddCustomImageType:j,placeholders:ie,searchPlaceholder:ae,setSearchPlaceholder:oe,handleSidebarDragStart:se,isTablesLoading:ce,tablesLoading:le,isPlaceholdersLoading:ue,placeholdersLoading:de,fontSizesState:fe,fontFamiliesState:pe,fontWeightsState:me,sidebarPosition:he=`left`}){return(0,d.jsxs)(`aside`,{className:`w-full lg:w-[30%] flex flex-col bg-white border-t lg:border-t-0 ${he===`left`?`lg:border-r`:`lg:border-l`} border-gray-200 overflow-y-auto shrink-0`,children:[(0,d.jsx)(`div`,{className:`grid grid-cols-5 gap-1 border-b border-gray-250 p-2 bg-slate-50`,children:[{value:`text`,icon:(0,d.jsx)(cx,{className:`h-4 w-4`})},{value:`tables`,icon:(0,d.jsx)(nx,{className:`h-4 w-4`})},{value:`images`,icon:(0,d.jsx)(qb,{className:`h-4 w-4`})},{value:`placeholders`,icon:(0,d.jsx)($b,{className:`h-4 w-4`})},{value:`styles`,icon:(0,d.jsx)(Qb,{className:`h-4 w-4`})}].map(n=>(0,d.jsxs)(`button`,{onClick:()=>t(n.value),className:`py-2 px-0.5 flex flex-col items-center justify-center gap-1 font-bold text-[9px] rounded-lg uppercase tracking-wider transition-all duration-150 ${e===n.value?`bg-orange-600 text-white shadow-sm shadow-orange-600/10`:`text-slate-500 hover:text-orange-600 hover:bg-orange-50/50`}`,children:[n.icon,(0,d.jsx)(`span`,{children:n.value})]},n.value))}),(0,d.jsxs)(`div`,{className:`p-4 flex-1 flex flex-col min-h-0 overflow-y-auto`,children:[e===`text`&&(0,d.jsx)(fx,{handleSidebarDragStart:se,createTextBlock:s,setBlocks:n,setSelectedBlockId:i,setActiveTab:t,defaultStyles:o}),e===`tables`&&(0,d.jsx)(px,{schemas:y,toggleSchemaColumn:b,customTableName:x,setCustomTableName:S,customLoopStart:C,setCustomLoopStart:w,customLoopEnd:T,setCustomLoopEnd:E,handleAddCustomTable:D,handleSidebarDragStart:se,setBlocks:n,setSelectedBlockId:i,setActiveTab:t,defaultStyles:o,isTablesLoading:ce,tablesLoading:le}),e===`images`&&(0,d.jsx)(mx,{customImageTypes:te,newImgTypeName:ne,setNewImgTypeName:re,handleAddCustomImageType:j,handleSidebarDragStart:se,createImageBlock:c,setBlocks:n,setSelectedBlockId:i,setActiveTab:t}),e===`placeholders`&&(0,d.jsx)(hx,{placeholders:ie,schemas:y,searchPlaceholder:ae,setSearchPlaceholder:oe,selectedBlockId:r,setBlocks:n,isPlaceholdersLoading:ue,placeholdersLoading:de}),e===`styles`&&(0,d.jsx)(_x,{selectedBlockId:r,getSelectedBlock:a,updateSelectedStyle:l,updateSelectedImageInfo:u,fontSizesState:fe,fontFamiliesState:pe,fontWeightsState:me,handleDeleteBlock:f,newColName:O,setNewColName:k,newColPlaceholder:A,setNewColPlaceholder:ee,handleAddTableColumn:m,handleRemoveTableColumn:p,handleUpdateTableColumn:h,handleReorderTableColumn:g,handleAddTableRow:_,handleRemoveTableRow:v,setBlocks:n})]})]})}var yx=[`bold`,`italic`,`underline`,`strikethrough`,`width`],bx=({block:e,onUpdate:t,onSelect:n,onDrop:r})=>{let i=(0,l.useRef)(null);(0,l.useEffect)(()=>{i.current&&i.current.innerHTML!==e.content&&document.activeElement!==i.current&&(i.current.innerHTML=e.content||`<br/>`)},[e.id,e.content]);let a=e.style,{bold:o,italic:s,underline:c,strikethrough:u,width:f}=a,p=T({},Pb(a,yx));o&&(p.fontWeight=`bold`),s&&(p.fontStyle=`italic`);let m=[];return c&&m.push(`underline`),u&&m.push(`line-through`),m.length>0&&(p.textDecoration=m.join(` `)),(0,d.jsx)(`div`,{ref:i,contentEditable:!0,suppressContentEditableWarning:!0,onFocus:n,onInput:e=>t(e.currentTarget.innerHTML),onBlur:e=>t(e.currentTarget.innerHTML),style:p,className:`h-fit w-full break-words outline-none`,onDrop:r,onDragOver:e=>e.preventDefault()})},xx=({blockId:e,colIdx:t,placeholder:n,onUpdate:r,onDrop:i})=>{let a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{a.current&&a.current.innerHTML!==n&&document.activeElement!==a.current&&(a.current.innerHTML=n)},[e,t,n]),(0,d.jsx)(`td`,{ref:a,contentEditable:!0,suppressContentEditableWarning:!0,onInput:e=>r(e.currentTarget.innerText||e.currentTarget.innerHTML),onBlur:e=>r(e.currentTarget.innerText||e.currentTarget.innerHTML),onDrop:i,onDragOver:e=>e.preventDefault(),className:`border border-slate-200 px-2.5 py-2.5 text-slate-500 bg-slate-50/20 font-sans outline-none focus:bg-slate-100/50 transition-colors`})},Sx=e=>{let t=[];return e.forEach(e=>{e.style.sameRow&&t.length>0?t[t.length-1].blocks.push(e):t.push({id:e.id,blocks:[e]})}),t};function Cx({blocks:e,setBlocks:t,selectedBlockId:n,setSelectedBlockId:r,setActiveTab:i,showMockData:a,placeholderMockData:o,dragOverIndex:s,setDragOverIndex:c,draggedSidebarItem:l,defaultStyles:u,zoom:f,panOffset:p,spacePressed:m,canvasHeight:h,viewportRef:g,canvasContainerRef:_,handleMouseDown:v,handleMouseMove:y,handleMouseUp:b,createTextBlock:x,duplicateBlock:S,reorderBlock:C,handleDeleteBlock:w,handleSidebarDrop:E,handleTableCellDrop:D,updateTableCell:O,handleTextDrop:k}){let A=(e,t)=>{e.dataTransfer.setData(`blockIndex`,t.toString()),e.dataTransfer.setData(`source`,`canvas`),e.dataTransfer.effectAllowed=`move`},ee=(n,r)=>{n.preventDefault(),n.stopPropagation();let i=n.dataTransfer.getData(`source`);if(i===`sidebar`)E(r);else if(i===`canvas`){let i=parseInt(n.dataTransfer.getData(`blockIndex`));if(isNaN(i)||i===r)return;let a=[...e],o=a.splice(i,1)[0],s=i<r?r-1:r;a.splice(s,0,o),t(a)}c(null)};return(0,d.jsx)(`div`,{ref:g,className:`flex-1 overflow-auto p-8 flex justify-center items-start outline-none transition-all ${m?`cursor-grab active:cursor-grabbing`:`cursor-default`}`,onMouseDown:v,onMouseMove:y,onMouseUp:b,onMouseLeave:b,children:(0,d.jsx)(`div`,{style:{transform:`translate(${p.x}px, ${p.y}px) scale(${f})`,transformOrigin:`top center`},className:`transition-transform duration-75 ease-out select-none`,children:(0,d.jsxs)(`div`,{ref:_,style:{height:`${h}px`},className:`w-[794px] min-h-[1123px] bg-white shadow-lg border border-gray-300/80 px-[60px] py-[60px] flex flex-col relative canvas-editor-area`,onDragOver:e=>e.preventDefault(),onDrop:n=>{if(n.preventDefault(),n.stopPropagation(),l)E(e.length);else{let e=n.dataTransfer.getData(`placeholder`);if(e){n.preventDefault();let a=x(`p`,`{{${e}}}`,u==null?void 0:u.p);t(e=>[...e,a]),r(a.id),i(`styles`)}}},children:[e.length===0?(0,d.jsxs)(`div`,{className:`flex-1 border-2 border-dashed border-gray-200 rounded-2xl flex flex-col items-center justify-center p-8 text-center text-slate-400`,children:[(0,d.jsx)(Qb,{className:`h-10 w-10 mb-3 animate-bounce text-slate-350`}),(0,d.jsx)(`span`,{className:`font-bold text-sm text-slate-600 block`,children:`Drag & Drop Editor Canvas`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-400 mt-1 max-w-sm`,children:`Select elements from the sidebar tabs (Text, Tables, Images) and drag them here to assemble your template structure.`})]}):Sx(e).map(a=>{var o;let s=a.blocks.length>1;return(0,d.jsx)(`div`,{className:`group/row ${a.blocks.some(e=>e.style.position===`absolute`)?``:`relative`} border border-transparent rounded-lg hover:border-slate-200/60 p-1 mb-2 ${s?((o=a.blocks[0])==null||(o=o.style)==null?void 0:o.flexDirection)===`column`?`flex flex-col gap-2`:`flex flex-row gap-4`:``}`,children:a.blocks.map(a=>{var o,l,u,f;let p=n===a.id,m=T(T({},a.style),_b(a.style.customCss||``));return(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>{let n=e.findIndex(e=>e.id===a.id);A(t,n)},onDragOver:t=>{t.preventDefault(),c(e.findIndex(e=>e.id===a.id))},onDrop:t=>{let n=e.findIndex(e=>e.id===a.id);ee(t,n)},onClick:e=>{e.stopPropagation(),r(a.id),i(`styles`)},style:{width:a.style.position===`absolute`?`100%`:a.style.width||(s?`48%`:`100%`),height:a.style.position===`absolute`?a.style.height||`100%`:void 0,position:a.style.position,top:a.style.top,left:a.style.left,zIndex:a.style.zIndex?parseInt(a.style.zIndex):void 0},className:`group/block relative p-0.5 rounded-xl border border-transparent transition-all duration-150 cursor-pointer ${p?`bg-orange-50/20 border-orange-500 shadow-sm ring-2 ring-orange-500/10`:`hover:bg-slate-50/30 hover:border-gray-200`} ${a.style.position===`absolute`?`!absolute !inset-0 !m-auto`:``}`,children:[p&&(0,d.jsxs)(`div`,{className:`absolute -top-3.5 right-3 bg-orange-600 text-white rounded-lg px-2 py-0.5 text-[10px] font-bold flex items-center space-x-1.5 shadow-md z-30 select-none`,children:[(0,d.jsx)(`button`,{onClick:()=>{C(e.findIndex(e=>e.id===a.id),`up`)},className:`hover:text-slate-350`,title:`Move Up`,children:(0,d.jsx)(Bb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>{C(e.findIndex(e=>e.id===a.id),`down`)},className:`hover:text-slate-350`,title:`Move Down`,children:(0,d.jsx)(zb,{className:`h-3 w-3`})}),(0,d.jsx)(`div`,{className:`h-3 w-[1px] bg-slate-700`}),(0,d.jsx)(`button`,{onClick:e=>S(a.id,e),className:`hover:text-slate-350`,title:`Duplicate block`,children:(0,d.jsx)(Ub,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:e=>w(a.id,e),className:`hover:text-red-400 text-red-300`,title:`Delete block`,children:(0,d.jsx)(sx,{className:`h-3 w-3`})})]}),a.type===`table`?(0,d.jsx)(`div`,{className:`overflow-x-auto w-full select-none`,children:(0,d.jsxs)(`table`,{style:m,className:`w-full border-collapse`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsx)(`tr`,{children:(o=a.tableInfo)==null?void 0:o.columns.filter(e=>e.enabled!==!1).map((e,t)=>(0,d.jsx)(`th`,{className:`border border-slate-200 px-2.5 py-1 text-slate-700 text-left bg-slate-50 font-sans`,children:e.columnName||``},t))})}),(0,d.jsx)(`tbody`,{children:((l=a.tableInfo)!=null&&l.mockRows&&a.tableInfo.mockRows.length>0?a.tableInfo.mockRows:[{}]).map((e,t)=>{var n;return(0,d.jsx)(`tr`,{className:`bg-slate-50/10 border-b border-slate-100 hover:bg-slate-50/20`,children:(n=a.tableInfo)==null?void 0:n.columns.filter(e=>e.enabled!==!1).map((t,n)=>{let r=e&&typeof e==`object`&&e[t.columnName]||t.placeholder;if(t.loop&&t.columns&&t.columns.length>0){let e=t.columns.filter(e=>e.enabled!==!1);return(0,d.jsx)(`td`,{className:`border border-slate-200 p-2 align-top bg-slate-50/20`,children:(0,d.jsxs)(`div`,{className:`w-full overflow-x-auto space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] font-semibold text-slate-500`,children:[(0,d.jsxs)(`span`,{children:[`Sub-table: `,t.columnName]}),(0,d.jsx)(`span`,{className:`px-1.5 py-0.5 bg-slate-200 text-slate-600 rounded text-[8px]`,children:`loop = true`})]}),(0,d.jsxs)(`table`,{className:`w-full border-collapse border border-slate-200 rounded text-xs bg-white`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsx)(`tr`,{children:e.map((e,t)=>(0,d.jsx)(`th`,{className:`border border-slate-200 px-2 py-1 text-slate-700 text-left bg-slate-100/80 font-sans font-semibold text-[10px]`,children:e.columnName},t))})}),(0,d.jsx)(`tbody`,{children:(0,d.jsx)(`tr`,{className:`bg-slate-50/30`,children:e.map((e,t)=>(0,d.jsx)(xx,{blockId:a.id,colIdx:t,placeholder:e.placeholder,onUpdate:e=>O(a.id,n,e,t),onDrop:e=>D(e,a.id,n,t)},t))})})]})]})},n)}return(0,d.jsx)(xx,{blockId:a.id,colIdx:n,placeholder:r,onUpdate:e=>O(a.id,n,e),onDrop:e=>D(e,a.id,n)},n)})},t)})})]})}):a.type===`image`?(0,d.jsx)(`div`,{style:{textAlign:m.textAlign||`left`,width:`100%`,marginBottom:m.marginBottom,padding:m.padding,backgroundColor:m.backgroundColor},className:`w-full select-none`,children:(0,d.jsx)(`div`,{style:{width:s?`100%`:a.style.width&&a.style.width.endsWith(`%`)?a.style.width:`100%`,display:`inline-block`,textAlign:m.textAlign||`left`},children:((u=a.imageInfo)==null?void 0:u.imageType)===`barcode`?(0,d.jsx)(`div`,{style:{width:a.style.imageWidth||(a.style.width&&a.style.width.endsWith(`px`)?a.style.width:`100%`),height:a.style.height||a.style.minHeight||`70px`,marginLeft:m.textAlign===`center`||m.textAlign===`right`?`auto`:`0`,marginRight:m.textAlign===`center`?`auto`:m.textAlign===`right`?`0`:`auto`},className:`border border-dashed border-slate-200 p-2 bg-slate-50/5 rounded-lg flex items-center justify-center overflow-hidden`,dangerouslySetInnerHTML:{__html:vb(a.imageInfo.barcodeValue||`SHIP-99201`)}}):(0,d.jsx)(`img`,{src:((f=a.imageInfo)==null?void 0:f.url)||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`,style:{width:a.style.imageWidth||(a.style.width&&a.style.width.endsWith(`px`)?a.style.width:`100%`),height:`auto`,maxHeight:a.style.height||`300px`,objectFit:a.style.objectFit||`contain`,opacity:a.style.opacity||`1`,display:`block`,marginLeft:m.textAlign===`center`||m.textAlign===`right`?`auto`:`0`,marginRight:m.textAlign===`center`?`auto`:m.textAlign===`right`?`0`:`auto`},alt:`graphic content`})})}):(0,d.jsx)(bx,{block:a,onUpdate:e=>{t(t=>t.map(t=>t.id===a.id?T(T({},t),{},{content:e}):t))},onSelect:()=>r(a.id),onDrop:e=>k(e,a.id)})]},a.id)})},a.id)}),s!==null&&(0,d.jsx)(`div`,{className:`h-[2px] bg-orange-500 rounded my-1 shadow-md animate-pulse`})]})})})}function wx({showImportHtml:e=!0,showImportPdf:t=!0,showPreview:n=!0,showExport:r=!0,showExportPdf:i=!0,showClearCanvas:a,customButtonStyles:o,customButtonClassNames:s,customActionComponents:c,handleHtmlImport:u,handlePdfImport:f,setPreviewOpen:p,handleExport:m,handleExportPdf:h,handleClearCanvas:g,zoom:_,setZoom:v,setPanOffset:y}){let b=(0,l.useRef)(null),x=(0,l.useRef)(null);return(0,d.jsxs)(`div`,{className:`bg-white border-b border-gray-200 px-4 py-2 flex flex-wrap items-center justify-between shadow-xs sticky top-0 z-20 gap-2`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e&&(0,d.jsxs)(d.Fragment,{children:[c!=null&&c.importHtml?c.importHtml({onClick:()=>{var e;return(e=b.current)==null?void 0:e.click()}}):(0,d.jsxs)(`button`,{onClick:()=>{var e;return(e=b.current)==null?void 0:e.click()},style:o==null?void 0:o.importHtml,className:(s==null?void 0:s.importHtml)||`inline-flex items-center space-x-1 px-2.5 py-1 border border-gray-200 rounded-lg text-xs font-semibold bg-white hover:bg-slate-50 text-slate-700 transition-colors shadow-2xs cursor-pointer`,title:`Import local HTML file`,children:[(0,d.jsx)(lx,{className:`h-3.5 w-3.5 text-slate-500`}),(0,d.jsx)(`span`,{children:`Import HTML`})]}),(0,d.jsx)(`input`,{type:`file`,ref:b,onChange:u,accept:`.html`,className:`hidden`})]}),t&&(0,d.jsxs)(d.Fragment,{children:[c!=null&&c.importPdf?c.importPdf({onClick:()=>{var e;return(e=x.current)==null?void 0:e.click()}}):(0,d.jsxs)(`button`,{onClick:()=>{var e;return(e=x.current)==null?void 0:e.click()},style:o==null?void 0:o.importPdf,className:(s==null?void 0:s.importPdf)||`inline-flex items-center space-x-1 px-2.5 py-1 border border-gray-200 rounded-lg text-xs font-semibold bg-white hover:bg-slate-50 text-slate-700 transition-colors shadow-2xs cursor-pointer`,title:`Import PDF layout structure`,children:[(0,d.jsx)(Kb,{className:`h-3.5 w-3.5 text-slate-500`}),(0,d.jsx)(`span`,{children:`Import PDF`})]}),(0,d.jsx)(`input`,{type:`file`,ref:x,onChange:f,accept:`.pdf`,className:`hidden`})]}),n&&(c!=null&&c.preview?c.preview({onClick:()=>p(!0)}):(0,d.jsxs)(`button`,{onClick:()=>p(!0),style:o==null?void 0:o.preview,className:(s==null?void 0:s.preview)||`inline-flex items-center space-x-1 px-2.5 py-1 border border-slate-200 rounded-lg text-xs font-semibold bg-slate-50 text-slate-700 hover:bg-slate-100 transition-colors shadow-2xs cursor-pointer`,children:[(0,d.jsx)(Gb,{className:`h-3.5 w-3.5 text-slate-500`}),(0,d.jsx)(`span`,{children:`Live Preview`})]})),i&&(c!=null&&c.exportPdf?c.exportPdf({onClick:h}):(0,d.jsxs)(`button`,{onClick:h,style:o==null?void 0:o.exportPdf,className:(s==null?void 0:s.exportPdf)||`inline-flex items-center space-x-1 px-2.5 py-1 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-xs font-semibold transition-colors shadow-2xs shadow-indigo-600/10 cursor-pointer`,children:[(0,d.jsx)(Xb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Download PDF`})]})),r&&(c!=null&&c.export?c.export({onClick:m}):(0,d.jsxs)(`button`,{onClick:m,style:o==null?void 0:o.export,className:(s==null?void 0:s.export)||`inline-flex items-center space-x-1 px-2.5 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-semibold transition-colors shadow-2xs shadow-orange-600/10 cursor-pointer`,children:[(0,d.jsx)(Wb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Export Template`})]})),a&&(0,d.jsxs)(`button`,{onClick:g,style:o==null?void 0:o.clearCanvas,className:(s==null?void 0:s.clearCanvas)||`inline-flex items-center space-x-1 px-2.5 py-1 text-xs font-semibold border border-red-200 text-red-650 bg-red-50 hover:bg-red-100 rounded-lg transition-colors cursor-pointer`,title:`Clear all canvas elements`,children:[(0,d.jsx)(sx,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Clear Canvas`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 bg-slate-50 border border-gray-200 px-2.5 py-0.5 rounded-xl shadow-xs select-none shrink-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,d.jsx)(`button`,{onClick:()=>v(e=>Math.max(e-.1,.5)),className:`h-5 w-5 rounded border border-gray-200 bg-white hover:bg-slate-50 flex items-center justify-center font-bold text-slate-650 hover:text-slate-900 transition-colors text-[10px] select-none cursor-pointer`,title:`Zoom Out`,children:`−`}),(0,d.jsxs)(`div`,{className:`w-10 text-center text-[11px] font-bold text-slate-700`,children:[Math.round(_*100),`%`]}),(0,d.jsx)(`button`,{onClick:()=>v(e=>Math.min(e+.1,2)),className:`h-5 w-5 rounded border border-gray-200 bg-white hover:bg-slate-50 flex items-center justify-center font-bold text-slate-650 hover:text-slate-900 transition-colors text-[10px] select-none cursor-pointer`,title:`Zoom In`,children:`+`})]}),(0,d.jsx)(`div`,{className:`h-3.5 w-[1px] bg-gray-200`}),(0,d.jsx)(`input`,{type:`range`,min:`0.5`,max:`2.0`,step:`0.05`,value:_,onChange:e=>v(parseFloat(e.target.value)),className:`w-16 accent-orange-600 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsx)(`button`,{onClick:()=>{v(1),y({x:0,y:0})},className:`text-[9px] font-bold text-slate-500 hover:text-slate-800 hover:underline cursor-pointer`,children:`Reset`})]})]})}function Tx({previewOpen:e,setPreviewOpen:t,generateExportHtml:n}){return e?(0,d.jsx)(`div`,{className:`fixed inset-0 bg-slate-950/65 backdrop-blur-xs flex items-center justify-center z-50 p-6`,children:(0,d.jsxs)(`div`,{className:`bg-white rounded-2xl w-full max-w-[900px] h-[90%] flex flex-col shadow-2xl overflow-hidden border border-gray-200`,children:[(0,d.jsxs)(`div`,{className:`bg-slate-50 border-b border-gray-200 px-6 py-4 flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`h3`,{className:`text-sm font-bold text-slate-800 flex items-center space-x-2`,children:[(0,d.jsx)(Gb,{className:`h-4 w-4 text-slate-655`}),(0,d.jsx)(`span`,{children:`HTML Document Render Output`})]}),(0,d.jsx)(`p`,{className:`text-[10px] text-slate-400 mt-0.5`,children:`Sandboxed iframe preview of final template markup`})]}),(0,d.jsx)(`button`,{onClick:()=>t(!1),className:`p-1.5 bg-slate-100 hover:bg-slate-200 text-slate-500 hover:text-slate-800 rounded-lg transition-colors`,children:(0,d.jsx)(ux,{className:`h-4 w-4`})})]}),(0,d.jsx)(`div`,{className:`flex-1 bg-slate-100 p-6 overflow-hidden`,children:(0,d.jsx)(`iframe`,{title:`HTML Preview Sandbox`,srcDoc:n(!0),className:`w-full h-full bg-white border border-gray-200 rounded-xl shadow-xs`,sandbox:`allow-same-origin`})}),(0,d.jsxs)(`details`,{className:`bg-slate-50 border-t border-gray-200`,children:[(0,d.jsxs)(`summary`,{className:`px-6 py-3 text-xs font-bold text-slate-600 cursor-pointer select-none hover:text-slate-800 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{children:`View Raw Output Markup (HTML)`}),(0,d.jsx)(`span`,{className:`text-[10px] text-slate-400 font-medium font-sans`,children:`Click to expand`})]}),(0,d.jsx)(`div`,{className:`px-6 pb-6 overflow-x-auto max-h-[250px]`,children:(0,d.jsx)(`pre`,{className:`bg-slate-900 text-slate-200 p-4 rounded-lg text-[10px] font-mono whitespace-pre-wrap select-all`,children:n(!1)})})]})]})}):null}function Ex({bubbleCoords:e,applySelectionFormat:t}){return e?(0,d.jsxs)(`div`,{className:`fixed bg-slate-900 border border-slate-800 text-white rounded-xl shadow-xl py-1 px-1.5 flex items-center space-x-1.5 z-50 select-none -translate-x-1/2`,style:{left:`${e.x}px`,top:`${e.y}px`},children:[(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`bold`)},className:`h-6 w-6 rounded hover:bg-slate-800 flex items-center justify-center font-bold text-xs text-slate-200 hover:text-white transition-colors`,title:`Bold Selection`,children:`B`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`italic`)},className:`h-6 w-6 rounded hover:bg-slate-800 flex items-center justify-center italic text-xs text-slate-200 hover:text-white transition-colors`,title:`Italic Selection`,children:`I`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`underline`)},className:`h-6 w-6 rounded hover:bg-slate-800 flex items-center justify-center underline text-xs text-slate-200 hover:text-white transition-colors`,title:`Underline Selection`,children:`U`}),(0,d.jsx)(`div`,{className:`h-4 w-[1px] bg-slate-800 mx-1`}),(0,d.jsxs)(`select`,{value:e.format||``,onChange:e=>{e.preventDefault(),e.target.value&&(t(`formatBlock`,e.target.value),e.target.value===`P`&&t(`fontSize`,`3`))},className:`bg-slate-800 text-white text-[10px] rounded px-1 py-0.5 outline-none cursor-pointer border border-slate-700`,children:[(0,d.jsx)(`option`,{value:``,disabled:!0,children:`Format...`}),(0,d.jsx)(`option`,{value:`H1`,children:`Heading 1`}),(0,d.jsx)(`option`,{value:`H2`,children:`Heading 2`}),(0,d.jsx)(`option`,{value:`H3`,children:`Heading 3`}),(0,d.jsx)(`option`,{value:`P`,children:`Paragraph`}),(0,d.jsx)(`option`,{value:`BLOCKQUOTE`,children:`Quote`})]}),(0,d.jsx)(`div`,{className:`h-4 w-[1px] bg-slate-800 mx-1`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#3b82f6`)},className:`h-4 w-4 rounded-full bg-blue-500 hover:scale-110 transition-transform cursor-pointer`,title:`Color Blue`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#ef4444`)},className:`h-4 w-4 rounded-full bg-red-500 hover:scale-110 transition-transform cursor-pointer`,title:`Color Red`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#1e293b`)},className:`h-4 w-4 rounded-full bg-slate-700 hover:scale-110 transition-transform cursor-pointer border border-slate-850`,title:`Color Slate`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#22c55e`)},className:`h-4 w-4 rounded-full bg-green-500 hover:scale-110 transition-transform cursor-pointer`,title:`Color Green`}),(0,d.jsx)(`div`,{className:`h-4 w-[1px] bg-slate-800`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`removeFormat`)},className:`hover:bg-slate-800 rounded text-[10px] px-1.5 h-6 flex items-center justify-center text-slate-400 hover:text-white font-semibold transition-colors`,title:`Clear Formatting`,children:`Clear`})]}):null}Bu.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@6.1.200/build/pdf.worker.min.mjs`;var Dx=e=>{let t=[];return e.forEach(e=>{e.style.sameRow&&t.length>0?t[t.length-1].blocks.push(e):t.push({id:e.id,blocks:[e]})}),t},Ox=e=>e?e.replace(/contenteditable="[^"]*"/g,``).replace(/class="[^"]*"/g,``).replace(/data-placeholder="[^"]*"/g,``).replace(/ /g,` `).trim():``;function kx({tableSchemas:e,placeholders:t,defaultLogo:n,defaultBanner:r,headerTitle:i=`HTML Template Builder`,headerSubtitle:a=`Design and export templates dynamically`,headerLogo:o,typographySizes:s,typographyWeights:c,typographyFonts:u,templatingLanguage:f=`csharp`,loopSyntax:p=`foreach`,onChange:m,onExport:h,onExportPdf:g,initialBlocks:_,defaultStyles:y,showImportHtml:b=!0,showImportPdf:x=!0,showClearCanvas:S=!0,showPreview:C=!0,showExport:w=!0,showExportPdf:E=!0,showHeader:D=!0,sidebarPosition:O=`left`,isTablesLoading:A,tablesLoading:ee,isPlaceholdersLoading:te,placeholdersLoading:ne,customButtonStyles:re,customButtonClassNames:j,customActionComponents:ie}={}){let{zoom:ae,setZoom:oe,panOffset:se,setPanOffset:ce,spacePressed:le,canvasHeight:ue,viewportRef:de,canvasContainerRef:fe,handleMouseDown:pe,handleMouseMove:me,handleMouseUp:he}=Cb(),{customTableName:ge,setCustomTableName:_e,customLoopStart:ve,setCustomLoopStart:ye,customLoopEnd:be,setCustomLoopEnd:xe,newColName:Se,setNewColName:Ce,newColPlaceholder:we,setNewColPlaceholder:Te,bubbleCoords:Ee,setBubbleCoords:M,schemas:N,isParsing:De,setIsParsing:Oe,parseStatusText:ke,setParseStatusText:Ae,parseError:je,setParseError:Me,draggedSidebarItem:P,setDraggedSidebarItem:Ne,dragOverIndex:Pe,setDragOverIndex:Fe,newImgTypeName:Ie,setNewImgTypeName:Le,customImageTypes:Re,searchPlaceholder:F,setSearchPlaceholder:I,handleAddCustomTable:ze,handleAddCustomImageType:Be,toggleSchemaColumn:Ve,applySelectionFormat:He,setSavedRange:Ue}=wb({tableSchemas:e}),{blocks:L,setBlocks:We,selectedBlockId:Ge,setSelectedBlockId:Ke,getSelectedBlock:qe,createTextBlock:Je,createTableBlock:Ye,createImageBlock:Xe,handleDeleteBlock:Ze,handleDuplicateBlock:Qe,handleMoveBlockUp:R,handleMoveBlockDown:z,updateSelectedStyle:$e,updateSelectedImageInfo:et,handleRemoveTableColumn:tt,handleAddTableColumn:nt,handleUpdateTableColumn:rt,handleReorderTableColumn:it,handleAddTableRow:at,handleRemoveTableRow:ot}=Sb({initialBlocks:_,defaultStyles:y,defaultLogo:n,defaultBanner:r,onChange:m}),[st,ct]=(0,l.useState)(`text`),[lt,B]=(0,l.useState)(!1),[ut]=(0,l.useState)(!0),[dt]=(0,l.useState)(s||[{label:`8px`,value:`8px`},{label:`9px`,value:`9px`},{label:`10px`,value:`10px`},{label:`11px`,value:`11px`},{label:`12px`,value:`12px`},{label:`14px`,value:`14px`},{label:`16px`,value:`16px`},{label:`18px`,value:`18px`},{label:`20px`,value:`20px`},{label:`24px`,value:`24px`},{label:`28px`,value:`28px`},{label:`32px`,value:`32px`},{label:`36px`,value:`36px`}]),[ft]=(0,l.useState)(u||[{label:`Outfit (Default)`,value:`'Outfit', 'Inter', sans-serif`},{label:`Inter`,value:`'Inter', sans-serif`},{label:`Roboto`,value:`'Roboto', sans-serif`},{label:`System Sans`,value:`system-ui, -apple-system, sans-serif`},{label:`Georgia (Serif)`,value:`Georgia, serif`},{label:`Courier New (Mono)`,value:`'Courier New', monospace`}]),[pt]=(0,l.useState)(c||[{label:`Light`,value:`300`},{label:`Regular`,value:`400`},{label:`Medium`,value:`500`},{label:`Semibold`,value:`600`},{label:`Bold`,value:`700`},{label:`Extra Bold`,value:`800`}]),[mt]=(0,l.useState)(f),[ht]=(0,l.useState)(p),[gt]=(0,l.useState)(!0),_t={};(0,l.useEffect)(()=>{let e=()=>{let e=window.getSelection();if(!e||e.isCollapsed||e.toString().trim()===``){M(null),Ue(null);return}let t=document.activeElement;if(!(t&&t.getAttribute(`contenteditable`)===`true`&&(t.closest(`.canvas-editor-area`)||t.closest(`td`)))){M(null),Ue(null);return}try{let t=e.getRangeAt(0),n=t.getBoundingClientRect(),r=document.queryCommandValue(`formatBlock`)||``;r=r.toUpperCase(),M({x:n.left+n.width/2,y:n.top-38,format:r}),Ue(t)}catch(e){M(null),Ue(null)}};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[M,Ue]),(0,l.useEffect)(()=>{let e=de.current;if(!e)return;let t=e=>{if(e.ctrlKey){e.preventDefault();let t=e.deltaY<0?1:-1;oe(e=>Math.min(2,Math.max(.5,e+t*.05)))}};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[de,oe]),(0,l.useEffect)(()=>{window.updateContentFromRawDelete=(e,t)=>{We(n=>n.map(n=>n.id===e?T(T({},n),{},{content:t}):n))}},[We]);let vt=e=>{var t;let n=(t=e.target.files)==null?void 0:t[0];if(!n)return;Oe(!0),Ae(`Parsing HTML...`),Me(null);let r=new FileReader;r.onload=t=>{try{var n;let e=bb((n=t.target)==null?void 0:n.result);e.length>0&&We(e)}catch(e){console.error(e),Me(e.message||`Failed to parse HTML`)}finally{Oe(!1),e.target&&(e.target.value=``)}},r.readAsText(n)},yt=e=>{var t;let n=(t=e.target.files)==null?void 0:t[0];if(!n)return;Oe(!0),Ae(`Reading PDF text layers...`),Me(null);let r=new FileReader;r.onload=v(function*(){try{let e=r.result,t=yield xb(e,k);t.length>0&&We(e=>[...e,...t])}catch(e){console.error(e),Me(e.message||`Failed to read PDF`)}finally{Oe(!1),e.target&&(e.target.value=``)}}),r.readAsArrayBuffer(n)},bt=e=>{let t=e||`items`;if(mt===`handlebars`||mt===`mustache`){let e=ht===`foreach`?`foreach`:`each`;return{start:`{{#${e} ${t}}}`,end:`{{/${e}}}`}}return mt===`liquid`||mt===`scriban`||mt===`dotnet`?{start:`{% for ${t.endsWith(`s`)?t.slice(0,-1):`item`} in ${t} %}`,end:`{% endfor %}`}:mt===`js`||mt===`ts`?{start:`\${${t}.map(${t.endsWith(`s`)?t.slice(0,-1):`item`} => \``,end:"`).join('')}"}:mt===`csharp`||mt===`razor`?{start:`@foreach (var ${t.endsWith(`s`)?t.slice(0,-1):`item`} in ${t}) {`,end:`}`}:{start:ve.replace(`items`,t),end:be}},xt=(e=!1)=>{let t=`<!DOCTYPE html>
|
|
58
|
+
</svg>`},yb=(e,t)=>{let n=`11px`,r=`400`;return e===`h1`?(n=`24px`,r=`700`):e===`h2`?(n=`20px`,r=`700`):e===`h3`?(n=`16px`,r=`600`):e===`h4`?(n=`14px`,r=`600`):e===`h5`?(n=`12px`,r=`600`):e===`h6`?(n=`10px`,r=`600`):e===`title`?(n=`28px`,r=`800`):e===`subtitle`?(n=`14px`,r=`300`):e===`caption`&&(n=`9px`,r=`400`),{id:`block-${Math.random().toString(36).substr(2,9)}`,type:e,content:t,style:{fontSize:n,fontWeight:r,color:`#1e293b`,backgroundColor:`transparent`,textAlign:`left`,bold:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`title`].includes(e),italic:!1,underline:!1,strikethrough:!1,width:`100%`,marginBottom:`8px`,padding:`8px`,minHeight:`auto`}}},bb=e=>{let t=new DOMParser().parseFromString(e,`text/html`),n=[],r=Array.from(t.body.children);if(r.length===0){let e=t.body.innerText||t.body.textContent||``;e.trim()&&n.push(yb(`p`,e.trim()))}else{let e=t.querySelectorAll(`style`),i=[];e.forEach(e=>{let t=e.textContent||``,n=/([^{]+)\{([^}]+)\}/g,r;for(;(r=n.exec(t))!==null;){let e=r[1].trim(),t=r[2].trim(),n={};t.split(`;`).forEach(e=>{let t=e.split(`:`);t.length===2&&(n[t[0].trim().toLowerCase()]=t[1].trim())}),i.push({selector:e,styles:n})}});let a=e=>{let t={fontSize:`11px`,fontWeight:`400`,color:`#1e293b`,backgroundColor:`transparent`,textAlign:`left`,bold:!1,italic:!1,underline:!1,strikethrough:!1,width:`100%`,marginBottom:`8px`,padding:`8px`},n=e.style;return n.fontSize&&(t.fontSize=n.fontSize),n.fontWeight&&(t.fontWeight=n.fontWeight),n.color&&(t.color=n.color),n.backgroundColor&&(t.backgroundColor=n.backgroundColor),n.textAlign&&(t.textAlign=n.textAlign),n.padding&&(t.padding=n.padding),n.marginBottom&&(t.marginBottom=n.marginBottom),n.width&&(t.width=n.width),i.forEach(n=>{try{e.matches(n.selector)&&(n.styles[`font-size`]&&(t.fontSize=n.styles[`font-size`]),n.styles[`font-weight`]&&(t.fontWeight=n.styles[`font-weight`]),n.styles.color&&(t.color=n.styles.color),n.styles[`background-color`]&&(t.backgroundColor=n.styles[`background-color`]),n.styles[`text-align`]&&(t.textAlign=n.styles[`text-align`]),n.styles.padding&&(t.padding=n.styles.padding),n.styles[`margin-bottom`]&&(t.marginBottom=n.styles[`margin-bottom`]),n.styles.width&&(t.width=n.styles.width))}catch(e){}}),(t.fontWeight===`bold`||parseInt(t.fontWeight)>=600)&&(t.bold=!0),t};r.forEach(e=>{let t=e;if(t.tagName===`STYLE`)return;let r=t.querySelector(`table, img, h1, h2, h3, h4, h5, h6, p, span, div`)||t,i=r.tagName.toLowerCase(),o=a(r);if(i===`table`){let e=Array.from(r.querySelectorAll(`thead th`));e.length===0&&(e=Array.from(r.querySelectorAll(`tr:first-child th, tr:first-child td`)));let t=e.map(e=>{var t,n;return{columnName:((t=e.textContent)==null?void 0:t.trim())||`Header`,placeholder:`{{item.${((n=e.textContent)==null?void 0:n.trim().toLowerCase().replace(/\s+/g,`_`))||`field`}}}`,enabled:!0}});n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:`table`,content:``,style:o,tableInfo:{tableName:`imported_table`,columns:t,loop:!0,isNestable:!1,parentPath:`items`,maxNestingDepth:5,nestingPrefix:` `,showNestingLevel:!1}})}else if(i===`img`)n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:`image`,content:``,style:o,imageInfo:{imageType:`logo`,url:r.getAttribute(`src`)||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`}});else if(i===`svg`)n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:`image`,content:``,style:o,imageInfo:{imageType:`barcode`,barcodeValue:`SHIP-99201`,barcodePlaceholder:`{{barcode}}`}});else{let e=`p`;[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(i)?e=i:i===`span`&&(e=`caption`),n.push({id:`block-${Math.random().toString(36).substr(2,9)}`,type:e,content:r.innerHTML||r.textContent||``,style:o})}})}return n},xb=function(){var e=v(function*(e,t){let n=yield t.getDocument({data:new Uint8Array(e)}).promise,r=[],i=Math.min(n.numPages,3);for(let e=1;e<=i;e++){let t=(yield(yield n.getPage(e)).getTextContent()).items.map(e=>({text:e.str,x:e.transform[4],y:e.transform[5],fontSize:e.transform[3]})).filter(e=>e.text.trim()!==``);if(t.length===0)continue;t.sort((e,t)=>Math.abs(e.y-t.y)<6?e.x-t.x:t.y-e.y);let i=[],a=[];if(t.forEach(e=>{if(a.length===0)a.push(e);else{let t=a[a.length-1];if(Math.abs(e.y-t.y)<6)a.push(e);else{let t=a.map(e=>e.text).join(` `),n=a.reduce((e,t)=>e+t.y,0)/a.length,r=Math.max(...a.map(e=>e.fontSize));i.push({y:n,fontSize:r,text:t}),a=[e]}}}),a.length>0){let e=a.map(e=>e.text).join(` `),t=a.reduce((e,t)=>e+t.y,0)/a.length,n=Math.max(...a.map(e=>e.fontSize));i.push({y:t,fontSize:n,text:e})}i.forEach(e=>{let t=`p`,n=e.fontSize>16;n?t=e.fontSize>26?`h1`:e.fontSize>20?`h2`:`h3`:e.fontSize<10&&(t=`caption`);let i=Math.round(e.fontSize*1.15)+`px`;r.push({id:`pdf-block-${Math.random().toString(36).substr(2,9)}`,type:t,content:e.text,style:{fontSize:i,fontWeight:n?`700`:`400`,color:`#1e293b`,backgroundColor:`transparent`,textAlign:`left`,bold:n,italic:!1,underline:!1,strikethrough:!1}})})}return r});return function(t,n){return e.apply(this,arguments)}}();function Sb({initialBlocks:e,defaultStyles:t,defaultLogo:n,defaultBanner:r,onChange:i}={}){let[a,o]=(0,l.useState)(e||[]),[s,c]=(0,l.useState)(null);(0,l.useEffect)(()=>{i&&i(a)},[a,i]);let u=()=>a.find(e=>e.id===s)||null,d=(e,t,n)=>{let r={};return e===`title`?r={fontSize:`24px`,fontWeight:`800`}:e===`subtitle`?r={fontSize:`14px`,fontWeight:`700`,color:`#64748b`}:e===`h1`?r={fontSize:`20px`,fontWeight:`800`}:e===`h2`?r={fontSize:`18px`,fontWeight:`700`}:e===`h3`?r={fontSize:`16px`,fontWeight:`600`}:e===`caption`&&(r={fontSize:`10px`,color:`#94a3b8`}),{id:Math.random().toString(36).substring(2,11),type:e,content:t,style:T(T({fontSize:`12px`,fontWeight:`normal`,textAlign:`left`,color:`#1e293b`,backgroundColor:`transparent`,marginBottom:`0px`,padding:`0px`,bold:!1,italic:!1,underline:!1,strikethrough:!1},r),n)}},f=e=>T(T({},e),{},{columns:e.columns?e.columns.map(f):void 0});return{blocks:a,setBlocks:o,selectedBlockId:s,setSelectedBlockId:c,getSelectedBlock:u,createTextBlock:d,createTableBlock:e=>({id:Math.random().toString(36).substring(2,11),type:`table`,content:``,style:T({fontSize:`11px`,fontWeight:`normal`,textAlign:`left`,color:`#334155`,backgroundColor:`transparent`,marginBottom:`0px`,padding:`0px`,bold:!1,italic:!1,underline:!1,strikethrough:!1},(t==null?void 0:t.table)||{}),tableInfo:T(T({},e),{},{columns:e.columns.map(f),mockRows:[]})}),createImageBlock:e=>{let i=`100%`,a=`120px`;return e===`logo`?(i=`120px`,a=`60px`):e===`banner`?(i=`100%`,a=`150px`):e===`barcode`?(i=`200px`,a=`80px`):e===`watermark`&&(i=`300px`,a=`300px`),{id:Math.random().toString(36).substring(2,11),type:`image`,content:``,style:T(T({fontSize:`12px`,fontWeight:`normal`,color:`#000055`,backgroundColor:`transparent`,textAlign:`center`,marginBottom:`0px`,padding:`0px`,width:`100%`,imageWidth:i,height:a,minHeight:a,bold:!1,italic:!1,underline:!1,strikethrough:!1},(t==null?void 0:t.image)||{}),e===`watermark`?{opacity:`0.2`,position:`absolute`,top:`0`,left:`0`,zIndex:10,height:`100%`}:{}),imageInfo:{imageType:e,url:e===`logo`?n||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`:e===`banner`?r||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`:pb,barcodeValue:e===`barcode`?`SHIP-99201`:void 0,barcodePlaceholder:e===`barcode`?`{{barcode}}`:void 0}}},handleDeleteBlock:e=>{o(t=>t.filter(t=>t.id!==e)),s===e&&c(null)},handleDuplicateBlock:e=>{let t=a.find(t=>t.id===e);if(!t)return;let n=T(T({},t),{},{id:Math.random().toString(36).substring(2,11),style:T({},t.style),tableInfo:t.tableInfo?T(T({},t.tableInfo),{},{columns:t.tableInfo.columns.map(f),mockRows:t.tableInfo.mockRows?[...t.tableInfo.mockRows]:void 0}):void 0,imageInfo:t.imageInfo?T({},t.imageInfo):void 0}),r=a.findIndex(t=>t.id===e);o(e=>{let t=[...e];return t.splice(r+1,0,n),t}),c(n.id)},handleMoveBlockUp:e=>{e!==0&&o(t=>{let n=[...t],r=n[e];return n[e]=n[e-1],n[e-1]=r,n})},handleMoveBlockDown:e=>{e!==a.length-1&&o(t=>{let n=[...t],r=n[e];return n[e]=n[e+1],n[e+1]=r,n})},updateSelectedStyle:(e,t)=>{s&&o(n=>n.map(n=>n.id===s?T(T({},n),{},{style:T(T({},n.style),{},{[e]:t})}):n))},updateSelectedImageInfo:(e,t)=>{s&&o(i=>i.map(i=>{if(i.id===s&&i.type===`image`){let a={};return e===`imageType`&&(a=t===`logo`?{url:n||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`}:t===`banner`?{url:r||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`}:t===`barcode`?{barcodeValue:`SHIP-99201`,barcodePlaceholder:`{{barcode}}`}:{url:pb}),T(T({},i),{},{imageInfo:T(T({},i.imageInfo),{},{[e]:t},a)})}return i}))},handleRemoveTableColumn:(e,t)=>{s&&o(n=>n.map(n=>{if(n.id===s&&n.type===`table`&&n.tableInfo){var r;let i=[...n.tableInfo.columns];if(t!==void 0&&(r=i[e])!=null&&r.columns){let n=i[e].columns.filter((e,n)=>n!==t);i[e]=T(T({},i[e]),{},{columns:n})}else i.splice(e,1);return T(T({},n),{},{tableInfo:T(T({},n.tableInfo),{},{columns:i})})}return n}))},handleAddTableColumn:(e,t,n,r)=>{!s||!e.trim()||o(i=>i.map(i=>{if(i.id===s&&i.type===`table`&&i.tableInfo){let a=[...i.tableInfo.columns];if(r!==void 0&&a[r]){let n=a[r].columns||[];a[r]=T(T({},a[r]),{},{loop:!0,columns:[...n,{columnName:e.trim(),placeholder:t.trim(),enabled:!0}]})}else n?a.push({columnName:e.trim(),placeholder:t.trim(),enabled:!0,loop:!0,columns:[]}):a.push({columnName:e.trim(),placeholder:t.trim(),enabled:!0});return T(T({},i),{},{tableInfo:T(T({},i.tableInfo),{},{columns:a})})}return i}))},handleUpdateTableColumn:(e,t,n,r)=>{s&&o(i=>i.map(i=>{if(i.id===s&&i.type===`table`&&i.tableInfo){var a;let o=[...i.tableInfo.columns];if(r!==void 0&&(a=o[e])!=null&&a.columns){let i=[...o[e].columns];i[r]=T(T({},i[r]),{},{columnName:t.trim(),placeholder:n.trim()}),o[e]=T(T({},o[e]),{},{columns:i})}else o[e]&&(o[e]=T(T({},o[e]),{},{columnName:t.trim(),placeholder:n.trim()}));return T(T({},i),{},{tableInfo:T(T({},i.tableInfo),{},{columns:o})})}return i}))},handleReorderTableColumn:(e,t,n)=>{s&&o(r=>r.map(r=>{if(r.id===s&&r.type===`table`&&r.tableInfo){var i;let a=[...r.tableInfo.columns];if(n!==void 0&&(i=a[e])!=null&&i.columns){let r=[...a[e].columns],i=t===`up`?n-1:n+1;if(i>=0&&i<r.length){let t=r[n];r[n]=r[i],r[i]=t,a[e]=T(T({},a[e]),{},{columns:r})}}else{let n=t===`up`?e-1:e+1;if(n>=0&&n<a.length){let t=a[e];a[e]=a[n],a[n]=t}}return T(T({},r),{},{tableInfo:T(T({},r.tableInfo),{},{columns:a})})}return r}))},handleAddTableRow:e=>{let t=e||s;t&&o(e=>e.map(e=>{if(e.id===t&&e.type===`table`&&e.tableInfo){let t=e.tableInfo.columns||[],n=e.tableInfo.mockRows&&e.tableInfo.mockRows.length>0?e.tableInfo.mockRows:[{}],r={};return t.forEach(e=>{e.columnName&&(r[e.columnName]=e.placeholder||``)}),T(T({},e),{},{tableInfo:T(T({},e.tableInfo),{},{mockRows:[...n,r]})})}return e}))},handleRemoveTableRow:(e,t)=>{let n=t||s;n&&o(t=>t.map(t=>{if(t.id===n&&t.type===`table`&&t.tableInfo){let n=t.tableInfo.mockRows&&t.tableInfo.mockRows.length>0?t.tableInfo.mockRows:[{}];if(n.length<=1)return T(T({},t),{},{tableInfo:T(T({},t.tableInfo),{},{mockRows:[{}]})});let r=n.filter((t,n)=>n!==e);return T(T({},t),{},{tableInfo:T(T({},t.tableInfo),{},{mockRows:r})})}return t}))}}}function Cb(){let[e,t]=(0,l.useState)(.7),[n,r]=(0,l.useState)({x:0,y:0}),[i,a]=(0,l.useState)(!1),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(1123),d=(0,l.useRef)({x:0,y:0}),f=(0,l.useRef)(null),p=(0,l.useRef)(null);return(0,l.useEffect)(()=>{let e=e=>{let t=document.activeElement,n=t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.getAttribute(`contenteditable`)===`true`);e.code===`Space`&&!n&&(s(!0),e.preventDefault())},t=e=>{e.code===`Space`&&s(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]),(0,l.useEffect)(()=>{if(!p.current)return;let e=new ResizeObserver(e=>{for(let t of e)u(t.target.scrollHeight)});return e.observe(p.current),()=>e.disconnect()},[]),{zoom:e,setZoom:t,panOffset:n,setPanOffset:r,isPanning:i,setIsPanning:a,spacePressed:o,setSpacePressed:s,canvasHeight:c,setCanvasHeight:u,viewportRef:f,canvasContainerRef:p,handleMouseDown:e=>{o&&(a(!0),d.current={x:e.clientX-n.x,y:e.clientY-n.y})},handleMouseMove:e=>{i&&o&&r({x:e.clientX-d.current.x,y:e.clientY-d.current.y})},handleMouseUp:()=>{a(!1)},handleZoomIn:()=>t(e=>Math.min(e+.1,2)),handleZoomOut:()=>t(e=>Math.max(e-.1,.5)),handleZoomReset:()=>{t(1),r({x:0,y:0})}}}function wb({tableSchemas:e}={}){let[t,n]=(0,l.useState)(`invoice_items`),[r,i]=(0,l.useState)(`{% for item in invoice.items %}`),[a,o]=(0,l.useState)(`{% endfor %}`),[s,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)([]),[g,_]=(0,l.useState)(!1),[v,y]=(0,l.useState)(``),[b,x]=(0,l.useState)(null),[S,C]=(0,l.useState)(``),[w,E]=(0,l.useState)(null),[D,O]=(0,l.useState)(null),[k,A]=(0,l.useState)(``),[ee,j]=(0,l.useState)([]),te=e=>({columnName:e.columnName||e.columnNameEn||e.columnNameDe||``,placeholder:e.placeholder||``,enabled:e.enabled!==!1,loop:!!e.loop,columns:Array.isArray(e.columns)?e.columns.map(te):void 0});(0,l.useEffect)(()=>{e&&e.length>0?h(e.map(e=>T(T({},e),{},{columns:e.columns.map(te)}))):h([])},[e]);let ne=()=>{if(!t.trim())return;let e={tableName:t.trim().replace(/\s+/g,`_`).toLowerCase(),columns:[{columnName:`Description`,placeholder:`{{description}}`,enabled:!0},{columnName:`Qty`,placeholder:`{{quantity}}`,enabled:!0},{columnName:`Total Price`,placeholder:`{{total_price}}`,enabled:!0}],loop:!0,isNestable:!1,parentPath:`items`,maxNestingDepth:5,nestingPrefix:` `,showNestingLevel:!1,loopStartTag:r,loopEndTag:a};h(t=>[...t,e]),n(``)},M=()=>{if(!k.trim())return;let e=k.trim().toLowerCase().replace(/\s+/g,`_`);if(ee.some(t=>t.imageType===e)){A(``);return}j(t=>[...t,{label:k.trim(),imageType:e,description:`Placeholder container for ${k.trim()}`}]),A(``)},re=(e,t,n)=>{h(r=>r.map((r,i)=>{if(i===e){var a;let e=[...r.columns];if(n!==void 0&&(a=e[t])!=null&&a.columns){let r=[...e[t].columns];r[n]=T(T({},r[n]),{},{enabled:r[n].enabled===!1}),e[t]=T(T({},e[t]),{},{columns:r})}else e[t]=T(T({},e[t]),{},{enabled:e[t].enabled===!1});return T(T({},r),{},{columns:e})}return r}))},[ie,ae]=(0,l.useState)(null);return{customTableName:t,setCustomTableName:n,customLoopStart:r,setCustomLoopStart:i,customLoopEnd:a,setCustomLoopEnd:o,newColName:s,setNewColName:c,newColPlaceholder:u,setNewColPlaceholder:d,bubbleCoords:f,setBubbleCoords:p,schemas:m,setSchemas:h,isParsing:g,setIsParsing:_,parseStatusText:v,setParseStatusText:y,parseError:b,setParseError:x,draggedSidebarItem:w,setDraggedSidebarItem:E,dragOverIndex:D,setDragOverIndex:O,newImgTypeName:k,setNewImgTypeName:A,customImageTypes:ee,setCustomImageTypes:j,searchPlaceholder:S,setSearchPlaceholder:C,handleAddCustomTable:ne,handleAddCustomImageType:M,toggleSchemaColumn:re,applySelectionFormat:(e,t=``)=>{if(ie){let e=window.getSelection();e==null||e.removeAllRanges(),e==null||e.addRange(ie)}document.execCommand(e,!1,t),p(null)},setSavedRange:ae}}var Tb=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Eb=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Db=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Ob=e=>{let t=Db(e);return t.charAt(0).toUpperCase()+t.slice(1)},kb={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ab=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},jb=(0,l.createContext)({}),Mb=()=>(0,l.useContext)(jb);function Nb(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Pb(e,t){if(e==null)return{};var n,r,i=Nb(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Fb=[`color`,`size`,`strokeWidth`,`absoluteStrokeWidth`,`className`,`children`,`iconNode`],Ib=(0,l.forwardRef)((e,t)=>{var n,r,i;let{color:a,size:o,strokeWidth:s,absoluteStrokeWidth:c,className:u=``,children:d,iconNode:f}=e,p=Pb(e,Fb),{size:m=24,strokeWidth:h=2,absoluteStrokeWidth:g=!1,color:_=`currentColor`,className:v=``}=(n=Mb())==null?{}:n,y=(c==null?g:c)?Number(s==null?h:s)*24/Number(o==null?m:o):s==null?h:s;return(0,l.createElement)(`svg`,T(T(T({ref:t},kb),{},{width:(r=o==null?m:o)==null?kb.width:r,height:(i=o==null?m:o)==null?kb.height:i,stroke:a==null?_:a,strokeWidth:y,className:Tb(`lucide`,v,u)},!d&&!Ab(p)&&{"aria-hidden":`true`}),p),[...f.map(([e,t])=>(0,l.createElement)(e,t)),...Array.isArray(d)?d:[d]])}),Lb=[`className`],Rb=(e,t)=>{let n=(0,l.forwardRef)((n,r)=>{let{className:i}=n,a=Pb(n,Lb);return(0,l.createElement)(Ib,T({ref:r,iconNode:t,className:Tb(`lucide-${Eb(Ob(e))}`,`lucide-${e}`,i)},a))});return n.displayName=Ob(e),n},zb=Rb(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Bb=Rb(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Vb=Rb(`barcode`,[[`path`,{d:`M3 5v14`,key:`1nt18q`}],[`path`,{d:`M8 5v14`,key:`1ybrkv`}],[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`M17 5v14`,key:`ycjyhj`}],[`path`,{d:`M21 5v14`,key:`nzette`}]]),Hb=Rb(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ub=Rb(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Wb=Rb(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Gb=Rb(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Kb=Rb(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),qb=Rb(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Jb=Rb(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Yb=Rb(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Xb=Rb(`printer`,[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]),Zb=Rb(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Qb=Rb(`sliders-vertical`,[[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M12 21v-9`,key:`17s77i`}],[`path`,{d:`M12 8V3`,key:`13r4qs`}],[`path`,{d:`M17 16h4`,key:`h1uq16`}],[`path`,{d:`M19 12V3`,key:`o1uvq1`}],[`path`,{d:`M19 21v-5`,key:`qua636`}],[`path`,{d:`M3 14h4`,key:`bcjad9`}],[`path`,{d:`M5 10V3`,key:`cb8scm`}],[`path`,{d:`M5 21v-7`,key:`1w1uti`}]]),$b=Rb(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),ex=Rb(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),tx=Rb(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),nx=Rb(`table`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),rx=Rb(`text-align-center`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M17 12H7`,key:`16if0g`}],[`path`,{d:`M19 19H5`,key:`vjpgq2`}]]),ix=Rb(`text-align-end`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M21 19H7`,key:`4cu937`}]]),ax=Rb(`text-align-justify`,[[`path`,{d:`M3 5h18`,key:`1u36vt`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 19h18`,key:`awlh7x`}]]),ox=Rb(`text-align-start`,[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]]),sx=Rb(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),cx=Rb(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),lx=Rb(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),ux=Rb(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function dx({headerLogo:e,headerTitle:t,headerSubtitle:n,parseError:r,isParsing:i,parseStatusText:a}){return(0,d.jsxs)(`header`,{className:`bg-white border-b border-gray-200 px-6 py-3.5 flex items-center justify-between sticky top-0 z-10 shadow-xs gap-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[e||(0,d.jsx)(`div`,{className:`h-9 w-9 bg-orange-600 rounded-xl flex items-center justify-center text-white shadow-md shadow-orange-600/20`,children:(0,d.jsx)($b,{className:`h-5 w-5`})}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h1`,{className:`text-lg font-bold tracking-tight text-slate-800`,children:t}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:n})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[r&&(0,d.jsxs)(`span`,{className:`text-[10px] text-red-500 font-bold bg-red-50 px-2 py-0.5 rounded inline-block border border-red-100`,children:[`Error: `,r]}),i&&(0,d.jsx)(`span`,{className:`text-[10px] text-orange-600 font-bold bg-orange-50 px-2 py-0.5 rounded inline-block border border-orange-100 animate-pulse`,children:a||`Parsing...`})]})]})}function fx({handleSidebarDragStart:e,createTextBlock:t,setBlocks:n,setSelectedBlockId:r,setActiveTab:i,defaultStyles:a}){return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Typography Elements`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Select standard headings or paragraphs to structure your page layout.`})]}),(0,d.jsx)(`div`,{className:`grid grid-cols-1 gap-3 select-none`,children:[{label:`Document Title`,type:`title`,style:`text-2xl font-extrabold text-slate-900 tracking-tight`},{label:`Document Subtitle`,type:`subtitle`,style:`text-sm font-bold text-slate-500`},{label:`Heading 1`,type:`h1`,style:`text-xl font-extrabold text-slate-850`},{label:`Heading 2`,type:`h2`,style:`text-lg font-bold text-slate-800`},{label:`Heading 3`,type:`h3`,style:`text-md font-semibold text-slate-750`},{label:`Normal Paragraph`,type:`p`,style:`text-xs text-slate-600 leading-relaxed`},{label:`Caption Note`,type:`caption`,style:`text-[10px] text-slate-400 font-mono italic`}].map(o=>(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>e(t,o.type),className:`border border-gray-200 rounded-xl p-3 bg-white hover:border-slate-350 transition-all flex flex-col space-y-2 cursor-grab shadow-xs group`,children:[(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-slate-400 uppercase tracking-wide`,children:o.type}),(0,d.jsx)(`div`,{className:`${o.style} truncate pr-4`,children:o.label}),(0,d.jsx)(`button`,{onClick:()=>{let e=t(o.type,o.label,a==null?void 0:a[o.type]);n(t=>[...t,e]),r(e.id),i(`styles`)},className:`w-full py-1 bg-slate-50 hover:bg-slate-200 text-slate-600 rounded-lg text-[9px] font-semibold transition-all text-center border border-gray-150`,children:`Insert at End`})]},o.type))})]})}function px({schemas:e,toggleSchemaColumn:t,customTableName:n,setCustomTableName:r,customLoopStart:i,setCustomLoopStart:a,customLoopEnd:o,setCustomLoopEnd:s,handleAddCustomTable:c,handleSidebarDragStart:l,setBlocks:u,setSelectedBlockId:f,setActiveTab:p,defaultStyles:m,isTablesLoading:h,tablesLoading:g}){return h||g?(0,d.jsxs)(`div`,{className:`space-y-6`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Dynamic Tables`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Configure loop table templates and drag onto the canvas.`})]}),(0,d.jsx)(`div`,{className:`space-y-4 animate-pulse`,children:[1,2].map(e=>(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-2xl p-4 bg-white space-y-3 shadow-xs`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`div`,{className:`h-4 bg-slate-200 rounded w-1/3`}),(0,d.jsx)(`div`,{className:`h-3 bg-slate-100 rounded w-16`})]}),(0,d.jsx)(`div`,{className:`h-9 bg-slate-100 rounded-lg w-full`}),(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`div`,{className:`h-3 bg-slate-100 rounded w-1/4`}),(0,d.jsxs)(`div`,{className:`h-20 bg-slate-50 border border-gray-100 rounded-lg w-full p-2 space-y-2`,children:[(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-200/70 rounded w-3/4`}),(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-200/70 rounded w-2/3`})]})]})]},e))})]}):(0,d.jsxs)(`div`,{className:`space-y-6`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Dynamic Tables`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Configure loop table templates and drag onto the canvas.`})]}),(0,d.jsx)(`div`,{className:`space-y-4`,children:e.map((e,n)=>(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-2xl p-4 bg-white space-y-3 shadow-xs`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(nx,{className:`h-4 w-4 text-slate-650`}),(0,d.jsx)(`h4`,{className:`font-bold text-xs uppercase text-slate-700 tracking-wider`,children:e.tableName})]}),(0,d.jsx)(`span`,{className:`px-1.5 py-0.5 bg-slate-100 text-[8px] font-bold text-slate-600 rounded`,children:`loop = true`})]}),(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>l(t,`table`,e),className:`bg-slate-50 border border-slate-200 hover:border-slate-400 rounded-lg p-2.5 flex items-center justify-between cursor-grab`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`div`,{className:`h-5 w-5 bg-slate-200 rounded flex items-center justify-center`,children:(0,d.jsx)(Yb,{className:`h-3 w-3 text-slate-600`})}),(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700`,children:`Drag to Canvas`})]}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400 italic`,children:`Drag & Drop`})]}),(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400 font-bold uppercase tracking-wider block`,children:`Columns:`}),(0,d.jsx)(`div`,{className:`max-h-[180px] overflow-y-auto border border-gray-150 rounded-lg p-2 space-y-1.5 bg-slate-50/50`,children:e.columns.map((e,r)=>{let i=e.loop&&e.columns&&e.columns.length>0;return(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsxs)(`button`,{onClick:()=>t(n,r),className:`flex items-center space-x-2 w-full text-left py-0.5 text-xs text-slate-600 hover:text-slate-800 transition-colors font-medium`,children:[e.enabled===!1?(0,d.jsx)(tx,{className:`h-3.5 w-3.5 text-slate-300 flex-shrink-0`}):(0,d.jsx)(ex,{className:`h-3.5 w-3.5 text-slate-700 flex-shrink-0`}),(0,d.jsxs)(`span`,{className:`truncate flex items-center gap-1`,children:[(0,d.jsx)(`span`,{children:e.columnName}),i&&(0,d.jsx)(`span`,{className:`px-1 bg-slate-200 text-slate-600 rounded text-[8px] font-mono`,children:`(sub-table)`})]})]}),i&&e.enabled!==!1&&(0,d.jsxs)(`div`,{className:`ml-4 pl-2.5 border-l-2 border-slate-200 space-y-1 my-1`,children:[(0,d.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold uppercase tracking-wider block`,children:`Sub Columns:`}),e.columns.map((e,i)=>(0,d.jsxs)(`button`,{onClick:()=>t(n,r,i),className:`flex items-center space-x-2 w-full text-left py-0.5 text-[11px] text-slate-500 hover:text-slate-800 transition-colors`,children:[e.enabled===!1?(0,d.jsx)(tx,{className:`h-3 w-3 text-slate-300 flex-shrink-0`}):(0,d.jsx)(ex,{className:`h-3 w-3 text-slate-600 flex-shrink-0`}),(0,d.jsxs)(`span`,{className:`truncate`,children:[e.columnName,` `,(0,d.jsxs)(`span`,{className:`text-[8px] text-slate-400`,children:[`(`,e.placeholder,`)`]})]})]},i))]})]},r)})})]}),(0,d.jsx)(`button`,{onClick:()=>{let t={id:Math.random().toString(36).substring(2,11),type:`table`,content:``,style:T({fontSize:`10px`,fontWeight:`400`,color:`#334155`,backgroundColor:`transparent`,textAlign:`left`,bold:!1,italic:!1,underline:!1,strikethrough:!1,width:`100%`,marginBottom:`12px`,padding:`8px`},m==null?void 0:m.table),tableInfo:T(T({},e),{},{columns:e.columns.map(e=>T({},e))})};u(e=>[...e,t]),f(t.id),p(`styles`)},className:`w-full py-1 bg-slate-50 hover:bg-slate-200 text-slate-600 rounded-lg text-[9px] font-semibold transition-all text-center border border-gray-150`,children:`Insert at End`})]},e.tableName))}),(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-2xl p-4 bg-slate-50/20 border-dashed space-y-4 mt-6`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 pb-2 border-b border-gray-150`,children:[(0,d.jsx)($b,{className:`h-4 w-4 text-slate-655`}),(0,d.jsx)(`h4`,{className:`font-bold text-xs uppercase text-slate-800 tracking-wider`,children:`Custom Table Builder`})]}),(0,d.jsxs)(`div`,{className:`space-y-3`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block mb-1`,children:`Table Name`}),(0,d.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`invoice_items`,className:`w-full px-3 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block mb-1`,children:`Loop Start tag`}),(0,d.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`{% for item in invoice.items %}`,className:`w-full px-3 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500 bg-white text-slate-600 font-bold`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block mb-1`,children:`Loop End tag`}),(0,d.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`{% endfor %}`,className:`w-full px-3 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500 bg-white text-slate-600 font-bold`})]}),(0,d.jsxs)(`button`,{onClick:c,className:`w-full py-2 bg-orange-600 hover:bg-orange-700 text-white rounded-xl text-xs font-bold transition-all shadow-sm flex items-center justify-center space-x-1.5 shadow-orange-600/10`,children:[(0,d.jsx)(Yb,{className:`h-4 w-4`}),(0,d.jsx)(`span`,{children:`Add Custom Loop Table`})]})]})]})]})}function mx({customImageTypes:e,newImgTypeName:t,setNewImgTypeName:n,handleAddCustomImageType:r,handleSidebarDragStart:i,createImageBlock:a,setBlocks:o,setSelectedBlockId:s,setActiveTab:c}){let l=[{label:`Brand Logo`,imageType:`logo`,description:`Standard document vector logo`,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})},{label:`Campaign Banner`,imageType:`banner`,description:`Wide horizontal graphics banner`,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})},{label:`Dynamic Barcode`,imageType:`barcode`,description:`Barcode replaced dynamically`,icon:(0,d.jsx)(Vb,{className:`h-4 w-4 text-slate-550`})},{label:`Watermark`,imageType:`watermark`,description:`Background graphic with low opacity`,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})},...e.map(e=>({label:e.label,imageType:e.imageType,description:e.description,icon:(0,d.jsx)(qb,{className:`h-4 w-4 text-slate-550`})}))];return(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Image & Barcode Elements`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Drag elements onto the canvas, or insert below.`})]}),(0,d.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>(0,d.jsxs)(`div`,{className:`border border-gray-200 rounded-xl p-3 bg-white space-y-3 shadow-xs`,children:[(0,d.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[e.icon,(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h4`,{className:`font-bold text-xs text-slate-700`,children:e.label}),(0,d.jsx)(`p`,{className:`text-[9px] text-slate-400`,children:e.description})]})]})}),(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>i(t,`image`,void 0,e.imageType),className:`bg-slate-50 border border-slate-200 hover:border-slate-450 rounded-lg p-2 flex items-center justify-between cursor-grab transition-all`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`div`,{className:`h-5 w-5 bg-slate-200 rounded flex items-center justify-center`,children:(0,d.jsx)(Yb,{className:`h-3 w-3 text-slate-750`})}),(0,d.jsx)(`span`,{className:`text-[11px] font-bold text-slate-700`,children:`Drag to Canvas`})]}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400 italic`,children:`Drag`})]}),(0,d.jsx)(`button`,{onClick:()=>{let t=a(e.imageType);o(e=>[...e,t]),s(t.id),c(`styles`)},className:`w-full py-1 bg-slate-100 hover:bg-slate-200 text-slate-600 rounded-lg text-[10px] font-semibold transition-all text-center border border-gray-150`,children:`Insert at End`})]},e.imageType))}),(0,d.jsxs)(`div`,{className:`border border-dashed border-gray-200 rounded-xl p-3 space-y-2 bg-slate-50/50 mt-4`,children:[(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Add Custom Image Type`}),(0,d.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`e.g. Signature`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs focus:outline-none focus:border-slate-500 bg-white`}),(0,d.jsxs)(`button`,{onClick:r,className:`w-full py-1.5 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-bold transition-all flex items-center justify-center space-x-1`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Add Custom Category`})]})]})]})}function hx({placeholders:e,schemas:t,searchPlaceholder:n,setSearchPlaceholder:r,selectedBlockId:i,setBlocks:a,isPlaceholdersLoading:o,placeholdersLoading:s}){if(o||s)return(0,d.jsxs)(`div`,{className:`space-y-4 flex-1 flex flex-col min-h-0`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Variables Palette`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Click to copy, or drag variables into text areas or table cells.`})]}),(0,d.jsx)(`div`,{className:`h-9 bg-slate-100 rounded-xl w-full animate-pulse`}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-2 pr-1 animate-pulse`,children:[1,2,3,4].map(e=>(0,d.jsxs)(`div`,{className:`w-full border border-gray-200 p-2.5 rounded-xl bg-white shadow-xs space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-200 rounded w-1/2`}),(0,d.jsx)(`div`,{className:`h-3.5 bg-slate-100 rounded w-1/4`})]}),(0,d.jsx)(`div`,{className:`h-6 bg-slate-50 rounded border border-gray-100 w-full`})]},e))})]});let c=()=>{let t=[];return(e||[]).forEach(e=>{t.push({label:e.label,placeholder:e.placeholder,category:e.category||`General`})}),t.filter(e=>e.label.toLowerCase().includes(n.toLowerCase())||e.placeholder.toLowerCase().includes(n.toLowerCase()))},l=e=>{if(i){let t=`{{${e.replace(/[{}]/g,``)}}}`;a(e=>e.map(e=>e.id===i&&e.type!==`table`?T(T({},e),{},{content:e.content+t}):e))}},u=c();return(0,d.jsxs)(`div`,{className:`space-y-4 flex-1 flex flex-col min-h-0`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Variables Palette`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Click to copy, or drag variables into text areas or table cells.`})]}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(Zb,{className:`absolute left-3 top-2.5 h-4 w-4 text-slate-400`}),(0,d.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Search variables...`,className:`w-full pl-9 pr-4 py-2 border border-gray-200 rounded-xl text-xs focus:outline-none focus:border-slate-500 transition-colors`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-2 pr-1`,children:u.length===0?(0,d.jsx)(`div`,{className:`text-xs text-slate-400 italic text-center py-4`,children:`No variables available.`}):u.map((e,t)=>{let n=e.placeholder.replace(/[{}]/g,``);return(0,d.jsx)(`div`,{className:`w-full border border-gray-200 p-2.5 rounded-xl bg-white shadow-xs cursor-grab active:cursor-grabbing hover:bg-slate-50 transition-colors`,draggable:!0,onDragStart:e=>{e.dataTransfer.setData(`placeholder`,n),e.dataTransfer.effectAllowed=`copy`},onClick:()=>l(e.placeholder),title:`Drag into text or cells, or click to insert`,children:(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold text-slate-700 truncate mr-2`,children:e.label}),(0,d.jsx)(`code`,{className:`text-[9px] bg-slate-100 px-1.5 py-0.5 rounded text-slate-800 font-bold shrink-0 border border-slate-200/50`,children:e.placeholder})]})},t)})})]})}var gx=e=>{if(!e)return 100;if(e.endsWith(`%`)){let t=parseInt(e,10);return isNaN(t)?100:Math.min(100,Math.max(10,t))}return 100};function _x({selectedBlockId:e,getSelectedBlock:t,updateSelectedStyle:n,updateSelectedImageInfo:r,fontSizesState:i,fontFamiliesState:a,fontWeightsState:o,handleDeleteBlock:s,newColName:c,setNewColName:u,newColPlaceholder:f,setNewColPlaceholder:p,handleAddTableColumn:m,handleRemoveTableColumn:h,handleUpdateTableColumn:g,handleReorderTableColumn:_,handleAddTableRow:v,handleRemoveTableRow:y,setBlocks:b}){var x;let[S,C]=(0,l.useState)(null),[w,E]=(0,l.useState)(``),[D,O]=(0,l.useState)(``),[k,A]=(0,l.useState)(null),[ee,j]=(0,l.useState)(``),[te,ne]=(0,l.useState)(``),M=t();if(!e||!M)return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Formatting Panel`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Customize the styles of the selected block.`})]}),(0,d.jsxs)(`div`,{className:`border border-dashed border-gray-200 rounded-xl p-6 text-center bg-slate-50/50`,children:[(0,d.jsx)(Qb,{className:`h-8 w-8 text-slate-350 mx-auto mb-2`}),(0,d.jsx)(`span`,{className:`text-xs font-semibold text-slate-500 block`,children:`No block selected`}),(0,d.jsx)(`p`,{className:`text-[10px] text-slate-400 mt-1`,children:`Select any element inside the canvas to configure typography, sizing, colors, or templating loop engines.`})]})]});let re=M.type===`table`,ie=()=>{c.trim()&&(m(c,f),u(``),p(``))};if(M.type===`image`){let e=M.imageInfo||{imageType:`logo`};return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Formatting Panel`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Customize the styles of the selected block.`})]}),(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 pb-3 border-b border-gray-100`,children:[(0,d.jsx)(`div`,{className:`h-6 w-6 bg-slate-100 rounded flex items-center justify-center text-slate-700`,children:(0,d.jsx)(qb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 capitalize`,children:`Editing Image Element`})]}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-slate-50 border border-gray-200 rounded-xl select-none`,children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 block`,children:`Row Alignment`}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400`,children:`Display side-by-side`})]}),(0,d.jsx)(`button`,{onClick:()=>{let e=!M.style.sameRow;n(`sameRow`,e),e?(n(`width`,`48%`),b(e=>{let t=e.findIndex(e=>e.id===M.id);return t>0?e.map((e,n)=>n===t-1&&(!e.style.width||e.style.width===`100%`)?T(T({},e),{},{style:T(T({},e.style),{},{width:`48%`})}):e):e})):n(`width`,`100%`)},className:`w-10 h-6 flex items-center rounded-full p-1 transition-colors duration-150 ${M.style.sameRow?`bg-orange-600 justify-end`:`bg-slate-300 justify-start`}`,children:(0,d.jsx)(`span`,{className:`bg-white w-4 h-4 rounded-full shadow-md`})})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Image Category`}),(0,d.jsx)(`div`,{className:`grid grid-cols-4 gap-1 bg-slate-50 p-1 border border-gray-200 rounded-lg`,children:[`logo`,`banner`,`barcode`,`watermark`].map(t=>(0,d.jsx)(`button`,{onClick:()=>r(`imageType`,t),className:`py-1 text-[9px] font-bold rounded capitalize transition-all ${e.imageType===t?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:t},t))})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Alignment (Position)`}),(0,d.jsx)(`div`,{className:`flex items-center space-x-1 border border-gray-200 rounded-lg p-1 bg-slate-50 w-fit`,children:[{value:`left`,icon:(0,d.jsx)(ox,{className:`h-3.5 w-3.5`})},{value:`center`,icon:(0,d.jsx)(rx,{className:`h-3.5 w-3.5`})},{value:`right`,icon:(0,d.jsx)(ix,{className:`h-3.5 w-3.5`})}].map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`textAlign`,e.value),type:`button`,className:`p-1.5 rounded transition-all ${M.style.textAlign===e.value?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:e.icon},e.value))})]}),(0,d.jsxs)(`div`,{className:`space-y-1 pt-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Block Width (%)`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:[gx(M.style.width),`%`]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`input`,{type:`range`,min:`10`,max:`100`,step:`5`,value:gx(M.style.width),onChange:e=>n(`width`,`${Math.min(100,Math.max(10,parseInt(e.target.value,10)))}%`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 w-10 text-right`,children:[gx(M.style.width),`%`]})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1 pt-1 mt-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Image Element Width (px)`}),(0,d.jsx)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:M.style.imageWidth||(M.style.width&&M.style.width.endsWith(`px`)?M.style.width:`100%`)})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`input`,{type:`range`,min:`10`,max:`1000`,step:`5`,value:parseInt(M.style.imageWidth||(M.style.width&&M.style.width.endsWith(`px`)?M.style.width:`100`))||100,onChange:e=>n(`imageWidth`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 w-10 text-right`,children:[parseInt(M.style.imageWidth||(M.style.width&&M.style.width.endsWith(`px`)?M.style.width:`100`))||100,`px`]})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1 pt-1 mt-3`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block mb-1`,children:`Object Fit`}),(0,d.jsxs)(`select`,{value:M.style.objectFit||`contain`,onChange:e=>n(`objectFit`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:[(0,d.jsx)(`option`,{value:`contain`,children:`Contain`}),(0,d.jsx)(`option`,{value:`cover`,children:`Cover`}),(0,d.jsx)(`option`,{value:`fill`,children:`Fill`}),(0,d.jsx)(`option`,{value:`none`,children:`None`})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Image Height`}),(0,d.jsx)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:M.style.height||M.style.minHeight||`auto`})]}),(0,d.jsx)(`div`,{className:`flex items-center space-x-2`,children:(0,d.jsx)(`input`,{type:`range`,min:`20`,max:`400`,step:`10`,value:parseInt(M.style.height||M.style.minHeight||`100`)||100,onChange:e=>{n(`height`,`${e.target.value}px`),n(`minHeight`,`${e.target.value}px`)},className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`})})]}),e.imageType===`barcode`?(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-150`,children:[(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Barcode Configuration`}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500`,children:`Mock Barcode Value`}),(0,d.jsx)(`input`,{type:`text`,value:e.barcodeValue||``,onChange:e=>r(`barcodeValue`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500`})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-500`,children:`Backend Variable`}),(0,d.jsx)(`input`,{type:`text`,value:e.barcodePlaceholder||``,onChange:e=>r(`barcodePlaceholder`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs font-mono focus:outline-none focus:border-slate-500 text-slate-700 font-bold`})]})]}):(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-150`,children:[(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Image Asset Upload`}),(0,d.jsxs)(`div`,{className:`flex flex-col items-center p-3 border border-dashed border-gray-200 rounded-lg bg-slate-50/50 hover:bg-slate-50 transition-all cursor-pointer relative`,children:[(0,d.jsx)(lx,{className:`h-5 w-5 text-slate-400 mb-1`}),(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-slate-650`,children:`Choose local image file`}),(0,d.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:e=>{var t;let n=(t=e.target.files)==null?void 0:t[0];if(!n)return;let i=new FileReader;i.onload=e=>{var t;r(`url`,(t=e.target)==null?void 0:t.result)},i.readAsDataURL(n)},className:`absolute inset-0 opacity-0 cursor-pointer`})]})]}),(0,d.jsx)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Bottom Margin`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(M.style.marginBottom||`0px`),onChange:e=>n(`marginBottom`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200`})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Padding`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(M.style.padding||`0px`),onChange:e=>n(`padding`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200`})]})]})}),(0,d.jsx)(`div`,{className:`pt-4 border-t border-red-100 flex items-center justify-between`,children:(0,d.jsxs)(`button`,{onClick:()=>s(M.id),className:`w-full py-2 bg-red-50 hover:bg-red-100 border border-red-200 text-red-650 rounded-xl text-xs font-bold transition-all flex items-center justify-center space-x-1 shadow-xs cursor-pointer`,children:[(0,d.jsx)(sx,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Delete Element`})]})})]})]})}return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-slate-800`,children:`Formatting Panel`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-500`,children:`Customize the styles of the selected block.`})]}),(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 pb-3 border-b border-gray-100`,children:[(0,d.jsx)(`div`,{className:`h-6 px-3 bg-slate-100 rounded flex items-center justify-center text-slate-700 font-bold text-[10px] uppercase`,children:M.type}),(0,d.jsxs)(`span`,{className:`text-xs font-bold text-slate-700 capitalize`,children:[`Editing `,M.type===`table`?`Table Block`:`Typography Element`]})]}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-slate-50 border border-gray-200 rounded-xl select-none`,children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 block`,children:`Row Alignment`}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400`,children:`Display side-by-side`})]}),(0,d.jsx)(`button`,{onClick:()=>{let e=!M.style.sameRow;n(`sameRow`,e),e?(n(`width`,`48%`),b(e=>{let t=e.findIndex(e=>e.id===M.id);return t>0?e.map((e,n)=>n===t-1&&(!e.style.width||e.style.width===`100%`)?T(T({},e),{},{style:T(T({},e.style),{},{width:`48%`})}):e):e})):n(`width`,`100%`)},className:`w-10 h-6 flex items-center rounded-full p-1 transition-colors duration-150 ${M.style.sameRow?`bg-orange-600 justify-end`:`bg-slate-300 justify-start`}`,children:(0,d.jsx)(`span`,{className:`bg-white w-4 h-4 rounded-full shadow-md`})})]}),M.style.sameRow&&(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-slate-50 border border-gray-200 rounded-xl select-none`,children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 block`,children:`Row Direction`}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400`,children:`Layout stacked or side-by-side`})]}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-1 bg-slate-100 p-0.5 border border-gray-200 rounded-lg w-[180px]`,children:[`row`,`column`].map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>{n(`flexDirection`,e),b(t=>{let n=t.findIndex(e=>e.id===M.id);if(n===-1)return t;let r=n;for(;r>0&&t[r].style.sameRow;)r--;let i=[r],a=r+1;for(;a<t.length&&t[a].style.sameRow;)i.push(a),a++;return t.map((t,n)=>i.includes(n)?T(T({},t),{},{style:T(T({},t.style),{},{flexDirection:e})}):t)})},className:`px-2 py-1 text-[9px] font-bold rounded capitalize transition-all text-center ${M.style.flexDirection===e||e===`row`&&!M.style.flexDirection?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:e===`row`?`Side-by-side`:`Stacked`},e))})]}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Font Size`}),(0,d.jsx)(`select`,{value:M.style.fontSize,onChange:e=>n(`fontSize`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:i.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),!re&&(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Weight`}),(0,d.jsx)(`select`,{value:M.style.fontWeight,onChange:e=>n(`fontWeight`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:o.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]}),!re&&(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Font Family`}),(0,d.jsxs)(`select`,{value:M.style.fontFamily||``,onChange:e=>n(`fontFamily`,e.target.value),className:`w-full px-2 py-1.5 border border-gray-200 rounded-lg text-xs focus:outline-none focus:border-slate-500 bg-white font-medium`,children:[(0,d.jsx)(`option`,{value:``,children:`Default Font (Global)`}),a.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),!re&&(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Alignment & Formatting`}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border border-gray-200 rounded-lg p-1 bg-slate-50`,children:[(0,d.jsx)(`div`,{className:`flex items-center space-x-0.5`,children:[{value:`left`,icon:(0,d.jsx)(ox,{className:`h-3.5 w-3.5`})},{value:`center`,icon:(0,d.jsx)(rx,{className:`h-3.5 w-3.5`})},{value:`right`,icon:(0,d.jsx)(ix,{className:`h-3.5 w-3.5`})},{value:`justify`,icon:(0,d.jsx)(ax,{className:`h-3.5 w-3.5`})}].map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`textAlign`,e.value),className:`p-1.5 rounded transition-all ${M.style.textAlign===e.value?`bg-white text-slate-800 shadow-xs border border-gray-200`:`text-slate-500 hover:text-slate-800`}`,children:e.icon},e.value))}),(0,d.jsx)(`div`,{className:`h-5 w-[1px] bg-slate-200 mx-1`}),(0,d.jsx)(`div`,{className:`flex items-center space-x-0.5`,children:[{key:`bold`,label:`B`,className:`font-bold`},{key:`italic`,label:`I`,className:`italic`},{key:`underline`,label:`U`,className:`underline`},{key:`strikethrough`,label:`S`,className:`line-through`}].map(e=>{let t=M.style[e.key]===!0;return(0,d.jsx)(`button`,{onClick:()=>n(e.key,!t),className:`h-7 w-7 rounded text-xs transition-all ${t?`bg-white text-slate-800 shadow-xs border border-gray-200 font-bold`:`text-slate-500 hover:text-slate-800`}`,children:(0,d.jsx)(`span`,{className:e.className,children:e.label})},e.key)})})]})]}),(0,d.jsxs)(`div`,{className:`space-y-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Text Color`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[mb.map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`color`,e),className:`h-5 w-5 rounded-full border border-gray-200 shadow-xs transition-transform ${M.style.color===e?`scale-120 ring-2 ring-slate-800`:`hover:scale-110`}`,style:{backgroundColor:e}},e)),(0,d.jsx)(`input`,{type:`color`,value:M.style.color,onChange:e=>n(`color`,e.target.value),className:`h-5 w-5 rounded-full border border-gray-200 cursor-pointer overflow-hidden p-0`})]})]}),(0,d.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Background Color`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[hb.map(e=>(0,d.jsx)(`button`,{onClick:()=>n(`backgroundColor`,e),className:`h-5 w-5 rounded-full border border-gray-200 shadow-xs transition-transform ${M.style.backgroundColor===e?`scale-120 ring-2 ring-slate-800`:`hover:scale-110`}`,style:{backgroundColor:e===`transparent`?`#ffffff`:e},children:e===`transparent`&&(0,d.jsx)(`span`,{className:`text-[8px] text-slate-400 font-bold block leading-5 text-center`,children:`T`})},e)),(0,d.jsx)(`input`,{type:`color`,value:M.style.backgroundColor===`transparent`?`#ffffff`:M.style.backgroundColor,onChange:e=>n(`backgroundColor`,e.target.value),className:`h-5 w-5 rounded-full border border-gray-200 cursor-pointer overflow-hidden p-0`})]})]})]}),(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider`,children:`Block Width (%)`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 font-bold bg-slate-100 px-1.5 py-0.5 rounded`,children:[gx(M.style.width),`%`]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,d.jsx)(`input`,{type:`range`,min:`10`,max:`100`,step:`5`,value:gx(M.style.width),onChange:e=>n(`width`,`${Math.min(100,Math.max(10,parseInt(e.target.value,10)))}%`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsxs)(`span`,{className:`text-[10px] font-mono text-slate-500 w-10 text-right`,children:[gx(M.style.width),`%`]})]})]}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Bottom Margin`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(M.style.marginBottom||`0px`),onChange:e=>n(`marginBottom`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg`})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase block`,children:`Padding`}),(0,d.jsx)(`input`,{type:`range`,min:`0`,max:`40`,step:`2`,value:parseInt(M.style.padding||`0px`),onChange:e=>n(`padding`,`${e.target.value}px`),className:`w-full accent-slate-800 h-1 bg-gray-200 rounded-lg`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-slate-50 border border-gray-200 rounded-xl select-none mt-2`,children:[(0,d.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-slate-700 block`,children:`Page Break Before`}),(0,d.jsx)(`span`,{className:`text-[9px] text-slate-400`,children:`Force new page before this block`})]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>{n(`pageBreakBefore`,M.style.pageBreakBefore===`always`||M.style.pageBreakBefore===!0?`auto`:`always`)},className:`w-10 h-6 flex items-center rounded-full p-1 transition-colors duration-150 ${M.style.pageBreakBefore===`always`||M.style.pageBreakBefore===!0?`bg-orange-600 justify-end`:`bg-slate-300 justify-start`}`,children:(0,d.jsx)(`span`,{className:`bg-white w-4 h-4 rounded-full shadow-md`})})]})]}),re&&M.tableInfo&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Table Rows`}),(0,d.jsxs)(`span`,{className:`text-[10px] text-slate-400 font-medium`,children:[((x=M.tableInfo.mockRows)==null?void 0:x.length)||1,` row(s) configured`]})]}),(0,d.jsxs)(`button`,{type:`button`,onClick:()=>v&&v(M.id),className:`px-3 py-1.5 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-bold transition-all flex items-center space-x-1 shadow-xs`,title:`Add a new row to table`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Add Row`})]})]}),(0,d.jsx)(`div`,{className:`space-y-1.5 max-h-[140px] overflow-y-auto pr-1`,children:(M.tableInfo.mockRows&&M.tableInfo.mockRows.length>0?M.tableInfo.mockRows:[{}]).map((e,t)=>{var n;return(0,d.jsxs)(`div`,{className:`flex items-center justify-between bg-slate-50 border border-gray-200 rounded-lg p-2 text-xs`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-slate-700`,children:[`Row #`,t+1]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>y&&y(t,M.id),disabled:(((n=M.tableInfo)==null||(n=n.mockRows)==null?void 0:n.length)||1)<=1,className:`p-1 text-slate-400 hover:text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:hover:bg-transparent rounded transition-colors`,title:`Remove row`,children:(0,d.jsx)(sx,{className:`h-3.5 w-3.5`})})]},t)})})]}),(0,d.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-gray-100`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-slate-400 uppercase tracking-wider block`,children:`Table Columns`}),(0,d.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1`,children:M.tableInfo.columns.map((e,t)=>{var n,r;let i=e.loop&&e.columns&&e.columns.length>0;return(0,d.jsxs)(`div`,{className:`bg-slate-50 border border-gray-200 rounded-lg p-2 space-y-1.5 text-xs`,children:[S===String(t)?(0,d.jsxs)(`div`,{className:`space-y-1.5 p-1 bg-white border border-orange-300 rounded`,children:[(0,d.jsx)(`div`,{className:`text-[9px] font-bold text-orange-600 uppercase`,children:`Edit Column`}),(0,d.jsx)(`input`,{type:`text`,value:w,onChange:e=>E(e.target.value),placeholder:`Header Name`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-xs bg-white`}),(0,d.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Value (e.g. {{item.sku}})`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-xs font-mono bg-white`}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,d.jsxs)(`button`,{onClick:()=>{g&&g(t,w,D),C(null)},className:`p-1 px-2 bg-orange-600 text-white hover:bg-orange-700 rounded text-[10px] flex items-center gap-1 font-bold`,children:[(0,d.jsx)(Hb,{className:`h-3 w-3`}),(0,d.jsx)(`span`,{children:`Save`})]}),(0,d.jsxs)(`button`,{onClick:()=>C(null),className:`p-1 px-2 bg-gray-200 text-slate-700 hover:bg-gray-300 rounded text-[10px] flex items-center gap-1`,children:[(0,d.jsx)(ux,{className:`h-3 w-3`}),(0,d.jsx)(`span`,{children:`Cancel`})]})]})]}):(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{className:`truncate mr-2`,children:[(0,d.jsxs)(`span`,{className:`font-bold text-slate-700 block truncate flex items-center gap-1`,children:[(0,d.jsx)(`span`,{children:e.columnName}),i&&(0,d.jsx)(`span`,{className:`px-1 bg-blue-100 text-blue-700 rounded text-[8px] font-mono`,children:`loop (sub-table)`})]}),(0,d.jsx)(`code`,{className:`text-[9px] font-mono text-slate-500 truncate block`,children:e.placeholder})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`up`),disabled:t===0,className:`p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-200 disabled:opacity-30 disabled:hover:bg-transparent rounded transition-colors`,title:`Move Up`,children:(0,d.jsx)(Bb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`down`),disabled:t===(((n=M.tableInfo)==null?void 0:n.columns.length)||0)-1,className:`p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-200 disabled:opacity-30 disabled:hover:bg-transparent rounded transition-colors`,title:`Move Down`,children:(0,d.jsx)(zb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{onClick:()=>{C(String(t)),E(e.columnName),O(e.placeholder)},className:`p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-200 rounded transition-colors`,title:`Edit column`,children:(0,d.jsx)(Jb,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{onClick:()=>h(t),className:`p-1 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded transition-colors border border-transparent`,disabled:!M.tableInfo||M.tableInfo.columns.length<=1,title:`Delete column`,children:(0,d.jsx)(sx,{className:`h-3.5 w-3.5`})})]})]}),i&&(0,d.jsxs)(`div`,{className:`ml-2 pl-2 border-l-2 border-blue-200 space-y-1.5 pt-1 mt-1`,children:[(0,d.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,d.jsxs)(`span`,{className:`text-[8px] font-bold text-blue-600 uppercase tracking-wider block`,children:[`Sub-Table Columns (`,((r=e.columns)==null?void 0:r.length)||0,`):`]})}),e.columns.map((n,r)=>{let i=`${t}-${r}`;return S===i?(0,d.jsxs)(`div`,{className:`space-y-1 p-1.5 bg-white border border-blue-300 rounded`,children:[(0,d.jsx)(`div`,{className:`text-[8px] font-bold text-blue-600 uppercase`,children:`Edit Sub-Column`}),(0,d.jsx)(`input`,{type:`text`,value:w,onChange:e=>E(e.target.value),placeholder:`Header Name`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-[11px] bg-white`}),(0,d.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Value`,className:`w-full px-2 py-0.5 border border-gray-200 rounded text-[11px] font-mono bg-white`}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-1 pt-0.5`,children:[(0,d.jsxs)(`button`,{onClick:()=>{g&&g(t,w,D,r),C(null)},className:`p-0.5 px-1.5 bg-blue-600 text-white hover:bg-blue-700 rounded text-[9px] flex items-center gap-1 font-bold`,children:[(0,d.jsx)(Hb,{className:`h-2.5 w-2.5`}),(0,d.jsx)(`span`,{children:`Save`})]}),(0,d.jsxs)(`button`,{onClick:()=>C(null),className:`p-0.5 px-1.5 bg-gray-200 text-slate-700 hover:bg-gray-300 rounded text-[9px] flex items-center gap-1`,children:[(0,d.jsx)(ux,{className:`h-2.5 w-2.5`}),(0,d.jsx)(`span`,{children:`Cancel`})]})]})]},r):(0,d.jsxs)(`div`,{className:`flex items-center justify-between bg-white border border-gray-150 rounded px-2 py-1 text-[11px]`,children:[(0,d.jsxs)(`div`,{className:`truncate mr-1`,children:[(0,d.jsx)(`span`,{className:`font-semibold text-slate-700 block truncate`,children:n.columnName}),(0,d.jsx)(`code`,{className:`text-[8px] font-mono text-slate-400 truncate block`,children:n.placeholder})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`up`,r),disabled:r===0,className:`p-0.5 text-slate-400 hover:text-slate-700 hover:bg-slate-100 disabled:opacity-30 disabled:hover:bg-transparent rounded`,title:`Move Sub-Column Up`,children:(0,d.jsx)(Bb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>_&&_(t,`down`,r),disabled:r===e.columns.length-1,className:`p-0.5 text-slate-400 hover:text-slate-700 hover:bg-slate-100 disabled:opacity-30 disabled:hover:bg-transparent rounded`,title:`Move Sub-Column Down`,children:(0,d.jsx)(zb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>{C(i),E(n.columnName),O(n.placeholder)},className:`p-0.5 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded`,title:`Edit sub-column`,children:(0,d.jsx)(Jb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>h(t,r),className:`p-0.5 text-slate-400 hover:text-red-600 hover:bg-red-50 rounded`,title:`Delete sub-column`,children:(0,d.jsx)(sx,{className:`h-3 w-3`})})]})]},r)}),k===t?(0,d.jsxs)(`div`,{className:`bg-white border border-blue-200 rounded p-2 space-y-1.5 mt-1`,children:[(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-blue-600 block`,children:`Add Sub-Column`}),(0,d.jsx)(`input`,{type:`text`,value:ee,onChange:e=>j(e.target.value),placeholder:`Header Name (e.g. Price)`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs bg-white`}),(0,d.jsx)(`input`,{type:`text`,value:te,onChange:e=>ne(e.target.value),placeholder:`Value (e.g. {{item.price}})`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs font-mono bg-white`}),(0,d.jsxs)(`div`,{className:`flex gap-1 pt-1`,children:[(0,d.jsx)(`button`,{onClick:()=>{ee.trim()&&(m(ee,te||`{{item.value}}`,!1,t),j(``),ne(``),A(null))},className:`flex-1 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded text-[10px] font-bold`,children:`Add`}),(0,d.jsx)(`button`,{onClick:()=>{A(null),j(``),ne(``)},className:`py-1 px-2 bg-gray-100 hover:bg-gray-200 text-slate-600 rounded text-[10px]`,children:`Cancel`})]})]}):(0,d.jsxs)(`button`,{onClick:()=>A(t),className:`w-full py-1 text-[10px] font-bold text-blue-600 hover:bg-blue-50 border border-dashed border-blue-200 rounded flex items-center justify-center space-x-1 transition-colors mt-1`,children:[(0,d.jsx)(Yb,{className:`h-3 w-3`}),(0,d.jsx)(`span`,{children:`Add Sub-Column`})]})]})]},t)})}),(0,d.jsxs)(`div`,{className:`bg-slate-50 border border-gray-200 border-dashed rounded-xl p-3 space-y-3`,children:[(0,d.jsx)(`span`,{className:`text-[9px] font-bold text-slate-500 uppercase tracking-wider block`,children:`Add New Column`}),(0,d.jsx)(`div`,{children:(0,d.jsx)(`input`,{type:`text`,value:c,onChange:e=>u(e.target.value),placeholder:`Header Name`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs focus:outline-none focus:border-slate-500 bg-white`})}),(0,d.jsx)(`div`,{children:(0,d.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Value (e.g. {{item.sku}})`,className:`w-full px-2 py-1 border border-gray-200 rounded text-xs font-mono focus:outline-none focus:border-orange-655 bg-white`})}),(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsxs)(`button`,{onClick:ie,className:`flex-1 py-1.5 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-bold transition-all flex items-center justify-center space-x-1`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Column`})]}),(0,d.jsxs)(`button`,{onClick:()=>{c.trim()&&(m(c,f||`{{item.price}}`,!0),u(``),p(``))},className:`flex-1 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-xs font-bold transition-all flex items-center justify-center space-x-1`,title:`Add column as nested sub-table`,children:[(0,d.jsx)(Yb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Sub-Table`})]})]})]})]})]}),(0,d.jsx)(`div`,{className:`pt-4 border-t border-red-100 flex items-center justify-between`,children:(0,d.jsxs)(`button`,{onClick:()=>s(M.id),className:`w-full py-2 bg-red-50 hover:bg-red-100 border border-red-200 text-red-650 rounded-xl text-xs font-bold transition-all flex items-center justify-center space-x-1 shadow-xs cursor-pointer`,children:[(0,d.jsx)(sx,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Delete Element`})]})})]})]})}function vx({activeTab:e,setActiveTab:t,setBlocks:n,selectedBlockId:r,setSelectedBlockId:i,getSelectedBlock:a,defaultStyles:o,createTextBlock:s,createImageBlock:c,updateSelectedStyle:l,updateSelectedImageInfo:u,handleDeleteBlock:f,handleRemoveTableColumn:p,handleAddTableColumn:m,handleUpdateTableColumn:h,handleReorderTableColumn:g,handleAddTableRow:_,handleRemoveTableRow:v,schemas:y,toggleSchemaColumn:b,customTableName:x,setCustomTableName:S,customLoopStart:C,setCustomLoopStart:w,customLoopEnd:T,setCustomLoopEnd:E,handleAddCustomTable:D,newColName:O,setNewColName:k,newColPlaceholder:A,setNewColPlaceholder:ee,customImageTypes:j,newImgTypeName:te,setNewImgTypeName:ne,handleAddCustomImageType:M,placeholders:re,searchPlaceholder:ie,setSearchPlaceholder:ae,handleSidebarDragStart:oe,isTablesLoading:se,tablesLoading:ce,isPlaceholdersLoading:le,placeholdersLoading:ue,fontSizesState:de,fontFamiliesState:fe,fontWeightsState:pe,sidebarPosition:me=`left`}){return(0,d.jsxs)(`aside`,{className:`w-full lg:w-[30%] flex flex-col bg-white border-t lg:border-t-0 ${me===`left`?`lg:border-r`:`lg:border-l`} border-gray-200 overflow-y-auto shrink-0`,children:[(0,d.jsx)(`div`,{className:`grid grid-cols-5 gap-1 border-b border-gray-250 p-2 bg-slate-50`,children:[{value:`text`,icon:(0,d.jsx)(cx,{className:`h-4 w-4`})},{value:`tables`,icon:(0,d.jsx)(nx,{className:`h-4 w-4`})},{value:`images`,icon:(0,d.jsx)(qb,{className:`h-4 w-4`})},{value:`placeholders`,icon:(0,d.jsx)($b,{className:`h-4 w-4`})},{value:`styles`,icon:(0,d.jsx)(Qb,{className:`h-4 w-4`})}].map(n=>(0,d.jsxs)(`button`,{onClick:()=>t(n.value),className:`py-2 px-0.5 flex flex-col items-center justify-center gap-1 font-bold text-[9px] rounded-lg uppercase tracking-wider transition-all duration-150 ${e===n.value?`bg-orange-600 text-white shadow-sm shadow-orange-600/10`:`text-slate-500 hover:text-orange-600 hover:bg-orange-50/50`}`,children:[n.icon,(0,d.jsx)(`span`,{children:n.value})]},n.value))}),(0,d.jsxs)(`div`,{className:`p-4 flex-1 flex flex-col min-h-0 overflow-y-auto`,children:[e===`text`&&(0,d.jsx)(fx,{handleSidebarDragStart:oe,createTextBlock:s,setBlocks:n,setSelectedBlockId:i,setActiveTab:t,defaultStyles:o}),e===`tables`&&(0,d.jsx)(px,{schemas:y,toggleSchemaColumn:b,customTableName:x,setCustomTableName:S,customLoopStart:C,setCustomLoopStart:w,customLoopEnd:T,setCustomLoopEnd:E,handleAddCustomTable:D,handleSidebarDragStart:oe,setBlocks:n,setSelectedBlockId:i,setActiveTab:t,defaultStyles:o,isTablesLoading:se,tablesLoading:ce}),e===`images`&&(0,d.jsx)(mx,{customImageTypes:j,newImgTypeName:te,setNewImgTypeName:ne,handleAddCustomImageType:M,handleSidebarDragStart:oe,createImageBlock:c,setBlocks:n,setSelectedBlockId:i,setActiveTab:t}),e===`placeholders`&&(0,d.jsx)(hx,{placeholders:re,schemas:y,searchPlaceholder:ie,setSearchPlaceholder:ae,selectedBlockId:r,setBlocks:n,isPlaceholdersLoading:le,placeholdersLoading:ue}),e===`styles`&&(0,d.jsx)(_x,{selectedBlockId:r,getSelectedBlock:a,updateSelectedStyle:l,updateSelectedImageInfo:u,fontSizesState:de,fontFamiliesState:fe,fontWeightsState:pe,handleDeleteBlock:f,newColName:O,setNewColName:k,newColPlaceholder:A,setNewColPlaceholder:ee,handleAddTableColumn:m,handleRemoveTableColumn:p,handleUpdateTableColumn:h,handleReorderTableColumn:g,handleAddTableRow:_,handleRemoveTableRow:v,setBlocks:n})]})]})}var yx=[`bold`,`italic`,`underline`,`strikethrough`,`width`],bx=({block:e,onUpdate:t,onSelect:n,onDrop:r})=>{let i=(0,l.useRef)(null);(0,l.useEffect)(()=>{i.current&&i.current.innerHTML!==e.content&&document.activeElement!==i.current&&(i.current.innerHTML=e.content||`<br/>`)},[e.id,e.content]);let a=e.style,{bold:o,italic:s,underline:c,strikethrough:u,width:f}=a,p=T({},Pb(a,yx));o&&(p.fontWeight=`bold`),s&&(p.fontStyle=`italic`);let m=[];return c&&m.push(`underline`),u&&m.push(`line-through`),m.length>0&&(p.textDecoration=m.join(` `)),(0,d.jsx)(`div`,{ref:i,contentEditable:!0,suppressContentEditableWarning:!0,onFocus:n,onInput:e=>t(e.currentTarget.innerHTML),onBlur:e=>t(e.currentTarget.innerHTML),style:p,className:`h-fit w-full break-words outline-none`,onDrop:r,onDragOver:e=>e.preventDefault()})},xx=({blockId:e,colIdx:t,placeholder:n,onUpdate:r,onDrop:i})=>{let a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{a.current&&a.current.innerHTML!==n&&document.activeElement!==a.current&&(a.current.innerHTML=n)},[e,t,n]),(0,d.jsx)(`td`,{ref:a,contentEditable:!0,suppressContentEditableWarning:!0,onInput:e=>r(e.currentTarget.innerText||e.currentTarget.innerHTML),onBlur:e=>r(e.currentTarget.innerText||e.currentTarget.innerHTML),onDrop:i,onDragOver:e=>e.preventDefault(),className:`border border-slate-200 px-2.5 py-2.5 text-slate-500 bg-slate-50/20 font-sans outline-none focus:bg-slate-100/50 transition-colors`})},Sx=e=>{let t=[];return e.forEach(e=>{e.style.sameRow&&t.length>0?t[t.length-1].blocks.push(e):t.push({id:e.id,blocks:[e]})}),t};function Cx({blocks:e,setBlocks:t,selectedBlockId:n,setSelectedBlockId:r,setActiveTab:i,showMockData:a,placeholderMockData:o,dragOverIndex:s,setDragOverIndex:c,draggedSidebarItem:l,defaultStyles:u,zoom:f,panOffset:p,spacePressed:m,canvasHeight:h,viewportRef:g,canvasContainerRef:_,handleMouseDown:v,handleMouseMove:y,handleMouseUp:b,createTextBlock:x,duplicateBlock:S,reorderBlock:C,handleDeleteBlock:w,handleSidebarDrop:E,handleTableCellDrop:D,updateTableCell:O,handleTextDrop:k}){let A=(e,t)=>{e.dataTransfer.setData(`blockIndex`,t.toString()),e.dataTransfer.setData(`source`,`canvas`),e.dataTransfer.effectAllowed=`move`},ee=(n,r)=>{n.preventDefault(),n.stopPropagation();let i=n.dataTransfer.getData(`source`);if(i===`sidebar`)E(r);else if(i===`canvas`){let i=parseInt(n.dataTransfer.getData(`blockIndex`));if(isNaN(i)||i===r)return;let a=[...e],o=a.splice(i,1)[0],s=i<r?r-1:r;a.splice(s,0,o),t(a)}c(null)},j=1123,te=Math.max(1,Math.ceil(h/j));return(0,d.jsx)(`div`,{ref:g,className:`flex-1 overflow-auto p-8 flex justify-center items-start outline-none transition-all ${m?`cursor-grab active:cursor-grabbing`:`cursor-default`}`,onMouseDown:v,onMouseMove:y,onMouseUp:b,onMouseLeave:b,children:(0,d.jsx)(`div`,{style:{transform:`translate(${p.x}px, ${p.y}px) scale(${f})`,transformOrigin:`top center`},className:`transition-transform duration-75 ease-out select-none`,children:(0,d.jsxs)(`div`,{ref:_,style:{minHeight:`${Math.max(1123,te*j)}px`},className:`w-[794px] bg-white shadow-lg border border-gray-300/80 px-[60px] py-[60px] flex flex-col relative canvas-editor-area`,onDragOver:e=>e.preventDefault(),onDrop:n=>{if(n.preventDefault(),n.stopPropagation(),l)E(e.length);else{let e=n.dataTransfer.getData(`placeholder`);if(e){n.preventDefault();let a=x(`p`,`{{${e}}}`,u==null?void 0:u.p);t(e=>[...e,a]),r(a.id),i(`styles`)}}},children:[Array.from({length:Math.max(0,te-1)}).map((e,t)=>{let n=t+2,r=(t+1)*j;return(0,d.jsx)(`div`,{style:{top:`${r}px`},className:`absolute left-0 right-0 z-30 pointer-events-none flex items-center justify-center border-b-2 border-dashed border-orange-400/80 bg-orange-50/10 text-orange-600 text-[10px] font-bold py-1 select-none`,children:(0,d.jsx)(`span`,{className:`bg-orange-100/90 text-orange-700 border border-orange-300/80 px-2.5 py-0.5 rounded-full shadow-xs flex items-center space-x-1 font-mono`,children:(0,d.jsxs)(`span`,{children:[`📄 Page `,n,` Break (A4 - `,r,`px)`]})})},t)}),e.length===0?(0,d.jsxs)(`div`,{className:`flex-1 border-2 border-dashed border-gray-200 rounded-2xl flex flex-col items-center justify-center p-8 text-center text-slate-400`,children:[(0,d.jsx)(Qb,{className:`h-10 w-10 mb-3 animate-bounce text-slate-350`}),(0,d.jsx)(`span`,{className:`font-bold text-sm text-slate-600 block`,children:`Drag & Drop Editor Canvas`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-400 mt-1 max-w-sm`,children:`Select elements from the sidebar tabs (Text, Tables, Images) and drag them here to assemble your template structure.`})]}):Sx(e).map(a=>{var o;let s=a.blocks.length>1;return(0,d.jsx)(`div`,{style:T({pageBreakInside:`avoid`,breakInside:`avoid`},a.blocks.some(e=>e.style.pageBreakBefore===`always`||e.style.pageBreakBefore===!0)?{pageBreakBefore:`always`,breakBefore:`page`}:{}),className:`group/row ${a.blocks.some(e=>e.style.position===`absolute`)?``:`relative`} border border-transparent rounded-lg hover:border-slate-200/60 p-1 mb-2 ${s?((o=a.blocks[0])==null||(o=o.style)==null?void 0:o.flexDirection)===`column`?`flex flex-col gap-2`:`flex flex-row gap-4`:``}`,children:a.blocks.map(a=>{var o,l,u,f;let p=n===a.id,m=T(T({},a.style),_b(a.style.customCss||``));return(0,d.jsxs)(`div`,{draggable:!0,onDragStart:t=>{let n=e.findIndex(e=>e.id===a.id);A(t,n)},onDragOver:t=>{t.preventDefault(),c(e.findIndex(e=>e.id===a.id))},onDrop:t=>{let n=e.findIndex(e=>e.id===a.id);ee(t,n)},onClick:e=>{e.stopPropagation(),r(a.id),i(`styles`)},style:T({pageBreakInside:`avoid`,breakInside:`avoid`,width:a.style.position===`absolute`?`100%`:a.style.width||(s?`48%`:`100%`),height:a.style.position===`absolute`?a.style.height||`100%`:void 0,position:a.style.position,top:a.style.top,left:a.style.left,zIndex:a.style.zIndex?parseInt(a.style.zIndex):void 0},a.style.pageBreakBefore===`always`||a.style.pageBreakBefore===!0?{pageBreakBefore:`always`,breakBefore:`page`}:{}),className:`group/block relative p-0.5 rounded-xl border border-transparent transition-all duration-150 cursor-pointer ${p?`bg-orange-50/20 border-orange-500 shadow-sm ring-2 ring-orange-500/10`:`hover:bg-slate-50/30 hover:border-gray-200`} ${a.style.position===`absolute`?`!absolute !inset-0 !m-auto`:``}`,children:[p&&(0,d.jsxs)(`div`,{className:`absolute -top-3.5 right-3 bg-orange-600 text-white rounded-lg px-2 py-0.5 text-[10px] font-bold flex items-center space-x-1.5 shadow-md z-30 select-none`,children:[(0,d.jsx)(`button`,{onClick:()=>{C(e.findIndex(e=>e.id===a.id),`up`)},className:`hover:text-slate-350`,title:`Move Up`,children:(0,d.jsx)(Bb,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:()=>{C(e.findIndex(e=>e.id===a.id),`down`)},className:`hover:text-slate-350`,title:`Move Down`,children:(0,d.jsx)(zb,{className:`h-3 w-3`})}),(0,d.jsx)(`div`,{className:`h-3 w-[1px] bg-slate-700`}),(0,d.jsx)(`button`,{onClick:e=>S(a.id,e),className:`hover:text-slate-350`,title:`Duplicate block`,children:(0,d.jsx)(Ub,{className:`h-3 w-3`})}),(0,d.jsx)(`button`,{onClick:e=>w(a.id,e),className:`hover:text-red-400 text-red-300`,title:`Delete block`,children:(0,d.jsx)(sx,{className:`h-3 w-3`})})]}),a.type===`table`?(0,d.jsx)(`div`,{className:`overflow-x-auto w-full select-none`,children:(0,d.jsxs)(`table`,{style:m,className:`w-full border-collapse`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsx)(`tr`,{children:(o=a.tableInfo)==null?void 0:o.columns.filter(e=>e.enabled!==!1).map((e,t)=>(0,d.jsx)(`th`,{className:`border border-slate-200 px-2.5 py-1 text-slate-700 text-left bg-slate-50 font-sans`,children:e.columnName||``},t))})}),(0,d.jsx)(`tbody`,{children:((l=a.tableInfo)!=null&&l.mockRows&&a.tableInfo.mockRows.length>0?a.tableInfo.mockRows:[{}]).map((e,t)=>{var n;return(0,d.jsx)(`tr`,{className:`bg-slate-50/10 border-b border-slate-100 hover:bg-slate-50/20`,children:(n=a.tableInfo)==null?void 0:n.columns.filter(e=>e.enabled!==!1).map((t,n)=>{let r=e&&typeof e==`object`&&e[t.columnName]||t.placeholder;if(t.loop&&t.columns&&t.columns.length>0){let e=t.columns.filter(e=>e.enabled!==!1);return(0,d.jsx)(`td`,{className:`border border-slate-200 p-2 align-top bg-slate-50/20`,children:(0,d.jsxs)(`div`,{className:`w-full overflow-x-auto space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] font-semibold text-slate-500`,children:[(0,d.jsxs)(`span`,{children:[`Sub-table: `,t.columnName]}),(0,d.jsx)(`span`,{className:`px-1.5 py-0.5 bg-slate-200 text-slate-600 rounded text-[8px]`,children:`loop = true`})]}),(0,d.jsxs)(`table`,{className:`w-full border-collapse border border-slate-200 rounded text-xs bg-white`,children:[(0,d.jsx)(`thead`,{children:(0,d.jsx)(`tr`,{children:e.map((e,t)=>(0,d.jsx)(`th`,{className:`border border-slate-200 px-2 py-1 text-slate-700 text-left bg-slate-100/80 font-sans font-semibold text-[10px]`,children:e.columnName},t))})}),(0,d.jsx)(`tbody`,{children:(0,d.jsx)(`tr`,{className:`bg-slate-50/30`,children:e.map((e,t)=>(0,d.jsx)(xx,{blockId:a.id,colIdx:t,placeholder:e.placeholder,onUpdate:e=>O(a.id,n,e,t),onDrop:e=>D(e,a.id,n,t)},t))})})]})]})},n)}return(0,d.jsx)(xx,{blockId:a.id,colIdx:n,placeholder:r,onUpdate:e=>O(a.id,n,e),onDrop:e=>D(e,a.id,n)},n)})},t)})})]})}):a.type===`image`?(0,d.jsx)(`div`,{style:{textAlign:m.textAlign||`left`,width:`100%`,marginBottom:m.marginBottom,padding:m.padding,backgroundColor:m.backgroundColor},className:`w-full select-none`,children:(0,d.jsx)(`div`,{style:{width:s?`100%`:a.style.width&&a.style.width.endsWith(`%`)?a.style.width:`100%`,display:`inline-block`,textAlign:m.textAlign||`left`},children:((u=a.imageInfo)==null?void 0:u.imageType)===`barcode`?(0,d.jsx)(`div`,{style:{width:a.style.imageWidth||(a.style.width&&a.style.width.endsWith(`px`)?a.style.width:`100%`),height:a.style.height||a.style.minHeight||`70px`,marginLeft:m.textAlign===`center`||m.textAlign===`right`?`auto`:`0`,marginRight:m.textAlign===`center`?`auto`:m.textAlign===`right`?`0`:`auto`},className:`border border-dashed border-slate-200 p-2 bg-slate-50/5 rounded-lg flex items-center justify-center overflow-hidden`,dangerouslySetInnerHTML:{__html:vb(a.imageInfo.barcodeValue||`SHIP-99201`)}}):(0,d.jsx)(`img`,{src:((f=a.imageInfo)==null?void 0:f.url)||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`,style:{width:a.style.imageWidth||(a.style.width&&a.style.width.endsWith(`px`)?a.style.width:`100%`),height:`auto`,maxHeight:a.style.height||`300px`,objectFit:a.style.objectFit||`contain`,opacity:a.style.opacity||`1`,display:`block`,marginLeft:m.textAlign===`center`||m.textAlign===`right`?`auto`:`0`,marginRight:m.textAlign===`center`?`auto`:m.textAlign===`right`?`0`:`auto`},alt:`graphic content`})})}):(0,d.jsx)(bx,{block:a,onUpdate:e=>{t(t=>t.map(t=>t.id===a.id?T(T({},t),{},{content:e}):t))},onSelect:()=>r(a.id),onDrop:e=>k(e,a.id)})]},a.id)})},a.id)}),s!==null&&(0,d.jsx)(`div`,{className:`h-[2px] bg-orange-500 rounded my-1 shadow-md animate-pulse`})]})})})}function wx({showImportHtml:e=!0,showImportPdf:t=!0,showPreview:n=!0,showExport:r=!0,showExportPdf:i=!0,showClearCanvas:a,customButtonStyles:o,customButtonClassNames:s,customActionComponents:c,handleHtmlImport:u,handlePdfImport:f,setPreviewOpen:p,handleExport:m,handleExportPdf:h,handleClearCanvas:g,zoom:_,setZoom:v,setPanOffset:y}){let b=(0,l.useRef)(null),x=(0,l.useRef)(null);return(0,d.jsxs)(`div`,{className:`bg-white border-b border-gray-200 px-4 py-2 flex flex-wrap items-center justify-between shadow-xs sticky top-0 z-20 gap-2`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e&&(0,d.jsxs)(d.Fragment,{children:[c!=null&&c.importHtml?c.importHtml({onClick:()=>{var e;return(e=b.current)==null?void 0:e.click()}}):(0,d.jsxs)(`button`,{onClick:()=>{var e;return(e=b.current)==null?void 0:e.click()},style:o==null?void 0:o.importHtml,className:(s==null?void 0:s.importHtml)||`inline-flex items-center space-x-1 px-2.5 py-1 border border-gray-200 rounded-lg text-xs font-semibold bg-white hover:bg-slate-50 text-slate-700 transition-colors shadow-2xs cursor-pointer`,title:`Import local HTML file`,children:[(0,d.jsx)(lx,{className:`h-3.5 w-3.5 text-slate-500`}),(0,d.jsx)(`span`,{children:`Import HTML`})]}),(0,d.jsx)(`input`,{type:`file`,ref:b,onChange:u,accept:`.html`,className:`hidden`})]}),t&&(0,d.jsxs)(d.Fragment,{children:[c!=null&&c.importPdf?c.importPdf({onClick:()=>{var e;return(e=x.current)==null?void 0:e.click()}}):(0,d.jsxs)(`button`,{onClick:()=>{var e;return(e=x.current)==null?void 0:e.click()},style:o==null?void 0:o.importPdf,className:(s==null?void 0:s.importPdf)||`inline-flex items-center space-x-1 px-2.5 py-1 border border-gray-200 rounded-lg text-xs font-semibold bg-white hover:bg-slate-50 text-slate-700 transition-colors shadow-2xs cursor-pointer`,title:`Import PDF layout structure`,children:[(0,d.jsx)(Kb,{className:`h-3.5 w-3.5 text-slate-500`}),(0,d.jsx)(`span`,{children:`Import PDF`})]}),(0,d.jsx)(`input`,{type:`file`,ref:x,onChange:f,accept:`.pdf`,className:`hidden`})]}),n&&(c!=null&&c.preview?c.preview({onClick:()=>p(!0)}):(0,d.jsxs)(`button`,{onClick:()=>p(!0),style:o==null?void 0:o.preview,className:(s==null?void 0:s.preview)||`inline-flex items-center space-x-1 px-2.5 py-1 border border-slate-200 rounded-lg text-xs font-semibold bg-slate-50 text-slate-700 hover:bg-slate-100 transition-colors shadow-2xs cursor-pointer`,children:[(0,d.jsx)(Gb,{className:`h-3.5 w-3.5 text-slate-500`}),(0,d.jsx)(`span`,{children:`Live Preview`})]})),i&&(c!=null&&c.exportPdf?c.exportPdf({onClick:h}):(0,d.jsxs)(`button`,{onClick:h,style:o==null?void 0:o.exportPdf,className:(s==null?void 0:s.exportPdf)||`inline-flex items-center space-x-1 px-2.5 py-1 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-xs font-semibold transition-colors shadow-2xs shadow-indigo-600/10 cursor-pointer`,children:[(0,d.jsx)(Xb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Download PDF`})]})),r&&(c!=null&&c.export?c.export({onClick:m}):(0,d.jsxs)(`button`,{onClick:m,style:o==null?void 0:o.export,className:(s==null?void 0:s.export)||`inline-flex items-center space-x-1 px-2.5 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded-lg text-xs font-semibold transition-colors shadow-2xs shadow-orange-600/10 cursor-pointer`,children:[(0,d.jsx)(Wb,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Export Template`})]})),a&&(0,d.jsxs)(`button`,{onClick:g,style:o==null?void 0:o.clearCanvas,className:(s==null?void 0:s.clearCanvas)||`inline-flex items-center space-x-1 px-2.5 py-1 text-xs font-semibold border border-red-200 text-red-650 bg-red-50 hover:bg-red-100 rounded-lg transition-colors cursor-pointer`,title:`Clear all canvas elements`,children:[(0,d.jsx)(sx,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Clear Canvas`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center space-x-2 bg-slate-50 border border-gray-200 px-2.5 py-0.5 rounded-xl shadow-xs select-none shrink-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,d.jsx)(`button`,{onClick:()=>v(e=>Math.max(e-.1,.5)),className:`h-5 w-5 rounded border border-gray-200 bg-white hover:bg-slate-50 flex items-center justify-center font-bold text-slate-650 hover:text-slate-900 transition-colors text-[10px] select-none cursor-pointer`,title:`Zoom Out`,children:`−`}),(0,d.jsxs)(`div`,{className:`w-10 text-center text-[11px] font-bold text-slate-700`,children:[Math.round(_*100),`%`]}),(0,d.jsx)(`button`,{onClick:()=>v(e=>Math.min(e+.1,2)),className:`h-5 w-5 rounded border border-gray-200 bg-white hover:bg-slate-50 flex items-center justify-center font-bold text-slate-650 hover:text-slate-900 transition-colors text-[10px] select-none cursor-pointer`,title:`Zoom In`,children:`+`})]}),(0,d.jsx)(`div`,{className:`h-3.5 w-[1px] bg-gray-200`}),(0,d.jsx)(`input`,{type:`range`,min:`0.5`,max:`2.0`,step:`0.05`,value:_,onChange:e=>v(parseFloat(e.target.value)),className:`w-16 accent-orange-600 h-1 bg-gray-200 rounded-lg appearance-none cursor-pointer`}),(0,d.jsx)(`button`,{onClick:()=>{v(1),y({x:0,y:0})},className:`text-[9px] font-bold text-slate-500 hover:text-slate-800 hover:underline cursor-pointer`,children:`Reset`})]})]})}function Tx({previewOpen:e,setPreviewOpen:t,generateExportHtml:n}){return e?(0,d.jsx)(`div`,{className:`fixed inset-0 bg-slate-950/65 backdrop-blur-xs flex items-center justify-center z-50 p-6`,children:(0,d.jsxs)(`div`,{className:`bg-white rounded-2xl w-full max-w-[900px] h-[90%] flex flex-col shadow-2xl overflow-hidden border border-gray-200`,children:[(0,d.jsxs)(`div`,{className:`bg-slate-50 border-b border-gray-200 px-6 py-4 flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`h3`,{className:`text-sm font-bold text-slate-800 flex items-center space-x-2`,children:[(0,d.jsx)(Gb,{className:`h-4 w-4 text-slate-655`}),(0,d.jsx)(`span`,{children:`HTML Document Render Output`})]}),(0,d.jsx)(`p`,{className:`text-[10px] text-slate-400 mt-0.5`,children:`Sandboxed iframe preview of final template markup`})]}),(0,d.jsx)(`button`,{onClick:()=>t(!1),className:`p-1.5 bg-slate-100 hover:bg-slate-200 text-slate-500 hover:text-slate-800 rounded-lg transition-colors`,children:(0,d.jsx)(ux,{className:`h-4 w-4`})})]}),(0,d.jsx)(`div`,{className:`flex-1 bg-slate-100 p-6 overflow-hidden`,children:(0,d.jsx)(`iframe`,{title:`HTML Preview Sandbox`,srcDoc:n(!0),className:`w-full h-full bg-white border border-gray-200 rounded-xl shadow-xs`,sandbox:`allow-same-origin`})}),(0,d.jsxs)(`details`,{className:`bg-slate-50 border-t border-gray-200`,children:[(0,d.jsxs)(`summary`,{className:`px-6 py-3 text-xs font-bold text-slate-600 cursor-pointer select-none hover:text-slate-800 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{children:`View Raw Output Markup (HTML)`}),(0,d.jsx)(`span`,{className:`text-[10px] text-slate-400 font-medium font-sans`,children:`Click to expand`})]}),(0,d.jsx)(`div`,{className:`px-6 pb-6 overflow-x-auto max-h-[250px]`,children:(0,d.jsx)(`pre`,{className:`bg-slate-900 text-slate-200 p-4 rounded-lg text-[10px] font-mono whitespace-pre-wrap select-all`,children:n(!1)})})]})]})}):null}function Ex({bubbleCoords:e,applySelectionFormat:t}){return e?(0,d.jsxs)(`div`,{className:`fixed bg-slate-900 border border-slate-800 text-white rounded-xl shadow-xl py-1 px-1.5 flex items-center space-x-1.5 z-50 select-none -translate-x-1/2`,style:{left:`${e.x}px`,top:`${e.y}px`},children:[(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`bold`)},className:`h-6 w-6 rounded hover:bg-slate-800 flex items-center justify-center font-bold text-xs text-slate-200 hover:text-white transition-colors`,title:`Bold Selection`,children:`B`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`italic`)},className:`h-6 w-6 rounded hover:bg-slate-800 flex items-center justify-center italic text-xs text-slate-200 hover:text-white transition-colors`,title:`Italic Selection`,children:`I`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`underline`)},className:`h-6 w-6 rounded hover:bg-slate-800 flex items-center justify-center underline text-xs text-slate-200 hover:text-white transition-colors`,title:`Underline Selection`,children:`U`}),(0,d.jsx)(`div`,{className:`h-4 w-[1px] bg-slate-800 mx-1`}),(0,d.jsxs)(`select`,{value:e.format||``,onChange:e=>{e.preventDefault(),e.target.value&&(t(`formatBlock`,e.target.value),e.target.value===`P`&&t(`fontSize`,`3`))},className:`bg-slate-800 text-white text-[10px] rounded px-1 py-0.5 outline-none cursor-pointer border border-slate-700`,children:[(0,d.jsx)(`option`,{value:``,disabled:!0,children:`Format...`}),(0,d.jsx)(`option`,{value:`H1`,children:`Heading 1`}),(0,d.jsx)(`option`,{value:`H2`,children:`Heading 2`}),(0,d.jsx)(`option`,{value:`H3`,children:`Heading 3`}),(0,d.jsx)(`option`,{value:`P`,children:`Paragraph`}),(0,d.jsx)(`option`,{value:`BLOCKQUOTE`,children:`Quote`})]}),(0,d.jsx)(`div`,{className:`h-4 w-[1px] bg-slate-800 mx-1`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#3b82f6`)},className:`h-4 w-4 rounded-full bg-blue-500 hover:scale-110 transition-transform cursor-pointer`,title:`Color Blue`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#ef4444`)},className:`h-4 w-4 rounded-full bg-red-500 hover:scale-110 transition-transform cursor-pointer`,title:`Color Red`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#1e293b`)},className:`h-4 w-4 rounded-full bg-slate-700 hover:scale-110 transition-transform cursor-pointer border border-slate-850`,title:`Color Slate`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`foreColor`,`#22c55e`)},className:`h-4 w-4 rounded-full bg-green-500 hover:scale-110 transition-transform cursor-pointer`,title:`Color Green`}),(0,d.jsx)(`div`,{className:`h-4 w-[1px] bg-slate-800`}),(0,d.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),t(`removeFormat`)},className:`hover:bg-slate-800 rounded text-[10px] px-1.5 h-6 flex items-center justify-center text-slate-400 hover:text-white font-semibold transition-colors`,title:`Clear Formatting`,children:`Clear`})]}):null}zu.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@6.1.200/build/pdf.worker.min.mjs`;var Dx=e=>{let t=[];return e.forEach(e=>{e.style.sameRow&&t.length>0?t[t.length-1].blocks.push(e):t.push({id:e.id,blocks:[e]})}),t},Ox=e=>e?e.replace(/contenteditable="[^"]*"/g,``).replace(/class="[^"]*"/g,``).replace(/data-placeholder="[^"]*"/g,``).replace(/ /g,` `).trim():``;function kx({tableSchemas:e,placeholders:t,defaultLogo:n,defaultBanner:r,headerTitle:i=`HTML Template Builder`,headerSubtitle:a=`Design and export templates dynamically`,headerLogo:o,typographySizes:s,typographyWeights:c,typographyFonts:u,templatingLanguage:f=`csharp`,loopSyntax:p=`foreach`,onChange:m,onExport:h,onExportPdf:g,initialBlocks:_,defaultStyles:y,showImportHtml:b=!0,showImportPdf:x=!0,showClearCanvas:S=!0,showPreview:C=!0,showExport:w=!0,showExportPdf:E=!0,showHeader:D=!0,sidebarPosition:O=`left`,isTablesLoading:A,tablesLoading:ee,isPlaceholdersLoading:j,placeholdersLoading:te,customButtonStyles:ne,customButtonClassNames:M,customActionComponents:re}={}){let{zoom:ie,setZoom:ae,panOffset:oe,setPanOffset:se,spacePressed:ce,canvasHeight:le,viewportRef:ue,canvasContainerRef:de,handleMouseDown:fe,handleMouseMove:pe,handleMouseUp:me}=Cb(),{customTableName:he,setCustomTableName:ge,customLoopStart:_e,setCustomLoopStart:ve,customLoopEnd:ye,setCustomLoopEnd:be,newColName:xe,setNewColName:Se,newColPlaceholder:Ce,setNewColPlaceholder:we,bubbleCoords:Te,setBubbleCoords:N,schemas:P,isParsing:Ee,setIsParsing:De,parseStatusText:Oe,setParseStatusText:ke,parseError:Ae,setParseError:je,draggedSidebarItem:F,setDraggedSidebarItem:Me,dragOverIndex:Ne,setDragOverIndex:Pe,newImgTypeName:Fe,setNewImgTypeName:Ie,customImageTypes:Le,searchPlaceholder:I,setSearchPlaceholder:L,handleAddCustomTable:Re,handleAddCustomImageType:ze,toggleSchemaColumn:Be,applySelectionFormat:Ve,setSavedRange:He}=wb({tableSchemas:e}),{blocks:R,setBlocks:Ue,selectedBlockId:We,setSelectedBlockId:Ge,getSelectedBlock:Ke,createTextBlock:qe,createTableBlock:Je,createImageBlock:Ye,handleDeleteBlock:Xe,handleDuplicateBlock:Ze,handleMoveBlockUp:z,handleMoveBlockDown:B,updateSelectedStyle:Qe,updateSelectedImageInfo:$e,handleRemoveTableColumn:et,handleAddTableColumn:tt,handleUpdateTableColumn:nt,handleReorderTableColumn:rt,handleAddTableRow:it,handleRemoveTableRow:at}=Sb({initialBlocks:_,defaultStyles:y,defaultLogo:n,defaultBanner:r,onChange:m}),[ot,st]=(0,l.useState)(`text`),[ct,V]=(0,l.useState)(!1),[lt]=(0,l.useState)(!0),[ut]=(0,l.useState)(s||[{label:`8px`,value:`8px`},{label:`9px`,value:`9px`},{label:`10px`,value:`10px`},{label:`11px`,value:`11px`},{label:`12px`,value:`12px`},{label:`14px`,value:`14px`},{label:`16px`,value:`16px`},{label:`18px`,value:`18px`},{label:`20px`,value:`20px`},{label:`24px`,value:`24px`},{label:`28px`,value:`28px`},{label:`32px`,value:`32px`},{label:`36px`,value:`36px`}]),[dt]=(0,l.useState)(u||[{label:`Outfit (Default)`,value:`'Outfit', 'Inter', sans-serif`},{label:`Inter`,value:`'Inter', sans-serif`},{label:`Roboto`,value:`'Roboto', sans-serif`},{label:`System Sans`,value:`system-ui, -apple-system, sans-serif`},{label:`Georgia (Serif)`,value:`Georgia, serif`},{label:`Courier New (Mono)`,value:`'Courier New', monospace`}]),[ft]=(0,l.useState)(c||[{label:`Light`,value:`300`},{label:`Regular`,value:`400`},{label:`Medium`,value:`500`},{label:`Semibold`,value:`600`},{label:`Bold`,value:`700`},{label:`Extra Bold`,value:`800`}]),[pt]=(0,l.useState)(f),[mt]=(0,l.useState)(p),[ht]=(0,l.useState)(!0),gt={};(0,l.useEffect)(()=>{let e=()=>{let e=window.getSelection();if(!e||e.isCollapsed||e.toString().trim()===``){N(null),He(null);return}let t=document.activeElement;if(!(t&&t.getAttribute(`contenteditable`)===`true`&&(t.closest(`.canvas-editor-area`)||t.closest(`td`)))){N(null),He(null);return}try{let t=e.getRangeAt(0),n=t.getBoundingClientRect(),r=document.queryCommandValue(`formatBlock`)||``;r=r.toUpperCase(),N({x:n.left+n.width/2,y:n.top-38,format:r}),He(t)}catch(e){N(null),He(null)}};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[N,He]),(0,l.useEffect)(()=>{let e=ue.current;if(!e)return;let t=e=>{if(e.ctrlKey){e.preventDefault();let t=e.deltaY<0?1:-1;ae(e=>Math.min(2,Math.max(.5,e+t*.05)))}};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[ue,ae]),(0,l.useEffect)(()=>{window.updateContentFromRawDelete=(e,t)=>{Ue(n=>n.map(n=>n.id===e?T(T({},n),{},{content:t}):n))}},[Ue]);let _t=e=>{var t;let n=(t=e.target.files)==null?void 0:t[0];if(!n)return;De(!0),ke(`Parsing HTML...`),je(null);let r=new FileReader;r.onload=t=>{try{var n;let e=bb((n=t.target)==null?void 0:n.result);e.length>0&&Ue(e)}catch(e){console.error(e),je(e.message||`Failed to parse HTML`)}finally{De(!1),e.target&&(e.target.value=``)}},r.readAsText(n)},vt=e=>{var t;let n=(t=e.target.files)==null?void 0:t[0];if(!n)return;De(!0),ke(`Reading PDF text layers...`),je(null);let r=new FileReader;r.onload=v(function*(){try{let e=r.result,t=yield xb(e,k);t.length>0&&Ue(e=>[...e,...t])}catch(e){console.error(e),je(e.message||`Failed to read PDF`)}finally{De(!1),e.target&&(e.target.value=``)}}),r.readAsArrayBuffer(n)},yt=e=>{let t=e||`items`;if(pt===`handlebars`||pt===`mustache`){let e=mt===`foreach`?`foreach`:`each`;return{start:`{{#${e} ${t}}}`,end:`{{/${e}}}`}}return pt===`liquid`||pt===`scriban`||pt===`dotnet`?{start:`{% for ${t.endsWith(`s`)?t.slice(0,-1):`item`} in ${t} %}`,end:`{% endfor %}`}:pt===`js`||pt===`ts`?{start:`\${${t}.map(${t.endsWith(`s`)?t.slice(0,-1):`item`} => \``,end:"`).join('')}"}:pt===`csharp`||pt===`razor`?{start:`@foreach (var ${t.endsWith(`s`)?t.slice(0,-1):`item`} in ${t}) {`,end:`}`}:{start:_e.replace(`items`,t),end:ye}},bt=(e=!1)=>{let t=`<!DOCTYPE html>
|
|
59
59
|
<html>
|
|
60
60
|
<head>
|
|
61
61
|
<meta charset="utf-8">
|
|
62
62
|
<title>Exported HTML Template</title>
|
|
63
63
|
<style>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
@page {
|
|
65
|
+
size: A4 portrait;
|
|
66
|
+
margin: 0;
|
|
67
|
+
}
|
|
68
|
+
* {
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
}
|
|
71
|
+
html, body {
|
|
72
|
+
margin: 0;
|
|
73
|
+
padding: 0;
|
|
74
|
+
background-color: #f8fafc;
|
|
75
|
+
font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
76
|
+
color: #1e293b;
|
|
77
|
+
-webkit-print-color-adjust: exact;
|
|
78
|
+
print-color-adjust: exact;
|
|
79
|
+
}
|
|
80
|
+
.paper-sheet {
|
|
81
|
+
width: 794px;
|
|
82
|
+
min-height: 1123px;
|
|
83
|
+
margin: 20px auto;
|
|
84
|
+
padding: 60px;
|
|
85
|
+
background-color: #ffffff;
|
|
86
|
+
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
position: relative;
|
|
89
|
+
}
|
|
90
|
+
.row-container {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
width: 100%;
|
|
94
|
+
align-items: stretch;
|
|
95
|
+
margin-bottom: 8px;
|
|
96
|
+
page-break-inside: avoid !important;
|
|
97
|
+
break-inside: avoid !important;
|
|
98
|
+
break-inside: avoid-page !important;
|
|
99
|
+
}
|
|
100
|
+
.block-container {
|
|
101
|
+
box-sizing: border-box;
|
|
102
|
+
page-break-inside: avoid !important;
|
|
103
|
+
break-inside: avoid !important;
|
|
104
|
+
break-inside: avoid-page !important;
|
|
105
|
+
}
|
|
106
|
+
h1, h2, h3, h4, h5, h6, p {
|
|
107
|
+
margin: 0;
|
|
108
|
+
padding: 0;
|
|
109
|
+
}
|
|
110
|
+
table {
|
|
111
|
+
width: 100%;
|
|
112
|
+
border-collapse: collapse;
|
|
113
|
+
page-break-inside: auto;
|
|
114
|
+
}
|
|
115
|
+
tr {
|
|
116
|
+
page-break-inside: avoid !important;
|
|
117
|
+
break-inside: avoid !important;
|
|
118
|
+
break-inside: avoid-page !important;
|
|
119
|
+
}
|
|
120
|
+
th {
|
|
121
|
+
background-color: #f1f5f9;
|
|
122
|
+
color: #334155;
|
|
123
|
+
border: 1px solid #e2e8f0;
|
|
124
|
+
padding: 6px 8px;
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
text-align: left;
|
|
127
|
+
}
|
|
128
|
+
td {
|
|
129
|
+
border: 1px solid #e2e8f0;
|
|
130
|
+
padding: 6px 8px;
|
|
131
|
+
color: #475569;
|
|
132
|
+
}
|
|
133
|
+
tr:nth-child(even) {
|
|
134
|
+
background-color: #f8fafc;
|
|
135
|
+
}
|
|
136
|
+
img, svg {
|
|
137
|
+
page-break-inside: avoid !important;
|
|
138
|
+
break-inside: avoid !important;
|
|
139
|
+
break-inside: avoid-page !important;
|
|
140
|
+
}
|
|
141
|
+
.page-break-before {
|
|
142
|
+
page-break-before: always !important;
|
|
143
|
+
break-before: page !important;
|
|
144
|
+
}
|
|
145
|
+
span[data-placeholder] {
|
|
146
|
+
background-color: #f1f5f9;
|
|
147
|
+
color: #1e293b;
|
|
148
|
+
border: 1px solid #e2e8f0;
|
|
149
|
+
padding: 1px 4px;
|
|
150
|
+
border-radius: 3px;
|
|
151
|
+
font-weight: 600;
|
|
152
|
+
display: inline-flex;
|
|
153
|
+
font-size: inherit;
|
|
154
|
+
}
|
|
155
|
+
@media print {
|
|
156
|
+
html, body {
|
|
157
|
+
background-color: #ffffff !important;
|
|
158
|
+
}
|
|
159
|
+
.paper-sheet {
|
|
160
|
+
width: 100% !important;
|
|
161
|
+
max-width: 100% !important;
|
|
162
|
+
min-height: 100% !important;
|
|
163
|
+
margin: 0 !important;
|
|
164
|
+
padding: 60px !important;
|
|
165
|
+
box-shadow: none !important;
|
|
166
|
+
border: none !important;
|
|
167
|
+
background-color: #ffffff !important;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
72
170
|
</style>
|
|
73
171
|
</head>
|
|
74
172
|
<body>
|
|
75
|
-
|
|
173
|
+
<div class="paper-sheet">
|
|
174
|
+
`;return Dx(R).forEach(n=>{let r=n.blocks.length>1;if(r){var i;let e=((i=n.blocks[0])==null||(i=i.style)==null?void 0:i.flexDirection)||`row`;t+=` <div class="row-container" style="display: flex; flex-direction: ${e}; flex-wrap: wrap; gap: 16px; width: 100%; align-items: stretch; margin-bottom: 8px;">\n`}n.blocks.forEach(n=>{let i=gb(n.style),a=n.style.textAlign===`center`?`margin-left: auto; margin-right: auto;`:n.style.textAlign===`right`?`margin-left: auto; margin-right: 0;`:`margin-left: 0; margin-right: auto;`,o=n.style.width||(r?`48%`:`100%`),s=r?`0px`:n.style.marginBottom||`8px`,c=n.style.height?`height: ${n.style.height};`:``,l=`margin-bottom: ${s}; padding: ${n.style.padding||`8px`}; width: ${o}; min-height: ${n.style.minHeight||`auto`}; ${c} ${a} background-color: ${n.style.backgroundColor||`transparent`};`;if(n.type===`table`){let r=n.tableInfo;if(!r)return;let a=r.columns.filter(e=>e.enabled!==!1);t+=` <div class="block-container" style="${l}">\n`;let o=i;i.includes(`font-size`)||(o+=` font-size: 10px;`),i.includes(`color`)||(o+=` color: #334155;`),i.includes(`text-align`)||(o+=` text-align: left;`),i.includes(`font-weight`)||(o+=` font-weight: 400;`),t+=` <table style="${o}">\n`,t+=` <thead>
|
|
76
175
|
`,t+=` <tr>
|
|
77
176
|
`,a.forEach(e=>{let n=e.columnName||``;t+=` <th>${n}</th>\n`}),t+=` </tr>
|
|
78
177
|
`,t+=` </thead>
|
|
79
178
|
`,t+=` <tbody>
|
|
80
179
|
`;let s=(t,n)=>{let r=(t.columns||[]).filter(e=>e.enabled!==!1),i=` <table style="width: 100%; border-collapse: collapse; margin: 4px 0;">
|
|
81
|
-
`;
|
|
180
|
+
`;i+=` <thead>
|
|
82
181
|
`,i+=` <tr>
|
|
83
182
|
`,r.forEach(e=>{i+=` <th>${e.columnName||``}</th>\n`}),i+=` </tr>
|
|
84
183
|
`,i+=` </thead>
|
|
85
184
|
`,i+=` <tbody>
|
|
86
|
-
|
|
87
|
-
`,r.forEach(t=>{let n=Ox(t.placeholder);typeof e==`object`&&e&&Object.keys(e).forEach(t=>{let r=RegExp(`\\{\\{(item\\.|package\\.)?${t}\\}\\}`,`g`);n=n.replace(r,e[t])}),Object.keys(
|
|
88
|
-
`})
|
|
185
|
+
`;let a=t.columnName,o=n&&Array.isArray(n[a])&&n[a].length>0?n[a]:[{}];if(e||o.length>1||!t.loop)o.forEach(e=>{i+=` <tr>
|
|
186
|
+
`,r.forEach(t=>{let n=Ox(t.placeholder);typeof e==`object`&&e&&Object.keys(e).forEach(t=>{let r=RegExp(`\\{\\{(item\\.|package\\.)?${t}\\}\\}`,`g`);n=n.replace(r,e[t])}),Object.keys(gt).forEach(e=>{let t=gt[e];n.includes(`{{${e}}}`)&&(n=n.replace(RegExp(`\\{\\{${e}\\}\\}`,`g`),t))}),n=n.replace(/\{\{[^}]+\}\}/g,``),i+=` <td>${n}</td>\n`}),i+=` </tr>
|
|
187
|
+
`});else{let e=t.columnName||`items`,n=yt(e);ht?i+=` <!-- ${n.start} --><tr>\n`:i+=` ${n.start}<tr>\n`,r.forEach(e=>{i+=` <td>${e.placeholder}</td>\n`}),ht?i+=` </tr><!-- ${n.end} -->\n`:i+=` </tr>${n.end}\n`}return i+=` </tbody>
|
|
89
188
|
`,i+=` </table>`,i},c=t=>{let n=` <tr>
|
|
90
|
-
`;return a.forEach(
|
|
91
|
-
`,n}
|
|
189
|
+
`;return a.forEach(i=>{if(i.loop&&i.columns&&i.columns.length>0)n+=` <td>\n${s(i,t)}\n </td>\n`;else{let a=Ox(i.placeholder);(e||r.mockRows&&r.mockRows.length>1)&&(t&&typeof t==`object`&&Object.keys(t).forEach(e=>{a.includes(`{{${e}}}`)&&(a=a.replace(RegExp(`\\{\\{${e}\\}\\}`,`g`),t[e])),a.includes(`{{item.${e}}}`)&&(a=a.replace(RegExp(`\\{\\{item\\.${e}\\}\\}`,`g`),t[e])),a.includes(`{{package.${e}}}`)&&(a=a.replace(RegExp(`\\{\\{package\\.${e}\\}\\}`,`g`),t[e]))}),Object.keys(gt).forEach(e=>{let t=gt[e];a.includes(`{{${e}}}`)&&(a=a.replace(RegExp(`\\{\\{${e}\\}\\}`,`g`),t))}),e&&(a=a.replace(/\{\{[^}]+\}\}/g,``))),n+=` <td>${a}</td>\n`}}),n+=` </tr>
|
|
190
|
+
`,n},u=r.mockRows&&r.mockRows.length>0?r.mockRows:[{}];if(e||u.length>1||!r.loop)u.forEach(e=>{t+=c(e)});else{let e=r.tableName===`package`?`shipment.packages`:r.tableName===`article`?`package.articles`:r.tableName,n=yt(e);ht?t+=` <!-- ${n.start} --><tr>\n`:t+=` ${n.start}<tr>\n`,a.forEach(e=>{e.loop&&e.columns&&e.columns.length>0?t+=` <td>\n${s(e)}\n </td>\n`:t+=` <td>${e.placeholder}</td>\n`}),ht?t+=` </tr><!-- ${n.end} -->\n`:t+=` </tr>${n.end}\n`}t+=` </tbody>
|
|
92
191
|
`,t+=` </table>
|
|
93
192
|
`,t+=` </div>
|
|
94
|
-
`}else if(n.type===`image`){let i=n.imageInfo||{imageType:`logo`},a=``,s=n.style.height||n.style.minHeight||`auto`,c=n.style.imageWidth||(n.style.width&&n.style.width.endsWith(`px`)?n.style.width:`100%`),l=n.style.textAlign||`left`,u=l===`center`?`margin-left: auto; margin-right: auto;`:l===`right`?`margin-left: auto; margin-right: 0;`:`margin-left: 0; margin-right: auto;`;a=i.imageType===`barcode`?e
|
|
193
|
+
`}else if(n.type===`image`){let i=n.imageInfo||{imageType:`logo`},a=``,s=n.style.height||n.style.minHeight||`auto`,c=n.style.imageWidth||(n.style.width&&n.style.width.endsWith(`px`)?n.style.width:`100%`),l=n.style.textAlign||`left`,u=l===`center`?`margin-left: auto; margin-right: auto;`:l===`right`?`margin-left: auto; margin-right: 0;`:`margin-left: 0; margin-right: auto;`;a=i.imageType===`barcode`?e||lt?`<div style="width: ${c}; height: ${s}; display: block; ${u}">${vb(i.barcodeValue||`SHIP-99201`)}</div>`:`<img src="${i.barcodePlaceholder||`{{barcode}}`}" style="width: ${c}; height: ${s}; display: block; ${u}" alt="Barcode" />`:`<img src="${i.url||`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MDAiIGhlaWdodD0iNDAwIiB2aWV3Qm94PSIwIDAgODAwIDQwMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0iI2YxZjVmOSIvPjxyZWN0IHg9IjEwIiB5PSIxMCIgd2lkdGg9Ijc4MCIgaGVpZ2h0PSIzODAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2RiZTJmNiIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtZGFzaGFycmF5PSI2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSInT3V0Zml0JywgJ0ludGVyJywgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIyNCIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzk0YTNiOCIgZG9taW5hbnQtYmFzZWxpbmU9Im1pZGRsZSIgdGV4dC1hbmNob3I9Im1pZGRsZSI+U2VsZWN0IEltYWdlPC90ZXh0Pjwvc3ZnPg==`}" style="width: ${c}; height: auto; max-height: ${s===`auto`?`300px`:s}; object-fit: ${n.style.objectFit||`contain`}; ${n.style.opacity?`opacity: ${n.style.opacity};`:``} display: block; ${u}" alt="${i.imageType}" />`;let d=r?`100%`:n.style.width&&n.style.width.endsWith(`%`)?n.style.width:`100%`;t+=` <div class="block-container" style="display: block; width: ${o}; text-align: ${l}; border: none; background-color: transparent; ${n.style.marginBottom?`margin-bottom: ${n.style.marginBottom};`:``}">\n`,t+=` <div style="width: ${d}; text-align: ${l}; display: block;">\n`,t+=` ${a}\n`,t+=` </div>
|
|
95
194
|
`,t+=` </div>
|
|
96
|
-
`}else{let r=`p`;[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(n.type)?r=n.type:n.type===`title`?r=`h1`:n.type===`subtitle`?r=`h2`:n.type===`caption`&&(r=`span`);let a=Ox(n.content);e&&
|
|
195
|
+
`}else{let r=`p`;[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`].includes(n.type)?r=n.type:n.type===`title`?r=`h1`:n.type===`subtitle`?r=`h2`:n.type===`caption`&&(r=`span`);let a=Ox(n.content);(e||lt)&&(Object.keys(gt).forEach(e=>{let t=gt[e];a=a.replace(RegExp(`\\{\\{${e}\\}\\}`,`g`),t)}),e&&(a=a.replace(/\{\{[^}]+\}\}/g,``))),t+=` <div class="block-container" style="${l} text-align: ${n.style.textAlign};">\n`,t+=` <${r} style="${i}">${a}</${r}>\n`,t+=` </div>
|
|
97
196
|
`}}),r&&(t+=` </div>
|
|
98
|
-
`)}),t
|
|
99
|
-
|
|
197
|
+
`)}),t+=` </div>
|
|
198
|
+
`,t+=`</body>
|
|
199
|
+
</html>`,t},xt=()=>{let e=bt(!1);if(h)h(e);else{let t=new Blob([e],{type:`text/html;charset=utf-8;`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`exported_template.html`,n.click()}},St=()=>{let e=bt(!0);if(g)g(e);else{let t=window.open(``,`_blank`);t&&(t.document.write(e),t.document.close(),t.focus(),setTimeout(()=>{t.print(),t.close()},500))}},Ct=()=>{Ue([]),Ge(null)},wt=(e,t)=>{let n=e.dataTransfer.getData(`placeholder`);if(!n)return;e.preventDefault(),e.stopPropagation();let r=`{{${n.replace(/[{}]/g,``)}}}`;Ue(e=>e.map(e=>e.id===t?T(T({},e),{},{content:e.content+r}):e))},Tt=(e,t,n,r)=>{let i=e.dataTransfer.getData(`placeholder`);if(!i)return;e.preventDefault(),e.stopPropagation();let a=i.startsWith(`{{`)?i:`{{${i}}}`;Et(t,n,a,r)},Et=(e,t,n,r)=>{Ue(i=>i.map(i=>{if(i.id===e&&i.type===`table`&&i.tableInfo){var a;let e=[...i.tableInfo.columns];if(r!==void 0&&(a=e[t])!=null&&a.columns){let i=[...e[t].columns];i[r]=T(T({},i[r]),{},{placeholder:n}),e[t]=T(T({},e[t]),{},{columns:i})}else e[t]=T(T({},e[t]),{},{placeholder:n});return T(T({},i),{},{tableInfo:T(T({},i.tableInfo),{},{columns:e})})}return i}))};return(0,d.jsxs)(`div`,{className:`min-h-screen bg-slate-50 flex flex-col font-sans`,children:[D&&(0,d.jsx)(dx,{headerLogo:o,headerTitle:i,headerSubtitle:a,parseError:Ae,isParsing:Ee,parseStatusText:Oe}),(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col ${O===`left`?`lg:flex-row-reverse`:`lg:flex-row`} overflow-hidden`,children:[(0,d.jsxs)(`main`,{className:`w-full lg:w-[70%] flex flex-col bg-slate-100 border-b lg:border-b-0 ${O===`left`?`lg:border-l`:`lg:border-r`} border-gray-200 overflow-hidden relative`,children:[(0,d.jsx)(wx,{showImportHtml:b,showImportPdf:x,showPreview:C,showExport:w,showExportPdf:E,showClearCanvas:S,customButtonStyles:ne,customButtonClassNames:M,customActionComponents:re,handleHtmlImport:_t,handlePdfImport:vt,setPreviewOpen:V,handleExport:xt,handleExportPdf:St,handleClearCanvas:Ct,zoom:ie,setZoom:ae,setPanOffset:se}),(0,d.jsx)(Cx,{blocks:R,setBlocks:Ue,selectedBlockId:We,setSelectedBlockId:Ge,setActiveTab:st,showMockData:lt,placeholderMockData:gt,dragOverIndex:Ne,setDragOverIndex:Pe,draggedSidebarItem:F,defaultStyles:y,zoom:ie,panOffset:oe,spacePressed:ce,canvasHeight:le,viewportRef:ue,canvasContainerRef:de,handleMouseDown:fe,handleMouseMove:pe,handleMouseUp:me,createTextBlock:qe,duplicateBlock:Ze,reorderBlock:(e,t)=>{t===`up`?z(e):B(e)},handleDeleteBlock:Xe,handleSidebarDrop:e=>{if(!F)return;let t;if(F.type===`table`&&F.tableSchema)t=Je(F.tableSchema);else if(F.type===`image`&&F.imageType)t=Ye(F.imageType);else{let e=`Enter text here...`;F.type===`h1`?e=`Heading 1`:F.type===`h2`?e=`Heading 2`:F.type===`h3`?e=`Heading 3`:F.type===`title`?e=`Document Title`:F.type===`subtitle`?e=`Document Subtitle`:F.type===`caption`&&(e=`Caption text...`),t=qe(F.type,e,y==null?void 0:y[F.type])}Ue(n=>{let r=[...n];return r.splice(e,0,t),r}),Ge(t.id),st(`styles`)},handleTableCellDrop:Tt,updateTableCell:Et,handleTextDrop:wt})]}),(0,d.jsx)(vx,{activeTab:ot,setActiveTab:st,setBlocks:Ue,selectedBlockId:We,setSelectedBlockId:Ge,getSelectedBlock:Ke,defaultStyles:y,createTextBlock:qe,createImageBlock:Ye,updateSelectedStyle:Qe,updateSelectedImageInfo:$e,handleDeleteBlock:Xe,handleRemoveTableColumn:et,handleAddTableColumn:tt,handleUpdateTableColumn:nt,handleReorderTableColumn:rt,handleAddTableRow:it,handleRemoveTableRow:at,schemas:P,toggleSchemaColumn:Be,customTableName:he,setCustomTableName:ge,customLoopStart:_e,setCustomLoopStart:ve,customLoopEnd:ye,setCustomLoopEnd:be,handleAddCustomTable:Re,newColName:xe,setNewColName:Se,newColPlaceholder:Ce,setNewColPlaceholder:we,customImageTypes:Le,newImgTypeName:Fe,setNewImgTypeName:Ie,handleAddCustomImageType:ze,placeholders:t,searchPlaceholder:I,setSearchPlaceholder:L,handleSidebarDragStart:(e,t,n,r)=>{Me({type:t,tableSchema:n,imageType:r}),e.dataTransfer.setData(`source`,`sidebar`),e.dataTransfer.effectAllowed=`copy`},isTablesLoading:A,tablesLoading:ee,isPlaceholdersLoading:j,placeholdersLoading:te,fontSizesState:ut,fontFamiliesState:dt,fontWeightsState:ft,sidebarPosition:O})]}),(0,d.jsx)(Ex,{bubbleCoords:Te,applySelectionFormat:Ve}),(0,d.jsx)(Tx,{previewOpen:ct,setPreviewOpen:V,generateExportHtml:bt})]})}var Ax=kx,jx=new WeakMap;function Mx(e,t){let n=jx.get(e);return n||(n=(0,u.createRoot)(e),jx.set(e,n)),n.render(l.default.createElement(kx,t)),n}function Nx(e){let t=jx.get(e);return t?(t.unmount(),jx.delete(e),!0):!1}exports.HtmlEditor=kx,exports.default=Ax,exports.mountHtmlEditor=Mx,exports.unmountHtmlEditor=Nx;
|