/**
 * @licstart The following is the entire license notice for the
 * JavaScript code in this page
 *
 * Copyright 2024 Mozilla Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @licend The above is the entire license notice for the
 * JavaScript code in this page
 */var t={9306(t,e,i){var n=i(4901),s=i(6823),r=TypeError;t.exports=function(t){if(n(t))return t;throw new r(s(t)+" is not a function")}},6194(t,e,i){var n=i(2248).has;t.exports=function(t){return n(t),t}},3506(t,e,i){var n=i(3925),s=String,r=TypeError;t.exports=function(t){if(n(t))return t;throw new r("Can't set "+s(t)+" as a prototype")}},7080(t,e,i){var n=i(4402).has;t.exports=function(t){return n(t),t}},3463(t){var e=TypeError;t.exports=function(t){if("string"==typeof t)return t;throw new e("Argument is not a string")}},4328(t,e,i){var n=i(4995),s=new n.WeakMap,r=n.set,a=n.remove;t.exports=function(t){return r(s,t,1),a(s,t),t}},6557(t,e,i){var n=i(4995).has;t.exports=function(t){return n(t),t}},679(t,e,i){var n=i(1625),s=TypeError;t.exports=function(t,e){if(n(e,t))return t;throw new s("Incorrect invocation")}},3972(t,e,i){var n=i(34),s=String,r=TypeError;t.exports=function(t){if(void 0===t||n(t))return t;throw new r(s(t)+" is not an object or undefined")}},8551(t,e,i){var n=i(34),s=String,r=TypeError;t.exports=function(t){if(n(t))return t;throw new r(s(t)+" is not an object")}},4154(t,e,i){var n=i(6955),s=TypeError;t.exports=function(t){if("Uint8Array"===n(t))return t;throw new s("Argument is not an Uint8Array")}},7811(t){t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7394(t,e,i){var n=i(4576),s=i(6706),r=i(2195),a=n.ArrayBuffer,o=n.TypeError;t.exports=a&&s(a.prototype,"byteLength","get")||function(t){if("ArrayBuffer"!==r(t))throw new o("ArrayBuffer expected");return t.byteLength}},3238(t,e,i){var n=i(4576),s=i(7811),r=i(7394),a=n.DataView;t.exports=function(t){if(!s||0!==r(t))return!1;try{return new a(t),!1}catch(t){return!0}}},5169(t,e,i){var n=i(3238),s=TypeError;t.exports=function(t){if(n(t))throw new s("ArrayBuffer is detached");return t}},5636(t,e,i){var n=i(4576),s=i(9504),r=i(6706),a=i(7696),o=i(5169),l=i(7394),h=i(4483),c=i(1548),d=n.structuredClone,u=n.ArrayBuffer,p=n.DataView,g=Math.min,m=u.prototype,f=p.prototype,b=s(m.slice),v=r(m,"resizable","get"),y=r(m,"maxByteLength","get"),w=s(f.getInt8),A=s(f.setInt8);t.exports=(c||h)&&function(t,e,i){var n,s=l(t),r=void 0===e?s:a(e),m=!v||!v(t);if(o(t),c&&(t=d(t,{transfer:[t]}),s===r&&(i||m)))return t;if(s>=r&&(!i||m))n=b(t,0,r);else{var f=i&&!m&&y?{maxByteLength:y(t)}:void 0;n=new u(r,f);for(var x=new p(t),S=new p(n),C=g(r,s),E=0;E<C;E++)A(S,E,w(x,E))}return c||h(t),n}},4644(t,e,i){var n,s,r,a=i(7811),o=i(3724),l=i(4576),h=i(4901),c=i(34),d=i(9297),u=i(6955),p=i(6823),g=i(6699),m=i(6840),f=i(2106),b=i(1625),v=i(2787),y=i(2967),w=i(8227),A=i(3392),x=i(1181),S=x.enforce,C=x.get,E=l.Int8Array,T=E&&E.prototype,_=l.Uint8ClampedArray,M=_&&_.prototype,k=E&&v(E),D=T&&v(T),P=Object.prototype,I=l.TypeError,R=w("toStringTag"),B=A("TYPED_ARRAY_TAG"),F="TypedArrayConstructor",L=a&&!!y&&"Opera"!==u(l.opera),O=!1,N={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},z=function(t){var e=v(t);if(c(e)){var i=C(e);return i&&d(i,F)?i[F]:z(e)}},H=function(t){if(!c(t))return!1;var e=u(t);return d(N,e)||d(U,e)};for(n in N)(r=(s=l[n])&&s.prototype)?S(r)[F]=s:L=!1;for(n in U)(r=(s=l[n])&&s.prototype)&&(S(r)[F]=s);if((!L||!h(k)||k===Function.prototype)&&(k=function(){throw new I("Incorrect invocation")},L))for(n in N)l[n]&&y(l[n],k);if((!L||!D||D===P)&&(D=k.prototype,L))for(n in N)l[n]&&y(l[n].prototype,D);if(L&&v(M)!==D&&y(M,D),o&&!d(D,R))for(n in O=!0,f(D,R,{configurable:!0,get:function(){return c(this)?this[B]:void 0}}),N)l[n]&&g(l[n],B,n);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:L,TYPED_ARRAY_TAG:O&&B,aTypedArray:function(t){if(H(t))return t;throw new I("Target is not a typed array")},aTypedArrayConstructor:function(t){if(h(t)&&(!y||b(k,t)))return t;throw new I(p(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,e,i,n){if(o){if(i)for(var s in N){var r=l[s];if(r&&d(r.prototype,t))try{delete r.prototype[t]}catch(i){try{r.prototype[t]=e}catch(t){}}}D[t]&&!i||m(D,t,i?e:L&&T[t]||e,n)}},exportTypedArrayStaticMethod:function(t,e,i){var n,s;if(o){if(y){if(i)for(n in N)if((s=l[n])&&d(s,t))try{delete s[t]}catch(t){}if(k[t]&&!i)return;try{return m(k,t,i?e:L&&k[t]||e)}catch(t){}}for(n in N)!(s=l[n])||s[t]&&!i||m(s,t,e)}},getTypedArrayConstructor:z,isView:function(t){if(!c(t))return!1;var e=u(t);return"DataView"===e||d(N,e)||d(U,e)},isTypedArray:H,TypedArray:k,TypedArrayPrototype:D}},5370(t,e,i){var n=i(6198);t.exports=function(t,e,i){for(var s=0,r=arguments.length>2?i:n(e),a=new t(r);r>s;)a[s]=e[s++];return a}},9617(t,e,i){var n=i(5397),s=i(5610),r=i(6198),a=function(t){return function(e,i,a){var o=n(e),l=r(o);if(0===l)return!t&&-1;var h,c=s(a,l);if(t&&i!=i){for(;l>c;)if((h=o[c++])!=h)return!0}else for(;l>c;c++)if((t||c in o)&&o[c]===i)return t||c||0;return!t&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},4527(t,e,i){var n=i(3724),s=i(4376),r=TypeError,a=Object.getOwnPropertyDescriptor,o=n&&!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(s(t)&&!a(t,"length").writable)throw new r("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e}},7680(t,e,i){var n=i(9504);t.exports=n([].slice)},2804(t){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=e+"+/",n=e+"-_",s=function(t){for(var e={},i=0;i<64;i++)e[t.charAt(i)]=i;return e};t.exports={i2c:i,c2i:s(i),i2cUrl:n,c2iUrl:s(n)}},6319(t,e,i){var n=i(8551),s=i(9539);t.exports=function(t,e,i,r){try{return r?e(n(i)[0],i[1]):e(i)}catch(e){s(t,"throw",e)}}},2195(t,e,i){var n=i(9504),s=n({}.toString),r=n("".slice);t.exports=function(t){return r(s(t),8,-1)}},6955(t,e,i){var n=i(2140),s=i(4901),r=i(2195),a=i(8227)("toStringTag"),o=Object,l="Arguments"===r(function(){return arguments}());t.exports=n?r:function(t){var e,i,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=o(t),a))?i:l?r(e):"Object"===(n=r(e))&&s(e.callee)?"Arguments":n}},7740(t,e,i){var n=i(9297),s=i(5031),r=i(7347),a=i(4913);t.exports=function(t,e,i){for(var o=s(e),l=a.f,h=r.f,c=0;c<o.length;c++){var d=o[c];n(t,d)||i&&n(i,d)||l(t,d,h(e,d))}}},2211(t,e,i){var n=i(9039);t.exports=!n((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 n=i(3724),s=i(4913),r=i(6980);t.exports=n?function(t,e,i){return s.f(t,e,r(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 n=i(3724),s=i(4913),r=i(6980);t.exports=function(t,e,i){n?s.f(t,e,r(0,i)):t[e]=i}},2106(t,e,i){var n=i(283),s=i(4913);t.exports=function(t,e,i){return i.get&&n(i.get,e,{getter:!0}),i.set&&n(i.set,e,{setter:!0}),s.f(t,e,i)}},6840(t,e,i){var n=i(4901),s=i(4913),r=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(n(i)&&r(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:s.f(t,e,{value:i,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return t}},6279(t,e,i){var n=i(6840);t.exports=function(t,e,i){for(var s in e)n(t,s,e[s],i);return t}},9433(t,e,i){var n=i(4576),s=Object.defineProperty;t.exports=function(t,e){try{s(n,t,{value:e,configurable:!0,writable:!0})}catch(i){n[t]=e}return e}},3724(t,e,i){var n=i(9039);t.exports=!n((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))},4483(t,e,i){var n,s,r,a,o=i(4576),l=i(9429),h=i(1548),c=o.structuredClone,d=o.ArrayBuffer,u=o.MessageChannel,p=!1;if(h)p=function(t){c(t,{transfer:[t]})};else if(d)try{u||(n=l("worker_threads"))&&(u=n.MessageChannel),u&&(s=new u,r=new d(2),a=function(t){s.port1.postMessage(null,[t])},2===r.byteLength&&(a(r),0===r.byteLength&&(p=a)))}catch(t){}t.exports=p},4055(t,e,i){var n=i(4576),s=i(34),r=n.document,a=s(r)&&s(r.createElement);t.exports=function(t){return a?r.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},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 n=i(4215);t.exports="NODE"===n},2839(t,e,i){var n=i(4576).navigator,s=n&&n.userAgent;t.exports=s?String(s):""},9519(t,e,i){var n,s,r=i(4576),a=i(2839),o=r.process,l=r.Deno,h=o&&o.versions||l&&l.version,c=h&&h.v8;c&&(s=(n=c.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!s&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(s=+n[1]),t.exports=s},4215(t,e,i){var n=i(4576),s=i(2839),r=i(2195),a=function(t){return s.slice(0,t.length)===t};t.exports=a("Bun/")?"BUN":a("Cloudflare-Workers")?"CLOUDFLARE":a("Deno/")?"DENO":a("Node.js/")?"NODE":n.Bun&&"string"==typeof Bun.version?"BUN":n.Deno&&"object"==typeof Deno.version?"DENO":"process"===r(n.process)?"NODE":n.window&&n.document?"BROWSER":"REST"},8574(t,e,i){var n=i(9504),s=Error,r=n("".replace),a=String(new s("zxcasd").stack),o=/\n\s*at [^:]*:[^\n]*/,l=o.test(a);t.exports=function(t,e){if(l&&"string"==typeof t&&!s.prepareStackTrace)for(;e--;)t=r(t,o,"");return t}},6518(t,e,i){var n=i(4576),s=i(7347).f,r=i(6699),a=i(6840),o=i(9433),l=i(7740),h=i(2796);t.exports=function(t,e){var i,c,d,u,p,g=t.target,m=t.global,f=t.stat;if(i=m?n:f?n[g]||o(g,{}):n[g]&&n[g].prototype)for(c in e){if(u=e[c],d=t.dontCallGetSet?(p=s(i,c))&&p.value:i[c],!h(m?c:g+(f?".":"#")+c,t.forced)&&void 0!==d){if(typeof u==typeof d)continue;l(u,d)}(t.sham||d&&d.sham)&&r(u,"sham",!0),a(i,c,u,t)}}},9039(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},8745(t,e,i){var n=i(616),s=Function.prototype,r=s.apply,a=s.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?a.bind(r):function(){return a.apply(r,arguments)})},6080(t,e,i){var n=i(7476),s=i(9306),r=i(616),a=n(n.bind);t.exports=function(t,e){return s(t),void 0===e?t:r?a(t,e):function(){return t.apply(e,arguments)}}},616(t,e,i){var n=i(9039);t.exports=!n((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},9565(t,e,i){var n=i(616),s=Function.prototype.call;t.exports=n?s.bind(s):function(){return s.apply(s,arguments)}},350(t,e,i){var n=i(3724),s=i(9297),r=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,o=s(r,"name"),l=o&&"something"===function(){}.name,h=o&&(!n||n&&a(r,"name").configurable);t.exports={EXISTS:o,PROPER:l,CONFIGURABLE:h}},6706(t,e,i){var n=i(9504),s=i(9306);t.exports=function(t,e,i){try{return n(s(Object.getOwnPropertyDescriptor(t,e)[i]))}catch(t){}}},7476(t,e,i){var n=i(2195),s=i(9504);t.exports=function(t){if("Function"===n(t))return s(t)}},9504(t,e,i){var n=i(616),s=Function.prototype,r=s.call,a=n&&s.bind.bind(r,r);t.exports=n?a:function(t){return function(){return r.apply(t,arguments)}}},944(t){var e=TypeError;t.exports=function(t){var i=t&&t.alphabet;if(void 0===i||"base64"===i||"base64url"===i)return i||"base64";throw new e("Incorrect `alphabet` option")}},9429(t,e,i){var n=i(4576),s=i(6193);t.exports=function(t){if(s){try{return n.process.getBuiltinModule(t)}catch(t){}try{return Function('return require("'+t+'")')()}catch(t){}}}},7751(t,e,i){var n=i(4576),s=i(4901),r=function(t){return s(t)?t:void 0};t.exports=function(t,e){return arguments.length<2?r(n[t]):n[t]&&n[t][e]}},1767(t){t.exports=function(t){return{iterator:t,next:t.next,done:!1}}},8646(t,e,i){var n=i(9565),s=i(8551),r=i(1767),a=i(851);t.exports=function(t,e){e&&"string"==typeof t||s(t);var i=a(t);return r(s(void 0!==i?n(i,t):t))}},851(t,e,i){var n=i(6955),s=i(5966),r=i(4117),a=i(6269),o=i(8227)("iterator");t.exports=function(t){if(!r(t))return s(t,o)||s(t,"@@iterator")||a[n(t)]}},81(t,e,i){var n=i(9565),s=i(9306),r=i(8551),a=i(6823),o=i(851),l=TypeError;t.exports=function(t,e){var i=arguments.length<2?o(t):e;if(s(i))return r(n(i,t));throw new l(a(t)+" is not iterable")}},5966(t,e,i){var n=i(9306),s=i(4117);t.exports=function(t,e){var i=t[e];return s(i)?void 0:n(i)}},3789(t,e,i){var n=i(9306),s=i(8551),r=i(9565),a=i(1291),o=i(1767),l="Invalid size",h=RangeError,c=TypeError,d=Math.max,u=function(t,e){this.set=t,this.size=d(e,0),this.has=n(t.has),this.keys=n(t.keys)};u.prototype={getIterator:function(){return o(s(r(this.keys,this.set)))},includes:function(t){return r(this.has,this.set,t)}},t.exports=function(t){s(t);var e=+t.size;if(e!=e)throw new c(l);var i=a(e);if(i<0)throw new h(l);return new u(t,i)}},4576(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 n=i(9504),s=i(8981),r=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return r(s(t),e)}},421(t){t.exports={}},397(t,e,i){var n=i(7751);t.exports=n("document","documentElement")},5917(t,e,i){var n=i(3724),s=i(9039),r=i(4055);t.exports=!n&&!s((function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))},7055(t,e,i){var n=i(9504),s=i(9039),r=i(2195),a=Object,o=n("".split);t.exports=s((function(){return!a("z").propertyIsEnumerable(0)}))?function(t){return"String"===r(t)?o(t,""):a(t)}:a},3167(t,e,i){var n=i(4901),s=i(34),r=i(2967);t.exports=function(t,e,i){var a,o;return r&&n(a=e.constructor)&&a!==i&&s(o=a.prototype)&&o!==i.prototype&&r(t,o),t}},3706(t,e,i){var n=i(9504),s=i(4901),r=i(7629),a=n(Function.toString);s(r.inspectSource)||(r.inspectSource=function(t){return a(t)}),t.exports=r.inspectSource},1181(t,e,i){var n,s,r,a=i(8622),o=i(4576),l=i(34),h=i(6699),c=i(9297),d=i(7629),u=i(6119),p=i(421),g="Object already initialized",m=o.TypeError,f=o.WeakMap;if(a||d.state){var b=d.state||(d.state=new f);b.get=b.get,b.has=b.has,b.set=b.set,n=function(t,e){if(b.has(t))throw new m(g);return e.facade=t,b.set(t,e),e},s=function(t){return b.get(t)||{}},r=function(t){return b.has(t)}}else{var v=u("state");p[v]=!0,n=function(t,e){if(c(t,v))throw new m(g);return e.facade=t,h(t,v,e),e},s=function(t){return c(t,v)?t[v]:{}},r=function(t){return c(t,v)}}t.exports={set:n,get:s,has:r,enforce:function(t){return r(t)?s(t):n(t,{})},getterFor:function(t){return function(e){var i;if(!l(e)||(i=s(e)).type!==t)throw new m("Incompatible receiver, "+t+" required");return i}}}},4209(t,e,i){var n=i(8227),s=i(6269),r=n("iterator"),a=Array.prototype;t.exports=function(t){return void 0!==t&&(s.Array===t||a[r]===t)}},4376(t,e,i){var n=i(2195);t.exports=Array.isArray||function(t){return"Array"===n(t)}},1108(t,e,i){var n=i(6955);t.exports=function(t){var e=n(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 n=i(9039),s=i(4901),r=/#|\.prototype\./,a=function(t,e){var i=l[o(t)];return i===c||i!==h&&(s(e)?n(e):!!e)},o=a.normalize=function(t){return String(t).replace(r,".").toLowerCase()},l=a.data={},h=a.NATIVE="N",c=a.POLYFILL="P";t.exports=a},4117(t){t.exports=function(t){return null==t}},34(t,e,i){var n=i(4901);t.exports=function(t){return"object"==typeof t?null!==t:n(t)}},3925(t,e,i){var n=i(34);t.exports=function(t){return n(t)||null===t}},6395(t){t.exports=!1},5810(t,e,i){var n=i(34),s=i(1181).get;t.exports=function(t){if(!n(t))return!1;var e=s(t);return!!e&&"RawJSON"===e.type}},757(t,e,i){var n=i(7751),s=i(4901),r=i(1625),a=i(7040),o=Object;t.exports=a?function(t){return"symbol"==typeof t}:function(t){var e=n("Symbol");return s(e)&&r(e.prototype,o(t))}},507(t,e,i){var n=i(9565);t.exports=function(t,e,i){for(var s,r,a=i?t:t.iterator,o=t.next;!(s=n(o,a)).done;)if(void 0!==(r=e(s.value)))return r}},2652(t,e,i){var n=i(6080),s=i(9565),r=i(8551),a=i(6823),o=i(4209),l=i(6198),h=i(1625),c=i(81),d=i(851),u=i(9539),p=TypeError,g=function(t,e){this.stopped=t,this.result=e},m=g.prototype;t.exports=function(t,e,i){var f,b,v,y,w,A,x,S=i&&i.that,C=!(!i||!i.AS_ENTRIES),E=!(!i||!i.IS_RECORD),T=!(!i||!i.IS_ITERATOR),_=!(!i||!i.INTERRUPTED),M=n(e,S),k=function(t){return f&&u(f,"normal"),new g(!0,t)},D=function(t){return C?(r(t),_?M(t[0],t[1],k):M(t[0],t[1])):_?M(t,k):M(t)};if(E)f=t.iterator;else if(T)f=t;else{if(!(b=d(t)))throw new p(a(t)+" is not iterable");if(o(b)){for(v=0,y=l(t);y>v;v++)if((w=D(t[v]))&&h(m,w))return w;return new g(!1)}f=c(t,b)}for(A=E?t.next:f.next;!(x=s(A,f)).done;){try{w=D(x.value)}catch(t){u(f,"throw",t)}if("object"==typeof w&&w&&h(m,w))return w}return new g(!1)}},1385(t,e,i){var n=i(9539);t.exports=function(t,e,i){for(var s=t.length-1;s>=0;s--)if(void 0!==t[s])try{i=n(t[s].iterator,e,i)}catch(t){e="throw",i=t}if("throw"===e)throw i;return i}},9539(t,e,i){var n=i(9565),s=i(8551),r=i(5966);t.exports=function(t,e,i){var a,o;s(t);try{if(!(a=r(t,"return"))){if("throw"===e)throw i;return i}a=n(a,t)}catch(t){o=!0,a=t}if("throw"===e)throw i;if(o)throw a;return s(a),i}},9462(t,e,i){var n=i(9565),s=i(2360),r=i(6699),a=i(6279),o=i(8227),l=i(1181),h=i(5966),c=i(7657).IteratorPrototype,d=i(2529),u=i(9539),p=i(1385),g=o("toStringTag"),m="IteratorHelper",f="WrapForValidIterator",b="normal",v="throw",y=l.set,w=function(t){var e=l.getterFor(t?f:m);return a(s(c),{next:function(){var i=e(this);if(t)return i.nextHandler();if(i.done)return d(void 0,!0);try{var n=i.nextHandler();return i.returnHandlerResult?n:d(n,i.done)}catch(t){throw i.done=!0,t}},return:function(){var i=e(this),s=i.iterator;if(i.done=!0,t){var r=h(s,"return");return r?n(r,s):d(void 0,!0)}if(i.inner)try{u(i.inner.iterator,b)}catch(t){return u(s,v,t)}if(i.openIters)try{p(i.openIters,b)}catch(t){return u(s,v,t)}return s&&u(s,b),d(void 0,!0)}})},A=w(!0),x=w(!1);r(x,g,"Iterator Helper"),t.exports=function(t,e,i){var n=function(n,s){s?(s.iterator=n.iterator,s.next=n.next):s=n,s.type=e?f:m,s.returnHandlerResult=!!i,s.nextHandler=t,s.counter=0,s.done=!1,y(this,s)};return n.prototype=e?A:x,n}},684(t){t.exports=function(t,e){var i="function"==typeof Iterator&&Iterator.prototype[t];if(i)try{i.call({next:null},e).next()}catch(t){return!0}}},4549(t,e,i){var n=i(4576);t.exports=function(t,e){var i=n.Iterator,s=i&&i.prototype,r=s&&s[t],a=!1;if(r)try{r.call({next:function(){return{done:!0}},return:function(){a=!0}},-1)}catch(t){t instanceof e||(a=!1)}if(!a)return r}},7657(t,e,i){var n,s,r,a=i(9039),o=i(4901),l=i(34),h=i(2360),c=i(2787),d=i(6840),u=i(8227),p=i(6395),g=u("iterator"),m=!1;[].keys&&("next"in(r=[].keys())?(s=c(c(r)))!==Object.prototype&&(n=s):m=!0),!l(n)||a((function(){var t={};return n[g].call(t)!==t}))?n={}:p&&(n=h(n)),o(n[g])||d(n,g,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:m}},6269(t){t.exports={}},6198(t,e,i){var n=i(8014);t.exports=function(t){return n(t.length)}},283(t,e,i){var n=i(9504),s=i(9039),r=i(4901),a=i(9297),o=i(3724),l=i(350).CONFIGURABLE,h=i(3706),c=i(1181),d=c.enforce,u=c.get,p=String,g=Object.defineProperty,m=n("".slice),f=n("".replace),b=n([].join),v=o&&!s((function(){return 8!==g((function(){}),"length",{value:8}).length})),y=String(String).split("String"),w=t.exports=function(t,e,i){"Symbol("===m(p(e),0,7)&&(e="["+f(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 n=d(t);return a(n,"source")||(n.source=b(y,"string"==typeof e?e:"")),t};Function.prototype.toString=w((function(){return r(this)&&u(this).source||h(this)}),"toString")},2248(t,e,i){var n=i(9504),s=Map.prototype;t.exports={Map:Map,set:n(s.set),get:n(s.get),has:n(s.has),remove:n(s.delete),proto:s}},741(t){var e=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(t){var n=+t;return(n>0?i:e)(n)}},7819(t,e,i){var n=i(9039);t.exports=!n((function(){var t="9007199254740993",e=JSON.rawJSON(t);return!JSON.isRawJSON(e)||JSON.stringify(e)!==t}))},6043(t,e,i){var n=i(9306),s=TypeError,r=function(t){var e,i;this.promise=new t((function(t,n){if(void 0!==e||void 0!==i)throw new s("Bad Promise constructor");e=t,i=n})),this.resolve=n(e),this.reject=n(i)};t.exports.f=function(t){return new r(t)}},2603(t,e,i){var n=i(655);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:n(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 n,s=i(8551),r=i(6801),a=i(8727),o=i(421),l=i(397),h=i(4055),c=i(6119),d="prototype",u="script",p=c("IE_PROTO"),g=function(){},m=function(t){return"<"+u+">"+t+"</"+u+">"},f=function(t){t.write(m("")),t.close();var e=t.parentWindow.Object;return t=null,e},b=function(){try{n=new ActiveXObject("htmlfile")}catch(t){}var t,e,i;b="undefined"!=typeof document?document.domain&&n?f(n):(e=h("iframe"),i="java"+u+":",e.style.display="none",l.appendChild(e),e.src=String(i),(t=e.contentWindow.document).open(),t.write(m("document.F=Object")),t.close(),t.F):f(n);for(var s=a.length;s--;)delete b[d][a[s]];return b()};o[p]=!0,t.exports=Object.create||function(t,e){var i;return null!==t?(g[d]=s(t),i=new g,g[d]=null,i[p]=t):i=b(),void 0===e?i:r.f(i,e)}},6801(t,e,i){var n=i(3724),s=i(8686),r=i(4913),a=i(8551),o=i(5397),l=i(1072);e.f=n&&!s?Object.defineProperties:function(t,e){a(t);for(var i,n=o(e),s=l(e),h=s.length,c=0;h>c;)r.f(t,i=s[c++],n[i]);return t}},4913(t,e,i){var n=i(3724),s=i(5917),r=i(8686),a=i(8551),o=i(6969),l=TypeError,h=Object.defineProperty,c=Object.getOwnPropertyDescriptor,d="enumerable",u="configurable",p="writable";e.f=n?r?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 n=c(t,e);n&&n[p]&&(t[e]=i.value,i={configurable:u in i?i[u]:n[u],enumerable:d in i?i[d]:n[d],writable:!1})}return h(t,e,i)}:h:function(t,e,i){if(a(t),e=o(e),a(i),s)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 n=i(3724),s=i(9565),r=i(8773),a=i(6980),o=i(5397),l=i(6969),h=i(9297),c=i(5917),d=Object.getOwnPropertyDescriptor;e.f=n?d:function(t,e){if(t=o(t),e=l(e),c)try{return d(t,e)}catch(t){}if(h(t,e))return a(!s(r.f,t,e),t[e])}},8480(t,e,i){var n=i(1828),s=i(8727).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return n(t,s)}},3717(t,e){e.f=Object.getOwnPropertySymbols},2787(t,e,i){var n=i(9297),s=i(4901),r=i(8981),a=i(6119),o=i(2211),l=a("IE_PROTO"),h=Object,c=h.prototype;t.exports=o?h.getPrototypeOf:function(t){var e=r(t);if(n(e,l))return e[l];var i=e.constructor;return s(i)&&e instanceof i?i.prototype:e instanceof h?c:null}},1625(t,e,i){var n=i(9504);t.exports=n({}.isPrototypeOf)},1828(t,e,i){var n=i(9504),s=i(9297),r=i(5397),a=i(9617).indexOf,o=i(421),l=n([].push);t.exports=function(t,e){var i,n=r(t),h=0,c=[];for(i in n)!s(o,i)&&s(n,i)&&l(c,i);for(;e.length>h;)s(n,i=e[h++])&&(~a(c,i)||l(c,i));return c}},1072(t,e,i){var n=i(1828),s=i(8727);t.exports=Object.keys||function(t){return n(t,s)}},8773(t,e){var i={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,s=n&&!i.call({1:2},1);e.f=s?function(t){var e=n(this,t);return!!e&&e.enumerable}:i},2967(t,e,i){var n=i(6706),s=i(34),r=i(7750),a=i(3506);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,i={};try{(t=n(Object.prototype,"__proto__","set"))(i,[]),e=i instanceof Array}catch(t){}return function(i,n){return r(i),a(n),s(i)?(e?t(i,n):i.__proto__=n,i):i}}():void 0)},4270(t,e,i){var n=i(9565),s=i(4901),r=i(34),a=TypeError;t.exports=function(t,e){var i,o;if("string"===e&&s(i=t.toString)&&!r(o=n(i,t)))return o;if(s(i=t.valueOf)&&!r(o=n(i,t)))return o;if("string"!==e&&s(i=t.toString)&&!r(o=n(i,t)))return o;throw new a("Can't convert object to primitive value")}},5031(t,e,i){var n=i(7751),s=i(9504),r=i(8480),a=i(3717),o=i(8551),l=s([].concat);t.exports=n("Reflect","ownKeys")||function(t){var e=r.f(o(t)),i=a.f;return i?l(e,i(t)):e}},8235(t,e,i){var n=i(9504),s=i(9297),r=SyntaxError,a=parseInt,o=String.fromCharCode,l=n("".charAt),h=n("".slice),c=n(/./.exec),d={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t"},u=/^[\da-f]{4}$/i,p=/^[\u0000-\u001F]$/;t.exports=function(t,e){for(var i=!0,n="";e<t.length;){var g=l(t,e);if("\\"===g){var m=h(t,e,e+2);if(s(d,m))n+=d[m],e+=2;else{if("\\u"!==m)throw new r('Unknown escape sequence: "'+m+'"');var f=h(t,e+=2,e+4);if(!c(u,f))throw new r("Bad Unicode escape at: "+e);n+=o(a(f,16)),e+=4}}else{if('"'===g){i=!1,e++;break}if(c(p,g))throw new r("Bad control character in string literal at: "+e);n+=g,e++}}if(i)throw new r("Unterminated string at: "+e);return{value:n,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 n=i(4117),s=TypeError;t.exports=function(t){if(n(t))throw new s("Can't call method on "+t);return t}},9286(t,e,i){var n=i(4402),s=i(8469),r=n.Set,a=n.add;t.exports=function(t){var e=new r;return s(t,(function(t){a(e,t)})),e}},3440(t,e,i){var n=i(7080),s=i(4402),r=i(9286),a=i(5170),o=i(3789),l=i(8469),h=i(507),c=s.has,d=s.remove;t.exports=function(t){var e=n(this),i=o(t),s=r(e);return a(e)<=i.size?l(e,(function(t){i.includes(t)&&d(s,t)})):h(i.getIterator(),(function(t){c(s,t)&&d(s,t)})),s}},4402(t,e,i){var n=i(9504),s=Set.prototype;t.exports={Set:Set,add:n(s.add),has:n(s.has),remove:n(s.delete),proto:s}},8750(t,e,i){var n=i(7080),s=i(4402),r=i(5170),a=i(3789),o=i(8469),l=i(507),h=s.Set,c=s.add,d=s.has;t.exports=function(t){var e=n(this),i=a(t),s=new h;return r(e)>i.size?l(i.getIterator(),(function(t){d(e,t)&&c(s,t)})):o(e,(function(t){i.includes(t)&&c(s,t)})),s}},4449(t,e,i){var n=i(7080),s=i(4402).has,r=i(5170),a=i(3789),o=i(8469),l=i(507),h=i(9539);t.exports=function(t){var e=n(this),i=a(t);if(r(e)<=i.size)return!1!==o(e,(function(t){if(i.includes(t))return!1}),!0);var c=i.getIterator();return!1!==l(c,(function(t){if(s(e,t))return h(c,"normal",!1)}))}},3838(t,e,i){var n=i(7080),s=i(5170),r=i(8469),a=i(3789);t.exports=function(t){var e=n(this),i=a(t);return!(s(e)>i.size)&&!1!==r(e,(function(t){if(!i.includes(t))return!1}),!0)}},8527(t,e,i){var n=i(7080),s=i(4402).has,r=i(5170),a=i(3789),o=i(507),l=i(9539);t.exports=function(t){var e=n(this),i=a(t);if(r(e)<i.size)return!1;var h=i.getIterator();return!1!==o(h,(function(t){if(!s(e,t))return l(h,"normal",!1)}))}},8469(t,e,i){var n=i(9504),s=i(507),r=i(4402),a=r.Set,o=r.proto,l=n(o.forEach),h=n(o.keys),c=h(new a).next;t.exports=function(t,e,i){return i?s({iterator:h(t),next:c},e):l(t,e)}},4916(t,e,i){var n=i(7751),s=function(t){return{size:t,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},r=function(t){return{size:t,has:function(){return!0},keys:function(){throw new Error("e")}}};t.exports=function(t,e){var i=n("Set");try{(new i)[t](s(0));try{return(new i)[t](s(-1)),!1}catch(n){if(!e)return!0;try{return(new i)[t](r(-1/0)),!1}catch(n){return e(new i([1,2])[t](r(1/0)))}}}catch(t){return!1}}},9835(t){t.exports=function(t){try{var e=new Set,i={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return e.clear(),e.add(4),function(){return{done:!0}}}})}},n=e[t](i);return 1===n.size&&4===n.values().next().value}catch(t){return!1}}},5170(t,e,i){var n=i(6706),s=i(4402);t.exports=n(s.proto,"size","get")||function(t){return t.size}},3650(t,e,i){var n=i(7080),s=i(4402),r=i(9286),a=i(3789),o=i(507),l=s.add,h=s.has,c=s.remove;t.exports=function(t){var e=n(this),i=a(t).getIterator(),s=r(e);return o(i,(function(t){h(e,t)?c(s,t):l(s,t)})),s}},4204(t,e,i){var n=i(7080),s=i(4402).add,r=i(9286),a=i(3789),o=i(507);t.exports=function(t){var e=n(this),i=a(t).getIterator(),l=r(e);return o(i,(function(t){s(l,t)})),l}},6119(t,e,i){var n=i(5745),s=i(3392),r=n("keys");t.exports=function(t){return r[t]||(r[t]=s(t))}},7629(t,e,i){var n=i(6395),s=i(4576),r=i(9433),a="__core-js_shared__",o=t.exports=s[a]||r(a,{});(o.versions||(o.versions=[])).push({version:"3.48.0",mode:n?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.48.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(t,e,i){var n=i(7629);t.exports=function(t,e){return n[t]||(n[t]=e||{})}},1548(t,e,i){var n=i(4576),s=i(9039),r=i(9519),a=i(4215),o=n.structuredClone;t.exports=!!o&&!s((function(){if("DENO"===a&&r>92||"NODE"===a&&r>94||"BROWSER"===a&&r>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 n=i(9519),s=i(9039),r=i(4576).String;t.exports=!!Object.getOwnPropertySymbols&&!s((function(){var t=Symbol("symbol detection");return!r(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&n&&n<41}))},5610(t,e,i){var n=i(1291),s=Math.max,r=Math.min;t.exports=function(t,e){var i=n(t);return i<0?s(i+e,0):r(i,e)}},5854(t,e,i){var n=i(2777),s=TypeError;t.exports=function(t){var e=n(t,"number");if("number"==typeof e)throw new s("Can't convert number to bigint");return BigInt(e)}},7696(t,e,i){var n=i(1291),s=i(8014),r=RangeError;t.exports=function(t){if(void 0===t)return 0;var e=n(t),i=s(e);if(e!==i)throw new r("Wrong length or index");return i}},5397(t,e,i){var n=i(7055),s=i(7750);t.exports=function(t){return n(s(t))}},1291(t,e,i){var n=i(741);t.exports=function(t){var e=+t;return e!=e||0===e?0:n(e)}},8014(t,e,i){var n=i(1291),s=Math.min;t.exports=function(t){var e=n(t);return e>0?s(e,9007199254740991):0}},8981(t,e,i){var n=i(7750),s=Object;t.exports=function(t){return s(n(t))}},9590(t,e,i){var n=i(1291),s=RangeError;t.exports=function(t){var e=n(t);if(e<0)throw new s("The argument can't be less than 0");return e}},2777(t,e,i){var n=i(9565),s=i(34),r=i(757),a=i(5966),o=i(4270),l=i(8227),h=TypeError,c=l("toPrimitive");t.exports=function(t,e){if(!s(t)||r(t))return t;var i,l=a(t,c);if(l){if(void 0===e&&(e="default"),i=n(l,t,e),!s(i)||r(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 n=i(2777),s=i(757);t.exports=function(t){var e=n(t,"string");return s(e)?e:e+""}},2140(t,e,i){var n={};n[i(8227)("toStringTag")]="z",t.exports="[object z]"===String(n)},655(t,e,i){var n=i(6955),s=String;t.exports=function(t){if("Symbol"===n(t))throw new TypeError("Cannot convert a Symbol value to a string");return s(t)}},6823(t){var e=String;t.exports=function(t){try{return e(t)}catch(t){return"Object"}}},3392(t,e,i){var n=i(9504),s=0,r=Math.random(),a=n(1.1.toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+a(++s+r,36)}},9143(t,e,i){var n=i(4576),s=i(9504),r=i(3972),a=i(3463),o=i(9297),l=i(2804),h=i(944),c=i(5169),d=l.c2i,u=l.c2iUrl,p=n.SyntaxError,g=n.TypeError,m=s("".charAt),f=function(t,e){for(var i=t.length;e<i;e++){var n=m(t,e);if(" "!==n&&"\t"!==n&&"\n"!==n&&"\f"!==n&&"\r"!==n)break}return e},b=function(t,e,i){var n=t.length;n<4&&(t+=2===n?"AA":"A");var s=(e[m(t,0)]<<18)+(e[m(t,1)]<<12)+(e[m(t,2)]<<6)+e[m(t,3)],r=[s>>16&255,s>>8&255,255&s];if(2===n){if(i&&0!==r[1])throw new p("Extra bits");return[r[0]]}if(3===n){if(i&&0!==r[2])throw new p("Extra bits");return[r[0],r[1]]}return r},v=function(t,e,i){for(var n=e.length,s=0;s<n;s++)t[i+s]=e[s];return i+n};t.exports=function(t,e,i,n){a(t),r(e);var s="base64"===h(e)?d:u,l=e?e.lastChunkHandling:void 0;if(void 0===l&&(l="loose"),"loose"!==l&&"strict"!==l&&"stop-before-partial"!==l)throw new g("Incorrect `lastChunkHandling` option");i&&c(i.buffer);var y=t.length,w=i||[],A=0,x=0,S="",C=0;if(n)for(;;){if((C=f(t,C))===y){if(S.length>0){if("stop-before-partial"===l)break;if("loose"!==l)throw new p("Missing padding");if(1===S.length)throw new p("Malformed padding: exactly one additional character");A=v(w,b(S,s,!1),A)}x=y;break}var E=m(t,C);if(++C,"="===E){if(S.length<2)throw new p("Padding is too early");if(C=f(t,C),2===S.length){if(C===y){if("stop-before-partial"===l)break;throw new p("Malformed padding: only one =")}"="===m(t,C)&&(++C,C=f(t,C))}if(C<y)throw new p("Unexpected character after padding");A=v(w,b(S,s,"strict"===l),A),x=y;break}if(!o(s,E))throw new p("Unexpected character");var T=n-A;if(1===T&&2===S.length||2===T&&3===S.length)break;if(4===(S+=E).length&&(A=v(w,b(S,s,!1),A),S="",x=C,A===n))break}return{bytes:w,read:x,written:A}}},2303(t,e,i){var n=i(4576),s=i(9504),r=n.Uint8Array,a=n.SyntaxError,o=n.parseInt,l=Math.min,h=/[^\da-f]/i,c=s(h.exec),d=s("".slice);t.exports=function(t,e){var i=t.length;if(i%2!=0)throw new a("String should be an even number of characters");for(var n=e?l(e.length,i/2):i/2,s=e||new r(n),u=0,p=0;p<n;){var g=d(t,u,u+=2);if(c(h,g))throw new a("String should only contain hex characters");s[p++]=o(g,16)}return{bytes:s,read:u}}},7416(t,e,i){var n=i(9039),s=i(8227),r=i(3724),a=i(6395),o=s("iterator");t.exports=!n((function(){var t=new URL("b?a=1&b=2&c=3","https://a"),e=t.searchParams,i=new URLSearchParams("a=1&a=2&b=3"),n="";return t.pathname="c%20d",e.forEach((function(t,i){e.delete("b"),n+=i+t})),i.delete("a",2),i.delete("b",void 0),a&&(!t.toJSON||!i.has("a",1)||i.has("a",2)||!i.has("a",void 0)||i.has("b"))||!e.size&&(a||!r)||!e.sort||"https://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[o]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==n||"x"!==new URL("https://x",void 0).host}))},7040(t,e,i){var n=i(4495);t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},8686(t,e,i){var n=i(3724),s=i(9039);t.exports=n&&s((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 n=i(4576),s=i(4901),r=n.WeakMap;t.exports=s(r)&&/native code/.test(String(r))},4995(t,e,i){var n=i(9504),s=WeakMap.prototype;t.exports={WeakMap:WeakMap,set:n(s.set),get:n(s.get),has:n(s.has),remove:n(s.delete)}},8227(t,e,i){var n=i(4576),s=i(5745),r=i(9297),a=i(3392),o=i(4495),l=i(7040),h=n.Symbol,c=s("wks"),d=l?h.for||h:h&&h.withoutSetter||a;t.exports=function(t){return r(c,t)||(c[t]=o&&r(h,t)?h[t]:d("Symbol."+t)),c[t]}},6573(t,e,i){var n=i(3724),s=i(2106),r=i(3238),a=ArrayBuffer.prototype;n&&!("detached"in a)&&s(a,"detached",{configurable:!0,get:function(){return r(this)}})},7936(t,e,i){var n=i(6518),s=i(5636);s&&n({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return s(this,arguments.length?arguments[0]:void 0,!1)}})},8100(t,e,i){var n=i(6518),s=i(5636);s&&n({target:"ArrayBuffer",proto:!0},{transfer:function(){return s(this,arguments.length?arguments[0]:void 0,!0)}})},4114(t,e,i){var n=i(6518),s=i(8981),r=i(6198),a=i(4527),o=i(6837);n({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=s(this),i=r(e),n=arguments.length;o(i+n);for(var l=0;l<n;l++)e[i]=arguments[l],i++;return a(e,i),i}})},8111(t,e,i){var n=i(6518),s=i(4576),r=i(679),a=i(8551),o=i(4901),l=i(2787),h=i(2106),c=i(4659),d=i(9039),u=i(9297),p=i(8227),g=i(7657).IteratorPrototype,m=i(3724),f=i(6395),b="constructor",v="Iterator",y=p("toStringTag"),w=TypeError,A=s[v],x=f||!o(A)||A.prototype!==g||!d((function(){A({})})),S=function(){if(r(this,g),l(this)===g)throw new w("Abstract class Iterator not directly constructable")},C=function(t,e){m?h(g,t,{configurable:!0,get:function(){return e},set:function(e){if(a(this),this===g)throw new w("You can't redefine this property");u(this,t)?this[t]=e:c(this,t,e)}}):g[t]=e};u(g,y)||C(y,v),!x&&u(g,b)&&g[b]!==Object||C(b,S),S.prototype=g,n({global:!0,constructor:!0,forced:x},{Iterator:S})},9314(t,e,i){var n=i(6518),s=i(9565),r=i(8551),a=i(1767),o=i(4149),l=i(9590),h=i(9539),c=i(9462),d=i(684),u=i(4549),p=i(6395),g=!p&&!d("drop",0),m=!p&&!g&&u("drop",RangeError),f=p||g||m,b=c((function(){for(var t,e=this.iterator,i=this.next;this.remaining;)if(this.remaining--,t=r(s(i,e)),this.done=!!t.done)return;if(t=r(s(i,e)),!(this.done=!!t.done))return t.value}));n({target:"Iterator",proto:!0,real:!0,forced:f},{drop:function(t){var e;r(this);try{e=l(o(+t))}catch(t){h(this,"throw",t)}return m?s(m,this,e):new b(a(this),{remaining:e})}})},1148(t,e,i){var n=i(6518),s=i(9565),r=i(2652),a=i(9306),o=i(8551),l=i(1767),h=i(9539),c=i(4549)("every",TypeError);n({target:"Iterator",proto:!0,real:!0,forced:c},{every:function(t){o(this);try{a(t)}catch(t){h(this,"throw",t)}if(c)return s(c,this,t);var e=l(this),i=0;return!r(e,(function(e,n){if(!t(e,i++))return n()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(t,e,i){var n=i(6518),s=i(9565),r=i(9306),a=i(8551),o=i(1767),l=i(9462),h=i(6319),c=i(6395),d=i(9539),u=i(684),p=i(4549),g=!c&&!u("filter",(function(){})),m=!c&&!g&&p("filter",TypeError),f=c||g||m,b=l((function(){for(var t,e,i=this.iterator,n=this.predicate,r=this.next;;){if(t=a(s(r,i)),this.done=!!t.done)return;if(e=t.value,h(i,n,[e,this.counter++],!0))return e}}));n({target:"Iterator",proto:!0,real:!0,forced:f},{filter:function(t){a(this);try{r(t)}catch(t){d(this,"throw",t)}return m?s(m,this,t):new b(o(this),{predicate:t})}})},116(t,e,i){var n=i(6518),s=i(9565),r=i(2652),a=i(9306),o=i(8551),l=i(1767),h=i(9539),c=i(4549)("find",TypeError);n({target:"Iterator",proto:!0,real:!0,forced:c},{find:function(t){o(this);try{a(t)}catch(t){h(this,"throw",t)}if(c)return s(c,this,t);var e=l(this),i=0;return r(e,(function(e,n){if(t(e,i++))return n(e)}),{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(t,e,i){var n=i(6518),s=i(9565),r=i(9306),a=i(8551),o=i(1767),l=i(8646),h=i(9462),c=i(9539),d=i(6395),u=i(684),p=i(4549);var g=!d&&!u("flatMap",(function(){})),m=!d&&!g&&p("flatMap",TypeError),f=d||g||m||function(){try{var t=Iterator.prototype.flatMap.call(new Map([[4,5]]).entries(),(function(t){return t}));t.next(),t.return()}catch(t){return!0}}(),b=h((function(){for(var t,e,i=this.iterator,n=this.mapper;;){if(e=this.inner)try{if(!(t=a(s(e.next,e.iterator))).done)return t.value;this.inner=null}catch(t){c(i,"throw",t)}if(t=a(s(this.next,i)),this.done=!!t.done)return;try{this.inner=l(n(t.value,this.counter++),!1)}catch(t){c(i,"throw",t)}}}));n({target:"Iterator",proto:!0,real:!0,forced:f},{flatMap:function(t){a(this);try{r(t)}catch(t){c(this,"throw",t)}return m?s(m,this,t):new b(o(this),{mapper:t,inner:null})}})},7588(t,e,i){var n=i(6518),s=i(9565),r=i(2652),a=i(9306),o=i(8551),l=i(1767),h=i(9539),c=i(4549)("forEach",TypeError);n({target:"Iterator",proto:!0,real:!0,forced:c},{forEach:function(t){o(this);try{a(t)}catch(t){h(this,"throw",t)}if(c)return s(c,this,t);var e=l(this),i=0;r(e,(function(e){t(e,i++)}),{IS_RECORD:!0})}})},1701(t,e,i){var n=i(6518),s=i(9565),r=i(9306),a=i(8551),o=i(1767),l=i(9462),h=i(6319),c=i(9539),d=i(684),u=i(4549),p=i(6395),g=!p&&!d("map",(function(){})),m=!p&&!g&&u("map",TypeError),f=p||g||m,b=l((function(){var t=this.iterator,e=a(s(this.next,t));if(!(this.done=!!e.done))return h(t,this.mapper,[e.value,this.counter++],!0)}));n({target:"Iterator",proto:!0,real:!0,forced:f},{map:function(t){a(this);try{r(t)}catch(t){c(this,"throw",t)}return m?s(m,this,t):new b(o(this),{mapper:t})}})},8237(t,e,i){var n=i(6518),s=i(2652),r=i(9306),a=i(8551),o=i(1767),l=i(9539),h=i(4549),c=i(8745),d=i(9039),u=TypeError,p=d((function(){[].keys().reduce((function(){}),void 0)})),g=!p&&h("reduce",u);n({target:"Iterator",proto:!0,real:!0,forced:p||g},{reduce:function(t){a(this);try{r(t)}catch(t){l(this,"throw",t)}var e=arguments.length<2,i=e?void 0:arguments[1];if(g)return c(g,this,e?[t]:[t,i]);var n=o(this),h=0;if(s(n,(function(n){e?(e=!1,i=n):i=t(i,n,h),h++}),{IS_RECORD:!0}),e)throw new u("Reduce of empty iterator with no initial value");return i}})},3579(t,e,i){var n=i(6518),s=i(9565),r=i(2652),a=i(9306),o=i(8551),l=i(1767),h=i(9539),c=i(4549)("some",TypeError);n({target:"Iterator",proto:!0,real:!0,forced:c},{some:function(t){o(this);try{a(t)}catch(t){h(this,"throw",t)}if(c)return s(c,this,t);var e=l(this),i=0;return r(e,(function(e,n){if(t(e,i++))return n()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(t,e,i){var n=i(6518),s=i(9565),r=i(8551),a=i(1767),o=i(4149),l=i(9590),h=i(9462),c=i(9539),d=i(4549),u=i(6395),p=!u&&d("take",RangeError),g=h((function(){var t=this.iterator;if(!this.remaining--)return this.done=!0,c(t,"normal",void 0);var e=r(s(this.next,t));return(this.done=!!e.done)?void 0:e.value}));n({target:"Iterator",proto:!0,real:!0,forced:u||p},{take:function(t){var e;r(this);try{e=l(o(+t))}catch(t){c(this,"throw",t)}return p?s(p,this,e):new g(a(this),{remaining:e})}})},9112(t,e,i){var n=i(6518),s=i(3724),r=i(4576),a=i(7751),o=i(9504),l=i(9565),h=i(4901),c=i(34),d=i(4376),u=i(9297),p=i(655),g=i(6198),m=i(4659),f=i(9039),b=i(8235),v=i(4495),y=r.JSON,w=r.Number,A=r.SyntaxError,x=y&&y.parse,S=a("Object","keys"),C=Object.getOwnPropertyDescriptor,E=o("".charAt),T=o("".slice),_=o(/./.exec),M=o([].push),k=/^\d$/,D=/^[1-9]$/,P=/^[\d-]$/,I=/^[\t\n\r ]$/,R=function(t,e,i,n){var s,r,a,o,h,p=t[e],m=n&&p===n.value,f=m&&"string"==typeof n.source?{source:n.source}:{};if(c(p)){var b=d(p),v=m?n.nodes:b?[]:{};if(b)for(s=v.length,a=g(p),o=0;o<a;o++)B(p,o,R(p,""+o,i,o<s?v[o]:void 0));else for(r=S(p),a=g(r),o=0;o<a;o++)h=r[o],B(p,h,R(p,h,i,u(v,h)?v[h]:void 0))}return l(i,t,e,p,f)},B=function(t,e,i){if(s){var n=C(t,e);if(n&&!n.configurable)return}void 0===i?delete t[e]:m(t,e,i)},F=function(t,e,i,n){this.value=t,this.end=e,this.source=i,this.nodes=n},L=function(t,e){this.source=t,this.index=e};L.prototype={fork:function(t){return new L(this.source,t)},parse:function(){var t=this.source,e=this.skip(I,this.index),i=this.fork(e),n=E(t,e);if(_(P,n))return i.number();switch(n){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 A('Unexpected character: "'+n+'" at: '+e)},node:function(t,e,i,n,s){return new F(e,n,t?null:T(this.source,i,n),s)},object:function(){for(var t=this.source,e=this.index+1,i=!1,n={},s={};e<t.length;){if(e=this.until(['"',"}"],e),"}"===E(t,e)&&!i){e++;break}var r=this.fork(e).string(),a=r.value;e=r.end,e=this.until([":"],e)+1,e=this.skip(I,e),r=this.fork(e).parse(),m(s,a,r),m(n,a,r.value),e=this.until([",","}"],r.end);var o=E(t,e);if(","===o)i=!0,e++;else if("}"===o){e++;break}}return this.node(1,n,this.index,e,s)},array:function(){for(var t=this.source,e=this.index+1,i=!1,n=[],s=[];e<t.length;){if(e=this.skip(I,e),"]"===E(t,e)&&!i){e++;break}var r=this.fork(e).parse();if(M(s,r),M(n,r.value),e=this.until([",","]"],r.end),","===E(t,e))i=!0,e++;else if("]"===E(t,e)){e++;break}}return this.node(1,n,this.index,e,s)},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("-"===E(t,i)&&i++,"0"===E(t,i))i++;else{if(!_(D,E(t,i)))throw new A("Failed to parse number at: "+i);i=this.skip(k,i+1)}if(("."===E(t,i)&&(i=this.skip(k,i+1)),"e"===E(t,i)||"E"===E(t,i))&&(i++,"+"!==E(t,i)&&"-"!==E(t,i)||i++,i===(i=this.skip(k,i))))throw new A("Failed to parse number's exponent value at: "+i);return this.node(0,w(T(t,e,i)),e,i)},keyword:function(t){var e=""+t,i=this.index,n=i+e.length;if(T(this.source,i,n)!==e)throw new A("Failed to parse value at: "+i);return this.node(0,t,i,n)},skip:function(t,e){for(var i=this.source;e<i.length&&_(t,E(i,e));e++);return e},until:function(t,e){e=this.skip(I,e);for(var i=E(this.source,e),n=0;n<t.length;n++)if(t[n]===i)return e;throw new A('Unexpected character: "'+i+'" at: '+e)}};var O=f((function(){var t,e="9007199254740993";return x(e,(function(e,i,n){t=n.source})),t!==e})),N=v&&!f((function(){return 1/x("-0 \t")!=-1/0}));n({target:"JSON",stat:!0,forced:O},{parse:function(t,e){return N&&!h(e)?x(t):function(t,e){t=p(t);var i=new L(t,0,""),n=i.parse(),s=n.value,r=i.skip(I,n.end);if(r<t.length)throw new A('Unexpected extra character: "'+E(t,r)+'" after the parsed data at: '+r);return h(e)?R({"":s},"",e,n):s}(t,e)}})},3110(t,e,i){var n=i(6518),s=i(7751),r=i(8745),a=i(9565),o=i(9504),l=i(9039),h=i(4376),c=i(4901),d=i(5810),u=i(757),p=i(2195),g=i(655),m=i(7680),f=i(8235),b=i(3392),v=i(4495),y=i(7819),w=String,A=s("JSON","stringify"),x=o(/./.exec),S=o("".charAt),C=o("".charCodeAt),E=o("".replace),T=o("".slice),_=o([].push),M=o(1.1.toString),k=/[\uD800-\uDFFF]/g,D=/^[\uD800-\uDBFF]$/,P=/^[\uDC00-\uDFFF]$/,I=b(),R=I.length,B=!v||l((function(){var t=s("Symbol")("stringify detection");return"[null]"!==A([t])||"{}"!==A({a:t})||"{}"!==A(Object(t))})),F=l((function(){return'"\\udf06\\ud834"'!==A("\udf06\ud834")||'"\\udead"'!==A("\udead")})),L=B?function(t,e){var i=m(arguments),n=N(e);if(c(n)||void 0!==t&&!u(t))return i[1]=function(t,e){if(c(n)&&(e=a(n,this,w(t),e)),!u(e))return e},r(A,null,i)}:A,O=function(t,e,i){var n=S(i,e-1),s=S(i,e+1);return x(D,t)&&!x(P,s)||x(P,t)&&!x(D,n)?"\\u"+M(C(t,0),16):t},N=function(t){if(c(t))return t;if(h(t)){for(var e=t.length,i=[],n=0;n<e;n++){var s=t[n];"string"==typeof s?_(i,s):"number"!=typeof s&&"Number"!==p(s)&&"String"!==p(s)||_(i,g(s))}var r=i.length,a=!0;return function(t,e){if(a)return a=!1,e;if(h(this))return e;for(var n=0;n<r;n++)if(i[n]===t)return e}}};A&&n({target:"JSON",stat:!0,arity:3,forced:B||F||!y},{stringify:function(t,e,i){var n=N(e),s=[],r=L(t,(function(t,e){var i=c(n)?a(n,this,w(t),e):e;return!y&&d(i)?I+(_(s,i.rawJSON)-1):i}),i);if("string"!=typeof r)return r;if(F&&(r=E(r,k,O)),y)return r;for(var o="",l=r.length,h=0;h<l;h++){var u=S(r,h);if('"'===u){var p=f(r,++h).end-1,g=T(r,h,p);o+=T(g,0,R)===I?s[T(g,R)]:'"'+g+'"',h=p}else o+=u}return o}})},2731(t,e,i){var n=i(6518),s=i(9306),r=i(6194),a=i(2248),o=i(6395),l=a.get,h=a.has,c=a.set;n({target:"Map",proto:!0,real:!0,forced:o},{getOrInsertComputed:function(t,e){if(r(this),s(e),h(this,t))return l(this,t);0===t&&1/t==-1/0&&(t=0);var i=e(t);return c(this,t,i),i}})},5367(t,e,i){var n=i(6518),s=i(6194),r=i(2248),a=i(6395),o=r.get,l=r.has,h=r.set;n({target:"Map",proto:!0,real:!0,forced:a},{getOrInsert:function(t,e){return l(s(this),t)?o(this,t):(h(this,t,e),e)}})},3068(t,e,i){var n=i(6518),s=i(9504),r=i(2652),a=RangeError,o=TypeError,l=1/0,h=Math.abs,c=Math.pow,d=s([].push),u=c(2,1023),p=c(2,53)-1,g=Number.MAX_VALUE,m=c(2,971),f={},b={},v={},y={},w={},A=function(t,e){var i=t+e;return{hi:i,lo:e-(i-t)}};n({target:"Math",stat:!0},{sumPrecise:function(t){var e=[],i=0,n=y;switch(r(t,(function(t){if(++i>=p)throw new a("Maximum allowed index exceeded");if("number"!=typeof t)throw new o("Value is not a number");n!==f&&(t!=t?n=f:t===l?n=n===b?f:v:t===-1/0?n=n===v?f:b:0===t&&1/t!==l||n!==y&&n!==w||(n=w,d(e,t)))})),n){case f:return NaN;case b:return-1/0;case v:return l;case y:return-0}for(var s,c,x,S,C,E,T=[],_=0,M=0;M<e.length;M++){s=e[M];for(var k=0,D=0;D<T.length;D++){if(c=T[D],h(s)<h(c)&&(E=s,s=c,c=E),S=(x=A(s,c)).hi,C=x.lo,h(S)===l){var P=S===l?1:-1;_+=P,h(s=s-P*u-P*u)<h(c)&&(E=s,s=c,c=E),S=(x=A(s,c)).hi,C=x.lo}0!==C&&(T[k++]=C),s=S}T.length=k,0!==s&&d(T,s)}var I=T.length-1;if(S=0,C=0,0!==_){var R=I>=0?T[I]:0;if(I--,h(_)>1||_>0&&R>0||_<0&&R<0)return _>0?l:-1/0;if(S=(x=A(_*u,R/2)).hi,C=x.lo,C*=2,h(2*S)===l)return S>0?S===u&&C===-m/2&&I>=0&&T[I]<0?g:l:S===-u&&C===m/2&&I>=0&&T[I]>0?-g:-1/0;0!==C&&(T[++I]=C,C=0),S*=2}for(;I>=0&&(S=(x=A(S,T[I--])).hi,0===(C=x.lo)););return I>=0&&(C<0&&T[I]<0||C>0&&T[I]>0)&&(c=2*C)===(s=S+c)-S&&(S=s),S}})},1689(t,e,i){var n=i(6518),s=i(4576),r=i(8745),a=i(7680),o=i(6043),l=i(9306),h=i(1103),c=s.Promise,d=!1;n({target:"Promise",stat:!0,forced:!c||!c.try||h((function(){c.try((function(t){d=8===t}),8)})).error||!d},{try:function(t){var e=arguments.length>1?a(arguments,1):[],i=o.f(this),n=h((function(){return r(l(t),void 0,e)}));return(n.error?i.reject:i.resolve)(n.value),i.promise}})},4628(t,e,i){var n=i(6518),s=i(6043);n({target:"Promise",stat:!0},{withResolvers:function(){var t=s.f(this);return{promise:t.promise,resolve:t.resolve,reject:t.reject}}})},7642(t,e,i){var n=i(6518),s=i(3440),r=i(9039);n({target:"Set",proto:!0,real:!0,forced:!i(4916)("difference",(function(t){return 0===t.size}))||r((function(){var t={size:1,has:function(){return!0},keys:function(){var t=0;return{next:function(){var i=t++>1;return e.has(1)&&e.clear(),{done:i,value:2}}}}},e=new Set([1,2,3,4]);return 3!==e.difference(t).size}))},{difference:s})},8004(t,e,i){var n=i(6518),s=i(9039),r=i(8750);n({target:"Set",proto:!0,real:!0,forced:!i(4916)("intersection",(function(t){return 2===t.size&&t.has(1)&&t.has(2)}))||s((function(){return"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))}))},{intersection:r})},3853(t,e,i){var n=i(6518),s=i(4449);n({target:"Set",proto:!0,real:!0,forced:!i(4916)("isDisjointFrom",(function(t){return!t}))},{isDisjointFrom:s})},5876(t,e,i){var n=i(6518),s=i(3838);n({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSubsetOf",(function(t){return t}))},{isSubsetOf:s})},2475(t,e,i){var n=i(6518),s=i(8527);n({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSupersetOf",(function(t){return!t}))},{isSupersetOf:s})},5024(t,e,i){var n=i(6518),s=i(3650),r=i(9835);n({target:"Set",proto:!0,real:!0,forced:!i(4916)("symmetricDifference")||!r("symmetricDifference")},{symmetricDifference:s})},1698(t,e,i){var n=i(6518),s=i(4204),r=i(9835);n({target:"Set",proto:!0,real:!0,forced:!i(4916)("union")||!r("union")},{union:s})},9577(t,e,i){var n=i(4644),s=i(1108),r=i(6198),a=i(1291),o=i(5854),l=n.aTypedArray,h=n.getTypedArrayConstructor,c=n.exportTypedArrayMethod,d=RangeError,u=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(t){return 8===t}}(),p=u&&function(){try{new Int8Array(1).with(-.5,1)}catch(t){return!0}}();c("with",{with:function(t,e){var i=l(this),n=r(i),c=a(t),u=c<0?n+c:c,p=s(i)?o(e):+e;if(u>=n||u<0)throw new d("Incorrect index");for(var g=new(h(i))(n),m=0;m<n;m++)g[m]=m===u?p:i[m];return g}}.with,!u||p)},5213(t,e,i){var n=i(6518),s=i(4576),r=i(5370),a=i(9143),o=s.Uint8Array,l=!o||!o.fromBase64||!function(){try{return void o.fromBase64("a")}catch(t){}try{o.fromBase64("",null)}catch(t){return!0}}();o&&n({target:"Uint8Array",stat:!0,forced:l},{fromBase64:function(t){var e=a(t,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(o,e.bytes)}})},6632(t,e,i){var n=i(6518),s=i(4576),r=i(9143),a=i(4154),o=s.Uint8Array,l=!o||!o.prototype.setFromBase64||!function(){var t=new o([255,255,255,255,255]);try{return void t.setFromBase64("",null)}catch(t){}try{return void t.setFromBase64("a")}catch(t){}try{t.setFromBase64("MjYyZg===")}catch(e){return 50===t[0]&&54===t[1]&&50===t[2]&&255===t[3]&&255===t[4]}}();o&&n({target:"Uint8Array",proto:!0,forced:l},{setFromBase64:function(t){a(this);var e=r(t,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:e.read,written:e.written}}})},4226(t,e,i){var n=i(6518),s=i(4576),r=i(3463),a=i(4154),o=i(5169),l=i(2303);s.Uint8Array&&n({target:"Uint8Array",proto:!0,forced:function(){try{var t=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(t).setFromHex("cafed00d")}catch(t){return!0}}()},{setFromHex:function(t){a(this),r(t),o(this.buffer);var e=l(t,this).read;return{read:e,written:e/2}}})},9486(t,e,i){var n=i(6518),s=i(4576),r=i(9504),a=i(3972),o=i(4154),l=i(5169),h=i(2804),c=i(944),d=h.i2c,u=h.i2cUrl,p=r("".charAt),g=s.Uint8Array,m=!g||!g.prototype.toBase64||!function(){try{(new g).toBase64(null)}catch(t){return!0}}();g&&n({target:"Uint8Array",proto:!0,forced:m},{toBase64:function(){var t=o(this),e=arguments.length?a(arguments[0]):void 0,i="base64"===c(e)?d:u,n=!!e&&!!e.omitPadding;l(this.buffer);for(var s,r="",h=0,g=t.length,m=function(t){return p(i,s>>6*t&63)};h+2<g;h+=3)s=(t[h]<<16)+(t[h+1]<<8)+t[h+2],r+=m(3)+m(2)+m(1)+m(0);return h+2===g?(s=(t[h]<<16)+(t[h+1]<<8),r+=m(3)+m(2)+m(1)+(n?"":"=")):h+1===g&&(s=t[h]<<16,r+=m(3)+m(2)+(n?"":"==")),r}})},456(t,e,i){var n=i(6518),s=i(4576),r=i(9504),a=i(4154),o=i(5169),l=r(1.1.toString),h=s.Uint8Array,c=!h||!h.prototype.toHex||!function(){try{return"ffffffffffffffff"===new h([255,255,255,255,255,255,255,255]).toHex()}catch(t){return!1}}();h&&n({target:"Uint8Array",proto:!0,forced:c},{toHex:function(){a(this),o(this.buffer);for(var t="",e=0,i=this.length;e<i;e++){var n=l(this[e],16);t+=1===n.length?"0"+n:n}return t}})},9452(t,e,i){var n=i(6518),s=i(9306),r=i(6557),a=i(4328),o=i(4995),l=i(6395),h=o.get,c=o.has,d=o.set;n({target:"WeakMap",proto:!0,real:!0,forced:l||!function(){try{WeakMap.prototype.getOrInsertComputed&&(new WeakMap).getOrInsertComputed(1,(function(){throw 1}))}catch(t){return t instanceof TypeError}}()},{getOrInsertComputed:function(t,e){if(r(this),a(t),s(e),c(this,t))return h(this,t);var i=e(t);return d(this,t,i),i}})},8454(t,e,i){var n=i(6518),s=i(6557),r=i(4995),a=i(6395),o=r.get,l=r.has,h=r.set;n({target:"WeakMap",proto:!0,real:!0,forced:a},{getOrInsert:function(t,e){return l(s(this),t)?o(this,t):(h(this,t,e),e)}})},4979(t,e,i){var n=i(6518),s=i(4576),r=i(7751),a=i(6980),o=i(4913).f,l=i(9297),h=i(679),c=i(3167),d=i(2603),u=i(5002),p=i(8574),g=i(3724),m=i(6395),f="DOMException",b=r("Error"),v=r(f),y=function(){h(this,w);var t=arguments.length,e=d(t<1?void 0:arguments[0]),i=d(t<2?void 0:arguments[1],"Error"),n=new v(e,i),s=new b(e);return s.name=f,o(n,"stack",a(1,p(s.stack,1))),c(n,this,y),n},w=y.prototype=v.prototype,A="stack"in new b(f),x="stack"in new v(1,2),S=v&&g&&Object.getOwnPropertyDescriptor(s,f),C=!(!S||S.writable&&S.configurable),E=A&&!C&&!x;n({global:!0,constructor:!0,forced:m||E},{DOMException:E?y:v});var T=r(f),_=T.prototype;if(_.constructor!==T)for(var M in m||o(_,"constructor",a(1,T)),u)if(l(u,M)){var k=u[M],D=k.s;l(T,D)||o(T,D,a(6,k.c))}},4603(t,e,i){var n=i(6840),s=i(9504),r=i(655),a=i(2812),o=URLSearchParams,l=o.prototype,h=s(l.append),c=s(l.delete),d=s(l.forEach),u=s([].push),p=new o("a=1&a=2&b=3");p.delete("a",1),p.delete("b",void 0),p+""!="a=2"&&n(l,"delete",(function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return c(this,t);var n=[];d(this,(function(t,e){u(n,{key:e,value:t})})),a(e,1);for(var s,o=r(t),l=r(i),p=0,g=0,m=!1,f=n.length;p<f;)s=n[p++],m||s.key===o?(m=!0,c(this,s.key)):g++;for(;g<f;)(s=n[g++]).key===o&&s.value===l||h(this,s.key,s.value)}),{enumerable:!0,unsafe:!0})},7566(t,e,i){var n=i(6840),s=i(9504),r=i(655),a=i(2812),o=URLSearchParams,l=o.prototype,h=s(l.getAll),c=s(l.has),d=new o("a=1");!d.has("a",2)&&d.has("a",void 0)||n(l,"has",(function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return c(this,t);var n=h(this,t);a(e,1);for(var s=r(i),o=0;o<n.length;)if(n[o++]===s)return!0;return!1}),{enumerable:!0,unsafe:!0})},8721(t,e,i){var n=i(3724),s=i(9504),r=i(2106),a=URLSearchParams.prototype,o=s(a.forEach);n&&!("size"in a)&&r(a,"size",{get:function(){var t=0;return o(this,(function(){t++})),t},configurable:!0,enumerable:!0})},5781(t,e,i){var n=i(6518),s=i(7751),r=i(2812),a=i(655),o=i(7416),l=s("URL");n({target:"URL",stat:!0,forced:!o},{parse:function(t){var e=r(arguments.length,1),i=a(t),n=e<2||void 0===arguments[1]?void 0:a(arguments[1]);try{return new l(i,n)}catch(t){return null}}})}},e={};function i(n){var s=e[n];if(void 0!==s)return s.exports;var r=e[n]={exports:{}};return t[n].call(r.exports,r,r.exports,i),r.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);i(4114),i(6573),i(8100),i(7936),i(8111),i(8237),i(5367),i(2731),i(3068),i(9577),i(6632),i(4226),i(9486),i(456),i(5781);const n=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),s=[.001,0,0,.001,0,0],r=1.35,a=1,o=2,l=4,h=16,c=32,d=64,u=128,p=256,g={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},m="pdfjs_internal_editor_",f={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},b={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},v={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},y=1,w=2,A=0,x=1,S=2,C=3,E=3,T=4,_={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},M={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},k=1,D=2,P=3,I=4,R=5,B={ERRORS:0,WARNINGS:1,INFOS:5},F={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},L=0,O=1,N=2,U=3,z=4,H={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let j=B.WARNINGS;function G(t){Number.isInteger(t)&&(j=t)}function $(){return j}function V(t){j>=B.INFOS&&console.info(`Info: ${t}`)}function W(t){j>=B.WARNINGS&&console.warn(`Warning: ${t}`)}function X(t){throw new Error(t)}function q(t,e){t||X(e)}function K(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){t.match(/\./g)?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const n=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n)?n:null}function Y(t,e,i=!1){const n=URL.parse(t);return n?(n.hash=e,n.href):i&&K(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function J(t){return t.substring(t.lastIndexOf("/")+1)}function Q(t,e,i,n=!1){return Object.defineProperty(t,e,{value:i,enumerable:!n,configurable:!0,writable:!1}),i}const Z=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class tt extends Z{constructor(t,e){super(t,"PasswordException"),this.code=e}}class et extends Z{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class it extends Z{constructor(t){super(t,"InvalidPDFException")}}class nt extends Z{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class st extends Z{constructor(t){super(t,"FormatError")}}class rt extends Z{constructor(t){super(t,"AbortException")}}function at(t){"string"!=typeof t&&X("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let n=0;n<e;++n)i[n]=255&t.charCodeAt(n);return i}class ot{static get isLittleEndian(){return Q(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return Q(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Q(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Q(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return Q(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return Q(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:t,userAgent:e}=navigator;return Q(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return Q(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const lt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class ht{static makeHexColor(t,e,i){return`#${lt[t]}${lt[e]}${lt[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const n=t[i],s=t[i+1];t[i]=n*e[0]+s*e[2]+e[4],t[i+1]=n*e[1]+s*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const n=e[0],s=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){const h=t[i+e],c=t[i+e+1];t[i+e]=h*n+c*r+o,t[i+e+1]=h*s+c*a+l}}static applyInverseTransform(t,e){const i=t[0],n=t[1],s=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/s,t[1]=(-i*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/s}static axialAlignedBoundingBox(t,e,i){const n=e[0],s=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3];let p=n*h+o,g=p,m=n*d+o,f=m,b=a*c+l,v=b,y=a*u+l,w=y;if(0!==s||0!==r){const t=s*h,e=s*d,i=r*c,n=r*u;p+=i,f+=i,m+=n,g+=n,b+=t,w+=t,y+=e,v+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,y,v,w),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,y,v,w)}static inverseTransform(t){const 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,e){const i=t[0],n=t[1],s=t[2],r=t[3],a=i**2+n**2,o=i*s+n*r,l=s**2+r**2,h=(a+l)/2,c=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){const 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){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>n)return null;const s=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return s>r?null:[i,s,n,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,n,s){s[0]=Math.min(s[0],t,i),s[1]=Math.min(s[1],e,n),s[2]=Math.max(s[2],t,i),s[3]=Math.max(s[3],e,n)}static#t(t,e,i,n,s,r,a,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*i)+u*n,g=c*(c*(c*s+3*l*r)+3*d*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,n,s,r,a,o,l,h,c,d){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,n,s,r,a,o,-c/h,d));const u=h**2-4*c*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,n,s,r,a,o,(-h+p)/g,d),this.#t(t,e,i,n,s,r,a,o,(-h-p)/g,d)}static bezierBoundingBox(t,e,i,n,s,r,a,o,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),this.#e(t,i,s,a,e,n,r,o,3*(3*(i-s)-t+a),6*(t-2*i+s),3*(i-t),l),this.#e(t,i,s,a,e,n,r,o,3*(3*(n-r)-e+o),6*(e-2*n+r),3*(n-e),l)}}let ct=null,dt=null;function ut(t){return ct||(ct=/([\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,dt=new Map([["ﬅ","ſt"]])),t.replaceAll(ct,((t,e,i)=>e?e.normalize("NFKC"):dt.get(i)))}function pt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){"object"==typeof t&&void 0!==t?.length||X("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const n=[];for(let s=0;s<e;s+=i){const r=Math.min(s+i,e),a=t.subarray(s,r);n.push(String.fromCharCode.apply(null,a))}return n.join("")}(t)}const gt="pdfjs_internal_id_";const mt=()=>[],ft=()=>new Map,bt=()=>Object.create(null);function vt(t,e,i){return Math.min(Math.max(t,e),i)}"function"!=typeof Response.prototype.bytes&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())}),"function"!=typeof AbortSignal.any&&(AbortSignal.any=function(t){const e=new AbortController,{signal:i}=e;for(const n of t)if(n.aborted)return e.abort(n.reason),i;for(const n of t)n.addEventListener("abort",(()=>{e.abort(n.reason)}),{signal:i});return i});i(1148),i(1701),i(4603),i(7566),i(8721);class yt{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let n=null;const s=i.name;if("#text"===s)n=i.value;else{if(!yt.shouldBuildText(s))return;i?.attributes?.textContent?n=i.attributes.textContent:i.value&&(n=i.value)}if(null!==n&&e.push({str:n}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}class wt{static setupStorage(t,e,i,n,s){const r=n.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===s)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===s)break;t.addEventListener("change",(t=>{n.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===s)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,s=-1===i.selectedIndex?"":i[i.selectedIndex].value;n.setValue(e,{value:s})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:n,linkService:s}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${n}`);for(const[e,i]of Object.entries(r))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&&s.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,n=t.xfaHtml,s=t.intent||"display",r=document.createElement(n.name);n.attributes&&this.setAttributes({html:r,element:n,intent:s,linkService:i});const a="richText"!==s,o=t.div;if(o.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===n.children.length){if(n.value){const t=document.createTextNode(n.value);r.append(t),a&&yt.shouldBuildText(n.name)&&l.push(t)}return{textDivs:l}}const h=[[n,-1,r]];for(;h.length>0;){const[t,n,r]=h.at(-1);if(n+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const t=document.createTextNode(o.value);l.push(t),r.append(t);continue}const d=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,c):document.createElement(c);if(r.append(d),o.attributes&&this.setAttributes({html:d,element:o,storage:e,intent:s,linkService:i}),o.children?.length>0)h.push([o,-1,d]);else if(o.value){const t=document.createTextNode(o.value);a&&yt.shouldBuildText(c)&&l.push(t),d.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const At="http://www.w3.org/2000/svg";class xt{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function St(t,e="text"){if(Pt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise(((i,n)=>{const s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="bytes"===e?"arraybuffer":e,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE)if(200!==s.status&&0!==s.status)n(new Error(s.statusText));else{switch(e){case"bytes":return void i(new Uint8Array(s.response));case"blob":case"json":return void i(s.response)}i(s.responseText)}},s.send(null)}))}class Ct{constructor({viewBox:t,userUnit:e,scale:i,rotation:n,offsetX:s=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=n,this.offsetX=s,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,d,u,p,g,m,f;switch((n%=360)<0&&(n+=360),n){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(d=-d,u=-u),0===h?(p=Math.abs(l-t[1])*i+s,g=Math.abs(o-t[0])*i+r,m=(t[3]-t[1])*i,f=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+s,g=Math.abs(l-t[1])*i+r,m=(t[2]-t[0])*i,f=(t[3]-t[1])*i),this.transform=[h*i,c*i,d*i,u*i,p-h*i*o-d*i*l,g-c*i*o-u*i*l],this.width=m,this.height=f}get rawDims(){const t=this.viewBox;return Q(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:n=this.offsetY,dontFlip:s=!1}={}){return new Ct({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}convertToViewportPoint(t,e){const i=[t,e];return ht.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];ht.applyTransform(e,this.transform);const i=[t[2],t[3]];return ht.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return ht.applyInverseTransform(i,this.transform),i}}class Et extends Z{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Tt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function _t(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Mt(t){return[t]=t.split(/[#?]/,1),J(t)}function kt(t,e="document.pdf"){if("string"!=typeof t)return e;if(Tt(t))return W('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;const n=t=>{try{let e=decodeURIComponent(t);return e.includes("/")&&(e=J(e),/^\.pdf$/i.test(e))?t:e}catch{return t}},s=/\.pdf$/i,r=J(i.pathname);if(s.test(r))return n(r);if(i.searchParams.size>0){const t=t=>[...t].findLast((t=>s.test(t))),e=t(i.searchParams.values())??t(i.searchParams.keys());if(e)return n(e)}if(i.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return n(t[0])}return e}class Dt{started=Object.create(null);times=[];time(t){t in this.started&&W(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||W(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:n,end:s}of this.times)t.push(`${i.padEnd(e)} ${s-n}ms\n`);return t.join("")}}function Pt(t,e){const i=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(i?.protocol??"")}function It(t){t.preventDefault()}function Rt(t){t.preventDefault(),t.stopPropagation()}function Bt(t){console.log("Deprecated API usage: "+t)}class Ft{static#i;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let s=parseInt(e[3],10);s=s>=1&&s<=31?s:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r: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;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(r+=h,a+=c):"+"===l&&(r-=h,a-=c),new Date(Date.UTC(i,n,s,r,a,o))}}function Lt(t,{scale:e=1,rotation:i=0}){const{width:n,height:s}=t.attributes.style,r=[0,0,parseInt(n),parseInt(s)];return new Ct({viewBox:r,userUnit:1,scale:e,rotation:i})}function Ot(t){if(t.startsWith("#")){const 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):(W(`Not a valid color format: "${t}"`),[0,0,0])}function Nt(t){const{a:e,b:i,c:n,d:s,e:r,f:a}=t.getTransform();return[e,i,n,s,r,a]}function Ut(t){const{a:e,b:i,c:n,d:s,e:r,f:a}=t.getTransform().invertSelf();return[e,i,n,s,r,a]}function zt(t,e,i=!1,n=!0){if(e instanceof Ct){const{pageWidth:n,pageHeight:s}=e.rawDims,{style:r}=t,a=ot.isCSSRoundSupported,o=`var(--total-scale-factor) * ${n}px`,l=`var(--total-scale-factor) * ${s}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,c=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=c,r.height=h):(r.width=h,r.height=c)}n&&t.setAttribute("data-main-rotation",e.rotation)}class Ht{constructor(){const{pixelRatio:t}=Ht;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,n,s=-1){let r=1/0,a=1/0,o=1/0;(i=Ht.capPixels(i,s))>0&&(r=Math.sqrt(i/(t*e))),-1!==n&&(a=n/t,o=n/e);const l=Math.min(r,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const jt=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Gt{static get isDarkMode(){return Q(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class $t{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),Q(this,"commentForegroundColor",Ot(i))}}function Vt(t,e,i,n){const s=255*(1-(n=vt(n??1,0,1)));return[t=Math.round(t*n+s),e=Math.round(e*n+s),i=Math.round(i*n+s)]}function Wt(t,e){const i=t[0]/255,n=t[1]/255,s=t[2]/255,r=Math.max(i,n,s),a=Math.min(i,n,s),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{const t=r-a;switch(e[1]=o<.5?t/(r+a):t/(2-r-a),r){case i:e[0]=60*((n-s)/t+(n<s?6:0));break;case n:e[0]=60*((s-i)/t+2);break;case s:e[0]=60*((i-n)/t+4)}}e[2]=o}function Xt(t,e){const i=t[0],n=t[1],s=t[2],r=(1-Math.abs(2*s-1))*n,a=r*(1-Math.abs(i/60%2-1)),o=s-r/2;switch(Math.floor(i/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o}}function qt(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Kt(t,e,i){Xt(t,i),i.map(qt);const n=.2126*i[0]+.7152*i[1]+.0722*i[2];Xt(e,i),i.map(qt);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];return n>s?(n+.05)/(s+.05):(s+.05)/(n+.05)}const Yt=new Map;function Jt(t,e){const i=t[0]+256*t[1]+65536*t[2]+16777216*e[0]+4294967296*e[1]+1099511627776*e[2];let n=Yt.get(i);if(n)return n;const s=new Float32Array(9),r=s.subarray(0,3),a=s.subarray(3,6);Wt(t,a);const o=s.subarray(6,9);Wt(e,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Kt(a,o,r)<h){let t,e;l?(t=a[2],e=1):(t=0,e=a[2]);const i=.005;for(;e-t>i;){const i=a[2]=(t+e)/2;l===Kt(a,o,r)<h?t=i:e=i}a[2]=l?e:t}return Xt(a,r),n=ht.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),Yt.set(i,n),n}function Qt({html:t,dir:e,className:i},n){const s=document.createDocumentFragment();if("string"==typeof t){const i=document.createElement("p");i.dir=e||"auto";const n=t.split(/(?:\r\n?|\n)/);for(let t=0,e=n.length;t<e;++t){const s=n[t];i.append(document.createTextNode(s)),t<e-1&&i.append(document.createElement("br"))}s.append(i)}else wt.render({xfaHtml:t,div:s,intent:"richText"});s.firstElementChild.classList.add("richText",i),n.append(s)}function Zt(t){const e=new Path2D;if(!t)return e;for(let i=0,n=t.length;i<n;)switch(t[i++]){case L:e.moveTo(t[i++],t[i++]);break;case O:e.lineTo(t[i++],t[i++]);break;case N:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case U:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case z:e.closePath();break;default:W(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class te{#n=null;#s=null;#r=null;#a=0;#o=[];#l=null;#h=null;get pagesNumber(){return this.#a}set pagesNumber(t){this.#a!==t&&(this.#a=t,this.#c())}#c(){this.#s=null,this.#n=null}addListener(t){this.#o.push(t)}removeListener(t){const e=this.#o.indexOf(t);e>=0&&this.#o.splice(e,1)}#d(t){for(const e of this.#o)e(t)}#u(t){if(this.#s)return;const e=this.#a,i=this.#s=new Uint32Array(e);this.#r=new Int32Array(i);const n=this.#n=new Map;if(t)for(let t=1;t<=e;t++)i[t-1]=t,n.set(t,[t])}#p(){const t=this.#n,e=this.#s;t.clear();for(let i=0,n=this.#a;i<n;i++){const n=e[i],s=t.get(n);s?s.push(i+1):t.set(n,[i+1])}}movePages(t,e,i){this.#u(!0);const n=this.#s,s=this.#n,r=e.length,a=new Uint32Array(r);let o=0;for(let t=0;t<r;t++){const s=e[t]-1;a[t]=n[s],s<i&&(o+=1)}const l=this.#a;let h=i-o;const c=l-r;h=vt(h,0,c);for(let e=0,i=0;e<l;e++)t.has(e+1)||(n[i++]=n[e]);n.copyWithin(h+r,h,c),n.set(a,h),this.#g(s,null),this.#p(),this.#d({type:"move"}),n.every(((t,e)=>t===e+1))&&this.#c()}deletePages(t){this.#u(!0);const e=this.#s,i=this.#n;this.pagesNumber-=t.length,this.#u(!1);const n=this.#s;let s=0,r=0;for(const i of t){const t=i-1;t!==s&&(n.set(e.subarray(s,t),r),r+=t-s),s=t+1}s<e.length&&n.set(e.subarray(s),r),this.#g(i,null),this.#p(),this.#d({type:"delete",pageNumbers:t})}copyPages(t){this.#u(!0),this.#h=t,this.#l=t.map((t=>this.#s[t-1])),this.#d({type:"copy",pageNumbers:t})}pastePages(t){this.#u(!0);const e=this.#s,i=this.#n,n=this.#h,s=new Map;let r=t;for(const t of n)s.set(++r,t);this.pagesNumber+=n.length,this.#u(!1);const a=this.#s;a.set(e.subarray(0,t),0),a.set(this.#l,t),a.set(e.subarray(t),t+n.length),this.#g(i,s),this.#p(),this.#d({type:"paste"}),this.#l=null}#g(t,e){const i=this.#r,n=this.#s,s=new Map;for(let r=0,a=this.#a;r<a;r++){const a=e?.get(r+1);if(a){i[r]=-a;continue}const o=n[r],l=s.get(o)||0;i[r]=t.get(o)?.[l],s.set(o,l+1)}}hasBeenAltered(){return null!==this.#s}getPageMappingForSaving(){const t=this.#n;let e=0;for(const i of t.values())e=Math.max(e,i.length);const i=new Array(e);for(let t=0;t<e;t++)i[t]={document:null,pageIndices:[],includePages:[]};for(const[e,n]of t)for(let t=0,s=n.length;t<s;t++)i[t].includePages.push([e-1,n[t]-1]);for(const{includePages:t,pageIndices:e}of i){t.sort(((t,e)=>t[0]-e[0]));for(let i=0,n=t.length;i<n;i++)e.push(t[i][1]),t[i]=t[i][0]}return i}getPrevPageNumber(t){return this.#r[t-1]??0}getPageNumber(t){return this.#n?this.#n.get(t)?.[0]??0:t}getPageId(t){return this.#s?.[t-1]??t}getMapping(){return this.#s.subarray(0,this.pagesNumber)}}i(4972),i(4628),i(7642),i(8004),i(3853),i(5876),i(2475),i(5024),i(1698),i(8454),i(9452),i(4979),i(3110),i(9314),i(3579),i(9112);class ee{#m=null;#f=null;#b;#v=null;#y=null;#w=null;#A=null;#x=null;static#S=null;constructor(t){this.#b=t,ee.#S||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#m=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#b._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",It,{signal:e}),t.addEventListener("pointerdown",ee.#C,{signal:e}));const i=this.#v=document.createElement("div");i.className="buttons",t.append(i);const n=this.#b.toolbarPosition;if(n){const{style:e}=t,i="ltr"===this.#b._uiManager.direction?1-n[0]:n[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#m}static#C(t){t.stopPropagation()}#E(t){this.#b._focusEventsAllowed=!1,Rt(t)}#T(t){this.#b._focusEventsAllowed=!0,Rt(t)}#_(t){const e=this.#b._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#E.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#T.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",It,{signal:e}),!0)}hide(){this.#m.classList.add("hidden"),this.#f?.hideDropdown()}show(){this.#m.classList.remove("hidden"),this.#y?.shown(),this.#w?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#b,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",ee.#S[t]),this.#_(i)&&i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#v.append(i)}get#M(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#_(e),this.#v.append(e,this.#M),this.#y=t}addComment(t,e=null){if(this.#w)return;const i=t.renderForToolbar();if(!i)return;this.#_(i);const n=this.#A=this.#M;e?(this.#v.insertBefore(i,e),this.#v.insertBefore(n,e)):this.#v.append(i,n),this.#w=t,t.toolbar=this}addColorPicker(t){if(this.#f)return;this.#f=t;const e=t.renderButton();this.#_(e),this.#v.append(e,this.#M)}async addEditSignatureButton(t){const e=this.#x=await t.renderEditButton(this.#b);this.#_(e),this.#v.append(e,this.#M)}removeButton(t){if("comment"===t)this.#w?.removeToolbarCommentButton(),this.#w=null,this.#A?.remove(),this.#A=null}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;const n=this.#v.querySelector(i);n&&"comment"===t&&this.addComment(e,n)}updateEditSignatureButton(t){this.#x&&(this.#x.title=t)}remove(){this.#m.remove(),this.#f?.destroy(),this.#f=null}}class ie{#v=null;#m=null;#k;constructor(t){this.#k=t}#D(){const t=this.#m=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#k._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",It,{signal:e});const i=this.#v=document.createElement("div");return i.className="buttons",t.append(i),this.#k.hasCommentManager()&&this.#P("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",(()=>{this.#k.commentSelection("floating_button")})),this.#P("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",(()=>{this.#k.highlightSelection("floating_button")})),t}#I(t,e){let i=0,n=0;for(const s of t){const t=s.y+s.height;if(t<i)continue;const r=s.x+(e?s.width:0);t>i?(n=r,i=t):e?r>n&&(n=r):r<n&&(n=r)}return[e?1-n:n,i]}show(t,e,i){const[n,s]=this.#I(e,i),{style:r}=this.#m||=this.#D();t.append(this.#m),r.insetInlineEnd=100*n+"%",r.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){this.#m.remove()}#P(t,e,i,n){const s=document.createElement("button");s.classList.add("basic",t),s.tabIndex=0,s.setAttribute("data-l10n-id",e);const r=document.createElement("span");s.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);const a=this.#k._signal;a instanceof AbortSignal&&!a.aborted&&(s.addEventListener("contextmenu",It,{signal:a}),s.addEventListener("click",n,{signal:a})),this.#v.append(s)}}function ne(t,e,i){for(const n of i)e.addEventListener(n,t[n].bind(t))}class se{static#R=NaN;static#B=null;static#F=NaN;static#L=null;static initializeAndAddPointerId(t){(se.#B||=new Set).add(t)}static setPointer(t,e){se.#R||=e,se.#L??=t}static setTimeStamp(t){se.#F=t}static isSamePointerId(t){return se.#R===t}static isSamePointerIdOrRemove(t){return se.#R===t||(se.#B?.delete(t),!1)}static isSamePointerType(t){return se.#L===t}static isInitializedAndDifferentPointerType(t){return null!==se.#L&&!se.isSamePointerType(t)}static isSameTimeStamp(t){return se.#F===t}static isUsingMultiplePointers(){return se.#B?.size>=1}static clearPointerType(){se.#L=null}static clearPointerIds(){se.#R=NaN,se.#B=null}static clearTimeStamp(){se.#F=NaN}}class re{#O=0;get id(){return`${m}${this.#O++}`}}class ae{#N=pt();#O=0;#U=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;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>';return Q(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#z(t,e){this.#U||=new Map;let i=this.#U.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.#N}_${this.#O++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await St(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=ae._isSVGFittingCanvas,n=new FileReader,s=new Image,r=new Promise(((t,r)=>{s.onload=()=>{i.bitmap=s,i.isSvg=!0,t()},n.onload=async()=>{const t=i.svgUrl=n.result;s.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},s.onerror=n.onerror=r}));n.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){W(t),i=null}return this.#U.set(t,i),i&&this.#U.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:n,type:s}=t;return this.#z(`${e}_${i}_${n}_${s}`,t)}async getFromUrl(t){return this.#z(t,t)}async getFromBlob(t,e){const i=await e;return this.#z(t,i)}async getFromId(t){this.#U||=new Map;const e=this.#U.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){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#U||=new Map;let i=this.#U.get(t);if(i?.bitmap)return i.refCounter+=1,i;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),i={bitmap:n.transferToImageBitmap(),id:`image_${this.#N}_${this.#O++}`,refCounter:1,isSvg:!1},this.#U.set(t,i),this.#U.set(i.id,i),i}getSvgUrl(t){const e=this.#U.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#U||=new Map;const e=this.#U.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const 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.#N}_`)}}class oe{#H=[];#j=!1;#G;#$=-1;constructor(t=128){this.#G=t}add({cmd:t,undo:e,post:i,mustExec:n,type:s=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(n&&t(),this.#j)return;const o={cmd:t,undo:e,post:i,type:s};if(-1===this.#$)return this.#H.length>0&&(this.#H.length=0),this.#$=0,void this.#H.push(o);if(r&&this.#H[this.#$].type===s)return a&&(o.undo=this.#H[this.#$].undo),void(this.#H[this.#$]=o);const l=this.#$+1;l===this.#G?this.#H.splice(0,1):(this.#$=l,l<this.#H.length&&this.#H.splice(l)),this.#H.push(o)}undo(){if(-1===this.#$)return;this.#j=!0;const{undo:t,post:e}=this.#H[this.#$];t(),e?.(),this.#j=!1,this.#$-=1}redo(){if(this.#$<this.#H.length-1){this.#$+=1,this.#j=!0;const{cmd:t,post:e}=this.#H[this.#$];t(),e?.(),this.#j=!1}}hasSomethingToUndo(){return-1!==this.#$}hasSomethingToRedo(){return this.#$<this.#H.length-1}cleanType(t){if(-1!==this.#$){for(let e=this.#$;e>=0;e--)if(this.#H[e].type!==t)return this.#H.splice(e+1,this.#$-e),void(this.#$=e);this.#H.length=0,this.#$=-1}}destroy(){this.#H=null}}class le{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ot.platform;for(const[i,n,s={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:n,options:s}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:n,options:s}),this.allKeys.add(t.split("+").at(-1)))}}#V(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);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#V(e));if(!i)return;const{callback:n,options:{bubbles:s=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(n.bind(t,...r,e)(),s||Rt(e))}}class he{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const n=window.getComputedStyle(e).color;t.set(i,Ot(n))}e.remove()}(t),Q(this,"_colors",t)}convert(t){const e=Ot(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return he._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?ht.makeHexColor(...e):t}}class ce{#W=new AbortController;#X=null;#q=null;#K=new Map;#Y=new Map;#J=null;#Q=null;#Z=null;#tt=new oe;#et=null;#it=null;#nt=null;#st=0;#rt=new Set;#at=null;#ot=null;#lt=new Set;_editorUndoBar=null;#ht=!1;#ct=!1;#dt=!1;#ut=null;#pt=null;#gt=null;#mt=null;#ft=!1;#bt=null;#vt=new re;#yt=!1;#wt=!1;#At=!1;#xt=null;#St=null;#Ct=null;#Et=null;#Tt=null;#_t=f.NONE;#Mt=new Set;#kt=null;#Dt=null;#Pt=null;#It=null;#Rt=null;#Bt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#Ft=[0,0];#Lt=null;#Ot=null;#Nt=null;#Ut=null;#zt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=ce.prototype,e=t=>t.#Ot.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,s=this.TRANSLATE_BIG;return Q(this,"_keyboardManager",new le([[["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.#Ot.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Ot.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}]]))}constructor(t,e,i,n,s,r,a,o,l,h,c,d,u,p,g,m){const f=this._signal=this.#W.signal;this.#Ot=t,this.#Nt=e,this.#Ut=i,this.#J=n,this.#et=s,this.#Dt=r,this.#Rt=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:f}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),a._on("setpreference",this.onSetPreference.bind(this),{signal:f}),a._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:f}),window.addEventListener("pointerdown",(()=>{this.#wt=!0}),{capture:!0,signal:f}),window.addEventListener("pointerup",(()=>{this.#wt=!1}),{capture:!0,signal:f}),window.addEventListener("beforeunload",this.#Ht.bind(this),{capture:!0,signal:f}),this.#jt(),this.#Gt(),this.#$t(),this.#Q=o.annotationStorage,this.#ut=o.filterFactory,this.#Pt=l,this.#mt=h||null,this.#ht=c,this.#ct=d,this.#dt=u,this.#Tt=p||null,this.viewParameters={realScale:xt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,s?.setSidebarUiManager(this)}destroy(){this.#zt?.resolve(),this.#zt=null,this.#W?.abort(),this.#W=null,this._signal=null;for(const t of this.#Y.values())t.destroy();this.#Y.clear(),this.#K.clear(),this.#lt.clear(),this.#Et?.clear(),this.#X=null,this.#Mt.clear(),this.#tt.destroy(),this.#J?.destroy(),this.#et?.destroy(),this.#Dt?.destroy(),this.#bt?.hide(),this.#bt=null,this.#Ct?.destroy(),this.#Ct=null,this.#q=null,this.#pt&&(clearTimeout(this.#pt),this.#pt=null),this.#Lt&&(clearTimeout(this.#Lt),this.#Lt=null),this._editorUndoBar?.destroy(),this.#Rt=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#Tt}get useNewAltTextFlow(){return this.#ct}get useNewAltTextWhenAddingImage(){return this.#dt}get hcmFilter(){return Q(this,"hcmFilter",this.#Pt?this.#ut.addHCMFilter(this.#Pt.foreground,this.#Pt.background):"none")}get direction(){return Q(this,"direction",getComputedStyle(this.#Ot).direction)}get _highlightColors(){return Q(this,"_highlightColors",this.#mt?new Map(this.#mt.split(",").map((t=>((t=t.split("=").map((t=>t.trim())))[1]=t[1].toUpperCase(),t)))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return Q(this,"highlightColors",null);const e=new Map,i=!!this.#Pt;for(const[n,s]of t){const t=n.endsWith("_HCM");i&&t?e.set(n.replace("_HCM",""),s):i||t||e.set(n,s)}return Q(this,"highlightColors",e)}get highlightColorNames(){return Q(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#nt=t}setMainHighlightColorPicker(t){this.#Ct=t}editAltText(t,e=!1){this.#J?.editAltText(this,t,e)}hasCommentManager(){return!!this.#et}editComment(t,e,i,n){this.#et?.showDialog(this,t,e,i,n)}selectComment(t,e){const i=this.#Y.get(t)?.getEditorByUID(e);i?.toggleComment(!0,!0)}updateComment(t){this.#et?.updateComment(t.getData())}updatePopupColor(t){this.#et?.updatePopupColor(t)}removeComment(t){this.#et?.removeComments([t.uid])}deleteComment(t,e){const i=()=>{t.comment=e};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null},undo:i,mustExec:!0})}toggleComment(t,e,i){this.#et?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#et?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#et?.dialogElement||null}async waitForEditorsRendered(t){if(this.#Y.has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),n=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n),await i}getSignature(t){this.#Dt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#Dt}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}){if("enableNewAltTextWhenAddingImage"===t)this.#dt=e}onPageChanging({pageNumber:t}){this.#st=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#Y.delete(t),this.#st===t&&(this.#st=0)}focusMainContainer(){this.#Ot.focus()}findParent(t,e){for(const i of this.#Y.values()){const{x:n,y:s,width:r,height:a}=i.div.getBoundingClientRect();if(t>=n&&t<=n+r&&e>=s&&e<=s+a)return i}return null}disableUserSelect(t=!1){this.#Nt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#lt.add(t)}removeShouldRescale(t){this.#lt.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*xt.PDF_TO_CSS_UNITS;for(const t of this.#lt)t.onScaleChanging();this.#nt?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Vt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Wt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#Y.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:a}=i,o=i.toString(),l=this.#Vt(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();const c=this.#Wt(l),d=this.#_t===f.NONE,u=()=>{const i=c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:a,text:o});d&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};d?this.switchToMode(f.HIGHLIGHT,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}#Ht(t){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#Xt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#Vt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#bt||=new ie(this),this.#bt.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#Q)return null;const e=`${m}${t}`,i=this.#Q.getRawValue(e);return i&&this.#Q.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#Q||this.#Q.has(t.id)||this.#Q.setValue(t.id,t)}a11yAlert(t,e=null){const i=this.#Ut;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#qt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#kt&&(this.#bt?.hide(),this.#kt=null,this.#Kt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#kt)return;const i=this.#Vt(t).closest(".textLayer");if(i){if(this.#bt?.hide(),this.#kt=e,this.#Kt({hasSelectedText:!0}),(this.#_t===f.HIGHLIGHT||this.#_t===f.NONE)&&(this.#_t===f.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#ft=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#_t===f.HIGHLIGHT?this.#Wt(i):null;if(t?.toggleDrawing(),this.#wt){const e=new AbortController,i=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#Yt("main_toolbar"))};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})}else t?.toggleDrawing(!0),this.#Yt("main_toolbar")}}else this.#kt&&(this.#bt?.hide(),this.#kt=null,this.#Kt({hasSelectedText:!1}))}#Yt(t=""){this.#_t===f.HIGHLIGHT?this.highlightSelection(t):this.#ht&&this.#Xt()}#jt(){document.addEventListener("selectionchange",this.#qt.bind(this),{signal:this._signal})}#Jt(){if(this.#gt)return;this.#gt=new AbortController;const t=this.combinedSignal(this.#gt);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Qt(){this.#gt?.abort(),this.#gt=null}blur(){if(this.isShiftKeyDown=!1,this.#ft&&(this.#ft=!1,this.#Yt("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#Mt)if(e.div.contains(t)){this.#St=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#St)return;const[t,e]=this.#St;this.#St=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#$t(){if(this.#xt)return;this.#xt=new AbortController;const t=this.combinedSignal(this.#xt);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Zt(){this.#xt?.abort(),this.#xt=null}#te(){if(this.#it)return;this.#it=new AbortController;const t=this.combinedSignal(this.#it);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})}#ee(){this.#it?.abort(),this.#it=null}#Gt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#$t(),this.setEditingState(!0)}removeEditListeners(){this.#Zt(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#ot)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#ot)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#X?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#Mt){const 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();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#ot)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void W(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const n=this.currentLayer;try{const t=[];for(const e of i){const i=await n.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#ie(e);this.#ne(t)},s=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:s,mustExec:!0})}catch(t){W(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#_t===f.NONE||this.isEditorHandlingKeyboard||ce._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#ft&&(this.#ft=!1,this.#Yt("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}#Kt(t){Object.entries(t).some((([t,e])=>this.#Bt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Bt,t)}),this.#_t===f.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#se([[b.HIGHLIGHT_FREE,!0]]))}#se(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Jt(),this.#te(),this.#Kt({isEditing:this.#_t!==f.NONE,isEmpty:this.#re(),hasSomethingToUndo:this.#tt.hasSomethingToUndo(),hasSomethingToRedo:this.#tt.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Qt(),this.#ee(),this.#Kt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#ot){this.#ot=t;for(const t of this.#ot)this.#se(t.defaultPropertiesToUpdate)}}getId(){return this.#vt.id}get currentLayer(){return this.#Y.get(this.#st)}getLayer(t){return this.#Y.get(t)}get currentPageIndex(){return this.#st}addLayer(t){this.#Y.set(t.pageIndex,t),this.#yt?t.enable():t.disable()}removeLayer(t){this.#Y.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,n=!1,s=!1,r=!1){if(this.#_t!==t&&(!this.#zt||(await this.#zt.promise,this.#zt))){if(this.#zt=Promise.withResolvers(),this.#nt?.commitOrRemove(),this.#_t===f.POPUP&&this.#et?.hideSidebar(),this.#et?.destroyPopup(),this.#_t=t,t===f.NONE){this.setEditingState(!1),this.#ae();for(const t of this.#K.values())t.hideStandaloneCommentButton();return this._editorUndoBar?.hide(),this.toggleComment(null),void this.#zt.resolve()}for(const t of this.#K.values())t.addStandaloneCommentButton();t===f.SIGNATURE&&await(this.#Dt?.loadSignatures()),i&&se.clearPointerType(),this.setEditingState(!0),await this.#oe(),this.unselectAll();for(const e of this.#Y.values())e.updateMode(t);if(t===f.POPUP){this.#q||=await this.#Rt.getAnnotationsByType(new Set(this.#ot.map((t=>t._editorType))));const t=new Set,e=[];for(const i of this.#K.values()){const{annotationElementId:n,hasComment:s,deleted:r}=i;n&&t.add(n),s&&!r&&e.push(i.getData())}for(const i of this.#q){const{id:n,popupRef:s,contentsObj:r}=i;s&&r?.str&&!t.has(n)&&!this.#rt.has(n)&&e.push(i)}this.#et?.showSidebar(e)}if(!e)return n&&this.addNewEditorFromKeyboard(),void this.#zt.resolve();for(const t of this.#K.values())t.uid===e?(this.setSelected(t),r?t.editComment():s?t.enterInEditMode():t.focus()):t.unselect();this.#zt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#_t&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#ot){switch(t){case b.CREATE:return void this.currentLayer.addNewEditor(e);case b.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#It||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const i of this.#Mt)i.updateParams(t,e);else for(const i of this.#ot)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#K.values())i.editorType===t&&i.show(e);(this.#It?.get(b.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#se([[b.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#At!==t){this.#At=t;for(const e of this.#Y.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#oe(){if(!this.#yt){this.#yt=!0;const t=[];for(const e of this.#Y.values())t.push(e.enable());await Promise.all(t);for(const t of this.#K.values())t.enable()}}#ae(){if(this.unselectAll(),this.#yt){this.#yt=!1;for(const t of this.#Y.values())t.disable();for(const t of this.#K.values())t.disable()}}*getEditors(t){for(const e of this.#K.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#K.get(t)}addEditor(t){this.#K.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#pt&&clearTimeout(this.#pt),this.#pt=setTimeout((()=>{this.focusMainContainer(),this.#pt=null}),0)),this.#K.delete(t.id),t.annotationElementId&&this.#Et?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#rt.has(t.annotationElementId)||this.#Q?.remove(t.id)}addDeletedAnnotationElement(t){this.#rt.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#rt.has(t)}removeDeletedAnnotationElement(t){this.#rt.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#ie(t){const e=this.#Y.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#X!==t&&(this.#X=t,t&&this.#se(t.propertiesToUpdate))}get#le(){let t=null;for(t of this.#Mt);return t}updateUI(t){this.#le===t&&this.#se(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#se(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#Mt.has(t))return this.#Mt.delete(t),t.unselect(),void this.#Kt({hasSelectedEditor:this.hasSelection});this.#Mt.add(t),t.select(),this.#se(t.propertiesToUpdate),this.#Kt({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#nt?.commitOrRemove();for(const e of this.#Mt)e!==t&&e.unselect();this.#Mt.clear(),this.#Mt.add(t),t.select(),this.#se(t.propertiesToUpdate),this.#Kt({hasSelectedEditor:!0})}isSelected(t){return this.#Mt.has(t)}get firstSelectedEditor(){return this.#Mt.values().next().value}unselect(t){t.unselect(),this.#Mt.delete(t),this.#Kt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#Mt.size}get isEnterHandled(){return 1===this.#Mt.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#tt.undo(),this.#Kt({hasSomethingToUndo:this.#tt.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#re()}),this._editorUndoBar?.hide()}redo(){this.#tt.redo(),this.#Kt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#tt.hasSomethingToRedo(),isEmpty:this.#re()})}addCommands(t){this.#tt.add(t),this.#Kt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#re()})}cleanUndoStack(t){this.#tt.cleanType(t)}#re(){if(0===this.#K.size)return!0;if(1===this.#K.size)for(const t of this.#K.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#Mt],i=()=>{for(const t of e)this.#ie(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#X?.commitOrRemove()}hasSomethingToControl(){return this.#X||this.hasSelection}#ne(t){for(const t of this.#Mt)t.unselect();this.#Mt.clear();for(const e of t)e.isEmpty()||(this.#Mt.add(e),e.select());this.#Kt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#Mt)t.commit();this.#ne(this.#K.values())}unselectAll(){if((!this.#X||(this.#X.commitOrRemove(),this.#_t===f.NONE))&&!this.#nt?.commitOrRemove()&&this.hasSelection){for(const t of this.#Mt)t.unselect();this.#Mt.clear(),this.#Kt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#Ft[0]+=t,this.#Ft[1]+=e;const[n,s]=this.#Ft,r=[...this.#Mt];this.#Lt&&clearTimeout(this.#Lt),this.#Lt=setTimeout((()=>{this.#Lt=null,this.#Ft[0]=this.#Ft[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#K.has(t.id)&&(t.translateInPage(n,s),t.translationDone())},undo:()=>{for(const t of r)this.#K.has(t.id)&&(t.translateInPage(-n,-s),t.translationDone())},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#at=new Map;for(const t of this.#Mt)this.#at.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#at)return!1;this.disableUserSelect(!1);const t=this.#at;this.#at=null;let e=!1;for(const[{x:i,y:n,pageIndex:s},r]of t)r.newX=i,r.newY=n,r.newPageIndex=s,e||=i!==r.savedX||n!==r.savedY||s!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,n)=>{if(this.#K.has(t.id)){const s=this.#Y.get(n);s?t._setParentAndPosition(s,e,i):(t.pageIndex=n,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:n,newY:s,newPageIndex:r}]of t)i(e,n,s,r)},undo:()=>{for(const[e,{savedX:n,savedY:s,savedPageIndex:r}]of t)i(e,n,s,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#at)for(const i of this.#at.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const 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.#Mt.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#X===t}getActive(){return this.#X}getMode(){return this.#_t}isEditingMode(){return this.#_t!==f.NONE}get imageManager(){return Q(this,"imageManager",new ae)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,n=e.rangeCount;i<n;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:n,width:s,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-n)/r,y:1-(t+a-i)/s,width:o/r,height:a/s});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/s,y:1-(e+o-n)/r,width:a/s,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-n)/r,y:(t-i)/s,width:o/r,height:a/s});break;default:a=(t,e,a,o)=>({x:(t-i)/s,y:(e-n)/r,width:a/s,height:o/r})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:n,height:s}of i.getClientRects())0!==n&&0!==s&&o.push(a(t,e,n,s))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#Z||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#Z?.delete(t)}renderAnnotationElement(t){const e=this.#Z?.get(t.data.id);if(!e)return;const i=this.#Q.getRawValue(e);i&&(this.#_t!==f.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const n=this.#Et?.get(t);n&&(n.setCanvas(e,i),this.#Et.delete(t))}addMissingCanvas(t,e){(this.#Et||=new Map).set(t,e)}}class de{#y=null;#he=!1;#ce=null;#de=null;#ue=null;#pe=null;#ge=!1;#me=null;#b=null;#fe=null;#be=null;#ve=!1;static#ye=null;static _l10n=null;constructor(t){this.#b=t,this.#ve=t._uiManager.useNewAltTextFlow,de.#ye||=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){de._l10n??=t}async render(){const t=this.#ce=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#de=document.createElement("span");t.append(e),this.#ve?(t.classList.add("new"),t.setAttribute("data-l10n-id",de.#ye.missing),e.setAttribute("data-l10n-id",de.#ye["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#b._uiManager._signal;t.addEventListener("contextmenu",It,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const n=t=>{t.preventDefault(),this.#b._uiManager.editAltText(this.#b),this.#ve&&this.#b._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#we}})};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#ge=!0,n(e))}),{signal:i}),await this.#Ae(),t}get#we(){return(this.#y?"added":null===this.#y&&this.guessedText&&"review")||"missing"}finish(){this.#ce&&(this.#ce.focus({focusVisible:this.#ge}),this.#ge=!1)}isEmpty(){return this.#ve?null===this.#y:!this.#y&&!this.#he}hasData(){return this.#ve?null!==this.#y||!!this.#fe:this.isEmpty()}get guessedText(){return this.#fe}async setGuessedText(t){null===this.#y&&(this.#fe=t,this.#be=await de._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Ae())}toggleAltTextBadge(t=!1){if(!this.#ve||this.#y)return this.#me?.remove(),void(this.#me=null);if(!this.#me){const t=this.#me=document.createElement("div");t.className="noAltTextBadge",this.#b.div.append(t)}this.#me.classList.toggle("hidden",!t)}serialize(t){let e=this.#y;return t||this.#fe!==e||(e=this.#be),{altText:e,decorative:this.#he,guessedText:this.#fe,textWithDisclaimer:this.#be}}get data(){return{altText:this.#y,decorative:this.#he}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:n,cancel:s=!1}){i&&(this.#fe=i,this.#be=n),this.#y===t&&this.#he===e||(s||(this.#y=t,this.#he=e),this.#Ae())}toggle(t=!1){this.#ce&&(!t&&this.#pe&&(clearTimeout(this.#pe),this.#pe=null),this.#ce.disabled=!t)}shown(){this.#b._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#we}})}destroy(){this.#ce?.remove(),this.#ce=null,this.#de=null,this.#ue=null,this.#me?.remove(),this.#me=null}async#Ae(){const t=this.#ce;if(!t)return;if(this.#ve){if(t.classList.toggle("done",!!this.#y),t.setAttribute("data-l10n-id",de.#ye[this.#we]),this.#de?.setAttribute("data-l10n-id",de.#ye[`${this.#we}-label`]),!this.#y)return void this.#ue?.remove()}else{if(!this.#y&&!this.#he)return t.classList.remove("done"),void this.#ue?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#ue;if(!e){this.#ue=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#b.id}`;const i=100,n=this.#b._uiManager._signal;n.addEventListener("abort",(()=>{clearTimeout(this.#pe),this.#pe=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#pe=setTimeout((()=>{this.#pe=null,this.#ue.classList.add("show"),this.#b._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:n}),t.addEventListener("mouseleave",(()=>{this.#pe&&(clearTimeout(this.#pe),this.#pe=null),this.#ue?.classList.remove("show")}),{signal:n})}this.#he?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#y),e.parentNode||t.append(e);this.#b.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class ue{#xe=null;#Se=null;#Ce=!1;#b=null;#Ee=null;#Te=null;#_e=null;#Me=null;#ke=!1;#De=null;constructor(t){this.#b=t}renderForToolbar(){const t=this.#Se=document.createElement("button");return t.className="comment",this.#D(t,!1)}renderForStandalone(){const t=this.#xe=document.createElement("button");t.className="annotationCommentButton";const e=this.#b.commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#b._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=this.#b.commentButtonColor;n&&(i.backgroundColor=n)}return this.#D(t,!0)}focusButton(){setTimeout((()=>{(this.#xe??this.#Se)?.focus()}),0)}onUpdatedColor(){if(!this.#xe)return;const t=this.#b.commentButtonColor;t&&(this.#xe.style.backgroundColor=t),this.#b._uiManager.updatePopupColor(this.#b)}get commentButtonWidth(){return(this.#xe?.getBoundingClientRect().width??0)/this.#b.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#De)return this.#De;if(!this.#xe)return null;const{x:t,y:e,height:i}=this.#xe.getBoundingClientRect(),{x:n,y:s,width:r,height:a}=this.#b.parent.boundingClientRect;return[(t-n)/r,(e+i-s)/a]}set commentPopupPositionInLayer(t){this.#De=t}hasDefaultPopupPosition(){return null===this.#De}removeStandaloneCommentButton(){this.#xe?.remove(),this.#xe=null}removeToolbarCommentButton(){this.#Se?.remove(),this.#Se=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#xe&&(this.#xe.classList.toggle("selected",t),this.#xe.ariaExpanded=e)}#D(t,e){if(!this.#b._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#b._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const i=this.#b._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",It,{signal:i}),e&&(t.addEventListener("focusin",(t=>{this.#b._focusEventsAllowed=!1,Rt(t)}),{capture:!0,signal:i}),t.addEventListener("focusout",(t=>{this.#b._focusEventsAllowed=!0,Rt(t)}),{capture:!0,signal:i})),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const n=e=>{e.preventDefault(),t===this.#Se?this.edit():this.#b.toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#Ce=!0,n(e))}),{signal:i}),t.addEventListener("pointerenter",(()=>{this.#b.toggleComment(!1,!0)}),{signal:i}),t.addEventListener("pointerleave",(()=>{this.#b.toggleComment(!1,!1)}),{signal:i}),t}edit(t){const e=this.commentPopupPositionInLayer;let i,n;if(e)[i,n]=e;else{[i,n]=this.#b.commentButtonPosition;const{width:t,height:e,x:s,y:r}=this.#b;i=s+i*t,n=r+n*e}const s=this.#b.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=s;this.#b._uiManager.editComment(this.#b,r+i*o,a+n*l,{...t,parentDimensions:s})}finish(){this.#Se&&(this.#Se.focus({focusVisible:this.#Ce}),this.#Ce=!1)}isDeleted(){return this.#ke||""===this.#_e}isEmpty(){return null===this.#_e}hasBeenEdited(){return this.isDeleted()||this.#_e!==this.#Ee}serialize(){return this.data}get data(){return{text:this.#_e,richText:this.#Te,date:this.#Me,deleted:this.isDeleted()}}set data(t){if(t!==this.#_e&&(this.#Te=null),null===t)return this.#_e="",void(this.#ke=!0);this.#_e=t,this.#Me=new Date,this.#ke=!1}restoreData({text:t,richText:e,date:i}){this.#_e=t,this.#Te=e,this.#Me=i,this.#ke=!1}setInitialText(t,e=null){this.#Ee=t,this.data=t,this.#Me=null,this.#Te=e}shown(){}destroy(){this.#Se?.remove(),this.#Se=null,this.#xe?.remove(),this.#xe=null,this.#_e="",this.#Te=null,this.#Me=null,this.#b=null,this.#Ce=!1,this.#ke=!1}}class pe{#Ot;#Pe=!1;#Ie=null;#Re;#Be;#Fe;#Le;#Oe=null;#Ne;#Ue=null;#ze;#He=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:n=null,onPinching:s=null,onPinchEnd:r=null,signal:a}){this.#Ot=t,this.#Ie=i,this.#Re=e,this.#Be=n,this.#Fe=s,this.#Le=r,this.#ze=new AbortController,this.#Ne=AbortSignal.any([a,this.#ze.signal]),t.addEventListener("touchstart",this.#je.bind(this),{passive:!1,signal:this.#Ne})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ht.pixelRatio}#je(t){if(this.#Re?.())return;if(1===t.touches.length){if(this.#Oe)return;const t=this.#Oe=new AbortController,e=AbortSignal.any([this.#Ne,t.signal]),i=this.#Ot,n={capture:!0,signal:e,passive:!1},s=t=>{"touch"===t.pointerType&&(this.#Oe?.abort(),this.#Oe=null)};return i.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(Rt(t),s(t))}),n),i.addEventListener("pointerup",s,n),void i.addEventListener("pointercancel",s,n)}if(!this.#He){this.#He=new AbortController;const t=AbortSignal.any([this.#Ne,this.#He.signal]),e=this.#Ot,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#Ge.bind(this),i);const n=this.#$e.bind(this);e.addEventListener("touchend",n,i),e.addEventListener("touchcancel",n,i),i.capture=!0,e.addEventListener("pointerdown",Rt,i),e.addEventListener("pointermove",Rt,i),e.addEventListener("pointercancel",Rt,i),e.addEventListener("pointerup",Rt,i),this.#Be?.()}if(Rt(t),2!==t.touches.length||this.#Ie?.())return void(this.#Ue=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#Ue={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#Ge(t){if(!this.#Ue||2!==t.touches.length)return;Rt(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:n,screenY:s}=e,{screenX:r,screenY:a}=i,o=this.#Ue,{touch0X:l,touch0Y:h,touch1X:c,touch1Y:d}=o,u=c-l,p=d-h,g=r-n,m=a-s,f=Math.hypot(g,m)||1,b=Math.hypot(u,p)||1;if(!this.#Pe&&Math.abs(b-f)<=pe.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=n,o.touch0Y=s,o.touch1X=r,o.touch1Y=a,!this.#Pe)return void(this.#Pe=!0);const v=[(n+r)/2,(s+a)/2];this.#Fe?.(v,b,f)}#$e(t){t.touches.length>=2||(this.#He&&(this.#He.abort(),this.#He=null,this.#Le?.()),this.#Ue&&(Rt(t),this.#Ue=null,this.#Pe=!1))}destroy(){this.#ze?.abort(),this.#ze=null,this.#Oe?.abort(),this.#Oe=null}}class ge{#Ve=null;#We=null;#y=null;#w=null;#xe=null;#Xe=!1;#qe=null;#Ke="";#Ye=null;#Je=null;#Qe=null;#Ze=null;#ti=null;#ei="";#ii=!1;#ni=null;#si=!1;#ri=!1;#ai=!1;#oi=null;#li=0;#hi=0;#ci=null;#di=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ui=!1;#pi=ge._zIndex++;static _borderLineWidth=-1;static _colorManager=new he;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ge.prototype._resizeWithKeyboard,e=ce.TRANSLATE_SMALL,i=ce.TRANSLATE_BIG;return Q(this,"_resizerKeyboardManager",new le([[["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"],ge.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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:n,pageX:s,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[s,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return Q(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new me({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(ge._l10n??=t,ge._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!==ge._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ge._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){X("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ui}set _isDraggable(t){this.#ui=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[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}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#pi}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#gi(),this.#Ze?.remove(),this.#Ze=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ii?this.#ii=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,n){const[s,r]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(t+i)/s,this.y=(e+n)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,n]=this.parentDimensions;this.setAt(t*i,e*n,this.width*i,this.height*n),this._onTranslated()}#mi([t,e],i,n){[i,n]=this.screenToPageTranslation(i,n),this.x+=i/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#mi(this.parentDimensions,t,e)}translateInPage(t,e){this.#ni||=[this.x,this.y,this.width,this.height],this.#mi(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#ni||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[n,s]}=this;if(this.x+=t/n,this.y+=e/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{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:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#ni&&(this.#ni[0]!==this.x||this.#ni[1]!==this.y)}get _hasBeenResized(){return!!this.#ni&&(this.#ni[2]!==this.width||this.#ni[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ge,n=i/t,s=i/e;switch(this.rotation){case 90:return[-n,s];case 180:return[n,s];case 270:return[n,-s];default:return[-n,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,n]}=this;let{x:s,y:r,width:a,height:o}=this;if(a*=i,o*=n,s*=i,r*=n,this._mustFixPosition)switch(t){case 0:s=vt(s,0,i-a),r=vt(r,0,n-o);break;case 90:s=vt(s,0,i-o),r=vt(r,a,n);break;case 180:s=vt(s,a,i),r=vt(r,o,n);break;case 270:s=vt(s,o,i),r=vt(r,0,n-a)}this.x=s/=i,this.y=r/=n;const[l,h]=this.getBaseTranslation();s+=l,r+=h,e.left=`${(100*s).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#fi(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 ge.#fi(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ge.#fi(t,e,360-this.parentRotation)}#bi(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[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(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#vi(){if(this.#Ye)return;this.#Ye=document.createElement("div"),this.#Ye.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#Ye.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#yi.bind(this,i),{signal:e}),t.addEventListener("contextmenu",It,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Ye)}#yi(t,e){e.preventDefault();const{isMac:i}=ot.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#y?.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,this.#Je=[e.screenX,e.screenY];const s=new AbortController,r=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#wi.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Rt,{passive:!1,signal:r}),window.addEventListener("contextmenu",It,{signal:r}),this.#Qe={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const 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;const l=()=>{s.abort(),this.parent.togglePointerEvents(!0),this.#y?.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#Ai()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#xi(t,e,i,n){this.width=i,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#Ai(){if(!this.#Qe)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:n}=this.#Qe;this.#Qe=null;const s=this.x,r=this.y,a=this.width,o=this.height;s===t&&r===e&&a===i&&o===n||this.addCommands({cmd:this.#xi.bind(this,s,r,a,o),undo:this.#xi.bind(this,t,e,i,n),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#wi(t,e){const[i,n]=this.parentDimensions,s=this.x,r=this.y,a=this.width,o=this.height,l=ge.MIN_SIZE/i,h=ge.MIN_SIZE/n,c=this.#bi(this.rotation),d=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=this.#bi(360-this.rotation);let p,g,m=!1,f=!1;switch(t){case"topLeft":m=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":m=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":f=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":m=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":m=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":f=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(a,o),v=g(a,o);let y=d(...v);const w=ge._round(s+y[0]),A=ge._round(r+y[1]);let x,S,C=1,E=1;if(e.fromKeyboard)({deltaX:x,deltaY:S}=e);else{const{screenX:t,screenY:i}=e,[n,s]=this.#Je;[x,S]=this.screenToPageTranslation(t-n,i-s),this.#Je[0]=t,this.#Je[1]=i}var T,_;if([x,S]=(T=x/i,_=S/n,[u[0]*T+u[2]*_,u[1]*T+u[3]*_]),m){const t=Math.hypot(a,o);C=E=Math.max(Math.min(Math.hypot(v[0]-b[0]-x,v[1]-b[1]-S)/t,1/a,1/o),l/a,h/o)}else f?C=vt(Math.abs(v[0]-b[0]-x),l,1)/a:E=vt(Math.abs(v[1]-b[1]-S),h,1)/o;const M=ge._round(a*C),k=ge._round(o*E);y=d(...g(M,k));const D=w-y[0],P=A-y[1];this.#ni||=[this.x,this.y,this.width,this.height],this.width=M,this.height=k,this.x=D,this.y=P,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#y?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#ri)return this._editToolbar;this._editToolbar=new ee(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#y?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#y||(de.initialize(ge._l10n),this.#y=new de(this),this.#Ve&&(this.#y.data=this.#Ve,this.#Ve=null)),this.#y}get altTextData(){return this.#y?.data}set altTextData(t){this.#y&&(this.#y.data=t)}get guessedAltText(){return this.#y?.guessedText}async setGuessedAltText(t){await(this.#y?.setGuessedText(t))}serializeAltText(t){return this.#y?.serialize(t)}hasAltText(){return!!this.#y&&!this.#y.isEmpty()}hasAltTextData(){return this.#y?.hasData()??!1}focusCommentButton(){this.#w?.focusButton()}addCommentButton(){return this.canAddComment?this.#w||=new ue(this):null}addStandaloneCommentButton(){this._uiManager.hasCommentManager()&&(this.#xe?this._uiManager.isEditingMode()&&this.#xe.classList.remove("hidden"):this.hasComment&&(this.#xe=this.#w.renderForStandalone(),this.div.append(this.#xe)))}removeStandaloneCommentButton(){this.#w.removeStandaloneCommentButton(),this.#xe=null}hideStandaloneCommentButton(){this.#xe?.classList.add("hidden")}get comment(){if(!this.#w)return null;const{data:{richText:t,text:e,date:i,deleted:n}}=this.#w;return{text:e,richText:t,date:i,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#w||=new ue(this),"object"==typeof t&&null!==t?this.#w.restoreData(t):this.#w.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e)return;if(this.#w||=new ue(this),this.#w.setInitialText(t,i),!this.annotationElementId)return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){return this.#w?.hasBeenEdited()}get hasDeletedComment(){return this.#w?.isDeleted()}get hasComment(){return!!this.#w&&!this.#w.isEmpty()&&!this.#w.isDeleted()}async editComment(t){this.#w||=new ue(this),this.#w.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#w.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const e=180,i=100,[,,,n]=t.rect,[s]=this.pageDimensions,[r]=this.pageTranslation,a=r+s+1,o=n-i,l=a+e;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#w.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#Xe?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#Si();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[n,s]=this.getInitialTranslation();return this.translate(n,s),ne(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#di||=new pe({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Ci.bind(this),onPinching:this.#Ei.bind(this),onPinchEnd:this.#Ti.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#Ci(){this.#Qe={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#y?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ei(t,e,i){let n=i/e*.7+1-.7;if(1===n)return;const s=this.#bi(this.rotation),r=(t,e)=>[s[0]*t+s[2]*e,s[1]*t+s[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,d=this.height,u=ge.MIN_SIZE/a,p=ge.MIN_SIZE/o;n=Math.max(Math.min(n,1/c,1/d),u/c,p/d);const g=ge._round(c*n),m=ge._round(d*n);if(g===c&&m===d)return;this.#ni||=[l,h,c,d];const f=r(c/2,d/2),b=ge._round(l+f[0]),v=ge._round(h+f[1]),y=r(g/2,m/2);this.x=b-y[0],this.y=v-y[1],this.width=g,this.height=m,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#Ti(){this.#y?.toggle(!0),this.parent.togglePointerEvents(!0),this.#Ai()}pointerdown(t){const{isMac:e}=ot.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ii=!0,this._isDraggable?this.#_i(t):this.#Mi(t))}#Mi(t){const{isMac:e}=ot.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#_i(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const n=new AbortController,s=this._uiManager.combinedSignal(n),r={capture:!0,passive:!1,signal:s},a=t=>{n.abort(),this.#qe=null,this.#ii=!1,this._uiManager.endDragSession()||this.#Mi(t),i&&this._onStopDragging()};e&&(this.#li=t.clientX,this.#hi=t.clientY,this.#qe=t.pointerId,this.#Ke=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:e,clientY:n,pointerId:s}=t;if(s!==this.#qe)return void Rt(t);const[r,a]=this.screenToPageTranslation(e-this.#li,n-this.#hi);this.#li=e,this.#hi=n,this._uiManager.dragSelectedEditors(r,a)}),r),window.addEventListener("touchmove",Rt,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#Ke&&(this.#di||t.isPrimary)&&a(t),Rt(t)}),r));const o=t=>{this.#qe&&this.#qe!==t.pointerId?Rt(t):a(t)};window.addEventListener("pointerup",o,{signal:s}),window.addEventListener("blur",o,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#oi&&clearTimeout(this.#oi),this.#oi=setTimeout((()=>{this.#oi=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const n=this.parentScale,[s,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/n,h=e/n,c=this.x*s,d=this.y*r,u=this.width*s,p=this.height*r;switch(i){case 0:return[c+l+a,r-d-h-p+o,c+l+u+a,r-d-h+o];case 90:return[c+h+a,r-d+l+o,c+h+p+a,r-d+l+u+o];case 180:return[c-l-u+a,r-d+h+o,c-l+a,r-d+h+p+o];case 270:return[c-h-p+a,r-d-l-u+o,c-h+a,r-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,n,s,r]=t,a=s-i,o=r-n;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-n,o,a];case 180:return[s,e-n,a,o];case 270:return[s,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&ge._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#w?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:n,deleted:s,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!s,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#ri=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#ri=!1,!0)}isInEditMode(){return this.#ri}shouldGetKeyboardEvents(){return this.#ai}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:n}=this.getClientDimensions(),{innerHeight:s,innerWidth:r}=window;return e<r&&n>0&&t<s&&i>0}#Si(){if(this.#ti||!this.div)return;this.#ti=new AbortController;const t=this._uiManager.combinedSignal(this.#ti);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#Si()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){const n=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,n.#Ve=t.accessibilityData,n._isCopy=t.isCopy||!1;const[s,r]=n.pageDimensions,[a,o,l,h]=n.getRectInCurrentCoords(t.rect,r);return n.x=a/s,n.y=o/r,n.width=l/s,n.height=h/r,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#ti?.abort(),this.#ti=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#oi&&(clearTimeout(this.#oi),this.#oi=null),this.#gi(),this.removeEditToolbar(),this.#ci){for(const t of this.#ci.values())clearTimeout(t);this.#ci=null}this.parent=null,this.#di?.destroy(),this.#di=null,this.#Ze?.remove(),this.#Ze=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#vi(),this.#Ye.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[i,n,s,r]=this.getPDFRect();return[ge._round(i+(s-i)*t),ge._round(n+(r-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#w.commentPopupPositionInLayer}set commentPopupPosition(t){this.#w.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#w.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#w.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#w?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#Qe={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#Ye.children;if(!this.#We){this.#We=Array.from(e);const t=this.#ki.bind(this),i=this.#Di.bind(this),n=this._uiManager._signal;for(const e of this.#We){const s=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:n}),e.addEventListener("blur",i,{signal:n}),e.addEventListener("focus",this.#Pi.bind(this,s),{signal:n}),e.setAttribute("data-l10n-id",ge._l10nResizer[s])}}const i=this.#We[0];let n=0;for(const t of e){if(t===i)break;n++}const s=(360-this.rotation+this.parentRotation)%360/90*(this.#We.length/4);if(s!==n){if(s<n)for(let t=0;t<n-s;t++)this.#Ye.append(this.#Ye.firstElementChild);else if(s>n)for(let t=0;t<s-n;t++)this.#Ye.firstElementChild.before(this.#Ye.lastElementChild);let t=0;for(const i of e){const e=this.#We[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ge._l10nResizer[e])}}this.#Ii(0),this.#ai=!0,this.#Ye.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#ki(t){ge._resizerKeyboardManager.exec(this,t)}#Di(t){this.#ai&&t.relatedTarget?.parentNode!==this.#Ye&&this.#gi()}#Pi(t){this.#ei=this.#ai?t:""}#Ii(t){if(this.#We)for(const e of this.#We)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#ai&&this.#wi(this.#ei,{deltaX:t,deltaY:e,fromKeyboard:!0})}#gi(){this.#ai=!1,this.#Ii(-1),this.#Ai()}_stopResizingWithKeyboard(){this.#gi(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#y?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout((()=>this.div?.focus({preventScroll:!0})),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#Ye?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#y?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#si}set isEditing(t){this.#si=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#ci||=new Map;const{action:e}=t;let i=this.#ci.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#ci.delete(e),0===this.#ci.size&&(this.#ci=null)}),ge._telemetryTimeout),void this.#ci.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#Xe=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Xe=!0}updateFakeAnnotationElement(t){if(this.#Ze||this.deleted)return this.deleted?(this.#Ze.remove(),void(this.#Ze=null)):void((this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#Ze.updateEdited({rect:this.getPDFRect(),popup:this.comment}));this.#Ze=t.addFakeAnnotation(this)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class me extends ge{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const fe=3285377520,be=4294901760,ve=65535;class ye{constructor(t){this.h1=t?4294967295&t:fe,this.h2=t?4294967295&t:fe}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let n=0,s=t.length;n<s;n++){const s=t.charCodeAt(n);s<=255?e[i++]=s:(e[i++]=s>>>8,e[i++]=255&s)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const n=i>>2,s=i-4*n,r=new Uint32Array(e.buffer,0,n);let a=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let t=0;t<n;t++)1&t?(a=r[t],a=a*c&be|a*u&ve,a=a<<15|a>>>17,a=a*d&be|a*p&ve,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*c&be|o*u&ve,o=o<<15|o>>>17,o=o*d&be|o*p&ve,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,s){case 3:a^=e[4*n+2]<<16;case 2:a^=e[4*n+1]<<8;case 1:a^=e[4*n],a=a*c&be|a*u&ve,a=a<<15|a>>>17,a=a*d&be|a*p&ve,1&n?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&be|36045*t&ve,e=4283543511*e&be|(2950163797*(e<<16|t>>>16)&be)>>>16,t^=e>>>1,t=444984403*t&be|60499*t&ve,e=3301882366*e&be|(3120437893*(e<<16|t>>>16)&be)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const we=Object.freeze({map:null,hash:"",transfer:void 0});class Ae{#Ri=!1;#Bi=null;#Fi=null;#Li=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const i=this.#Li.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Li.get(t)}remove(t){const e=this.#Li.get(t);if(void 0!==e&&(e instanceof ge&&this.#Fi.delete(e.annotationElementId),this.#Li.delete(t),0===this.#Li.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(const t of this.#Li.values())if(t instanceof ge)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Li.get(t);let n=!1;if(void 0!==i)for(const[t,s]of Object.entries(e))i[t]!==s&&(n=!0,i[t]=s);else n=!0,this.#Li.set(t,e);n&&this.#Oi(),e instanceof ge&&((this.#Fi||=new Map).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#Li.has(t)}get size(){return this.#Li.size}#Oi(){this.#Ri||(this.#Ri=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Ri&&(this.#Ri=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new xe(this)}get serializable(){if(0===this.#Li.size)return we;const t=new Map,e=new ye,i=[],n=Object.create(null);let s=!1;for(const[i,r]of this.#Li){const a=r instanceof ge?r.serialize(!1,n):r;r.page&&(r.pageIndex=r.page._pageIndex,delete r.page),a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),s||=!!a.bitmap)}if(s)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:we}get editorStats(){let t=null;const e=new Map;let i=0,n=0;for(const s of this.#Li.values()){if(!(s instanceof ge)){s.popup&&(s.popup.deleted?n+=1:i+=1);continue}s.isCommentDeleted?n+=1:s.hasEditedComment&&(i+=1);const r=s.telemetryFinalData;if(!r)continue;const{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[t,e]of Object.entries(r)){if("type"===t)continue;const i=o.getOrInsertComputed(t,ft);i.set(e,(i.get(e)??0)+1)}}if((n>0||i>0)&&(t||=Object.create(null),t.comments={deleted:n,edited:i}),!t)return null;for(const[i,n]of e)t[i]=n.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Bi=null}updateEditor(t,e){const i=this.#Fi?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#Fi?.get(t)||null}get modifiedIds(){if(this.#Bi)return this.#Bi;const t=[];if(this.#Fi)for(const e of this.#Fi.values())e.serialize()&&t.push(e.annotationElementId);return this.#Bi={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#Li.entries()}}class xe extends Ae{#Ni=we;constructor(t){super();const{serializable:e}=t;if(e===we)return;const{map:i,hash:n,transfer:s}=e,r=structuredClone(i,s?{transfer:s}:null);this.#Ni={map:r,hash:n,transfer:[]}}get print(){X("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Ni}get modifiedIds(){return Q(this,"modifiedIds",{ids:new Set,hash:""})}}class Se{#Ui=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));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#Ui.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#Ui.has(t.loadedName))if(q(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:n,style:s}=t,r=new FontFace(e,n,s);this.addNativeFontFace(r);try{await r.load(),this.#Ui.add(e),i?.(t)}catch{W(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else X("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)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw W(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return Q(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return Q(this,"isSyncFontLoadingSupported",n||ot.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(q(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return Q(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,i,n){return t.substring(0,e)+n+t.substring(e+i)}let s,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=n(c,976,h.length,h);const d=1482184792;let u=i(c,16);for(s=0,r=h.length-3;s<r;s+=4)u=u-d+i(h,s)|0;var p;s<h.length&&(u=u-d+i(h+"XXX",s)|0),c=n(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const m=this._document.createElement("div");m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++l>30)return W("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{m.remove(),e.complete()}))}}class Ce{#zi;constructor(t,e=null,i,n){this.compiledGlyphs=Object.create(null),this.#zi=t,this._inspectFont=e,i&&Object.assign(this,i),n&&(this.charProcOperatorList=n)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const 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(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let n;try{n=t.get(i)}catch(t){W(`getPathGenerator - ignoring character: "${t}".`)}const s=Zt(n?.path);return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=s}get black(){return this.#zi.black}get bold(){return this.#zi.bold}get disableFontFace(){return this.#zi.disableFontFace??!1}set disableFontFace(t){Q(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#zi.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#zi.isInvalidPDFjsFont}get isType3Font(){return this.#zi.isType3Font}get italic(){return this.#zi.italic}get missingFile(){return this.#zi.missingFile}get remeasure(){return this.#zi.remeasure}get vertical(){return this.#zi.vertical}get ascent(){return this.#zi.ascent}get defaultWidth(){return this.#zi.defaultWidth}get descent(){return this.#zi.descent}get bbox(){return this.#zi.bbox}set bbox(t){Q(this,"bbox",t)}get fontMatrix(){return this.#zi.fontMatrix}get fallbackName(){return this.#zi.fallbackName}get loadedName(){return this.#zi.loadedName}get mimetype(){return this.#zi.mimetype}get name(){return this.#zi.name}get data(){return this.#zi.data}clearData(){this.#zi.clearData()}get cssFontInfo(){return this.#zi.cssFontInfo}get systemFontInfo(){return this.#zi.systemFontInfo}get defaultVMetrics(){return this.#zi.defaultVMetrics}}class Ee{#Hi;#ji;#Gi;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){const e=new TextEncoder,i={};let n=0;for(const s of Ee.strings){const r=e.encode(t[s]);i[s]=r,n+=4+r.length}const s=new ArrayBuffer(n),r=new Uint8Array(s),a=new DataView(s);let o=0;for(const t of Ee.strings){const e=i[t],n=e.length;a.setUint32(o,n),r.set(e,o+4),o+=4+n}return q(o===s.byteLength,"CssFontInfo.write: Buffer overflow"),s}constructor(t){this.#Hi=t,this.#ji=new DataView(this.#Hi),this.#Gi=new TextDecoder}#$i(t){q(t<Ee.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#ji.getUint32(e)+4;const i=this.#ji.getUint32(e);return this.#Gi.decode(new Uint8Array(this.#Hi,e+4,i))}get fontFamily(){return this.#$i(0)}get fontWeight(){return this.#$i(1)}get italicAngle(){return this.#$i(2)}}class Te{#Hi;#ji;#Gi;static strings=["css","loadedName","baseFontName","src"];static write(t){const e=new TextEncoder,i={};let n=0;for(const s of Te.strings){const r=e.encode(t[s]);i[s]=r,n+=4+r.length}n+=4;let s,r,a=1+n;t.style&&(s=e.encode(t.style.style),r=e.encode(t.style.weight),a+=4+s.length+4+r.length);const o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o);let c=0;h.setUint8(c++,t.guessFallback?1:0),h.setUint32(c,0),c+=4,n=0;for(const t of Te.strings){const e=i[t],s=e.length;n+=4+s,h.setUint32(c,s),l.set(e,c+4),c+=4+s}return h.setUint32(c-n-4,n),t.style&&(h.setUint32(c,s.length),l.set(s,c+4),c+=4+s.length,h.setUint32(c,r.length),l.set(r,c+4),c+=4+r.length),q(c<=o.byteLength,"SubstitionInfo.write: Buffer overflow"),o.transferToFixedLength(c)}constructor(t){this.#Hi=t,this.#ji=new DataView(this.#Hi),this.#Gi=new TextDecoder}get guessFallback(){return 0!==this.#ji.getUint8(0)}#$i(t){q(t<Te.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#ji.getUint32(e)+4;const i=this.#ji.getUint32(e);return this.#Gi.decode(new Uint8Array(this.#Hi,e+4,i))}get css(){return this.#$i(0)}get loadedName(){return this.#$i(1)}get baseFontName(){return this.#$i(2)}get src(){return this.#$i(3)}get style(){let t=1;t+=4+this.#ji.getUint32(t);const e=this.#ji.getUint32(t),i=this.#Gi.decode(new Uint8Array(this.#Hi,t+4,e));t+=4+e;const n=this.#ji.getUint32(t);return{style:i,weight:this.#Gi.decode(new Uint8Array(this.#Hi,t+4,n))}}}class _e{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static#Vi=Math.ceil(2*this.bools.length/8);static#Wi=this.#Vi+8*this.numbers.length;static#Xi=this.#Wi+1+8;static#qi=this.#Xi+1+48;static#Ki=this.#qi+1+6;#Hi;#Gi;#ji;constructor({data:t,extra:e}){this.#Hi=t,this.#Gi=new TextDecoder,this.#ji=new DataView(this.#Hi),e&&Object.assign(this,e)}#Yi(t){q(t<_e.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=2*t%8,n=this.#ji.getUint8(e)>>i&3;return 0===n?void 0:2===n}get black(){return this.#Yi(0)}get bold(){return this.#Yi(1)}get disableFontFace(){return this.#Yi(2)}get fontExtraProperties(){return this.#Yi(3)}get isInvalidPDFjsFont(){return this.#Yi(4)}get isType3Font(){return this.#Yi(5)}get italic(){return this.#Yi(6)}get missingFile(){return this.#Yi(7)}get remeasure(){return this.#Yi(8)}get vertical(){return this.#Yi(9)}#Ji(t){return q(t<_e.numbers.length,"Invalid number index"),this.#ji.getFloat64(_e.#Vi+8*t)}get ascent(){return this.#Ji(0)}get defaultWidth(){return this.#Ji(1)}get descent(){return this.#Ji(2)}get bbox(){let t=_e.#Wi;if(0===this.#ji.getUint8(t))return;t+=1;const e=[];for(let i=0;i<4;i++)e.push(this.#ji.getInt16(t,!0)),t+=2;return e}get fontMatrix(){let t=_e.#Xi;if(0===this.#ji.getUint8(t))return;t+=1;const e=[];for(let i=0;i<6;i++)e.push(this.#ji.getFloat64(t,!0)),t+=8;return e}get defaultVMetrics(){let t=_e.#qi;if(0===this.#ji.getUint8(t))return;t+=1;const e=[];for(let i=0;i<3;i++)e.push(this.#ji.getInt16(t,!0)),t+=2;return e}#$i(t){q(t<_e.strings.length,"Invalid string index");let e=_e.#Ki+4;for(let i=0;i<t;i++)e+=this.#ji.getUint32(e)+4;const i=this.#ji.getUint32(e),n=new Uint8Array(i);return n.set(new Uint8Array(this.#Hi,e+4,i)),this.#Gi.decode(n)}get fallbackName(){return this.#$i(0)}get loadedName(){return this.#$i(1)}get mimetype(){return this.#$i(2)}get name(){return this.#$i(3)}get data(){let t=_e.#Ki;t+=4+this.#ji.getUint32(t);t+=4+this.#ji.getUint32(t);t+=4+this.#ji.getUint32(t);const e=this.#ji.getUint32(t);if(0!==e)return new Uint8Array(this.#Hi,t+4,e)}clearData(){let t=_e.#Ki;t+=4+this.#ji.getUint32(t);t+=4+this.#ji.getUint32(t);t+=4+this.#ji.getUint32(t);const e=this.#ji.getUint32(t);new Uint8Array(this.#Hi,t+4,e).fill(0),this.#ji.setUint32(t,0)}get cssFontInfo(){let t=_e.#Ki;t+=4+this.#ji.getUint32(t);t+=4+this.#ji.getUint32(t);const e=this.#ji.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#Hi,t+4,e)),new Ee(i.buffer)}get systemFontInfo(){let t=_e.#Ki;t+=4+this.#ji.getUint32(t);const e=this.#ji.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#Hi,t+4,e)),new Te(i.buffer)}static write(t){const e=t.systemFontInfo?Te.write(t.systemFontInfo):null,i=t.cssFontInfo?Ee.write(t.cssFontInfo):null,n=new TextEncoder,s={};let r=0;for(const e of _e.strings)s[e]=n.encode(t[e]),r+=4+s[e].length;const a=_e.#Ki+4+r+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0),o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o);let c=0;const d=_e.bools.length;let u=0,p=0;for(let e=0;e<d;e++){const i=t[_e.bools[e]];u|=(void 0===i?0:i?2:1)<<p,p+=2,8!==p&&e!==d-1||(h.setUint8(c++,u),u=0,p=0)}q(c===_e.#Vi,"FontInfo.write: Boolean properties offset mismatch");for(const e of _e.numbers)h.setFloat64(c,t[e]),c+=8;if(q(c===_e.#Wi,"FontInfo.write: Number properties offset mismatch"),t.bbox){h.setUint8(c++,4);for(const e of t.bbox)h.setInt16(c,e,!0),c+=2}else h.setUint8(c++,0),c+=8;if(q(c===_e.#Xi,"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){h.setUint8(c++,6);for(const e of t.fontMatrix)h.setFloat64(c,e,!0),c+=8}else h.setUint8(c++,0),c+=48;if(q(c===_e.#qi,"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){h.setUint8(c++,1);for(const e of t.defaultVMetrics)h.setInt16(c,e,!0),c+=2}else h.setUint8(c++,0),c+=6;q(c===_e.#Ki,"FontInfo.write: DefaultVMetrics properties offset mismatch"),h.setUint32(_e.#Ki,0),c+=4;for(const t of _e.strings){const e=s[t],i=e.length;h.setUint32(c,i),l.set(e,c+4),c+=4+i}if(h.setUint32(_e.#Ki,c-_e.#Ki-4),e){const t=e.byteLength;h.setUint32(c,t),q(c+4+t<=o.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),l.set(new Uint8Array(e),c+4),c+=4+t}else h.setUint32(c,0),c+=4;if(i){const t=i.byteLength;h.setUint32(c,t),q(c+4+t<=o.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),l.set(new Uint8Array(i),c+4),c+=4+t}else h.setUint32(c,0),c+=4;return void 0===t.data?(h.setUint32(c,0),c+=4):(h.setUint32(c,t.data.length),l.set(t.data,c+4),c+=4+t.data.length),q(c<=o.byteLength,"FontInfo.write: Buffer overflow"),o.transferToFixedLength(c)}}class Me{static#Qi=0;static#Zi=1;static#tn=2;static#en=3;static#in=4;static#nn=8;static#sn=12;static#rn=16;constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}static write(t){let e,i=null,n=[],s=[],r=[],a=[],o=null,l=null;switch(t[0]){case"RadialAxial":e="axial"===t[1]?1:2,i=t[2],r=t[3],1===e?n.push(...t[4],...t[5]):n.push(t[4][0],t[4][1],t[6],t[5][0],t[5][1],t[7]);break;case"Mesh":e=3,o=t[1],n=t[2],s=t[3],a=t[4]||[],i=t[6],l=t[7];break;default:throw new Error(`Unsupported pattern type: ${t[0]}`)}const h=Math.floor(n.length/2),c=Math.floor(s.length/3),d=r.length,u=a.length;let p=0;for(const t of a)p+=1,p=4*Math.ceil(p/4),p+=4+4*t.coords.length,p+=4+4*t.colors.length,void 0!==t.verticesPerRow&&(p+=4);const g=new ArrayBuffer(20+8*h+3*c+8*d+(i?16:0)+(l?3:0)+p),m=new DataView(g),f=new Uint8Array(g);m.setUint8(Me.#Qi,e),m.setUint8(Me.#Zi,i?1:0),m.setUint8(Me.#tn,l?1:0),m.setUint8(Me.#en,o),m.setUint32(Me.#in,h,!0),m.setUint32(Me.#nn,c,!0),m.setUint32(Me.#sn,d,!0),m.setUint32(Me.#rn,u,!0);let b=20;new Float32Array(g,b,2*h).set(n),b+=8*h,f.set(s,b),b+=3*c;for(const[t,e]of r)m.setFloat32(b,t,!0),b+=4,m.setUint32(b,parseInt(e.slice(1),16),!0),b+=4;if(i)for(const t of i)m.setFloat32(b,t,!0),b+=4;l&&(f.set(l,b),b+=3);for(let t=0;t<a.length;t++){const e=a[t];m.setUint8(b,e.type),b+=1,b=4*Math.ceil(b/4),m.setUint32(b,e.coords.length,!0),b+=4;new Int32Array(g,b,e.coords.length).set(e.coords),b+=4*e.coords.length,m.setUint32(b,e.colors.length,!0),b+=4;new Int32Array(g,b,e.colors.length).set(e.colors),b+=4*e.colors.length,void 0!==e.verticesPerRow&&(m.setUint32(b,e.verticesPerRow,!0),b+=4)}return g}getIR(){const t=this.view,e=this.data[Me.#Qi],i=!!this.data[Me.#Zi],n=!!this.data[Me.#tn],s=t.getUint32(Me.#in,!0),r=t.getUint32(Me.#nn,!0),a=t.getUint32(Me.#sn,!0),o=t.getUint32(Me.#rn,!0);let l=20;const h=new Float32Array(this.buffer,l,2*s);l+=8*s;const c=new Uint8Array(this.buffer,l,3*r);l+=3*r;const d=[];for(let e=0;e<a;++e){const e=t.getFloat32(l,!0);l+=4;const i=t.getUint32(l,!0);l+=4,d.push([e,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let e=0;e<4;++e)u.push(t.getFloat32(l,!0)),l+=4}let p=null;n&&(p=new Uint8Array(this.buffer,l,3),l+=3);const g=[];for(let e=0;e<o;++e){const e=t.getUint8(l);l+=1,l=4*Math.ceil(l/4);const i=t.getUint32(l,!0);l+=4;const n=new Int32Array(this.buffer,l,i);l+=4*i;const s=t.getUint32(l,!0);l+=4;const r=new Int32Array(this.buffer,l,s);l+=4*s;const a={type:e,coords:n,colors:r};e===w&&(a.verticesPerRow=t.getUint32(l,!0),l+=4),g.push(a)}if(1===e)return["RadialAxial","axial",u,d,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",u,d,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(3===e){const t=this.data[Me.#en];let e=null;if(h.length>0){let t=h[0],i=h[0],n=h[1],s=h[1];for(let e=0;e<h.length;e+=2){const r=h[e],a=h[e+1];t=t>r?r:t,n=n>a?a:n,i=i<r?r:i,s=s<a?a:s}e=[t,n,i,s]}return["Mesh",t,h,c,g,e,u,p]}throw new Error(`Unsupported pattern kind: ${e}`)}}class ke{static write(t){let e,i;return ot.isFloat16ArraySupported?(i=new ArrayBuffer(2*t.length),e=new Float16Array(i)):(i=new ArrayBuffer(4*t.length),e=new Float32Array(i)),e.set(t),i}#Hi;constructor(t){this.#Hi=t}get path(){return ot.isFloat16ArraySupported?new Float16Array(this.#Hi):new Float32Array(this.#Hi)}}function De(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Pe=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Ie=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[n,s,...r]=i;if(!t(n)&&!Number.isInteger(n))return!1;if(!e(s))return!1;const a=r.length;let o=!0;switch(s.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(const t of r)if(!("number"==typeof t||o&&null===t))return!1;return!0}.bind(null,Pe,(t=>"object"==typeof t&&"string"==typeof t?.name));class Re{#o=new Map;#an=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#an.then((()=>{for(const[t]of this.#o)t.call(this,i)}))}addEventListener(t,e,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return void W("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);n=()=>s.removeEventListener("abort",r),s.addEventListener("abort",r)}this.#o.set(e,n)}removeEventListener(t,e){this.#o.get(e)?.(),this.#o.delete(e)}terminate(){for(const[,t]of this.#o)t?.();this.#o.clear()}}i(1689);const Be=1,Fe=2,Le=1,Oe=2,Ne=3,Ue=4,ze=5,He=6,je=7,Ge=8;function $e(){}function Ve(t){if(t instanceof rt||t instanceof it||t instanceof tt||t instanceof nt||t instanceof et)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||X('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new rt(t.message);case"InvalidPDFException":return new it(t.message);case"PasswordException":return new tt(t.message,t.code);case"ResponseException":return new nt(t.message,t.status,t.missing);case"UnknownErrorException":return new et(t.message,t.details)}return new et(t.message,t.toString())}class We{#on=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.#ln.bind(this),{signal:this.#on.signal})}#ln({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#hn(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Be)i.resolve(t.data);else{if(t.callback!==Fe)throw new Error("Unexpected callback case");i.reject(Ve(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,n=t.sourceName,s=this.comObj;Promise.try(e,t.data).then((function(e){s.postMessage({sourceName:i,targetName:n,callback:Be,callbackId:t.callbackId,data:e})}),(function(e){s.postMessage({sourceName:i,targetName:n,callback:Fe,callbackId:t.callbackId,reason:Ve(e)})}))}else t.streamId?this.#cn(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new 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)}sendWithPromise(t,e,i){const n=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[n]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},i)}catch(t){s.reject(t)}return s.promise}sendWithStream(t,e,i,n){const s=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[s]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:s,data:e,desiredSize:i.desiredSize},n),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[s].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:He,streamId:s,desiredSize:t.desiredSize}),e.promise},cancel:t=>{q(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[s].cancelCall=e,this.streamControllers[s].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Le,streamId:s,reason:Ve(t)}),e.promise}},i)}#cn(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),s.postMessage({sourceName:i,targetName:n,stream:Ue,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:Ne,streamId:e}),delete r.streamSinks[e])},error(t){q(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:ze,streamId:e,reason:Ve(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(){s.postMessage({sourceName:i,targetName:n,stream:Ge,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:i,targetName:n,stream:Ge,streamId:e,reason:Ve(t)})}))}#hn(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Ge:t.success?r.startCall.resolve():r.startCall.reject(Ve(t.reason));break;case je:t.success?r.pullCall.resolve():r.pullCall.reject(Ve(t.reason));break;case He:if(!a){s.postMessage({sourceName:i,targetName:n,stream:je,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||$e).then((function(){s.postMessage({sourceName:i,targetName:n,stream:je,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:i,targetName:n,stream:je,streamId:e,reason:Ve(t)})}));break;case Ue:if(q(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Ne:if(q(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#dn(r,e);break;case ze:q(r,"error should have stream controller"),r.controller.error(Ve(t.reason)),this.#dn(r,e);break;case Oe:t.success?r.cancelCall.resolve():r.cancelCall.reject(Ve(t.reason)),this.#dn(r,e);break;case Le:if(!a)break;const o=Ve(t.reason);Promise.try(a.onCancel||$e,o).then((function(){s.postMessage({sourceName:i,targetName:n,stream:Oe,streamId:e,success:!0})}),(function(t){s.postMessage({sourceName:i,targetName:n,stream:Oe,streamId:e,reason:Ve(t)})})),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#dn(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#on?.abort(),this.#on=null}}class Xe{#un=!1;constructor({enableHWA:t=!1}){this.#un=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#un})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){X("Abstract method `_createCanvas` called.")}}class qe extends Xe{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class Ke{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){X("Abstract method `_fetch` called.")}}class Ye extends Ke{async _fetch(t){const e=await St(t,this.isCompressed?"bytes":"text");return e instanceof Uint8Array?e:at(e)}}i(2489);class Je{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,n,s){return"none"}destroy(t=!1){}}class Qe extends Je{#pn;#gn;#mn;#fn;#bn;#vn;#O=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#fn=t,this.#bn=e}get#U(){return this.#gn||=new Map}get#yn(){return this.#vn||=new Map}get#wn(){if(!this.#mn){const t=this.#bn.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#bn.createElementNS(At,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#mn=this.#bn.createElementNS(At,"defs"),t.append(i),i.append(this.#mn),this.#bn.body.append(t)}return this.#mn}#An(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const n=i.join(",");return[n,n,n]}const[e,i,n]=t,s=new Array(256),r=new Array(256),a=new Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255,r[t]=i[t]/255,a[t]=n[t]/255;return[s.join(","),r.join(","),a.join(",")]}#xn(t){if(void 0===this.#pn){this.#pn="";const t=this.#bn.URL;t!==this.#bn.baseURI&&(Tt(t)?W('#createUrl: ignore "data:"-URL for performance reasons.'):this.#pn=Y(t,""))}return`url(${this.#pn}#${t})`}addFilter(t){if(!t)return"none";let e=this.#U.get(t);if(e)return e;const[i,n,s]=this.#An(t),r=1===t.length?i:`${i}${n}${s}`;if(e=this.#U.get(r),e)return this.#U.set(t,e),e;const a=`g_${this.#fn}_transfer_map_${this.#O++}`,o=this.#xn(a);this.#U.set(t,o),this.#U.set(r,o);const l=this.#Sn(a);return this.#Cn(i,n,s,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,n="base";let s=this.#yn.get(n);if(s?.key===i)return s.url;if(s?(s.filter?.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},this.#yn.set(n,s)),!t||!e)return s.url;const r=this.#En(t);t=ht.makeHexColor(...r);const a=this.#En(e);if(e=ht.makeHexColor(...a),this.#wn.style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#fn}_hcm_filter`,c=s.filter=this.#Sn(h);this.#Cn(l,l,l,c),this.#Tn(c);const d=(t,e)=>{const i=r[t]/255,n=a[t]/255,s=new Array(e+1);for(let t=0;t<=e;t++)s[t]=i+t/e*(n-i);return s.join(",")};return this.#Cn(d(0,5),d(1,5),d(2,5),c),s.url=this.#xn(h),s.url}addAlphaFilter(t){let e=this.#U.get(t);if(e)return e;const[i]=this.#An([t]),n=`alpha_${i}`;if(e=this.#U.get(n),e)return this.#U.set(t,e),e;const s=`g_${this.#fn}_alpha_map_${this.#O++}`,r=this.#xn(s);this.#U.set(t,r),this.#U.set(n,r);const a=this.#Sn(s);return this.#_n(i,a),r}addLuminosityFilter(t){let e,i,n=this.#U.get(t||"luminosity");if(n)return n;if(t?([e]=this.#An([t]),i=`luminosity_${e}`):i="luminosity",n=this.#U.get(i),n)return this.#U.set(t,n),n;const s=`g_${this.#fn}_luminosity_map_${this.#O++}`,r=this.#xn(s);this.#U.set(t,r),this.#U.set(i,r);const a=this.#Sn(s);return this.#Mn(a),t&&this.#_n(e,a),r}addHighlightHCMFilter(t,e,i,n,s){const r=`${e}-${i}-${n}-${s}`;let a=this.#yn.get(t);if(a?.key===r)return a.url;if(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#yn.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#En.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,u]=[n,s].map(this.#En.bind(this));c<h&&([h,c,d,u]=[c,h,u,d]),this.#wn.style.color="";const p=(t,e,i)=>{const n=new Array(256),s=(c-h)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*s),i=r+t*a;for(let t=o;t<=e;t++)n[t]=i;o=e+1}for(let t=o;t<256;t++)n[t]=n[o-1];return n.join(",")},g=`g_${this.#fn}_hcm_${t}_filter`,m=a.filter=this.#Sn(g);return this.#Tn(m),this.#Cn(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),m),a.url=this.#xn(g),a.url}destroy(t=!1){t&&this.#vn?.size||(this.#mn?.parentNode.parentNode.remove(),this.#mn=null,this.#gn?.clear(),this.#gn=null,this.#vn?.clear(),this.#vn=null,this.#O=0)}#Mn(t){const e=this.#bn.createElementNS(At,"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)}#Tn(t){const e=this.#bn.createElementNS(At,"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)}#Sn(t){const e=this.#bn.createElementNS(At,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#wn.append(e),e}#kn(t,e,i){const n=this.#bn.createElementNS(At,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),t.append(n)}#Cn(t,e,i,n){const s=this.#bn.createElementNS(At,"feComponentTransfer");n.append(s),this.#kn(s,"feFuncR",t),this.#kn(s,"feFuncG",e),this.#kn(s,"feFuncB",i)}#_n(t,e){const i=this.#bn.createElementNS(At,"feComponentTransfer");e.append(i),this.#kn(i,"feFuncA",t)}#En(t){return this.#wn.style.color=t,Ot(getComputedStyle(this.#wn).getPropertyValue("color"))}}class Ze{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){X("Abstract method `_fetch` called.")}}class ti extends Ze{async _fetch(t){return St(t,"bytes")}}class ei{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load wasm data at: ${e}`)}))}async _fetch(t){X("Abstract method `_fetch` called.")}}class ii extends ei{async _fetch(t){return St(t,"bytes")}}if(n){let t;try{const e=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=e("@napi-rs/canvas")}catch(t){W(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(t){W(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(t?.DOMMatrix?globalThis.DOMMatrix=t.DOMMatrix:W("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(t?.ImageData?globalThis.ImageData=t.ImageData:W("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(t?.Path2D?globalThis.Path2D=t.Path2D:W("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function ni(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}class si extends Je{}class ri extends Xe{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class ai extends Ke{async _fetch(t){return ni(t)}}class oi extends Ze{async _fetch(t){return ni(t)}}class li extends ei{async _fetch(t){return ni(t)}}i(7588);const hi="__forcedDependency",{floor:ci,ceil:di}=Math;function ui(t,e,i,n,s,r){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],n),t[4*e+2]=Math.max(t[4*e+2],s),t[4*e+3]=Math.max(t[4*e+3],r)}const pi=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class gi{#Dn;#Pn;constructor(t,e){this.#Dn=t,this.#Pn=e}get length(){return this.#Dn.length}isEmpty(t){return this.#Dn[t]===pi}minX(t){return this.#Pn[4*t+0]/256}minY(t){return this.#Pn[4*t+1]/256}maxX(t){return(this.#Pn[4*t+2]+1)/256}maxY(t){return(this.#Pn[4*t+3]+1)/256}}const mi=(t,e)=>t?.getOrInsertComputed(e,(()=>({dependencies:new Set,isRenderingOperation:!1})));class fi{#In={__proto__:null};#Rn={__proto__:null,transform:[],moveText:[],sameLineText:[],[hi]:[]};#Bn=new Map;#Fn=[];#Ln=[];#On=[[1,0,0,1,0,0]];#Nn=[-1/0,-1/0,1/0,1/0];#Un=new Float64Array([1/0,1/0,-1/0,-1/0]);#zn=-1;#Hn=new Set;#jn=new Map;#Gn=new Map;#$n;#Vn;#Wn;#Dn;#Xn;constructor(t,e,i=!1){this.#$n=t.width,this.#Vn=t.height,this.#qn(e),i&&(this.#Xn=new Map)}growOperationsCount(t){t>=this.#Dn.length&&this.#qn(t,this.#Dn)}#qn(t,e){const i=new ArrayBuffer(4*t);this.#Wn=new Uint8ClampedArray(i),this.#Dn=new Uint32Array(i),e&&e.length>0?(this.#Dn.set(e),this.#Dn.fill(pi,e.length)):this.#Dn.fill(pi)}save(t){return this.#In={__proto__:this.#In},this.#Rn={__proto__:this.#Rn,transform:{__proto__:this.#Rn.transform},moveText:{__proto__:this.#Rn.moveText},sameLineText:{__proto__:this.#Rn.sameLineText},[hi]:{__proto__:this.#Rn[hi]}},this.#Nn={__proto__:this.#Nn},this.#Fn.push(t),this}restore(t){const e=Object.getPrototypeOf(this.#In);if(null===e)return this;this.#In=e,this.#Rn=Object.getPrototypeOf(this.#Rn),this.#Nn=Object.getPrototypeOf(this.#Nn);const i=this.#Fn.pop();return void 0!==i&&(mi(this.#Xn,t)?.dependencies.add(i),this.#Dn[t]=this.#Dn[i]),this}recordOpenMarker(t){return this.#Fn.push(t),this}getOpenMarker(){return 0===this.#Fn.length?null:this.#Fn.at(-1)}recordCloseMarker(t){const e=this.#Fn.pop();return void 0!==e&&(mi(this.#Xn,t)?.dependencies.add(e),this.#Dn[t]=this.#Dn[e]),this}beginMarkedContent(t){return this.#Ln.push(t),this}endMarkedContent(t){const e=this.#Ln.pop();return void 0!==e&&(mi(this.#Xn,t)?.dependencies.add(e),this.#Dn[t]=this.#Dn[e]),this}pushBaseTransform(t){return this.#On.push(ht.multiplyByDOMMatrix(this.#On.at(-1),t.getTransform())),this}popBaseTransform(){return this.#On.length>1&&this.#On.pop(),this}recordSimpleData(t,e){return this.#In[t]=e,this}recordIncrementalData(t,e){return this.#Rn[t].push(e),this}resetIncrementalData(t,e){return this.#Rn[t].length=0,this}recordNamedData(t,e){return this.#Bn.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#In[t]=this.#Bn.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(hi,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#In&&this.recordFutureForcedDependency(e,this.#In[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#Hn)this.recordFutureForcedDependency(hi,t);return this}resetBBox(t){return this.#zn!==t&&(this.#zn=t,this.#Un[0]=1/0,this.#Un[1]=1/0,this.#Un[2]=-1/0,this.#Un[3]=-1/0),this}recordClipBox(t,e,i,n,s,r){const a=ht.multiplyByDOMMatrix(this.#On.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];ht.axialAlignedBoundingBox([i,s,n,r],a,o);const l=ht.intersect(this.#Nn,o);return l?(this.#Nn[0]=l[0],this.#Nn[1]=l[1],this.#Nn[2]=l[2],this.#Nn[3]=l[3]):(this.#Nn[0]=this.#Nn[1]=1/0,this.#Nn[2]=this.#Nn[3]=-1/0),this}recordBBox(t,e,i,n,s,r){const a=this.#Nn;if(a[0]===1/0)return this;const o=ht.multiplyByDOMMatrix(this.#On.at(-1),e.getTransform());if(a[0]===-1/0)return ht.axialAlignedBoundingBox([i,s,n,r],o,this.#Un),this;const l=[1/0,1/0,-1/0,-1/0];return ht.axialAlignedBoundingBox([i,s,n,r],o,l),this.#Un[0]=Math.min(this.#Un[0],Math.max(l[0],a[0])),this.#Un[1]=Math.min(this.#Un[1],Math.max(l[1],a[1])),this.#Un[2]=Math.max(this.#Un[2],Math.min(l[2],a[2])),this.#Un[3]=Math.max(this.#Un[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,n=1,s=0,r=0,a){const o=i.bbox;let l,h;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#Gn.get(i),!1!==l&&(h=[0,0,0,0],ht.axialAlignedBoundingBox(o,i.fontMatrix,h),1===n&&0===s&&0===r||ht.scaleMinMax([n,0,0,-n,s,r],h),l)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!a)return this.recordFullPageBBox(t);const c=a();return o&&h&&void 0===l&&(l=h[0]<=s-c.actualBoundingBoxLeft&&h[2]>=s+c.actualBoundingBoxRight&&h[1]<=r-c.actualBoundingBoxAscent&&h[3]>=r+c.actualBoundingBoxDescent,this.#Gn.set(i,l),l)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,s-c.actualBoundingBoxLeft,s+c.actualBoundingBoxRight,r-c.actualBoundingBoxAscent,r+c.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#Un[0]=Math.max(0,this.#Nn[0]),this.#Un[1]=Math.max(0,this.#Nn[1]),this.#Un[2]=Math.min(this.#$n,this.#Nn[2]),this.#Un[3]=Math.min(this.#Vn,this.#Nn[3]),this}getSimpleIndex(t){return this.#In[t]}recordDependencies(t,e){const i=this.#Hn,n=this.#In,s=this.#Rn;for(const t of e)t in this.#In?i.add(n[t]):t in s&&s[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#Bn.has(e)&&this.#Hn.add(this.#Bn.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[hi]),this.#Xn){const e=mi(this.#Xn,t),{dependencies:i}=e;this.#Hn.forEach(i.add,i),this.#Fn.forEach(i.add,i),this.#Ln.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(this.#zn===t){const i=ci(256*this.#Un[0]/this.#$n),n=ci(256*this.#Un[1]/this.#Vn),s=di(256*this.#Un[2]/this.#$n),r=di(256*this.#Un[3]/this.#Vn);ui(this.#Wn,t,i,n,s,r);for(const e of this.#Hn)e!==t&&ui(this.#Wn,e,i,n,s,r);for(const e of this.#Fn)e!==t&&ui(this.#Wn,e,i,n,s,r);for(const e of this.#Ln)e!==t&&ui(this.#Wn,e,i,n,s,r);e||(this.#Hn.clear(),this.#zn=-1)}return this}recordShowTextOperation(t,e=!1){const i=Array.from(this.#Hn);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const t of i)this.recordIncrementalData("sameLineText",t);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#zn===t&&(this.#zn=-1,this.#Nn[0]=Math.max(this.#Nn[0],this.#Un[0]),this.#Nn[1]=Math.max(this.#Nn[1],this.#Un[1]),this.#Nn[2]=Math.min(this.#Nn[2],this.#Un[2]),this.#Nn[3]=Math.min(this.#Nn[3],this.#Un[3]),e||this.#Hn.clear()),this}_takePendingDependencies(){const t=this.#Hn;return this.#Hn=new Set,t}_extractOperation(t){const e=this.#jn.get(t);return this.#jn.delete(t),e}_pushPendingDependencies(t){for(const e of t)this.#Hn.add(e)}take(){return this.#Gn.clear(),new gi(this.#Dn,this.#Wn)}takeDebugMetadata(){return this.#Xn}}class bi{#Kn;#Yn;#Jn;#Qn=0;#Zn=0;constructor(t,e,i){if(t instanceof bi&&t.#Jn===!!i)return t;this.#Kn=t,this.#Yn=e,this.#Jn=!!i}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#Zn++,this.#Kn.save(this.#Yn),this}restore(t){return this.#Zn>0&&(this.#Kn.restore(this.#Yn),this.#Zn--),this}recordOpenMarker(t){return this.#Qn++,this}getOpenMarker(){return this.#Qn>0?this.#Yn:this.#Kn.getOpenMarker()}recordCloseMarker(t){return this.#Qn--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#Kn.pushBaseTransform(t),this}popBaseTransform(){return this.#Kn.popBaseTransform(),this}recordSimpleData(t,e){return this.#Kn.recordSimpleData(t,this.#Yn),this}recordIncrementalData(t,e){return this.#Kn.recordIncrementalData(t,this.#Yn),this}resetIncrementalData(t,e){return this.#Kn.resetIncrementalData(t,this.#Yn),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#Kn.recordSimpleDataFromNamed(t,e,this.#Yn),this}recordFutureForcedDependency(t,e){return this.#Kn.recordFutureForcedDependency(t,this.#Yn),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#Kn.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#Kn.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#Jn||this.#Kn.resetBBox(this.#Yn),this}recordClipBox(t,e,i,n,s,r){return this.#Jn||this.#Kn.recordClipBox(this.#Yn,e,i,n,s,r),this}recordBBox(t,e,i,n,s,r){return this.#Jn||this.#Kn.recordBBox(this.#Yn,e,i,n,s,r),this}recordCharacterBBox(t,e,i,n,s,r,a){return this.#Jn||this.#Kn.recordCharacterBBox(this.#Yn,e,i,n,s,r,a),this}recordFullPageBBox(t){return this.#Jn||this.#Kn.recordFullPageBBox(this.#Yn),this}getSimpleIndex(t){return this.#Kn.getSimpleIndex(t)}recordDependencies(t,e){return this.#Kn.recordDependencies(this.#Yn,e),this}recordNamedDependency(t,e){return this.#Kn.recordNamedDependency(this.#Yn,e),this}recordOperation(t){return this.#Kn.recordOperation(this.#Yn,!0),this}recordShowTextOperation(t){return this.#Kn.recordShowTextOperation(this.#Yn,!0),this}bboxToClipBoxDropOperation(t){return this.#Jn||this.#Kn.bboxToClipBoxDropOperation(this.#Yn,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const vi=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],yi=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],wi=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],Ai=["filter","fillColor","fillAlpha"],xi=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Si=["transform"],Ci=["transform","fillColor"],Ei="Fill",Ti="Stroke",_i="Shading";function Mi(t,e){if(!e)return;const i=e[2]-e[0],n=e[3]-e[1],s=new Path2D;s.rect(e[0],e[1],i,n),t.clip(s)}class ki{isModifyingCurrentTransform(){return!1}getPattern(){X("Abstract method `getPattern` called.")}}class Di extends ki{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}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}_createGradient(t,e=null){let i,n=this._p0,s=this._p1;if(e&&(n=n.slice(),s=s.slice(),ht.applyTransform(n,e),ht.applyTransform(s,e)),"axial"===this._type)i=t.createLinearGradient(n[0],n[1],s[0],s[1]);else if("radial"===this._type){let r=this._r0,a=this._r1;if(e){const t=new Float32Array(2);ht.singularValueDecompose2dScale(e,t),r*=t[0],a*=t[0]}i=t.createRadialGradient(n[0],n[1],r,s[0],s[1],a)}for(const t of this._colorStops)i.addColorStop(t[0],t[1]);return i}getPattern(t,e,i,n){let s;if(n===Ti||n===Ei){if(this.isOriginBased()){let n=ht.transform(i,e.baseTransform);this.matrix&&(n=ht.transform(n,this.matrix));const s=.001,r=Math.hypot(n[0],n[1]),a=Math.hypot(n[2],n[3]),o=(n[0]*n[2]+n[1]*n[3])/(r*a);if(Math.abs(o)<s){if(!this.isRadial())return this._createGradient(t,n);if(Math.abs(r-a)<s)return this._createGradient(t,n)}}const r=e.current.getClippedPathBoundingBox(n,Nt(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[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(-r[0],-r[1]),i=ht.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Mi(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),s=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(i);s.setTransform(c)}else Mi(t,this._bbox),s=this._createGradient(t);return s}}function Pi(t,e,i,n,s,r,a,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[i+1]>l[n+1]&&(u=i,i=n,n=u,u=r,r=a,a=u),l[n+1]>l[s+1]&&(u=n,n=s,s=u,u=a,a=o,o=u),l[i+1]>l[n+1]&&(u=i,i=n,n=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,m=(l[n]+e.offsetX)*e.scaleX,f=(l[n+1]+e.offsetY)*e.scaleY,b=(l[s]+e.offsetX)*e.scaleX,v=(l[s+1]+e.offsetY)*e.scaleY;if(g>=v)return;const y=h[r],w=h[r+1],A=h[r+2],x=h[a],S=h[a+1],C=h[a+2],E=h[o],T=h[o+1],_=h[o+2],M=Math.round(g),k=Math.round(v);let D,P,I,R,B,F,L,O;for(let t=M;t<=k;t++){if(t<f){const e=t<g?0:(g-t)/(g-f);D=p-(p-m)*e,P=y-(y-x)*e,I=w-(w-S)*e,R=A-(A-C)*e}else{let e;e=t>v?1:f===v?0:(f-t)/(f-v),D=m-(m-b)*e,P=x-(x-E)*e,I=S-(S-T)*e,R=C-(C-_)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),B=p-(p-b)*e,F=y-(y-E)*e,L=w-(w-T)*e,O=A-(A-_)*e;const i=Math.round(Math.min(D,B)),n=Math.round(Math.max(D,B));let s=d*t+4*i;for(let t=i;t<=n;t++)e=(D-t)/(D-B),e<0?e=0:e>1&&(e=1),c[s++]=P-(P-F)*e|0,c[s++]=I-(I-L)*e|0,c[s++]=R-(R-O)*e|0,c[s++]=255}}function Ii(t,e,i){const n=e.coords,s=e.colors;let r,a;switch(e.type){case w:const o=e.verticesPerRow,l=Math.floor(n.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)Pi(t,i,n[e],n[e+1],n[e+o],s[e],s[e+1],s[e+o]),Pi(t,i,n[e+o+1],n[e+1],n[e+o],s[e+o+1],s[e+1],s[e+o])}break;case y:for(r=0,a=n.length;r<a;r+=3)Pi(t,i,n[r],n[r+1],n[r+2],s[r],s[r+1],s[r+2]);break;default:throw new Error("illegal figure")}}class Ri extends ki{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const n=Math.floor(this._bounds[0]),s=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-n,a=Math.ceil(this._bounds[3])-s,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,c=a/l,d={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-s,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),m=g.context,f=m.createImageData(o,l);if(e){const t=f.data;for(let i=0,n=t.length;i<n;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)Ii(f,t,d);m.putImageData(f,2,2);return{canvas:g.canvas,offsetX:n-2*h,offsetY:s-2*c,scaleX:h,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,n){Mi(t,this._bbox);const s=new Float32Array(2);if(n===_i)ht.singularValueDecompose2dScale(Nt(t),s);else if(this.matrix){ht.singularValueDecompose2dScale(this.matrix,s);const[t,i]=s;ht.singularValueDecompose2dScale(e.baseTransform,s),s[0]*=t,s[1]*=i}else ht.singularValueDecompose2dScale(e.baseTransform,s);const r=this._createMeshCanvas(s,n===_i?null:this._background,e.cachedCanvases);return n!==_i&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Bi extends ki{getPattern(){return"hotpink"}}const Fi=1,Li=2;class Oi{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,n){this.color=t[1],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.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t,e){const{bbox:i,operatorList:n,paintType:s,tilingType:r,color:a,canvasGraphicsFactory:o}=this;let{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),V("TilingType: "+r);const c=i[0],d=i[1],u=i[2],p=i[3],g=u-c,m=p-d,f=new Float32Array(2);ht.singularValueDecompose2dScale(this.matrix,f);const[b,v]=f;ht.singularValueDecompose2dScale(this.baseTransform,f);const y=b*f[0],w=v*f[1];let A=g,x=m,S=!1,C=!1;const E=Math.ceil(l*y),T=Math.ceil(h*w);E>=Math.ceil(g*y)?A=l:S=!0,T>=Math.ceil(m*w)?x=h:C=!0;const _=this.getSizeAndScale(A,this.ctx.canvas.width,y),M=this.getSizeAndScale(x,this.ctx.canvas.height,w),k=t.cachedCanvases.getCanvas("pattern",_.size,M.size),D=k.context,P=o.createCanvasGraphics(D,e);if(P.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(P,s,a),D.translate(-_.scale*c,-M.scale*d),P.transform(0,_.scale,0,0,M.scale,0,0),D.save(),P.dependencyTracker?.save(),this.clipBbox(P,c,d,u,p),P.baseTransform=Nt(P.ctx),P.executeOperatorList(n),P.endDrawing(),P.dependencyTracker?.restore(),D.restore(),S||C){const e=k.canvas;S&&(A=l),C&&(x=h);const i=this.getSizeAndScale(A,this.ctx.canvas.width,y),n=this.getSizeAndScale(x,this.ctx.canvas.height,w),s=i.size,r=n.size,a=t.cachedCanvases.getCanvas("pattern-workaround",s,r),o=a.context,u=S?Math.floor(g/l):0,p=C?Math.floor(m/h):0;for(let t=0;t<=u;t++)for(let i=0;i<=p;i++)o.drawImage(e,s*t,r*i,s,r,0,0,s,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:n.scale,offsetX:c,offsetY:d}}return{canvas:k.canvas,scaleX:_.scale,scaleY:M.scale,offsetX:c,offsetY:d}}getSizeAndScale(t,e,i){const n=Math.max(Oi.MAX_PATTERN_SIZE,e);let s=Math.ceil(t*i);return s>=n?s=n:i=s/t,{scale:i,size:s}}clipBbox(t,e,i,n,s){const r=n-e,a=s-i;t.ctx.rect(e,i,r,a),ht.axialAlignedBoundingBox([e,i,n,s],Nt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const n=t.ctx,s=t.current;switch(e){case Fi:const{fillStyle:t,strokeStyle:r}=this.ctx;n.fillStyle=s.fillColor=t,n.strokeStyle=s.strokeColor=r;break;case Li:n.fillStyle=n.strokeStyle=i,s.fillColor=s.strokeColor=i;break;default:throw new st(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,n,s){let r=i;n!==_i&&(r=ht.transform(r,e.baseTransform),this.matrix&&(r=ht.transform(r,this.matrix)));const a=this.createPatternCanvas(e,s);let o=new DOMMatrix(r);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}}function Ni({src:t,srcPos:e=0,dest:i,width:n,height:s,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ot.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=n>>3,d=7&n,u=l^h,p=t.length;i=new Uint32Array(i.buffer);let g=0;for(let n=0;n<s;++n){for(const n=e+c;e<n;++e,g+=8){const n=t[e];i[g]=l^-(n>>7&1)&u,i[g+1]=l^-(n>>6&1)&u,i[g+2]=l^-(n>>5&1)&u,i[g+3]=l^-(n>>4&1)&u,i[g+4]=l^-(n>>3&1)&u,i[g+5]=l^-(n>>2&1)&u,i[g+6]=l^-(n>>1&1)&u,i[g+7]=l^-(1&n)&u}if(0===d)continue;const n=e<p?t[e++]:255;for(let t=0;t<d;++t,++g)i[g]=l^-(n>>7-t&1)&u}return{srcPos:e,destPos:g}}const Ui=16;let zi=-1;const Hi="undefined"!=typeof navigator&&(navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")||/\b(iPad|iPhone|iPod)(?=;)/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1),ji=new DOMMatrix,Gi=new Float32Array(2),$i=new Float32Array([1/0,1/0,-1/0,-1/0]);class Vi{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,i)):(n=this.canvasFactory.create(e,i),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Wi(t,e,i,n,s,r,a,o,l,h){const[c,d,u,p,g,m]=Nt(t);if(0===d&&0===u){const f=a*c+g,b=Math.round(f),v=o*p+m,y=Math.round(v),w=(a+l)*c+g,A=Math.abs(Math.round(w)-b)||1,x=(o+h)*p+m,S=Math.abs(Math.round(x)-y)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),b,y),t.drawImage(e,i,n,s,r,0,0,A,S),t.setTransform(c,d,u,p,g,m),[A,S]}if(0===c&&0===p){const f=o*u+g,b=Math.round(f),v=a*d+m,y=Math.round(v),w=(o+h)*u+g,A=Math.abs(Math.round(w)-b)||1,x=(a+l)*d+m,S=Math.abs(Math.round(x)-y)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,b,y),t.drawImage(e,i,n,s,r,0,0,S,A),t.setTransform(c,d,u,p,g,m),[S,A]}t.drawImage(e,i,n,s,r,a,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class Xi{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=s;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=A;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;globalCompositeOperation="source-over";fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,i){i?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=$i.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=Ei,e=null){const i=this.minMax.slice();if(t===Ti){e||X("Stroke bounding box must include transform."),ht.singularValueDecompose2dScale(e,Gi);const t=Gi[0]*this.lineWidth/2,n=Gi[1]*this.lineWidth/2;i[0]-=t,i[1]-=n,i[2]+=t,i[3]+=n}return i}updateClipFromPath(){const t=ht.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set($i,0)}getClippedPathBoundingBox(t=Ei,e=null){return ht.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function qi(t,e,i){const{width:n,height:s,data:r,kind:a}=t,o=new Uint8ClampedArray(e*i*4),l=n/e,h=s/i;if(a===_.RGBA_32BPP)for(let t=0;t<i;t++){const i=Math.floor(t*h);for(let s=0;s<e;s++){const a=4*(i*n+Math.floor(s*l)),h=4*(t*e+s);o[h]=r[a],o[h+1]=r[a+1],o[h+2]=r[a+2],o[h+3]=r[a+3]}}else if(a===_.RGB_24BPP)for(let t=0;t<i;t++){const i=Math.floor(t*h);for(let s=0;s<e;s++){const a=3*(i*n+Math.floor(s*l)),h=4*(t*e+s);o[h]=r[a],o[h+1]=r[a+1],o[h+2]=r[a+2],o[h+3]=255}}else if(a===_.GRAYSCALE_1BPP){const t=n+7>>3;for(let n=0;n<i;n++){const i=Math.floor(n*h);for(let s=0;s<e;s++){const a=Math.floor(s*l),h=4*(n*e+s),c=r[i*t+(a>>3)]&128>>(7&a)?255:0;o[h]=c,o[h+1]=c,o[h+2]=c,o[h+3]=255}}}return new ImageData(o,e,i)}function Ki(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,n=e.width,s=i%Ui,r=(i-s)/Ui,a=0===s?r:r+1,o=t.createImageData(n,Ui);let l,h=0;const c=e.data,d=o.data;let u,p,g,m;if(e.kind===_.GRAYSCALE_1BPP){const e=c.byteLength,i=new Uint32Array(d.buffer,0,d.byteLength>>2),m=i.length,f=n+7>>3,b=4294967295,v=ot.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?Ui:s,l=0,p=0;p<g;p++){const t=e-h;let s=0;const r=t>f?n:8*t-7,a=-8&r;let o=0,d=0;for(;s<a;s+=8)d=c[h++],i[l++]=128&d?b:v,i[l++]=64&d?b:v,i[l++]=32&d?b:v,i[l++]=16&d?b:v,i[l++]=8&d?b:v,i[l++]=4&d?b:v,i[l++]=2&d?b:v,i[l++]=1&d?b:v;for(;s<r;s++)0===o&&(d=c[h++],o=128),i[l++]=d&o?b:v,o>>=1}for(;l<m;)i[l++]=0;t.putImageData(o,0,u*Ui)}}else if(e.kind===_.RGBA_32BPP){for(p=0,m=n*Ui*4,u=0;u<r;u++)d.set(c.subarray(h,h+m)),h+=m,t.putImageData(o,0,p),p+=Ui;u<a&&(m=n*s*4,d.set(c.subarray(h,h+m)),t.putImageData(o,0,p))}else{if(e.kind!==_.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Ui,m=n*g,u=0;u<a;u++){for(u>=r&&(g=s,m=n*g),l=0,p=m;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*Ui)}}}function Yi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,n=e.width,s=i%Ui,r=(i-s)/Ui,a=0===s?r:r+1,o=t.createImageData(n,Ui);let l=0;const h=e.data,c=o.data;for(let e=0;e<a;e++){const i=e<r?Ui:s;({srcPos:l}=Ni({src:h,srcPos:l,dest:c,width:n,height:i,nonBlackColor:0})),t.putImageData(o,0,e*Ui)}}function Ji(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of i)void 0!==t[n]&&(e[n]=t[n]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Qi(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function Zi(t,e){if(e)return!0;ht.singularValueDecompose2dScale(t,Gi);const i=Math.fround(Ht.pixelRatio*xt.PDF_TO_CSS_UNITS);return Gi[0]<=i&&Gi[1]<=i}const tn=["butt","round","square"],en=["miter","round","bevel"],nn={},sn={};class rn{constructor(t,e,i,n,s,{optionalContentConfig:r,markedContentStack:a=null},o,l,h){this.ctx=t,this.current=new Xi(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=i,this.canvasFactory=n,this.filterFactory=s,this.groupStack=[],this.knockoutGroupStack=[],this.knockoutFallbackWarned=!1,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=r,this.cachedCanvases=new Vi(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,this.dependencyTracker=h??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:n=null}){const s=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,s,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",s,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Nt(this.compositeCtx))}this.ctx.save(),Qi(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=Nt(this.ctx)}executeOperatorList(t,e,i,n,s){const r=t.argsArray,a=t.fnArray;let o=e||0;const l=r.length;if(l===o)return o;const h=l-o>10&&"function"==typeof i,c=h?Date.now()+15:0;let d=0;const u=this.commonObjs,p=this.objs;let g,m;for(;;){if(void 0!==n&&o===n.nextBreakPoint)return n.breakIt(o,i),o;if(!s||s(o))if(g=a[o],m=r[o]??null,g!==F.dependency)null===m?this[g](o):this[g](o,...m);else for(const t of m){this.dependencyTracker?.recordNamedData(t,o);const e=t.startsWith("g_")?u:p;if(!e.has(t))return e.get(t,i),o}if(o++,o===l)return o;if(h&&++d>10){if(Date.now()>c)return i(),o;d=0}}}#ts(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#ts(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#es()}#es(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,n=t.height??t.displayHeight;let s,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=n,c="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=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&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),s=this.cachedCanvases.getCanvas(c,e,i),r=s.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=s.canvas,l=e,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){const i=this.ctx,{width:n,height:s}=e,r=this.current.fillColor,a=this.current.patternFill,o=Nt(i);let l,h,c,d;if((e.bitmap||e.data)&&e.count>1){const i=e.bitmap||e.data.buffer;h=JSON.stringify(a?o:[o.slice(0,4),r]),l=this._cachedBitmapsMap.getOrInsertComputed(i,ft);const n=l.get(h);if(n&&!a){const e=Math.round(Math.min(o[0],o[2])+o[4]),i=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Ci),{canvas:n,offsetX:e,offsetY:i}}c=n}c||(d=this.cachedCanvases.getCanvas("maskCanvas",n,s),Yi(d.context,e));let u=ht.transform(o,[1/n,0,0,-1/s,0,0]);u=ht.transform(u,[1,0,0,1,0,-s]);const p=$i.slice();ht.axialAlignedBoundingBox([0,0,n,s],u,p);const[g,m,f,b]=p,v=Math.round(f-g)||1,y=Math.round(b-m)||1,w=this.cachedCanvases.getCanvas("fillCanvas",v,y),A=w.context,x=g,S=m;A.translate(-x,-S),A.transform(...u),c||(c=this._scaleImage(d.canvas,Ut(A)),c=c.img,l&&a&&l.set(h,c)),A.imageSmoothingEnabled=Zi(Nt(A),e.interpolate),Wi(A,c,0,0,c.width,c.height,0,0,n,s),A.globalCompositeOperation="source-in";const C=ht.transform(Ut(A),[1,0,0,1,-x,-S]);return A.fillStyle=a?r.getPattern(i,this,C,Ei,t):r,A.fillRect(0,0,n,s),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(h,w.canvas)),this.dependencyTracker?.recordDependencies(t,Ci),{canvas:w.canvas,offsetX:Math.round(x),offsetY:Math.round(S)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=tn[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=en[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[i,n]of e)switch(i){case"LW":this.setLineWidth(t,n);break;case"LC":this.setLineCap(t,n);break;case"LJ":this.setLineJoin(t,n);break;case"ML":this.setMiterLimit(t,n);break;case"D":this.setDash(t,n[0],n[1]);break;case"RI":this.setRenderingIntent(t,n);break;case"FL":this.setFlatness(t,n);break;case"Font":this.setFont(t,n[0],n[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=n;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.current.fillAlpha=n,this.#is();break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.current.globalCompositeOperation=n,this.#is();break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}#ns(){for(let t=this.knockoutGroupStack.length-1;t>=0;t--)if(this.knockoutGroupStack[t])return!0;return!1}#is(){const t=this.current.globalCompositeOperation||"source-over";if(this.#ns()&&0===this.current.fillAlpha&&"source-over"===t)return this.ctx.globalCompositeOperation="destination-out",void(this.ctx.globalAlpha=1);this.ctx.globalCompositeOperation=t,this.ctx.globalAlpha=this.current.fillAlpha}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,i=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(n,e,i);this.suspendedCtx=this.ctx;const r=this.ctx=s.context;r.setTransform(this.suspendedCtx.getTransform()),Ji(this.suspendedCtx,r),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,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,n,s,r,a){e.transform(t,i,n,s,r,a),this.__originalTransform(t,i,n,s,r,a)},t.setTransform=function(t,i,n,s,r,a){e.setTransform(t,i,n,s,r,a),this.__originalSetTransform(t,i,n,s,r,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,n,s,r,a){e.bezierCurveTo(t,i,n,s,r,a),this.__originalBezierCurveTo(t,i,n,s,r,a)},t.rect=function(t,i,n,s){e.rect(t,i,n,s),this.__originalRect(t,i,n,s)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ji(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;Hi?this.composeSMaskSafari(i,e,this.ctx,t):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()}composeSMask(t,e,i,n){const s=n[0],r=n[1],a=n[2]-s,o=n[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,s,r,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,n,s,r,a,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(r)if(u<0||p<0||u+i>d.width||p+n>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,n),e=t.context;e.drawImage(d,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,n),e.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,i,n),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(u,p,i,n),t.restore()}(a||"Luminosity"===s)&&this.#ss(d,u,p,i,n,s,a),e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const g=new Path2D;g.rect(o,l,i,n),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,i,n,o,l,i,n),e.restore()}#ss(t,e,i,n,s,r,a){const o=t.getContext("2d"),l=o.getImageData(e,i,n,s),h=l.data;if("Luminosity"===r)for(let t=0;t<h.length;t+=4){let e=Math.round(.3*h[t]+.59*h[t+1]+.11*h[t+2]);a&&(e=a[e]),h[t]=h[t+1]=h[t+2]=255,h[t+3]=e}else if(a)for(let t=3;t<h.length;t+=4)h[t]=a[h[t]];o.putImageData(l,e,i)}composeSMaskSafari(t,e,i,n){const s=n[0],r=n[1],a=n[2]-s,o=n[3]-r;0!==a&&0!==o&&(this.genericComposeSMaskSafari(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,s,r,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())}composeSMaskBackdropSafari(t,e,i,n){const s=t.length;for(let r=3;r<s;r+=4){const s=t[r];if(0===s)t[r-3]=e,t[r-2]=i,t[r-1]=n;else if(s<255){const a=255-s;t[r-3]=t[r-3]*s+e*a>>8,t[r-2]=t[r-2]*s+i*a>>8,t[r-1]=t[r-1]*s+n*a>>8}}}composeSMaskAlphaSafari(t,e,i){const n=t.length;for(let s=3;s<n;s+=4){const n=i?i[t[s]]:t[s];e[s]=e[s]*n*.00392156862745098|0}}composeSMaskLuminositySafari(t,e,i){const n=t.length;for(let s=3;s<n;s+=4){const n=77*t[s-3]+152*t[s-2]+28*t[s-1];e[s]=i?e[s]*i[n>>8]>>8:e[s]*n>>16}}genericComposeSMaskSafari(t,e,i,n,s,r,a,o,l,h,c){const d=!!r,u=d?r[0]:0,p=d?r[1]:0,g=d?r[2]:0,m="Luminosity"===s?this.composeSMaskLuminositySafari:this.composeSMaskAlphaSafari,f=Math.min(n,Math.ceil(1048576/i));for(let s=0;s<n;s+=f){const r=Math.min(f,n-s),b=t.getImageData(o-h,s+(l-c),i,r),v=e.getImageData(o,s+l,i,r);d&&this.composeSMaskBackdropSafari(b.data,u,p,g),m.call(this,b.data,v.data,a),e.putImageData(v,o,s+l)}}save(t){this.inSMaskMode&&Ji(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){this.dependencyTracker?.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Ji(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,n,s,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,n,s,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,n){let[s]=i;if(!n)return s||=i[0]=new Path2D,void this[e](t,s);if(null!==this.dependencyTracker){const i=e===F.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-i,n[2]+i,n[1]-i,n[3]+i).recordDependencies(t,["transform"])}s instanceof Path2D||(s=i[0]=Zt(s)),ht.axialAlignedBoundingBox(n,Nt(this.ctx),this.current.minMax),this[e](t,s),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){const n=this.ctx,s=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const i=s.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=s.getPattern(n,this,Ut(n),Ti,t),i){const t=new Path2D;t.addPath(e,n.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,vi),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Ti,Nt(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){const n=this.ctx,s=this.current.fillColor;let r=!1;if(this.current.patternFill){const i=s.isModifyingCurrentTransform()?n.getTransform():null;if(this.dependencyTracker?.save(t),n.save(),n.fillStyle=s.getPattern(n,this,Ut(n),Ei,t),i){const t=new Path2D;t.addPath(e,n.getTransform().invertSelf().multiplySelf(i)),e=t}r=!0}const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),this.dependencyTracker?.recordDependencies(t,yi),r&&(n.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,a)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Ai).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=nn}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=sn}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){const t=new Path2D,n=i.getTransform().invertSelf();for(const{transform:i,x:s,y:r,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(n).translate(s,r).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||s,0!==r.fontMatrix[0]&&0!==r.fontMatrix[3]||W("Invalid font matrix for font "+e),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=i,n.isType3Font)return;const a=n.loadedName||"sans-serif",o=n.systemFontInfo?.css||`"${a}", ${n.fallbackName}`;let l="normal";n.black?l="900":n.bold&&(l="bold");const h=n.italic?"italic":"normal";let c=i;i<16?c=16:i>100&&(c=100),this.current.fontSizeScale=i/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#rs(t,e,i){const n=new Path2D;return n.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),n}paintChar(t,e,i,n,s,r){const a=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,d=h&E,u=!!(h&T),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;let m;if((l.disableFontFace||u||p||g)&&!l.missingFile&&(m=l.getPathGenerator(this.commonObjs,e)),m&&(l.disableFontFace||p||g)){let e;if(a.save(),a.translate(i,n),a.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,a,l),d===A||d===S)if(s){e=a.getTransform(),a.setTransform(...s);const t=this.#rs(m,e,s);a.fill(t)}else a.fill(m);if(d===x||d===S)if(r){e||=a.getTransform(),a.setTransform(...r);const{a:t,b:i,c:n,d:s}=e,o=ht.inverseTransform(r),l=ht.transform([t,i,n,s,0,0],o);ht.singularValueDecompose2dScale(l,Gi),a.lineWidth*=Math.max(Gi[0],Gi[1])/c,a.stroke(this.#rs(m,e,r))}else a.lineWidth/=c,a.stroke(m);a.restore()}else d!==A&&d!==S||(a.fillText(e,i,n),this.dependencyTracker?.recordCharacterBBox(t,a,l,c,i,n,(()=>a.measureText(e)))),d!==x&&d!==S||(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,l,c,i,n,(()=>a.measureText(e))).recordDependencies(t,vi),a.strokeText(e,i,n));if(u){(this.pendingTextPaths||=[]).push({transform:Nt(a),x:i,y:n,fontSize:c,path:m}),this.dependencyTracker?.recordCharacterBBox(t,a,l,c,i,n)}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return Q(this,"isFontSubpixelAAEnabled",i)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,xi).resetBBox(t),this.current.textRenderingMode&T&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const i=this.current,n=i.font;if(n.isType3Font)return this.showType3Text(t,e),void this.dependencyTracker?.recordShowTextOperation(t);const s=i.fontSize;if(0===s)return void this.dependencyTracker?.recordOperation(t);const r=this.ctx,a=i.fontSizeScale,o=i.charSpacing,l=i.wordSpacing,h=i.fontDirection,c=i.textHScale*h,d=e.length,u=n.vertical,p=u?1:-1,g=n.defaultVMetrics,m=s*i.fontMatrix[0],f=i.textRenderingMode===A&&!n.disableFontFace&&!i.patternFill;let b,v;r.save(),i.textMatrix&&r.transform(...i.textMatrix),r.translate(i.x,i.y+i.textRise),h>0?r.scale(c,-1):r.scale(c,1);const y=i.textRenderingMode&E,w=y===x||y===S;if((y===A||y===S)&&i.patternFill){r.save();const e=i.fillColor.getPattern(r,this,Ut(r),Ei,t);b=Nt(r),r.restore(),r.fillStyle=e}if(w&&i.patternStroke){r.save();const e=i.strokeColor.getPattern(r,this,Ut(r),Ti,t);v=Nt(r),r.restore(),r.strokeStyle=e}let C=i.lineWidth;const _=i.textMatrixScale;if(0===_||0===C?w&&(C=this.getSinglePixelWidth()):C/=_,1!==a&&(r.scale(a,a),C/=a),r.lineWidth=C,n.isInvalidPDFjsFont){const n=[];let s=0;for(const t of e)n.push(t.unicode),s+=t.width;const a=n.join("");if(r.fillText(a,0,0),null!==this.dependencyTracker){const e=r.measureText(a);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}return i.x+=s*m*c,r.restore(),void this.compose()}const M="undefined"!=typeof navigator&&!ot.platform.isFirefox&&/Chrome|CriOS/.test(navigator.userAgent)&&(ot.platform.isMac||/\b(iPad|iPhone|iPod)(?=;)/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1);let k,D=0;for(k=0;k<d;++k){const i=e[k];if("number"==typeof i){D+=p*i*s/1e3;continue}let c=!1;const d=(i.isSpace?l:0)+o,y=i.fontChar,w=i.accent;let A,x,S,C=i.width;if(u){const t=i.vmetric||g,e=-(i.vmetric?t[1]:.5*C)*m,n=t[2]*m;C=t?-t[0]:C,A=e/a,x=(D+n)/a}else A=D/a,x=0;if(n.remeasure&&C>0){S=r.measureText(y);const t=1e3*S.width/s*a;if(C<t&&this.isFontSubpixelAAEnabled&&!M){const e=C/t;c=!0,r.save(),r.scale(e,1),A/=e}else C!==t&&(A+=(C-t)/2e3*s/a)}if(this.contentVisible&&(i.isInFont||n.missingFile))if(f&&!w)r.fillText(y,A,x),this.dependencyTracker?.recordCharacterBBox(t,r,S?{bbox:null}:n,s/a,A,x,(()=>S??r.measureText(y)));else if(this.paintChar(t,y,A,x,b,v),w){const e=A+s*w.offset.x/a,i=x-s*w.offset.y/a;this.paintChar(t,w.fontChar,e,i,b,v)}D+=u?C*m-d*h:C*m+d*h,c&&r.restore()}u?i.y-=D:i.x+=D*c,r.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){const i=this.ctx,n=this.current,r=n.font,a=n.fontSize,o=n.fontDirection,l=r.vertical?1:-1,h=n.charSpacing,c=n.wordSpacing,d=n.textHScale*o,u=n.fontMatrix||s,p=e.length;let g,m,f,b;if(n.textRenderingMode===C||0===a)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),n.textMatrix&&i.transform(...n.textMatrix),i.translate(n.x,n.y+n.textRise),i.scale(d,o);const v=this.dependencyTracker;for(this.dependencyTracker=v?new bi(v,t):null,g=0;g<p;++g){if(m=e[g],"number"==typeof m){b=l*m*a/1e3,this.ctx.translate(b,0),n.x+=b*d;continue}const t=(m.isSpace?c:0)+h,s=r.charProcOperatorList[m.operatorListId];s?this.contentVisible&&(this.save(),i.scale(a,a),i.transform(...u),this.executeOperatorList(s),this.restore()):W(`Type3 character "${m.operatorListId}" is not available.`);const o=[m.width,0];ht.applyTransform(o,u),f=o[0]*a+t,i.translate(f,0),n.x+=f*d}i.restore(),v&&(this.dependencyTracker=v)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,n,s,r,a){const o=new Path2D;o.rect(n,s,r-n,a-s),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,n,r,s,a).recordClipBox(t,this.ctx,n,r,s,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){const t=this.baseTransform||Nt(this.ctx),n={createCanvasGraphics:(t,e)=>new rn(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new bi(this.dependencyTracker,e,!0):null)};i=new Oi(e,this.ctx,n,t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(t){switch(t[0]){case"RadialAxial":return new Di(t);case"Mesh":return new Ri(t);case"Dummy":return new Bi}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,n)),i&&(n.matrix=i),n}shadingFill(t,e){if(!this.contentVisible)return;const i=this.ctx;this.save(t);const n=this._getPattern(t,e);i.fillStyle=n.getPattern(i,this,Ut(i),_i,t);const s=Ut(i);if(s){const{width:t,height:e}=i.canvas,n=$i.slice();ht.axialAlignedBoundingBox([0,0,t,e],s,n);const[r,a,o,l]=n;this.ctx.fillRect(r,a,o-r,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Si).recordDependencies(t,yi).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){X("Should not call beginInlineImage")}beginImageData(){X("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Nt(this.ctx),i)){ht.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,n,s,r]=i,a=new Path2D;a.rect(e,n,s-e,r-n),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,s,n,r),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;e.isolated||V("TODO: Support non-isolated groups."),this.knockoutGroupStack.push(!!e.knockout),e.knockout&&!this.knockoutFallbackWarned&&(this.knockoutFallbackWarned=!0,W("Knockout group fallback enabled."));const n=Nt(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let s=$i.slice();ht.axialAlignedBoundingBox(e.bbox,Nt(i),s);const r=[0,0,i.canvas.width,i.canvas.height];s=ht.intersect(s,r)||[0,0,0,0];const a=Math.floor(s[0]),o=Math.floor(s[1]),l=Math.max(Math.ceil(s[2])-a,1),h=Math.max(Math.ceil(s[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let c="groupAt"+this.groupLevel;e.smask&&(c+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(c,l,h),u=d.context;u.translate(-a,-o),u.transform(...n);let p=new Path2D;const[g,m,f,b]=e.bbox;if(p.rect(g,m,f-g,b-m),e.matrix){const t=new Path2D;t.addPath(p,new DOMMatrix(e.matrix)),p=t}u.clip(p),e.smask&&this.smaskStack.push({canvas:d.canvas,context:u,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),e.smask&&!this.dependencyTracker||(i.setTransform(1,0,0,1,0,0),i.translate(a,o),i.save()),Ji(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--,this.knockoutGroupStack.pop();const i=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const e=Nt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);const n=$i.slice();ht.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,n),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,i,n,s,r){if(this.#ts(),Qi(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const s=i[2]-i[0],a=i[3]-i[1];if(r&&this.annotationCanvasMap){(n=n.slice())[4]-=i[0],n[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=s,i[3]=a,ht.singularValueDecompose2dScale(Nt(this.ctx),Gi);const{viewportScale:t}=this,r=Math.ceil(s*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Gi[0],0,0,-Gi[1],0,a*Gi[1]),Qi(this.ctx)}else{Qi(this.ctx),this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],s,a),this.ctx.clip(e)}}this.current=new Xi(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...n),this.transform(t,...s)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#es(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const i=e.count;(e=this.getObject(t,e.data,e)).count=i;const n=this.ctx,s=this._createMaskCanvas(t,e),r=s.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(r,s.offsetX,s.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,s.offsetX,s.offsetX+r.width,s.offsetY,s.offsetY+r.height).recordOperation(t),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,n=0,s=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.ctx;o.save();const l=Nt(o);o.transform(i,n,s,r,0,0);const h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,c=a.length;e<c;e+=2){const c=ht.transform(l,[i,n,s,r,a[e],a[e+1]]);o.drawImage(h.canvas,c[4],c[5]),this.dependencyTracker?.recordBBox(t,this.ctx,c[4],c[4]+h.canvas.width,c[5],c[5]+h.canvas.height)}o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx,n=this.current.fillColor,s=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Ci);for(const r of e){const{data:e,width:a,height:o,transform:l}=r,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),c=h.context;c.save();Yi(c,this.getObject(t,e,r)),c.globalCompositeOperation="source-in",c.fillStyle=s?n.getPattern(c,this,Ut(i),Ei,t):n,c.fillRect(0,0,a,o),c.restore(),i.save(),i.transform(...l),i.scale(1,-1),Wi(i,h.canvas,0,0,a,o,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,a,0,o),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):W("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,n,s){if(!this.contentVisible)return;const r=this.getObject(t,e);if(!r)return void W("Dependent image isn't ready yet");const a=r.width,o=r.height,l=[];for(let t=0,e=s.length;t<e;t+=2)l.push({transform:[i,0,0,n,s[t],s[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}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;const{bitmap:e,width:i,height:n}=t,s=this.cachedCanvases.getCanvas("inlineImage",i,n),r=s.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",s.canvas}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const i=e.width,n=e.height,s=this.ctx;this.save(t);const{filter:r}=s;let a;if("none"!==r&&""!==r&&(s.filter="none"),s.scale(1/i,-1/n),e.bitmap)a=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)a=e;else if(zi>0&&i*n>zi){const t=Math.sqrt(zi/(i*n)),s=Math.max(1,Math.floor(i*t)),r=Math.max(1,Math.floor(n*t)),o=this.cachedCanvases.getCanvas("inlineImage",s,r).context;o.putImageData(qi(e,s,r),0,0),a=this.applyTransferMapsToCanvas(o)}else{const t=this.cachedCanvases.getCanvas("inlineImage",i,n).context;Ki(t,e),a=this.applyTransferMapsToCanvas(t)}const o=this._scaleImage(a,Ut(s));s.imageSmoothingEnabled=Zi(Nt(s),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,s,0,i,-n,0).recordDependencies(t,wi).recordOperation(t),Wi(s,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,i,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){if(!this.contentVisible)return;const n=this.ctx;let s;if(e.bitmap)s=e.bitmap;else{const t=e.width,i=e.height;if(zi>0&&t*i>zi){const n=Math.sqrt(zi/(t*i)),r=Math.max(1,Math.floor(t*n)),a=Math.max(1,Math.floor(i*n)),o=this.cachedCanvases.getCanvas("inlineImage",r,a).context;o.putImageData(qi(e,r,a),0,0),s=this.applyTransferMapsToCanvas(o)}else{const n=this.cachedCanvases.getCanvas("inlineImage",t,i).context;Ki(n,e),s=this.applyTransferMapsToCanvas(n)}}this.dependencyTracker?.resetBBox(t);for(const e of i)n.save(),n.transform(...e.transform),n.scale(1,-1),Wi(n,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,yi).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const s=this.ctx;this.pendingClip?(n||(this.pendingClip===sn?s.clip(e,"evenodd"):s.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Nt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:n,d:s}=this.ctx.getTransform();let r,a;if(0===i&&0===n){const i=Math.abs(e),n=Math.abs(s);if(i===n)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/n;else{const e=i*t,s=n*t;r=e<1?1/e:1,a=s<1?1/s:1}}else{const o=Math.abs(e*s-i*n),l=Math.hypot(e,i),h=Math.hypot(n,s);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:n}}=this,[s,r]=this.getScaleForStroking();if(s===r)return i.lineWidth=(n||1)*s,void i.stroke(t);const a=i.getLineDash();e&&i.save(),i.scale(s,r),ji.a=1/s,ji.d=1/r;const o=new Path2D;if(o.addPath(t,ji),a.length>0){const t=Math.max(s,r);i.setLineDash(a.map((e=>e/t))),i.lineDashOffset/=t}i.lineWidth=n||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in F)void 0!==rn.prototype[t]&&(rn.prototype[F[t]]=rn.prototype[t]);class an{static#as=null;static#os="";static get workerPort(){return this.#as}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#as=t}static get workerSrc(){return this.#os}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#os=t}}class on{#ls;#hs;constructor({parsedData:t,rawData:e}){this.#ls=t,this.#hs=e}getRaw(){return this.#hs}get(t){return this.#ls.get(t)??null}[Symbol.iterator](){return this.#ls.entries()}}const ln=Symbol("INTERNAL");class hn{#cs=!1;#ds=!1;#us=!1;#ps=!0;constructor(t,{name:e,intent:i,usage:n,rbGroups:s}){this.#cs=!!(t&o),this.#ds=!!(t&l),this.name=e,this.intent=i,this.usage=n,this.rbGroups=s}get visible(){if(this.#us)return this.#ps;if(!this.#ps)return!1;const{print:t,view:e}=this.usage;return this.#cs?"OFF"!==e?.viewState:!this.#ds||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==ln&&X("Internal method `_setVisible` called."),this.#us=i,this.#ps=e}}class cn{#gs=null;#ms=new Map;#fs=null;#bs=null;constructor(t,e=o){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#bs=t.order;for(const i of t.groups)this.#ms.set(i.id,new hn(e,i));if("OFF"===t.baseState)for(const t of this.#ms.values())t._setVisible(ln,!1);for(const e of t.on)this.#ms.get(e)._setVisible(ln,!0);for(const e of t.off)this.#ms.get(e)._setVisible(ln,!1);this.#fs=this.getHash()}}#vs(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let n=1;n<e;n++){const e=t[n];let s;if(Array.isArray(e))s=this.#vs(e);else{if(!this.#ms.has(e))return W(`Optional content group not found: ${e}`),!0;s=this.#ms.get(e).visible}switch(i){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return"And"===i}isVisible(t){if(0===this.#ms.size)return!0;if(!t)return V("Optional content group not defined."),!0;if("OCG"===t.type)return this.#ms.has(t.id)?this.#ms.get(t.id).visible:(W(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#vs(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#ms.has(e))return W(`Optional content group not found: ${e}`),!0;if(this.#ms.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#ms.has(e))return W(`Optional content group not found: ${e}`),!0;if(!this.#ms.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#ms.has(e))return W(`Optional content group not found: ${e}`),!0;if(!this.#ms.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#ms.has(e))return W(`Optional content group not found: ${e}`),!0;if(this.#ms.get(e).visible)return!1}return!0}return W(`Unknown optional content policy ${t.policy}.`),!0}return W(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const n=this.#ms.get(t);if(n){if(i&&e&&n.rbGroups.length)for(const e of n.rbGroups)for(const i of e)i!==t&&this.#ms.get(i)?._setVisible(ln,!1,!0);n._setVisible(ln,!!e,!0),this.#gs=null}else W(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":i=n;continue}const t=this.#ms.get(n);if(t)switch(i){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!t.visible,e)}}this.#gs=null}get hasInitialVisibility(){return null===this.#fs||this.getHash()===this.#fs}getOrder(){return this.#ms.size?this.#bs?this.#bs.slice():[...this.#ms.keys()]:null}getGroup(t){return this.#ms.get(t)||null}getHash(){if(null!==this.#gs)return this.#gs;const t=new ye;for(const[e,i]of this.#ms)t.update(`${e}:${i.visible}`);return this.#gs=t.hexdigest()}[Symbol.iterator](){return this.#ms.entries()}}i(116);class dn{#ys=null;#ws=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#ys=e,this.#ws=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return q(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#ys(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new this.#ws(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){this._fullReader?.cancel(t);for(const e of new Set(this._rangeReaders))e.cancel(t)}}class un{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){X("Abstract method `read` called")}cancel(t){X("Abstract method `cancel` called")}}class pn{_stream=null;constructor(t,e,i){this._stream=t}async read(){X("Abstract method `read` called")}cancel(t){X("Abstract method `cancel` called")}}function gn(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function mn(){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class fn extends dn{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,bn,vn);const{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:n}=e;if(i?.length>0){const t=gn(i);this._queuedChunks.push(t)}this._progressiveDone=n,e.addRangeListener(((t,e)=>{this.#As(t,e)})),e.addProgressiveReadListener((t=>{this.#As(void 0,t)})),e.addProgressiveDoneListener((()=>{this._fullReader?.progressiveDone(),this._progressiveDone=!0})),e.transportReady()}#As(t,e){const i=gn(e);if(void 0===t)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const e=this._rangeReaders.keys().find((e=>e._begin===t));q(e,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),e._enqueue(i)}}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class bn extends un{#xs=mn.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:i,disableStream:n}=t._source,{length:s,contentDispositionFilename:r}=e;this._queuedChunks=t._queuedChunks||[];for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._done=t._progressiveDone,this._contentLength=s,this._isStreamingSupported=!n,this._isRangeSupported=!i,_t(r)&&(this._filename=r),this._headersCapability.resolve();const a=this._loaded;Promise.resolve().then((()=>{a>0&&this._loaded===a&&this._callOnProgress()}))}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength,this._callOnProgress()}}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#xs()}progressiveDone(){this._done||=!0,0===this._queuedChunks.length&&this.#xs()}}class vn extends pn{#xs=mn.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1}),this.#xs()}this._done=!0,this.onDone?.()}}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#xs(),this.onDone?.()}}function yn(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const n=e[t];void 0!==n&&i.append(t,n)}return i}function wn(t){return URL.parse(t)?.origin??null}function An({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:n}){const s={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return s;if(s.suggestedLength=r,r<=2*i)return s;if(n||!e)return s;if("bytes"!==t.get("Accept-Ranges"))return s;return"identity"!==(t.get("Content-Encoding")||"identity")||(s.allowRangeRequests=!0),s}function xn(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=n("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const s=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=s.exec(t));){let[,t,n,s]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[n,s]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,n]=e[t];n=a(n),i&&(n=unescape(n),0===t&&(n=o(n))),r.push(n)}return r.join("")}(t),i)return r(l(i));if(i=n("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function n(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const n=new TextDecoder(t,{fatal:!0}),s=at(i);i=n.decode(s),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const 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){const e=t.indexOf("'");return-1===e?t:s(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,n){if("q"===i||"Q"===i)return s(e,n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{n=atob(n)}catch{}return s(e,n)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(_t(t))return t}return null}function Sn(t,e){return new nt(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,404===t||0===t&&"file:"===e.protocol)}function Cn(t,e){if(t!==e)throw new Error(`Expected range response-origin "${t}" to match "${e}".`)}function En(t,e,i,n){return fetch(t,{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function Tn(t,e){if(200!==t&&206!==t)throw Sn(t,e)}function _n(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw new Error(`getArrayBuffer - unexpected data: ${t}`)}class Mn extends dn{_responseOrigin=null;constructor(t){super(t,kn,Dn);const{httpHeaders:e,url:i}=t;q(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=yn(!0,e)}}class kn extends un{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,length:n,rangeChunkSize:s,url:r,withCredentials:a}=t._source;this._contentLength=n,this._isStreamingSupported=!i,this._isRangeSupported=!e;const o=new Headers(t.headers);En(r,o,a,this._abortController).then((i=>{t._responseOrigin=wn(i.url),Tn(i.status,r),this._reader=i.body.getReader();const n=i.headers,{allowRangeRequests:a,suggestedLength:o}=An({responseHeaders:n,isHttp:!0,rangeChunkSize:s,disableRange:e});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=xn(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new rt("Streaming is disabled.")),this._headersCapability.resolve()})).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:_n(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Dn extends pn{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:n,withCredentials:s}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`),En(n,r,s,this._abortController).then((e=>{Cn(wn(e.url),t._responseOrigin),Tn(e.status,n),this._reader=e.body.getReader(),this._readCapability.resolve()})).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:_n(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Pn extends dn{#Ss=new WeakMap;_responseOrigin=null;constructor(t){super(t,In,Rn);const{httpHeaders:e,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=yn(this.isHttp,e)}_request(t){const e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#Ss.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.validateStatus=t=>206===t||200===t):i.validateStatus=t=>200===t,e.responseType="arraybuffer",q(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#Cs.bind(this,e),e.onprogress=this.#Es.bind(this,e),e.send(null),e}#Es(t,e){this.#Ss.get(t)?.onProgress?.(e)}#Cs(t,e){const i=this.#Ss.get(t);if(!i)return;if(t.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==t.readyState)return;if(!this.#Ss.has(t))return;if(this.#Ss.delete(t),0===t.status&&this.isHttp)return void i.onError(t.status);const n=t.status||200;if(!i.validateStatus(n))return void i.onError(t.status);const s="string"!=typeof(r=t.response)?r:at(r).buffer;var r;if(206===n){const e=t.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(e)?i.onDone(s):(W('Missing or invalid "Content-Range" header.'),i.onError(0))}else s?i.onDone(s):i.onError(t.status)}_abortRequest(t){this.#Ss.has(t)&&(this.#Ss.delete(t),t.abort())}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class In extends un{#xs=mn.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t);const{length:e}=t._source;this._contentLength=e,this._fullRequestXhr=t._request({onHeadersReceived:this.#Ts.bind(this),onDone:this.#_s.bind(this),onError:this.#Ms.bind(this),onProgress:this.#Es.bind(this)})}#Ts(){const t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,n=this._fullRequestXhr;t._responseOrigin=wn(n.responseURL);const s=n.getAllResponseHeaders(),r=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:a,suggestedLength:o}=An({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});a&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=xn(r),this._isRangeSupported&&t._abortRequest(n),this._headersCapability.resolve()}#_s(t){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._cachedChunks.push(t);this._done=!0,0===this._cachedChunks.length&&this.#xs()}#Ms(t){this._storedError=Sn(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#Es(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#xs(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class Rn extends pn{#xs=mn.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#Ts.bind(this),onDone:this.#_s.bind(this),onError:this.#Ms.bind(this),onProgress:null})}#Ts(){const t=wn(this._requestXhr?.responseURL);try{Cn(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#Ms(0)}}#_s(t){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunk=t;this._done=!0,this.#xs(),this.onClosed?.()}#Ms(t){this._storedError??=Sn(t,this._stream.url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#xs(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function Bn(t){const{Readable:e}=process.getBuiltinModule("stream");if("function"==typeof e.toWeb)return e.toWeb(t);return process.getBuiltinModule("module").createRequire(import.meta.url)("node-readable-to-web-readable-stream").makeDefaultReadableStreamFromNodeReadable(t)}class Fn extends dn{constructor(t){super(t,Ln,On);const{url:e}=t;q("file:"===e.protocol,"PDFNodeStream only supports file:// URLs.")}}class Ln extends un{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,length:n,rangeChunkSize:s,url:r}=t._source;this._contentLength=n,this._isStreamingSupported=!i,this._isRangeSupported=!e;const a=process.getBuiltinModule("fs");a.promises.lstat(r).then((t=>{const e=Bn(a.createReadStream(r));this._reader=e.getReader();const{size:i}=t;i<=2*s&&(this._isRangeSupported=!1),this._contentLength=i,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new rt("Streaming is disabled.")),this._headersCapability.resolve()})).catch((t=>{"ENOENT"===t.code&&(t=Sn(0,r)),this._headersCapability.reject(t)}))}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:_n(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class On extends pn{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:n}=t._source,s=process.getBuiltinModule("fs");try{const t=Bn(s.createReadStream(n,{start:e,end:i-1}));this._reader=t.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:_n(t),done:!1}}cancel(t){this._reader?.cancel(t)}}const Nn=Symbol("INITIAL_DATA"),Un=()=>({...Promise.withResolvers(),data:Nn});class zn{#ks=new Map;#Ds(t){return this.#ks.getOrInsertComputed(t,Un)}get(t,e=null){if(e){const i=this.#Ds(t);return i.promise.then((()=>e(i.data))),null}const i=this.#ks.get(t);if(!i||i.data===Nn)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#ks.get(t);return!!e&&e.data!==Nn}delete(t){const e=this.#ks.get(t);return!(!e||e.data===Nn)&&(this.#ks.delete(t),!0)}resolve(t,e=null){const i=this.#Ds(t);i.data=e,i.resolve()}clear(){for(const{data:t}of this.#ks.values())t?.bitmap?.close();this.#ks.clear()}*[Symbol.iterator](){for(const[t,{data:e}]of this.#ks)e!==Nn&&(yield[t,e])}}class Hn{#Ps=Promise.withResolvers();#Ot=null;#Is=!1;#Rs=!!globalThis.FontInspector?.enabled;#Bs=null;#Fs=null;#Ls=0;#Os=0;#Ns=null;#Us=null;#zs=0;#Hs=0;#js=Object.create(null);#Gs=[];#$s=null;#Vs=[];#Ws=new WeakMap;#Xs=null;static#qs=new Map;static#Ks=new Map;static#Ys=new WeakMap;static#Js=null;static#Qs=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#$s=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#$s=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#Ot=this.#Us=e,this.#Hs=i.scale*Ht.pixelRatio,this.#zs=i.rotation,this.#Fs={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:s,pageX:r,pageY:a}=i.rawDims;this.#Xs=[1,0,0,-1,-r,a+s],this.#Os=n,this.#Ls=s,Hn.#Zs(),e.style.setProperty("--min-font-size",Hn.#Js),zt(e,i),this.#Ps.promise.finally((()=>{Hn.#Qs.delete(this),this.#Fs=null,this.#js=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ot.platform;return Q(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#Ns.read().then((({value:e,done:i})=>{i?this.#Ps.resolve():(this.#Bs??=e.lang,Object.assign(this.#js,e.styles),this.#tr(e.items),t())}),this.#Ps.reject)};return this.#Ns=this.#$s.getReader(),Hn.#Qs.add(this),t(),this.#Ps.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*Ht.pixelRatio,n=t.rotation;if(n!==this.#zs&&(e?.(),this.#zs=n,zt(this.#Us,{rotation:n})),i!==this.#Hs){e?.(),this.#Hs=i;const t={div:null,properties:null,ctx:Hn.#er(this.#Bs)};for(const e of this.#Vs)t.properties=this.#Ws.get(e),t.div=e,this.#ir(t)}}cancel(){const t=new rt("TextLayer task cancelled.");this.#Ns?.cancel(t).catch((()=>{})),this.#Ns=null,this.#Ps.reject(t)}get textDivs(){return this.#Vs}get textContentItemsStr(){return this.#Gs}#tr(t){if(this.#Is)return;this.#Fs.ctx??=Hn.#er(this.#Bs);const e=this.#Vs,i=this.#Gs;for(const n of t){if(e.length>1e5)return W("Ignoring additional textDivs for performance reasons."),void(this.#Is=!0);if(void 0!==n.str)i.push(n.str),this.#nr(n);else if("beginMarkedContentProps"===n.type||"beginMarkedContent"===n.type){const t=this.#Ot;this.#Ot=document.createElement("span"),this.#Ot.classList.add("markedContent"),n.id&&this.#Ot.setAttribute("id",`${n.id}`),"Artifact"===n.tag&&(this.#Ot.ariaHidden=!0),t.append(this.#Ot)}else"endMarkedContent"===n.type&&(this.#Ot=this.#Ot.parentNode)}}#nr(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#Vs.push(e);const n=ht.transform(this.#Xs,t.transform);let s=Math.atan2(n[1],n[0]);const r=this.#js[t.fontName];r.vertical&&(s+=Math.PI/2);let a=this.#Rs&&r.fontSubstitution||r.fontFamily;a=Hn.fontFamilyMap.get(a)||a;const o=Math.hypot(n[2],n[3]),l=o*Hn.#sr(a,r,this.#Bs);let h,c;0===s?(h=n[4],c=n[5]-l):(h=n[4]+l*Math.sin(s),c=n[5]-l*Math.cos(s));const d=e.style;d.left=`${(100*h/this.#Os).toFixed(2)}%`,d.top=`${(100*c/this.#Ls).toFixed(2)}%`,d.setProperty("--font-height",`${o.toFixed(2)}px`),d.fontFamily=a,i.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Rs&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==s&&(i.angle=s*(180/Math.PI));let u=!1;if(t.str.length>1)u=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(u=!0)}if(u&&(i.canvasWidth=r.vertical?t.height:t.width),this.#Ws.set(e,i),this.#Fs.div=e,this.#Fs.properties=i,this.#ir(this.#Fs),i.hasText&&this.#Ot.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#Ot.append(t)}}#ir(t){const{div:e,properties:i,ctx:n}=t,{style:s}=e;if(0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=s,{canvasWidth:r,fontSize:a}=i;Hn.#rr(n,a*this.#Hs,t);const{width:o}=n.measureText(e.textContent);o>0&&s.setProperty("--scale-x",r*this.#Hs/o)}0!==i.angle&&s.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#Qs.size>0)){this.#qs.clear();for(const{canvas:t}of this.#Ks.values())t.remove();this.#Ks.clear()}}static#er(t=null){let e=this.#Ks.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Ks.set(t,e),this.#Ys.set(e,{size:0,family:""})}return e}static#rr(t,e,i){const n=this.#Ys.get(t);e===n.size&&i===n.family||(t.font=`${e}px ${i}`,n.size=e,n.family=i)}static#Zs(){if(null!==this.#Js)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#Js=t.getBoundingClientRect().height,t.remove()}static#sr(t,e,i){const n=this.#qs.get(t);if(n)return n;const s=this.#er(i);s.canvas.width=s.canvas.height=30,this.#rr(s,30,t);const r=s.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let l=.8;return a?l=a/(a+o):(ot.platform.isFirefox&&W("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#qs.set(t,l),l}}function jn(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Gn,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t;if("string"==typeof t){if(n){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}const e=URL.parse(t,window.location);if(e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,r=t.data?function(t){if(n&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return at(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,o=!0===t.withCredentials,l=t.password??null,h=t.range instanceof $n?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let d=t.worker instanceof Xn?t.worker:null;const u=t.verbosity,p="string"!=typeof t.docBaseUrl||Tt(t.docBaseUrl)?null:t.docBaseUrl,g=De(t.cMapUrl),m=!1!==t.cMapPacked,f=t.CMapReaderFactory||(n?ai:Ye),b=De(t.iccUrl),v=De(t.standardFontDataUrl),y=t.StandardFontDataFactory||(n?oi:ti),w=De(t.wasmUrl),A=t.WasmFactory||(n?li:ii),x=!0!==t.stopAtErrors,S=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,C=!1!==t.isEvalSupported,E="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!n,T="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!n&&(ot.platform.isFirefox||!globalThis.chrome),_=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1;_>0&&(zi=_>>2);const M="boolean"==typeof t.disableFontFace?t.disableFontFace:n,k=!0===t.fontExtraProperties,D=!0===t.enableXfa,P=t.ownerDocument||globalThis.document,I=!0===t.disableRange,R=!0===t.disableStream,B=!0===t.disableAutoFetch,F=!0===t.pdfBug,L=t.CanvasFactory||(n?ri:qe),O=t.FilterFactory||(n?si:Qe),N=!0===t.enableHWA,U=!1!==t.useWasm,z=t.pagesMapper||new te,H=h?h.length:t.length??NaN,j="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!n&&!M,$="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===Ye&&y===ti&&A===ii&&g&&v&&w&&Pt(g,document.baseURI)&&Pt(v,document.baseURI)&&Pt(w,document.baseURI));G(u);const V={canvasFactory:new L({ownerDocument:P,enableHWA:N}),filterFactory:new O({docId:i,ownerDocument:P}),cMapReaderFactory:$?null:new f({baseUrl:g,isCompressed:m}),standardFontDataFactory:$?null:new y({baseUrl:v}),wasmFactory:$?null:new A({baseUrl:w})};d||(d=Xn.create({verbosity:u,port:an.workerPort}),e._worker=d);const W={docId:i,apiVersion:"5.5.207",data:r,password:l,disableAutoFetch:B,rangeChunkSize:c,length:H,docBaseUrl:p,enableXfa:D,evaluatorOptions:{maxImageSize:S,disableFontFace:M,ignoreErrors:x,isEvalSupported:C,isOffscreenCanvasSupported:E,isImageDecoderSupported:T,canvasMaxAreaInBytes:_,fontExtraProperties:k,useSystemFonts:j,useWasm:U,useWorkerFetch:$,cMapUrl:g,iccUrl:b,standardFontDataUrl:v,wasmUrl:w}},X={ownerDocument:P,pdfBug:F,styleElement:null,enableHWA:N,loadingParams:{disableAutoFetch:B,enableXfa:D}};return d.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const t=d.messageHandler.sendWithPromise("GetDocRequest",W,r?[r.buffer]:null);let l;if(h)l=new fn({pdfDataRangeTransport:h,disableRange:I,disableStream:R});else if(!r){if(!s)throw new Error("getDocument - no `url` parameter provided.");const t=Pt(s)?Mn:n?Fn:Pn;l=new t({url:s,length:H,httpHeaders:a,withCredentials:o,rangeChunkSize:c,disableRange:I,disableStream:R})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const n=new We(i,t,d.port),s=new qn(n,e,l,X,V,z);e._transport=s,n.send("Ready",null)}))})).catch(e._capability.reject),e}class Gn{static#fn=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+Gn.#fn++;destroyed=!1;onPassword=null;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}async getData(){return this._transport.getData()}}class $n{#Ps=Promise.withResolvers();#ar=[];#or=[];#lr=[];constructor(t,e,i=!1,n=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=n,Object.defineProperty(this,"onDataProgress",{value:()=>{Bt("`PDFDataRangeTransport.prototype.onDataProgress` - method was removed, since loading progress is now reported automatically through the `PDFDataTransportStream` class (and related code).")}})}addRangeListener(t){this.#lr.push(t)}addProgressiveReadListener(t){this.#or.push(t)}addProgressiveDoneListener(t){this.#ar.push(t)}onDataRange(t,e){for(const i of this.#lr)i(t,e)}onDataProgressiveRead(t){this.#Ps.promise.then((()=>{for(const e of this.#or)e(t)}))}onDataProgressiveDone(){this.#Ps.promise.then((()=>{for(const t of this.#ar)t()}))}transportReady(){this.#Ps.resolve()}requestDataRange(t,e){X("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Vn{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Q(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}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 Wn{#hr=!1;#cr=null;constructor(t,e,i,n,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Dt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new zn,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#cr=n}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-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:n=0,dontFlip:s=!1}={}){return new Ct({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Q(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:n="display",annotationMode:s=g.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1,recordOperations:p=!1,operationsFilter:m=null}){this._stats?.time("Overall");const f=this._transport.getRenderingIntent(n,s,d,u),{renderingIntent:b,cacheKey:v}=f;this.#hr=!1,o||=this._transport.getOptionalContentConfig(b);const y=this._intentStates.getOrInsertComputed(v,bt);y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const w=!!(b&l);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(f));const A=Boolean(this._pdfBug&&globalThis.StepperManager?.enabled),x=!this.recordedBBoxes&&(p||A),S=t=>{if(y.renderTasks.delete(C),x){const t=C.gfx?.dependencyTracker.take();t&&(C.stepper&&C.stepper.setOperatorBBoxes(t,C.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=t))}w&&(this.#hr=!0),this.#dr(),t?(C.capability.reject(t),this._abortOperatorList({intentState:y,reason:t instanceof Error?t:new Error(t)})):C.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},C=new Yn({callback:S,params:{canvas:e,canvasContext:t,dependencyTracker:x?new fi(e,y.operatorList.length,A):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:m});(y.renderTasks||=new Set).add(C);const E=C.task;return Promise.all([y.displayReadyCapability.promise,o]).then((([t,e])=>{if(this.destroyed)S();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&b))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");C.initializeGraphics({transparency:t,optionalContentConfig:e}),C.operatorListChanged()}})).catch(S),E}getOperatorList({intent:t="display",annotationMode:e=g.ENABLE,printAnnotationStorage:i=null,isEditing:n=!1}={}){const s=this._transport.getRenderingIntent(t,e,i,n,!0),r=this._intentStates.getOrInsertComputed(s.cacheKey,bt);let a;return r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(s)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#cr.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>yt.textContent(t)));const e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null},n=e.getReader();try{for(;;){const{done:t,value:e}=await n.read();if(t)break;i.lang??=e.lang,Object.assign(i.styles,e.styles),i.items.push(...e.items)}}finally{n.releaseLock()}return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#hr=!1,Promise.all(t)}cleanup(t=!1){this.#hr=!0;const e=this.#dr();return t&&e&&(this._stats&&=new Dt),e}#dr(){if(!this.#hr||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#hr=!1,!0}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,n=t.length;i<n;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#dr()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:n}){const{map:s,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#cr.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:s,modifiedIds:n},void 0,r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#dr()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(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 Et){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new rt(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class Xn{#Ps=Promise.withResolvers();#ur=null;#as=null;#pr=null;static#gr=0;static#mr=!1;static#fr=new WeakMap;static{n&&(this.#mr=!0,an.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const n=new URL(e,i);return i.origin===n.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{if(Bt("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=$()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(Xn.#fr.has(e))throw new Error("Cannot use more than one PDFWorker per port.");Xn.#fr.set(e,this),this.#br(e)}else this.#vr()}get promise(){return this.#Ps.promise}#yr(){this.#Ps.resolve(),this.#ur.send("configure",{verbosity:this.verbosity})}get port(){return this.#as}get messageHandler(){return this.#ur}#br(t){this.#as=t,this.#ur=new We("main","worker",t),this.#ur.on("ready",(()=>{})),this.#yr()}#vr(){if(Xn.#mr||Xn.#wr)return void this.#Ar();let{workerSrc:t}=Xn;try{Xn._isSameOrigin(window.location,t)||(t=Xn._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new We("main","worker",e),n=()=>{s.abort(),i.destroy(),e.terminate(),this.destroyed?this.#Ps.reject(new Error("Worker was destroyed")):this.#Ar()},s=new AbortController;e.addEventListener("error",(()=>{this.#pr||n()}),{signal:s.signal}),i.on("test",(t=>{s.abort(),!this.destroyed&&t?(this.#ur=i,this.#as=e,this.#pr=e,this.#yr()):n()})),i.on("ready",(t=>{if(s.abort(),this.destroyed)n();else try{r()}catch{this.#Ar()}}));const r=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void r()}catch{V("The worker has been disabled.")}this.#Ar()}#Ar(){Xn.#mr||(W("Setting up fake worker."),Xn.#mr=!0),Xn._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this.#Ps.reject(new Error("Worker was destroyed"));const e=new Re;this.#as=e;const i="fake"+Xn.#gr++,n=new We(i+"_worker",i,e);t.setup(n,e),this.#ur=new We(i,i+"_worker",e),this.#yr()})).catch((t=>{this.#Ps.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this.#pr?.terminate(),this.#pr=null,Xn.#fr.delete(this.#as),this.#as=null,this.#ur?.destroy(),this.#ur=null}static create(t){const e=this.#fr.get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Xn(t)}static get workerSrc(){if(an.workerSrc)return an.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#wr(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Q(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#wr)return this.#wr;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class qn{downloadInfoCapability=Promise.withResolvers();#xr=null;#Sr=new Map;#Cr=null;#Er=new Map;#Tr=new Map;#_r=new Map;#Mr=null;#kr=null;constructor(t,e,i,n,s,r){this.messageHandler=t,this.loadingTask=e,this.#Cr=i,this.commonObjs=new zn,this.fontLoader=new Se({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.enableHWA=n.enableHWA,this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.cMapReaderFactory=s.cMapReaderFactory,this.standardFontDataFactory=s.standardFontDataFactory,this.wasmFactory=s.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler(),this.pagesMapper=r,this.pagesMapper.addListener(this.#Dr.bind(this))}#Dr({type:t,pageNumbers:e}){if("copy"===t){this.#kr=new Map;for(const t of e)this.#kr.set(t,{proxy:this.#Er.get(t-1)||null,promise:this.#Tr.get(t-1)||null});return}if("delete"===t)for(const t of e)this.#Er.delete(t-1),this.#Tr.delete(t-1);const i=new Map,n=new Map,{pagesMapper:s}=this;for(let t=0,e=s.pagesNumber;t<e;t++){const e=s.getPrevPageNumber(t+1);if(e<0){const{proxy:s,promise:r}=this.#kr?.get(-e)||{};s&&i.set(t,s),r&&n.set(t,r);continue}const r=e-1,a=this.#Er.get(r);a&&i.set(t,a);const o=this.#Tr.get(r);o&&n.set(t,o)}this.#Er=i,this.#Tr=n}#Pr(t,e=null){return this.#Sr.getOrInsertComputed(t,(()=>this.messageHandler.sendWithPromise(t,e)))}#Es({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:vt(Math.round(t/e*100),0,100)})}get annotationStorage(){return Q(this,"annotationStorage",new Ae)}getRenderingIntent(t,e=g.ENABLE,i=null,n=!1,s=!1){let r=o,m=we;switch(t){case"any":r=a;break;case"display":break;case"print":r=l;break;default:W(`getRenderingIntent - invalid intent: ${t}`)}const f=r&l&&i instanceof xe?i:this.annotationStorage;switch(e){case g.DISABLE:r+=d;break;case g.ENABLE:break;case g.ENABLE_FORMS:r+=h;break;case g.ENABLE_STORAGE:r+=c,m=f.serializable;break;default:W(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(r+=u),s&&(r+=p);const{ids:b,hash:v}=f.modifiedIds;return{renderingIntent:r,cacheKey:[r,m.hash,v].join("_"),annotationStorageSerializable:m,modifiedIds:b}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Mr?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Er.values())t.push(e._destroy());this.#Er.clear(),this.#Tr.clear(),this.#_r.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#Sr.clear(),this.filterFactory.destroy(),Hn.cleanup(),this.#Cr?.cancelAllRequests(new rt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{q(this.#Cr,"GetReader - no `BasePDFStream` instance available."),this.#xr=this.#Cr.getFullReader(),this.#xr.onProgress=t=>this.#Es(t),e.onPull=()=>{this.#xr.read().then((function({value:t,done:i}){i?e.close():(q(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this.#xr.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async t=>{await this.#xr.headersReady;const{isStreamingSupported:e,isRangeSupported:i,contentLength:n}=this.#xr;return e&&i&&(this.#xr.onProgress=null),{isStreamingSupported:e,isRangeSupported:i,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{q(this.#Cr,"GetRangeReader - no `BasePDFStream` instance available.");const i=this.#Cr.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(q(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}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this.pagesMapper.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Vn(t,this))})),t.on("DocException",(t=>{e._capability.reject(Ve(t))})),t.on("PasswordRequest",(t=>{this.#Mr=Promise.withResolvers();try{if(!e.onPassword)throw Ve(t);const i=t=>{t instanceof Error?this.#Mr.reject(t):this.#Mr.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Mr.reject(t)}return this.#Mr.promise})),t.on("DataLoaded",(t=>{this.#Es({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#Er.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,n])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in n){const t=n.error;W(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const s=new _e(n),r=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new Ce(s,r,n.extra,n.charProcOperatorList);this.fontLoader.bind(a).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a.fontExtraProperties&&a.data&&a.clearData(),this.commonObjs.resolve(e,a)}));break;case"CopyLocalImage":const{imageRef:o}=n;q(o,"The imageRef must be defined.");for(const t of this.#Er.values())for(const[,i]of t.objs)if(i?.ref===o)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":this.commonObjs.resolve(e,new ke(n));break;case"Image":this.commonObjs.resolve(e,n);break;case"Pattern":const l=new Me(n);this.commonObjs.resolve(e,l.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,n])=>{if(this.destroyed)return;const s=this.#Er.get(e);if(!s.objs.has(t))if(0!==s._intentStates.size)switch(i){case"Image":case"Pattern":s.objs.resolve(t,n);break;default:throw new Error(`Got unknown object type ${i}`)}else n?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||this.#Es(t)})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&W("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#xr?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}extractPages(t){return this.messageHandler.sendWithPromise("ExtractPages",{pageInfos:t})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.pagesMapper.getPageId(t)-1,n=this.#Tr.get(e);if(n)return n;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then((t=>{if(this.destroyed)throw new Error("Transport destroyed");t.refStr&&this.#_r.set(t.refStr,i);const n=new Wn(e,t,this,this.pagesMapper,this._params.pdfBug);return this.#Er.set(e,n),n}));return this.#Tr.set(e,s),s}async getPageIndex(t){if(!Pe(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),i=this.pagesMapper.getPageNumber(e+1);if(0===i)throw new Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#Pr("GetFieldObjects")}hasJSActions(){return this.#Pr("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#Pr("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#Pr("GetOptionalContentConfig").then((e=>new cn(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return this.#Sr.getOrInsertComputed(t,(()=>this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new on(t[1]):null,contentDispositionFilename:this.#xr?.filename??null,contentLength:this.#xr?.contentLength??null,hasStructTree:t[2]})))))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Er.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Sr.clear(),this.filterFactory.destroy(!0),Hn.cleanup()}}cachedPageNumber(t){if(!Pe(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`,i=this.#_r.get(e);if(i>=0){const t=this.pagesMapper.getPageNumber(i+1);if(0!==t)return t}return null}}class Kn{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}}class Yn{#Ir=null;static#Rr=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:n,annotationCanvasMap:s,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,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 Kn(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Yn.#Rr.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Yn.#Rr.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:i,transform:n,background:s,dependencyTracker:r}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new rn(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Ir&&(window.cancelAnimationFrame(this.#Ir),this.#Ir=null),Yn.#Rr.delete(this._canvas),t||=new Et(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Ir=window.requestAnimationFrame((()=>{this.#Ir=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Yn.#Rr.delete(this._canvas),this.callback())))}}const Jn="5.5.207",Qn="527964698";class Zn{#Br=null;#Fr=null;#Lr;#Or=null;#Nr=!1;#Ur=!1;#b=null;#zr;#Hr=null;#k=null;static#jr=null;static get _keyboardManager(){return Q(this,"_keyboardManager",new le([[["Escape","mac+Escape"],Zn.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Zn.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Zn.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Zn.prototype._moveToPrevious],[["Home","mac+Home"],Zn.prototype._moveToBeginning],[["End","mac+End"],Zn.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#Ur=!1,this.#b=t):this.#Ur=!0,this.#k=t?._uiManager||e,this.#zr=this.#k._eventBus,this.#Lr=t?.color?.toUpperCase()||this.#k?.highlightColors.values().next().value||"#FFFF98",Zn.#jr||=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(){const t=this.#Br=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#b&&(t.ariaControls=`${this.#b.id}_colorpicker_dropdown`);const e=this.#k._signal;t.addEventListener("click",this.#Gr.bind(this),{signal:e}),t.addEventListener("keydown",this.#$r.bind(this),{signal:e});const i=this.#Fr=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#Lr,t.append(i),t}renderMainDropdown(){const t=this.#Or=this.#Vr();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#Vr(){const t=document.createElement("div"),e=this.#k._signal;t.addEventListener("contextmenu",It,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#b&&(t.id=`${this.#b.id}_colorpicker_dropdown`);for(const[i,n]of this.#k.highlightColors){const s=document.createElement("button");s.tabIndex="0",s.role="option",s.setAttribute("data-color",n),s.title=i,s.setAttribute("data-l10n-id",Zn.#jr[i]);const r=document.createElement("span");s.append(r),r.className="swatch",r.style.backgroundColor=n,s.ariaSelected=n===this.#Lr,s.addEventListener("click",this.#Wr.bind(this,n),{signal:e}),t.append(s)}return t.addEventListener("keydown",this.#$r.bind(this),{signal:e}),t}#Wr(t,e){e.stopPropagation(),this.#zr.dispatch("switchannotationeditorparams",{source:this,type:b.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#Br)return void this.#Gr(t);const e=t.target.getAttribute("data-color");e&&this.#Wr(e,t)}_moveToNext(t){this.#Xr?t.target!==this.#Br?t.target.nextSibling?.focus():this.#Or.firstElementChild?.focus():this.#Gr(t)}_moveToPrevious(t){t.target!==this.#Or?.firstElementChild&&t.target!==this.#Br?(this.#Xr||this.#Gr(t),t.target.previousSibling?.focus()):this.#Xr&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Xr?this.#Or.firstElementChild?.focus():this.#Gr(t)}_moveToEnd(t){this.#Xr?this.#Or.lastElementChild?.focus():this.#Gr(t)}#$r(t){Zn._keyboardManager.exec(this,t)}#Gr(t){if(this.#Xr)return void this.hideDropdown();if(this.#Nr=0===t.detail,this.#Hr||(this.#Hr=new AbortController,window.addEventListener("pointerdown",this.#C.bind(this),{signal:this.#k.combinedSignal(this.#Hr)})),this.#Br.ariaExpanded="true",this.#Or)return void this.#Or.classList.remove("hidden");const e=this.#Or=this.#Vr();this.#Br.append(e)}#C(t){this.#Or?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Or?.classList.add("hidden"),this.#Br.ariaExpanded="false",this.#Hr?.abort(),this.#Hr=null}get#Xr(){return this.#Or&&!this.#Or.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#Ur||(this.#Xr?(this.hideDropdown(),this.#Br.focus({preventScroll:!0,focusVisible:this.#Nr})):this.#b?.unselect())}updateColor(t){if(this.#Fr&&(this.#Fr.style.backgroundColor=t),!this.#Or)return;const e=this.#k.highlightColors.values();for(const i of this.#Or.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#Br?.remove(),this.#Br=null,this.#Fr=null,this.#Or?.remove(),this.#Or=null}}class ts{#qr=null;#b=null;#k=null;static#jr=null;constructor(t){this.#b=t,this.#k=t._uiManager,ts.#jr||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#qr)return this.#qr;const{editorType:t,colorType:e,color:i}=this.#b,n=this.#qr=document.createElement("input");return n.type="color",n.value=i||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",ts.#jr[t]),n.addEventListener("input",(()=>{this.#k.updateParams(e,n.value)}),{signal:this.#k._signal}),n}update(t){this.#qr&&(this.#qr.value=t)}destroy(){this.#qr?.remove(),this.#qr=null}hideDropdown(){}}i(531);function es(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function is(t){return Math.max(0,Math.min(255,255*t))}class ns{static CMYK_G([t,e,i,n]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+n)]}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=is(t),t,t]}static G_HTML([t]){const e=es(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(is)}static RGB_HTML(t){return`#${t.map(es).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,i+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,i,n]){return[is(1-Math.min(1,t+n)),is(1-Math.min(1,i+n)),is(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const n=1-t,s=1-e,r=1-i;return["CMYK",n,s,r,Math.min(n,s,r)]}}class ss{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){X("Abstract method `_createSVG` called.")}}class rs extends ss{_createSVG(t){return document.createElementNS(At,t)}}const as=new WeakSet,os=60*(new Date).getTimezoneOffset()*1e3;class ls{static create(t){switch(t.data.annotationType){case M.LINK:return new ds(t);case M.TEXT:return new us(t);case M.WIDGET:switch(t.data.fieldType){case"Tx":return new gs(t);case"Btn":return t.data.radioButton?new bs(t):t.data.checkBox?new fs(t):new vs(t);case"Ch":return new ys(t);case"Sig":return new ms(t)}return new ps(t);case M.POPUP:return new ws(t);case M.FREETEXT:return new xs(t);case M.LINE:return new Ss(t);case M.SQUARE:return new Cs(t);case M.CIRCLE:return new Es(t);case M.POLYLINE:return new Ts(t);case M.CARET:return new Ms(t);case M.INK:return new ks(t);case M.POLYGON:return new _s(t);case M.HIGHLIGHT:return new Ds(t);case M.UNDERLINE:return new Ps(t);case M.SQUIGGLY:return new Is(t);case M.STRIKEOUT:return new Rs(t);case M.STAMP:return new Bs(t);case M.FILEATTACHMENT:return new Fs(t);default:return new hs(t)}}}class hs{#Kr=null;#Yr=!1;#Jr=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!t?.str&&!e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return hs._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:i,rect:n}=this.data;let s=-1/0,r=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>r?(r=e[t+1],s=e[t+2]):e[t+1]===r&&(s=Math.max(s,e[t+2]));return[s,r]}if(i?.length>=1){for(const t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>r?(r=t[e+1],s=t[e]):t[e+1]===r&&(s=Math.max(s,t[e]));if(s!==1/0)return[s,r]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:n,pageX:s,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-s)/i,t[1]=100*(t[1]-r)/n,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${m}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${m}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#Jr?.popup||this.popup)?.remove(),this.#Jr=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#Kr||={rect:this.data.rect.slice(0)});const{rect:e,popup:i}=t;e&&this.#Qr(e);let n=this.#Jr?.popup||this.popup;!n&&i?.text&&(this._createPopup(i),n=this.#Jr.popup),n&&(n.updateEdited(t),i?.deleted&&(n.remove(),this.#Jr=null,this.popup=null))}resetEdited(){this.#Kr&&(this.#Qr(this.#Kr.rect),this.#Jr?.popup.resetEdited(),this.#Kr=null)}#Qr(t){const{container:{style:e},data:{rect:i,rotation:n},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-a)/s+"%",e.top=100*(r-t[3]+o)/r+"%",0===n?(e.width=100*(t[2]-t[0])/s+"%",e.height=100*(t[3]-t[1])/r+"%"):this.setRotation(n)}_createContainer(t){const{data:e,parent:{page:i,viewport:n}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",e.id),this instanceof ps||this instanceof ds||(s.tabIndex=0);const{style:r}=s;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(s.title=e.alternativeText),e.noRotate&&s.classList.add("norotate"),!e.rect||this instanceof ws){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,s),s}const{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;r.borderRadius=e}else if(this instanceof bs){const t=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case k:r.borderStyle="solid";break;case D:r.borderStyle="dashed";break;case P:W("Unimplemented border style: beveled");break;case I:W("Unimplemented border style: inset");break;case R:r.borderBottomStyle="solid"}const n=e.borderColor||null;n?(this.#Yr=!0,r.borderColor=ht.makeHexColor(0|n[0],0|n[1],0|n[2])):r.borderWidth=0}const l=ht.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:c,pageX:d,pageY:u}=n.rawDims;r.left=100*(l[0]-d)/h+"%",r.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/c+"%"):this.setRotation(p,s),s}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims;let{width:s,height:r}=this;t%180!=0&&([s,r]=[r,s]),e.style.width=100*s/i+"%",e.style.height=100*r/n+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const n=i.detail[t],s=n[0],r=n.slice(1);i.target.style[e]=ns[`${s}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:ns[`${s}_rgb`](r)})};return Q(this,"_commonActions",{display:t=>{const{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=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const n of Object.keys(e.detail)){(t[n]||i[n])?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[n,s]of Object.entries(e)){const r=i[n];if(r){r({detail:{[n]:s},target:t}),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,n,s]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(n===r&&s===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(this.#Yr){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["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="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=n-e,l=s-i,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let i=2,n=t.length;i<n;i+=8){const n=t[i],r=t[i+1],c=t[i+2],d=t[i+3],p=h.createElement("rect"),g=(c-e)/o,m=(s-r)/l,f=(n-c)/o,b=(r-d)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),a?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#Yr&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let i,n;t?(i={str:t.text},n=t.date):(i=e.contentsObj,n=e.modificationDate),this.#Jr=new ws({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#Jr||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#Jr}render(){X("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:t,id:s,exportValues:r}of n){if(-1===t)continue;if(s===e)continue;const n="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${s}"]`);!a||as.has(a)?i.push({id:s,exportValue:n,domElement:a}):W(`_getElementsByName - element not allowed: ${s}`)}return i}for(const n of document.getElementsByName(t)){const{exportValue:t}=n,s=n.getAttribute("data-element-id");s!==e&&(as.has(n)&&i.push({id:s,exportValue:t,domElement:n}))}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(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class cs extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class ds extends hs{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let n=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),n=!0):t.attachment?(this.#Zr(i,t.attachment,t.overlaidText,t.attachmentDest),n=!0):t.setOCGState?(this.#ta(i,t.setOCGState,t.overlaidText),n=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),n=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&(this.contentElement=i,this.container.append(i)),this.container}#ea(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#ea(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#ea()}#Zr(t,e,i="",n=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,n),!1),this.#ea()}#ta(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#ea()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(e.actions)){const s=i.get(n);s&&(t[s]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:n}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#ea()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#ea(),!this._fieldObjects)return W('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:n,include:s}=e,r=[];if(0!==t.length||0!==n.length){const e=new Set(n);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===s&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const a=this.annotationStorage,o=[];for(const t of r){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(as.has(i)?i.dispatchEvent(new Event("resetform")):W(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class us extends hs{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class ps extends hs{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ot.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,n,s){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(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}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(t)}})}))}_setEventListeners(t,e,i,n){for(const[s,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,s,r,n),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":ht.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,s=t.style;let a;const o=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(r*n))||1);a=Math.min(n,o(e/r))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(n,o(t/r))}s.fontSize=`calc(${a}px * var(--total-scale-factor))`,s.color=ht.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(s.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class gs extends ps{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,n){const s=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),s.setValue(r.id,{[n]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const n=t.getValue(e,{value:this.data.fieldValue});let s=n.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&s.length>r&&(s=s.slice(0,r));let a=n.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:s,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??s,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",a??s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),as.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:l,datetimeType:h,timeStep:c}=this.data,d=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",(n=>{t.setValue(e,{value:n.target.value}),this.setPropertyOnSiblings(i,"value",n.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let u=t=>{const{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;const{target:e}=t;if(d&&(e.type=h,c&&(e.step=c)),o.userValue){const t=o.userValue;if(d)if("time"===h){const i=new Date(t),n=[i.getHours(),i.getMinutes(),i.getSeconds()];e.value=n.map((t=>t.toString().padStart(2,"0"))).join(":")}else e.value=new Date(t-os).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const n={value(i){o.userValue=i.detail.value??"",d||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:n}=i.detail;o.formattedValue=n,null!=n&&i.target!==document.activeElement&&(i.target.value=n);const s={formattedValue:n};d&&(s.value=n),t.setValue(e,s)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:n}=i.detail,{target:s}=i;if(0===n)return void s.removeAttribute("maxLength");s.setAttribute("maxLength",n);let r=o.userValue;!r||r.length<=n||(r=r.slice(0,n),s.value=o.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}}))}};this._dispatchEventFromSandbox(n,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;const{value:n}=t.target;o.lastCommittedValue!==n&&(o.lastCommittedValue=n,o.userValue=n,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const n=u;u=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{target:i}=t;let{value:s}=i;if(d){if(s&&"time"===h){const t=s.split(":").map((t=>parseInt(t,10)));s=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else s.includes("T")||(s=`${s}T00:00`),s=new Date(s).valueOf();i.type="text"}o.userValue=s,o.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),n(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:n}=t,{value:s,selectionStart:r,selectionEnd:a}=n;let l=r,h=a;switch(t.inputType){case"deleteWordBackward":{const t=s.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=s.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,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(u&&i.addEventListener("blur",u),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.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 ms extends ps{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class fs extends ps{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const s=document.createElement("input");return as.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.setAttribute("exportValue",e.exportValue),s.tabIndex=0,s.addEventListener("change",(n=>{const{name:s,checked:r}=n.target;for(const n of this._getElementsByName(s,i)){const i=r&&n.exportValue===e.exportValue;n.domElement&&(n.domElement.checked=i),t.setValue(n.id,{value:i})}t.setValue(i,{value:r})})),s.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(s.addEventListener("updatefromsandbox",(e=>{const n={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class bs extends ps{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(i,{value:n})),n)for(const n of this._getElementsByName(e.fieldName,i))t.setValue(n.id,{value:!1});const s=document.createElement("input");if(as.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.tabIndex=0,s.addEventListener("change",(e=>{const{name:n,checked:s}=e.target;for(const e of this._getElementsByName(n,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:s})})),s.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const n=e.buttonValue;s.addEventListener("updatefromsandbox",(e=>{const s={value:e=>{const s=n===e.detail.value;for(const n of this._getElementsByName(e.target.name)){const e=s&&n.id===i;n.domElement&&(n.domElement.checked=e),t.setValue(n.id,{value:e})}}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class vs extends ds{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class ys extends ps{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");as.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;let s=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of n.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),s=!1),n.append(e)}let r=null;if(s){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),n.prepend(t),r=()=>{t.remove(),n.removeEventListener("input",r),r=null},n.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:s}=n;return s?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(i=>{const s={value(i){r?.();const s=i.detail.value,l=new Set(Array.isArray(s)?s:[s]);for(const t of n.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){n.multiple=!0},remove(i){const s=n.options,r=i.detail.remove;if(s[r].selected=!1,n.remove(r),s.length>0){-1===Array.prototype.findIndex.call(s,(t=>t.selected))&&(s[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:s,displayValue:r,exportValue:h}=i.detail.insert,c=n.children[s],d=document.createElement("option");d.textContent=r,d.value=h,c?c.before(d):n.append(d),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:s}=i.detail;for(;0!==n.length;)n.remove(0);for(const t of s){const{displayValue:e,exportValue:i}=t,s=document.createElement("option");s.textContent=e,s.value=i,n.append(s)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const n=new Set(i.detail.indices);for(const t of i.target.options)t.selected=n.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(s,i)})),n.addEventListener("input",(i=>{const n=a(!0),s=a(!1);t.setValue(e,{value:n}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:s,changeEx:n,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,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))):n.addEventListener("input",(function(i){t.setValue(e,{value:a(!0)})})),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class ws extends hs{constructor(t){const{data:e,elements:i,parent:n}=t,s=!!n._commentManager;if(super(t,{isRenderable:!s&&hs._hasPopupData(e)}),this.elements=i,s&&hs._hasPopupData(e)){const t=this.popup=this.#ia();for(const e of i)e.popup=t}else this.popup=null}#ia(){return new As({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=this.#ia(),i=[];for(const t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map((t=>`${gt}${t}`)).join(",")),this.container}}class As{#et=null;#na=this.#$r.bind(this);#sa=this.#ra.bind(this);#aa=this.#oa.bind(this);#la=this.#ha.bind(this);#ca=null;#Ot=null;#da=null;#ua=null;#pa=null;#ga=null;#ma=null;#fa=!1;#ba=null;#va=null;#$=null;#ya=null;#wa=null;#De=null;#Aa=null;#Te=null;#xa=null;#Kr=null;#Sa=!1;#Ca=null;#Ea=null;constructor({container:t,color:e,elements:i,titleObj:n,modificationDate:s,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:c,commentManager:d=null}){this.#Ot=t,this.#xa=n,this.#da=r,this.#Te=a,this.#ga=o,this.#ca=e,this.#Aa=l,this.#ma=h,this.#pa=i,this.#et=d,this.#Ca=i[0],this.#ua=Ft.toDateObject(s),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup())),d||(this.#Ta(),this.#Ot.hidden=!0,c&&this.#ha())}#Ta(){if(this.#va)return;this.#va=new AbortController;const{signal:t}=this.#va;for(const e of this.trigger)e.addEventListener("click",this.#la,{signal:t}),e.addEventListener("pointerenter",this.#aa,{signal:t}),e.addEventListener("pointerleave",this.#sa,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#pa)e.container?.addEventListener("keydown",this.#na,{signal:t})}#_a(){const t=this.#pa.find((t=>t.hasCommentButton));t&&(this.#wa=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#ya)return void(this.#ya.parentNode||this.#Ca.container.after(this.#ya));if(this.#wa||this.#_a(),!this.#wa)return;const{signal:t}=this.#va=new AbortController,e=this.#Ca.hasOwnCommentButton,i=()=>{this.#et.toggleCommentPopup(this,!0,void 0,!e)},n=()=>{this.#et.toggleCommentPopup(this,!1,!0,!e)},s=()=>{this.#et.toggleCommentPopup(this,!1,!1)};if(e){this.#ya=this.#Ca.container;for(const e of this.trigger)e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#na,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",n,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),e.classList.add("popupTriggerArea")}else{const e=this.#ya=document.createElement("button");e.className="annotationCommentButton";const r=this.#Ca.container;e.style.zIndex=r.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#Ma(),this.#ka(),e.addEventListener("keydown",this.#na,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",n,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),r.after(e)}}#ka(){if(this.#Ca.extraPopupElement&&!this.#Ca.editor)return;this.#ya||this.renderCommentButton();const[t,e]=this.#wa,{style:i}=this.#ya;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#Ma(){this.#Ca.extraPopupElement||(this.#ya||this.renderCommentButton(),this.#ya.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#Ca.commentData;return t?this.#ga._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout((()=>{this.#ya?.focus()}),0)}getData(){const{richText:t,color:e,opacity:i,creationDate:n,modificationDate:s}=this.#Ca.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:n,modificationDate:s}}get elementBeforePopup(){return this.#ya}get comment(){return this.#Ea||=this.#Ca.commentText,this.#Ea}set comment(t){t!==this.comment&&(this.#Ca.commentText=this.#Ea=t)}focus(){this.#Ca.container?.focus()}get parentBoundingClientRect(){return this.#Ca.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#ya&&(this.#ya.classList.toggle("selected",t),this.#ya.ariaExpanded=e)}setSelectedCommentButton(t){this.#ya.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#De)return this.#De;const{x:t,y:e,height:i}=this.#ya.getBoundingClientRect(),{x:n,y:s,width:r,height:a}=this.#Ca.layer.getBoundingClientRect();return[(t-n)/r,(e+i-s)/a]}set commentPopupPosition(t){this.#De=t}hasDefaultPopupPosition(){return null===this.#De}get commentButtonPosition(){return this.#wa}get commentButtonWidth(){return this.#ya.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=this.#De||this.commentButtonPosition.map((t=>t/100)),n=this.parentBoundingClientRect,{x:s,y:r,width:a,height:o}=n;this.#et.showDialog(null,this,s+e*a,r+i*o,{...t,parentDimensions:n})}render(){if(this.#ba)return;const t=this.#ba=document.createElement("div");if(t.className="popup",this.#ca){const e=t.style.outlineColor=ht.makeHexColor(...this.#ca);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#xa?.str){const t=document.createElement("span");t.className="title",e.append(t),({dir:t.dir,str:t.textContent}=this.#xa)}if(t.append(e),this.#ua){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#ua.valueOf()})),t.dateTime=this.#ua.toISOString(),e.append(t)}Qt({html:this.#Da||this.#da.str,dir:this.#da?.dir,className:"popupContent"},t),this.#Ot.append(t)}get#Da(){const t=this.#Te,e=this.#da;return!t?.str||e?.str&&e.str!==t.str?null:this.#Te.html||null}get#Pa(){return this.#Da?.attributes?.style?.fontSize||0}get#Ia(){return this.#Da?.attributes?.style?.color||null}#Ra(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:this.#Ia,fontSize:this.#Pa?`calc(${this.#Pa}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:n});return i}#$r(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#fa)&&this.#ha()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#et)return i?(this.remove(),this.#Ea=null):e&&(e.deleted?this.remove():(this.#Ma(),this.#Ea=e.text)),void(t&&(this.#wa=null,this.#_a(),this.#ka()));i||e?.deleted?this.remove():(this.#Ta(),this.#Kr||={contentsObj:this.#da,richText:this.#Te},t&&(this.#$=null),e&&e.text&&(this.#Te=this.#Ra(e.text),this.#ua=Ft.toDateObject(e.date),this.#da=null),this.#ba?.remove(),this.#ba=null)}resetEdited(){this.#Kr&&(({contentsObj:this.#da,richText:this.#Te}=this.#Kr),this.#Kr=null,this.#ba?.remove(),this.#ba=null,this.#$=null)}remove(){if(this.#va?.abort(),this.#va=null,this.#ba?.remove(),this.#ba=null,this.#Sa=!1,this.#fa=!1,this.#ya?.remove(),this.#ya=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#Ba(){if(null!==this.#$)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:n,pageY:s}}}=this.#ga;let r=!!this.#ma,a=r?this.#ma:this.#Aa;for(const t of this.#pa)if(!a||null!==ht.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=ht.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,c=o[1];this.#$=[100*(h-n)/e,100*(c-s)/i];const{style:d}=this.#Ot;d.left=`${this.#$[0]}%`,d.top=`${this.#$[1]}%`}#ha(){this.#et?this.#et.toggleCommentPopup(this,!1):(this.#fa=!this.#fa,this.#fa?(this.#oa(),this.#Ot.addEventListener("click",this.#la),this.#Ot.addEventListener("keydown",this.#na)):(this.#ra(),this.#Ot.removeEventListener("click",this.#la),this.#Ot.removeEventListener("keydown",this.#na)))}#oa(){this.#ba||this.render(),this.isVisible?this.#fa&&this.#Ot.classList.add("focused"):(this.#Ba(),this.#Ot.hidden=!1,this.#Ot.style.zIndex=parseInt(this.#Ot.style.zIndex)+1e3)}#ra(){this.#Ot.classList.remove("focused"),!this.#fa&&this.isVisible&&(this.#Ot.hidden=!0,this.#Ot.style.zIndex=parseInt(this.#Ot.style.zIndex)-1e3)}forceHide(){this.#Sa=this.isVisible,this.#Sa&&(this.#Ot.hidden=!0)}maybeShow(){this.#et||(this.#Ta(),this.#Sa&&(this.#ba||this.#oa(),this.#Sa=!1,this.#Ot.hidden=!1))}get isVisible(){return!this.#et&&!1===this.#Ot.hidden}}class xs extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=f.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Ss extends hs{#Fa=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=this.#Fa=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),s.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),s.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),s.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),s.setAttribute("stroke-width",t.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),n.append(s),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Fa}addHighlightArea(){this.container.classList.add("highlightArea")}}class Cs extends hs{#La=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,r=this.#La=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",s/2),r.setAttribute("y",s/2),r.setAttribute("width",e-s),r.setAttribute("height",i-s),r.setAttribute("stroke-width",s||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#La}addHighlightArea(){this.container.classList.add("highlightArea")}}class Es extends hs{#Oa=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,r=this.#Oa=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-s/2),r.setAttribute("ry",i/2-s/2),r.setAttribute("stroke-width",s||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Oa}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ts extends hs{#Na=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:n},width:s,height:r}=this;if(!e)return this.container;const a=this.svgFactory.create(s,r,!0);let o=[];for(let i=0,n=e.length;i<n;i+=2){const n=e[i]-t[0],s=t[3]-e[i+1];o.push(`${n},${s}`)}o=o.join(" ");const l=this.#Na=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),!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Na}addHighlightArea(){this.container.classList.add("highlightArea")}}class _s extends Ts{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ms extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class ks extends hs{#Ua=null;#za=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?f.HIGHLIGHT:f.INK}#Ha(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);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:n,popupRef:s}}=this,{transform:r,width:a,height:o}=this.#Ha(e,t),l=this.svgFactory.create(a,o,!0),h=this.#Ua=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",n.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",r);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#za.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:n}=t,s=this.#Ua;if(e>=0&&s.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#za.length;t<e;t++)this.#za[t].setAttribute("points",i[t].join(","));if(n){const{transform:t,width:e,height:i}=this.#Ha(this.data.rotation,n);s.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),s.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#za}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ds extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=f.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Ps extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Is extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Rs extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Bs extends hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=f.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Fs extends hs{#ja=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#Ga.bind(this)),this.#ja=i;const{isMac:n}=ot.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&this.#Ga()})),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#ja}addHighlightArea(){this.container.classList.add("highlightArea")}#Ga(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class Ls{#$a=null;#Va=null;#Q=null;#Wa=new Map;#Xa=null;#qa=null;#pa=[];#Ka=!1;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:n,page:s,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#$a=e,this.#Va=i,this.#Xa=a||null,this.#qa=l||null,this.#Q=h||new Ae,this.page=s,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=n,this._commentManager=o||null}hasEditableAnnotations(){return this.#Wa.size>0}async render(t){const{annotations:e}=t,i=this.div;zt(i,this.viewport);const n=new Map,s=[],r={data:null,layer:i,linkService:this.#qa,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new rs,annotationStorage:this.#Q,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===M.POPUP;if(e){const e=n.get(t.id);if(!e)continue;if(!this._commentManager){s.push(t);continue}r.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;r.data=t;const i=ls.create(r);if(!i.isRenderable)continue;e||(this.#pa.push(i),t.popupRef&&n.getOrInsertComputed(t.popupRef,mt).push(i));const a=i.render();t.hidden&&(a.style.visibility="hidden"),i._isEditable&&(this.#Wa.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}await this.#Ya();for(const t of s){const e=r.elements=n.get(t.id);r.data=t;const i=ls.create(r);if(!i.isRenderable)continue;const s=i.render();i.contentElement.id=`${gt}${t.id}`,t.hidden&&(s.style.visibility="hidden"),e.at(-1).container.after(s)}this.#Ja()}async#Ya(){if(0===this.#pa.length)return;this.div.replaceChildren();const t=[];if(!this.#Ka){this.#Ka=!0;for(const{contentElement:e,data:{id:i}}of this.#pa){const n=e.id=`${gt}${i}`;t.push(this.#Xa?.getAriaAttributes(n).then((t=>{if(t)for(const[i,n]of t)e.setAttribute(i,n)})))}}this.#pa.sort((({data:{rect:[t,e,i,n]}},{data:{rect:[s,r,a,o]}})=>{if(t===i&&e===n)return 1;if(s===a&&r===o)return-1;const l=(e+n)/2,h=(r+o)/2;if(l>=o&&h<=e)return-1;if(h>=n&&l<=r)return 1;return(t+i)/2-(s+a)/2}));const e=document.createDocumentFragment();for(const t of this.#pa)e.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&e.append(t.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#$a)for(const t of this.#pa)this.#$a.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:this.#qa,svgFactory:new rs,parent:this};for(const i of t){i.borderStyle||=Ls._defaultBorderStyle,e.data=i;const t=ls.create(e);t.isRenderable&&(t.render(),t.contentElement.id=`${gt}${i.id}`,this.#pa.push(t))}await this.#Ya()}update({viewport:t}){const e=this.div;this.viewport=t,zt(e,{rotation:t.rotation}),this.#Ja(),e.hidden=!1}#Ja(){if(!this.#Va)return;const t=this.div;for(const[e,i]of this.#Va){const n=t.querySelector(`[data-annotation-id="${e}"]`);if(!n)continue;i.className="annotationContent";const{firstChild:s}=n;s?"CANVAS"===s.nodeName?s.replaceWith(i):s.classList.contains("annotationContent")?s.after(i):s.before(i):n.append(i);const r=this.#Wa.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,n.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#Va.clear()}getEditableAnnotations(){return Array.from(this.#Wa.values())}getEditableAnnotation(t){return this.#Wa.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:i,rotation:n}=t,s=new cs({data:{id:i,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#qa,annotationStorage:this.#Q});return s.render(),s.contentElement.id=`${gt}${i}`,s.createOrUpdatePopup(),this.#pa.push(s),s}removeAnnotation(t){const e=this.#pa.findIndex((e=>e.data.id===t));if(e<0)return;const[i]=this.#pa.splice(e,1);this.#$a?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(const e of t)e.updateFakeAnnotationElement(this);this.#Ya()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return Q(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:k,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const Os=/\r\n?|\n/g;class Ns extends ge{#Qa="";#Za=`${this.id}-editor`;#to=null;#Pa;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Ns.prototype,e=t=>t.isEmpty(),i=ce.TRANSLATE_SMALL,n=ce.TRANSLATE_BIG;return Q(this,"_keyboardManager",new le([[["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:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}static _type="freetext";static _editorType=f.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||Ns._defaultColor||ge._defaultLineColor,this.#Pa=t.fontSize||Ns._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,e){ge.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case b.FREETEXT_SIZE:Ns._defaultFontSize=e;break;case b.FREETEXT_COLOR:Ns._defaultColor=e}}updateParams(t,e){switch(t){case b.FREETEXT_SIZE:this.#eo(e);break;case b.FREETEXT_COLOR:this.#Ma(e)}}static get defaultPropertiesToUpdate(){return[[b.FREETEXT_SIZE,Ns._defaultFontSize],[b.FREETEXT_COLOR,Ns._defaultColor||ge._defaultLineColor]]}get propertiesToUpdate(){return[[b.FREETEXT_SIZE,this.#Pa],[b.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new ts(this),[["colorPicker",this._colorPicker]]}get colorType(){return b.FREETEXT_COLOR}#eo(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#Pa)*this.parentScale),this.#Pa=t,this.#io()},i=this.#Pa;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:b.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#Ma(t){const e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:b.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Ns._internalPadding*t,-(Ns._internalPadding+this.#Pa)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#to=new AbortController;const t=this._uiManager.combinedSignal(this.#to);return 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}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Za),this._isDraggable=!0,this.#to?.abort(),this.#to=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}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()}#no(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(Ns.#so(i)),e=i);return t.join("\n")}#io(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,n=e.style.display,s=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=n,e.classList.toggle("hidden",s)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Qa,e=this.#Qa=this.#no().trimEnd();if(t===e)return;const i=t=>{this.#Qa=t,t?(this.#ro(),this._uiManager.rebuild(this),this.#io()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#io()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Ns._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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Za),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#Pa}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(s[0]-h)/o,u=e+this.height-(s[1]-c)/l;break;case 90:d=t+(s[0]-h)/o,u=e-(s[1]-c)/l,[r,a]=[a,-r];break;case 180:d=t-this.width+(s[0]-h)/o,u=e-(s[1]-c)/l,[r,a]=[-r,-a];break;case 270:d=t+(s[0]-h-this.height*l)/o,u=e+(s[1]-c-this.width*o)/l,[r,a]=[-a,r]}this.setAt(d*i,u*n,r,a)}else this._moveAfterPaste(t,e);this.#ro(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#so(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Os,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const n=Ns.#ao(e.getData("text")||"").replaceAll(Os,"\n");if(!n)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();const r=s.getRangeAt(0);if(!n.includes("\n"))return r.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void s.collapseToStart();const{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){const t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(Os,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(Ns.#so(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(Os,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(Ns.#so(i))}this.#Qa=`${l.join("\n")}${n}${h.join("\n")}`,this.#ro();const c=new Range;let d=Math.sumPrecise(l.map((t=>t.length)));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(d<=e){c.setStart(t,d),c.setEnd(t,d);break}d-=e}s.removeAllRanges(),s.addRange(c)}#ro(){if(this.editorDiv.replaceChildren(),this.#Qa)for(const t of this.#Qa.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#oo(){return this.#Qa.replaceAll(" "," ")}static#ao(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=Ns._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let n=null;if(t instanceof xs){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:s,rotation:r,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:c,modificationDate:d},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=t;if(!u||0===u.length)return null;n=t={annotationType:f.FREETEXT,color:Array.from(i),fontSize:e,value:u.join("\n"),position:p,pageIndex:g-1,rect:s.slice(0),rotation:r,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:c,modificationDate:d}}const s=await super.deserialize(t,e,i);return s.#Pa=t.fontSize,s.color=ht.makeHexColor(...t.color),s.#Qa=Ns.#ao(t.value),s._initialData=n,t.comment&&s.setCommentData(t),s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=ge._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#Pa,value:this.#oo()});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!this.#lo(i)?null:(i.id=this.annotationElementId,i)}#lo(t){const{value:e,fontSize:i,color:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==n[e]))||t.pageIndex!==s}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:i}=e;i.fontSize=`calc(${this.#Pa}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(const t of this.#Qa.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#Qa}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Us{static PRECISION=1e-4;toSVGPath(){X("Abstract method `toSVGPath` must be implemented.")}get box(){X("Abstract getter `box` must be implemented.")}serialize(t,e){X("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,n,s,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*n,r[a+1]=i+t[a+1]*s;return r}static _rescaleAndSwap(t,e,i,n,s,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*n,r[a+1]=i+t[a]*s;return r}static _translate(t,e,i,n){n||=new Float32Array(t.length);for(let s=0,r=t.length;s<r;s+=2)n[s]=e+t[s],n[s+1]=i+t[s+1];return n}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,n,s){switch(s){case 90:return[1-e/i,t/n];case 180:return[1-t/i,1-e/n];case 270:return[e/i,1-t/n];default:return[t/i,e/n]}}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,n,s,r){return[(t+5*i)/6,(e+5*n)/6,(5*i+s)/6,(5*n+r)/6,(i+s)/2,(n+r)/2]}}class zs{#ho;#co=[];#do;#uo;#po=[];#go=new Float32Array(18);#mo;#fo;#bo;#vo;#yo;#wo;#Ao=[];static#xo=8;static#So=2;static#Co=zs.#xo+zs.#So;constructor({x:t,y:e},i,n,s,r,a=0){this.#ho=i,this.#wo=s*n,this.#uo=r,this.#go.set([NaN,NaN,NaN,NaN,t,e],6),this.#do=a,this.#vo=zs.#xo*n,this.#bo=zs.#Co*n,this.#yo=n,this.#Ao.push(t,e)}isEmpty(){return isNaN(this.#go[8])}#Eo(){const t=this.#go.subarray(4,6),e=this.#go.subarray(16,18),[i,n,s,r]=this.#ho;return[(this.#mo+(t[0]-e[0])/2-i)/s,(this.#fo+(t[1]-e[1])/2-n)/r,(this.#mo+(e[0]-t[0])/2-i)/s,(this.#fo+(e[1]-t[1])/2-n)/r]}add({x:t,y:e}){this.#mo=t,this.#fo=e;const[i,n,s,r]=this.#ho;let[a,o,l,h]=this.#go.subarray(8,12);const c=t-l,d=e-h,u=Math.hypot(c,d);if(u<this.#bo)return!1;const p=u-this.#vo,g=p/u,m=g*c,f=g*d;let b=a,v=o;a=l,o=h,l+=m,h+=f,this.#Ao?.push(t,e);const y=m/p,w=-f/p*this.#wo,A=y*this.#wo;if(this.#go.set(this.#go.subarray(2,8),0),this.#go.set([l+w,h+A],4),this.#go.set(this.#go.subarray(14,18),12),this.#go.set([l-w,h-A],16),isNaN(this.#go[6]))return 0===this.#po.length&&(this.#go.set([a+w,o+A],2),this.#po.push(NaN,NaN,NaN,NaN,(a+w-i)/s,(o+A-n)/r),this.#go.set([a-w,o-A],14),this.#co.push(NaN,NaN,NaN,NaN,(a-w-i)/s,(o-A-n)/r)),this.#go.set([b,v,a,o,l,h],6),!this.isEmpty();this.#go.set([b,v,a,o,l,h],6);return Math.abs(Math.atan2(v-o,b-a)-Math.atan2(f,m))<Math.PI/2?([a,o,l,h]=this.#go.subarray(2,6),this.#po.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/s,((o+h)/2-n)/r),[a,o,b,v]=this.#go.subarray(14,18),this.#co.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/s,((v+o)/2-n)/r),!0):([b,v,a,o,l,h]=this.#go.subarray(0,6),this.#po.push(((b+5*a)/6-i)/s,((v+5*o)/6-n)/r,((5*a+l)/6-i)/s,((5*o+h)/6-n)/r,((a+l)/2-i)/s,((o+h)/2-n)/r),[l,h,a,o,b,v]=this.#go.subarray(12,18),this.#co.push(((b+5*a)/6-i)/s,((v+5*o)/6-n)/r,((5*a+l)/6-i)/s,((5*o+h)/6-n)/r,((a+l)/2-i)/s,((o+h)/2-n)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#po,e=this.#co;if(isNaN(this.#go[6])&&!this.isEmpty())return this.#To();const 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.#_o(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.#Mo(i),i.join(" ")}#To(){const[t,e,i,n]=this.#ho,[s,r,a,o]=this.#Eo();return`M${(this.#go[2]-t)/i} ${(this.#go[3]-e)/n} L${(this.#go[4]-t)/i} ${(this.#go[5]-e)/n} L${s} ${r} L${a} ${o} L${(this.#go[16]-t)/i} ${(this.#go[17]-e)/n} L${(this.#go[14]-t)/i} ${(this.#go[15]-e)/n} Z`}#Mo(t){const e=this.#co;t.push(`L${e[4]} ${e[5]} Z`)}#_o(t){const[e,i,n,s]=this.#ho,r=this.#go.subarray(4,6),a=this.#go.subarray(16,18),[o,l,h,c]=this.#Eo();t.push(`L${(r[0]-e)/n} ${(r[1]-i)/s} L${o} ${l} L${h} ${c} L${(a[0]-e)/n} ${(a[1]-i)/s}`)}newFreeDrawOutline(t,e,i,n,s,r){return new Hs(t,e,i,n,s,r)}getOutlines(){const t=this.#po,e=this.#co,i=this.#go,[n,s,r,a]=this.#ho,o=new Float32Array((this.#Ao?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#Ao[t]-n)/r,o[t+1]=(this.#Ao[t+1]-s)/a;if(o[o.length-2]=(this.#mo-n)/r,o[o.length-1]=(this.#fo-s)/a,isNaN(i[6])&&!this.isEmpty())return this.#ko(o);const l=new Float32Array(this.#po.length+24+this.#co.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#Do(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#Po(l,h),this.newFreeDrawOutline(l,o,this.#ho,this.#yo,this.#do,this.#uo)}#ko(t){const e=this.#go,[i,n,s,r]=this.#ho,[a,o,l,h]=this.#Eo(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-i)/s,(e[3]-n)/r,NaN,NaN,NaN,NaN,(e[4]-i)/s,(e[5]-n)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/s,(e[17]-n)/r,NaN,NaN,NaN,NaN,(e[14]-i)/s,(e[15]-n)/r],0),this.newFreeDrawOutline(c,t,this.#ho,this.#yo,this.#do,this.#uo)}#Po(t,e){const i=this.#co;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#Do(t,e){const i=this.#go.subarray(4,6),n=this.#go.subarray(16,18),[s,r,a,o]=this.#ho,[l,h,c,d]=this.#Eo();return t.set([NaN,NaN,NaN,NaN,(i[0]-s)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(n[0]-s)/a,(n[1]-r)/o],e),e+24}}class Hs extends Us{#ho;#Io=new Float32Array(4);#do;#uo;#Ao;#yo;#Ro;constructor(t,e,i,n,s,r){super(),this.#Ro=t,this.#Ao=e,this.#ho=i,this.#yo=n,this.#do=s,this.#uo=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#Bo(r);const[a,o,l,h]=this.#Io;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(){const t=[`M${this.#Ro[4]} ${this.#Ro[5]}`];for(let e=6,i=this.#Ro.length;e<i;e+=6)isNaN(this.#Ro[e])?t.push(`L${this.#Ro[e+4]} ${this.#Ro[e+5]}`):t.push(`C${this.#Ro[e]} ${this.#Ro[e+1]} ${this.#Ro[e+2]} ${this.#Ro[e+3]} ${this.#Ro[e+4]} ${this.#Ro[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,n],s){const r=i-t,a=n-e;let o,l;switch(s){case 0:o=Us._rescale(this.#Ro,t,n,r,-a),l=Us._rescale(this.#Ao,t,n,r,-a);break;case 90:o=Us._rescaleAndSwap(this.#Ro,t,e,r,a),l=Us._rescaleAndSwap(this.#Ao,t,e,r,a);break;case 180:o=Us._rescale(this.#Ro,i,e,-r,a),l=Us._rescale(this.#Ao,i,e,-r,a);break;case 270:o=Us._rescaleAndSwap(this.#Ro,i,n,-r,-a),l=Us._rescaleAndSwap(this.#Ao,i,n,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#Bo(t){const e=this.#Ro;let i=e[4],n=e[5];const s=[i,n,i,n];let r=i,a=n,o=i,l=n;const h=t?Math.max:Math.min,c=new Float32Array(4);for(let t=6,d=e.length;t<d;t+=6){const d=e[t+4],u=e[t+5];isNaN(e[t])?(ht.pointBoundingBox(d,u,s),a>u?(r=d,a=u):a===u&&(r=h(r,d)),l<u?(o=d,l=u):l===u&&(o=h(o,d))):(c[0]=c[1]=1/0,c[2]=c[3]=-1/0,ht.bezierBoundingBox(i,n,...e.slice(t,t+6),c),ht.rectBoundingBox(c[0],c[1],c[2],c[3],s),a>c[1]?(r=c[0],a=c[1]):a===c[1]&&(r=h(r,c[0])),l<c[3]?(o=c[2],l=c[3]):l===c[3]&&(o=h(o,c[2]))),i=d,n=u}const d=this.#Io;d[0]=s[0]-this.#do,d[1]=s[1]-this.#do,d[2]=s[2]-s[0]+2*this.#do,d[3]=s[3]-s[1]+2*this.#do,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#Io}newOutliner(t,e,i,n,s,r=0){return new zs(t,e,i,n,s,r)}getNewOutline(t,e){const[i,n,s,r]=this.#Io,[a,o,l,h]=this.#ho,c=s*l,d=r*h,u=i*l+a,p=n*h+o,g=this.newOutliner({x:this.#Ao[0]*c+u,y:this.#Ao[1]*d+p},this.#ho,this.#yo,t,this.#uo,e??this.#do);for(let t=2;t<this.#Ao.length;t+=2)g.add({x:this.#Ao[t]*c+u,y:this.#Ao[t+1]*d+p});return g.getOutlines()}}class js{#ho;#Fo;#Lo;#Oo=[];#No=[];constructor(t,e=0,i=0,n=!0){const s=[1/0,1/0,-1/0,-1/0],r=10**-4;for(const{x:i,y:n,width:a,height:o}of t){const t=Math.floor((i-e)/r)*r,l=Math.ceil((i+a+e)/r)*r,h=Math.floor((n-e)/r)*r,c=Math.ceil((n+o+e)/r)*r,d=[t,h,c,!0],u=[l,h,c,!1];this.#Oo.push(d,u),ht.rectBoundingBox(t,h,l,c,s)}const a=s[2]-s[0]+2*i,o=s[3]-s[1]+2*i,l=s[0]-i,h=s[1]-i;let c=n?-1/0:1/0,d=1/0;const u=this.#Oo.at(n?-1:-2),p=[u[0],u[2]];for(const t of this.#Oo){const[e,i,s,r]=t;!r&&n?i<d?(d=i,c=e):i===d&&(c=Math.max(c,e)):r&&!n&&(i<d?(d=i,c=e):i===d&&(c=Math.min(c,e))),t[0]=(e-l)/a,t[1]=(i-h)/o,t[2]=(s-h)/o}this.#ho=new Float32Array([l,h,a,o]),this.#Fo=[c,d],this.#Lo=p}getOutlines(){this.#Oo.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Oo)e[3]?(t.push(...this.#Uo(e)),this.#zo(e)):(this.#Ho(e),t.push(...this.#Uo(e)));return this.#jo(t)}#jo(t){const e=[],i=new Set;for(const i of t){const[t,n,s]=i;e.push([t,n,i],[t,s,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,n=e.length;t<n;t+=2){const n=e[t][2],s=e[t+1][2];n.push(s),s.push(n),i.add(n),i.add(s)}const n=[];let s;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,c=r;for(s=[e,a],n.push(s);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(s.push(h,c,e,c===r?r:a),h=e),c=c===r?a:r}s.push(h,c)}return new Gs(n,this.#ho,this.#Fo,this.#Lo)}#Go(t){const e=this.#No;let i=0,n=e.length-1;for(;i<=n;){const s=i+n>>1,r=e[s][0];if(r===t)return s;r<t?i=s+1:n=s-1}return n+1}#zo([,t,e]){const i=this.#Go(t);this.#No.splice(i,0,[t,e])}#Ho([,t,e]){const i=this.#Go(t);for(let n=i;n<this.#No.length;n++){const[i,s]=this.#No[n];if(i!==t)break;if(i===t&&s===e)return void this.#No.splice(n,1)}for(let n=i-1;n>=0;n--){const[i,s]=this.#No[n];if(i!==t)break;if(i===t&&s===e)return void this.#No.splice(n,1)}}#Uo(t){const[e,i,n]=t,s=[[e,i,n]],r=this.#Go(n);for(let t=0;t<r;t++){const[i,n]=this.#No[t];for(let t=0,r=s.length;t<r;t++){const[,a,o]=s[t];if(!(n<=a||o<=i))if(a>=i)if(o>n)s[t][1]=n;else{if(1===r)return[];s.splice(t,1),t--,r--}else s[t][2]=i,o>n&&s.push([e,n,o])}}return s}}class Gs extends Us{#ho;#$o;constructor(t,e,i,n){super(),this.#$o=t,this.#ho=e,this.firstPoint=i,this.lastPoint=n}toSVGPath(){const t=[];for(const e of this.#$o){let[i,n]=e;t.push(`M${i} ${n}`);for(let s=2;s<e.length;s+=2){const r=e[s],a=e[s+1];r===i?(t.push(`V${a}`),n=a):a===n&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,n],s){const r=[],a=i-t,o=n-e;for(const e of this.#$o){const i=new Array(e.length);for(let s=0;s<e.length;s+=2)i[s]=t+e[s]*a,i[s+1]=n-e[s+1]*o;r.push(i)}return r}get box(){return this.#ho}get classNamesForOutlining(){return["highlightOutline"]}}class $s extends zs{newFreeDrawOutline(t,e,i,n,s,r){return new Vs(t,e,i,n,s,r)}}class Vs extends Hs{newOutliner(t,e,i,n,s,r=0){return new $s(t,e,i,n,s,r)}}class Ws extends ge{#Vo=null;#Wo=0;#Xo;#qo=null;#f=null;#Ko=null;#Yo=null;#Jo=0;#Qo=null;#Zo=null;#O=null;#tl=!1;#Fo=null;#Lo=null;#el=null;#_e="";#wo;#il="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=f.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Ws.prototype;return Q(this,"_keyboardManager",new le([[["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||Ws._defaultColor,this.#wo=t.thickness||Ws._defaultThickness,this.opacity=t.opacity||Ws._defaultOpacity,this.#Xo=t.boxes||null,this.#il=t.methodOfCreation||"",this.#_e=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#tl=!0,this.#nl(t),this.#sl()):this.#Xo&&(this.#Vo=t.anchorNode,this.#Wo=t.anchorOffset,this.#Yo=t.focusNode,this.#Jo=t.focusOffset,this.#rl(),this.#sl(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#tl?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#wo,methodOfCreation:this.#il}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#rl(){const t=new js(this.#Xo,.001);this.#Zo=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#Zo.box;const e=new js(this.#Xo,.0025,.001,"ltr"===this._uiManager.direction);this.#Ko=e.getOutlines();const{firstPoint:i}=this.#Zo;this.#Fo=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];const{lastPoint:n}=this.#Ko;this.#Lo=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#nl({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#Zo=t;if(this.#Ko=t.getNewOutline(this.#wo/2+1.5,.0025),e>=0)this.#O=e,this.#qo=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#el=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ko.box,path:{d:this.#Ko.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#O,{bbox:Ws.#al(this.#Zo.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#el,{bbox:Ws.#al(this.#Ko.box,e),path:{d:this.#Ko.toSVGPath()}})}const[n,s,r,a]=t.box;switch(this.rotation){case 0:this.x=n,this.y=s,this.width=r,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=s,this.y=1-n,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-n,this.y=1-s,this.width=r,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-s,this.y=n,this.width=r*e/t,this.height=a*t/e;break}}const{firstPoint:o}=t;this.#Fo=[(o[0]-n)/r,(o[1]-s)/a];const{lastPoint:l}=this.#Ko;this.#Lo=[(l[0]-n)/r,(l[1]-s)/a]}static initialize(t,e){ge.initialize(t,e),Ws._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case b.HIGHLIGHT_COLOR:Ws._defaultColor=e;break;case b.HIGHLIGHT_THICKNESS:Ws._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Lo}get commentButtonPosition(){return this.#Fo}updateParams(t,e){switch(t){case b.HIGHLIGHT_COLOR:this.#Ma(e);break;case b.HIGHLIGHT_THICKNESS:this.#ol(e)}}static get defaultPropertiesToUpdate(){return[[b.HIGHLIGHT_COLOR,Ws._defaultColor],[b.HIGHLIGHT_THICKNESS,Ws._defaultThickness]]}get propertiesToUpdate(){return[[b.HIGHLIGHT_COLOR,this.color||Ws._defaultColor],[b.HIGHLIGHT_THICKNESS,this.#wo||Ws._defaultThickness],[b.HIGHLIGHT_FREE,this.#tl]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#O,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#f?.updateColor(this.color),super.onUpdatedColor()}#Ma(t){const e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,n=this.opacity;this.addCommands({cmd:e.bind(this,t,Ws._defaultOpacity),undo:e.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:b.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#ol(t){const e=this.#wo,i=t=>{this.#wo=t,this.#ll(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:b.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",this.#f=new Zn({editor:this})]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#hl())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#hl())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#cl(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#sl(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#cl():t&&(this.#sl(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#ll(t){this.#tl&&(this.#nl({highlightOutlines:this.#Zo.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#cl(){null!==this.#O&&this.parent&&(this.parent.drawLayer.remove(this.#O),this.#O=null,this.parent.drawLayer.remove(this.#el),this.#el=null)}#sl(t=this.parent){null===this.#O&&(({id:this.#O,clipPathId:this.#qo}=t.drawLayer.draw({bbox:this.#Zo.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#tl},path:{d:this.#Zo.toSVGPath()}},!1,!0)),this.#el=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#tl},bbox:this.#Ko.box,path:{d:this.#Ko.toSVGPath()}},this.#tl),this.#Qo&&(this.#Qo.style.clipPath=this.#qo))}static#al([t,e,i,n],s){switch(s){case 90:return[1-e-n,t,n,i];case 180:return[1-t-i,1-e-n,i,n];case 270:return[e,1-t-i,n,i]}return[t,e,i,n]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#tl?(t=(t-this.rotation+360)%360,i=Ws.#al(this.#Zo.box,t)):i=Ws.#al([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#O,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#el,{bbox:Ws.#al(this.#Ko.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#_e&&(t.setAttribute("aria-label",this.#_e),t.setAttribute("role","mark")),this.#tl?t.classList.add("free"):this.div.addEventListener("keydown",this.#dl.bind(this),{signal:this._uiManager._signal});const e=this.#Qo=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#qo,this.setDims(),ne(this,this.#Qo,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#el,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#el,{rootClass:{hovered:!1}})}#dl(t){Ws._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#ul(!0);break;case 1:case 3:this.#ul(!1)}}#ul(t){if(!this.#Vo)return;const e=window.getSelection();t?e.setPosition(this.#Vo,this.#Wo):e.setPosition(this.#Yo,this.#Jo)}select(){super.select(),this.#el&&this.parent?.drawLayer.updateProperties(this.#el,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#el&&(this.parent?.drawLayer.updateProperties(this.#el,{rootClass:{selected:!1}}),this.#tl||this.#ul(!1))}get _mustFixPosition(){return!this.#tl}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#O,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#el,{rootClass:{hidden:!t}}))}#hl(){return this.#tl?this.rotation:0}#pl(){if(this.#tl)return null;const[t,e]=this.pageDimensions,[i,n]=this.pageTranslation,s=this.#Xo,r=new Float32Array(8*s.length);let a=0;for(const{x:o,y:l,width:h,height:c}of s){const s=o*t+i,d=(1-l)*e+n;r[a]=r[a+4]=s,r[a+1]=r[a+3]=d,r[a+2]=r[a+6]=s+h*t,r[a+5]=r[a+7]=d-c*e,a+=8}return r}#gl(t){return this.#Zo.serialize(t,this.#hl())}static startHighlighting(t,e,{target:i,x:n,y:s}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=e=>{h.abort(),this.#ml(t,e)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Rt,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",It,{signal:c}),i.addEventListener("pointermove",this.#fl.bind(this,t),{signal:c}),this._freeHighlight=new $s({x:n,y:s},[r,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#fl(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#ml(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 n=null;if(t instanceof Ds){const{data:{quadPoints:e,rect:i,rotation:s,id:r,color:a,opacity:o,popupRef:l,richText:h,contentsObj:c,creationDate:d,modificationDate:u},parent:{page:{pageNumber:p}}}=t;n=t={annotationType:f.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:h,comment:c?.str||null,creationDate:d,modificationDate:u}}else if(t instanceof ks){const{data:{inkLists:e,rect:i,rotation:s,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:c,creationDate:d,modificationDate:u},parent:{page:{pageNumber:p}}}=t;n=t={annotationType:f.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:h,comment:c?.str||null,creationDate:d,modificationDate:u}}const{color:s,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=ht.makeHexColor(...s),l.opacity=o||1,a&&(l.#wo=t.thickness),l._initialData=n,t.comment&&l.setCommentData(t);const[h,c]=l.pageDimensions,[d,u]=l.pageTranslation;if(r){const t=l.#Xo=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-d)/h,y:1-(r[e+1]-u)/c,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/c});l.#rl(),l.#sl(),l.rotate(l.rotation)}else if(a){l.#tl=!0;const t=a[0],i={x:t[0]-d,y:c-(t[1]-u)},n=new $s(i,[0,0,h,c],1,l.#wo/2,!0,.001);for(let e=0,s=t.length;e<s;e+=2)i.x=t[e]-d,i.y=c-(t[e+1]-u),n.add(i);const{id:s,clipPathId:r}=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:n.toSVGPath()}},!0,!0);l.#nl({highlightOutlines:n.getOutlines(),highlightId:s,clipPathId:r}),l.#sl(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=ge._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#wo,quadPoints:this.#pl(),outlines:this.#gl(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#lo(i)?null:(i.id=this.annotationElementId,i)}#lo(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class Xs{#bl=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#bl[t]=e}toSVGProperties(){const t=this.#bl;return this.#bl=Object.create(null),{root:t}}reset(){this.#bl=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){X("Not implemented")}}class qs extends ge{#vl=null;#yl;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#wl=null;static#Al=null;static#xl=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#yl=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(this.#Sl(t),this.#sl())}#Sl({drawOutlines:t,drawId:e,drawingOptions:i}){this.#vl=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Cl(t,this.parent),this.#El(t.box)}#Cl(t,e){const{id:i}=e.drawLayer.draw(qs._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[n,s]of Object.entries(e))i.has(n)?Object.assign(t[n],s):t[n]=s;return t}static getDefaultDrawingOptions(t){X("Not implemented")}static get typesMap(){X("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(qs.#wl.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,n]of this.typesMap)t.push([i,e[n]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,n]of this.constructor.typesMap)t.push([i,e[n]]);return t}_updateProperty(t,e,i){const n=this._drawingOptions,s=n[e],r=i=>{n.updateProperty(e,i);const s=this.#vl.updateProperty(e,i);s&&this.#El(s),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,qs._mergeSVGProperties(this.#vl.getPathResizingSVGProperties(this.#Tl()),{bbox:this.#_l()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,qs._mergeSVGProperties(this.#vl.getPathResizedSVGProperties(this.#Tl()),{bbox:this.#_l()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#_l()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,qs._mergeSVGProperties(this.#vl.getPathTranslatedSVGProperties(this.#Tl(),this.parentDimensions),{bbox:this.#_l()}))}_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.#yl&&(this.#yl=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#cl(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#sl(),this.#El(this.#vl.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#cl()):t&&(this._uiManager.addShouldRescale(this),this.#sl(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#cl(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#sl(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Cl(this.#vl,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Ml([t,e,i,n]){const{parentDimensions:[s,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/s),n*(s/r)];case 180:return[1-t,1-e,i,n];case 270:return[1-e,t,i*(r/s),n*(s/r)];default:return[t,e,i,n]}}#Tl(){const{x:t,y:e,width:i,height:n,parentDimensions:[s,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(s/r),n*(r/s)];case 180:return[1-t,1-e,i,n];case 270:return[e,1-t,i*(s/r),n*(r/s)];default:return[t,e,i,n]}}#El(t){[this.x,this.y,this.width,this.height]=this.#Ml(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#_l(){const{x:t,y:e,width:i,height:n,rotation:s,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*s+r)/90){case 1:return[1-e-n,t,n,i];case 2:return[1-t-i,1-e-n,i,n];case 3:return[e,1-t-i,n,i];case 4:return[t,e-i*(a/o),n*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),n*(o/a)];case 6:return[1-t-n*(o/a),1-e,n*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-n*(o/a),i*(a/o),n*(o/a)];case 8:return[t-i,e-n,i,n];case 9:return[1-e,t-i,n,i];case 10:return[1-t,1-e,i,n];case 11:return[e-n,1-t,n,i];case 12:return[t-n*(o/a),e,n*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-n*(o/a),i*(a/o),n*(o/a)];case 14:return[1-t,1-e-i*(a/o),n*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),n*(o/a)];default:return[t,e,i,n]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,qs._mergeSVGProperties({bbox:this.#_l()},this.#vl.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#El(this.#vl.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const n=document.createElement("div");return i.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,n,s){X("Not implemented")}static startDrawing(t,e,i,n){const{target:s,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=n;if(se.isInitializedAndDifferentPointerType(l))return;const{viewport:{rotation:h}}=t,{width:c,height:d}=s.getBoundingClientRect(),u=qs.#Al=new AbortController,p=t.combinedSignal(u);se.setPointer(l,o),window.addEventListener("pointerup",(t=>{se.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)}),{signal:p}),window.addEventListener("pointercancel",(t=>{se.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()}),{signal:p}),window.addEventListener("pointerdown",(t=>{se.isSamePointerType(t.pointerType)&&(se.initializeAndAddPointerId(t.pointerId),qs.#wl.isCancellable()&&(qs.#wl.removeLastElement(),qs.#wl.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",It,{signal:p}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),s.addEventListener("touchmove",(t=>{se.isSameTimeStamp(t.timeStamp)&&Rt(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),qs.#wl?t.drawLayer.updateProperties(this._currentDrawId,qs.#wl.startNew(r,a,c,d,h)):(e.updateUIForDefaultProperties(this),qs.#wl=this.createDrawerInstance(r,a,c,d,h),qs.#xl=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(qs.#xl.toSVGProperties(),qs.#wl.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(se.isSameTimeStamp(t.timeStamp),!qs.#wl)return;const{offsetX:e,offsetY:i,pointerId:n}=t;se.isSamePointerId(n)&&(se.isUsingMultiplePointers()?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,qs.#wl.add(e,i)),se.setTimeStamp(t.timeStamp),Rt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,qs.#wl=null,qs.#xl=null,se.clearTimeStamp()),qs.#Al&&(qs.#Al.abort(),qs.#Al=null,se.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,qs.#wl.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=qs.#wl,i=this._currentDrawId,n=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:b.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(b.DRAW_STEP),!qs.#wl.isEmpty()){const{pageDimensions:[i,n],scale:s}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:qs.#wl.getOutlines(i*s,n*s,s,this._INNER_MARGIN),drawingOptions:qs.#xl,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,n,s,r){X("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:n,pageHeight:s,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,n,s,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#Sl({drawOutlines:o}),l.#sl(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[n,s]=this.pageDimensions;return this.#vl.serialize([e,i,n,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class Ks{#go=new Float64Array(6);#Fa;#kl;#zs;#wo;#Ao;#Dl="";#Pl=0;#$o=new Ys;#Il;#Rl;constructor(t,e,i,n,s,r){this.#Il=i,this.#Rl=n,this.#zs=s,this.#wo=r,[t,e]=this.#Bl(t,e);const a=this.#Fa=[NaN,NaN,NaN,NaN,t,e];this.#Ao=[t,e],this.#kl=[{line:a,points:this.#Ao}],this.#go.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#wo=e)}#Bl(t,e){return Us._normalizePoint(t,e,this.#Il,this.#Rl,this.#zs)}isEmpty(){return!this.#kl||0===this.#kl.length}isCancellable(){return this.#Ao.length<=10}add(t,e){[t,e]=this.#Bl(t,e);const[i,n,s,r]=this.#go.subarray(2,6),a=t-s,o=e-r;return Math.hypot(this.#Il*a,this.#Rl*o)<=2?null:(this.#Ao.push(t,e),isNaN(i)?(this.#go.set([s,r,t,e],2),this.#Fa.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#go[0])&&this.#Fa.splice(6,6),this.#go.set([i,n,s,r,t,e],0),this.#Fa.push(...Us.createBezierPoints(i,n,s,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#Ao.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,n,s){this.#Il=i,this.#Rl=n,this.#zs=s,[t,e]=this.#Bl(t,e);const r=this.#Fa=[NaN,NaN,NaN,NaN,t,e];this.#Ao=[t,e];const a=this.#kl.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#kl.push({line:r,points:this.#Ao}),this.#go.set(r,0),this.#Pl=0,this.toSVGPath(),null}getLastElement(){return this.#kl.at(-1)}setLastElement(t){return this.#kl?(this.#kl.push(t),this.#Fa=t.line,this.#Ao=t.points,this.#Pl=0,{path:{d:this.toSVGPath()}}):this.#$o.setLastElement(t)}removeLastElement(){if(!this.#kl)return this.#$o.removeLastElement();this.#kl.pop(),this.#Dl="";for(let t=0,e=this.#kl.length;t<e;t++){const{line:e,points:i}=this.#kl[t];this.#Fa=e,this.#Ao=i,this.#Pl=0,this.toSVGPath()}return{path:{d:this.#Dl}}}toSVGPath(){const t=Us.svgRound(this.#Fa[4]),e=Us.svgRound(this.#Fa[5]);if(2===this.#Ao.length)return this.#Dl=`${this.#Dl} M ${t} ${e} Z`,this.#Dl;if(this.#Ao.length<=6){const i=this.#Dl.lastIndexOf("M");this.#Dl=`${this.#Dl.slice(0,i)} M ${t} ${e}`,this.#Pl=6}if(4===this.#Ao.length){const t=Us.svgRound(this.#Fa[10]),e=Us.svgRound(this.#Fa[11]);return this.#Dl=`${this.#Dl} L ${t} ${e}`,this.#Pl=12,this.#Dl}const i=[];0===this.#Pl&&(i.push(`M ${t} ${e}`),this.#Pl=6);for(let t=this.#Pl,e=this.#Fa.length;t<e;t+=6){const[e,n,s,r,a,o]=this.#Fa.slice(t,t+6).map(Us.svgRound);i.push(`C${e} ${n} ${s} ${r} ${a} ${o}`)}return this.#Dl+=i.join(" "),this.#Pl=this.#Fa.length,this.#Dl}getOutlines(t,e,i,n){const s=this.#kl.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#$o.build(this.#kl,t,e,i,this.#zs,this.#wo,n),this.#go=null,this.#Fa=null,this.#kl=null,this.#Dl=null,this.#$o}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Ys extends Us{#Io;#Fl=0;#do;#kl;#Il;#Rl;#Ll;#zs;#wo;build(t,e,i,n,s,r,a){this.#Il=e,this.#Rl=i,this.#Ll=n,this.#zs=s,this.#wo=r,this.#do=a??0,this.#kl=t,this.#Ol()}get thickness(){return this.#wo}setLastElement(t){return this.#kl.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#kl.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#kl)if(t.push(`M${Us.svgRound(e[4])} ${Us.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Us.svgRound(e[10])} ${Us.svgRound(e[11])}`);else for(let i=6,n=e.length;i<n;i+=6){const[n,s,r,a,o,l]=e.subarray(i,i+6).map(Us.svgRound);t.push(`C${n} ${s} ${r} ${a} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,n],s){const r=[],a=[],[o,l,h,c]=this.#Nl();let d,u,p,g,m,f,b,v,y;switch(this.#zs){case 0:y=Us._rescale,d=t,u=e+n,p=i,g=-n,m=t+o*i,f=e+(1-l-c)*n,b=t+(o+h)*i,v=e+(1-l)*n;break;case 90:y=Us._rescaleAndSwap,d=t,u=e,p=i,g=n,m=t+l*i,f=e+o*n,b=t+(l+c)*i,v=e+(o+h)*n;break;case 180:y=Us._rescale,d=t+i,u=e,p=-i,g=n,m=t+(1-o-h)*i,f=e+l*n,b=t+(1-o)*i,v=e+(l+c)*n;break;case 270:y=Us._rescaleAndSwap,d=t+i,u=e+n,p=-i,g=-n,m=t+(1-l-c)*i,f=e+(1-o-h)*n,b=t+(1-l)*i,v=e+(1-o)*n}for(const{line:t,points:e}of this.#kl)r.push(y(t,d,u,p,g,s?new Array(t.length):null)),a.push(y(e,d,u,p,g,s?new Array(e.length):null));return{lines:r,points:a,rect:[m,f,b,v]}}static deserialize(t,e,i,n,s,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let c,d,u,p,g;switch(o){case 0:g=Us._rescale,c=-t/i,d=e/n+1,u=1/i,p=-1/n;break;case 90:g=Us._rescaleAndSwap,c=-e/n,d=-t/i,u=1/n,p=1/i;break;case 180:g=Us._rescale,c=t/i+1,d=-e/n,u=-1/i,p=1/n;break;case 270:g=Us._rescaleAndSwap,c=e/n+1,d=t/i+1,u=-1/n,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[n,s,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,n,s],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(Us.createBezierPoints(n,s,a,o,e,l),3*(r-2)),[n,s,a,o]=[a,o,e,l]}}}for(let t=0,e=r.length;t<e;t++)h.push({line:g(r[t].map((t=>t??NaN)),c,d,u,p),points:g(a[t].map((t=>t??NaN)),c,d,u,p)});const m=new this.prototype.constructor;return m.build(h,i,n,1,o,l,s),m}#Ul(t=this.#wo){const e=this.#do+t/2*this.#Ll;return this.#zs%180==0?[e/this.#Il,e/this.#Rl]:[e/this.#Rl,e/this.#Il]}#Nl(){const[t,e,i,n]=this.#Io,[s,r]=this.#Ul(0);return[t+s,e+r,i-2*s,n-2*r]}#Ol(){const t=this.#Io=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#kl){if(e.length<=12){for(let i=4,n=e.length;i<n;i+=6)ht.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],n=e[5];for(let s=6,r=e.length;s<r;s+=6){const[r,a,o,l,h,c]=e.subarray(s,s+6);ht.bezierBoundingBox(i,n,r,a,o,l,h,c,t),i=h,n=c}}const[e,i]=this.#Ul();t[0]=vt(t[0]-e,0,1),t[1]=vt(t[1]-i,0,1),t[2]=vt(t[2]+e,0,1),t[3]=vt(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#Io}updateProperty(t,e){return"stroke-width"===t?this.#ol(e):null}#ol(t){const[e,i]=this.#Ul();this.#wo=t;const[n,s]=this.#Ul(),[r,a]=[n-e,s-i],o=this.#Io;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[n,s]=this.#Ul();this.#Il=t,this.#Rl=e,this.#Ll=i;const[r,a]=this.#Ul(),o=r-n,l=a-s,h=this.#Io;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Fl=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#Io.map(Us.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Io;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Us.svgRound(t)} ${Us.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#Io;let i=0,n=0,s=0,r=0,a=0,o=0;switch(this.#Fl){case 90:n=e/t,s=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:n=-e/t,s=t/e,o=e;break;default:return""}return`matrix(${i} ${n} ${s} ${r} ${Us.svgRound(a)} ${Us.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,n]){const[s,r]=this.#Ul(),[a,o,l,h]=this.#Io;if(Math.abs(l-s)<=Us.PRECISION||Math.abs(h-r)<=Us.PRECISION){const s=t+i/2-(a+l/2),r=e+n/2-(o+h/2);return{path:{"transform-origin":`${Us.svgRound(t)} ${Us.svgRound(e)}`,transform:`${this.rotationTransform} translate(${s} ${r})`}}}const c=(i-2*s)/(l-2*s),d=(n-2*r)/(h-2*r),u=l/i,p=h/n;return{path:{"transform-origin":`${Us.svgRound(a)} ${Us.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Us.svgRound(s)} ${Us.svgRound(r)}) scale(${c} ${d}) translate(${Us.svgRound(-s)} ${Us.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,n]){const[s,r]=this.#Ul(),a=this.#Io,[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=n,Math.abs(h-s)<=Us.PRECISION||Math.abs(c-r)<=Us.PRECISION){const s=t+i/2-(o+h/2),r=e+n/2-(l+c/2);for(const{line:t,points:e}of this.#kl)Us._translate(t,s,r,t),Us._translate(e,s,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Us.svgRound(t)} ${Us.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(i-2*s)/(h-2*s),u=(n-2*r)/(c-2*r),p=-d*(o+s)+t+s,g=-u*(l+r)+e+r;if(1!==d||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#kl)Us._rescale(t,p,g,d,u,t),Us._rescale(e,p,g,d,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Us.svgRound(t)} ${Us.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[n,s]=i,r=this.#Io,a=t-r[0],o=e-r[1];if(this.#Il===n&&this.#Rl===s)for(const{line:t,points:e}of this.#kl)Us._translate(t,a,o,t),Us._translate(e,a,o,e);else{const t=this.#Il/n,e=this.#Rl/s;this.#Il=n,this.#Rl=s;for(const{line:i,points:n}of this.#kl)Us._rescale(i,a,o,t,e,i),Us._rescale(n,a,o,t,e,n);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Us.svgRound(t)} ${Us.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Io;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Us.svgRound(t[0])} ${Us.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Js extends Xs{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:ge._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._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Js(this._viewParameters);return t.updateAll(this),t}}class Qs extends qs{static _type="ink";static _editorType=f.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){ge.initialize(t,e),this._defaultDrawingOptions=new Js(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Q(this,"typesMap",new Map([[b.INK_THICKNESS,"stroke-width"],[b.INK_COLOR,"stroke"],[b.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,n,s){return new Ks(t,e,i,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,n,s,r){return Ys.deserialize(t,e,i,n,s,r)}static async deserialize(t,e,i){let n=null;if(t instanceof ks){const{data:{inkLists:e,rect:i,rotation:s,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:c,contentsObj:d,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;n=t={annotationType:f.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:h,richText:c,comment:d?.str||null,creationDate:u,modificationDate:p}}const s=await super.deserialize(t,e,i);return s._initialData=n,t.comment&&s.setCommentData(t),s}get toolbarButtons(){return this._colorPicker||=new ts(this),[["colorPicker",this._colorPicker]]}get colorType(){return b.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const 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=Qs.getDefaultDrawingOptions({stroke:ht.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":s,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:ge._colorManager.convert(n),opacity:s,thickness:r,paths:{lines:e,points:i}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#lo(a)?null:(a.id=this.annotationElementId,a)}#lo(t){const{color:e,thickness:i,opacity:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==n||t.pageIndex!==s}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class Zs extends Ys{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}i(5213);class tr{static#zl={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Hl(t,e,i,n){return n-=e,0===(i-=t)?n>0?0:4:1===i?n+6:2-n}static#jl=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#Gl(t,e,i,n,s,r,a){const o=this.#Hl(i,n,s,r);for(let s=0;s<8;s++){const r=(-s+o-a+16)%8;if(0!==t[(i+this.#jl[2*r])*e+(n+this.#jl[2*r+1])])return r}return-1}static#$l(t,e,i,n,s,r,a){const o=this.#Hl(i,n,s,r);for(let s=0;s<8;s++){const r=(s+o+a+16)%8;if(0!==t[(i+this.#jl[2*r])*e+(n+this.#jl[2*r+1])])return r}return-1}static#Vl(t,e,i,n){const s=t.length,r=new Int32Array(s);for(let e=0;e<s;e++)r[e]=t[e]<=n?1:0;for(let t=1;t<i-1;t++)r[t*e]=r[t*e+e-1]=0;for(let t=0;t<e;t++)r[t]=r[e*i-1-t]=0;let a,o=1;const l=[];for(let t=1;t<i-1;t++){a=1;for(let i=1;i<e-1;i++){const n=t*e+i,s=r[n];if(0===s)continue;let h=t,c=i;if(1===s&&0===r[n-1])o+=1,c-=1;else{if(!(s>=1&&0===r[n+1])){1!==s&&(a=Math.abs(s));continue}o+=1,c+=1,s>1&&(a=s)}const d=[i,t],u=c===i+1,p={isHole:u,points:d,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===a){g=t;break}g?g.isHole?p.parent=u?g.parent:a:p.parent=u?a:g.parent:p.parent=u?a:0;const m=this.#Gl(r,e,t,i,h,c,0);if(-1===m){r[n]=-o,1!==r[n]&&(a=Math.abs(r[n]));continue}let f=this.#jl[2*m],b=this.#jl[2*m+1];const v=t+f,y=i+b;h=v,c=y;let w=t,A=i;for(;;){const s=this.#$l(r,e,w,A,h,c,1);f=this.#jl[2*s],b=this.#jl[2*s+1];const l=w+f,u=A+b;d.push(u,l);const p=w*e+A;if(0===r[p+1]?r[p]=-o:1===r[p]&&(r[p]=o),l===t&&u===i&&w===v&&A===y){1!==r[n]&&(a=Math.abs(r[n]));break}h=w,c=A,w=l,A=u}}}return l}static#Wl(t,e,i,n){if(i-e<=4){for(let s=e;s<i-2;s+=2)n.push(t[s],t[s+1]);return}const s=t[e],r=t[e+1],a=t[i-4]-s,o=t[i-3]-r,l=Math.hypot(a,o),h=a/l,c=o/l,d=h*r-c*s,u=o/a,p=1/l,g=Math.atan(u),m=Math.cos(g),f=Math.sin(g),b=p*(Math.abs(m)+Math.abs(f)),v=p*(1-b+b**2),y=Math.max(Math.atan(Math.abs(f+m)*v),Math.atan(Math.abs(f-m)*v));let w=0,A=e;for(let n=e+2;n<i-2;n+=2){const e=Math.abs(d-h*t[n+1]+c*t[n]);e>w&&(A=n,w=e)}w>(l*y)**2?(this.#Wl(t,e,A+2,n),this.#Wl(t,A,i,n)):n.push(s,r)}static#Xl(t){const e=[],i=t.length;return this.#Wl(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#ql(t,e,i,n,s,r){const a=new Float32Array(r**2),o=-2*n**2,l=r>>1;for(let t=0;t<r;t++){const e=(t-l)**2;for(let i=0;i<r;i++)a[t*r+i]=Math.exp((e+(i-l)**2)/o)}const h=new Float32Array(256),c=-2*s**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/c);const d=t.length,u=new Uint8Array(d),p=new Uint32Array(256);for(let n=0;n<i;n++)for(let s=0;s<e;s++){const o=n*e+s,c=t[o];let d=0,g=0;for(let o=0;o<r;o++){const u=n+o-l;if(!(u<0||u>=i))for(let i=0;i<r;i++){const n=s+i-l;if(n<0||n>=e)continue;const p=t[u*e+n],m=a[o*r+i]*h[Math.abs(p-c)];d+=p*m,g+=m}}p[u[o]=Math.round(d/g)]++}return[u,p]}static#Kl(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#Yl(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let n=-1/0,s=1/0;for(let e=0,r=i.length;e<r;e++){const r=i[e]=t[e<<2];n=Math.max(n,r),s=Math.min(s,r)}const r=255/(n-s);for(let t=0,e=i.length;t<e;t++)i[t]=(i[t]-s)*r;return i}static#Jl(t){let e,i=-1/0,n=-1/0;const s=t.findIndex((t=>0!==t));let r=s,a=s;for(e=s;e<256;e++){const s=t[e];s>i&&(e-r>n&&(n=e-r,a=e-1),i=s,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#Ql(t){const e=t,{width:i,height:n}=t,{maxDim:s}=this.#zl;let r=i,a=n;if(i>s||n>s){let o=i,l=n,h=Math.log2(Math.max(i,n)/s);const c=Math.floor(h);h=h===c?c-1:c;for(let i=0;i<h;i++){r=Math.ceil(o/2),a=Math.ceil(l/2);const i=new OffscreenCanvas(r,a);i.getContext("2d").drawImage(t,0,0,o,l,0,0,r,a),o=r,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}const d=Math.min(s/r,s/a);r=Math.round(r*d),a=Math.round(a*d)}const o=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,r,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,r,a);const l=o.getImageData(0,0,r,a).data;return[this.#Yl(l),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:n},s,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=h.font=`${i} ${n} 200px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),v=1.5,y=Math.ceil(Math.max(Math.abs(d)+Math.abs(u)||0,b)*v),w=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200)*v);l=new OffscreenCanvas(y,w),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=c,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,y,w),h.fillStyle="black",h.fillText(t,.5*y/2,1.5*w/2);const A=this.#Yl(h.getImageData(0,0,y,w).data),x=this.#Kl(A),S=this.#Jl(x),C=this.#Vl(A,y,w,S);return this.processDrawnLines({lines:{curves:C,width:y,height:w},pageWidth:s,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,n,s){const[r,a,o]=this.#Ql(t),[l,h]=this.#ql(r,a,o,Math.hypot(a,o)*this.#zl.sigmaSFactor,this.#zl.sigmaR,this.#zl.kernelSize),c=this.#Jl(h),d=this.#Vl(l,a,o,c);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:i,rotation:n,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:s,mustSmooth:r,areContours:a}){n%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(const{points:t}of o){const e=r?this.#Xl(t):t;if(!e)continue;m.push(e);const i=e.length,n=new Float32Array(i),s=new Float32Array(3*(2===i?2:i-2));if(d.push({line:s,points:n}),2===i){n[0]=e[0]*p,n[1]=e[1]*g,s.set([NaN,NaN,NaN,NaN,n[0],n[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,n.set([a,o,l,h],0),s.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){const i=n[t]=e[t]*p,r=n[t+1]=e[t+1]*g;s.set(Us.createBezierPoints(a,o,l,h,i,r),3*(t-2)),[a,o,l,h]=[l,h,i,r]}}if(0===d.length)return null;const f=a?new Zs:new Ys;return f.build(d,e,i,1,n,a?0:c,s),{outline:f,newCurves:m,areContours:a,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:n,height:s}){let r,a=1/0,o=-1/0,l=0;for(const e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}r=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,c=8+3*h,d=new Uint32Array(c);let u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*r.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=n,d[u++]=s,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(i??0)),d[u++]=h,d[u++]=r.BYTES_PER_ELEMENT;for(const e of t)d[u++]=e.length-2,d[u++]=e[0],d[u++]=e[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const m=r.prototype.constructor;for(const e of t){const t=new m(e.length-2);for(let i=2,n=e.length;i<n;i++)t[i-2]=e[i]-e[i-2];g.write(t)}g.close();const f=await new Response(p.readable).arrayBuffer();return new Uint8Array(f).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:i,writable:n}=new DecompressionStream("deflate-raw"),s=n.getWriter();await s.ready,s.write(e).then((async()=>{await s.ready,await s.close()})).catch((()=>{}));let r=null,a=0;const o=i.getReader();try{for(;;){const{done:t,value:e}=await o.read();if(t)break;r||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]),r.set(e,a),a+=e.length}}finally{o.releaseLock()}const l=new Uint32Array(r.buffer,0,r.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],u=0===l[4],p=l[5],g=l[6],m=l[7],f=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let v;switch(m){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(r.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(r.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(r.buffer,b)}a=0;for(let t=0;t<g;t++){const e=l[3*t+8],i=new Float32Array(e+2);f.push(i);for(let e=0;e<2;e++)i[e]=l[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+v[a++]}return{areContours:u,thickness:p,outlines:f,width:c,height:d}}catch(t){return W(`decompressSignature: ${t}`),null}}}class er extends Xs{constructor(){super(),super.updateProperties({fill:ge._defaultLineColor,"stroke-width":0})}clone(){const t=new er;return t.updateAll(this),t}}class ir extends Js{constructor(t){super(t),super.updateProperties({stroke:ge._defaultLineColor,"stroke-width":1})}clone(){const t=new ir(this._viewParameters);return t.updateAll(this),t}}class nr extends qs{#Zl=!1;#th=null;#eh=null;#ih=null;static _type="signature";static _editorType=f.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#eh=t.signatureData||null,this.#th=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){ge.initialize(t,e),this._defaultDrawingOptions=new er,this._defaultDrawnSignatureOptions=new ir(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Q(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#th}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#eh){const{lines:t,mustSmooth:e,areContours:i,description:n,uuid:s,heightInPage:r}=this.#eh,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=tr.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:nr._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,r,n,s)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#th||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#ih=t,this.addEditToolbar()}getUuid(){return this.#ih}get description(){return this.#th}set description(t){this.#th=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)})))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:n,height:s}=this.#eh,r=Math.max(n,s);return{areContours:e,outline:tr.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:i,width:n,height:s},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,n){const{x:s,y:r}=this,{outline:a}=this.#eh=t;let o;this.#Zl=a instanceof Zs,this.description=i,this.#Zl?o=nr.getDefaultDrawingOptions():(o=nr._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=s,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return tr.process(t,e,i,n,nr._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:s}=this.parent.viewport;return tr.extractContoursFromText(t,e,i,n,s,nr._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return tr.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:nr._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=nr.getDefaultDrawingOptions():(this._drawingOptions=nr._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#Zl,color:[0,0,0],thickness:this.#Zl?0:n});return this.addComment(s),t?(s.paths={lines:e,points:i},s.uuid=this.#ih,s.isCopy=!0):s.lines=e,this.#th&&(s.accessibilityData={type:"Figure",alt:this.#th}),s}static deserializeDraw(t,e,i,n,s,r){return r.areContours?Zs.deserialize(t,e,i,n,s,r):Ys.deserialize(t,e,i,n,s,r)}static async deserialize(t,e,i){const n=await super.deserialize(t,e,i);return n.#Zl=t.areContours,n.description=t.accessibilityData?.alt||"",n.#ih=t.uuid,n}}class sr extends ge{#nh=null;#sh=null;#rh=null;#ah=null;#oh=null;#lh="";#hh=null;#ch=!1;#dh=null;#uh=!1;#ph=!1;static _type="stamp";static _editorType=f.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#ah=t.bitmapUrl,this.#oh=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){ge.initialize(t,e)}static isHandlingMimeForPasting(t){return jt.includes(t)}static paste(t,e){e.pasteEditor({mode:f.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#gh(t,e=!1){t?(this.#nh=t.bitmap,e||(this.#sh=t.id,this.#uh=t.isSvg),t.file&&(this.#lh=t.file.name),this.#mh()):this.remove()}#fh(){if(this.#rh=null,this._uiManager.enableWaiting(!1),this.#hh)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#nh)this.addEditToolbar().then((()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)}));else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#nh){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:s,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:n,width:s,height:r,channels:n.length/(s*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#bh(){if(this.#sh)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#sh).then((t=>this.#gh(t,!0))).finally((()=>this.#fh()));if(this.#ah){const t=this.#ah;return this.#ah=null,this._uiManager.enableWaiting(!0),void(this.#rh=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#gh(t))).finally((()=>this.#fh())))}if(this.#oh){const t=this.#oh;return this.#oh=null,this._uiManager.enableWaiting(!0),void(this.#rh=this._uiManager.imageManager.getFromFile(t).then((t=>this.#gh(t))).finally((()=>this.#fh())))}const t=document.createElement("input");t.type="file",t.accept=jt.join(",");const e=this._uiManager._signal;this.#rh=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#gh(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#fh())),t.click()}remove(){this.#sh&&(this.#nh=null,this._uiManager.imageManager.deleteId(this.#sh),this.#hh?.remove(),this.#hh=null,this.#dh&&(clearTimeout(this.#dh),this.#dh=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#sh&&null===this.#hh&&this.#bh(),this.isAttachedToDOM||this.parent.add(this))):this.#sh&&this.#bh()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#rh||this.#nh||this.#ah||this.#oh||this.#sh||this.#ch)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#ch||(this.#nh?this.#mh():this.#bh()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:n}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#sh=i,n&&(this.#nh=n),this.#ch=!1,this.#mh())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#dh&&clearTimeout(this.#dh);this.#dh=setTimeout((()=>{this.#dh=null,this.#vh()}),200)}#mh(){const{div:t}=this;let{width:e,height:i}=this.#nh;const[n,s]=this.pageDimensions,r=.75;if(this.width)e=this.width*n,i=this.height*s;else if(e>r*n||i>r*s){const t=Math.min(r*n/e,r*s/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);const a=this.#hh=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/n,this.height=i/s,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#vh(),this.#ph||(this.parent.addUndoableEditor(this),this.#ph=!0),this._reportTelemetry({action:"inserted_image"}),this.#lh&&this.div.setAttribute("aria-description",this.#lh),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);const{width:n,height:s}=this.#nh,r=new Ht;let a=this.#nh,o=n,l=s,h=null;if(e){if(n>e||s>e){const t=Math.min(e/n,e/s);o=Math.floor(n*t),l=Math.floor(s*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#uh||(a=this.#yh(t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":Gt.isDarkMode&&(d="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,m=p*r.sy,f=new OffscreenCanvas(2*g,2*m),b=f.getContext("2d");b.fillStyle=d,b.fillRect(0,0,2*g,2*m),b.fillStyle=u,b.fillRect(0,0,g,m),b.fillRect(g,m,g,m),c.fillStyle=c.createPattern(f,"repeat"),c.fillRect(0,0,t,i),c.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let c=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#nh,n>t||s>t){const r=Math.min(t/n,t/s);e=Math.floor(n*r),i=Math.floor(s*r),this.#uh||(a=this.#yh(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),c={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:c}}#yh(t,e){const{width:i,height:n}=this.#nh;let s=i,r=n,a=this.#nh;for(;s>2*t||r>2*e;){const i=s,n=r;s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(s,r);o.getContext("2d").drawImage(a,0,0,i,n,0,0,s,r),a=o.transferToImageBitmap()}return a}#vh(){const[t,e]=this.parentDimensions,{width:i,height:n}=this,s=new Ht,r=Math.ceil(i*t*s.sx),a=Math.ceil(n*e*s.sy),o=this.#hh;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#uh?this.#nh:this.#yh(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#wh(t){if(t){if(this.#uh){const t=this._uiManager.imageManager.getSvgUrl(this.#sh);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#nh);return t.getContext("2d").drawImage(this.#nh,0,0),t.toDataURL()}if(this.#uh){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*xt.PDF_TO_CSS_UNITS),n=Math.round(this.height*e*xt.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,n);return s.getContext("2d").drawImage(this.#nh,0,0,this.#nh.width,this.#nh.height,0,0,i,n),s.transferToImageBitmap()}return structuredClone(this.#nh)}static async deserialize(t,e,i){let n=null,s=!1;if(t instanceof Bs){const{data:{rect:r,rotation:a,id:o,structParent:l,popupRef:h,richText:c,contentsObj:d,creationDate:u,modificationDate:p},container:g,parent:{page:{pageNumber:m}},canvas:b}=t;let v,y;b?(delete t.canvas,({id:v,bitmap:y}=i.imageManager.getFromCanvas(g.id,b)),b.remove()):(s=!0,t._hasNoCanvas=!0);const w=(await e._structTree.getAriaAttributes(`${gt}${o}`))?.get("aria-label")||"";n=t={annotationType:f.STAMP,bitmapId:v,bitmap:y,pageIndex:m-1,rect:r.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:w},isSvg:!1,structParent:l,popupRef:h,richText:c,comment:d?.str||null,creationDate:u,modificationDate:p}}const r=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:d}=t;s?(i.addMissingCanvas(t.id,r),r.#ch=!0):h&&i.imageManager.isValidId(h)?(r.#sh=h,o&&(r.#nh=o)):r.#ah=l,r.#uh=c;const[u,p]=r.pageDimensions;return r.width=(a[2]-a[0])/u,r.height=(a[3]-a[1])/p,d&&(r.altTextData=d),r._initialData=n,t.comment&&r.setCommentData(t),r.#ph=!!n,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:this.#sh,isSvg:this.#uh});if(this.addComment(i),t)return i.bitmapUrl=this.#wh(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:n,altText:s}=this.serializeAltText(!1);if(!n&&s&&(i.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const t=this.#lo(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;const r=this.#uh?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#sh)){if(this.#uh){const t=e.stamps.get(this.#sh);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#wh(!1))}}else e.stamps.set(this.#sh,{area:r,serialized:i}),i.bitmap=this.#wh(!1);return i}#lo(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,n=t.pageIndex===e,s=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&s,isSameAltText:s}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class rr{#$a;#Ah=!1;#xh=null;#Sh=null;#Ch=null;#Eh=new Map;#Th=!1;#_h=!1;#Mh=!1;#kh=null;#Dh=null;#Ph=null;#Ih=null;#Rh=null;#Bh=-1;#k;static _initialized=!1;static#ot=new Map([Ns,Qs,sr,Ws,nr].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:n,accessibilityManager:s,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const c=[...rr.#ot.values()];if(!rr._initialized){rr._initialized=!0;for(const e of c)e.initialize(h,t)}t.registerEditorTypes(c),this.#k=t,this.pageIndex=e,this.div=i,this.#$a=s,this.#xh=r,this.viewport=l,this.#Ph=o,this.drawLayer=a,this._structTree=n,this.#k.addLayer(this)}updatePageIndex(t){for(const e of this.#Fh)e.updatePageIndex(t);this.pageIndex=t,this.#k.addLayer(this)}async setClonedFrom(t){if(!t)return;const e=[];for(const i of t.#Fh){const t=i.serialize(!0);t&&(t.isCopy=!1,e.push(this.deserialize(t).then((t=>{t&&this.addOrRebuild(t)}))))}await Promise.all(e)}get isEmpty(){return 0===this.#Eh.size}get isInvisible(){return this.isEmpty&&this.#k.getMode()===f.NONE}updateToolbar(t){this.#k.updateToolbar(t)}updateMode(t=this.#k.getMode()){switch(this.#Lh(),t){case f.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case f.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case f.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===f.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const i of rr.#ot.values())e.toggle(`${i._type}Editing`,t===i._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#Ph?.div}setEditingState(t){this.#k.setEditingState(t)}addCommands(t){this.#k.addCommands(t)}cleanUndoStack(t){this.#k.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#xh?.togglePointerEvents(t)}get#Fh(){return 0!==this.#Eh.size?this.#Eh.values():this.#k.getEditors(this.pageIndex)}async enable(){this.#Mh=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#Rh?.abort(),this.#Rh=null;const t=new Set;for(const e of this.#Fh)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#k.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));const e=this.#xh;if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),this.#k.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#Mh=!1,this.#k._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#_h=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#Ph&&!this.#Rh){this.#Rh=new AbortController;const t=this.#k.combinedSignal(this.#Rh);this.#Ph.div.addEventListener("pointerdown",(t=>{const{clientX:e,clientY:i,timeStamp:n}=t;if(n-this.#Bh>500)return void(this.#Bh=n);this.#Bh=-1;const{classList:s}=this.div;s.toggle("getElements",!0);const r=document.elementsFromPoint(e,i);if(s.toggle("getElements",!1),!this.div.contains(r[0]))return;let a;const o=new RegExp(`^${m}[0-9]+$`);for(const t of r)if(o.test(t.id)){a=t.id;break}if(!a)return;const l=this.#Eh.get(a);null===l?.annotationElementId&&(t.stopPropagation(),t.preventDefault(),l.dblclick(t))}),{signal:t,capture:!0})}const t=this.#xh,e=[];if(t){const i=new Map,n=new Map;for(const t of this.#Fh)t.disableEditing(),t.annotationElementId?null===t.serialize()?(n.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):i.set(t.annotationElementId,t):e.push(t);const s=t.getEditableAnnotations();for(const t of s){const{id:e}=t.data;if(this.#k.isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let s=n.get(e);s?(s.resetAnnotationElement(t),s.show(!1),t.show()):(s=i.get(e),s&&(this.#k.addChangedExistingAnnotation(s),s.renderAnnotationElement(t)&&s.show(!1)),t.show())}}this.#Lh(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of rr.#ot.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#_h=!1}getEditableAnnotation(t){return this.#xh?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#k.getActive()!==t&&this.#k.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#Ph?.div&&!this.#Ih){this.#Ih=new AbortController;const t=this.#k.combinedSignal(this.#Ih);this.#Ph.div.addEventListener("pointerdown",this.#Oh.bind(this),{signal:t}),this.#Ph.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#Ph?.div&&this.#Ih&&(this.#Ih.abort(),this.#Ih=null,this.#Ph.div.classList.remove("highlighting"))}#Oh(t){this.#k.unselectAll();const{target:e}=t;if(e===this.#Ph.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#Ph.div.contains(e)){const{isMac:e}=ot.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#k.showAllEditors("highlight",!0,!0),this.#Ph.div.classList.add("free"),this.toggleDrawing(),Ws.startHighlighting(this,"ltr"===this.#k.direction,{target:this.#Ph.div,x:t.x,y:t.y}),this.#Ph.div.addEventListener("pointerup",(()=>{this.#Ph.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#k._signal}),t.preventDefault()}}enableClick(){if(this.#Sh)return;this.#Sh=new AbortController;const t=this.#k.combinedSignal(this.#Sh);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#Sh?.abort(),this.#Sh=null}attach(t){this.#Eh.set(t.id,t);const{annotationElementId:e}=t;e&&this.#k.isDeletedAnnotationElement(e)&&this.#k.removeDeletedAnnotationElement(t)}detach(t){this.#Eh.delete(t.id),this.#$a?.removePointerInTextLayer(t.contentDiv),!this.#_h&&t.annotationElementId&&this.#k.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#k.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#k.addDeletedAnnotationElement(t),ge.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.#k.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#Mh),this.#k.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Ch&&(t._focusEventsAllowed=!1,this.#Ch=setTimeout((()=>{this.#Ch=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#k._signal}),e.focus())}),0)),t._structTreeParentId=this.#$a?.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})}getEditorByUID(t){for(const e of this.#Eh.values())if(e.uid===t)return e;return null}getNextId(){return this.#k.getId()}get#Nh(){return rr.#ot.get(this.#k.getMode())}combinedSignal(t){return this.#k.combinedSignal(t)}#Uh(t){const e=this.#Nh;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Nh?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#k.updateMode(t.mode);const{offsetX:i,offsetY:n}=this.#zh(),s=this.getNextId(),r=this.#Uh({parent:this,id:s,x:i,y:n,uiManager:this.#k,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await(rr.#ot.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#k))||null}createAndAddNewEditor(t,e,i={}){const n=this.getNextId(),s=this.#Uh({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:this.#k,isCentered:e,...i});return s&&this.add(s),s}get boundingClientRect(){return this.div.getBoundingClientRect()}#zh(){const{x:t,y:e,width:i,height:n}=this.boundingClientRect,s=Math.max(0,t),r=Math.max(0,e),a=(s+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+n))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(t={}){this.createAndAddNewEditor(this.#zh(),!0,t)}setSelected(t){this.#k.setSelected(t)}toggleSelected(t){this.#k.toggleSelected(t)}unselect(t){this.#k.unselect(t)}pointerup(t){const{isMac:e}=ot.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#Th)return;if(this.#Th=!1,this.#Nh?.isDrawer&&this.#Nh.supportMultipleDrawings)return;if(!this.#Ah)return void(this.#Ah=!0);const i=this.#k.getMode();i!==f.STAMP&&i!==f.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#k.unselectAll()}pointerdown(t){if(this.#k.getMode()===f.HIGHLIGHT&&this.enableTextSelection(),this.#Th)return void(this.#Th=!1);const{isMac:e}=ot.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#Th=!0,this.#Nh?.isDrawer)return void this.startDrawingSession(t);const i=this.#k.getActive();this.#Ah=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#kh)return void this.#Nh.startDrawing(this,this.#k,!1,t);this.#k.setCurrentDrawingSession(this),this.#kh=new AbortController;const e=this.#k.combinedSignal(this.#kh);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#Dh=null,this.commitOrRemove())}),{signal:e}),this.#Nh.startDrawing(this,this.#k,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#Dh=t)}else this.#Dh&&setTimeout((()=>{this.#Dh?.focus(),this.#Dh=null}),0)}endDrawingSession(t=!1){return this.#kh?(this.#k.setCurrentDrawingSession(null),this.#kh.abort(),this.#kh=null,this.#Dh=null,this.#Nh.endDrawing(t)):null}findNewParent(t,e,i){const n=this.#k.findParent(e,i);return null!==n&&n!==this&&(n.changeParent(t),!0)}commitOrRemove(){return!!this.#kh&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#kh&&this.#Nh.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#k.getActive()?.parent===this&&(this.#k.commitOrRemove(),this.#k.setActiveEditor(null)),this.#Ch&&(clearTimeout(this.#Ch),this.#Ch=null);for(const t of this.#Eh.values())this.#$a?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Eh.clear(),this.#k.removeLayer(this)}#Lh(){for(const t of this.#Eh.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,zt(this.div,t);for(const t of this.#k.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#k.commitOrRemove(),this.#Lh();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,zt(this.div,{rotation:i}),e!==i)for(const t of this.#Eh.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#k.viewParameters.realScale}}class ar{#ga=null;#Hh=new Map;#jh=new Map;static#O=0;setParent(t){if(this.#ga){if(this.#ga!==t){if(this.#Hh.size>0)for(const e of this.#Hh.values())e.remove(),t.append(e);this.#ga=t}}else this.#ga=t}static get _svgFactory(){return Q(this,"_svgFactory",new rs)}static#Gh(t,[e,i,n,s]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*n+"%",r.height=100*s+"%"}#$h(){const t=ar._svgFactory.create(1,1,!0);return this.#ga.append(t),t.setAttribute("aria-hidden",!0),t}#Vh(t,e){const i=ar._svgFactory.createElement("clipPath");t.append(i);const n=`clip_${e}`;i.setAttribute("id",n),i.setAttribute("clipPathUnits","objectBoundingBox");const s=ar._svgFactory.createElement("use");return i.append(s),s.setAttribute("href",`#${e}`),s.classList.add("clip"),n}#Wh(t,e){for(const[i,n]of Object.entries(e))null===n?t.removeAttribute(i):t.setAttribute(i,n)}draw(t,e=!1,i=!1){const n=ar.#O++,s=this.#$h(),r=ar._svgFactory.createElement("defs");s.append(r);const a=ar._svgFactory.createElement("path");r.append(a);const o=`path_${n}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#jh.set(n,a);const l=i?this.#Vh(r,o):null,h=ar._svgFactory.createElement("use");return s.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(s,t),this.#Hh.set(n,s),{id:n,clipPathId:`url(#${l})`}}drawOutline(t,e){const i=ar.#O++,n=this.#$h(),s=ar._svgFactory.createElement("defs");n.append(s);const r=ar._svgFactory.createElement("path");s.append(r);const a=`path_${i}`;let o;if(r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke"),e){const t=ar._svgFactory.createElement("mask");s.append(t),o=`mask_${i}`,t.setAttribute("id",o),t.setAttribute("maskUnits","objectBoundingBox");const e=ar._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const n=ar._svgFactory.createElement("use");t.append(n),n.setAttribute("href",`#${a}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const l=ar._svgFactory.createElement("use");n.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return n.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(n,t),this.#Hh.set(i,n),i}finalizeDraw(t,e){this.#jh.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:n,rootClass:s,path:r}=e,a="number"==typeof t?this.#Hh.get(t):t;if(a){if(i&&this.#Wh(a,i),n&&ar.#Gh(a,n),s){const{classList:t}=a;for(const[e,i]of Object.entries(s))t.toggle(e,i)}if(r){const t=a.firstElementChild.firstElementChild;this.#Wh(t,r)}}}updateParent(t,e){if(e===this)return;const i=this.#Hh.get(t);i&&(e.#ga.append(i),this.#Hh.delete(t),e.#Hh.set(t,i))}remove(t){this.#jh.delete(t),null!==this.#ga&&(this.#Hh.get(t).remove(),this.#Hh.delete(t))}destroy(){this.#ga=null;for(const t of this.#Hh.values())t.remove();this.#Hh.clear(),this.#jh.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:js},globalThis.pdfjsLib={AbortException:rt,AnnotationEditorLayer:rr,AnnotationEditorParamsType:b,AnnotationEditorType:f,AnnotationEditorUIManager:ce,AnnotationLayer:Ls,AnnotationMode:g,AnnotationType:M,applyOpacity:Vt,build:Qn,ColorPicker:Zn,createValidAbsoluteUrl:K,CSSConstants:$t,DOMSVGFactory:rs,DrawLayer:ar,FeatureTest:ot,fetchData:St,findContrastColor:Jt,getDocument:jn,getFilenameFromUrl:Mt,getPdfFilenameFromUrl:kt,getRGB:Ot,getUuid:pt,getXfaPageViewport:Lt,GlobalWorkerOptions:an,ImageKind:_,InvalidPDFException:it,isDataScheme:Tt,isPdfFile:_t,isValidExplicitDest:Ie,makeArr:mt,makeMap:ft,makeObj:bt,MathClamp:vt,noContextMenu:It,normalizeUnicode:ut,OPS:F,OutputScale:Ht,PasswordResponses:H,PDFDataRangeTransport:$n,PDFDateString:Ft,PDFWorker:Xn,PermissionFlag:v,PixelsPerInch:xt,RenderingCancelledException:Et,renderRichText:Qt,ResponseException:nt,setLayerDimensions:zt,shadow:Q,SignatureExtractor:tr,stopEvent:Rt,SupportedImageMimeTypes:jt,TextLayer:Hn,TouchManager:pe,updateUrlHash:Y,Util:ht,VerbosityLevel:B,version:Jn,XfaLayer:wt};export{rt as AbortException,rr as AnnotationEditorLayer,b as AnnotationEditorParamsType,f as AnnotationEditorType,ce as AnnotationEditorUIManager,Ls as AnnotationLayer,g as AnnotationMode,M as AnnotationType,$t as CSSConstants,Zn as ColorPicker,rs as DOMSVGFactory,ar as DrawLayer,ot as FeatureTest,an as GlobalWorkerOptions,_ as ImageKind,it as InvalidPDFException,vt as MathClamp,F as OPS,Ht as OutputScale,$n as PDFDataRangeTransport,Ft as PDFDateString,Xn as PDFWorker,H as PasswordResponses,v as PermissionFlag,xt as PixelsPerInch,Et as RenderingCancelledException,nt as ResponseException,tr as SignatureExtractor,jt as SupportedImageMimeTypes,Hn as TextLayer,pe as TouchManager,ht as Util,B as VerbosityLevel,wt as XfaLayer,Vt as applyOpacity,Qn as build,K as createValidAbsoluteUrl,St as fetchData,Jt as findContrastColor,jn as getDocument,Mt as getFilenameFromUrl,kt as getPdfFilenameFromUrl,Ot as getRGB,pt as getUuid,Lt as getXfaPageViewport,Tt as isDataScheme,_t as isPdfFile,Ie as isValidExplicitDest,mt as makeArr,ft as makeMap,bt as makeObj,It as noContextMenu,ut as normalizeUnicode,Qt as renderRichText,zt as setLayerDimensions,Q as shadow,Rt as stopEvent,Y as updateUrlHash,Jn as version};