PageSourceSearch

https://whsm.com/_next/static/chunks/51fb665c.a8114ed27035e44f.js

js whsm.com collected 2026-10-07 18:34:35 UTC 376,358 bytes, 2 lines download raw bytes

vendor: 5,067 bytes, line 1
1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{92488:function(t,e,i){i.r(e),i.d(e,{AbortException:function(){return iJ},AnnotationEditorLayer:function(){return iZ},AnnotationEditorParamsType:function(){return i0},AnnotationEditorType:function(){return i1},AnnotationEditorUIManager:function(){return i2},AnnotationLayer:function(){return i5},AnnotationMode:function(){return i3},ColorPicker:function(){return i6},DOMSVGFactory:function(){return i4},DrawLayer:function(){return i9},FeatureTest:function(){return i7},GlobalWorkerOptions:function(){return i8},ImageKind:function(){return st},InvalidPDFException:function(){return se},MissingPDFException:function(){return si},OPS:function(){return ss},OutputScale:function(){return sr},PDFDataRangeTransport:function(){return sn},PDFDateString:function(){return sa},PDFWorker:function(){return so},PasswordResponses:function(){return sl},PermissionFlag:function(){return sh},PixelsPerInch:function(){return sd},RenderingCancelledException:function(){return sc},TextLayer:function(){return su},TouchManager:function(){return sp},UnexpectedResponseException:function(){return sg},Util:function(){return sf},VerbosityLevel:function(){return sm},XfaLayer:function(){return sb},build:function(){return sv},createValidAbsoluteUrl:function(){return sA},fetchData:function(){return sy},getDocument:function(){return sw},getFilenameFromUrl:function(){return s_},getPdfFilenameFromUrl:function(){return sx},getXfaPageViewport:function(){return sE},isDataScheme:function(){return sS},isPdfFile:function(){return sT},noContextMenu:function(){return sC},normalizeUnicode:function(){return sM},setLayerDimensions:function(){return sP},shadow:function(){return sR},stopEvent:function(){return sI},version:function(){return sk}});var s=i(40257),r=i(96434).Buffer,n={9306:(t,e,i)=>{var s=i(4901),r=i(6823),n=TypeError;t.exports=function(t){if(s(t))return t;throw new n(r(t)+" is not a function")}},3506:(t,e,i)=>{var s=i(3925),r=String,n=TypeError;t.exports=function(t){if(s(t))return t;throw new n("Can't set "+r(t)+" as a prototype")}},7080:(t,e,i)=>{var s=i(4402).has;t.exports=function(t){return s(t),t}},679:(t,e,i)=>{var s=i(1625),r=TypeError;t.exports=function(t,e){if(s(e,t))return t;throw new r("Incorrect invocation")}},8551:(t,e,i)=>{var s=i(34),r=String,n=TypeError;t.exports=function(t){if(s(t))return t;throw new n(r(t)+" is not an object")}},7811:t=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7394:(t,e,i)=>{var s=i(4576),r=i(6706),n=i(2195),a=s.ArrayBuffer,o=s.TypeError;t.exports=a&&r(a.prototype,"byteLength","get")||function(t){if("ArrayBuffer"!==n(t))throw new o("ArrayBuffer expected");return t.byteLength}},3238:(t,e,i)=>{var s=i(4576),r=i(7476),n=i(7394),a=s.ArrayBuffer,o=a&&a.prototype,l=o&&r(o.slice);t.exports=function(t){if(0!==n(t)||!l)return!1;try{return l(t,0,0),!1}catch(t){return!0}}},5169:(t,e,i)=>{var s=i(3238),r=TypeError;t.exports=function(t){if(s(t))throw new r("ArrayBuffer is detached");return t}},5636:(t,e,i)=>{var s=i(4576),r=i(9504),n=i(6706),a=i(7696),o=i(5169),l=i(7394),h=i(4483),d=i(1548),c=s.structuredClone,u=s.ArrayBuffer,p=s.DataView,g=Math.min,f=u.prototype,m=p.prototype,b=r(f.slice),v=n(f,"resizable","get"),A=n(f,"maxByteLength","get"),y=r(m.getInt8),w=r(m.setInt8);t.exports=(d||h)&&function(t,e,i){var s,r=l(t),n=void 0===e?r:a(e),f=!v||!v(t);if(o(t),d&&(t=c(t,{transfer:[t]}),r===n&&(i||f)))return t;if(r>=n&&(!i||f))s=b(t,0,n);else{s=new u(n,i&&!f&&A?{maxByteLength:A(t)}:void 0);for(var m=new p(t),_=new p(s),x=g(n,r),E=0;E<x;E++)w(_,E,y(m,E))}return d||h(t),s}},4644:(t,e,i)=>{var s,r,n,a=i(7811),o=i(3724),l=i(4576),h=i(4901),d=i(34),c=i(9297),u=i(6955),p=i(6823),g=i(6699),f=i(6840),m=i(2106),b=i(1625),v=i(2787),A=i(2967),y=i(8227),w=i(3392),_=i(1181),x=_.enforce,E=_.get,S=l.Int8Array,T=S&&S.prototype,C=l.Uint8ClampedArray,M=C&&C.prototype,P=S&&v(S),R=T&&v(T),I=Object.prototype,k=l.TypeError,D=y("toStringTag"),L=w("TYPED_ARRAY_TAG"),F="TypedArrayConstructor",O=a&&!!A&&"Opera"!==u(l.opera),N=!1,B={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},z={BigInt64Array:8,BigUint64Array:8},H=function(t){var e=v(t);if(d(e)){var i=E(e);return i&&c(i,F)?i[F]:H(e)}},j=function(t){if(!d(t))return!1;var e=u(t);return c(B,e)||c(z,e)};for(s in B)(n=(r=l[s])&&r.prototype)?x(n)[F]=r:O=!1;for(s in z)(n=(r=l[s])&&r.prototype)&&(x(n)[F]=r);if((!O||!h(P)||P===Function.prototype)&&(P=function(){throw new k("Incorrect invocation")},O))for(s in B)l[s]&&A(l[s],P);if((!O||!R||R===I)&&(R=P.prototype,O))for(s in B)l[s]&&A(l[s].prototype,R);if(O&&v(M)!==R&&A(M,R),o&&!c(R,D))for(s in N=!0,m(R,D,{configurable:!0,get:function(){return d(this)?this[L]:void 0}}),B)l[s]&&g(l[s],L,s);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:O,TYPED_ARRAY_TAG:N&&L,aTypedArray:function(t){if(j(t))return t;throw new k("Target is not a typed array")},aTypedArrayConstructor:function(t){if(h(t)&&(!A||b(P,t)))return t;throw new k(p(t)+" is not a typed array constructor")}
1,exportTypedArrayMethod:function(t,e,i,s){if(o){if(i)for(var r in B){var n=l[r];if(n&&c(n.prototype,t))try{delete n.prototype[t]}catch(i){try{n.prototype[t]=e}catch(t){}}}(!R[t]||i)&&f(R,t,i?e:O&&T[t]||e,s)}},exportTypedArrayStaticMethod:function(t,e,i){var s,r;if(o){if(A){if(i){for(s in B)if((r=l[s])&&c(r,t))try{delete r[t]}catch(t){}}if(P[t]&&!i)return;try{return f(P,t,i?e:O&&P[t]||e)}catch(t){}}for(s in B)(r=l[s])&&(!r[t]||i)&&f(r,t,e)}},getTypedArrayConstructor:H,isView:function(t){if(!d(t))return!1;var e=u(t);return"DataView"===e||c(B,e)||c(z,e)},isTypedArray:j,TypedArray:P,TypedArrayPrototype:R}},5370:(t,e,i)=>{var s=i(6198);t.exports=function(t,e,i){for(var r=0,n=arguments.length>2?i:s(e),a=new t(n);n>r;)a[r]=e[r++];return a}},9617:(t,e,i)=>{var s=i(5397),r=i(5610),n=i(6198),a=function(t){return function(e,i,a){var o,l=s(e),h=n(l);if(0===h)return!t&&-1;var d=r(a,h);if(t&&i!=i){for(;h>d;)if((o=l[d++])!=o)return!0}else for(;h>d;d++)if((t||d in l)&&l[d]===i)return t||d||0;return!t&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},4527:(t,e,i)=>{var s=i(3724),r=i(4376),n=TypeError,a=Object.getOwnPropertyDescriptor,o=s&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();t.exports=o?function(t,e){if(r(t)&&!a(t,"length").writable)throw new n("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e}},7680:(t,e,i)=>{var s=i(9504);t.exports=s([].slice)},7628:(t,e,i)=>{var s=i(6198);t.exports=function(t,e){for(var i=s(t),r=new e(i),n=0;n<i;n++)r[n]=t[i-n-1];return r}},9928:(t,e,i)=>{var s=i(6198),r=i(1291),n=RangeError;t.exports=function(t,e,i,a){var o=s(t),l=r(i),h=l<0?o+l:l;if(h>=o||h<0)throw new n("Incorrect index");for(var d=new e(o),c=0;c<o;c++)d[c]=c===h?a:t[c];return d}},6319:(t,e,i)=>{var s=i(8551),r=i(9539);t.exports=function(t,e,i,n){try{return n?e(s(i)[0],i[1]):e(i)}catch(e){r(t,"throw",e)}}},2195:(t,e,i)=>{var s=i(9504),r=s({}.toString),n=s("".slice);t.exports=function(t){return n(r(t),8,-1)}},6955:(t,e,i)=>{var s=i(2140),r=i(4901),n=i(2195),a=i(8227)("toStringTag"),o=Object,l="Arguments"===n(function(){return arguments}()),h=function(t,e){try{return t[e]}catch(t){}};t.exports=s?n:function(t){var e,i,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=h(e=o(t),a))?i:l?n(e):"Object"===(s=n(e))&&r(e.callee)?"Arguments":s}},7740:(t,e,i)=>{var s=i(9297),r=i(5031),n=i(7347),a=i(4913);t.exports=function(t,e,i){for(var o=r(e),l=a.f,h=n.f,d=0;d<o.length;d++){var c=o[d];s(t,c)||i&&s(i,c)||l(t,c,h(e,c))}}},2211:(t,e,i)=>{var s=i(9039);t.exports=!s(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})},2529:t=>{t.exports=function(t,e){return{value:t,done:e}}},6699:(t,e,i)=>{var s=i(3724),r=i(4913),n=i(6980);t.exports=s?function(t,e,i){return r.f(t,e,n(1,i))}:function(t,e,i){return t[e]=i,t}},6980:t=>{t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},4659:(t,e,i)=>{var s=i(3724),r=i(4913),n=i(6980);t.exports=function(t,e,i){s?r.f(t,e,n(0,i)):t[e]=i}},2106:(t,e,i)=>{var s=i(283),r=i(4913);t.exports=function(t,e,i){return i.get&&s(i.get,e,{getter:!0}),i.set&&s(i.set,e,{setter:!0}),r.f(t,e,i)}},6840:(t,e,i)=>{var s=i(4901),r=i(4913),n=i(283),a=i(9433);t.exports=function(t,e,i,o){o||(o={});var l=o.enumerable,h=void 0!==o.name?o.name:e;if(s(i)&&n(i,h,o),o.global)l?t[e]=i:a(e,i);else{try{o.unsafe?t[e]&&(l=!0):delete t[e]}catch(t){}l?t[e]=i:r.f(t,e,{value:i,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return t}},6279:(t,e,i)=>{var s=i(6840);t.exports=function(t,e,i){for(var r in e)s(t,r,e[r],i);return t}},9433:(t,e,i)=>{var s=i(4576),r=Object.defineProperty;t.exports=function(t,e){try{r(s,t,{value:e,configurable:!0,writable:!0})}catch(i){s[t]=e}return e}},3724:(t,e,i)=>{var s=i(9039);t.exports=!s(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})},4483:(t,e,i)=>{var s,r,n,a,o=i(4576),l=i(9429),h=i(1548),d=o.structuredClone,c=o.ArrayBuffer,u=o.MessageChannel,p=!1;if(h)p=function(t){d(t,{transfer:[t]})};else if(c)try{!u&&(s=l("worker_threads"))&&(u=s.MessageChannel),u&&(r=new u,n=new c(2),a=function(t){r.port1.postMessage(null,[t])},2===n.byteLength&&(a(n),0===n.byteLength&&(p=a)))}catch(t){}t.exports=p},4055:(t,e,i)=>{var s=i(4576),r=i(34),n=s.document,a=r(n)&&r(n.createElement);t.exports=function(t){return a?n.createElement(t):{}}},6837:t=>{var e=TypeError;t.exports=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}},5002:t=>{t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1}
vendor: 4,148 bytes, line 1
1,NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8727:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},6193:(t,e,i)=>{var s=i(4215);t.exports="NODE"===s},2839:(t,e,i)=>{var s=i(4576).navigator,r=s&&s.userAgent;t.exports=r?String(r):""},9519:(t,e,i)=>{var s,r,n=i(4576),a=i(2839),o=n.process,l=n.Deno,h=o&&o.versions||l&&l.version,d=h&&h.v8;d&&(r=(s=d.split("."))[0]>0&&s[0]<4?1:+(s[0]+s[1])),!r&&a&&(!(s=a.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=a.match(/Chrome\/(\d+)/))&&(r=+s[1]),t.exports=r},4215:(t,e,i)=>{var s=i(4576),r=i(2839),n=i(2195),a=function(t){return r.slice(0,t.length)===t};t.exports=a("Bun/")?"BUN":a("Cloudflare-Workers")?"CLOUDFLARE":a("Deno/")?"DENO":a("Node.js/")?"NODE":s.Bun&&"string"==typeof Bun.version?"BUN":s.Deno&&"object"==typeof Deno.version?"DENO":"process"===n(s.process)?"NODE":s.window&&s.document?"BROWSER":"REST"},8574:(t,e,i)=>{var s=i(9504),r=Error,n=s("".replace),a=String(new r("zxcasd").stack),o=/\n\s*at [^:]*:[^\n]*/,l=o.test(a);t.exports=function(t,e){if(l&&"string"==typeof t&&!r.prepareStackTrace)for(;e--;)t=n(t,o,"");return t}},6518:(t,e,i)=>{var s=i(4576),r=i(7347).f,n=i(6699),a=i(6840),o=i(9433),l=i(7740),h=i(2796);t.exports=function(t,e){var i,d,c,u,p,g=t.target,f=t.global,m=t.stat;if(i=f?s:m?s[g]||o(g,{}):s[g]&&s[g].prototype)for(d in e){if(u=e[d],c=t.dontCallGetSet?(p=r(i,d))&&p.value:i[d],!h(f?d:g+(m?".":"#")+d,t.forced)&&void 0!==c){if(typeof u==typeof c)continue;l(u,c)}(t.sham||c&&c.sham)&&n(u,"sham",!0),a(i,d,u,t)}}},9039:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},8745:(t,e,i)=>{var s=i(616),r=Function.prototype,n=r.apply,a=r.call;t.exports="object"==typeof Reflect&&Reflect.apply||(s?a.bind(n):function(){return a.apply(n,arguments)})},6080:(t,e,i)=>{var s=i(7476),r=i(9306),n=i(616),a=s(s.bind);t.exports=function(t,e){return r(t),void 0===e?t:n?a(t,e):function(){return t.apply(e,arguments)}}},616:(t,e,i)=>{var s=i(9039);t.exports=!s(function(){var t=(function(){}).bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})},9565:(t,e,i)=>{var s=i(616),r=Function.prototype.call;t.exports=s?r.bind(r):function(){return r.apply(r,arguments)}},350:(t,e,i)=>{var s=i(3724),r=i(9297),n=Function.prototype,a=s&&Object.getOwnPropertyDescriptor,o=r(n,"name"),l=o&&(!s||s&&a(n,"name").configurable);t.exports={EXISTS:o,PROPER:o&&"something"===(function(){}).name,CONFIGURABLE:l}},6706:(t,e,i)=>{var s=i(9504),r=i(9306);t.exports=function(t,e,i){try{return s(r(Object.getOwnPropertyDescriptor(t,e)[i]))}catch(t){}}},7476:(t,e,i)=>{var s=i(2195),r=i(9504);t.exports=function(t){if("Function"===s(t))return r(t)}},9504:(t,e,i)=>{var s=i(616),r=Function.prototype,n=r.call,a=s&&r.bind.bind(n,n);t.exports=s?a:function(t){return function(){return n.apply(t,arguments)}}},9429:(t,e,i)=>{var s=i(4576),r=i(6193);t.exports=function(t){if(r){try{return s.process.getBuiltinModule(t)}catch(t){}try{return Function('return require("'+t+'")')()}catch(t){}}}},7751:(t,e,i)=>{var s=i(4576),r=i(4901);t.exports=function(t,e){var i;return arguments.length<2?r(i=s[t])?i:void 0:s[t]&&s[t][e]}},1767:t=>{t.exports=function(t){return{iterator:t,next:t.next,done:!1}}}
vendor: 4,199 bytes, line 1
1,8646:(t,e,i)=>{var s=i(9565),r=i(8551),n=i(1767),a=i(851);t.exports=function(t,e){e&&"string"==typeof t||r(t);var i=a(t);return n(r(void 0!==i?s(i,t):t))}},851:(t,e,i)=>{var s=i(6955),r=i(5966),n=i(4117),a=i(6269),o=i(8227)("iterator");t.exports=function(t){if(!n(t))return r(t,o)||r(t,"@@iterator")||a[s(t)]}},81:(t,e,i)=>{var s=i(9565),r=i(9306),n=i(8551),a=i(6823),o=i(851),l=TypeError;t.exports=function(t,e){var i=arguments.length<2?o(t):e;if(r(i))return n(s(i,t));throw new l(a(t)+" is not iterable")}},5966:(t,e,i)=>{var s=i(9306),r=i(4117);t.exports=function(t,e){var i=t[e];return r(i)?void 0:s(i)}},3789:(t,e,i)=>{var s=i(9306),r=i(8551),n=i(9565),a=i(1291),o=i(1767),l="Invalid size",h=RangeError,d=TypeError,c=Math.max,u=function(t,e){this.set=t,this.size=c(e,0),this.has=s(t.has),this.keys=s(t.keys)};u.prototype={getIterator:function(){return o(r(n(this.keys,this.set)))},includes:function(t){return n(this.has,this.set,t)}},t.exports=function(t){r(t);var e=+t.size;if(e!=e)throw new d(l);var i=a(e);if(i<0)throw new h(l);return new u(t,i)}},4576:function(t){var e=function(t){return t&&t.Math===Math&&t};t.exports=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof global&&global)||e("object"==typeof this&&this)||function(){return this}()||Function("return this")()},9297:(t,e,i)=>{var s=i(9504),r=i(8981),n=s({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return n(r(t),e)}},421:t=>{t.exports={}},397:(t,e,i)=>{var s=i(7751);t.exports=s("document","documentElement")},5917:(t,e,i)=>{var s=i(3724),r=i(9039),n=i(4055);t.exports=!s&&!r(function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a})},7055:(t,e,i)=>{var s=i(9504),r=i(9039),n=i(2195),a=Object,o=s("".split);t.exports=r(function(){return!a("z").propertyIsEnumerable(0)})?function(t){return"String"===n(t)?o(t,""):a(t)}:a},3167:(t,e,i)=>{var s=i(4901),r=i(34),n=i(2967);t.exports=function(t,e,i){var a,o;return n&&s(a=e.constructor)&&a!==i&&r(o=a.prototype)&&o!==i.prototype&&n(t,o),t}},3706:(t,e,i)=>{var s=i(9504),r=i(4901),n=i(7629),a=s(Function.toString);r(n.inspectSource)||(n.inspectSource=function(t){return a(t)}),t.exports=n.inspectSource},1181:(t,e,i)=>{var s,r,n,a=i(8622),o=i(4576),l=i(34),h=i(6699),d=i(9297),c=i(7629),u=i(6119),p=i(421),g="Object already initialized",f=o.TypeError,m=o.WeakMap;if(a||c.state){var b=c.state||(c.state=new m);b.get=b.get,b.has=b.has,b.set=b.set,s=function(t,e){if(b.has(t))throw new f(g);return e.facade=t,b.set(t,e),e},r=function(t){return b.get(t)||{}},n=function(t){return b.has(t)}}else{var v=u("state");p[v]=!0,s=function(t,e){if(d(t,v))throw new f(g);return e.facade=t,h(t,v,e),e},r=function(t){return d(t,v)?t[v]:{}},n=function(t){return d(t,v)}}t.exports={set:s,get:r,has:n,enforce:function(t){return n(t)?r(t):s(t,{})},getterFor:function(t){return function(e){var i;if(!l(e)||(i=r(e)).type!==t)throw new f("Incompatible receiver, "+t+" required");return i}}}},4209:(t,e,i)=>{var s=i(8227),r=i(6269),n=s("iterator"),a=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||a[n]===t)}},4376:(t,e,i)=>{var s=i(2195);t.exports=Array.isArray||function(t){return"Array"===s(t)}},1108:(t,e,i)=>{var s=i(6955);t.exports=function(t){var e=s(t);return"BigInt64Array"===e||"BigUint64Array"===e}},4901:t=>{var e="object"==typeof document&&document.all;t.exports=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(t){return"function"==typeof t}},2796:(t,e,i)=>{var s=i(9039),r=i(4901),n=/#|\.prototype\./,a=function(t,e){var i=l[o(t)];return i===d||i!==h&&(r(e)?s(e):!!e)},o=a.normalize=function(t){return String(t).replace(n,".").toLowerCase()},l=a.data={},h=a.NATIVE="N",d=a.POLYFILL="P";t.exports=a},4117:t=>{t.exports=function(t){return null==t}},34:(t,e,i)=>{var s=i(4901);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},3925:(t,e,i)=>{var s=i(34);t.exports=function(t){return s(t)||null===t}},6395:t=>{t.exports=!1},757:(t,e,i)=>{var s=i(7751),r=i(4901),n=i(1625),a=i(7040),o=Object;t.exports=a?function(t){return"symbol"==typeof t}:function(t){var e=s("Symbol");return r(e)&&n(e.prototype,o(t))}}
1,507:(t,e,i)=>{var s=i(9565);t.exports=function(t,e,i){for(var r,n,a=i?t:t.iterator,o=t.next;!(r=s(o,a)).done;)if(void 0!==(n=e(r.value)))return n}},2652:(t,e,i)=>{var s=i(6080),r=i(9565),n=i(8551),a=i(6823),o=i(4209),l=i(6198),h=i(1625),d=i(81),c=i(851),u=i(9539),p=TypeError,g=function(t,e){this.stopped=t,this.result=e},f=g.prototype;t.exports=function(t,e,i){var m,b,v,A,y,w,_,x=i&&i.that,E=!!(i&&i.AS_ENTRIES),S=!!(i&&i.IS_RECORD),T=!!(i&&i.IS_ITERATOR),C=!!(i&&i.INTERRUPTED),M=s(e,x),P=function(t){return m&&u(m,"normal",t),new g(!0,t)},R=function(t){return E?(n(t),C?M(t[0],t[1],P):M(t[0],t[1])):C?M(t,P):M(t)};if(S)m=t.iterator;else if(T)m=t;else{if(!(b=c(t)))throw new p(a(t)+" is not iterable");if(o(b)){for(v=0,A=l(t);A>v;v++)if((y=R(t[v]))&&h(f,y))return y;return new g(!1)}m=d(t,b)}for(w=S?t.next:m.next;!(_=r(w,m)).done;){try{y=R(_.value)}catch(t){u(m,"throw",t)}if("object"==typeof y&&y&&h(f,y))return y}return new g(!1)}},9539:(t,e,i)=>{var s=i(9565),r=i(8551),n=i(5966);t.exports=function(t,e,i){var a,o;r(t);try{if(!(a=n(t,"return"))){if("throw"===e)throw i;return i}a=s(a,t)}catch(t){o=!0,a=t}if("throw"===e)throw i;if(o)throw a;return r(a),i}},9462:(t,e,i)=>{var s=i(9565),r=i(2360),n=i(6699),a=i(6279),o=i(8227),l=i(1181),h=i(5966),d=i(7657).IteratorPrototype,c=i(2529),u=i(9539),p=o("toStringTag"),g="IteratorHelper",f="WrapForValidIterator",m=l.set,b=function(t){var e=l.getterFor(t?f:g);return a(r(d),{next:function(){var i=e(this);if(t)return i.nextHandler();try{var s=i.done?void 0:i.nextHandler();return c(s,i.done)}catch(t){throw i.done=!0,t}},return:function(){var i=e(this),r=i.iterator;if(i.done=!0,t){var n=h(r,"return");return n?s(n,r):c(void 0,!0)}if(i.inner)try{u(i.inner.iterator,"normal")}catch(t){return u(r,"throw",t)}return r&&u(r,"normal"),c(void 0,!0)}})},v=b(!0),A=b(!1);n(A,p,"Iterator Helper"),t.exports=function(t,e){var i=function(i,s){s?(s.iterator=i.iterator,s.next=i.next):s=i,s.type=e?f:g,s.nextHandler=t,s.counter=0,s.done=!1,m(this,s)};return i.prototype=e?v:A,i}},713:(t,e,i)=>{var s=i(9565),r=i(9306),n=i(8551),a=i(1767),o=i(9462),l=i(6319),h=o(function(){var t=this.iterator,e=n(s(this.next,t));if(!(this.done=!!e.done))return l(t,this.mapper,[e.value,this.counter++],!0)});t.exports=function(t){return n(this),r(t),new h(a(this),{mapper:t})}},7657:(t,e,i)=>{var s,r,n,a=i(9039),o=i(4901),l=i(34),h=i(2360),d=i(2787),c=i(6840),u=i(8227),p=i(6395),g=u("iterator"),f=!1;[].keys&&("next"in(n=[].keys())?(r=d(d(n)))!==Object.prototype&&(s=r):f=!0),!l(s)||a(function(){var t={};return s[g].call(t)!==t})?s={}:p&&(s=h(s)),o(s[g])||c(s,g,function(){return this}),t.exports={IteratorPrototype:s,BUGGY_SAFARI_ITERATORS:f}},6269:t=>{t.exports={}},6198:(t,e,i)=>{var s=i(8014);t.exports=function(t){return s(t.length)}},283:(t,e,i)=>{var s=i(9504),r=i(9039),n=i(4901),a=i(9297),o=i(3724),l=i(350).CONFIGURABLE,h=i(3706),d=i(1181),c=d.enforce,u=d.get,p=String,g=Object.defineProperty,f=s("".slice),m=s("".replace),b=s([].join),v=o&&!r(function(){return 8!==g(function(){},"length",{value:8}).length}),A=String(String).split("String"),y=t.exports=function(t,e,i){"Symbol("===f(p(e),0,7)&&(e="["+m(p(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!a(t,"name")||l&&t.name!==e)&&(o?g(t,"name",{value:e,configurable:!0}):t.name=e),v&&i&&a(i,"arity")&&t.length!==i.arity&&g(t,"length",{value:i.arity});try{i&&a(i,"constructor")&&i.constructor?o&&g(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var s=c(t);return a(s,"source")||(s.source=b(A,"string"==typeof e?e:"")),t};Function.prototype.toString=y(function(){return n(this)&&u(this).source||h(this)},"toString")},741:t=>{var e=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(t){var s=+t;return(s>0?i:e)(s)}},6043:(t,e,i)=>{var s=i(9306),r=TypeError,n=function(t){var e,i;this.promise=new t(function(t,s){if(void 0!==e||void 0!==i)throw new r("Bad Promise constructor");e=t,i=s}),this.resolve=s(e),this.reject=s(i)};t.exports.f=function(t){return new n(t)}},2603:(t,e,i)=>{var s=i(655);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:s(t)}},4149:t=>{var e=RangeError;t.exports=function(t){if(t==t)return t;throw new e("NaN is not allowed")}},2360:(t,e,i)=>{var s,r=i(8551),n=i(6801),a=i(8727),o=i(421),l=i(397),h=i(4055),d=i(6119),c="prototype",u="script",p=d("IE_PROTO"),g=function(){},f=function(t){return"<"+u+">"+t+"</"+u+">"},m=function(t){t.write(f("")),t.close();var e=t.parentWindow.Object;return t=null,e},b=function(){var t,e=h("iframe");return e.style.display="none",l.appendChild(e),e.src=String("java"+u+":"),(t=e.contentWindow.document).open(),t.write(f("document.F=Object")),t.close(),t.F}
vendor: 2,397 bytes, line 1
1,v=function(){try{s=new ActiveXObject("htmlfile")}catch(t){}v="undefined"!=typeof document?document.domain&&s?m(s):b():m(s);for(var t=a.length;t--;)delete v[c][a[t]];return v()};o[p]=!0,t.exports=Object.create||function(t,e){var i;return null!==t?(g[c]=r(t),i=new g,g[c]=null,i[p]=t):i=v(),void 0===e?i:n.f(i,e)}},6801:(t,e,i)=>{var s=i(3724),r=i(8686),n=i(4913),a=i(8551),o=i(5397),l=i(1072);e.f=s&&!r?Object.defineProperties:function(t,e){a(t);for(var i,s=o(e),r=l(e),h=r.length,d=0;h>d;)n.f(t,i=r[d++],s[i]);return t}},4913:(t,e,i)=>{var s=i(3724),r=i(5917),n=i(8686),a=i(8551),o=i(6969),l=TypeError,h=Object.defineProperty,d=Object.getOwnPropertyDescriptor,c="enumerable",u="configurable",p="writable";e.f=s?n?function(t,e,i){if(a(t),e=o(e),a(i),"function"==typeof t&&"prototype"===e&&"value"in i&&p in i&&!i[p]){var s=d(t,e);s&&s[p]&&(t[e]=i.value,i={configurable:u in i?i[u]:s[u],enumerable:c in i?i[c]:s[c],writable:!1})}return h(t,e,i)}:h:function(t,e,i){if(a(t),e=o(e),a(i),r)try{return h(t,e,i)}catch(t){}if("get"in i||"set"in i)throw new l("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},7347:(t,e,i)=>{var s=i(3724),r=i(9565),n=i(8773),a=i(6980),o=i(5397),l=i(6969),h=i(9297),d=i(5917),c=Object.getOwnPropertyDescriptor;e.f=s?c:function(t,e){if(t=o(t),e=l(e),d)try{return c(t,e)}catch(t){}if(h(t,e))return a(!r(n.f,t,e),t[e])}},8480:(t,e,i)=>{var s=i(1828),r=i(8727).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return s(t,r)}},3717:(t,e)=>{e.f=Object.getOwnPropertySymbols},2787:(t,e,i)=>{var s=i(9297),r=i(4901),n=i(8981),a=i(6119),o=i(2211),l=a("IE_PROTO"),h=Object,d=h.prototype;t.exports=o?h.getPrototypeOf:function(t){var e=n(t);if(s(e,l))return e[l];var i=e.constructor;return r(i)&&e instanceof i?i.prototype:e instanceof h?d:null}},1625:(t,e,i)=>{var s=i(9504);t.exports=s({}.isPrototypeOf)},1828:(t,e,i)=>{var s=i(9504),r=i(9297),n=i(5397),a=i(9617).indexOf,o=i(421),l=s([].push);t.exports=function(t,e){var i,s=n(t),h=0,d=[];for(i in s)!r(o,i)&&r(s,i)&&l(d,i);for(;e.length>h;)r(s,i=e[h++])&&(~a(d,i)||l(d,i));return d}},1072:(t,e,i)=>{var s=i(1828),r=i(8727);t.exports=Object.keys||function(t){return s(t,r)}},8773:(t,e)=>{var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,r=s&&!i.call({1:2},1);e.f=r?function(t){var e=s(this,t);return!!e&&e.enumerable}:i},2967:(t,e,i)=>{var s=i(6706),r=i(34),n=i(7750),a=i(3506);
1t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,i={};try{(t=s(Object.prototype,"__proto__","set"))(i,[]),e=i instanceof Array}catch(t){}return function(i,s){return n(i),a(s),r(i)&&(e?t(i,s):i.__proto__=s),i}}():void 0)},4270:(t,e,i)=>{var s=i(9565),r=i(4901),n=i(34),a=TypeError;t.exports=function(t,e){var i,o;if("string"===e&&r(i=t.toString)&&!n(o=s(i,t))||r(i=t.valueOf)&&!n(o=s(i,t))||"string"!==e&&r(i=t.toString)&&!n(o=s(i,t)))return o;throw new a("Can't convert object to primitive value")}},5031:(t,e,i)=>{var s=i(7751),r=i(9504),n=i(8480),a=i(3717),o=i(8551),l=r([].concat);t.exports=s("Reflect","ownKeys")||function(t){var e=n.f(o(t)),i=a.f;return i?l(e,i(t)):e}},8235:(t,e,i)=>{var s=i(9504),r=i(9297),n=SyntaxError,a=parseInt,o=String.fromCharCode,l=s("".charAt),h=s("".slice),d=s(/./.exec),c={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":"\n","\\r":"\r","\\t":"	"},u=/^[\da-f]{4}$/i,p=/^[\u0000-\u001F]$/;t.exports=function(t,e){for(var i=!0,s="";e<t.length;){var g=l(t,e);if("\\"===g){var f=h(t,e,e+2);if(r(c,f))s+=c[f],e+=2;else if("\\u"===f){var m=h(t,e+=2,e+4);if(!d(u,m))throw new n("Bad Unicode escape at: "+e);s+=o(a(m,16)),e+=4}else throw new n('Unknown escape sequence: "'+f+'"')}else if('"'===g){i=!1,e++;break}else{if(d(p,g))throw new n("Bad control character in string literal at: "+e);s+=g,e++}}if(i)throw new n("Unterminated string at: "+e);return{value:s,end:e}}},1103:t=>{t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},7750:(t,e,i)=>{var s=i(4117),r=TypeError;t.exports=function(t){if(s(t))throw new r("Can't call method on "+t);return t}},9286:(t,e,i)=>{var s=i(4402),r=i(8469),n=s.Set,a=s.add;t.exports=function(t){var e=new n;return r(t,function(t){a(e,t)}),e}},3440:(t,e,i)=>{var s=i(7080),r=i(4402),n=i(9286),a=i(5170),o=i(3789),l=i(8469),h=i(507),d=r.has,c=r.remove;t.exports=function(t){var e=s(this),i=o(t),r=n(e);return a(e)<=i.size?l(e,function(t){i.includes(t)&&c(r,t)}):h(i.getIterator(),function(t){d(e,t)&&c(r,t)}),r}},4402:(t,e,i)=>{var s=i(9504),r=Set.prototype;t.exports={Set:Set,add:s(r.add),has:s(r.has),remove:s(r.delete),proto:r}},8750:(t,e,i)=>{var s=i(7080),r=i(4402),n=i(5170),a=i(3789),o=i(8469),l=i(507),h=r.Set,d=r.add,c=r.has;t.exports=function(t){var e=s(this),i=a(t),r=new h;return n(e)>i.size?l(i.getIterator(),function(t){c(e,t)&&d(r,t)}):o(e,function(t){i.includes(t)&&d(r,t)}),r}},4449:(t,e,i)=>{var s=i(7080),r=i(4402).has,n=i(5170),a=i(3789),o=i(8469),l=i(507),h=i(9539);t.exports=function(t){var e=s(this),i=a(t);if(n(e)<=i.size)return!1!==o(e,function(t){if(i.includes(t))return!1},!0);var d=i.getIterator();return!1!==l(d,function(t){if(r(e,t))return h(d,"normal",!1)})}},3838:(t,e,i)=>{var s=i(7080),r=i(5170),n=i(8469),a=i(3789);t.exports=function(t){var e=s(this),i=a(t);return!(r(e)>i.size)&&!1!==n(e,function(t){if(!i.includes(t))return!1},!0)}},8527:(t,e,i)=>{var s=i(7080),r=i(4402).has,n=i(5170),a=i(3789),o=i(507),l=i(9539);t.exports=function(t){var e=s(this),i=a(t);if(n(e)<i.size)return!1;var h=i.getIterator();return!1!==o(h,function(t){if(!r(e,t))return l(h,"normal",!1)})}},8469:(t,e,i)=>{var s=i(9504),r=i(507),n=i(4402),a=n.Set,o=n.proto,l=s(o.forEach),h=s(o.keys),d=h(new a).next;t.exports=function(t,e,i){return i?r({iterator:h(t),next:d},e):l(t,e)}},4916:(t,e,i)=>{var s=i(7751),r=function(t){return{size:t,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}};t.exports=function(t){var e=s("Set");try{new e()[t](r(0));try{return new e()[t](r(-1)),!1}catch(t){return!0}}catch(t){return!1}}},5170:(t,e,i)=>{var s=i(6706),r=i(4402);t.exports=s(r.proto,"size","get")||function(t){return t.size}},3650:(t,e,i)=>{var s=i(7080),r=i(4402),n=i(9286),a=i(3789),o=i(507),l=r.add,h=r.has,d=r.remove;t.exports=function(t){var e=s(this),i=a(t).getIterator(),r=n(e);return o(i,function(t){h(e,t)?d(r,t):l(r,t)}),r}},4204:(t,e,i)=>{var s=i(7080),r=i(4402).add,n=i(9286),a=i(3789),o=i(507);t.exports=function(t){var e=s(this),i=a(t).getIterator(),l=n(e);return o(i,function(t){r(l,t)}),l}},6119:(t,e,i)=>{var s=i(5745),r=i(3392),n=s("keys");t.exports=function(t){return n[t]||(n[t]=r(t))}},7629:(t,e,i)=>{var s=i(6395),r=i(4576),n=i(9433),a="__core-js_shared__",o=t.exports=r[a]||n(a,{});(o.versions||(o.versions=[])).push({version:"3.39.0",mode:s?"pure":"global",copyright:"\xa9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745:(t,e,i)=>{var s=i(7629);t.exports=function(t,e){return s[t]||(s[t]=e||{})}},1548:(t,e,i)=>{var s=i(4576),r=i(9039),n=i(9519),a=i(4215),o=s.structuredClone;t.exports=!!o&&!r(function(){if("DENO"===a&&n>92||"NODE"===a&&n>94||"BROWSER"===a&&n>97)return!1;var t=new ArrayBuffer(8),e=o(t,{transfer:[t]});return 0!==t.byteLength||8!==e.byteLength})},4495:(t,e,i)=>{var s=i(9519),r=i(9039),n=i(4576).String;t.exports=!!Object.getOwnPropertySymbols&&!r(function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t) instanceof Symbol)||!Symbol.sham&&s&&s<41})},5610:(t,e,i)=>{var s=i(1291),r=Math.max,n=Math.min;t.exports=function(t,e){var i=s(t);return i<0?r(i+e,0):n(i,e)}},5854:(t,e,i)=>{var s=i(2777),r=TypeError;t.exports=function(t){var e=s(t,"number");if("number"==typeof e)throw new r("Can't convert number to bigint");return BigInt(e)}},7696:(t,e,i)=>{var s=i(1291),r=i(8014),n=RangeError;t.exports=function(t){if(void 0===t)return 0;var e=s(t),i=r(e);
1if(e!==i)throw new n("Wrong length or index");return i}},5397:(t,e,i)=>{var s=i(7055),r=i(7750);t.exports=function(t){return s(r(t))}},1291:(t,e,i)=>{var s=i(741);t.exports=function(t){var e=+t;return e!=e||0===e?0:s(e)}},8014:(t,e,i)=>{var s=i(1291),r=Math.min;t.exports=function(t){var e=s(t);return e>0?r(e,9007199254740991):0}},8981:(t,e,i)=>{var s=i(7750),r=Object;t.exports=function(t){return r(s(t))}},9590:(t,e,i)=>{var s=i(1291),r=RangeError;t.exports=function(t){var e=s(t);if(e<0)throw new r("The argument can't be less than 0");return e}},2777:(t,e,i)=>{var s=i(9565),r=i(34),n=i(757),a=i(5966),o=i(4270),l=i(8227),h=TypeError,d=l("toPrimitive");t.exports=function(t,e){if(!r(t)||n(t))return t;var i,l=a(t,d);if(l){if(void 0===e&&(e="default"),!r(i=s(l,t,e))||n(i))return i;throw new h("Can't convert object to primitive value")}return void 0===e&&(e="number"),o(t,e)}},6969:(t,e,i)=>{var s=i(2777),r=i(757);t.exports=function(t){var e=s(t,"string");return r(e)?e:e+""}},2140:(t,e,i)=>{var s=i(8227)("toStringTag"),r={};r[s]="z",t.exports="[object z]"===String(r)},655:(t,e,i)=>{var s=i(6955),r=String;t.exports=function(t){if("Symbol"===s(t))throw TypeError("Cannot convert a Symbol value to a string");return r(t)}},6823:t=>{var e=String;t.exports=function(t){try{return e(t)}catch(t){return"Object"}}},3392:(t,e,i)=>{var s=i(9504),r=0,n=Math.random(),a=s(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+a(++r+n,36)}}
1,7040:(t,e,i)=>{var s=i(4495);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},8686:(t,e,i)=>{var s=i(3724),r=i(9039);t.exports=s&&r(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})},2812:t=>{var e=TypeError;t.exports=function(t,i){if(t<i)throw new e("Not enough arguments");return t}},8622:(t,e,i)=>{var s=i(4576),r=i(4901),n=s.WeakMap;t.exports=r(n)&&/native code/.test(String(n))},8227:(t,e,i)=>{var s=i(4576),r=i(5745),n=i(9297),a=i(3392),o=i(4495),l=i(7040),h=s.Symbol,d=r("wks"),c=l?h.for||h:h&&h.withoutSetter||a;t.exports=function(t){return n(d,t)||(d[t]=o&&n(h,t)?h[t]:c("Symbol."+t)),d[t]}},6573:(t,e,i)=>{var s=i(3724),r=i(2106),n=i(3238),a=ArrayBuffer.prototype;!s||"detached"in a||r(a,"detached",{configurable:!0,get:function(){return n(this)}})},7936:(t,e,i)=>{var s=i(6518),r=i(5636);r&&s({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return r(this,arguments.length?arguments[0]:void 0,!1)}})},8100:(t,e,i)=>{var s=i(6518),r=i(5636);r&&s({target:"ArrayBuffer",proto:!0},{transfer:function(){return r(this,arguments.length?arguments[0]:void 0,!0)}})},4114:(t,e,i)=>{var s=i(6518),r=i(8981),n=i(6198),a=i(4527),o=i(6837);s({target:"Array",proto:!0,arity:1,forced:i(9039)(function(){return 4294967297!==[].push.call({length:4294967296},1)})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(t){return t instanceof TypeError}}()},{push:function(t){var e=r(this),i=n(e),s=arguments.length;o(i+s);for(var l=0;l<s;l++)e[i]=arguments[l],i++;return a(e,i),i}})},8111:(t,e,i)=>{var s=i(6518),r=i(4576),n=i(679),a=i(8551),o=i(4901),l=i(2787),h=i(2106),d=i(4659),c=i(9039),u=i(9297),p=i(8227),g=i(7657).IteratorPrototype,f=i(3724),m=i(6395),b="constructor",v="Iterator",A=p("toStringTag"),y=TypeError,w=r[v],_=m||!o(w)||w.prototype!==g||!c(function(){w({})}),x=function(){if(n(this,g),l(this)===g)throw new y("Abstract class Iterator not directly constructable")},E=function(t,e){f?h(g,t,{configurable:!0,get:function(){return e},set:function(e){if(a(this),this===g)throw new y("You can't redefine this property");u(this,t)?this[t]=e:d(this,t,e)}}):g[t]=e};u(g,A)||E(A,v),(_||!u(g,b)||g[b]===Object)&&E(b,x),x.prototype=g,s({global:!0,constructor:!0,forced:_},{Iterator:x})},9314:(t,e,i)=>{var s=i(6518),r=i(9565),n=i(8551),a=i(1767),o=i(4149),l=i(9590),h=i(9462),d=i(6395),c=h(function(){for(var t,e=this.iterator,i=this.next;this.remaining;)if(this.remaining--,t=n(r(i,e)),this.done=!!t.done)return;if(t=n(r(i,e)),!(this.done=!!t.done))return t.value});s({target:"Iterator",proto:!0,real:!0,forced:d},{drop:function(t){n(this);var e=l(o(+t));return new c(a(this),{remaining:e})}})},1148:(t,e,i)=>{var s=i(6518),r=i(2652),n=i(9306),a=i(8551),o=i(1767);s({target:"Iterator",proto:!0,real:!0},{every:function(t){a(this),n(t);var e=o(this),i=0;return!r(e,function(e,s){if(!t(e,i++))return s()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489:(t,e,i)=>{var s=i(6518),r=i(9565),n=i(9306),a=i(8551),o=i(1767),l=i(9462),h=i(6319),d=i(6395),c=l(function(){for(var t,e,i=this.iterator,s=this.predicate,n=this.next;;){if(t=a(r(n,i)),this.done=!!t.done)return;if(h(i,s,[e=t.value,this.counter++],!0))return e}});s({target:"Iterator",proto:!0,real:!0,forced:d},{filter:function(t){return a(this),n(t),new c(o(this),{predicate:t})}})},531:(t,e,i)=>{var s=i(6518),r=i(9565),n=i(9306),a=i(8551),o=i(1767),l=i(8646),h=i(9462),d=i(9539),c=i(6395),u=h(function(){for(var t,e,i=this.iterator,s=this.mapper;;){if(e=this.inner)try{if(!(t=a(r(e.next,e.iterator))).done)return t.value;this.inner=null}catch(t){d(i,"throw",t)}if(t=a(r(this.next,i)),this.done=!!t.done)return;try{this.inner=l(s(t.value,this.counter++),!1)}catch(t){d(i,"throw",t)}}});s({target:"Iterator",proto:!0,real:!0,forced:c},{flatMap:function(t){return a(this),n(t),new u(o(this),{mapper:t,inner:null})}})},1701:(t,e,i)=>{var s=i(6518),r=i(713);s({target:"Iterator",proto:!0,real:!0,forced:i(6395)},{map:r})},3579:(t,e,i)=>{var s=i(6518),r=i(2652),n=i(9306),a=i(8551),o=i(1767);s({target:"Iterator",proto:!0,real:!0},{some:function(t){a(this),n(t);var e=o(this),i=0;return r(e,function(e,s){if(t(e,i++))return s()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},1689:(t,e,i)=>{var s=i(6518),r=i(4576),n=i(8745),a=i(7680),o=i(6043),l=i(9306),h=i(1103),d=r.Promise,c=!1;s({target:"Promise",stat:!0,forced:!d||!d.try||h(function(){d.try(function(t){c=8===t},8)}).error||!c},{try:function(t){var e=arguments.length>
11?a(arguments,1):[],i=o.f(this),s=h(function(){return n(l(t),void 0,e)});return(s.error?i.reject:i.resolve)(s.value),i.promise}})},4628:(t,e,i)=>{var s=i(6518),r=i(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var t=r.f(this);return{promise:t.promise,resolve:t.resolve,reject:t.reject}}})},7642:(t,e,i)=>{var s=i(6518),r=i(3440);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("difference")},{difference:r})},8004:(t,e,i)=>{var s=i(6518),r=i(9039),n=i(8750);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("intersection")||r(function(){return"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))})},{intersection:n})},3853:(t,e,i)=>{var s=i(6518),r=i(4449);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isDisjointFrom")},{isDisjointFrom:r})},5876:(t,e,i)=>{var s=i(6518),r=i(3838);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSubsetOf")},{isSubsetOf:r})},2475:(t,e,i)=>{var s=i(6518),r=i(8527);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSupersetOf")},{isSupersetOf:r})},5024:(t,e,i)=>{var s=i(6518),r=i(3650);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("symmetricDifference")},{symmetricDifference:r})},1698:(t,e,i)=>{var s=i(6518),r=i(4204);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("union")},{union:r})},7467:(t,e,i)=>{var s=i(7628),r=i(4644),n=r.aTypedArray,a=r.exportTypedArrayMethod,o=r.getTypedArrayConstructor;a("toReversed",function(){return s(n(this),o(this))})},4732:(t,e,i)=>{var s=i(4644),r=i(9504),n=i(9306),a=i(5370),o=s.aTypedArray,l=s.getTypedArrayConstructor,h=s.exportTypedArrayMethod,d=r(s.TypedArrayPrototype.sort);h("toSorted",function(t){void 0!==t&&n(t);var e=o(this);return d(a(l(e),e),t)})},9577:(t,e,i)=>{var s=i(9928),r=i(4644),n=i(1108),a=i(1291),o=i(5854),l=r.aTypedArray,h=r.getTypedArrayConstructor;(0,r.exportTypedArrayMethod)("with",{with:function(t,e){var i=l(this),r=a(t),d=n(i)?o(e):+e;return s(i,h(i),r,d)}}.with,!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(t){return 8===t}}())},8992:(t,e,i)=>{i(8111)},4743:(t,e,i)=>{i(9314)},3215:(t,e,i)=>{i(1148)},4520:(t,e,i)=>{i(2489)},670:(t,e,i)=>{i(531)},1454:(t,e,i)=>{i(1701)},7550:(t,e,i)=>{i(3579)},8335:(t,e,i)=>{var s=i(6518),r=i(3724),n=i(4576),a=i(7751),o=i(9504),l=i(9565),h=i(4901),d=i(34),c=i(4376),u=i(9297),p=i(655),g=i(6198),f=i(4659),m=i(9039),b=i(8235),v=i(4495),A=n.JSON,y=n.Number,w=n.SyntaxError,_=A&&A.parse,x=a("Object","keys"),E=Object.getOwnPropertyDescriptor,S=o("".charAt),T=o("".slice),C=o(/./.exec),M=o([].push),P=/^\d$/,R=/^[1-9]$/,I=/^[\d-]$/,k=/^[\t\n\r ]$/,D=function(t,e){var i=new N(t=p(t),0,""),s=i.parse(),r=s.value,n=i.skip(k,s.end);if(n<t.length)throw new w('Unexpected extra character: "'+S(t,n)+'" after the parsed data at: '+n);return h(e)?L({"":r},"",e,s):r},L=function(t,e,i,s){var r,n,a,o,h,p=t[e],f=s&&p===s.value,m=f&&"string"==typeof s.source?{source:s.source}:{};if(d(p)){var b=c(p),v=f?s.nodes:b?[]:{};if(b)for(o=0,r=v.length,a=g(p);o<a;o++)F(p,o,L(p,""+o,i,o<r?v[o]:void 0));else for(o=0,a=g(n=x(p));o<a;o++)F(p,h=n[o],L(p,h,i,u(v,h)?v[h]:void 0))}return l(i,t,e,p,m)},F=function(t,e,i){if(r){var s=E(t,e);if(s&&!s.configurable)return}void 0===i?delete t[e]:f(t,e,i)},O=function(t,e,i,s){this.value=t,this.end=e,this.source=i,this.nodes=s},N=function(t,e){this.source=t,this.index=e};N.prototype={fork:function(t){return new N(this.source,t)},parse:function(){var t=this.source,e=this.skip(k,this.index),i=this.fork(e),s=S(t,e);if(C(I,s))return i.number();switch(s){case"{":return i.object();case"[":return i.array();case'"':return i.string();case"t":return i.keyword(!0);case"f":return i.keyword(!1);case"n":return i.keyword(null)}throw new w('Unexpected character: "'+s+'" at: '+e)},node:function(t,e,i,s,r){return new O(e,s,t?null:T(this.source,i,s),r)},object:function(){for(var t=this.source,e=this.index+1,i=!1,s={},r={};e<t.length;){if("}"===S(t,e=this.until(['"',"}"],e))&&!i){e++;break}var n=this.fork(e).string(),a=n.value;e=n.end,e=this.until([":"],e)+1,e=this.skip(k,e),f(r,a,n=this.fork(e).parse()),f(s,a,n.value);var o=S(t,e=this.until([",","}"],n.end));if(","===o)i=!0,e++;else if("}"===o){e++;break}}return this.node(1,s,this.index,e,r)},array:function(){for(var t=this.source,e=this.index+1,i=!1,s=[],r=[];e<t.length;){if("]"===S(t,e=this.skip(k,e))&&!i){e++;break}var n=this.fork(e).parse();if(M(r,n),M(s,n.value),","===S(t,e=this.until([",","]"],n.end)))i=!0,e++;else if("]"===S(t,e)){e++;break}}return this.node(1,s,this.index,e,r)},string:function(){var t=this.index,e=b(this.source,this.index+1);return this.node(0,e.value,t,e.end)},number:function(){var t=this.source,e=this.index,i=e;if("-"===S(t,i)&&i++,"0"===S(t,i))i++;else if(C(R,S(t,i)))i=this.skip(P,i+1);else throw new w("Failed to parse number at: "+i);if("."===S(t,i)&&(i=this.skip(P,i+1)),("e"===S(t,i)||"E"===S(t,i))&&(("+"===S(t,++i)||"-"===S(t,i))&&i++,i===(i=this.skip(P,i))))throw new w("Failed to parse number's exponent value at: "+i);return this.node(0,y(T(t,e,i)),e,i)},keyword:function(t){var e=""+t,i=this.index,s=i+e.length;if(T(this.source,i,s)!==e)throw new w("Failed to parse value at: "+i);return this.node(0,t,i,s)},skip:function(t,e){for(var i=this.source;e<i.length&&C(t,S(i,e));e++);return e},until:function(t,e){e=this.skip(k,e);for(var i=S(this.source,e),s=0;s<t.length;s++)if(t[s]===i)return e;throw new w('Unexpected character: "'+i+'" at: '+e)}};var B=m(function(){var t,e="9007199254740993";return _(e,function(e,i,s){t=s.source}),t!==e}),z=v&&!m(function(){return 1/_("-0 	")!=-1/0});s({target:"JSON",stat:!0,forced:B},{parse:function(t,e){return z&&!h(e)?_(t):D(t,e)}})},5247:(t,e,i)=>{i(1689)},4979:(t,e,i)=>{var s=i(6518),r=i(4576),n=i(7751),a=i(6980),o=i(4913).f,l=i(9297),h=i(679),d=i(3167),c=i(2603),u=i(5002),p=i(8574),g=i(3724),f=i(6395),m="DOMException",b=n("Error"),v=n(m),A=function(){h(this,y);var t=arguments.length,e=c(t<1?void 0:arguments[0]),i=c(t<2?void 0:arguments[1],"Error"),s=new v(e,i),r=new b(e);return r.name=m,o(s,"stack",a(1,p(r.stack,1))),d(s,this,A),s},y=A.prototype=v.prototype,w="stack"in new b(m),_="stack"in new v(1,2),x=v&&g&&Object.getOwnPropertyDescriptor(r,m),E=!!x&&!(x.writable&&x.configurable),S=w&&!E&&!_;s({global:!0,constructor:!0,forced:f||S},{DOMException:S?A:v});var T=n(m),C=T.prototype;if(C.constructor!==T){for(var M in f||o(C,"constructor",a(1,T)),u)if(l(u,M)){var P=u[M],R=P.s;l(T,R)||o(T,R,a(6,P.c))}}},4603:(t,e,i)=>{var s=i(6840),r=i(9504),n=i(655),a=i(2812),o=URLSearchParams,l=o.prototype,h=r(l.append),d=r(l.delete),c=r(l.forEach),u=r([].push),p=new o("a=1&a=2&b=3");p.delete("a",1),p.delete("b",void 0),p+""!="a=2"&&s(l,"delete",function(t){var e,i=arguments.length,s=i<2?void 0:arguments[1];if(i&&void 0===s)return d(this,t);var r=[];c(this,function(t,e){u(r,{key:e,value:t})}),a(i,1);for(var o=n(t),l=n(s),p=0,g=0,f=!1,m=r.length;p<m;)e=r[p++],f||e.key===o?(f=!0,d(this,e.key)):g++;for(;g<m;)(e=r[g++]).key===o&&e.value===l||h(this,e.key,e.value)},{enumerable:!0,unsafe:!0})},7566:(t,e,i)=>{var s=i(6840),r=i(9504),n=i(655),a=i(2812),o=URLSearchParams,l=o.prototype,h=r(l.getAll),d=r(l.has),c=new o("a=1");(c.has("a",2)||!c.has("a",void 0))&&s(l,"has",function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return d(this,t);var s=h(this,t);a(e,1);for(var r=n(i),o=0;o<s.length;)if(s[o++]===r)return!0;return!1},{enumerable:!0,unsafe:!0})}
1,8721:(t,e,i)=>{var s=i(3724),r=i(9504),n=i(2106),a=URLSearchParams.prototype,o=r(a.forEach);!s||"size"in a||n(a,"size",{get:function(){var t=0;return o(this,function(){t++}),t},configurable:!0,enumerable:!0})}},a={};function o(t){var e=a[t];if(void 0!==e)return e.exports;var i=a[t]={exports:{}};return n[t].call(i.exports,i,i.exports,o),i.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var l=globalThis.pdfjsLib={};o.d(l,{AbortException:()=>B,AnnotationEditorLayer:()=>iY,AnnotationEditorParamsType:()=>f,AnnotationEditorType:()=>g,AnnotationEditorUIManager:()=>tx,AnnotationLayer:()=>iI,AnnotationMode:()=>p,ColorPicker:()=>ij,DOMSVGFactory:()=>e7,DrawLayer:()=>iQ,FeatureTest:()=>U,GlobalWorkerOptions:()=>ed,ImageKind:()=>v,InvalidPDFException:()=>L,MissingPDFException:()=>F,OPS:()=>_,OutputScale:()=>tg,PDFDataRangeTransport:()=>eW,PDFDateString:()=>tl,PDFWorker:()=>eY,PasswordResponses:()=>x,PermissionFlag:()=>m,PixelsPerInch:()=>Y,RenderingCancelledException:()=>Z,TextLayer:()=>eN,TouchManager:()=>tS,UnexpectedResponseException:()=>O,Util:()=>G,VerbosityLevel:()=>w,XfaLayer:()=>e8,build:()=>e5,createValidAbsoluteUrl:()=>P,fetchData:()=>Q,getDocument:()=>e$,getFilenameFromUrl:()=>ti,getPdfFilenameFromUrl:()=>ts,getXfaPageViewport:()=>th,isDataScheme:()=>tt,isPdfFile:()=>te,noContextMenu:()=>ta,normalizeUnicode:()=>q,setLayerDimensions:()=>tp,shadow:()=>R,stopEvent:()=>to,version:()=>e2}),o(4114),o(6573),o(8100),o(7936),o(7467),o(4732),o(9577),o(5247),o(4979),o(4603),o(7566),o(8721);let h="object"==typeof s&&s+""=="[object process]"&&!s.versions.nw&&!(s.versions.electron&&s.type&&"browser"!==s.type),d=[1,0,0,1,0,0],c=[.001,0,0,.001,0,0],u={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},p={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},g={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},f={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},m={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},b={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},v={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},A={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,WIDGET:20},y={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},w={ERRORS:0,WARNINGS:1,INFOS:5},_={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},x={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},E=w.WARNINGS;function S(t){E>=w.INFOS&&console.log(`Info: ${t}`)}function T(t){E>=w.WARNINGS&&console.log(`Warning: ${t}`)}function C(t){throw Error(t)}function M(t,e){t||C(e)}function P(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let r=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch{}return null}function R(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let I=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class k extends I{constructor(t,e){super(t,"PasswordException"),this.code=e}}class D extends I{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class L extends I{constructor(t){super(t,"InvalidPDFException")}}class F extends I{constructor(t){super(t,"MissingPDFException")}}class O extends I{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class N extends I{constructor(t){super(t,"FormatError")}}class B extends I{constructor(t){super(t,"AbortException")}}function z(t){("object"!=typeof t||t?.length===void 0)&&C("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let r=Math.min(s+8192,e),n=t.subarray(s,r);i.push(String.fromCharCode.apply(null,n))}return i.join("")}function H(t){"string"!=typeof t&&C("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function j(t){let e=Object.create(null);for(let[i,s]of t)e[i]=s;return e}class U{static get isLittleEndian(){return R(this,"isLittleEndian",function(){let t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return R(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return R(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return R(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?R(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):R(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return R(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let $=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class G{static makeHexColor(t,e,i){return`#${$[t]}${$[e]}${$[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){let i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){let i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),r=this.applyTransform([t[0],t[3]],e),n=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],r[0],n[0]),Math.min(i[1],s[1],r[1],n[1]),Math.max(i[0],s[0],r[0],n[0]),Math.max(i[1],s[1],r[1],n[1])]}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){let e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],r=t[2]*e[0]+t[3]*e[2],n=t[2]*e[1]+t[3]*e[3],a=(i+n)/2,o=Math.sqrt((i+n)**2-4*(i*n-r*s))/2;return[Math.sqrt(a+o||1),Math.sqrt(a-o||1)]}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;let r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),n=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>n?null:[i,r,s,n]}static #t(t,e,i,s,r,n,a,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*r+3*l*n)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,r,n,a,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,r,n,a,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,r,n,a,o,(-h+p)/g,c),this.#t(t,e,i,s,r,n,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,r,n,a,o,l){return l?(l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,i,r,a,e,
1s,n,o,3*(-t+3*(i-r)+a),6*(t-2*i+r),3*(i-t),l),this.#e(t,i,r,a,e,s,n,o,3*(-e+3*(s-n)+o),6*(e-2*s+n),3*(s-e),l),l}}let V=null,W=null;function q(t){return V||(V=/([\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,W=new Map([["ſt","ſt"]])),t.replaceAll(V,(t,e,i)=>e?e.normalize("NFKC"):W.get(i))}let X="pdfjs_internal_id_";o(4628),o(7642),o(8004),o(3853),o(5876),o(2475),o(5024),o(1698),o(1454),o(8992),o(4743),o(3215),o(7550),o(8335);let K="http://www.w3.org/2000/svg";class Y{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Q(t,e="text"){if(tn(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType=e,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){switch(e){case"arraybuffer":case"blob":case"json":i(r.response);return}i(r.responseText);return}s(Error(r.statusText))}},r.send(null)})}class J{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:r=0,offsetY:n=0,dontFlip:a=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=r,this.offsetY=n,i*=e;let f=(t[2]+t[0])/2,m=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(h=-h,d=-d),0===o?(c=Math.abs(m-t[1])*i+r,u=Math.abs(f-t[0])*i+n,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(f-t[0])*i+r,u=Math.abs(m-t[1])*i+n,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*f-h*i*m,u-l*i*f-d*i*m],this.width=p,this.height=g}get rawDims(){let{userUnit:t,viewBox:e}=this,i=e.map(e=>e*t);return R(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:r=!1}={}){return new J({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}convertToViewportPoint(t,e){return G.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=G.applyTransform([t[0],t[1]],this.transform),i=G.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return G.applyInverseTransform([t,e],this.transform)}}class Z extends I{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function tt(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function te(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function ti(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function ts(t,e="document.pdf"){if("string"!=typeof t)return e;if(tt(t))return T('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t),r=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(r&&(r=r[0]).includes("%"))try{r=i.exec(decodeURIComponent(r))[0]}catch{}return r||e}class tr{started=Object.create(null);times=[];time(t){t in this.started&&T(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||T(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:t}of this.times)e=Math.max(t.length,e);for(let{name:i,start:s,end:r}of this.times)t.push(`${i.padEnd(e)} ${r-s}ms
2`);return t.join("")}}function tn(t,e){try{let{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function ta(t){t.preventDefault()}function to(t){t.preventDefault(),t.stopPropagation()}class tl{static #i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#i.exec(t);if(!e)return null;let i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(n+=h,a+=d):"+"===l&&(n-=h,a-=d),new Date(Date.UTC(i,s,r,n,a,o))}}function th(t,{scale:e=1,rotation:i=0}){let{width:s,height:r}=t.attributes.style;
2return new J({viewBox:[0,0,parseInt(s),parseInt(r)],userUnit:1,scale:e,rotation:i})}function td(t){if(t.startsWith("#")){let e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(T(`Not a valid color format: "${t}"`),[0,0,0])}function tc(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform();return[e,i,s,r,n,a]}function tu(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform().invertSelf();return[e,i,s,r,n,a]}function tp(t,e,i=!1,s=!0){if(e instanceof J){let{pageWidth:s,pageHeight:r}=e.rawDims,{style:n}=t,a=U.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${r}px`,h=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(n.width=d,n.height=h):(n.width=h,n.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tg{constructor(){let t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class tf{#s=null;#r=null;#n;#a=null;#o=null;static #l=null;constructor(t){this.#n=t,tf.#l||=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"})}render(){let t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;t.addEventListener("contextmenu",ta,{signal:e}),t.addEventListener("pointerdown",tf.#h,{signal:e});let i=this.#a=document.createElement("div");i.className="buttons",t.append(i);let s=this.#n.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#n._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static #h(t){t.stopPropagation()}#c(t){this.#n._focusEventsAllowed=!1,to(t)}#u(t){this.#n._focusEventsAllowed=!0,to(t)}#p(t){let e=this.#n._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ta,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){let{editorType:t,_uiManager:e}=this.#n,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",tf.#l[t]),this.#p(i),i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#a.append(i)}get #g(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#p(e),this.#a.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#r=t;let e=t.renderButton();this.#p(e),this.#a.prepend(e,this.#g)}remove(){this.#s.remove(),this.#r?.destroy(),this.#r=null}}class tm{#a=null;#s=null;#f;constructor(t){this.#f=t}#m(){let t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",ta,{signal:this.#f._signal});let e=this.#a=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(let r of t){let t=r.y+r.height;if(t<i)continue;let n=r.x+(e?r.width:0);if(t>i){s=n,i=t;continue}e?n>s&&(s=n):n<s&&(s=n)}return[e?1-s:s,i]}show(t,e,i){let[s,r]=this.#v(e,i),{style:n}=this.#s||=this.#m();t.append(this.#s),n.insetInlineEnd=`${100*s}%`,n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){let t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let i=this.#f._signal;t.addEventListener("contextmenu",ta,{signal:i}),t.addEventListener("click",()=>{this.#f.highlightSelection("floating_button")},{signal:i}),this.#a.append(t)}}function tb(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tv{#A=0;get id(){return`pdfjs_internal_editor_${this.#A++}`}}class tA{#y=(function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),z(t)})();#A=0;#w=null;static get _isSVGFittingCanvas(){let t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',R(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async #_(t,e){this.#w||=new Map;let i=this.#w.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#A++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Q(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tA._isSVGFittingCanvas,s=new FileReader,r=new Image,n=new Promise((t,n)=>{r.onload=()=>{i.bitmap=r,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;r.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},r.onerror=s.onerror=n});s.readAsDataURL(t),await n}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){T(t),i=null}return this.#w.set(t,i),i&&this.#w.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:r}=t;return this.#_(`${e}_${i}_${s}_${r}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){let i=await e;return this.#_(t,i)}async getFromId(t){this.#w||=new Map;let e=this.#w.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#w||=new Map;let i=this.#w.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#A++}`,refCounter:1,isSvg:!1},this.#w.set(t,i),this.#w.set(i.id,i),i}getSvgUrl(t){let e=this.#w.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#w||=new Map;let e=this.#w.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class ty{#x=[];#E=!1;#S;#T=-1;constructor(t=128){this.#S=t}add({cmd:t,undo:e,post:i,mustExec:s,type:r=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(s&&t(),this.#E)return;let o={cmd:t,undo:e,post:i,type:r};if(-1===this.#T){this.#x.length>0&&(this.#x.length=0),this.#T=0,this.#x.push(o);return}if(n&&this.#x[this.#T].type===r){a&&(o.undo=this.#x[this.#T].undo),this.#x[this.#T]=o;return}let l=this.#T+1;l===this.#S?this.#x.splice(0,1):(this.#T=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#T)return;this.#E=!0;let{undo:t,post:e}=this.#x[this.#T];t(),e?.(),this.#E=!1,this.#T-=1}redo(){if(this.#T<this.#x.length-1){this.#T+=1,this.#E=!0;let{cmd:t,post:e}=this.#x[this.#T];t(),e?.(),this.#E=!1}}hasSomethingToUndo(){return -1!==this.#T}hasSomethingToRedo(){return this.#T<this.#x.length-1}cleanType(t){if(-1!==this.#T){for(let e=this.#T;e>=0;e--)if(this.#x[e].type!==t){this.#x.splice(e+1,this.#T-e),this.#T=e;return}this.#x.length=0,this.#T=-1}}destroy(){this.#x=null}}class tw{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=U.platform;for(let[i,s,r={}]of t)for(let t of i){let i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:r}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:r}),this.allKeys.add(t.split("+").at(-1)))}}#C(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#C(e));if(!i)return;let{callback:s,options:{bubbles:r=!1,args:n=[],checker:a=null}}=i;(!a||a(t,e))&&(s.bind(t,...n,e)(),r||to(e))}}class t_{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return!function(t){let e=document.createElement("span");for(let i of(e.style.visibility="hidden",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,td(s))}e.remove()}(t),R(this,"_colors",t)}convert(t){let e=td(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return t_._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?G.makeHexColor(...e):t}}class tx{#M=new AbortController;#P=null;#R=new Map;#I=new Map;#k=null;#D=null;#L=null;#F=new ty;#O=null;#N=null;#B=0;#z=new Set;#H=null;#j=null;#U=new Set;_editorUndoBar=null;#$=!1;#G=!1;#V=!1;#W=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new tv;#Z=!1;#tt=!1;#te=null;#ti=null;#ts=null;#tr=null;#tn=g.NONE;#ta=new Set;#to=null;#tl=null;#th=null;#td={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#tc=[0,0];#tu=null;#tp=null;#tg=null;#tf=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tx.prototype,e=t=>t.#tp.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>
2{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return R(this,"_keyboardManager",new tw([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["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:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tp.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tp.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,i,s,r,n,a,o,l,h,d,c,u){let p=this._signal=this.#M.signal;this.#tp=t,this.#tg=e,this.#k=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:p}),this.#tm(),this.#tb(),this.#tv(),this.#D=r.annotationStorage,this.#W=r.filterFactory,this.#tl=n,this.#K=a||null,this.#$=o,this.#G=l,this.#V=h,this.#tr=d||null,this.viewParameters={realScale:Y.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null,this._supportsPinchToZoom=!1!==u}destroy(){for(let t of(this.#tf?.resolve(),this.#tf=null,this.#M?.abort(),this.#M=null,this._signal=null,this.#I.values()))t.destroy();this.#I.clear(),this.#R.clear(),this.#U.clear(),this.#P=null,this.#ta.clear(),this.#F.destroy(),this.#k?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#tu&&(clearTimeout(this.#tu),this.#tu=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#tr}get useNewAltTextFlow(){return this.#G}get useNewAltTextWhenAddingImage(){return this.#V}get hcmFilter(){return R(this,"hcmFilter",this.#tl?this.#W.addHCMFilter(this.#tl.foreground,this.#tl.background):"none")}get direction(){return R(this,"direction",getComputedStyle(this.#tp).direction)}get highlightColors(){return R(this,"highlightColors",this.#K?new Map(this.#K.split(",").map(t=>t.split("=").map(t=>t.trim()))):null)}get highlightColorNames(){return R(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#N=t}setMainHighlightColorPicker(t){this.#ts=t}editAltText(t,e=!1){this.#k?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){"enableNewAltTextWhenAddingImage"===t&&(this.#V=e)}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#tp.focus()}findParent(t,e){for(let i of this.#I.values()){let{x:s,y:r,width:n,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+n&&e>=r&&e<=r+a)return i}return null}disableUserSelect(t=!1){this.#tg.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#U.add(t)}removeShouldRescale(t){this.#U.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*Y.PDF_TO_CSS_UNITS,this.#U))e.onScaleChanging();this.#N?.onScaleChanging()}
2onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tA({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#ty(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#I.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:n}=e,a=e.toString(),o=this.#tA(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();let h=this.#ty(o),d=this.#tn===g.NONE,c=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:n,text:a}),d&&this.showAllEditors("highlight",!0,!0)};if(d){this.switchToMode(g.HIGHLIGHT,c);return}c()}#tw(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tA(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new tm(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#t_(){let t=document.getSelection();if(!t||t.isCollapsed){this.#to&&(this.#Q?.hide(),this.#to=null,this.#tx({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#to)return;let i=this.#tA(t).closest(".textLayer");if(!i){this.#to&&(this.#Q?.hide(),this.#to=null,this.#tx({hasSelectedText:!1}));return}if(this.#Q?.hide(),this.#to=e,this.#tx({hasSelectedText:!0}),(this.#tn===g.HIGHLIGHT||this.#tn===g.NONE)&&(this.#tn===g.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#tn===g.HIGHLIGHT?this.#ty(i):null;t?.toggleDrawing();let e=new AbortController,s=this.combinedSignal(e),r=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tE("main_toolbar"))};window.addEventListener("pointerup",r,{signal:s}),window.addEventListener("blur",r,{signal:s})}}#tE(t=""){this.#tn===g.HIGHLIGHT?this.highlightSelection(t):this.#$&&this.#tw()}#tm(){document.addEventListener("selectionchange",this.#t_.bind(this),{signal:this._signal})}#tS(){if(this.#X)return;this.#X=new AbortController;let t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#tT(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#tE("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#ta)if(e.div.contains(t)){this.#ti=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#ti)return;let[t,e]=this.#ti;this.#ti=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tv(){if(this.#te)return;this.#te=new AbortController;let t=this.combinedSignal(this.#te);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tC(){this.#te?.abort(),this.#te=null}#tM(){if(this.#O)return;this.#O=new AbortController;let t=this.combinedSignal(this.#O);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#tP(){this.#O?.abort(),this.#O=null}#tb(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tv(),this.#tM()}removeEditListeners(){this.#tC(),this.#tP()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#j)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#j)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#P?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#ta){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#j)if(e.isHandlingMimeForPasting(t.type)){e.paste(t,this.currentLayer);return}let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){T(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}this.addCommands({cmd:()=>{for(let e of t)this.#tR(e);this.#tI(t)},undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){T(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tn===g.NONE||this.isEditorHandlingKeyboard||tx._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#tE("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#tx(t){Object.entries(t).some(([t,e])=>this.#td[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#td,t)}),this.#tn===g.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tk([[f.HIGHLIGHT_FREE,!0]]))}#tk(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tS(),this.#tM(),this.#tx({isEditing:this.#tn!==g.NONE,isEmpty:this.#tD(),hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:this.#F.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#tT(),this.#tP(),this.#tx({isEditing:!1}),this.disableUserSelect(!1))}
2registerEditorTypes(t){if(!this.#j)for(let e of(this.#j=t,this.#j))this.#tk(e.defaultPropertiesToUpdate)}getId(){return this.#J.id}get currentLayer(){return this.#I.get(this.#B)}getLayer(t){return this.#I.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#I.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#I.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#tn!==t&&(!this.#tf||(await this.#tf.promise,this.#tf))){if(this.#tf=Promise.withResolvers(),this.#tn=t,t===g.NONE){this.setEditingState(!1),this.#tL(),this._editorUndoBar?.hide(),this.#tf.resolve();return}for(let e of(this.setEditingState(!0),await this.#tF(),this.unselectAll(),this.#I.values()))e.updateMode(t);if(!e){i&&this.addNewEditorFromKeyboard(),this.#tf.resolve();return}for(let t of this.#R.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#tf.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#tn&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#j){switch(t){case f.CREATE:this.currentLayer.addNewEditor();return;case f.HIGHLIGHT_DEFAULT_COLOR:this.#ts?.updateColor(e);break;case f.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#th||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(let i of this.#ta)i.updateParams(t,e);for(let i of this.#j)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#R.values())i.editorType===t&&i.show(e);(this.#th?.get(f.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tk([[f.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t)for(let e of(this.#tt=t,this.#I.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #tF(){if(!this.#Z){this.#Z=!0;let t=[];for(let e of this.#I.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#R.values()))e.enable()}}#tL(){if(this.unselectAll(),this.#Z){for(let t of(this.#Z=!1,this.#I.values()))t.disable();for(let t of this.#R.values())t.disable()}}getEditors(t){let e=[];for(let i of this.#R.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#R.get(t)}addEditor(t){this.#R.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout(()=>{this.focusMainContainer(),this.#q=null},0)),this.#R.delete(t.id),this.unselect(t),t.annotationElementId&&this.#z.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#z.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#z.has(t)}removeDeletedAnnotationElement(t){this.#z.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tR(t){let e=this.#I.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#P!==t&&(this.#P=t,t&&this.#tk(t.propertiesToUpdate))}get #tO(){let t=null;for(t of this.#ta);return t}updateUI(t){this.#tO===t&&this.#tk(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tk(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#ta.has(t)){this.#ta.delete(t),t.unselect(),this.#tx({hasSelectedEditor:this.hasSelection});return}this.#ta.add(t),t.select(),this.#tk(t.propertiesToUpdate),this.#tx({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.#N?.commitOrRemove(),this.#ta))e!==t&&e.unselect();this.#ta.clear(),this.#ta.add(t),t.select(),this.#tk(t.propertiesToUpdate),this.#tx({hasSelectedEditor:!0})}isSelected(t){return this.#ta.has(t)}get firstSelectedEditor(){return this.#ta.values().next().value}unselect(t){t.unselect(),this.#ta.delete(t),this.#tx({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#ta.size}get isEnterHandled(){return 1===this.#ta.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#F.undo(),this.#tx({hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tD()}),this._editorUndoBar?.hide()}redo(){this.#F.redo(),this.#tx({hasSomethingToUndo:!0,hasSomethingToRedo:this.#F.hasSomethingToRedo(),isEmpty:this.#tD()})}addCommands(t){this.#F.add(t),this.#tx({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tD()})}cleanUndoStack(t){this.#F.cleanType(t)}#tD(){if(0===this.#R.size)return!0;
2if(1===this.#R.size)for(let t of this.#R.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#ta],i=()=>{for(let t of e)this.#tR(t)};this.addCommands({cmd:()=>{for(let t of(this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length),e))t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#P?.commitOrRemove()}hasSomethingToControl(){return this.#P||this.hasSelection}#tI(t){for(let t of this.#ta)t.unselect();for(let e of(this.#ta.clear(),t))e.isEmpty()||(this.#ta.add(e),e.select());this.#tx({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#ta)t.commit();this.#tI(this.#R.values())}unselectAll(){if(!(this.#P&&(this.#P.commitOrRemove(),this.#tn!==g.NONE)||this.#N?.commitOrRemove())&&this.hasSelection){for(let t of this.#ta)t.unselect();this.#ta.clear(),this.#tx({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#tc[0]+=t,this.#tc[1]+=e;let[s,r]=this.#tc,n=[...this.#ta];for(let i of(this.#tu&&clearTimeout(this.#tu),this.#tu=setTimeout(()=>{this.#tu=null,this.#tc[0]=this.#tc[1]=0,this.addCommands({cmd:()=>{for(let t of n)this.#R.has(t.id)&&t.translateInPage(s,r)},undo:()=>{for(let t of n)this.#R.has(t.id)&&t.translateInPage(-s,-r)},mustExec:!1})},1e3),n))i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#H=new Map,this.#ta))this.#H.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#H)return!1;this.disableUserSelect(!1);let t=this.#H;this.#H=null;let e=!1;for(let[{x:i,y:s,pageIndex:r},n]of t)n.newX=i,n.newY=s,n.newPageIndex=r,e||=i!==n.savedX||s!==n.savedY||r!==n.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#R.has(t.id)){let r=this.#I.get(s);r?t._setParentAndPosition(r,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:r,newPageIndex:n}]of t)i(e,s,r,n)},undo:()=>{for(let[e,{savedX:s,savedY:r,savedPageIndex:n}]of t)i(e,s,r,n)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#H)for(let i of this.#H.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#ta.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#P===t}getActive(){return this.#P}getMode(){return this.#tn}get imageManager(){return R(this,"imageManager",new tA)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:r,width:n,height:a}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-r)/a,y:1-(t+i-s)/n,width:o/a,height:i/n});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/n,y:1-(e+o-r)/a,width:i/n,height:o/a});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-r)/a,y:(t-s)/n,width:o/a,height:i/n});break;default:e=(t,e,i,o)=>({x:(t-s)/n,y:(e-r)/a,width:i/n,height:o/a})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:r,height:n}of s.getClientRects())0!==r&&0!==n&&o.push(e(t,i,r,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#L||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#L?.delete(t)}renderAnnotationElement(t){let e=this.#L?.get(t.data.id);if(!e)return;let i=this.#D.getRawValue(e);i&&(this.#tn!==g.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}}class tE{#o=null;#tN=!1;#tB=null;#tz=null;#tH=null;#tj=null;#tU=!1;#t$=null;#n=null;#tG=null;#tV=null;#tW=!1;static #tq=null;static _l10n=null;constructor(t){this.#n=t,this.#tW=t._uiManager.useNewAltTextFlow,tE.#tq||=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){tE._l10n??=t}async render(){let t=this.#tB=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#tz=document.createElement("span");t.append(e),this.#tW?(t.classList.add("new"),t.setAttribute("data-l10n-id",tE.#tq.missing),e.setAttribute("data-l10n-id",tE.#tq["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#n._uiManager._signal;t.addEventListener("contextmenu",ta,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#n._uiManager.editAltText(this.#n),this.#tW&&this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#tX}})};
2return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#tU=!0,s(e))},{signal:i}),await this.#tK(),t}get #tX(){return this.#o&&"added"||null===this.#o&&this.guessedText&&"review"||"missing"}finish(){this.#tB&&(this.#tB.focus({focusVisible:this.#tU}),this.#tU=!1)}isEmpty(){return this.#tW?null===this.#o:!this.#o&&!this.#tN}hasData(){return this.#tW?null!==this.#o||!!this.#tG:this.isEmpty()}get guessedText(){return this.#tG}async setGuessedText(t){null===this.#o&&(this.#tG=t,this.#tV=await tE._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#tK())}toggleAltTextBadge(t=!1){if(!this.#tW||this.#o){this.#t$?.remove(),this.#t$=null;return}if(!this.#t$){let t=this.#t$=document.createElement("div");t.className="noAltTextBadge",this.#n.div.append(t)}this.#t$.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#tG!==e||(e=this.#tV),{altText:e,decorative:this.#tN,guessedText:this.#tG,textWithDisclaimer:this.#tV}}get data(){return{altText:this.#o,decorative:this.#tN}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:r=!1}){i&&(this.#tG=i,this.#tV=s),(this.#o!==t||this.#tN!==e)&&(r||(this.#o=t,this.#tN=e),this.#tK())}toggle(t=!1){this.#tB&&(!t&&this.#tj&&(clearTimeout(this.#tj),this.#tj=null),this.#tB.disabled=!t)}shown(){this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#tX}})}destroy(){this.#tB?.remove(),this.#tB=null,this.#tz=null,this.#tH=null,this.#t$?.remove(),this.#t$=null}async #tK(){let t=this.#tB;if(!t)return;if(this.#tW){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",tE.#tq[this.#tX]),this.#tz?.setAttribute("data-l10n-id",tE.#tq[`${this.#tX}-label`]),!this.#o){this.#tH?.remove();return}}else{if(!this.#o&&!this.#tN){t.classList.remove("done"),this.#tH?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#tH;if(!e){this.#tH=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#n.id}`;let i=this.#n._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#tj),this.#tj=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#tj=setTimeout(()=>{this.#tj=null,this.#tH.classList.add("show"),this.#n._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#tj&&(clearTimeout(this.#tj),this.#tj=null),this.#tH?.classList.remove("show")},{signal:i})}this.#tN?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);let i=this.#n.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}class tS{#tp;#tY=!1;#tQ=null;#tJ;#tZ;#t0;#t1;#t2;#t5=null;#t3;#t6=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:r=null,onPinchEnd:n=null,signal:a}){this.#tp=t,this.#tQ=i,this.#tJ=e,this.#tZ=s,this.#t0=r,this.#t1=n,this.#t3=new AbortController,this.#t2=AbortSignal.any([a,this.#t3.signal]),t.addEventListener("touchstart",this.#t4.bind(this),{passive:!1,signal:this.#t2})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return R(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#t4(t){if(this.#tJ?.()||t.touches.length<2)return;if(!this.#t6){this.#t6=new AbortController;let t=AbortSignal.any([this.#t2,this.#t6.signal]),e=this.#tp,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#t9.bind(this),i),e.addEventListener("touchend",this.#t7.bind(this),i),e.addEventListener("touchcancel",this.#t7.bind(this),i),this.#tZ?.()}if(to(t),2!==t.touches.length||this.#tQ?.()){this.#t5=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#t5={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#t9(t){if(!this.#t5||2!==t.touches.length)return;let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:r}=e,{screenX:n,screenY:a}=i,o=this.#t5,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(n-s,a-r)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#tY&&Math.abs(p-u)<=tS.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=r,o.touch1X=n,o.touch1Y=a,t.preventDefault(),!this.#tY){this.#tY=!0;return}let g=[(s+n)/2,(r+a)/2];this.#t0?.(g,p,u)}#t7(t){this.#t6.abort(),this.#t6=null,this.#t1?.(),this.#t5&&(t.preventDefault(),this.#t5=null,this.#tY=!1)}destroy(){this.#t3?.abort(),this.#t3=null}}class tT{#t8=null;#et=null;#o=null;#ee=!1;#ei=null;#es="";#er=!1;#en=null;#ea=null;#eo=null;#el=null;#eh="";#ed=!1;#ec=null;#eu=!1;#ep=!1;#eg=!1;#ef=null;#em=0;#eb=0;#ev=null;#eA=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ey=!1;#ew=tT._zIndex++;static _borderLineWidth=-1;static _colorManager=new t_;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=tT.prototype._resizeWithKeyboard,e=tx.TRANSLATE_SMALL,i=tx.TRANSLATE_BIG;return R(this,"_resizerKeyboardManager",new tw([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],tT.prototype._stopResizingWithKeyboard]]))}constructor(t){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;let{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[r,n];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return R(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tC({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(tT._l10n??=t,tT._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"}),-1!==tT._borderLineWidth)return;let i=getComputedStyle(document.documentElement);tT._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){C("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ey}set _isDraggable(t){this.#ey=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#ew}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#e_(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ed?this.#ed=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.closest(`#${this.id}`)&&(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[r,n]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/r,this.y=(e+s)/n,this.fixAndSetPosition()}#ex([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#ex(this.parentDimensions,t,e)}translateInPage(t,e){this.#ec||=[this.x,this.y,this.width,this.height],this.#ex(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#ec||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,r]}=this;if(this.x+=t/s,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this,[o,l]=this.getBaseTranslation();n+=o,a+=l;let{style:h}=i;h.left=`${(100*n).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#ec&&(this.#ec[0]!==this.x||this.#ec[1]!==this.y)}get _hasBeenResized(){return!!this.#ec&&(this.#ec[2]!==this.width||this.#ec[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=tT,s=i/t,r=i/e;switch(this.rotation){case 90:return[-s,r];case 180:return[s,r];case 270:return[s,-r];default:return[-s,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:r,y:n,width:a,height:o}=this;if(a*=i,o*=s,r*=i,n*=s,this._mustFixPosition)switch(t){case 0:r=Math.max(0,Math.min(i-a,r)),n=Math.max(0,Math.min(s-o,n));break;case 90:r=Math.max(0,Math.min(i-o,r)),n=Math.min(s,Math.max(a,n));break;case 180:r=Math.min(i,Math.max(a,r)),n=Math.min(s,Math.max(o,n));break;case 270:r=Math.min(i,Math.max(o,r)),n=Math.max(0,Math.min(s-a,n))}this.x=r/=i,this.y=n/=s;let[l,h]=this.getBaseTranslation();r+=l,n+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static #eE(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return tT.#eE(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return tT.#eE(t,e,360-this.parentRotation)}#eS(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){let[i,s]=this.parentDimensions,{style:r}=this.div;r.width=`${(100*t/i).toFixed(2)}%`,this.#er||(r.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),r=!this.#er&&e.endsWith("%");if(s&&r)return;let[n,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/n).toFixed(2)}%`),this.#er||r||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#eT(){if(this.#en)return;this.#en=document.createElement("div"),this.#en.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#en.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#eC.bind(this,i),{signal:e}),t.addEventListener("contextmenu",ta,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#en)}#eC(t,e){e.preventDefault();let{isMac:i}=U.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#ea=[e.screenX,e.screenY];let r=new AbortController,n=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#eM.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",to,{passive:!1,signal:n}),window.addEventListener("contextmenu",ta,{signal:n}),this.#eo={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#eP()};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}#eR(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;let[r,n]=this.parentDimensions;this.setDims(r*i,n*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#eP(){if(!this.#eo)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#eo;this.#eo=null;let r=this.x,n=this.y,a=this.width,o=this.height;(r!==t||n!==e||a!==i||o!==s)&&this.addCommands({cmd:this.#eR.bind(this,r,n,a,o),undo:this.#eR.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#eM(t,e){let i,s,r,n,a,o;let[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=tT.MIN_SIZE/l,f=tT.MIN_SIZE/h,m=this.#eS(this.rotation),b=(t,e)=>[m[0]*t+m[2]*e,m[1]*t+m[3]*e],v=this.#eS(360-this.rotation),A=!1,y=!1;switch(t){case"topLeft":A=!0,i=(t,e)=>
2[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":A=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":y=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":A=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":A=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":y=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let w=i(u,p),_=s(u,p),x=b(..._),E=tT._round(d+x[0]),S=tT._round(c+x[1]),T=1,C=1;if(e.fromKeyboard)({deltaX:r,deltaY:n}=e);else{let{screenX:t,screenY:i}=e,[s,a]=this.#ea;[r,n]=this.screenToPageTranslation(t-s,i-a),this.#ea[0]=t,this.#ea[1]=i}if([r,n]=(a=r/l,o=n/h,[v[0]*a+v[2]*o,v[1]*a+v[3]*o]),A){let t=Math.hypot(u,p);T=C=Math.max(Math.min(Math.hypot(_[0]-w[0]-r,_[1]-w[1]-n)/t,1/u,1/p),g/u,f/p)}else y?T=Math.max(g,Math.min(1,Math.abs(_[0]-w[0]-r)))/u:C=Math.max(f,Math.min(1,Math.abs(_[1]-w[1]-n)))/p;let M=tT._round(u*T),P=tT._round(p*C),R=E-(x=b(...s(M,P)))[0],I=S-x[1];this.#ec||=[this.x,this.y,this.width,this.height],this.width=M,this.height=P,this.x=R,this.y=I,this.setDims(l*M,h*P),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#ep||(this._editToolbar=new tf(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(tE.initialize(tT._l10n),this.#o=new tE(this),this.#t8&&(this.#o.data=this.#t8,this.#t8=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await this.#o?.setGuessedText(t)}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#ee?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#eI();let[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);let[i,s]=this.getInitialTranslation();return this.translate(i,s),tb(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#eA||=new tS({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#ek.bind(this),onPinching:this.#eD.bind(this),onPinchEnd:this.#eL.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#ek(){this.#eo={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#eD(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let r=this.#eS(this.rotation),n=(t,e)=>[r[0]*t+r[2]*e,r[1]*t+r[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;s=Math.max(Math.min(s,1/d,1/c),tT.MIN_SIZE/a/d,tT.MIN_SIZE/o/c);let u=tT._round(d*s),p=tT._round(c*s);if(u===d&&p===c)return;this.#ec||=[l,h,d,c];let g=n(d/2,c/2),f=tT._round(l+g[0]),m=tT._round(h+g[1]),b=n(u/2,p/2);this.x=f-b[0],this.y=m-b[1],this.width=u,this.height=p,this.setDims(a*u,o*p),this.fixAndSetPosition(),this._onResizing()}#eL(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#eP()}pointerdown(t){let{isMac:e}=U.platform;if(0!==t.button||t.ctrlKey&&e){t.preventDefault();return}if(this.#ed=!0,this._isDraggable){this.#eF(t);return}this.#eO(t)}get isSelected(){return this._uiManager.isSelected(this)}#eO(t){let{isMac:e}=U.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#eF(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,r=this._uiManager.combinedSignal(s),n={capture:!0,passive:!1,signal:r},a=t=>{s.abort(),this.#ei=null,this.#ed=!1,this._uiManager.endDragSession()||this.#eO(t),i&&this._onStopDragging()};e&&(this.#em=t.clientX,this.#eb=t.clientY,this.#ei=t.pointerId,this.#es=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._onStartDragging());let{clientX:e,clientY:s,pointerId:r}=t;if(r!==this.#ei){to(t);return}let[n,a]=this.screenToPageTranslation(e-this.#em,s-this.#eb);this.#em=e,this.#eb=s,this._uiManager.dragSelectedEditors(n,a)},n),window.addEventListener("touchmove",to,n),window.addEventListener("pointerdown",t=>{t.pointerType===this.#es&&(this.#eA||t.isPrimary)&&a(t),to(t)},n));let o=t=>{if(!this.#ei||this.#ei===t.pointerId){a(t);return}to(t)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#ef&&clearTimeout(this.#ef),this.#ef=setTimeout(()=>{this.#ef=null,this.parent?.moveEditorInDOM(this)},0)}
2_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){let s=this.parentScale,[r,n]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*r,c=this.y*n,u=this.width*r,p=this.height*n;switch(i){case 0:return[d+l+a,n-c-h-p+o,d+l+u+a,n-c-h+o];case 90:return[d+h+a,n-c+l+o,d+h+p+a,n-c+l+u+o];case 180:return[d-l-u+a,n-c+h+o,d-l+a,n-c+h+p+o];case 270:return[d-h-p+a,n-c-l-u+o,d-h+a,n-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,r,n]=t,a=r-i,o=n-s;switch(this.rotation){case 0:return[i,e-n,a,o];case 90:return[i,e-s,o,a];case 180:return[r,e-s,a,o];case 270:return[r,e-n,o,a];default:throw Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#ep=!0}disableEditMode(){this.#ep=!1}isInEditMode(){return this.#ep}shouldGetKeyboardEvents(){return this.#eg}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:r,innerWidth:n}=window;return e<n&&s>0&&t<r&&i>0}#eI(){if(this.#el||!this.div)return;this.#el=new AbortController;let t=this._uiManager.combinedSignal(this.#el);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#eI()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){C("An editor must be serializable")}static async deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#t8=t.accessibilityData;let[r,n]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,n);return s.x=a/r,s.y=o/n,s.width=l/r,s.height=h/n,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#el?.abort(),this.#el=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#ef&&(clearTimeout(this.#ef),this.#ef=null),this.#e_(),this.removeEditToolbar(),this.#ev){for(let t of this.#ev.values())clearTimeout(t);this.#ev=null}this.parent=null,this.#eA?.destroy(),this.#eA=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#eT(),this.#en.classList.remove("hidden"),tb(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#eo={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#en.children;if(!this.#et){this.#et=Array.from(e);let t=this.#eN.bind(this),i=this.#eB.bind(this),s=this._uiManager._signal;for(let e of this.#et){let r=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#ez.bind(this,r),{signal:s}),e.setAttribute("data-l10n-id",tT._l10nResizer[r])}}let i=this.#et[0],s=0;for(let t of e){if(t===i)break;s++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#et.length/4);if(r!==s){if(r<s)for(let t=0;t<s-r;t++)this.#en.append(this.#en.firstChild);else if(r>s)for(let t=0;t<r-s;t++)this.#en.firstChild.before(this.#en.lastChild);let t=0;for(let i of e){let e=this.#et[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",tT._l10nResizer[e])}}this.#eH(0),this.#eg=!0,this.#en.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#eN(t){tT._resizerKeyboardManager.exec(this,t)}#eB(t){this.#eg&&t.relatedTarget?.parentNode!==this.#en&&this.#e_()}#ez(t){this.#eh=this.#eg?t:""}#eH(t){if(this.#et)for(let e of this.#et)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#eg&&this.#eM(this.#eh,{deltaX:t,deltaY:e,fromKeyboard:!0})}#e_(){this.#eg=!1,this.#eH(-1),this.#eP()}_stopResizingWithKeyboard(){this.#e_(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)}unselect(){this.#en?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#eu}set isEditing(t){this.#eu=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#er=!0;let{style:i}=this.div;i.aspectRatio=t/e,i.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#ev||=new Map;let{action:e}=t,i=this.#ev.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#ev.delete(e),0===this.#ev.size&&(this.#ev=null)},tT._telemetryTimeout),this.#ev.set(e,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
2show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ee=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ee=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class tC extends tT{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}class tM{constructor(t){this.h1=t?4294967295&t:3285377520,this.h2=t?4294967295&t:3285377520}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,r=t.length;s<r;s++){let r=t.charCodeAt(s);r<=255?e[i++]=r:(e[i++]=r>>>8,e[i++]=255&r)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,r=i-4*s,n=new Uint32Array(e.buffer,0,s),a=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=a=461845907*(a=(a=3432918353*(a=n[t])&4294901760|11601*a&65535)<<15|a>>>17)&4294901760|13715*a&65535,l=5*(l=l<<13|l>>>19)+3864292196):(h^=o=461845907*(o=(o=3432918353*(o=n[t])&4294901760|11601*o&65535)<<15|o>>>17)&4294901760|13715*o&65535,h=5*(h=h<<13|h>>>19)+3864292196);switch(a=0,r){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=461845907*(a=(a=3432918353*a&4294901760|11601*a&65535)<<15|a>>>17)&4294901760|13715*a&65535,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=4283543511*e&4294901760|((e<<16|(t=3981806797*t&4294901760|36045*t&65535)>>>16)*2950163797&4294901760)>>>16,t^=e>>>1,e=3301882366*e&4294901760|((e<<16|(t=444984403*t&4294901760|60499*t&65535)>>>16)*3120437893&4294901760)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let tP=Object.freeze({map:null,hash:"",transfer:void 0});class tR{#ej=!1;#eU=null;#e$=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let i=this.#e$.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#e$.get(t)}remove(t){if(this.#e$.delete(t),0===this.#e$.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let t of this.#e$.values())if(t instanceof tT)return;this.onAnnotationEditor(null)}}setValue(t,e){let i=this.#e$.get(t),s=!1;if(void 0!==i)for(let[t,r]of Object.entries(e))i[t]!==r&&(s=!0,i[t]=r);else s=!0,this.#e$.set(t,e);s&&this.#eG(),e instanceof tT&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#e$.has(t)}getAll(){return this.#e$.size>0?j(this.#e$):null}setAll(t){for(let[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#e$.size}#eG(){this.#ej||(this.#ej=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#ej&&(this.#ej=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new tI(this)}get serializable(){if(0===this.#e$.size)return tP;let t=new Map,e=new tM,i=[],s=Object.create(null),r=!1;for(let[i,n]of this.#e$){let a=n instanceof tT?n.serialize(!1,s):n;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),r||=!!a.bitmap)}if(r)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:tP}get editorStats(){let t=null,e=new Map;for(let i of this.#e$.values()){if(!(i instanceof tT))continue;let s=i.telemetryFinalData;if(!s)continue;let{type:r}=s;e.has(r)||e.set(r,Object.getPrototypeOf(i).constructor),t||=Object.create(null);let n=t[r]||=new Map;for(let[t,e]of Object.entries(s)){if("type"===t)continue;let i=n.get(t);i||(i=new Map,n.set(t,i));let s=i.get(e)??0;i.set(e,s+1)}}for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#eU=null}get modifiedIds(){if(this.#eU)return this.#eU;let t=[];for(let e of this.#e$.values())e instanceof tT&&e.annotationElementId&&e.serialize()&&t.pu
2sh(e.annotationElementId);return this.#eU={ids:new Set(t),hash:t.join(",")}}}class tI extends tR{#eV;constructor(t){super();let{map:e,hash:i,transfer:s}=t.serializable,r=structuredClone(e,s?{transfer:s}:null);this.#eV={map:r,hash:i,transfer:s}}get print(){C("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#eV}get modifiedIds(){return R(this,"modifiedIds",{ids:new Set,hash:""})}}class tk{#eW=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#eW.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#eW.has(t.loadedName))){if(M(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:s,style:r}=t,n=new FontFace(i,s,r);this.addNativeFontFace(n);try{await n.load(),this.#eW.add(i),e?.(t)}catch{T(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}C("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw T(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return R(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return h?t=!0:"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)&&(t=!0),R(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(M(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return R(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,r;function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function a(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=n(c=a(c,976,d.length,d),16);for(s=0,r=d.length-3;s<r;s+=4)u=u-1482184792+n(d,s)|0;s<d.length&&(u=u-1482184792+n(d+"XXX",s)|0),c=a(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let f=this._document.createElement("div");
2for(let e of(f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++h>30){T("Load test font never loaded."),i();return}if(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){i();return}setTimeout(t.bind(null,e,i))}(d,()=>{f.remove(),e.complete()})}}class tD{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){for(let e in this.compiledGlyphs=Object.create(null),t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){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)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){var t;let e;if(!this.data||this.disableFontFace)return null;let i=`url(data:${this.mimetype};base64,${(t=this.data,Uint8Array.prototype.toBase64?t.toBase64():btoa(z(t)))});`;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${i}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${i}}`;return this._inspectFont?.(this,i),e}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){T(`getPathGenerator - ignoring character: "${t}".`)}let r=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}}let tL={DATA:1,ERROR:2},tF={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function tO(){}function tN(t){if(t instanceof B||t instanceof L||t instanceof F||t instanceof k||t instanceof O||t instanceof D)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||C('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new B(t.message);case"InvalidPDFException":return new L(t.message);case"MissingPDFException":return new F(t.message);case"PasswordException":return new k(t.message,t.code);case"UnexpectedResponseException":return new O(t.message,t.status);case"UnknownErrorException":return new D(t.message,t.details)}return new D(t.message,t.toString())}class tB{#eq=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#eX.bind(this),{signal:this.#eq.signal})}#eX({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#eK(t);return}if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===tL.DATA)i.resolve(t.data);else if(t.callback===tL.ERROR)i.reject(tN(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(e){r.postMessage({sourceName:i,targetName:s,callback:tL.DATA,callbackId:t.callbackId,data:e})},function(e){r.postMessage({sourceName:i,targetName:s,callback:tL.ERROR,callbackId:t.callbackId,reason:tN(e)})});return}if(t.streamId){this.#eY(t);return}e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}
2sendWithPromise(t,e,i){let s=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[s]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,i,s){let r=this.streamId++,n=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[r]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:n,targetName:a,action:t,streamId:r,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[r].pullCall=e,o.postMessage({sourceName:n,targetName:a,stream:tF.PULL,streamId:r,desiredSize:t.desiredSize}),e.promise},cancel:t=>{M(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[r].cancelCall=e,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:tF.CANCEL,streamId:r,reason:tN(t)}),e.promise}},i)}#eY(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this,a=this.actionHandler[t.action],o={enqueue(t,n=1,a){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=n,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:s,stream:tF.ENQUEUE,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:tF.CLOSE,streamId:e}),delete n.streamSinks[e])},error(t){M(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:tF.ERROR,streamId:e,reason:tN(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:tF.START_COMPLETE,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:tF.START_COMPLETE,streamId:e,reason:tN(t)})})}#eK(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case tF.START_COMPLETE:t.success?n.startCall.resolve():n.startCall.reject(tN(t.reason));break;case tF.PULL_COMPLETE:t.success?n.pullCall.resolve():n.pullCall.reject(tN(t.reason));break;case tF.PULL:if(!a){r.postMessage({sourceName:i,targetName:s,stream:tF.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||tO).then(function(){r.postMessage({sourceName:i,targetName:s,stream:tF.PULL_COMPLETE,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:tF.PULL_COMPLETE,streamId:e,reason:tN(t)})});break;case tF.ENQUEUE:if(M(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case tF.CLOSE:if(M(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#eQ(n,e);break;case tF.ERROR:M(n,"error should have stream controller"),n.controller.error(tN(t.reason)),this.#eQ(n,e);break;case tF.CANCEL_COMPLETE:t.success?n.cancelCall.resolve():n.cancelCall.reject(tN(t.reason)),this.#eQ(n,e);break;case tF.CANCEL:if(!a)break;let o=tN(t.reason);Promise.try(a.onCancel||tO,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:tF.CANCEL_COMPLETE,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:tF.CANCEL_COMPLETE,streamId:e,reason:tN(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #eQ(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#eq?.abort(),this.#eq=null}}class tz{#eJ=!1;constructor({enableHWA:t=!1}){this.#eJ=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#eJ})}}reset(t,e,i){if(!t.canvas)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){C("Abstract method `_createCanvas` called.")}}class tH extends tz{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class tj{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){C("Abstract method `_fetch` called.")}}class tU extends tj{async _fetch(t){let e=await Q(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):H(e)}}o(4520);class t${addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,r){return"none"}destroy(t=!1){}}class tG extends t${#eZ;#e0;#e1;#e2;#e5;#e3;#A=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#e2=t,this.#e5=e}get #w(){return this.#e0||=new Map}get #e6(){return this.#e3||=new Map}get #e4(){if(!this.#e1){let t=this.#e5.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let i=this.#e5.createElementNS(K,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#e1=this.#e5.createElementNS(K,"defs"),t.append(i),i.append(this.#e1),this.#e5.body.append(t)}return this.#e1}#e9(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,r=Array(256),n=Array(256),a=Array(256);for(let t=0;t<256;t++)r[t]=e[t]/255,n[t]=i[t]/255,a[t]=s[t]/255;return[r.join(","),n.join(","),a.join(",")]}#e7(t){if(void 0===this.#eZ){this.#eZ="";let t=this.#e5.URL;t!==this.#e5.baseURI&&(tt(t)?T('#createUrl: ignore "data:"-URL for performance reasons.'):this.#eZ=t.split("#",1)[0])}return`url(${this.#eZ}#${t})`}addFilter(t){if(!t)return"none";let e=this.#w.get(t);if(e)return e;
2let[i,s,r]=this.#e9(t),n=1===t.length?i:`${i}${s}${r}`;if(e=this.#w.get(n))return this.#w.set(t,e),e;let a=`g_${this.#e2}_transfer_map_${this.#A++}`,o=this.#e7(a);this.#w.set(t,o),this.#w.set(n,o);let l=this.#e8(a);return this.#it(i,s,r,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",r=this.#e6.get(s);if(r?.key===i||(r?(r.filter?.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},this.#e6.set(s,r)),!t||!e))return r.url;let n=this.#ie(t);t=G.makeHexColor(...n);let a=this.#ie(e);if(e=G.makeHexColor(...a),this.#e4.style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#e2}_hcm_filter`,d=r.filter=this.#e8(h);this.#it(l,l,l,d),this.#ii(d);let c=(t,e)=>{let i=n[t]/255,s=a[t]/255,r=Array(e+1);for(let t=0;t<=e;t++)r[t]=i+t/e*(s-i);return r.join(",")};return this.#it(c(0,5),c(1,5),c(2,5),d),r.url=this.#e7(h),r.url}addAlphaFilter(t){let e=this.#w.get(t);if(e)return e;let[i]=this.#e9([t]),s=`alpha_${i}`;if(e=this.#w.get(s))return this.#w.set(t,e),e;let r=`g_${this.#e2}_alpha_map_${this.#A++}`,n=this.#e7(r);this.#w.set(t,n),this.#w.set(s,n);let a=this.#e8(r);return this.#is(i,a),n}addLuminosityFilter(t){let e,i,s=this.#w.get(t||"luminosity");if(s)return s;if(t?([e]=this.#e9([t]),i=`luminosity_${e}`):i="luminosity",s=this.#w.get(i))return this.#w.set(t,s),s;let r=`g_${this.#e2}_luminosity_map_${this.#A++}`,n=this.#e7(r);this.#w.set(t,n),this.#w.set(i,n);let a=this.#e8(r);return this.#ir(a),t&&this.#is(e,a),n}addHighlightHCMFilter(t,e,i,s,r){let n=`${e}-${i}-${s}-${r}`,a=this.#e6.get(t);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#e6.set(t,a)),!e||!i))return a.url;let[o,l]=[e,i].map(this.#ie.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,r].map(this.#ie.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#e4.style.color="";let p=(t,e,i)=>{let s=Array(256),r=(d-h)/i,n=t/255,a=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*r),i=n+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#e2}_hcm_${t}_filter`,f=a.filter=this.#e8(g);return this.#ii(f),this.#it(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#e7(g),a.url}destroy(t=!1){t&&this.#e3?.size||(this.#e1?.parentNode.parentNode.remove(),this.#e1=null,this.#e0?.clear(),this.#e0=null,this.#e3?.clear(),this.#e3=null,this.#A=0)}#ir(t){let e=this.#e5.createElementNS(K,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#ii(t){let e=this.#e5.createElementNS(K,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#e8(t){let e=this.#e5.createElementNS(K,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#e4.append(e),e}#ia(t,e,i){let s=this.#e5.createElementNS(K,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#it(t,e,i,s){let r=this.#e5.createElementNS(K,"feComponentTransfer");
2s.append(r),this.#ia(r,"feFuncR",t),this.#ia(r,"feFuncG",e),this.#ia(r,"feFuncB",i)}#is(t,e){let i=this.#e5.createElementNS(K,"feComponentTransfer");e.append(i),this.#ia(i,"feFuncA",t)}#ie(t){return this.#e4.style.color=t,td(getComputedStyle(this.#e4).getPropertyValue("color"))}}class tV{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load font data at: ${e}`)})}async _fetch(t){C("Abstract method `_fetch` called.")}}class tW extends tV{async _fetch(t){return new Uint8Array(await Q(t,"arraybuffer"))}}if(h){let t;try{let e=s.getBuiltinModule("module").createRequire("file:///app/node_modules/pdfjs-dist/legacy/build/pdf.mjs");try{t=e("@napi-rs/canvas")}catch(t){T(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(t){T(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(t?.DOMMatrix?globalThis.DOMMatrix=t.DOMMatrix:T("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(t?.ImageData?globalThis.ImageData=t.ImageData:T("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(t?.Path2D?globalThis.Path2D=t.Path2D:T("Cannot polyfill `Path2D`, rendering may be broken."))}async function tq(t){let e=s.getBuiltinModule("fs");return new Uint8Array(await e.promises.readFile(t))}class tX extends t${}class tK extends tz{_createCanvas(t,e){return s.getBuiltinModule("module").createRequire("file:///app/node_modules/pdfjs-dist/legacy/build/pdf.mjs")("@napi-rs/canvas").createCanvas(t,e)}}class tY extends tj{async _fetch(t){return tq(t)}}class tQ extends tV{async _fetch(t){return tq(t)}}let tJ={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function tZ(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],r=new Path2D;r.rect(e[0],e[1],i,s),t.clip(r)}class t0{getPattern(){C("Abstract method `getPattern` called.")}}class t1 extends t0{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;for(let i of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let r;if(s===tJ.STROKE||s===tJ.FILL){let n=e.current.getClippedPathBoundingBox(s,tc(t))||[0,0,0,0],a=Math.ceil(n[2]-n[0])||1,o=Math.ceil(n[3]-n[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-n[0],-n[1]),i=G.transform(i,[1,0,0,1,n[0],n[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),tZ(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),r=t.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(i);r.setTransform(d)}else tZ(t,this._bbox),r=this._createGradient(t);return r}}function t2(t,e,i,s,r,n,a,o){let l,h,d,c,u,p,g,f,m;let b=e.coords,v=e.colors,A=t.data,y=4*t.width;b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l),b[s+1]>b[r+1]&&(l=s,s=r,r=l,l=a,a=o,o=l),b[i+1]>b[s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l);let w=(b[i]+e.offsetX)*e.scaleX,_=(b[i+1]+e.offsetY)*e.scaleY,x=(b[s]+e.offsetX)*e.scaleX,E=(b[s+1]+e.offsetY)*e.scaleY,S=(b[r]+e.offsetX)*e.scaleX,T=(b[r+1]+e.offsetY)*e.scaleY;if(_>=T)return;let C=v[n],M=v[n+1],P=v[n+2],R=v[a],I=v[a+1],k=v[a+2],D=v[o],L=v[o+1],F=v[o+2],O=Math.round(_),N=Math.round(T);for(let t=O;t<=N;t++){let e;if(t<E){let e=t<_?0:(_-t)/(_-E);h=w-(w-x)*e,d=C-(C-R)*e,c=M-(M-I)*e,u=P-(P-k)*e}else{let e;h=x-(x-S)*(e=t>T?1:E===T?0:(E-t)/(E-T)),d=R-(R-D)*e,c=I-(I-L)*e,u=k-(k-F)*e}p=w-(w-S)*(e=t<_?0:t>T?1:(_-t)/(_-T)),g=C-(C-D)*e,f=M-(M-L)*e,m=P-(P-F)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),r=y*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),A[r++]=d-(d-g)*e|0,A[r++]=c-(c-f)*e|0,A[r++]=u-(u-m)*e|0,A[r++]=255}}class t5 extends t0{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(n*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=n/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-r,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){let t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}
2for(let t of this._figures)!function(t,e,i){let s,r;let n=e.coords,a=e.colors;switch(e.type){case"lattice":let o=e.verticesPerRow,l=Math.floor(n.length/o)-1,h=o-1;for(s=0;s<l;s++){let e=s*o;for(let s=0;s<h;s++,e++)t2(t,i,n[e],n[e+1],n[e+o],a[e],a[e+1],a[e+o]),t2(t,i,n[e+o+1],n[e+1],n[e+o],a[e+o+1],a[e+1],a[e+o])}break;case"triangles":for(s=0,r=n.length;s<r;s+=3)t2(t,i,n[s],n[s+1],n[s+2],a[s],a[s+1],a[s+2]);break;default:throw Error("illegal figure")}}(m,t,c);return f.putImageData(m,2,2),{canvas:g.canvas,offsetX:s-2*h,offsetY:r-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let r;if(tZ(t,this._bbox),s===tJ.SHADING)r=G.singularValueDecompose2dScale(tc(t));else if(r=G.singularValueDecompose2dScale(e.baseTransform),this.matrix){let t=G.singularValueDecompose2dScale(this.matrix);r=[r[0]*t[0],r[1]*t[1]]}let n=this._createMeshCanvas(r,s===tJ.SHADING?null:this._background,e.cachedCanvases);return s!==tJ.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY),t.createPattern(n.canvas,"no-repeat")}}class t3 extends t0{getPattern(){return"hotpink"}}let t6={COLORED:1,UNCOLORED:2};class t4{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,r){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=r}createPatternCanvas(t){let{bbox:e,operatorList:i,paintType:s,tilingType:r,color:n,canvasGraphicsFactory:a}=this,{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),S("TilingType: "+r);let h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=G.singularValueDecompose2dScale(this.matrix),m=G.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],v=f[1]*m[1],A=p,y=g,w=!1,_=!1,x=Math.ceil(l*v),E=Math.ceil(g*v);Math.ceil(o*b)>=Math.ceil(p*b)?A=o:w=!0,x>=E?y=l:_=!0;let T=this.getSizeAndScale(A,this.ctx.canvas.width,b),C=this.getSizeAndScale(y,this.ctx.canvas.height,v),M=t.cachedCanvases.getCanvas("pattern",T.size,C.size),P=M.context,R=a.createCanvasGraphics(P);if(R.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(R,s,n),P.translate(-T.scale*h,-C.scale*d),R.transform(T.scale,0,0,C.scale,0,0),P.save(),this.clipBbox(R,h,d,c,u),R.baseTransform=tc(R.ctx),R.executeOperatorList(i),R.endDrawing(),P.restore(),w||_){let e=M.canvas;w&&(A=o),_&&(y=l);let i=this.getSizeAndScale(A,this.ctx.canvas.width,b),s=this.getSizeAndScale(y,this.ctx.canvas.height,v),r=i.size,n=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",r,n),c=a.context,u=w?Math.floor(p/o):0,f=_?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)c.drawImage(e,r*t,n*i,r,n,0,0,r,n);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:M.canvas,scaleX:T.scale,scaleY:C.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){let s=Math.max(t4.MAX_PATTERN_SIZE,e),r=Math.ceil(t*i);return r>=s?r=s:i=r/t,{scale:i,size:r}}clipBbox(t,e,i,s,r){let n=s-e,a=r-i;t.ctx.rect(e,i,n,a),t.current.updateRectMinMax(tc(t.ctx),[e,i,s,r]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,r=t.current;switch(e){case t6.COLORED:let n=this.ctx;s.fillStyle=n.fillStyle,s.strokeStyle=n.strokeStyle,r.fillColor=n.fillStyle,r.strokeColor=n.strokeStyle;break;case t6.UNCOLORED:let a=G.makeHexColor(i[0],i[1],i[2]);s.fillStyle=a,s.strokeStyle=a,r.fillColor=a,r.strokeColor=a;break;default:throw new N(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let r=i;s!==tJ.SHADING&&(r=G.transform(r,e.baseTransform),this.matrix&&(r=G.transform(r,this.matrix)));let n=this.createPatternCanvas(e),a=new DOMMatrix(r);a=(a=a.translate(n.offsetX,n.offsetY)).scale(1/n.scaleX,1/n.scaleY);let o=t.createPattern(n.canvas,"repeat");return o.setTransform(a),o}}class t9{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}
2function t7(t,e,i,s,r,n,a,o,l,h){let[d,c,u,p,g,f]=tc(t);if(0===c&&0===u){let m=Math.round(a*d+g),b=Math.round(o*p+f),v=Math.abs(Math.round((a+l)*d+g)-m)||1,A=Math.abs(Math.round((o+h)*p+f)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),m,b),t.drawImage(e,i,s,r,n,0,0,v,A),t.setTransform(d,c,u,p,g,f),[v,A]}if(0===d&&0===p){let m=Math.round(o*u+g),b=Math.round(a*c+f),v=Math.abs(Math.round((o+h)*u+g)-m)||1,A=Math.abs(Math.round((a+l)*c+f)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,m,b),t.drawImage(e,i,s,r,n,0,0,A,v),t.setTransform(d,c,u,p,g,f),[A,v]}return t.drawImage(e,i,s,r,n,a,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class t8{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=d,this.textMatrixScale=1,this.fontMatrix=c,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=b.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=G.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){let i=G.applyTransform(e,t),s=G.applyTransform(e.slice(2),t),r=G.applyTransform([e[0],e[3]],t),n=G.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],r[0],n[0]),this.minY=Math.min(this.minY,i[1],s[1],r[1],n[1]),this.maxX=Math.max(this.maxX,i[0],s[0],r[0],n[0]),this.maxY=Math.max(this.maxY,i[1],s[1],r[1],n[1])}updateScalingPathMinMax(t,e){G.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,r,n,a,o,l,h){let d=G.bezierBoundingBox(e,i,s,r,n,a,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=tJ.FILL,e=null){let i=[this.minX,this.minY,this.maxX,this.maxY];if(t===tJ.STROKE){e||C("Stroke bounding box must include transform.");let t=G.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,r=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=r,i[2]+=s,i[3]+=r}return i}updateClipFromPath(){let t=G.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=tJ.FILL,e=null){return G.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function et(t,e){let i,s,r,n;if(e instanceof ImageData){t.putImageData(e,0,0);return}let a=e.height,o=e.width,l=a%16,h=(a-l)/16,d=0===l?h:h+1,c=t.createImageData(o,16),u=0,p,g=e.data,f=c.data;if(e.kind===v.GRAYSCALE_1BPP){let e=g.byteLength,n=new Uint32Array(f.buffer,0,f.byteLength>>2),a=n.length,m=o+7>>3,b=U.isLittleEndian?4278190080:255;for(i=0;i<d;i++){for(s=0,r=i<h?16:l,p=0;s<r;s++){let t=e-u,i=0,s=t>m?o:8*t-7,r=-8&s,a=0,l=0;for(;i<r;i+=8)l=g[u++],n[p++]=128&l?4294967295:b,n[p++]=64&l?4294967295:b,n[p++]=32&l?4294967295:b,n[p++]=16&l?4294967295:b,n[p++]=8&l?4294967295:b,n[p++]=4&l?4294967295:b,n[p++]=2&l?4294967295:b,n[p++]=1&l?4294967295:b;for(;i<s;i++)0===a&&(l=g[u++],a=128),n[p++]=l&a?4294967295:b,a>>=1}for(;p<a;)n[p++]=0;t.putImageData(c,0,16*i)}}else if(e.kind===v.RGBA_32BPP){for(i=0,s=0,n=64*o;i<h;i++)f.set(g.subarray(u,u+n)),u+=n,t.putImageData(c,0,s),s+=16;i<d&&(n=o*l*4,f.set(g.subarray(u,u+n)),t.putImageData(c,0,s))}else if(e.kind===v.RGB_24BPP)for(i=0,n=o*(r=16);i<d;i++){for(i>=h&&(n=o*(r=l)),p=0,s=n;s--;)f[p++]=g[u++],f[p++]=g[u++],f[p++]=g[u++],f[p++]=255;t.putImageData(c,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function ee(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}let i=e.height,s=e.width,r=i%16,n=(i-r)/16,a=0===r?n:n+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<a;e++){let i=e<n?16:r;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:s,height:r,nonBlackColor:n=4294967295,inverseDecode:a=!1}){let o=U.isLittleEndian?4278190080:255,[l,h]=a?[n,o]:[o,n],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<r;s++){for(let s=e+d;e<s;e++){let s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;let s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function ei(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function es(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miter
2Limit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!h){let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function er(t,e){if(e)return!0;let i=G.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);let s=Math.fround((globalThis.devicePixelRatio||1)*Y.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}let en=["butt","round","square"],ea=["miter","round","bevel"],eo={},el={};class eh{constructor(t,e,i,s,r,{optionalContentConfig:n,markedContentStack:a=null},o,l){this.ctx=t,this.current=new t8(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=r,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=n,this.cachedCanvases=new t9(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let r=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,r,n),this.ctx.fillStyle=a,i){let t=this.cachedCanvases.getCanvas("transparent",r,n);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...tc(this.compositeCtx))}this.ctx.save(),es(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=tc(this.ctx)}executeOperatorList(t,e,i,s){let r;let n=t.argsArray,a=t.fnArray,o=e||0,l=n.length;if(l===o)return o;let h=l-o>10&&"function"==typeof i,d=h?Date.now()+15:0,c=0,u=this.commonObjs,p=this.objs;for(;;){if(void 0!==s&&o===s.nextBreakPoint)return s.breakIt(o,i),o;if((r=a[o])!==_.dependency)this[r].apply(this,n[o]);else for(let t of n[o]){let e=t.startsWith("g_")?u:p;if(!e.has(t))return e.get(t,i),o}if(++o===l)return o;if(h&&++c>10){if(Date.now()>d)return i(),o;c=0}}}#io(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){for(let t of(this.#io(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#il()}#il(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i,s;let r=t.width??t.displayWidth,n=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=r,h=n,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,r=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(r=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/r),(s=(i=this.cachedCanvases.getCanvas(d,e,r)).context).clearRect(0,0,e,r),s.drawImage(t,0,0,l,h,0,0,e,r),t=i.canvas,l=e,h=r,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){let e,i,s,r;let n=this.ctx,{width:a,height:o}=t,l=this.current.fillColor,h=this.current.patternFill,d=tc(n);if((t.bitmap||t.data)&&t.count>1){let r=t.bitmap||t.data.buffer;i=JSON.stringify(h?d:[d.slice(0,4),l]),(e=this._cachedBitmapsMap.get(r))||(e=new Map,this._cachedBitmapsMap.set(r,e));let n=e.get(i);if(n&&!h)return{canvas:n,offsetX:Math.round(Math.min(d[0],d[2])+d[4]),offsetY:Math.round(Math.min(d[1],d[3])+d[5])};s=n}s||ee((r=this.cachedCanvases.getCanvas("maskCanvas",a,o)).context,t);let c=G.transform(d,[1/a,0,0,-1/o,0,0]);c=G.transform(c,[1,0,0,1,0,-o]);let[u,p,g,f]=G.getAxialAlignedBoundingBox([0,0,a,o],c),m=this.cachedCanvases.getCanvas("fillCanvas",Math.round(g-u)||1,Math.round(f-p)||1),b=m.context;b.translate(-u,-p),b.transform(...c),!s&&(s=(s=this._scaleImage(r.canvas,tu(b))).img,e&&h&&e.set(i,s)),b.imageSmoothingEnabled=er(tc(b),t.interpolate),t7(b,s,0,0,s.width,s.height,0,0,a,o),b.globalCompositeOperation="source-in";let v=G.transform(tu(b),[1,0,0,1,-u,-p]);
2return b.fillStyle=h?l.getPattern(n,this,v,tJ.FILL):l,b.fillRect(0,0,a,o),e&&!h&&(this.cachedCanvases.delete("fillCanvas"),e.set(i,m.canvas)),{canvas:m.canvas,offsetX:Math.round(u),offsetY:Math.round(p)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=en[t]}setLineJoin(t){this.ctx.lineJoin=ea[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;let r=this.ctx;r.setTransform(...tc(this.suspendedCtx)),ei(this.suspendedCtx,r),function(t,e){if(t._removeMirroring)throw Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,r,n,a){e.transform(t,i,s,r,n,a),this.__originalTransform(t,i,s,r,n,a)},t.setTransform=function(t,i,s,r,n,a){e.setTransform(t,i,s,r,n,a),this.__originalSetTransform(t,i,s,r,n,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,r,n,a){e.bezierCurveTo(t,i,s,r,n,a),this.__originalBezierCurveTo(t,i,s,r,n,a)},t.rect=function(t,i,s,r){e.rect(t,i,s,r),this.__originalRect(t,i,s,r)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),ei(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore(
2)}composeSMask(t,e,i,s){let r=s[0],n=s[1],a=s[2]-r,o=s[3]-n;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,r,n,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,r,n,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(n){let e=G.makeHexColor(...n);if(u<0||p<0||u+i>c.width||p+s>c.height){let t=this.cachedCanvases.getCanvas("maskExtension",i,s),r=t.context;r.drawImage(c,-u,-p),r.globalCompositeOperation="destination-atop",r.fillStyle=e,r.fillRect(0,0,i,s),r.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let r=new Path2D;r.rect(u,p,i,s),t.clip(r),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===r&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===r&&(e.filter=this.filterFactory.addLuminosityFilter(a));let g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(ei(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),ei(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,r,n){this.ctx.transform(t,e,i,s,r,n),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let s,r;let n=this.ctx,a=this.current,o=a.x,l=a.y,h=tc(n),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case _.rectangle:o=e[u++],l=e[u++];let p=e[u++],g=e[u++],f=o+p,m=l+g;n.moveTo(o,l),0===p||0===g?n.lineTo(f,m):(n.lineTo(f,l),n.lineTo(f,m),n.lineTo(o,m)),d||a.updateRectMinMax(h,[o,l,f,m]),n.closePath();break;case _.moveTo:o=e[u++],l=e[u++],n.moveTo(o,l),d||a.updatePathMinMax(h,o,l);break;case _.lineTo:o=e[u++],l=e[u++],n.lineTo(o,l),d||a.updatePathMinMax(h,o,l);break;case _.curveTo:s=o,r=l,o=e[u+4],l=e[u+5],n.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),a.updateCurvePathMinMax(h,s,r,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case _.curveTo2:s=o,r=l,n.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),a.updateCurvePathMinMax(h,s,r,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case _.curveTo3:s=o,r=l,o=e[u+2],l=e[u+3],n.bezierCurveTo(e[u],e[u+1],o,l,o,l),a.updateCurvePathMinMax(h,s,r,e[u],e[u+1],o,l,o,l,c),u+=4;break;case _.closePath:n.closePath()}d&&a.updateScalingPathMinMax(h,c),a.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,tu(e),tJ.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){let e=this.ctx,i=this.current.fillColor,s=this.current.patternFill,r=!1;s&&(e.save(),e.fillStyle=i.getPattern(e,this,tu(e),tJ.FILL),r=!0);let n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),r&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=eo}eoClip(){this.pendingClip=el}beginText(){this.current.textMatrix=d,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let t=this.pendingTextPaths,e=this.ctx;if(void 0===t){e.beginPath();return}let i=new Path2D,s=e.getTransform().invertSelf();for(let{transform:e,x:r,y:n,fontSize:a,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(r,n).scale(a,-a));e.clip(i),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){let i=this.commonObjs.get(t),s=this.current;if(!i)throw Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||c,(0===s.fontMatrix[0]||0===s.fontMatrix[3])&&T("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;let r=i.loadedName||"sans-serif",n=i.systemFontInfo?.css||`"${r}", ${i.fallbackName}`,a="normal";i.black?a="900":i.bold&&(a="bold");let o=i.italic?"italic":"normal",l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${n}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,r,n){this.current.textMatrix=[t,e,i,s,r,n],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#ih(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,r){let n;let a=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,c=h&b.FILL_STROKE_MASK,u=!!(h&b.ADD_TO_PATH_FLAG),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;if((l.disableFontFace||u||p||g)&&(n=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||p||g){if(a.save(),a.translate(e,i),a.scale(d,-d
2),c===b.FILL||c===b.FILL_STROKE){if(s){let t=a.getTransform();a.setTransform(...s),a.fill(this.#ih(n,t,s))}else a.fill(n)}if(c===b.STROKE||c===b.FILL_STROKE){if(r){let t=a.getTransform();a.setTransform(...r),a.stroke(this.#ih(n,t,r))}else a.lineWidth/=d,a.stroke(n)}a.restore()}else(c===b.FILL||c===b.FILL_STROKE)&&a.fillText(t,e,i),(c===b.STROKE||c===b.FILL_STROKE)&&a.strokeText(t,e,i);u&&(this.pendingTextPaths||=[]).push({transform:tc(a),x:e,y:i,fontSize:d,path:n})}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return R(this,"isFontSubpixelAAEnabled",i)}showText(t){let e,i;let s=this.current,r=s.font;if(r.isType3Font)return this.showType3Text(t);let n=s.fontSize;if(0===n)return;let a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,d=s.fontDirection,c=s.textHScale*d,u=t.length,p=r.vertical,g=p?1:-1,f=r.defaultVMetrics,m=n*s.fontMatrix[0],v=s.textRenderingMode===b.FILL&&!r.disableFontFace&&!s.patternFill;if(a.save(),a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),d>0?a.scale(c,-1):a.scale(c,1),s.patternFill){a.save();let t=s.fillColor.getPattern(a,this,tu(a),tJ.FILL);e=tc(a),a.restore(),a.fillStyle=t}if(s.patternStroke){a.save();let t=s.strokeColor.getPattern(a,this,tu(a),tJ.STROKE);i=tc(a),a.restore(),a.strokeStyle=t}let A=s.lineWidth,y=s.textMatrixScale;if(0===y||0===A){let t=s.textRenderingMode&b.FILL_STROKE_MASK;(t===b.STROKE||t===b.FILL_STROKE)&&(A=this.getSinglePixelWidth())}else A/=y;if(1!==o&&(a.scale(o,o),A/=o),a.lineWidth=A,r.isInvalidPDFjsFont){let e=[],i=0;for(let s of t)e.push(s.unicode),i+=s.width;a.fillText(e.join(""),0,0),s.x+=i*m*c,a.restore(),this.compose();return}let w=0,_;for(_=0;_<u;++_){let s,c;let u=t[_];if("number"==typeof u){w+=g*u*n/1e3;continue}let b=!1,A=(u.isSpace?h:0)+l,y=u.fontChar,x=u.accent,E=u.width;if(p){let t=u.vmetric||f,e=-(u.vmetric?t[1]:.5*E)*m,i=t[2]*m;E=t?-t[0]:E,s=e/o,c=(w+i)/o}else s=w/o,c=0;if(r.remeasure&&E>0){let t=1e3*a.measureText(y).width/n*o;if(E<t&&this.isFontSubpixelAAEnabled){let e=E/t;b=!0,a.save(),a.scale(e,1),s/=e}else E!==t&&(s+=(E-t)/2e3*n/o)}if(this.contentVisible&&(u.isInFont||r.missingFile)){if(v&&!x)a.fillText(y,s,c);else if(this.paintChar(y,s,c,e,i),x){let t=s+n*x.offset.x/o,r=c-n*x.offset.y/o;this.paintChar(x.fontChar,t,r,e,i)}}w+=p?E*m-A*d:E*m+A*d,b&&a.restore()}p?s.y-=w:s.x+=w*c,a.restore(),this.compose()}showType3Text(t){let e,i,s,r;let n=this.ctx,a=this.current,o=a.font,l=a.fontSize,h=a.fontDirection,d=o.vertical?1:-1,u=a.charSpacing,p=a.wordSpacing,g=a.textHScale*h,f=a.fontMatrix||c,m=t.length;if(a.textRenderingMode!==b.INVISIBLE&&0!==l){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,n.save(),n.transform(...a.textMatrix),n.translate(a.x,a.y),n.scale(g,h),e=0;e<m;++e){if("number"==typeof(i=t[e])){r=d*i*l/1e3,this.ctx.translate(r,0),a.x+=r*g;continue}let h=(i.isSpace?p:0)+u,c=o.charProcOperatorList[i.operatorListId];if(!c){T(`Type3 character "${i.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=i,this.save(),n.scale(l,l),n.transform(...f),this.executeOperatorList(c),this.restore()),s=G.applyTransform([i.width,0],f)[0]*l+h,n.translate(s,0),a.x+=s*g}n.restore(),this.processingType3=null}}setCharWidth(t,e){}
2setCharWidthAndBounds(t,e,i,s,r,n){this.ctx.rect(i,s,r-i,n-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){let i=t[1],s=this.baseTransform||tc(this.ctx);e=new t4(t,i,this.ctx,{createCanvasGraphics:t=>new eh(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=G.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=G.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new t1(t);case"Mesh":return new t5(t);case"Dummy":return new t3}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save();let i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,tu(e),tJ.SHADING);let s=tu(e);if(s){let{width:t,height:i}=e.canvas,[r,n,a,o]=G.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(r,n,a-r,o-n)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){C("Should not call beginInlineImage")}beginImageData(){C("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=tc(this.ctx),e)){let t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(tc(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let e=this.ctx;t.isolated||S("TODO: Support non-isolated groups."),t.knockout&&T("Knockout groups not supported.");let i=tc(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw Error("Bounding box is required.");let s=G.getAxialAlignedBoundingBox(t.bbox,tc(e)),r=[0,0,e.canvas.width,e.canvas.height],n=Math.floor((s=G.intersect(s,r)||[0,0,0,0])[0]),a=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-n,1),l=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);let d=this.cachedCanvases.getCanvas(h,o,l),c=d.context;c.translate(-n,-a),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:n,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(n,a),e.save()),ei(e,c),this.ctx=c,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;let e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let t=tc(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);let i=G.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,r){if(this.#io(),es(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let s=e[2]-e[0],n=e[3]-e[1];if(r&&this.annotationCanvasMap){i=i.slice(),i[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=n;let[r,a]=G.singularValueDecompose2dScale(tc(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(n*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);let{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(r,0,0,-a,0,n*a),es(this.ctx)}else es(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,n),this.ctx.clip(),this.ctx.beginPath()}
2this.current=new t8(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#il(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;let e=t.count;(t=this.getObject(t.data,t)).count=e;let i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){let e,i,s;let{width:r,height:n}=t;if(r>1e3||n>1e3)return null;let a=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=r+1,l=new Uint8Array(o*(n+1)),h=r+7&-8,d=new Uint8Array(h*n),c=0;for(let e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(0!==d[c=0]&&(l[0]=1,++u),i=1;i<r;i++)d[c]!==d[c+1]&&(l[i]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[i]=2,++u),e=1;e<n;e++){c=e*h,s=e*o,d[c-h]!==d[c]&&(l[s]=d[c]?1:8,++u);let t=(d[c]?4:0)+(d[c-h]?8:0);for(i=1;i<r;i++)a[t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0)]&&(l[s+i]=a[t],++u),c++;if(d[c-h]!==d[c]&&(l[s+i]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(n-1),s=e*o,0!==d[c]&&(l[s]=8,++u),i=1;i<r;i++)d[c]!==d[c+1]&&(l[s+i]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[s+i]=4,++u),u>1e3)return null;let p=new Int32Array([0,o,-1,0,-o,0,0,0,1]),g=new Path2D;for(e=0;u&&e<=n;e++){let t=e*o,i=t+r;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%o,e);let s=t,n=l[t];do{let e=p[n];do t+=e;while(!l[t]);let i=l[t];5!==i&&10!==i?(n=i,l[t]=0):(n=i&51*n>>4,l[t]&=n>>2|n<<2),g.lineTo(t%o,t/o|0),!l[t]&&--u}while(s!==t);--e}return d=null,l=null,function(t){t.save(),t.scale(1/r,-1/n),t.translate(0,-n),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled)){s.compiled(i);return}let r=this._createMaskCanvas(t),n=r.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(n,r.offsetX,r.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,r,n){if(!this.contentVisible)return;t=this.getObject(t.data,t);let a=this.ctx;a.save();let o=tc(a);a.transform(e,i,s,r,0,0);let l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=n.length;t<h;t+=2){let h=G.transform(o,[e,i,s,r,n[t],n[t+1]]),[d,c]=G.applyTransform([0,0],h);a.drawImage(l.canvas,d,c)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(let r of t){let{data:t,width:n,height:a,transform:o}=r,l=this.cachedCanvases.getCanvas("maskCanvas",n,a),h=l.context;h.save(),ee(h,this.getObject(t,r)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,tu(e),tJ.FILL):i,h.fillRect(0,0,n,a),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),t7(e,l.canvas,0,0,n,a,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);if(!e){T("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;let r=this.getObject(t);if(!r){T("Dependent image isn't ready yet");return}let n=r.width,a=r.height,o=[];for(let t=0,r=s.length;t<r;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:n,h:a});this.paintInlineImageXObjectGroup(r,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;let{bitmap:e,width:i,height:s}=t,r=this.cachedCanvases.getCanvas("inlineImage",i,s),n=r.context;return n.filter=this.current.transferMaps,n.drawImage(e,0,0),n.filter="none",r.canvas}paintInlineImageXObject(t){let e;if(!this.contentVisible)return;let i=t.width,s=t.height,r=this.ctx;if(this.save(),!h){let{filter:t}=r;"none"!==t&&""!==t&&(r.filter="none")}if(r.scale(1/i,-1/s),t.bitmap)e=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)e=t;else{let r=this.cachedCanvases.getCanvas("inlineImage",i,s).context;et(r,t),e=this.applyTransferMapsToCanvas(r)}let n=this._scaleImage(e,tu(r));r.imageSmoothingEnabled=er(tc(r),t.interpolate),t7(r,n.img,0,0,n.paintWidth,n.paintHeight,0,-s,i,s),this.compose(),this.restore(
2)}paintInlineImageXObjectGroup(t,e){let i;if(!this.contentVisible)return;let s=this.ctx;if(t.bitmap)i=t.bitmap;else{let e=t.width,s=t.height,r=this.cachedCanvases.getCanvas("inlineImage",e,s).context;et(r,t),i=this.applyTransferMapsToCanvas(r)}for(let t of e)s.save(),s.transform(...t.transform),s.scale(1,-1),t7(s,i,t.x,t.y,t.w,t.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){let e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);let i=this.ctx;this.pendingClip&&(e||(this.pendingClip===el?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=tc(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e;let{lineWidth:i}=this.current,{a:s,b:r,c:n,d:a}=this.ctx.getTransform();if(0===r&&0===n){let r=Math.abs(s),n=Math.abs(a);if(r===n){if(0===i)t=e=1/r;else{let s=r*i;t=e=s<1?1/s:1}}else if(0===i)t=1/r,e=1/n;else{let s=r*i,a=n*i;t=s<1?1/s:1,e=a<1?1/a:1}}else{let o=Math.abs(s*a-r*n),l=Math.hypot(s,r),h=Math.hypot(n,a);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:i}=this.current,[s,r]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===r){e.stroke();return}let n=e.getLineDash();if(t&&e.save(),e.scale(s,r),n.length>0){let t=Math.max(s,r);e.setLineDash(n.map(e=>e/t)),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in _)void 0!==eh.prototype[t]&&(eh.prototype[_[t]]=eh.prototype[t]);class ed{static #id=null;static #ic="";static get workerPort(){return this.#id}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#id=t}static get workerSrc(){return this.#ic}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#ic=t}}class ec{#iu;#ip;constructor({parsedData:t,rawData:e}){this.#iu=t,this.#ip=e}getRaw(){return this.#ip}get(t){return this.#iu.get(t)??null}getAll(){return j(this.#iu)}has(t){return this.#iu.has(t)}}let eu=Symbol("INTERNAL");class ep{#ig=!1;#im=!1;#ib=!1;#iv=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:r}){this.#ig=!!(t&u.DISPLAY),this.#im=!!(t&u.PRINT),this.name=e,this.intent=i,this.usage=s,this.rbGroups=r}get visible(){if(this.#ib)return this.#iv;if(!this.#iv)return!1;let{print:t,view:e}=this.usage;return this.#ig?e?.viewState!=="OFF":!this.#im||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==eu&&C("Internal method `_setVisible` called."),this.#ib=i,this.#iv=e}}class eg{#iA=null;#iy=new Map;#iw=null;#i_=null;constructor(t,e=u.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(let i of(this.name=t.name,this.creator=t.creator,this.#i_=t.order,t.groups))this.#iy.set(i.id,new ep(e,i));if("OFF"===t.baseState)for(let t of this.#iy.values())t._setVisible(eu,!1);for(let e of t.on)this.#iy.get(e)._setVisible(eu,!0);for(let e of t.off)this.#iy.get(e)._setVisible(eu,!1);this.#iw=this.getHash()}#ix(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e;let r=t[s];if(Array.isArray(r))e=this.#ix(r);else{if(!this.#iy.has(r))return T(`Optional content group not found: ${r}`),!0;e=this.#iy.get(r).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#iy.size)return!0;
2if(!t)return S("Optional content group not defined."),!0;if("OCG"===t.type)return this.#iy.has(t.id)?this.#iy.get(t.id).visible:(T(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#ix(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#iy.has(e)){T(`Optional content group not found: ${e}`);break}if(!this.#iy.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#iy.has(e))return T(`Optional content group not found: ${e}`),!0;if(!this.#iy.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(let e of t.ids){if(!this.#iy.has(e)){T(`Optional content group not found: ${e}`);break}if(this.#iy.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#iy.has(e))return T(`Optional content group not found: ${e}`),!0;if(this.#iy.get(e).visible)return!0}return!1}return T(`Unknown optional content policy ${t.policy}.`),!0}return T(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#iy.get(t);if(!s){T(`Optional content group not found: ${t}`);return}if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#iy.get(i)?._setVisible(eu,!1,!0);s._setVisible(eu,!!e,!0),this.#iA=null}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#iy.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#iA=null}get hasInitialVisibility(){return null===this.#iw||this.getHash()===this.#iw}getOrder(){return this.#iy.size?this.#i_?this.#i_.slice():[...this.#iy.keys()]:null}getGroups(){return this.#iy.size>0?j(this.#iy):null}getGroup(t){return this.#iy.get(t)||null}getHash(){if(null!==this.#iA)return this.#iA;let t=new tM;for(let[e,i]of this.#iy)t.update(`${e}:${i.visible}`);return this.#iA=t.hexdigest()}}class ef{constructor(t,{disableRange:e=!1,disableStream:i=!1}){M(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:s,initialData:r,progressiveDone:n,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=n,this._contentDispositionFilename=a,r?.length>0){let t=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):M(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){M(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new em(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new eb(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeReaders.slice(0)))e.cancel(t);this._pdfDataRangeTransport.abort()}}class em{constructor(t,e,i=!1,s=null){for(let r of(this._stream=t,this._done=i||!1,this._filename=te(s)?s:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=r.byteLength;
2this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class eb{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{for(let e of(this._requests.shift().resolve({value:t,done:!1}),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ev(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function eA(t){try{return new URL(t).origin}catch{}return null}function ey({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let r={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(t.get("Content-Length"),10);return Number.isInteger(n)&&(r.suggestedLength=n,n<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(r.allowRangeRequests=!0)),r}function ew(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=a(i=i[1]);return n(t=l(t=o(t=unescape(t))))}if(i=function(t){let e;let i=[],r=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=r.exec(t));){let[,t,s,r]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,r]}let n=[];for(let t=0;t<i.length&&(t in i);++t){let[e,s]=i[t];s=a(s),e&&(s=unescape(s),0===t&&(s=o(s))),n.push(s)}return n.join("")}(t))return n(l(i));if(i=s("filename","i").exec(t)){let t=a(i=i[1]);return n(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function r(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),r=H(i);i=s.decode(r),e=!1}catch{}}return i}function n(t){return e&&/[\x80-\xff]/.test(t)&&(t=r("utf-8",t),e&&(t=r("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:r(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return r(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return r(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(te(t))return t}return null}function e_(t,e){return 404===t||0===t&&e.startsWith("file:")?new F('Missing PDF "'+e+'".'):new O(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function ex(t){return 200===t||206===t}function eE(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function eS(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(T(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class eT{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ev(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return M(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new eC(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new eM(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class eC{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;let e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;let i=new Headers(t.headers),s=e.url;fetch(s,eE(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=eA(e.url),!ex(e.status))throw e_(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();let i=e.headers,{allowRangeRequests:r,suggestedLength:n}=ey({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=n||this._contentLength,this._filename=ew(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new B("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:eS(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class eM{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;let s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;let r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`);let n=s.url;fetch(n,eE(r,this._withCredentials,this._abortController)).then(e=>{let i=eA(e.url);if(i!==t._responseOrigin)throw Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!ex(e.status))throw e_(e.status,n);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:eS(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class eP{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=ev(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};for(let[t,i]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",M(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){let i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){let i=this.pendingRequests[t];if(!i)return;let s=i.xhr;if(s.readyState>
2=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp){i.onError(s.status);return}let r=s.status||200;if(!(200===r&&206===i.expectedStatus)&&r!==i.expectedStatus){i.onError(s.status);return}let n=function(t){let e=t.response;return"string"!=typeof e?e:H(e).buffer}(s);if(206===r){let t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:n}):(T('Missing or invalid "Content-Range" header.'),i.onError(0))}else n?i.onDone({begin:0,chunk:n}):i.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class eR{constructor(t){this._source=t,this._manager=new eP(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return M(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new eI(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let i=new ek(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class eI{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=eA(e.responseURL);let i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:n}=ey({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=ew(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(let e of(this._storedError=e_(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest
2(this._fullRequestId),this._fullRequestReader=null}}class ek{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=eA(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;for(let t of(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){for(let e of(this._storedError??=e_(t,this._url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}let eD=/^[a-z][a-z0-9\-+.]+:/i;class eL{constructor(t){var e;this.source=t,this.url=(e=t.url,new URL(eD.test(e)?e:s.getBuiltinModule("url").pathToFileURL(e))),M("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return M(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new eF(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new eO(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class eF{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;let e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let i=s.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=new F(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new B("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class eO{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let r=t.source;this._isStreamingSupported=!r.disableStream;let n=s.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}
2class eN{#iE=Promise.withResolvers();#tp=null;#iS=!1;#iT=!!globalThis.FontInspector?.enabled;#iC=null;#iM=null;#iP=0;#iR=0;#iI=null;#ik=null;#iD=0;#iL=0;#iF=Object.create(null);#iO=[];#iN=null;#iB=[];#iz=new WeakMap;#iH=null;static #ij=new Map;static #iU=new Map;static #i$=new WeakMap;static #iG=null;static #iV=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#iN=t;else if("object"==typeof t)this.#iN=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tp=this.#ik=e,this.#iL=i.scale*(globalThis.devicePixelRatio||1),this.#iD=i.rotation,this.#iM={div:null,properties:null,ctx:null};let{pageWidth:s,pageHeight:r,pageX:n,pageY:a}=i.rawDims;this.#iH=[1,0,0,-1,-n,a+r],this.#iR=s,this.#iP=r,eN.#iW(),tp(e,i),this.#iE.promise.finally(()=>{eN.#iV.delete(this),this.#iM=null,this.#iF=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=U.platform;return R(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#iI.read().then(({value:e,done:i})=>{if(i){this.#iE.resolve();return}this.#iC??=e.lang,Object.assign(this.#iF,e.styles),this.#iq(e.items),t()},this.#iE.reject)};return this.#iI=this.#iN.getReader(),eN.#iV.add(this),t(),this.#iE.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*(globalThis.devicePixelRatio||1),s=t.rotation;if(s!==this.#iD&&(e?.(),this.#iD=s,tp(this.#ik,{rotation:s})),i!==this.#iL){e?.(),this.#iL=i;let t={div:null,properties:null,ctx:eN.#iX(this.#iC)};for(let e of this.#iB)t.properties=this.#iz.get(e),t.div=e,this.#iK(t)}}cancel(){let t=new B("TextLayer task cancelled.");this.#iI?.cancel(t).catch(()=>{}),this.#iI=null,this.#iE.reject(t)}get textDivs(){return this.#iB}get textContentItemsStr(){return this.#iO}#iq(t){if(this.#iS)return;this.#iM.ctx??=eN.#iX(this.#iC);let e=this.#iB,i=this.#iO;for(let s of t){if(e.length>1e5){T("Ignoring additional textDivs for performance reasons."),this.#iS=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tp;this.#tp=document.createElement("span"),this.#tp.classList.add("markedContent"),null!==s.id&&this.#tp.setAttribute("id",`${s.id}`),t.append(this.#tp)}else"endMarkedContent"===s.type&&(this.#tp=this.#tp.parentNode);continue}i.push(s.str),this.#iY(s)}}#iY(t){let e,i;let s=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#iB.push(s);let n=G.transform(this.#iH,t.transform),a=Math.atan2(n[1],n[0]),o=this.#iF[t.fontName];o.vertical&&(a+=Math.PI/2);let l=this.#iT&&o.fontSubstitution||o.fontFamily;l=eN.fontFamilyMap.get(l)||l;let h=Math.hypot(n[2],n[3]),d=h*eN.#iQ(l,this.#iC);0===a?(e=n[4],i=n[5]-d):(e=n[4]+d*Math.sin(a),i=n[5]-d*Math.cos(a));let c="calc(var(--scale-factor)*",u=s.style;this.#tp===this.#ik?(u.left=`${(100*e/this.#iR).toFixed(2)}%`,u.top=`${(100*i/this.#iP).toFixed(2)}%`):(u.left=`${c}${e.toFixed(2)}px)`,u.top=`${c}${i.toFixed(2)}px)`),u.fontSize=`${c}${(eN.#iG*h).toFixed(2)}px)`,u.fontFamily=l,r.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#iT&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==a&&(r.angle=180/Math.PI*a);let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(r.canvasWidth=o.vertical?t.height:t.width),this.#iz.set(s,r),this.#iM.div=s,this.#iM.properties=r,this.#iK(this.#iM),r.hasText&&this.#tp.append(s),r.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tp.append(t)}}#iK(t){let{div:e,properties:i,ctx:s}=t,{style:r}=e,n="";if(eN.#iG>1&&(n=`scale(${1/eN.#iG})`),0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=r,{canvasWidth:a,fontSize:o}=i;eN.#iJ(s,o*this.#iL,t);let{width:l}=s.measureText(e.textContent);l>0&&(n=`scaleX(${a*this.#iL/l}) ${n}`)}0!==i.angle&&(n=`rotate(${i.angle}deg) ${n}`),n.length>0&&(r.transform=n)}static cleanup(){if(!(this.#iV.size>0)){for(let{canvas:t}
2of(this.#ij.clear(),this.#iU.values()))t.remove();this.#iU.clear()}}static #iX(t=null){let e=this.#iU.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#iU.set(t,e),this.#i$.set(e,{size:0,family:""})}return e}static #iJ(t,e,i){let s=this.#i$.get(t);(e!==s.size||i!==s.family)&&(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static #iW(){if(null!==this.#iG)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#iG=t.getBoundingClientRect().height,t.remove()}static #iQ(t,e){let i=this.#ij.get(t);if(i)return i;let s=this.#iX(e);s.canvas.width=s.canvas.height=30,this.#iJ(s,30,t);let r=s.measureText(""),n=r.fontBoundingBoxAscent,a=Math.abs(r.fontBoundingBoxDescent);if(n){let e=n/(n+a);return this.#ij.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,30,30),s.strokeText("g",0,0);let o=s.getImageData(0,0,30,30).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/30);break}s.clearRect(0,0,30,30),s.strokeText("A",0,30),o=s.getImageData(0,0,30,30).data,n=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){n=30-Math.floor(t/4/30);break}s.canvas.width=s.canvas.height=0;let l=n?n/(n+a):.8;return this.#ij.set(t,l),l}}class eB{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,r=i.name;if("#text"===r)s=i.value;else{if(!eB.shouldBuildText(r))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}let ez=h?tK:tH,eH=h?tY:tU,ej=h?tX:tG,eU=h?tQ:tW;function e$(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new eV,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(h&&"string"==typeof t)return t}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(h&&void 0!==r&&t instanceof r)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return H(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,o=!0===t.withCredentials,l=t.password??null,d=t.range instanceof eW?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,u=t.worker instanceof eY?t.worker:null,p=t.verbosity,g="string"!=typeof t.docBaseUrl||tt(t.docBaseUrl)?null:t.docBaseUrl,f="string"==typeof t.cMapUrl?t.cMapUrl:null,m=!1!==t.cMapPacked,b=t.CMapReaderFactory||eH,v="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,A=t.StandardFontDataFactory||eU,y=!0!==t.stopAtErrors,w=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,_=!1!==t.isEvalSupported,x="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!h,S="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!h&&(U.platform.isFirefox||!globalThis.chrome),T=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:h,M=!0===t.fontExtraProperties,P=!0===t.enableXfa,R=t.ownerDocument||globalThis.document,I=!0===t.disableRange,k=!0===t.disableStream,D=!0===t.disableAutoFetch,L=!0===t.pdfBug,F=t.CanvasFactory||ez,O=t.FilterFactory||ej,N=!0===t.enableHWA,B=d?d.length:t.length??NaN,z="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!h&&!C,j="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:b===tU&&A===tW&&f&&v&&tn(f,document.baseURI)&&tn(v,document.baseURI);Number.isInteger(p)&&(E=p);let $={canvasFactory:new F({ownerDocument:R,enableHWA:N}),filterFactory:new O({docId:i,ownerDocument:R}),cMapReaderFactory:j?null:new b({baseUrl:f,isCompressed:m}),standardFontDataFactory:j?null:new A({baseUrl:v})};if(!u){let t={verbosity:p,port:ed.workerPort};u=t.port?eY.fromPort(t):new eY(t),e._worker=u}let G={docId:i,apiVersion:"4.10.38",data:n,password:l,disableAutoFetch:D,rangeChunkSize:c,length:B,docBaseUrl:g,enableXfa:P,evaluatorOptions:{maxImageSize:w,disableFontFace:C,ignoreErrors:y,isEvalSupported:_,isOffscreenCanvasSupported:x,isImageDecoderSupported:S,canvasMaxAreaInBytes:T,fontExtraProperties:M,useSystemFonts:z,cMapUrl:j?f:null,standardFontDataUrl:j?v:null}},V={disableFontFace:C,fontExtraProperties:M,ownerDocument:R,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:D,enableXfa:P}};return u.promise.then(function(){let t;if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");
2let r=u.messageHandler.sendWithPromise("GetDocRequest",G,n?[n.buffer]:null);if(d)t=new ef(d,{disableRange:I,disableStream:k});else if(!n){let e;if(!s)throw Error("getDocument - no `url` parameter provided.");if(h){if(tn(s)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=eT}else e=eL}else e=tn(s)?eT:eR;t=new e({url:s,length:B,httpHeaders:a,withCredentials:o,rangeChunkSize:c,disableRange:I,disableStream:k})}return r.then(s=>{if(e.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let r=new tB(i,s,u.port),n=new eQ(r,e,t,V,$);e._transport=n,r.send("Ready",null)})}).catch(e._capability.reject),e}function eG(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class eV{static #e2=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${eV.#e2++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}class eW{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(let i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let i of this._progressListeners)i(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(let e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){C("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class eq{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return R(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class eX{#iZ=null;#i0=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new tr:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new eZ,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:r=!1}={}
2){return new J({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return R(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=p.ENABLE,transform:r=null,background:n=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:d=!1}){this._stats?.time("Overall");let c=this._transport.getRenderingIntent(i,s,h,d),{renderingIntent:g,cacheKey:f}=c;this.#i0=!1,this.#i1(),a||=this._transport.getOptionalContentConfig(g);let m=this._intentStates.get(f);m||(m=Object.create(null),this._intentStates.set(f,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);let b=!!(g&u.PRINT);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));let v=t=>{m.renderTasks.delete(A),(this._maybeCleanupAfterRender||b)&&(this.#i0=!0),this.#i2(!b),t?(A.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:Error(t)})):A.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},A=new e1({callback:v,params:{canvasContext:t,viewport:e,transform:r,background:n},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:l});(m.renderTasks||=new Set).add(A);let y=A.task;return Promise.all([m.displayReadyCapability.promise,a]).then(([t,e])=>{if(this.destroyed){v();return}if(this._stats?.time("Rendering"),!(e.renderingIntent&g))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");A.initializeGraphics({transparency:t,optionalContentConfig:e}),A.operatorListChanged()}).catch(v),y}getOperatorList({intent:t="display",annotationMode:e=p.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){let r;let n=this._transport.getRenderingIntent(t,e,i,s,!0),a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||((r=Object.create(null)).operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>eB.textContent(t));let e=this.streamTextContent(t);return new Promise(function(t,i){let s=e.getReader(),r={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then(function({value:i,done:s}){if(s){t(r);return}r.lang??=i.lang,Object.assign(r.styles,i.styles),r.items.push(...i.items),e()},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#i0=!1,this.#i1(),Promise.all(t)}cleanup(t=!1){this.#i0=!0;let e=this.#i2(!1);
2return t&&e&&(this._stats&&=new tr),e}#i2(t=!1){if(this.#i1(),!this.#i0||this.destroyed)return!1;if(t)return this.#iZ=setTimeout(()=>{this.#iZ=null,this.#i2(!1)},5e3),!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#i0=!1,!0}#i1(){this.#iZ&&(clearTimeout(this.#iZ),this.#iZ=null)}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#i2(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:r,transfer:n}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:s},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;let l=()=>{a.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#i2(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof Z){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new B(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class eK{#i5=new Map;#i3=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#i3.then(()=>{for(let[t]of this.#i5)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:r}=i;if(r.aborted){T("LoopbackPort - cannot use an `aborted` signal.");return}let n=()=>this.removeEventListener(t,e);s=()=>r.removeEventListener("abort",n),r.addEventListener("abort",n)}this.#i5.set(e,s)}removeEventListener(t,e){let i=this.#i5.get(e);i?.(),this.#i5.delete(e)}terminate(){for(let[,t]of this.#i5)t?.();this.#i5.clear()}}class eY{static #i6=0;static #i4=!1;static #i9;static{h&&(this.#i4=!0,ed.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(!(i=new URL(t)).origin||"null"===i.origin)return!1}catch{return!1}let s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=E}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(eY.#i9?.has(e))throw Error("Cannot use more than one PDFWorker per port.");(eY.#i9||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#i7(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new tB("main","worker",t),this._messageHandler.on("ready",function(){}),this.#i7()}_initialize(){if(eY.#i4||eY.#i8){this._setupFakeWorker();return}let{workerSrc:t}=eY;try{eY._isSameOrigin(window.location.href,t)||(t=eY._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new tB("main","worker",e),s=()=>{r.abort(),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;e.addEventListener("error",()=>{this._webWorker||s()},{signal:r.signal}),i.on("test",t=>{if(r.abort(),this.destroyed||!t){s();return}this._messageHandler=i,this._port=e,this._webWorker=e,this.#i7()}),i.on("ready",t=>{if(r.abort(),this.destroyed){s();return}try{n()}catch{this._setupFakeWorker()}});let n=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};n();return}catch{S("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){eY.#i4||(T("Setting up fake worker."),eY.#i4=!0),eY._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(Error("Worker was destroyed"));return}let e=new eK;this._port=e;let i=`fake${eY.#i6++}`,s=new tB(i+"_worker",i,e);t.setup(s,e),this._messageHandler=new tB(i,i+"_worker",e),this.#i7()}).catch(t=>{this._readyCapability.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,eY.#i9?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw Error("PDFWorker.fromPort - invalid method signature.");let e=this.#i9?.get(t.port);
2if(e){if(e._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new eY(t)}static get workerSrc(){if(ed.workerSrc)return ed.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #i8(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return R(this,"_setupFakeWorkerGlobal",(async()=>this.#i8?this.#i8:(await import(this.workerSrc)).WorkerMessageHandler)())}}class eQ{#st=new Map;#se=new Map;#si=new Map;#ss=new Map;#sr=null;constructor(t,e,i,s,r){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new eZ,this.fontLoader=new tk({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#sn(t,e=null){let i=this.#st.get(t);if(i)return i;let s=this.messageHandler.sendWithPromise(t,e);return this.#st.set(t,s),s}get annotationStorage(){return R(this,"annotationStorage",new tR)}getRenderingIntent(t,e=p.ENABLE,i=null,s=!1,r=!1){let n=u.DISPLAY,a=tP;switch(t){case"any":n=u.ANY;break;case"display":break;case"print":n=u.PRINT;break;default:T(`getRenderingIntent - invalid intent: ${t}`)}let o=n&u.PRINT&&i instanceof tI?i:this.annotationStorage;switch(e){case p.DISABLE:n+=u.ANNOTATIONS_DISABLE;break;case p.ENABLE:break;case p.ENABLE_FORMS:n+=u.ANNOTATIONS_FORMS;break;case p.ENABLE_STORAGE:n+=u.ANNOTATIONS_STORAGE,a=o.serializable;break;default:T(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(n+=u.IS_EDITING),r&&(n+=u.OPLIST);let{ids:l,hash:h}=o.modifiedIds,d=[n,a.hash,h];return{renderingIntent:n,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#sr?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#se.values())t.push(e._destroy());this.#se.clear(),this.#si.clear(),this.#ss.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#st.clear(),this.filterFactory.destroy(),eN.cleanup(),this._networkStream?.cancelAllRequests(new B("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{M(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){if(i){e.close();return}M(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t])}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this._fullReader.headersReady;let{isStreamingSupported:i,isRangeSupported:s,contentLength:r}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:r}}),t.on("GetRangeReader",(t,e)=>{M(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let i=this._networkStream.getRangeReader(t.begin,t.end);if(!i){e.close();return}e.onPull=()=>{i.read().then(function({value:t,done:i}){if(i){e.close();return}M(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t])}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new eq(t,this))}),t.on("DocException",t=>{e._capability.reject(tN(t))}
2),t.on("PasswordRequest",t=>{this.#sr=Promise.withResolvers();try{if(!e.onPassword)throw tN(t);e.onPassword(t=>{t instanceof Error?this.#sr.reject(t):this.#sr.resolve({password:t})},t.code)}catch(t){this.#sr.reject(t)}return this.#sr.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#se.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":let{disableFontFace:r,fontExtraProperties:n,pdfBug:a}=this._params;if("error"in s){let t=s.error;T(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let o=new tD(s,{disableFontFace:r,fontExtraProperties:n,inspectFont:a&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null});this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!n&&o.data&&(o.data=null),this.commonObjs.resolve(e,o)});break;case"CopyLocalImage":let{imageRef:l}=s;for(let t of(M(l,"The imageRef must be defined."),this.#se.values()))for(let[,i]of t.objs)if(i?.ref===l){if(!i.dataLen)return null;return this.commonObjs.resolve(e,structuredClone(i)),i.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let r=this.#se.get(e);if(!r.objs.has(t)){if(0===r._intentStates.size){s?.bitmap?.close();return}switch(i){case"Image":r.objs.resolve(t,s),s?.dataLen>1e7&&(r._maybeCleanupAfterRender=!0);break;case"Pattern":r.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBuiltInCMap",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)}),t.on("FetchStandardFontData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&T("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.#si.get(e);if(i)return i;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw Error("Transport destroyed");i.refStr&&this.#ss.set(i.refStr,t);let s=new eX(e,i,this,this._params.pdfBug);return this.#se.set(e,s),s});return this.#si.set(e,s),s}getPageIndex(t){return eG(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#sn("GetFieldObjects")}hasJSActions(){return this.#sn("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}
2getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#sn("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#sn("GetOptionalContentConfig").then(e=>new eg(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#st.get(t);if(e)return e;let i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new ec(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#st.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#se.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#st.clear(),this.filterFactory.destroy(!0),eN.cleanup()}}cachedPageNumber(t){if(!eG(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#ss.get(e)??null}}let eJ=Symbol("INITIAL_DATA");class eZ{#sa=Object.create(null);#so(t){return this.#sa[t]||={...Promise.withResolvers(),data:eJ}}get(t,e=null){if(e){let i=this.#so(t);return i.promise.then(()=>e(i.data)),null}let i=this.#sa[t];if(!i||i.data===eJ)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#sa[t];return!!e&&e.data!==eJ}delete(t){let e=this.#sa[t];return!!e&&e.data!==eJ&&(delete this.#sa[t],!0)}resolve(t,e=null){let i=this.#so(t);i.data=e,i.resolve()}clear(){for(let t in this.#sa){let{data:e}=this.#sa[t];e?.bitmap?.close()}this.#sa=Object.create(null)}*[Symbol.iterator](){for(let t in this.#sa){let{data:e}=this.#sa[t];e!==eJ&&(yield[t,e])}}}class e0{#sl=null;constructor(t){this.#sl=t,this.onContinue=null}get promise(){return this.#sl.capability.promise}cancel(t=0){this.#sl.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#sl.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#sl;return t.form||t.canvas&&e?.size>0}}class e1{#sh=null;static #sd=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:r,operatorList:n,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new e0(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(e1.#sd.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.");e1.#sd.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:i,viewport:s,transform:r,background:n}=this.params;this.gfx=new eh(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:s,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#sh&&(window.cancelAnimationFrame(this.#sh),this.#sh=null),e1.#sd.delete(this._canvas),this.callback(t||new Z(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#sh=window.requestAnimationFrame(()=>{this.#sh=null,this._nextBound().catch(this._cancelBound)}
2):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){!this.cancelled&&(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),e1.#sd.delete(this._canvas),this.callback())))}}let e2="4.10.38",e5="f9bea397f";function e3(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function e6(t){return Math.max(0,Math.min(255,255*t))}o(670);class e4{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=e6(t),t,t]}static G_HTML([t]){let e=e3(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(e6)}static RGB_HTML(t){return`#${t.map(e3).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[e6(1-Math.min(1,t+s)),e6(1-Math.min(1,i+s)),e6(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,r=1-e,n=1-i;return["CMYK",s,r,n,Math.min(s,r,n)]}}class e9{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){C("Abstract method `_createSVG` called.")}}class e7 extends e9{_createSVG(t){return document.createElementNS(K,t)}}class e8{static setupStorage(t,e,i,s,r){let n=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==n.value&&(t.textContent=n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(n.value===i.attributes.xfaOn?t.setAttribute("checked",!0):n.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===r)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==n.value&&t.setAttribute("value",n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==n.value)for(let e of(t.setAttribute("value",n.value),i.children))e.attributes.value===n.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,r=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:r})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:r}){let{attributes:n}=e,a=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===n.type&&(n.name=`${n.name}-${s}`),Object.entries(n)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:a&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}a&&r.addLinkAttributes(t,n.href,n.newWindow),i&&n.dataId&&this.setupStorage(t,n.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,r=t.intent||"display",n=document.createElement(s.name);s.attributes&&this.setAttributes({html:n,element:s,intent:r,linkService:i});let a="richText"!==r,o=t.div;if(o.append(n),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);n.append(t),a&&eB.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,n]];for(;h.length>0;){let[t,s,n]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),n.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(n.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:r,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);a&&eB.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let it=new WeakSet;function ie(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class ii{static create(t){switch(t.data.annotationType){case A.LINK:return new ir(t);case A.TEXT:return new ia(t);case A.WIDGET:switch(t.data.fieldType){case"Tx":return new il(t);case"Btn":if(t.data.radioButton)return new ic(t);if(t.data.checkBox)return new id(t);return new iu(t);case"Ch":return new ip(t);case"Sig":return new ih(t)}return new io(t);case A.POPUP:return new ig(t);case A.FREETEXT:return new ib(t);case A.LINE:return new iv(t);case A.SQUARE:return new iA(t);case A.CIRCLE:return new iy(t);case A.POLYLINE:return new iw(t);case A.CARET:return new ix(t);case A.INK:return new iE(t);case A.POLYGON:return new i_(t);case A.HIGHLIGHT:return new iS(t);case A.UNDERLINE:return new iT(t);case A.SQUIGGLY:return new iC(t);case A.STRIKEOUT:return new iM(t);case A.STAMP:return new iP(t);case A.FILEATTACHMENT:return new iR(t);default:return new is(t)}}}class is{#sc=null;#su=!1;#sp=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return is._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#sc||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#sg(e),this.#sp?.popup.updateEdited(t)}resetEdited(){this.#sc&&(this.#sg(this.#sc.rect),this.#sp?.popup.resetEdited(),this.#sc=null)}#sg(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t);let{width:l,height:h}=ie(t);e.left=`${100*(t[0]-a)/r}%`,e.top=`${100*(n-t[3]+o)/n}%`,0===s?(e.width=`${100*l/r}%`,e.height=`${100*h/n}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),this instanceof io||(r.tabIndex=1e3);let{style:n}=r;if(n.zIndex=this.parent.zIndex++,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof ig){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,r),r}let{width:a,height:o}=ie(e.rect);if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){let e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;n.borderRadius=e}else if(this instanceof ic){let t=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;n.borderRadius=t}switch(e.borderStyle.style){case y.SOLID:n.borderStyle="solid";break;case y.DASHED:n.borderStyle="dashed";break;case y.BEVELED:T("Unimplemented border style: beveled");break;case y.INSET:T("Unimplemented border style: inset");break;case y.UNDERLINE:n.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#su=!0,n.borderColor=G.makeHexColor(0|s[0],0|s[1],0|s[2])):n.borderWidth=0}let l=G.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;n.left=`${100*(l[0]-c)/h}%`,n.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(n.width=`${100*a/h}%`,n.height=`${100*o/d}%`):this.setRotation(p,r),r}setRotation(t,e=this.container){let i,s;if(!this.data.rect)return;let{pageWidth:r,pageHeight:n}=this.parent.viewport.rawDims,{width:a,height:o}=ie(this.data.rect);t%180==0?(i=100*a/r,s=100*o/n):(i=100*o/r,s=100*a/n),e.style.width=`${i}%`,e.style.height=`${s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],r=s[0],n=s.slice(1);i.target.style[e]=e4[`${r}_HTML`](n),this.annotationStorage.setValue(this.data.id,{[e]:e4[`${r}_rgb`](n)})};return R(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>
2t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let r=t[s]||i[s];r?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,r]of Object.entries(e)){let n=i[s];n&&(n({detail:{[s]:r},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,r,n]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,a,o,l]=e.subarray(2,6);if(r===t&&n===a&&i===o&&s===l)return}let{style:a}=this.container;if(this.#su){let{borderColor:e,borderWidth:i}=a;a.borderWidth=0,t=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=r-i,l=n-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let s=2,r=e.length;s<r;
2s+=8){let r=e[s],a=e[s+1],d=e[s+2],c=e[s+3],p=h.createElement("rect"),g=(d-i)/o,f=(n-a)/l,m=(r-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#su&&(t.push("</g></svg>')"),a.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{data:t}=this,e=this.#sp=new ig({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){C("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:r,exportValues:n}of s){if(-1===t||r===e)continue;let s="string"==typeof n?n:null,a=document.querySelector(`[data-element-id="${r}"]`);if(a&&!it.has(a)){T(`_getElementsByName - element not allowed: ${r}`);continue}i.push({id:r,exportValue:s,domElement:a})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,r=s.getAttribute("data-element-id");r!==e&&it.has(s)&&i.push({id:r,exportValue:t,domElement:s})}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})})}}class ir extends is{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#sf(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#sm(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#sb(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#sb()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#sb()}#sf(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#sb()}#sm(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#sb()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let r=i.get(s);r&&(t[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#sb()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#sb(),!this._fieldObjects){T('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:r}=e,n=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===r&&n.push(i)}else for(let t of Object.values(this._fieldObjects))n.push(...t);let a=this.annotationStorage,o=[];for(let t of n){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!it.has(i)){T(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class ia extends is{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}
2class io extends is{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return U.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,r){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t)}})})}_setEventListeners(t,e,i,s){for(let[r,n]of i)("Action"===n||this.data.actions?.[n])&&(("Focus"===n||"Blur"===n)&&(e||={focused:!1}),this._setEventListener(t,e,r,n,s),"Focus"!==n||this.data.actions?.Blur?"Blur"!==n||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":G.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e;let{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,r=t.style,n=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);e=Math.min(s,n(t/(Math.round(t/(1.35*s))||1)/1.35))}else e=Math.min(s,n(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));r.fontSize=`calc(${e}px * var(--scale-factor))`,r.color=G.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class il extends io{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){let r=this.annotationStorage;
2for(let n of this._getElementsByName(t.name,t.id))n.domElement&&(n.domElement[e]=i),r.setValue(n.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),r=s.value||"",n=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;n&&r.length>n&&(r=r.slice(0,n));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let o={userValue:r,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=a??r,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type="text",i.setAttribute("value",a??r),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),it.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=1e3,this._setRequired(i,this.data.required),n&&(i.maxLength=n),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let l=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:r}=i;if(0===s){r.removeAttribute("maxLength");return}r.setAttribute("maxLength",s);let n=o.userValue;n&&!(n.length<=s)&&(n=n.slice(0,s),r.value=o.userValue=n,t.setValue(e,{value:n}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=l;l=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:r,selectionStart:n,selectionEnd:a}=s,l=n,h=a;switch(t.inputType){case"deleteWordBackward":{let t=r.substring(0,n).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}
2case"deleteWordForward":{let t=r.substring(n).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":n===a&&(l-=1);break;case"deleteContentForward":n===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(l&&i.addEventListener("blur",l),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/n;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else(i=document.createElement("div")).textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class ih extends io{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class id extends io{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return it.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=1e3,r.addEventListener("change",s=>{let{name:r,checked:n}=s.target;for(let s of this._getElementsByName(r,i)){let i=n&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:n})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ic extends io{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let r=document.createElement("input");if(it.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.tabIndex=1e3,r.addEventListener("change",e=>{let{name:s,checked:r}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:r})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let r=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=r&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}
2return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class iu extends ir{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class ip extends io{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");it.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=1e3;let r=this.data.combo&&this.data.options.length>0;for(let t of(!this.data.combo&&(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e}),this.data.options)){let e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),r=!1),s.append(e)}let n=null;if(r){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),n=()=>{t.remove(),s.removeEventListener("input",n),n=null},s.addEventListener("input",n)}let a=t=>{let e=t?"value":"textContent",{options:i,multiple:r}=s;return r?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},o=a(!1),l=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){n?.();let r=i.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){let r=s.options,n=i.detail.remove;r[n].selected=!1,s.remove(n),r.length>0&&-1===Array.prototype.findIndex.call(r,t=>t.selected)&&(r[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){let{index:r,displayValue:n,exportValue:h}=i.detail.insert,d=s.children[r],c=document.createElement("option");c.textContent=n,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){let{items:r}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of r){let{displayValue:e,exportValue:i}=t,r=document.createElement("option");r.textContent=e,r.value=i,s.append(r)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=a(!0),r=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:r,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ig extends is{constructor(t){let{data:e,elements:i}=t;super(t,{isRenderable:is._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new im({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(let i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(t=>`${X}${t}`).join(",")),this.container}}
2class im{#sv=this.#sA.bind(this);#sy=this.#sw.bind(this);#s_=this.#sx.bind(this);#sE=this.#sS.bind(this);#sT=null;#tp=null;#sC=null;#sM=null;#sP=null;#sR=null;#sI=null;#sk=!1;#sD=null;#T=null;#sL=null;#sF=null;#sO=null;#sc=null;#sN=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:r,contentsObj:n,richText:a,parent:o,rect:l,parentRect:h,open:d}){for(let d of(this.#tp=t,this.#sO=s,this.#sC=n,this.#sF=a,this.#sR=o,this.#sT=e,this.#sL=l,this.#sI=h,this.#sP=i,this.#sM=tl.toDateObject(r),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),this.trigger))d.addEventListener("click",this.#sE),d.addEventListener("mouseenter",this.#s_),d.addEventListener("mouseleave",this.#sy),d.classList.add("popupTriggerArea");for(let t of i)t.container?.addEventListener("keydown",this.#sv);this.#tp.hidden=!0,d&&this.#sS()}render(){if(this.#sD)return;let t=this.#sD=document.createElement("div");if(t.className="popup",this.#sT){let e=t.style.outlineColor=G.makeHexColor(...this.#sT);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:t.style.backgroundColor=G.makeHexColor(...this.#sT.map(t=>Math.floor(.7*(255-t)+t)))}let e=document.createElement("span");e.className="header";let i=document.createElement("h1");if(e.append(i),{dir:i.dir,str:i.textContent}=this.#sO,t.append(e),this.#sM){let t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#sM.valueOf()})),e.append(t)}let s=this.#sB;if(s)e8.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let e=this._formatContents(this.#sC);t.append(e)}this.#tp.append(t)}get #sB(){let t=this.#sF,e=this.#sC;return t?.str&&(!e?.str||e.str===t.str)&&this.#sF.html||null}get #sz(){return this.#sB?.attributes?.style?.fontSize||0}get #sH(){return this.#sB?.attributes?.style?.color||null}#sj(t){let e=[],i={style:{color:this.#sH,fontSize:this.#sz?`calc(${this.#sz}px * var(--scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}_formatContents({str:t,dir:e}){let i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let r=s[t];i.append(document.createTextNode(r)),t<e-1&&i.append(document.createElement("br"))}return i}#sA(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||"Enter"!==t.key&&("Escape"!==t.key||!this.#sk)||this.#sS()}updateEdited({rect:t,popupContent:e}){this.#sc||={contentsObj:this.#sC,richText:this.#sF},t&&(this.#T=null),e&&(this.#sF=this.#sj(e),this.#sC=null),this.#sD?.remove(),this.#sD=null}resetEdited(){this.#sc&&({contentsObj:this.#sC,richText:this.#sF}=this.#sc,this.#sc=null,this.#sD?.remove(),this.#sD=null,this.#T=null)}#sU(){if(null!==this.#T)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:r}}}=this.#sR,n=!!this.#sI,a=n?this.#sI:this.#sL;for(let t of this.#sP)if(!a||null!==G.intersect(t.data.rect,a)){a=t.data.rect,n=!0;break}let o=G.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=n?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#T=[100*(h-s)/e,100*(d-r)/i];let{style:c}=this.#tp;c.left=`${this.#T[0]}%`,c.top=`${this.#T[1]}%`}#sS(){this.#sk=!this.#sk,this.#sk?(this.#sx(),this.#tp.addEventListener("click",this.#sE),this.#tp.addEventListener("keydown",this.#sv)):(this.#sw(),this.#tp.removeEventListener("click",this.#sE),this.#tp.removeEventListener("keydown",this.#sv))}#sx(){this.#sD||this.render(),this.isVisible?this.#sk&&this.#tp.classList.add("focused"):(this.#sU(),this.#tp.hidden=!1,this.#tp.style.zIndex=parseInt(this.#tp.style.zIndex)+1e3)}#sw(){this.#tp.classList.remove("focused"),!this.#sk&&this.isVisible&&(this.#tp.hidden=!0,this.#tp.style.zIndex=parseInt(this.#tp.style.zIndex)-1e3)}forceHide(){this.#sN=this.isVisible,this.#sN&&(this.#tp.hidden=!0)}maybeShow(){this.#sN&&(this.#sD||this.#sx(),this.#sN=!1,this.#tp.hidden=!1)}get isVisible(){return!1===this.#tp.hidden}}class ib extends is{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=g.FREETEXT}
2render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class iv extends is{#s$=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:i}=ie(t.rect),s=this.svgFactory.create(e,i,!0),r=this.#s$=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),r.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),r.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),r.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),r.setAttribute("stroke-width",t.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#s$}addHighlightArea(){this.container.classList.add("highlightArea")}}class iA extends is{#sG=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:i}=ie(t.rect),s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,n=this.#sG=this.svgFactory.createElement("svg:rect");return n.setAttribute("x",r/2),n.setAttribute("y",r/2),n.setAttribute("width",e-r),n.setAttribute("height",i-r),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sG}addHighlightArea(){this.container.classList.add("highlightArea")}}class iy extends is{#sV=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:i}=ie(t.rect),s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,n=this.#sV=this.svgFactory.createElement("svg:ellipse");return n.setAttribute("cx",e/2),n.setAttribute("cy",i/2),n.setAttribute("rx",e/2-r/2),n.setAttribute("ry",i/2-r/2),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sV}addHighlightArea(){this.container.classList.add("highlightArea")}}class iw extends is{#sW=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;let{width:r,height:n}=ie(t),a=this.svgFactory.create(r,n,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],r=t[3]-e[i+1];o.push(`${s},${r}`)}o=o.join(" ");let l=this.#sW=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#sW}addHighlightArea(){this.container.classList.add("highlightArea")}}class i_ extends iw{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class ix extends is{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class iE extends is{#sq=null;#sX=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?g.HIGHLIGHT:g.INK}#sK(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:r}}=this,{transform:n,width:a,height:o}=this.#sK(e,t),l=this.svgFactory.create(a,o,!0),h=this.#sq=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",n);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#sX.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!r&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,r=this.#sq;if(e>=0&&r.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#sX.length;t<e;t++)this.#sX[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#sK(this.data.rotation,s);r.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),r.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#sX}addHighlightArea(){this.container.classList.add("highlightArea")}}class iS extends is{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=g.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}
2class iT extends is{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class iC extends is{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class iM extends is{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class iP extends is{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=g.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class iR extends is{#sY=null;constructor(t){super(t,{isRenderable:!0});let{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#sQ.bind(this)),this.#sY=t;let{isMac:s}=U.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#sQ()}),!i.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#sY}addHighlightArea(){this.container.classList.add("highlightArea")}#sQ(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class iI{#sJ=null;#sZ=null;#s0=new Map;#s1=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:r,viewport:n,structTreeLayer:a}){this.div=t,this.#sJ=e,this.#sZ=i,this.#s1=a||null,this.page=r,this.viewport=n,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#s0.size>0}async #s2(t,e){let i=t.firstChild||t,s=i.id=`${X}${e}`,r=await this.#s1?.getAriaAttributes(s);if(r)for(let[t,e]of r)i.setAttribute(t,e);this.div.append(t),this.#sJ?.moveElementInDOM(this.div,t,i,!1)}async render(t){let{annotations:e}=t,i=this.div;tp(i,this.viewport);let s=new Map,r={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new e7,annotationStorage:t.annotationStorage||new tR,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===A.POPUP;if(e){let e=s.get(t.id);if(!e)continue;r.elements=e}else{let{width:e,height:i}=ie(t.rect);if(e<=0||i<=0)continue}r.data=t;let i=ii.create(r);if(!i.isRenderable)continue;if(!e&&t.popupRef){let e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}let n=i.render();t.hidden&&(n.style.visibility="hidden"),await this.#s2(n,t.id),i._isEditable&&(this.#s0.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#s5()}update({viewport:t}){let e=this.div;this.viewport=t,tp(e,{rotation:t.rotation}),this.#s5(),e.hidden=!1}#s5(){if(!this.#sZ)return;let t=this.div;for(let[e,i]of this.#sZ){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";let{firstChild:r}=s;r?"CANVAS"===r.nodeName?r.replaceWith(i):r.classList.contains("annotationContent")?r.after(i):r.before(i):s.append(i)}this.#sZ.clear()}getEditableAnnotations(){return Array.from(this.#s0.values())}getEditableAnnotation(t){return this.#s0.get(t)}}let ik=/\r\n?|\n/g;class iD extends tT{#sT;#s3="";#s6=`${this.id}-editor`;#s4=null;#sz;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=iD.prototype,e=t=>t.isEmpty(),i=tx.TRANSLATE_SMALL,s=tx.TRANSLATE_BIG;return R(this,"_keyboardManager",new tw([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=g.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#sT=t.color||iD._defaultColor||tT._defaultLineColor,this.#sz=t.fontSize||iD._defaultFontSize}static initialize(t,e){tT.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
2static updateDefaultParams(t,e){switch(t){case f.FREETEXT_SIZE:iD._defaultFontSize=e;break;case f.FREETEXT_COLOR:iD._defaultColor=e}}updateParams(t,e){switch(t){case f.FREETEXT_SIZE:this.#s9(e);break;case f.FREETEXT_COLOR:this.#s7(e)}}static get defaultPropertiesToUpdate(){return[[f.FREETEXT_SIZE,iD._defaultFontSize],[f.FREETEXT_COLOR,iD._defaultColor||tT._defaultLineColor]]}get propertiesToUpdate(){return[[f.FREETEXT_SIZE,this.#sz],[f.FREETEXT_COLOR,this.#sT]]}#s9(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#sz)*this.parentScale),this.#sz=t,this.#s8()},i=this.#sz;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:f.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#s7(t){let e=t=>{this.#sT=this.editorDiv.style.color=t},i=this.#sT;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:f.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-iD._internalPadding*t,-(iD._internalPadding+this.#sz)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(g.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s4=new AbortController;let t=this._uiManager.combinedSignal(this.#s4);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#s6),this._isDraggable=!0,this.#s4?.abort(),this.#s4=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#rt(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(iD.#re(i)),e=i);return t.join("\n")}#s8(){let t;let[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,r=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#s3,e=this.#s3=this.#rt().trimEnd();if(t===e)return;let i=t=>{if(this.#s3=t,!t){this.remove();return}this.#ri(),this._uiManager.rebuild(this),this.#s8()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#s8()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){iD._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){let t,e;if(this.div)return this.div;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#s6),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:i}=this.editorDiv;if(i.fontSize=`calc(${this.#sz}
2px * var(--scale-factor))`,i.color=this.#sT,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),tb(this,this.div,["dblclick","keydown"]),this.width){let[i,s]=this.parentDimensions;if(this.annotationElementId){let r,n;let{position:a}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:r=t+(a[0]-c)/h,n=e+this.height-(a[1]-u)/d;break;case 90:r=t+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[l,-o];break;case 180:r=t-this.width+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[-o,-l];break;case 270:r=t+(a[0]-c-this.height*d)/h,n=e+(a[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(r*i,n*s,o,l)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#ri(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #re(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(ik,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=iD.#rs(e.getData("text")||"").replaceAll(ik,"\n");if(!s)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let n=r.getRangeAt(0);if(!s.includes("\n")){n.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),r.collapseToStart();return}let{startContainer:a,startOffset:o}=n,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(ik,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(iD.#re(i))}}l.push(a.nodeValue.slice(0,o).replaceAll(ik,""))}else if(a===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(iD.#re(i))}this.#s3=`${l.join("\n")}${s}${h.join("\n")}`,this.#ri();let d=new Range,c=l.reduce((t,e)=>t+e.length,0);for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}r.removeAllRanges(),r.addRange(d)}#ri(){if(this.editorDiv.replaceChildren(),this.#s3)for(let t of this.#s3.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#rr(){return this.#s3.replaceAll("\xa0"," ")}static #rs(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof ib){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:r,rotation:n,id:a,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:g.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:r.slice(0),rotation:n,id:a,deleted:!1,popupRef:o}}let r=await super.deserialize(t,e,i);return r.#sz=t.fontSize,r.#sT=G.makeHexColor(...t.color),r.#s3=iD.#rs(t.value),r.annotationElementId=t.id||null,r._initialData=s,r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=iD._internalPadding*this.parentScale,i=this.getRect(e,e),s=tT._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#sT),r={annotationType:g.FREETEXT,color:s,fontSize:this.#sz,value:this.#rr(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?r:this.annotationElementId&&!this.#rn(r)?null:(r.id=this.annotationElementId,r)}#rn(t){let{value:e,fontSize:i,color:s,pageIndex:r}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==r}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(this.deleted)return e;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#sz}px * var(--scale-factor))`,i.color=this.#sT,e.replaceChildren(),this.#s3.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}let s=iD._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#s3}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class iL{static PRECISION=1e-4;toSVGPath(){C("Abstract method `toSVGPath` must be implemented.")}get box(){C("Abstract getter `box` must be implemented.")}serialize(t,e){C("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*s,n[a+1]=i+t[a+1]*r;return n}static _rescaleAndSwap(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*s,n[a+1]=i+t[a]*r;return n}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r+=2)s[r]=e+t[r],s[r+1]=i+t[r+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,r){switch(r){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,r,n){return[(t+5*i)/6,(e+5*s)/6,(5*i+r)/6,(5*s+n)/6,(i+r)/2,(s+n)/2]}}class iF{#ra;#ro=[];#rl;#rh;#rd=[];#rc=new Float32Array(18);#ru;#rp;#rg;#rf;#rm;#rb;#rv=[];static #rA=8;static #ry=2;static #rw=iF.#rA+iF.#ry;constructor({x:t,y:e},i,s,r,n,a=0){this.#ra=i,this.#rb=r*s,this.#rh=n,this.#rc.set([NaN,NaN,NaN,NaN,t,e],6),this.#rl=a,this.#rf=iF.#rA*s,this.#rg=iF.#rw*s,this.#rm=s,this.#rv.push(t,e)}isEmpty(){return isNaN(this.#rc[8])}#r_(){let t=this.#rc.subarray(4,6),e=this.#rc.subarray(16,18),[i,s,r,n]=this.#ra;return[(this.#ru+(t[0]-e[0])/2-i)/r,(this.#rp+(t[1]-e[1])/2-s)/n,(this.#ru+(e[0]-t[0])/2-i)/r,(this.#rp+(e[1]-t[1])/2-s)/n]}add({x:t,y:e}){this.#ru=t,this.#rp=e;let[i,s,r,n]=this.#ra,[a,o,l,h]=this.#rc.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#rg)return!1;
2let p=u-this.#rf,g=p/u,f=g*d,m=g*c,b=a,v=o;a=l,o=h,l+=f,h+=m,this.#rv?.push(t,e);let A=-m/p*this.#rb,y=f/p*this.#rb;return(this.#rc.set(this.#rc.subarray(2,8),0),this.#rc.set([l+A,h+y],4),this.#rc.set(this.#rc.subarray(14,18),12),this.#rc.set([l-A,h-y],16),isNaN(this.#rc[6]))?(0===this.#rd.length&&(this.#rc.set([a+A,o+y],2),this.#rd.push(NaN,NaN,NaN,NaN,(a+A-i)/r,(o+y-s)/n),this.#rc.set([a-A,o-y],14),this.#ro.push(NaN,NaN,NaN,NaN,(a-A-i)/r,(o-y-s)/n)),this.#rc.set([b,v,a,o,l,h],6),!this.isEmpty()):((this.#rc.set([b,v,a,o,l,h],6),Math.abs(Math.atan2(v-o,b-a)-Math.atan2(m,f))<Math.PI/2)?([a,o,l,h]=this.#rc.subarray(2,6),this.#rd.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/r,((o+h)/2-s)/n),[a,o,b,v]=this.#rc.subarray(14,18),this.#ro.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/r,((v+o)/2-s)/n)):([b,v,a,o,l,h]=this.#rc.subarray(0,6),this.#rd.push(((b+5*a)/6-i)/r,((v+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n),[l,h,a,o,b,v]=this.#rc.subarray(12,18),this.#ro.push(((b+5*a)/6-i)/r,((v+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#rd,e=this.#ro;if(isNaN(this.#rc[6])&&!this.isEmpty())return this.#rx();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#rE(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#rS(i),i.join(" ")}#rx(){let[t,e,i,s]=this.#ra,[r,n,a,o]=this.#r_();return`M${(this.#rc[2]-t)/i} ${(this.#rc[3]-e)/s} L${(this.#rc[4]-t)/i} ${(this.#rc[5]-e)/s} L${r} ${n} L${a} ${o} L${(this.#rc[16]-t)/i} ${(this.#rc[17]-e)/s} L${(this.#rc[14]-t)/i} ${(this.#rc[15]-e)/s} Z`}#rS(t){let e=this.#ro;t.push(`L${e[4]} ${e[5]} Z`)}#rE(t){let[e,i,s,r]=this.#ra,n=this.#rc.subarray(4,6),a=this.#rc.subarray(16,18),[o,l,h,d]=this.#r_();t.push(`L${(n[0]-e)/s} ${(n[1]-i)/r} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/r}`)}newFreeDrawOutline(t,e,i,s,r,n){return new iO(t,e,i,s,r,n)}getOutlines(){let t=this.#rd,e=this.#ro,i=this.#rc,[s,r,n,a]=this.#ra,o=new Float32Array((this.#rv?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#rv[t]-s)/n,o[t+1]=(this.#rv[t+1]-r)/a;if(o[o.length-2]=(this.#ru-s)/n,o[o.length-1]=(this.#rp-r)/a,isNaN(i[6])&&!this.isEmpty())return this.#rT(o);let l=new Float32Array(this.#rd.length+24+this.#ro.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#rC(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#rM(l,h),this.newFreeDrawOutline(l,o,this.#ra,this.#rm,this.#rl,this.#rh)}#rT(t){let e=this.#rc,[i,s,r,n]=this.#ra,[a,o,l,h]=this.#r_(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/r,(e[3]-s)/n,NaN,NaN,NaN,NaN,(e[4]-i)/r,(e[5]-s)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/r,(e[17]-s)/n,NaN,NaN,NaN,NaN,(e[14]-i)/r,(e[15]-s)/n],0),this.newFreeDrawOutline(d,t,this.#ra,this.#rm,this.#rl,this.#rh)}#rM(t,e){let i=this.#ro;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#rC(t,e){let i=this.#rc.subarray(4,6),s=this.#rc.subarray(16,18),[r,n,a,o]=this.#ra,[l,h,d,c]=this.#r_();return t.set([NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-n)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-n)/o],e),e+=24}}class iO extends iL{#ra;#rP=new Float32Array(4);#rl;#rh;#rv;#rm;#rR;constructor(t,e,i,s,r,n){super(),this.#rR=t,this.#rv=e,this.#ra=i,this.#rm=s,this.#rl=r,this.#rh=n,this.lastPoint=[NaN,NaN],this.#rI(n);let[a,o,l,h]=this.#rP;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#rR[4]} ${this.#rR[5]}`];for(let e=6,i=this.#rR.length;e<i;e+=6){if(isNaN(this.#rR[e])){t.push(`L${this.#rR[e+4]} ${this.#rR[e+5]}`);continue}t.push(`C${this.#rR[e]} ${this.#rR[e+1]} ${this.#rR[e+2]} ${this.#rR[e+3]} ${this.#rR[e+4]} ${this.#rR[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],r){let n,a;let o=i-t,l=s-e;switch(r){case 0:n=iL._rescale(this.#rR,t,s,o,-l),a=iL._rescale(this.#rv,t,s,o,-l);break;case 90:n=iL._rescaleAndSwap(this.#rR,t,e,o,l),a=iL._rescaleAndSwap(this.#rv,t,e,o,l);break;case 180:n=iL._rescale(this.#rR,i,e,-o,l),a=iL._rescale(this.#rv,i,e,-o,l);break;case 270:n=iL._rescaleAndSwap(this.#rR,i,s,-o,-l),a=iL._rescaleAndSwap(this.#rv,i,s,-o,-l)}return{outline:Array.from(n),points:[Array.from(a)]}}#rI(t){let e=this.#rR,i=e[4],s=e[5],r=i,n=s,a=i,o=s,l=i,h=s,d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))r=Math.min(r,e[t+4]),n=Math.min(n,e[t+5]),a=Math.max(a,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{let c=G.bezierBoundingBox(i,s,...e.slice(t,t+6));r=Math.min(r,c[0]),n=Math.min(n,c[1]),a=Math.max(a,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}let c=this.#rP;c[0]=r-this.#rl,c[1]=n-this.#rl,c[2]=a-r+2*this.#rl,c[3]=o-n+2*this.#rl,this.lastPoint=[l,h]}get box(){return this.#rP}newOutliner(t,e,i,s,r,n=0){return new iF(t,e,i,s,r,n)}getNewOutline(t,e){let[i,s,r,n]=this.#rP,[a,o,l,h]=this.#ra,d=r*l,c=n*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#rv[0]*
2d+u,y:this.#rv[1]*c+p},this.#ra,this.#rm,t,this.#rh,e??this.#rl);for(let t=2;t<this.#rv.length;t+=2)g.add({x:this.#rv[t]*d+u,y:this.#rv[t+1]*c+p});return g.getOutlines()}}class iN{#ra;#rk;#rD=[];#rL=[];constructor(t,e=0,i=0,s=!0){let r=1/0,n=-1/0,a=1/0,o=-1/0;for(let{x:i,y:s,width:l,height:h}of t){let t=1e-4*Math.floor((i-e)/1e-4),d=1e-4*Math.ceil((i+l+e)/1e-4),c=1e-4*Math.floor((s-e)/1e-4),u=1e-4*Math.ceil((s+h+e)/1e-4),p=[t,c,u,!0],g=[d,c,u,!1];this.#rD.push(p,g),r=Math.min(r,t),n=Math.max(n,d),a=Math.min(a,c),o=Math.max(o,u)}let l=n-r+2*i,h=o-a+2*i,d=r-i,c=a-i,u=this.#rD.at(s?-1:-2),p=[u[0],u[2]];for(let t of this.#rD){let[e,i,s]=t;t[0]=(e-d)/l,t[1]=(i-c)/h,t[2]=(s-c)/h}this.#ra=new Float32Array([d,c,l,h]),this.#rk=p}getOutlines(){this.#rD.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#rD)e[3]?(t.push(...this.#rF(e)),this.#rO(e)):(this.#rN(e),t.push(...this.#rF(e)));return this.#rB(t)}#rB(t){let e;let i=[],s=new Set;for(let e of t){let[t,s,r]=e;i.push([t,s,e],[t,r,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],r=i[t+1][2];e.push(r),r.push(e),s.add(e),s.add(r)}let r=[];for(;s.size>0;){let t=s.values().next().value,[i,n,a,o,l]=t;s.delete(t);let h=i,d=n;for(e=[i,a],r.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,n,a,o,l]=t,h!==i&&(e.push(h,d,i,d===n?n:a),h=i),d=d===n?a:n}e.push(h,d)}return new iB(r,this.#ra,this.#rk)}#rz(t){let e=this.#rL,i=0,s=e.length-1;for(;i<=s;){let r=i+s>>1,n=e[r][0];if(n===t)return r;n<t?i=r+1:s=r-1}return s+1}#rO([,t,e]){let i=this.#rz(t);this.#rL.splice(i,0,[t,e])}#rN([,t,e]){let i=this.#rz(t);for(let s=i;s<this.#rL.length;s++){let[i,r]=this.#rL[s];if(i!==t)break;if(i===t&&r===e){this.#rL.splice(s,1);return}}for(let s=i-1;s>=0;s--){let[i,r]=this.#rL[s];if(i!==t)break;if(i===t&&r===e){this.#rL.splice(s,1);return}}}#rF(t){let[e,i,s]=t,r=[[e,i,s]],n=this.#rz(s);for(let t=0;t<n;t++){let[i,s]=this.#rL[t];for(let t=0,n=r.length;t<n;t++){let[,a,o]=r[t];if(!(s<=a)&&!(o<=i)){if(a>=i){if(o>s)r[t][1]=s;else{if(1===n)return[];r.splice(t,1),t--,n--}continue}r[t][2]=i,o>s&&r.push([e,s,o])}}}return r}}class iB extends iL{#ra;#rH;constructor(t,e,i){super(),this.#rH=t,this.#ra=e,this.lastPoint=i}toSVGPath(){let t=[];for(let e of this.#rH){let[i,s]=e;t.push(`M${i} ${s}`);for(let r=2;r<e.length;r+=2){let n=e[r],a=e[r+1];n===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${n}`),i=n)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],r){let n=[],a=i-t,o=s-e;for(let e of this.#rH){let i=Array(e.length);for(let r=0;r<e.length;r+=2)i[r]=t+e[r]*a,i[r+1]=s-e[r+1]*o;n.push(i)}return n}get box(){return this.#ra}get classNamesForOutlining(){return["highlightOutline"]}}class iz extends iF{newFreeDrawOutline(t,e,i,s,r,n){return new iH(t,e,i,s,r,n)}}class iH extends iO{newOutliner(t,e,i,s,r,n=0){return new iz(t,e,i,s,r,n)}}class ij{#rj=null;#rU=null;#r$;#rG=null;#rV=!1;#rW=!1;#n=null;#rq;#rX=null;#f=null;#rK;static #rY=null;static get _keyboardManager(){return R(this,"_keyboardManager",new tw([[["Escape","mac+Escape"],ij.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ij.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ij.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ij.prototype._moveToPrevious],[["Home","mac+Home"],ij.prototype._moveToBeginning],[["End","mac+End"],ij.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#rW=!1,this.#rK=f.HIGHLIGHT_COLOR,this.#n=t):(this.#rW=!0,this.#rK=f.HIGHLIGHT_DEFAULT_COLOR),this.#f=t?._uiManager||e,this.#rq=this.#f._eventBus,this.#r$=t?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",ij.#rY||=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 t=this.#rj=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);let e=this.#f._signal;t.addEventListener("click",this.#rQ.bind(this),{signal:e}),t.addEventListener("keydown",this.#sA.bind(this),{signal:e});let i=this.#rU=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#r$,t.append(i),t}renderMainDropdown(){let t=this.#rG=this.#rJ();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#rJ(){let t=document.createElement("div"),e=this.#f._signal;for(let[i,s]of(t.addEventListener("contextmenu",ta,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#f.highlightColors)){let r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",s),r.title=i,r.setAttribute("data-l10n-id",ij.#rY[i]);let n=document.createElement("span");r.append(n),n.className="swatch",n.style.backgroundColor=s,r.setAttribute("aria-selected",s===this.#r$),r.addEventListener("click",this.#rZ.bind(this,s),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#sA.bind(this),{signal:e}),t}#rZ(t,e){e.stopPropagation(),this.#rq.dispatch("switchannotationeditorparams",{source:this,type:this.#rK,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#rj){this.#rQ(t);return}let e=t.target.getAttribute("data-color");e&&this.#rZ(e,t)}_moveToNext(t){if(!this.#r0){this.#rQ(t);return}if(t.target===this.#rj){this.#rG.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#rG?.firstChild||t.target===this.#rj){this.#r0&&this._hideDropdownFromKeyboard();return}this.#r0||this.#rQ(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#r0){this.#rQ(t);return}this.#rG.firstChild?.focus()}_moveToEnd(t){if(!this.#r0){this.#rQ(t);return}
2this.#rG.lastChild?.focus()}#sA(t){ij._keyboardManager.exec(this,t)}#rQ(t){if(this.#r0){this.hideDropdown();return}if(this.#rV=0===t.detail,this.#rX||(this.#rX=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#rX)})),this.#rG){this.#rG.classList.remove("hidden");return}let e=this.#rG=this.#rJ();this.#rj.append(e)}#h(t){this.#rG?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#rG?.classList.add("hidden"),this.#rX?.abort(),this.#rX=null}get #r0(){return this.#rG&&!this.#rG.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#rW){if(!this.#r0){this.#n?.unselect();return}this.hideDropdown(),this.#rj.focus({preventScroll:!0,focusVisible:this.#rV})}}updateColor(t){if(this.#rU&&(this.#rU.style.backgroundColor=t),!this.#rG)return;let e=this.#f.highlightColors.values();for(let i of this.#rG.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#rj?.remove(),this.#rj=null,this.#rU=null,this.#rG?.remove(),this.#rG=null}}class iU extends tT{#r1=null;#r2=0;#r5;#r3=null;#r=null;#r6=null;#r4=null;#r9=0;#r7=null;#r8=null;#A=null;#nt=!1;#rk=null;#ne;#ni=null;#ns="";#rb;#nr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=g.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=iU.prototype;return R(this,"_keyboardManager",new tw([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||iU._defaultColor,this.#rb=t.thickness||iU._defaultThickness,this.#ne=t.opacity||iU._defaultOpacity,this.#r5=t.boxes||null,this.#nr=t.methodOfCreation||"",this.#ns=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#nt=!0,this.#nn(t),this.#na()):this.#r5&&(this.#r1=t.anchorNode,this.#r2=t.anchorOffset,this.#r4=t.focusNode,this.#r9=t.focusOffset,this.#no(),this.#na(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#nt?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#rb,methodOfCreation:this.#nr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#no(){let t=new iN(this.#r5,.001);this.#r8=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#r8.box;let e=new iN(this.#r5,.0025,.001,"ltr"===this._uiManager.direction);this.#r6=e.getOutlines();let{lastPoint:i}=this.#r6;this.#rk=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#nn({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#r8=t,this.#r6=t.getNewOutline(this.#rb/2+1.5,.0025),e>=0)this.#A=e,this.#r3=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#ni=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#r6.box,path:{d:this.#r6.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#A,{bbox:iU.#nl(this.#r8.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#ni,{bbox:iU.#nl(this.#r6.box,e),path:{d:this.#r6.toSVGPath()}})}let[s,r,n,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=r,this.width=n,this.height=a;break;case 90:{let[t,e]=this.parentDimensions;this.x=r,this.y=1-s,this.width=n*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-r,this.width=n,this.height=a;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-r,this.y=s,this.width=n*e/t,this.height=a*t/e}}let{lastPoint:o}=this.#r6;this.#rk=[(o[0]-s)/n,(o[1]-r)/a]}static initialize(t,e){tT.initialize(t,e),iU._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case f.HIGHLIGHT_DEFAULT_COLOR:iU._defaultColor=e;break;case f.HIGHLIGHT_THICKNESS:iU._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#rk}updateParams(t,e){switch(t){case f.HIGHLIGHT_COLOR:this.#s7(e);break;case f.HIGHLIGHT_THICKNESS:this.#nh(e)}}static get defaultPropertiesToUpdate(){return[[f.HIGHLIGHT_DEFAULT_COLOR,iU._defaultColor],[f.HIGHLIGHT_THICKNESS,iU._defaultThickness]]}get propertiesToUpdate(){return[[f.HIGHLIGHT_COLOR,this.color||iU._defaultColor],[f.HIGHLIGHT_THICKNESS,this.#rb||iU._defaultThickness],[f.HIGHLIGHT_FREE,this.#nt]]}#s7(t){let e=(t,e)=>{this.color=t,this.#ne=e,this.parent?.drawLayer.updateProperties(this.#A,{root:{fill:t,"fill-opacity":e}}),this.#r?.updateColor(t)},i=this.color,s=this.#ne;this.addCommands({cmd:e.bind(this,t,iU._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:f.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#nh(t){let e=this.#rb,i=t=>{this.#rb=t,this.#nd(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:f.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){let t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#r=new ij({editor:this}),t.addColorPicker(this.#r)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#nc())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#nc())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#nu(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#na(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#nu():t&&(this.#na(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#nd(t){if(!this.#nt)return;this.#nn({highlightOutlines:this.#r8.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#nu(){null!==this.#A&&this.parent&&(this.parent.drawLayer.remove(this.#A),this.#A=null,this.parent.drawLayer.remove(this.#ni),this.#ni=null)}#na(t=this.parent){null===this.#A&&({id:this.#A,clipPathId:this.#r3}=t.drawLayer.draw({bbox:this.#r8.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#ne},rootClass:{highlight:!0,free:this.#nt},path:{d:this.#r8.toSVGPath()}},!1,!0),this.#ni=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#nt},bbox:this.#r6.box,path:{d:this.#r6.toSVGPath()}},this.#nt),this.#r7&&(this.#r7.style.clipPath=this.#r3))}static #nl([t,e,i,s],r){switch(r){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){let e;let{drawLayer:i}
2=this.parent;this.#nt?(t=(t-this.rotation+360)%360,e=iU.#nl(this.#r8.box,t)):e=iU.#nl([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#A,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#ni,{bbox:iU.#nl(this.#r6.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#ns&&(t.setAttribute("aria-label",this.#ns),t.setAttribute("role","mark")),this.#nt?t.classList.add("free"):this.div.addEventListener("keydown",this.#np.bind(this),{signal:this._uiManager._signal});let e=this.#r7=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#r3;let[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),tb(this,this.#r7,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ni,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ni,{rootClass:{hovered:!1}})}#np(t){iU._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#ng(!0);break;case 1:case 3:this.#ng(!1)}}#ng(t){if(!this.#r1)return;let e=window.getSelection();t?e.setPosition(this.#r1,this.#r2):e.setPosition(this.#r4,this.#r9)}select(){super.select(),this.#ni&&this.parent?.drawLayer.updateProperties(this.#ni,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#ni&&(this.parent?.drawLayer.updateProperties(this.#ni,{rootClass:{selected:!1}}),this.#nt||this.#ng(!1))}get _mustFixPosition(){return!this.#nt}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#A,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#ni,{rootClass:{hidden:!t}}))}#nc(){return this.#nt?this.rotation:0}#nf(){if(this.#nt)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,r=this.#r5,n=new Float32Array(8*r.length),a=0;for(let{x:o,y:l,width:h,height:d}of r){let r=o*t+i,c=(1-l)*e+s;n[a]=n[a+4]=r,n[a+1]=n[a+3]=c,n[a+2]=n[a+6]=r+h*t,n[a+5]=n[a+7]=c-d*e,a+=8}return n}#nm(t){return this.#r8.serialize(t,this.#nc())}static startHighlighting(t,e,{target:i,x:s,y:r}){let{x:n,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#nb(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",to,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",ta,{signal:d}),i.addEventListener("pointermove",this.#nv.bind(this,t),{signal:d}),this._freeHighlight=new iz({x:s,y:r},[n,a,o,l],t.scale,this._defaultThickness/2,e,.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 #nv(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #nb(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof iS){let{data:{quadPoints:e,rect:i,rotation:r,id:n,color:a,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:g.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:r,id:n,deleted:!1,popupRef:l}}else if(t instanceof iE){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:g.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:r,id:n,deleted:!1,popupRef:l}}let{color:r,quadPoints:n,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=G.makeHexColor(...r),l.#ne=o||1,a&&(l.#rb=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;let[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(n){let t=l.#r5=[];for(let e=0;e<n.length;e+=8)t.push({x:(n[e]-c)/h,y:1-(n[e+1]-u)/d,width:(n[e+2]-n[e])/h,height:(n[e+1]-n[e+5])/d});l.#no(),l.#na(),l.rotate(l.rotation)}else if(a){l.#nt=!0;let t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new iz(i,[0,0,h,d],1,l.#rb/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),s.add(i);let{id:r,clipPathId:n}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#nn({highlightOutlines:s.getOutlines(),highlightId:r,clipPathId:n}),l.#na()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=this.getRect(0,0),i=tT._colorManager.convert(this.color),s={annotationType:g.HIGHLIGHT,color:i,opacity:this.#ne,thickness:this.#rb,quadPoints:this.#nf(),outlines:this.#nm(e),pageIndex:this.pageIndex,rect:e,rotation:this.#nc(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#rn(s)?null:(s.id=this.annotationElementId,s)}#rn(t){let{color:e}=this._initialData;return t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class i${#nA=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#nA[t]=e}toSVGProperties(){let t=this.#nA;return this.#nA=Object.create(null),{root:t}}reset(){this.#nA=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){C("Not implemented")}}class iG extends tT{#ny=null;#nw;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #n_=null;static #nx=null;static #nE=null;static #nS=NaN;static #nT=null;static #nC=null;static #nM=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#nw=t.mustBeCommitted||!1,t.drawOutlines&&
2(this.#nP(t),this.#na())}#nP({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ny=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#nR(t,this.parent),this.#nI(t.box)}#nR(t,e){let{id:i}=e.drawLayer.draw(iG._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,r]of Object.entries(e))i.has(s)?Object.assign(t[s],r):t[s]=r;return t}static getDefaultDrawingOptions(t){C("Not implemented")}static get typesMap(){C("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(iG.#n_.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,r=s[e],n=t=>{s.updateProperty(e,t);let i=this.#ny.updateProperty(e,t);i&&this.#nI(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:n.bind(this,i),undo:n.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,iG._mergeSVGProperties(this.#ny.getPathResizingSVGProperties(this.#nk()),{bbox:this.#nD()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,iG._mergeSVGProperties(this.#ny.getPathResizedSVGProperties(this.#nk()),{bbox:this.#nD()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#nD(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,iG._mergeSVGProperties(this.#ny.getPathTranslatedSVGProperties(this.#nk(),this.parentDimensions),{bbox:this.#nD()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.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(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#nw&&(this.#nw=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#nu(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#na(),this.#nI(this.#ny.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#nu()):t&&(this._uiManager.addShouldRescale(this),this.#na(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#nu(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#na(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#nR(this.#ny,t)}}#nL([t,e,i,s]){let{parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[e,1-t,n/r*i,r/n*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,n/r*i,r/n*s];default:return[t,e,i,s]}}#nk(){let{x:t,y:e,width:i,height:s,parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[1-e,t,r/n*i,n/r*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,r/n*i,n/r*s];default:return[t,e,i,s]}}#nI(t){if([this.x,this.y,this.width,this.height]=this.#nL(t),this.div){this.fixAndSetPosition();let[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#nD(){let{x:t,y:e,width:i,height:s,rotation:r,parentRotation:n,parentDimensions:[a,o]}=this;switch((4*r+n)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-a/o*i,o/a*s,a/o*i];case 5:return[1-e,t,a/o*i,o/a*s];case 6:return[1-t-o/a*s,1-e,o/a*s,a/o*i];case 7:return[e-a/o*i,1-t-o/a*s,a/o*i,o/a*s];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-o/a*s,e,o/a*s,a/o*i];case 13:return[1-e-a/o*i,t-o/a*s,a/o*i,o/a*s];case 14:return[1-t,1-e-a/o*i,o/a*s,a/o*i];case 15:return[e,1-t,a/o*i,o/a*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,iG._mergeSVGProperties({bbox:this.#nD()},this.#ny.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#nI(this.#ny.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}
2render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";let[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,r){C("Not implemented")}static startDrawing(t,e,i,s){let{target:r,offsetX:n,offsetY:a,pointerId:o,pointerType:l}=s;if(iG.#nT&&iG.#nT!==l)return;let{viewport:{rotation:h}}=t,{width:d,height:c}=r.getBoundingClientRect(),u=iG.#nx=new AbortController,p=t.combinedSignal(u);if(iG.#nS||=o,iG.#nT??=l,window.addEventListener("pointerup",t=>{iG.#nS===t.pointerId?this._endDraw(t):iG.#nC?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointercancel",t=>{iG.#nS===t.pointerId?this._currentParent.endDrawingSession():iG.#nC?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointerdown",t=>{iG.#nT===t.pointerType&&((iG.#nC||=new Set).add(t.pointerId),iG.#n_.isCancellable()&&(iG.#n_.removeLastElement(),iG.#n_.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",ta,{signal:p}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),r.addEventListener("touchmove",t=>{t.timeStamp===iG.#nM&&to(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),iG.#n_){t.drawLayer.updateProperties(this._currentDrawId,iG.#n_.startNew(n,a,d,c,h));return}e.updateUIForDefaultProperties(this),iG.#n_=this.createDrawerInstance(n,a,d,c,h),iG.#nE=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(iG.#nE.toSVGProperties(),iG.#n_.defaultSVGProperties),!0,!1)}static _drawMove(t){if(iG.#nM=-1,!iG.#n_)return;let{offsetX:e,offsetY:i,pointerId:s}=t;if(iG.#nS===s){if(iG.#nC?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,iG.#n_.add(e,i)),iG.#nM=t.timeStamp,to(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,iG.#n_=null,iG.#nE=null,iG.#nT=null,iG.#nM=NaN),iG.#nx&&(iG.#nx.abort(),iG.#nx=null,iG.#nS=NaN,iG.#nC=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,iG.#n_.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=iG.#n_,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:f.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(f.DRAW_STEP),!iG.#n_.isEmpty()){let{pageDimensions:[i,s],scale:r}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:iG.#n_.getOutlines(i*r,s*r,r,this._INNER_MARGIN),drawingOptions:iG.#nE,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,r,n){C("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:r,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,s,r,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#nP({drawOutlines:o}),l.#na(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,r]=this.pageDimensions;return this.#ny.serialize([e,i,s,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class iV{#rc=new Float64Array(6);#s$;#nF;#iD;#rb;#rv;#nO="";#nN=0;#rH=new iW;#nB;#nz;constructor(t,e,i,s,r,n){this.#nB=i,this.#nz=s,this.#iD=r,this.#rb=n,[t,e]=this.#nH(t,e);let a=this.#s$=[NaN,NaN,NaN,NaN,t,e];this.#rv=[t,e],this.#nF=[{line:a,points:this.#rv}],this.#rc.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#rb=e)}#nH(t,e){return iL._normalizePoint(t,e,this.#nB,this.#nz,this.#iD)}isEmpty(){return!this.#nF||0===this.#nF.length}isCancellable(){return this.#rv.length<=10}add(t,e){[t,e]=this.#nH(t,e);let[i,s,r,n]=this.#rc.subarray(2,6),a=t-r,o=e-n;return 2>=Math.hypot(this.#nB*a,this.#nz*o)?null:((this.#rv.push(t,e),isNaN(i))?(this.#rc.set([r,n,t,e],2),this.#s$.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#rc[0])&&this.#s$.splice(6,6),this.#rc.set([i,s,r,n,t,e],0),this.#s$.push(...iL.createBezierPoints(i,s,r,n,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){return this.add(t,e)||(2===this.#rv.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,r){this.#nB=i,this.#nz=s,this.#iD=r,[t,e]=this.#nH(t,e);let n=this.#s$=[NaN,NaN,NaN,NaN,t,e];this.#rv=[t,e];let a=this.#nF.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#nF.push({line:n,points:this.#rv}),this.#rc.set(n,0),this.#nN=0,this.toSVGPath(),null}getLastElement(){return this.#nF.at(-1)}setLastElement(t){return this.#nF?(this.#nF.push(t),this.#s$=t.line,this.#rv=t.points,this.#nN=0,{path:{d:this.toSVGPath()}}):this.#rH.setLastElement(t)}removeLastElement(){if(!this.#nF)return this.#rH.removeLastElement();this.#nF.pop(),this.#nO="";for(let t=0,e=this.#nF.length;t<e;t++){let{line:e,points:i}=this.#nF[t];this.#s$=e,this.#rv=i,this.#nN=0,this.toSVGPath()}return{path:{d:this.#nO}}}toSVGPath(){let t=iL.svgRound(this.#s$[4]),e=iL.svgRound(this.#s$[5]);if(2===this.#rv.length)return this.#nO=`${this.#nO} M ${t} ${e} Z`,this.#nO;if(this.#rv.length<=6){let i=this.#nO.lastIndexOf("M");this.#nO=`${this.#nO.slice(0,i)} M ${t} ${e}`,this.#nN=6}if(4===this.#rv.length){let t=iL.svgRound(this.#s$[10]),e=iL.svgRound(this.#s$[11]);return this.#nO=`${this.#nO} L ${t} ${e}`,this.#nN=12,this.#nO}let i=[];0===this.#nN&&(i.push(`M ${t} ${e}`),this.#nN=6);for(let t=this.#nN,e=this.#s$.length;t<e;t+=6){let[e,s,r,n,a,o]=this.#s$.slice(t,t+6).map(iL.svgRound);i.push(`C${e} ${s} ${r} ${n} ${a} ${o}`)}return this.#nO+=i.join(" "),this.#nN=this.#s$.length,this.#nO}getOutlines(t,e,i,s){let r=this.#nF.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#rH.build(this.#nF,t,e,i,this.#iD,this.#rb,s),this.#rc=null,this.#s$=null,this.#nF=null,this.#nO=null,this.#rH}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class iW extends iL{#rP;#nj=0;#rl;#nF;#nB;#nz;#nU;#iD;#rb;build(t,e,i,s,r,n,a){this.#nB=e,this.#nz=i,this.#nU=s,this.#iD=r,this.#rb=n,this.#rl=a??0,this.#nF=t,this.#n$()}setLastElement(t){return this.#nF.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#nF.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#nF){if(t.push(`M${iL.svgRound(e[4])} ${iL.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length){t.push(`L${iL.svgRound(e[10])} ${iL.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){let[s,r,n,a,o,l]=e.subarray(i,i+6).map(iL.svgRound);t.push(`C${s} ${r} ${n} ${a} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,s],r){let n,a,o,l,h,d,c,u,p;let g=[],f=[],[m,b,v,A]=this.#nG();switch(this.#iD){case 0:p=iL._rescale,n=t,a=e+s,o=i,l=-s,h=t+m*i,d=e+(1-b-A)*s,c=t+(m+v)*i,u=e+(1-b)*s;break;case 90:p=iL._rescaleAndSwap,n=t,a=e,o=i,l=s,h=t+b*i,d=e+m*s,c=t+(b+A)*i,u=e+(m+v)*s;break;case 180:p=iL._rescale,n=t+i,a=e,o=-i,l=s,h=t+(1-m-v)*i,d=e+b*s,c=t+(1-m)*i,u=e+(b+A)*s;break;case 270:p=iL._rescaleAndSwap,n=t+i,a=e+s,o=-i,l=-s,h=t+(1-b-A)*i,d=e+(1-m-v)*s,c=t+(1-b)*i,u=e+(1-m)*s}for(let{line:t,points:e}of this.#nF)g.push(p(t,n,a,o,l,r?Array(t.length):null)),f.push(p(e,n,a,o,l,r?Array(e.length):null));return{lines:g,points:f,rect:[h,d,c,u]}}static deserialize(t,e,i,s,r,{paths:{lines:n,points:a},rotation:o,thickness:l}){let h,d,c,u,p;let g=[];switch(o){case 0:p=iL._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=iL._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=iL._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=iL._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!n)for(let t of(n=[],a)){let e=t.length;if(2===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));n.push(i);let[s,r,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,r],0);for(let n=4;n<e;n+=2){let e=t[n],l=t[n+1];i.set(iL.createBezierPoints(s,r,a,o,e,l),(n-2)*3),[s,r,a,o]=[a,o,e,l]}}for(let t=0,e=n.length;t<e;t++)g.push({line:p(n[t].map(t=>t??NaN),h,d,c,u),points:p(a[t].map(t=>t??NaN),h,d,c,u)});let f=new iW;return f.build(g,i,s,1,o,l,r),f}#nV(t=this.#rb){let e=this.#rl+t/2*this.#nU;return this.#iD%180==0?[e/this.#nB,e/this.#nz]:[e/this.#nz,e/this.#nB]}#nG(){let[t,e,i,s]=this.#rP,[r,n]=this.#nV(0);return[t+r,e+n,i-2*r,s-2*n]}
2#n$(){let t=this.#rP=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:e}of this.#nF){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){let[s,r]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],r)}continue}let i=e[4],s=e[5];for(let r=6,n=e.length;r<n;r+=6){let[n,a,o,l,h,d]=e.subarray(r,r+6);G.bezierBoundingBox(i,s,n,a,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#nV();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#rP}updateProperty(t,e){return"stroke-width"===t?this.#nh(e):null}#nh(t){let[e,i]=this.#nV();this.#rb=t;let[s,r]=this.#nV(),[n,a]=[s-e,r-i],o=this.#rP;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],i){let[s,r]=this.#nV();this.#nB=t,this.#nz=e,this.#nU=i;let[n,a]=this.#nV(),o=n-s,l=a-r,h=this.#rP;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#nj=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#rP.map(iL.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#rP;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${iL.svgRound(t)} ${iL.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#rP,i=0,s=0,r=0,n=0,a=0,o=0;switch(this.#nj){case 90:s=e/t,r=-t/e,a=t;break;case 180:i=-1,n=-1,a=t,o=e;break;case 270:s=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${r} ${n} ${iL.svgRound(a)} ${iL.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[r,n]=this.#nV(),[a,o,l,h]=this.#rP;if(Math.abs(l-r)<=iL.PRECISION||Math.abs(h-n)<=iL.PRECISION){let r=t+i/2-(a+l/2),n=e+s/2-(o+h/2);return{path:{"transform-origin":`${iL.svgRound(t)} ${iL.svgRound(e)}`,transform:`${this.rotationTransform} translate(${r} ${n})`}}}let d=(i-2*r)/(l-2*r),c=(s-2*n)/(h-2*n);return{path:{"transform-origin":`${iL.svgRound(a)} ${iL.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/s}) translate(${iL.svgRound(r)} ${iL.svgRound(n)}) scale(${d} ${c}) translate(${iL.svgRound(-r)} ${iL.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[r,n]=this.#nV(),a=this.#rP,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-r)<=iL.PRECISION||Math.abs(d-n)<=iL.PRECISION){let r=t+i/2-(o+h/2),n=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#nF)iL._translate(t,r,n,t),iL._translate(e,r,n,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${iL.svgRound(t)} ${iL.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*r)/(h-2*r),u=(s-2*n)/(d-2*n),p=-c*(o+r)+t+r,g=-u*(l+n)+e+n;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#nF)iL._rescale(t,p,g,c,u,t),iL._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${iL.svgRound(t)} ${iL.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,r]=i,n=this.#rP,a=t-n[0],o=e-n[1];if(this.#nB===s&&this.#nz===r)for(let{line:t,points:e}of this.#nF)iL._translate(t,a,o,t),iL._translate(e,a,o,e);else{let t=this.#nB/s,e=this.#nz/r;for(let{line:i,points:n}of(this.#nB=s,this.#nz=r,this.#nF))iL._rescale(i,a,o,t,e,i),iL._rescale(n,a,o,t,e,n);n[2]*=t,n[3]*=e}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${iL.svgRound(t)} ${iL.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#rP;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${iL.svgRound(t[0])} ${iL.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class iq extends i${#nW;constructor(t){super(),this.#nW=t,super.updateProperties({fill:"none",stroke:tT._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#nW.realScale),super.updateSVGProperty(t,e)}clone(){let t=new iq(this.#nW);return t.updateAll(this),t}}class iX extends iG{static _type="ink";static _editorType=g.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){tT.initialize(t,e),this._defaultDrawingOptions=new iq(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return R(this,"typesMap",new Map([[f.INK_THICKNESS,"stroke-width"],[f.INK_COLOR,"stroke"],[f.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,r){return new iV(t,e,i,s,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,r,n){return iW.deserialize(t,e,i,s,r,n)}static async deserialize(t,e,i){let s=null;if(t instanceof iE){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:g.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:r,id:n,deleted:!1,popupRef:h}}let r=await super.deserialize(t,e,i);return r.annotationElementId=t.id||null,r._initialData=s,r}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=iX.getDefaultDrawingOptions({stroke:G.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:r,"stroke-opacity":n,"stroke-width":a}}=this,o={annotationType:g.INK,color:tT._colorManager.convert(r),opacity:n,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#rn(o)?null:(o.id=this.annotationElementId,o)}#rn(t){let{color:e,thickness:i,opacity:s,pageIndex:r}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==r}renderAnnotationElement(t){let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class iK extends tT{#nq=null;#nX=null;#nK=null;#nY=null;#nQ=null;#nJ="";#nZ=null;#n0=null;#n1=!1;#n2=!1;static _type="stamp";static _editorType=g.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#nY=t.bitmapUrl,this.#nQ=t.bitmapFile}static initialize(t,e){tT.initialize(t,e)}static get supportedTypes(){return R(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(t=>`image/${t}`))}static get supportedTypesStr(){return R(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(g.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#n5(t,e=!1){if(!t){this.remove();return}this.#nq=t.bitmap,e||(this.#nX=t.id,this.#n1=t.isSvg),t.file&&(this.#nJ=t.file.name),this.#n3()}#n6(){if(this.#nK=null,this._uiManager.enableWaiting(!1),this.#nZ){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#nq){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#nq){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:r,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:r,height:n,
2channels:s.length/(r*n)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#n4(){if(this.#nX){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#nX).then(t=>this.#n5(t,!0)).finally(()=>this.#n6());return}if(this.#nY){let t=this.#nY;this.#nY=null,this._uiManager.enableWaiting(!0),this.#nK=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#n5(t)).finally(()=>this.#n6());return}if(this.#nQ){let t=this.#nQ;this.#nQ=null,this._uiManager.enableWaiting(!0),this.#nK=this._uiManager.imageManager.getFromFile(t).then(t=>this.#n5(t)).finally(()=>this.#n6());return}let t=document.createElement("input");t.type="file",t.accept=iK.supportedTypesStr;let e=this._uiManager._signal;this.#nK=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#n5(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#n6()),t.click()}remove(){this.#nX&&(this.#nq=null,this._uiManager.imageManager.deleteId(this.#nX),this.#nZ?.remove(),this.#nZ=null,this.#n0&&(clearTimeout(this.#n0),this.#n0=null)),super.remove()}rebuild(){if(!this.parent){this.#nX&&this.#n4();return}super.rebuild(),null!==this.div&&(this.#nX&&null===this.#nZ&&this.#n4(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#nK||this.#nq||this.#nY||this.#nQ||this.#nX)}get isResizable(){return!0}render(){let t,e;if(this.div)return this.div;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#nq?this.#n3():this.#n4(),this.width&&!this.annotationElementId){let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#n0&&clearTimeout(this.#n0),this.#n0=setTimeout(()=>{this.#n0=null,this.#n9()},200))}#n3(){let{div:t}=this,{width:e,height:i}=this.#nq,[s,r]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*r;else if(e>.75*s||i>.75*r){let t=Math.min(.75*s/e,.75*r/i);e*=t,i*=t}let[n,a]=this.parentDimensions;this.setDims(e*n/s,i*a/r),this._uiManager.enableWaiting(!1);let o=this.#nZ=document.createElement("canvas");o.setAttribute("role","img"),this.addContainer(o),this.width=e/s,this.height=i/r,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#n9(),this.#n2||(this.parent.addUndoableEditor(this),this.#n2=!0),this._reportTelemetry({action:"inserted_image"}),this.#nJ&&o.setAttribute("aria-label",this.#nJ)}copyCanvas(t,e,i=!1){t||(t=224);let{width:s,height:r}=this.#nq,n=new tg,a=this.#nq,o=s,l=r,h=null;if(e){if(s>e||r>e){let t=Math.min(e/s,e/r);o=Math.floor(s*t),l=Math.floor(r*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*n.sx),i=h.height=Math.ceil(l*n.sy);this.#n1||(a=this.#n7(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(c="#8f8f9d",u="#42414d");let p=15*n.sx,g=15*n.sy,f=new OffscreenCanvas(2*p,2*g),m=f.getContext("2d");m.fillStyle=c,m.fillRect(0,0,2*p,2*g),m.fillStyle=u,m.fillRect(0,0,p,g),m.fillRect(p,g,p,g),d.fillStyle=d.createPattern(f,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(n.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#nq,s>t||r>t){let n=Math.min(t/s,t/r);e=Math.floor(s*n),i=Math.floor(r*n),this.#n1||(a=this.#n7(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#n7(t,e){let{width:i,height:s}=this.#nq,r=i,n=s,a=this.#nq;for(;r>2*t||n>2*e;){let i=r,s=n;r>2*t&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));let o=new OffscreenCanvas(r,n);o.getContext("2d").drawImage(a,0,0,i,s,0,0,r,n),a=o.transferToImageBitmap()}return a}#n9(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,r=new tg,n=Math.ceil(i*t*r.sx),a=Math.ceil(s*e*r.sy),o=this.#nZ;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;let l=this.#n1?this.#nq:this.#n7(n,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,n,a)}getImageForAltText(){return this.#nZ}#n8(t){if(t){if(this.#n1){let t=this._uiManager.imageManager.getSvgUrl(this.#nX);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#nq,t.getContext("2d").drawImage(this.#nq,0,0),t.toDataURL()}if(this.#n1){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*Y.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Y.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,s);return r.getContext("2d").drawImage(this.#nq,0,0,this.#nq.width,this.#nq.height,0,0,i,s),r.transferToImageBitmap()}return structuredClone(this.#nq)}static async deserialize(t,e,i){let s=null;if(t instanceof iP){let{data:{rect:r,rotation:n,id:a,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:d}}}=t,c=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,c);c.remove();let p=(await e._structTree.getAriaAttributes(`${X}${a}`))?.get("aria-label")||"";s=t={annotationType:g.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:r.slice(0),rotation:n,id:a,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}let r=await super.deserialize(t,e,i),{rect:n,bitmap:a,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(r.#nX=l,a&&(r.#nq=a)):r.#nY=o,r.#n1=h;let[c,u]=r.pageDimensions;
2return r.width=(n[2]-n[0])/c,r.height=(n[3]-n[1])/u,r.annotationElementId=t.id||null,d&&(r.altTextData=d),r._initialData=s,r.#n2=!!s,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i={annotationType:g.STAMP,bitmapId:this.#nX,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#n1,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#n8(!0),i.accessibilityData=this.serializeAltText(!0),i;let{decorative:s,altText:r}=this.serializeAltText(!1);if(!s&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){let t=this.#rn(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;let n=this.#n1?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#nX)){if(this.#n1){let t=e.stamps.get(this.#nX);n>t.area&&(t.area=n,t.serialized.bitmap.close(),t.serialized.bitmap=this.#n8(!1))}}else e.stamps.set(this.#nX,{area:n,serialized:i}),i.bitmap=this.#n8(!1);return i}#rn(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&r,isSameAltText:r}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class iY{#sJ;#at=!1;#ae=null;#ai=null;#as=null;#ar=new Map;#an=!1;#aa=!1;#ao=!1;#al=null;#ah=null;#ad=null;#ac=null;#f;static _initialized=!1;static #j=new Map([iD,iX,iK,iU].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:r,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:h}){let d=[...iY.#j.values()];if(!iY._initialized)for(let e of(iY._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#f=t,this.pageIndex=e,this.div=i,this.#sJ=r,this.#ae=n,this.viewport=l,this.#ad=o,this.drawLayer=a,this._structTree=s,this.#f.addLayer(this)}get isEmpty(){return 0===this.#ar.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===g.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(t=this.#f.getMode()){switch(this.#au(),t){case g.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case g.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case g.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;for(let i of iY.#j.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#ad?.div}setEditingState(t){this.#f.setEditingState(t)}addCommands(t){this.#f.addCommands(t)}cleanUndoStack(t){this.#f.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#ae?.div.classList.toggle("disabled",!t)}async enable(){this.#ao=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let e of this.#ar.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ae){this.#ao=!1;return}for(let e of this.#ae.getEditableAnnotations()){if(e.hide(),this.#f.isDeletedAnnotationElement(e.data.id)||t.has(e.data.id))continue;let i=await this.deserialize(e);i&&(this.addOrRebuild(i),i.enableEditing())}this.#ao=!1}disable(){this.#aa=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let i of this.#ar.values())if(i.disableEditing(),i.annotationElementId){if(null!==i.serialize()){t.set(i.annotationElementId,i);continue}e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()}if(this.#ae)for(let i of this.#ae.getEditableAnnotations()){let{id:s}=i.data;if(this.#f.isDeletedAnnotationElement(s))continue;let r=e.get(s);if(r){r.resetAnnotationElement(i),r.show(!1),i.show();continue}(r=t.get(s))&&(this.#f.addChangedExistingAnnotation(r),r.renderAnnotationElement(i)&&r.show(!1)),i.show()}this.#au(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let t of iY.#j.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#aa=!1}getEditableAnnotation(t){return this.#ae?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#ad?.div&&!this.#ac){this.#ac=new AbortController;let t=this.#f.combinedSignal(this.#ac);this.#ad.div.addEventListener("pointerdown",this.#ap.bind(this),{signal:t}),this.#ad.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#ad?.div&&this.#ac&&(this.#ac.abort(),this.#ac=null,this.#ad.div.classList.remove("highlighting"))}#ap(t){this.#f.unselectAll();let{target:e}=t;if(e===this.#ad.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#ad.div.contains(e)){let{isMac:e}=U.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#ad.div.classList.add("free"),this.toggleDrawing(),iU.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#ad.div,x:t.x,y:t.y}),this.#ad.div.addEventListener("pointerup",()=>{this.#ad.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#ai)return;this.#ai=new AbortController;let t=this.#f.combinedSignal(this.#ai);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#ai?.abort(),this.#ai=null}
2attach(t){this.#ar.set(t.id,t);let{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#ar.delete(t.id),this.#sJ?.removePointerInTextLayer(t.contentDiv),!this.#aa&&t.annotationElementId&&this.#f.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#f.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#f.addDeletedAnnotationElement(t.annotationElementId),tT.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#f.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#ao),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#as&&(t._focusEventsAllowed=!1,this.#as=setTimeout(()=>{this.#as=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#f._signal}),e.focus())},0)),t._structTreeParentId=this.#sJ?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#f.getId()}get #ag(){return iY.#j.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#af(t){let e=this.#ag;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#ag?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);let{offsetX:i,offsetY:s}=this.#am(),r=this.getNextId(),n=this.#af({parent:this,id:r,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});n&&this.add(n)}async deserialize(t){return await iY.#j.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#f)||null}createAndAddNewEditor(t,e,i={}){let s=this.getNextId(),r=this.#af({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return r&&this.add(r),r}#am(){let{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),r=Math.min(window.innerWidth,t+i),n=Math.min(window.innerHeight,e+s),a=(Math.max(0,t)+r)/2-t,o=(Math.max(0,e)+n)/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#am(),!0)}setSelected(t){this.#f.setSelected(t)}toggleSelected(t){this.#f.toggleSelected(t)}unselect(t){this.#f.unselect(t)}pointerup(t){let{isMac:e}=U.platform;if(0===t.button&&(!t.ctrlKey||!e)&&t.target===this.div&&this.#an&&(this.#an=!1,!this.#ag?.isDrawer||!this.#ag.supportMultipleDrawings)){if(!this.#at){this.#at=!0;return}if(this.#f.getMode()===g.STAMP){this.#f.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#f.getMode()===g.HIGHLIGHT&&this.enableTextSelection(),this.#an){this.#an=!1;return}let{isMac:e}=U.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#an=!0,this.#ag?.isDrawer){this.startDrawingSession(t);return}let i=this.#f.getActive();this.#at=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#al){this.#ag.startDrawing(this,this.#f,!1,t);return}this.#f.setCurrentDrawingSession(this),this.#al=new AbortController;let e=this.#f.combinedSignal(this.#al);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#ah=null,this.commitOrRemove())},{signal:e}),this.#ag.startDrawing(this,this.#f,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#ah=t);return}this.#ah&&setTimeout(()=>{this.#ah?.focus(),this.#ah=null},0)}endDrawingSession(t=!1){return this.#al?(this.#f.setCurrentDrawingSession(null),this.#al.abort(),this.#al=null,this.#ah=null,this.#ag.endDrawing(t)):null}findNewParent(t,e,i){let s=this.#f.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#al&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#al&&this.#ag.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#as&&(clearTimeout(this.#as),this.#as=null),this.#ar.values())
2)this.#sJ?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#ar.clear(),this.#f.removeLayer(this)}#au(){for(let t of this.#ar.values())t.isEmpty()&&t.remove()}render({viewport:t}){for(let e of(this.viewport=t,tp(this.div,t),this.#f.getEditors(this.pageIndex)))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#f.commitOrRemove(),this.#au();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,tp(this.div,{rotation:i}),e!==i)for(let t of this.#ar.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}}class iQ{#sR=null;#A=0;#ab=new Map;#av=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#sR){this.#sR=t;return}if(this.#sR!==t){if(this.#ab.size>0)for(let e of this.#ab.values())e.remove(),t.append(e);this.#sR=t}}static get _svgFactory(){return R(this,"_svgFactory",new e7)}static #aA(t,[e,i,s,r]){let{style:n}=t;n.top=`${100*i}%`,n.left=`${100*e}%`,n.width=`${100*s}%`,n.height=`${100*r}%`}#ay(){let t=iQ._svgFactory.create(1,1,!0);return this.#sR.append(t),t.setAttribute("aria-hidden",!0),t}#aw(t,e){let i=iQ._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let r=iQ._svgFactory.createElement("use");return i.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),s}#a_(t,e){for(let[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){let s=this.#A++,r=this.#ay(),n=iQ._svgFactory.createElement("defs");r.append(n);let a=iQ._svgFactory.createElement("path");n.append(a);let o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#av.set(s,a);let l=i?this.#aw(n,o):null,h=iQ._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(r,t),this.#ab.set(s,r),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){let i;let s=this.#A++,r=this.#ay(),n=iQ._svgFactory.createElement("defs");r.append(n);let a=iQ._svgFactory.createElement("path");n.append(a);let o=`path_p${this.pageIndex}_${s}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e){let t=iQ._svgFactory.createElement("mask");n.append(t),i=`mask_p${this.pageIndex}_${s}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=iQ._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let r=iQ._svgFactory.createElement("use");t.append(r),r.setAttribute("href",`#${o}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}let l=iQ._svgFactory.createElement("use");r.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return r.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#ab.set(s,r),s}finalizeDraw(t,e){this.#av.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:s,rootClass:r,path:n}=e,a="number"==typeof t?this.#ab.get(t):t;if(a){if(i&&this.#a_(a,i),s&&iQ.#aA(a,s),r){let{classList:t}=a;for(let[e,i]of Object.entries(r))t.toggle(e,i)}if(n){let t=a.firstChild.firstChild;this.#a_(t,n)}}}updateParent(t,e){if(e===this)return;let i=this.#ab.get(t);i&&(e.#sR.append(i),this.#ab.delete(t),e.#ab.set(t,i))}remove(t){this.#av.delete(t),null!==this.#sR&&(this.#ab.get(t).remove(),this.#ab.delete(t))}
2destroy(){for(let t of(this.#sR=null,this.#ab.values()))t.remove();this.#ab.clear(),this.#av.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:iN};var iJ=l.AbortException,iZ=l.AnnotationEditorLayer,i0=l.AnnotationEditorParamsType,i1=l.AnnotationEditorType,i2=l.AnnotationEditorUIManager,i5=l.AnnotationLayer,i3=l.AnnotationMode,i6=l.ColorPicker,i4=l.DOMSVGFactory,i9=l.DrawLayer,i7=l.FeatureTest,i8=l.GlobalWorkerOptions,st=l.ImageKind,se=l.InvalidPDFException,si=l.MissingPDFException,ss=l.OPS,sr=l.OutputScale,sn=l.PDFDataRangeTransport,sa=l.PDFDateString,so=l.PDFWorker,sl=l.PasswordResponses,sh=l.PermissionFlag,sd=l.PixelsPerInch,sc=l.RenderingCancelledException,su=l.TextLayer,sp=l.TouchManager,sg=l.UnexpectedResponseException,sf=l.Util,sm=l.VerbosityLevel,sb=l.XfaLayer,sv=l.build,sA=l.createValidAbsoluteUrl,sy=l.fetchData,sw=l.getDocument,s_=l.getFilenameFromUrl,sx=l.getPdfFilenameFromUrl,sE=l.getXfaPageViewport,sS=l.isDataScheme,sT=l.isPdfFile,sC=l.noContextMenu,sM=l.normalizeUnicode,sP=l.setLayerDimensions,sR=l.shadow,sI=l.stopEvent,sk=l.version}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.