PageSourceSearch

https://msastroacademy.com/assets/lesson-KQG0z5ji.js

js msastroacademy.com collected 2026-10-02 01:36:36 UTC 544,515 bytes, 57 lines download raw bytes

1var rr=h=>{throw TypeError(h)};var Zn=(h,t,e)=>t.has(h)||rr("Cannot "+e);var Tt=(h,t,e)=>(Zn(h,t,"read from private field"),e?e.call(h):t.get(h)),xe=(h,t,e)=>t.has(h)?rr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(h):t.set(h,e),Kt=(h,t,e,s)=>(Zn(h,t,"write to private field"),s?s.call(h,e):t.set(h,e),e),Ae=(h,t,e)=>(Zn(h,t,"access private method"),e);var ar=(h,t,e,s)=>({set _(n){Kt(h,t,n,e)},get _(){return Tt(h,t,s)}});import{r as U,j as A}from"./react-vendor-DDlTsOEd.js";import{g as Xs,A as sa,u as Xa,a as Ya,c as Ka,d as zt,b as Qa,h as or,S as lr,i as Ls,L as gs,j as cr,F as Ja,k as hr,f as dr,l as ur,m as Za,R as fr,n as qn,M as pr,o as qa}from"./index-BBAL-XO_.js";import{P as gr}from"./progress-acDYhtmc.js";import{B as ti}from"./badge-D-Efy8A-.js";import{u as to,c as eo,L as so,C as no,v as io,b as ro,i as ao}from"./LanguageToggle-DCR6PW1A.js";import{s as oo,b as lo,g as co}from"./learningExperience-CNPlsFZW.js";import{C as mr}from"./chevron-left-CSEuMicl.js";import{C as ho}from"./circle-play-DzrBCoVL.js";import{P as uo}from"./play-BkAhfr1u.js";import{S as fo}from"./send-C3YTITJa.js";import{C as vr}from"./chevron-right-BXLWPEsY.js";import"./contentLanguage-DI07xmLb.js";const po=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],cn=Xs("brain",po);const go=[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]],yr=Xs("fast-forward",go);const mo=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],vo=Xs("gauge",mo);const yo=[["path",{d:"M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z",key:"2a1g8i"}],["path",{d:"M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z",key:"rg3s36"}]],ei=Xs("rewind",yo);const bo=[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]],xo=Xs("sticky-note",bo);var Ao={9306(h,t,e){var s=e(4901),n=e(6823),i=TypeError;h.exports=function(r){if(s(r))return r;throw new i(n(r)+" is not a function")}},3506(h,t,e){var s=e(3925),n=String,i=TypeError;h.exports=function(r){if(s(r))return r;throw new i("Can't set "+n(r)+" as a prototype")}},7080(h,t,e){var s=e(4402).has;h.exports=function(n){return s(n),n}},3463(h){var t=TypeError;h.exports=function(e){if(typeof e=="string")return e;throw new t("Argument is not a string")}},4328(h,t,e){var s=e(4995),n=new s.WeakMap,i=s.set,r=s.remove;h.exports=function(a){return i(n,a,1),r(n,a),a}},6557(h,t,e){var s=e(4995).has;h.exports=function(n){return s(n),n}},6469(h,t,e){var s=e(8227),n=e(2360),i=e(4913).f,r=s("unscopables"),a=Array.prototype;a[r]===void 0&&i(a,r,{configurable:!0,value:n(null)}),h.exports=function(o){a[r][o]=!0}},679(h,t,e){var s=e(1625),n=TypeError;h.exports=function(i,r){if(s(r,i))return i;throw new n("Incorrect invocation")}},3972(h,t,e){var s=e(34),n=String,i=TypeError;h.exports=function(r){if(r===void 0||s(r))return r;throw new i(n(r)+" is not an object or undefined")}},8551(h,t,e){var s=e(34),n=String,i=TypeError;h.exports=function(r){if(s(r))return r;throw new i(n(r)+" is not an object")}},4154(h,t,e){var s=e(6955),n=TypeError;h.exports=function(i){if(s(i)==="Uint8Array")return i;throw new n("Argument is not an Uint8Array")}},7811(h){h.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"},7394(h,t,e){var s=e(4576),n=e(6706),i=e(2195),r=s.ArrayBuffer,a=s.TypeError;h.exports=r&&n(r.prototype,"byteLength","get")||function(o){if(i(o)!=="ArrayBuffer")throw new a("ArrayBuffer expected");return o.byteLength}},3238(h,t,e){var s=e(4576),n=e(7811),i=e(7394),r=s.DataView;
1h.exports=function(a){if(!n||i(a)!==0)return!1;try{return new r(a),!1}catch{return!0}}},5169(h,t,e){var s=e(3238),n=TypeError;h.exports=function(i){if(s(i))throw new n("ArrayBuffer is detached");return i}},4644(h,t,e){var s=e(7811),n=e(3724),i=e(4576),r=e(4901),a=e(34),o=e(9297),l=e(6955),c=e(6823),d=e(6699),u=e(6840),f=e(2106),p=e(1625),g=e(2787),m=e(2967),v=e(8227),y=e(3392),b=e(1181),S=b.enforce,x=b.get,w=i.Int8Array,E=w&&w.prototype,C=i.Uint8ClampedArray,T=C&&C.prototype,O=w&&g(w),I=E&&g(E),M=Object.prototype,N=i.TypeError,D=v("toStringTag"),$=y("TYPED_ARRAY_TAG"),k="TypedArrayConstructor",F=s&&!!m&&l(i.opera)!=="Opera",W=!1,G,at,bt,J={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},tt={BigInt64Array:8,BigUint64Array:8},dt=function(nt){if(!a(nt))return!1;var ut=l(nt);return ut==="DataView"||o(J,ut)||o(tt,ut)},_t=function(X){var nt=g(X);if(a(nt)){var ut=x(nt);return ut&&o(ut,k)?ut[k]:_t(nt)}},B=function(X){if(!a(X))return!1;var nt=l(X);return o(J,nt)||o(tt,nt)},R=function(X){if(B(X))return X;throw new N("Target is not a typed array")},j=function(X){if(r(X)&&(!m||p(O,X)))return X;throw new N(c(X)+" is not a typed array constructor")},K=function(X,nt,ut,kt){if(n){if(ut)for(var ft in J){var At=i[ft];if(At&&o(At.prototype,X))try{delete At.prototype[X]}catch{try{At.prototype[X]=nt}catch{}}}(!I[X]||ut)&&u(I,X,ut?nt:F&&E[X]||nt,kt)}},ct=function(X,nt,ut){var kt,ft;if(n){if(m){if(ut){for(kt in J)if(ft=i[kt],ft&&o(ft,X))try{delete ft[X]}catch{}}if(!O[X]||ut)try{return u(O,X,ut?nt:F&&O[X]||nt)}catch{}else return}for(kt in J)ft=i[kt],ft&&(!ft[X]||ut)&&u(ft,X,nt)}};for(G in J)at=i[G],bt=at&&at.prototype,bt?S(bt)[k]=at:F=!1;for(G in tt)at=i[G],bt=at&&at.prototype,bt&&(S(bt)[k]=at);if((!F||!r(O)||O===Function.prototype)&&(O=function(){throw new N("Incorrect invocation")},F))for(G in J)i[G]&&m(i[G],O);if((!F||!I||I===M)&&(I=O.prototype,F))for(G in J)i[G]&&m(i[G].prototype,I);if(F&&g(T)!==I&&m(T,I),n&&!o(I,D)){W=!0,f(I,D,{configurable:!0,get:function(){return a(this)?this[$]:void 0}});for(G in J)i[G]&&d(i[G].prototype,$,G)}h.exports={NATIVE_ARRAY_BUFFER_VIEWS:F,TYPED_ARRAY_TAG:W&&$,aTypedArray:R,aTypedArrayConstructor:j,exportTypedArrayMethod:K,exportTypedArrayStaticMethod:ct,getTypedArrayConstructor:_t,isView:dt,isTypedArray:B,TypedArray:O,TypedArrayPrototype:I}},5370(h,t,e){var s=e(6198);h.exports=function(n,i,r){for(var a=0,o=arguments.length>2?r:s(i),l=new n(o);o>a;)l[a]=i[a++];return l}},9617(h,t,e){var s=e(5397),n=e(5610),i=e(6198),r=function(a){return function(o,l,c){var d=s(o),u=i(d);if(u===0)return!a&&-1;var f=n(c,u),p;if(a&&l!==l){for(;u>f;)if(p=d[f++],p!==p)return!0}else for(;u>f;f++)if((a||f in d)&&d[f]===l)return a||f||0;return!a&&-1}};h.exports={includes:r(!0),indexOf:r(!1)}},4527(h,t,e){var s=e(3724),n=e(4376),i=TypeError,r=Object.getOwnPropertyDescriptor,a=s&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(o){return o instanceof TypeError}})();h.exports=a?function(o,l){if(n(o)&&!r(o,"length").writable)throw new i("Cannot set read only .length");return o.length=l}:function(o,l){return o.length=l}},7680(h,t,e){var s=e(9504);h.exports=s([].slice)},2804(h){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=t+"+/",s=t+"-_",n=function(i){for(var r={},a=0;a<64;a++)r[i.charAt(a)]=a;return r};h.exports={i2c:e,c2i:n(e),i2cUrl:s,c2iUrl:n(s)}},6319(h,t,e){var s=e(8551),n=e(9539);h.exports=function(i,r,a,o){try{return o?r(s(a)[0],a[1]):r(a)}catch(l){n(i,"throw",l)}}},2195(h,t,e){var s=e(9504),n=s({}.toString),i=s("".slice);h.exports=function(r){return i(n(r),8,-1)}},6955(h,t,e){var s=e(2140),n=e(4901),i=e(2195),r=e(8227),a=r("toStringTag"),o=Object,l=i((function(){return arguments})())==="Arguments",c=function(d,u){try{return d[u]}catch{}};h.exports=s?i:function(d){var u,f,p;return d===void 0?"Undefined":d===null?"Null":typeof(f=c(u=o(d),a))=="string"?f:l?i(u):(p=i(u))==="Object"&&n(u.callee)?"Arguments":p}},7740(h,t,e){var s=e(9297),n=e(5031),i=e(7347),r=e(4913);h.exports=function(a,o,l){for(var c=n(o),d=r.f,u=i.f,f=0;f<c.length;f++){var p=c[f];!s(a,p)&&!(l&&s(l,p))&&d(a,p,u(o,p))}}},2211(h,t,e){var s=e(9039);h.exports=!s(function(){function n(){}return n.prototype.constructor=null,Object.getPrototypeOf(new n)!==n.prototype})},2529(h){h.exports=function(t,e){return{value:t,done:e}}},6699(h,t,e){var s=e(3724),n=e(4913),i=e(6980);h.exports=s?function(r,a,o){return n.f(r,a,i(1,o))}:function(r,a,o){return r[a]=o,r}},6980(h){h.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}},4659(h,t,e){var s=e(3724),n=e(4913),i=e(6980);h.exports=function(r,a,o){s?n.f(r,a,i(0,o)):r[a]=o}},2106(h,t,e){var s=e(283),n=e(4913);h.exports=function(i,r,a){return a.get&&s(a.get,r,{getter:!0}),a.set&&s(a.set,r,{setter:!0}),n.f(i,r,a)}},6840(h,t,e){var s=e(4901),n=e(4913),i=e(283),r=e(9433);h.exports=function(a,o,l,c){c||(c={});var d=c.enumerable,u=c.name!==void 0?c.name:o;if(s(l)&&i(l,u,c),c.global)d?a[o]=l:r(o,l);else{try{c.unsafe?a[o]&&(d=!0):delete a[o]}catch{}
1d?a[o]=l:n.f(a,o,{value:l,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return a}},6279(h,t,e){var s=e(6840);h.exports=function(n,i,r){for(var a in i)s(n,a,i[a],r);return n}},9433(h,t,e){var s=e(4576),n=Object.defineProperty;h.exports=function(i,r){try{n(s,i,{value:r,configurable:!0,writable:!0})}catch{s[i]=r}return r}},3724(h,t,e){var s=e(9039);h.exports=!s(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})},4055(h,t,e){var s=e(4576),n=e(34),i=s.document,r=n(i)&&n(i.createElement);h.exports=function(a){return r?i.createElement(a):{}}},6837(h){var t=TypeError,e=9007199254740991;h.exports=function(s){if(s>e)throw new t("Maximum allowed index exceeded");return s}},5002(h){h.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}
1,InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8727(h){h.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2839(h,t,e){var s=e(4576),n=s.navigator,i=n&&n.userAgent;h.exports=i?String(i):""},9519(h,t,e){var s=e(4576),n=e(2839),i=s.process,r=s.Deno,a=i&&i.versions||r&&r.version,o=a&&a.v8,l,c;o&&(l=o.split("."),c=l[0]>0&&l[0]<4?1:+(l[0]+l[1])),!c&&n&&(l=n.match(/Edge\/(\d+)/),(!l||l[1]>=74)&&(l=n.match(/Chrome\/(\d+)/),l&&(c=+l[1]))),h.exports=c},6193(h,t,e){var s=e(9504),n=Error,i=s("".replace),r=(function(l){return String(new n(l).stack)})("zxcasd"),a=/\n\s*at [^:]*:[^\n]*/,o=a.test(r);h.exports=function(l,c){if(o&&typeof l=="string"&&!n.prepareStackTrace)for(;c--;)l=i(l,a,"");return l}},6518(h,t,e){var s=e(4576),n=e(7347).f,i=e(6699),r=e(6840),a=e(9433),o=e(7740),l=e(2796);h.exports=function(c,d){var u=c.target,f=c.global,p=c.stat,g,m,v,y,b,S;if(f?m=s:p?m=s[u]||a(u,{}):m=s[u]&&s[u].prototype,m)for(v in d){if(b=d[v],c.dontCallGetSet?(S=n(m,v),y=S&&S.value):y=m[v],g=l(f?v:u+(p?".":"#")+v,c.forced),!g&&y!==void 0){if(typeof b==typeof y)continue;o(b,y)}(c.sham||y&&y.sham)&&i(b,"sham",!0),r(m,v,b,c)}}},9039(h){h.exports=function(t){try{return!!t()}catch{return!0}}},8745(h,t,e){var s=e(616),n=Function.prototype,i=n.apply,r=n.call;h.exports=typeof Reflect=="object"&&Reflect.apply||(s?r.bind(i):function(){return r.apply(i,arguments)})},6080(h,t,e){var s=e(7476),n=e(9306),i=e(616),r=s(s.bind);h.exports=function(a,o){return n(a),o===void 0?a:i?r(a,o):function(){return a.apply(o,arguments)}}},616(h,t,e){var s=e(9039);h.exports=!s(function(){var n=(function(){}).bind();return typeof n!="function"||n.hasOwnProperty("prototype")})},9565(h,t,e){var s=e(616),n=Function.prototype.call;h.exports=s?n.bind(n):function(){return n.apply(n,arguments)}},350(h,t,e){var s=e(3724),n=e(9297),i=Function.prototype,r=s&&Object.getOwnPropertyDescriptor,a=n(i,"name"),o=a&&(function(){}).name==="something",l=a&&(!s||s&&r(i,"name").configurable);h.exports={EXISTS:a,PROPER:o,CONFIGURABLE:l}},6706(h,t,e){var s=e(9504),n=e(9306);h.exports=function(i,r,a){try{return s(n(Object.getOwnPropertyDescriptor(i,r)[a]))}catch{}}},7476(h,t,e){var s=e(2195),n=e(9504);h.exports=function(i){if(s(i)==="Function")return n(i)}},9504(h,t,e){var s=e(616),n=Function.prototype,i=n.call,r=s&&n.bind.bind(i,i);h.exports=s?r:function(a){return function(){return i.apply(a,arguments)}}},944(h){var t=TypeError;h.exports=function(e){var s=e&&e.alphabet;if(s===void 0||s==="base64"||s==="base64url")return s||"base64";throw new t("Incorrect `alphabet` option")}},7751(h,t,e){var s=e(4576),n=e(4901),i=function(r){return n(r)?r:void 0};h.exports=function(r,a){return arguments.length<2?i(s[r]):s[r]&&s[r][a]}},1767(h){h.exports=function(t){return{iterator:t,next:t.next,done:!1}}},8646(h,t,e){var s=e(9565),n=e(8551),i=e(1767),r=e(3085);h.exports=function(a,o){(!o||typeof a!="string")&&n(a);var l=r(a);return i(n(l!==void 0?s(l,a):a))}},8563(h,t,e){var s=e(9565),n=e(4901),i=e(8551),r=e(6823),a=e(3085),o=TypeError;h.exports=function(l,c){var d=arguments.length<2?a(l):c;if(n(d))return i(s(d,l));throw new o(r(l)+" is not iterable")}},3085(h,t,e){var s=e(2195),n=e(4117),i=e(5966),r=e(8227),a=r("iterator"),o=Array.prototype;h.exports=function(l){if(!n(l))return i(l,a)||i(l,"@@iterator")||(s(l)==="Arguments"?o[a]:void 0)}},5966(h,t,e){var s=e(9306),n=e(4117);h.exports=function(i,r){var a=i[r];return n(a)?void 0:s(a)}},3789(h,t,e){var s=e(9306),n=e(8551),i=e(9565),r=e(1291),a=e(1767),o="Invalid size",l=RangeError,c=TypeError,d=Math.max,u=function(f,p){this.set=f,this.size=d(p,0),this.has=s(f.has),this.keys=s(f.keys)};u.prototype={getIterator:function(){return a(n(i(this.keys,this.set)))},includes:function(f){return i(this.has,this.set,f)}},h.exports=function(f){n(f);var p=+f.size;if(p!==p)throw new c(o);var g=r(p);if(g<0)throw new l(o);return new u(f,g)}},4576(h){var t=function(e){return e&&e.Math===Math&&e};h.exports=t(typeof globalThis=="object"&&globalThis)||t(typeof window=="object"&&window)||t(typeof self=="object"&&self)||t(typeof global=="object"&&global)||t(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()},9297(h,t,e){var s=e(9504),n=e(8981),i=s({}.hasOwnProperty);h.exports=Object.hasOwn||function(a,o){return i(n(a),o)}},421(h){h.exports={}},397(h,t,e){var s=e(7751);h.exports=s("document","documentElement")},5917(h,t,e){var s=e(3724),n=e(9039),i=e(4055);h.exports=!s&&!n(function(){return Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a!==7})},7055(h,t,e){var s=e(9504),n=e(9039),i=e(2195),r=Object,a=s("".split);h.exports=n(function(){return!r("z").propertyIsEnumerable(0)})?function(o){return i(o)==="String"?a(o,""):r(o)}:r},3167(h,t,e){var s=e(4901),n=e(34),i=e(2967);h.exports=function(r,a,o){var l,c;return i&&s(l=a.constructor)&&l!==o&&n(c=l.prototype)&&c!==o.prototype&&i(r,c),r}},3706(h,t,e){var s=e(9504),n=e(4901),i=e(7629),r=s(Function.toString);n(i.inspectSource)||(i.inspectSource=function(a){return r(a)}),h.exports=i.inspectSource},1181(h,t,e){var s=e(8622),n=e(4576),i=e(34),r=e(6699),a=e(9297),o=e(7629),l=e(6119),c=e(421),d="Object already initialized",u=n.TypeError,f=n.WeakMap,p,g,m,v=function(x){return m(x)?g(x):p(x,{})},y=function(x){return function(w){var E;if(!i(w)||(E=g(w)).type!==x)throw new u("Incompatible receiver, "+x+" required");return E}};if(s||o.state){var b=o.state||(o.state=new f);b.get=b.get,b.has=b.has,b.set=b.set,p=function(x,w){if(b.has(x))throw new u(d);return w.facade=x,b.set(x,w),w},g=function(x){return b.get(x)||{}},m=function(x){return b.has(x)}}else{var S=l("state");c[S]=!0,p=function(x,w){if(a(x,S))throw new u(d);return w.facade=x,r(x,S,w),w},g=function(x){return a(x,S)?x[S]:{}},m=function(x){return a(x,S)}}h.exports={set:p,get:g,has:m,enforce:v,getterFor:y}},4209(h,t,e){var s=e(8227),n=e(6269),i=s("iterator"),r=Array.prototype;h.exports=function(a){return a!==void 0&&(n.Array===a||r[i]===a)}},4376(h,t,e){var s=e(2195);h.exports=Array.isArray||function(i){return s(i)==="Array"}},1108(h,t,e){var s=e(6955);h.exports=function(n){var i=s(n);return i==="BigInt64Array"||i==="BigUint64Array"}},4901(h){var t=typeof document=="object"&&document.all;h.exports=typeof t>"u"&&t!==void 0?function(e){return typeof e=="function"||e===t}:function(e){return typeof e=="function"}},2796(h,t,e){var s=e(9039),n=e(4901),i=/#|\.prototype\./,r=function(d,u){var f=o[a(d)];return f===c?!0:f===l?!1:n(u)?s(u):!!u},a=r.normalize=function(d){return String(d).replace(i,".").toLowerCase()},o=r.data={},l=r.NATIVE="N",c=r.POLYFILL="P";h.exports=r},4117(h){h.exports=function(t){return t==null}},34(h,t,e){var s=e(4901);h.exports=function(n){return typeof n=="object"?n!==null:s(n)}},3925(h,t,e){var s=e(34);h.exports=function(n){return s(n)||n===null}},6395(h){h.exports=!1},5810(h,t,e){var s=e(34),n=e(1181).get;h.exports=function(r){if(!s(r))return!1;var a=n(r);return!!a&&a.type==="RawJSON"}},757(h,t,e){var s=e(7751),n=e(4901),i=e(1625),r=e(7040),a=Object;h.exports=r?function(o){return typeof o=="symbol"}:function(o){var l=s("Symbol");return n(l)&&i(l.prototype,a(o))}},507(h,t,e){var s=e(9565);h.exports=function(n,i,r){for(var a=r?n:n.iterator,o=n.next,l,c;!(l=s(o,a)).done;)if(c=i(l.value),c!==void 0)return c}},2652(h,t,e){var s=e(6080),n=e(9565),i=e(8551),r=e(6823),a=e(4209),o=e(6198),l=e(1625),c=e(8563),d=e(3085),u=e(9539),f=TypeError,p=function(m,v){this.stopped=m,this.result=v},g=p.prototype;h.exports=function(m,v,y){var b=y&&y.that,S=!!(y&&y.AS_ENTRIES),x=!!(y&&y.IS_RECORD),w=!!(y&&y.IS_ITERATOR),E=!!(y&&y.INTERRUPTED),C=s(v,b),T,O,I,M,N,D,$,k=function(G){var at=T;return T=void 0,at&&u(at,"normal"),new p(!0,G)},F=function(G){return S?(i(G),E?C(G[0],G[1],k):C(G[0],G[1])):E?C(G,k):C(G)};if(x)T=m.iterator;else if(w)T=m;else{if(O=d(m),!O)throw new f(r(m)+" is not iterable");if(a(O)){for(I=0,M=o(m);M>I;I++)if(N=F(m[I]),N&&l(g,N))return N;return new p(!1)}T=c(m,O)}for(D=x?m.next:T.next;!($=n(D,T)).done;){var W=$.value;try{N=F(W)}catch(G){if(T)u(T,"throw",G);else throw G}if(typeof N=="object"&&N&&l(g,N))return N}return new p(!1)}},6859(h){h.exports=function(t){t.iterator=t.next=t.nextHandler=t.mapper=t.predicate=t.inner=t.iterables=t.iters=t.openIters=t.padding=t.finishResults=t.buffer=null}},1385(h,t,e){var s=e(9539);h.exports=function(n,i,r){for(var a=n.length-1;a>=0;a--)if(n[a]!==void 0)try{r=s(n[a].iterator,i,r)}catch(o){i="throw",r=o}if(i==="throw")throw r;return r}},9539(h,t,e){var s=e(9565),n=e(8551),i=e(5966);h.exports=function(r,a,o){var l,c;n(r);try{if(l=i(r,"return"),!l){if(a==="throw")throw o;return o}l=s(l,r)}catch(d){c=!0,l=d}if(a==="throw")throw o;if(c)throw l;return n(l),o}},9462(h,t,e){var s=e(9565),n=e(2360),i=e(6699),r=e(6279),a=e(8227),o=e(1181),l=e(5966),c=e(7657).IteratorPrototype,d=e(2529),u=e(9539),f=e(1385),p=e(6859),g=a("toStringTag"),m="IteratorHelper",v="WrapForValidIterator",y="normal",b="throw",S=o.set,x=function(C){var T=o.getterFor(C?v:m);return r(n(c),{next:function(){var I=T(this);if(C)return I.nextHandler();if(I.done)return d(void 0,!0);try{var M=I.nextHandler();return I.done&&p(I),I.returnHandlerResult?M:d(M,I.done)}catch(N){throw I.done=!0,p(I),N}},return:function(){var O=T(this),I=O.iterator,M=O.inner,N=O.openIters,D=O.done;if(O.done=!0,C){var $=l(I,"return");return $?s($,I):d(void 0,!0)}if(p(O),D)return d(void 0,!0);if(M)try{u(M.iterator,y)}catch(k){return u(I,b,k)}if(N)try{f(N,y)}catch(k){if(I)return u(I,b,k);throw k}return I&&u(I,y),d(void 0,!0)}})},w=x(!0),E=x(!1);i(E,g,"Iterator Helper"),h.exports=function(C,T,O){var I=function(N,D){D?(D.iterator=N.iterator,D.next=N.next):D=N,D.type=T?v:m,D.returnHandlerResult=!!O,D.nextHandler=C,D.counter=0,D.done=!1,S(this,D)};return I.prototype=T?w:E,I}},684(h){h.exports=function(t,e){var s=typeof Iterator=="function"&&Iterator.prototype[t];if(s)try{s.call({next:null},e).next()}catch{return!0}}},4549(h,t,e){var s=e(4576);h.exports=function(n,i){var r=s.Iterator,a=r&&r.prototype,o=a&&a[n],l=!1;if(o)try{o.call({next:function(){return{done:!0}},return:function(){l=!0}},-1)}catch(c){c instanceof i||(l=!1)}if(!l)return o}},7657(h,t,e){var s=e(9039),n=e(4901),i=e(34),r=e(2360),a=e(2787),o=e(6840),l=e(8227),c=e(6395),d=l("iterator"),u=!1,f,p,g;[].keys&&(g=[].keys(),"next"in g?(p=a(a(g)),p!==Object.prototype&&(f=p)):u=!0);var m=!i(f)||s(function(){var v={};return f[d].call(v)!==v});m?f={}:c&&(f=r(f)),n(f[d])||o(f,d,function(){return this}),h.exports={IteratorPrototype:f,BUGGY_SAFARI_ITERATORS:u}},6269(h){h.exports=Object.create?Object.create(null):{}},6198(h,t,e){var s=e(8014);h.exports=function(n){return s(n.length)}},283(h,t,e){var s=e(9504),n=e(9039),i=e(4901),r=e(9297),a=e(3724),o=e(350).CONFIGURABLE,l=e(3706),c=e(1181),d=c.enforce,u=c.get,f=String,p=Object.defineProperty,g=s("".slice),m=s("".replace),v=s([].join),y=a&&!n(function(){return p(function(){},"length",{value:8}).length!==8}),b=String(String).split("String"),S=h.exports=function(x,w,E){g(f(w),0,7)==="Symbol("&&(w="["+m(f(w),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),E&&E.getter&&(w="get "+w),E&&E.setter&&(w="set "+w),(!r(x,"name")||o&&x.name!==w)&&(a?p(x,"name",{value:w,configurable:!0}):x.name=w),y&&E&&r(E,"arity")&&x.length!==E.arity&&p(x,"length",{value:E.arity});try{E&&r(E,"constructor")&&E.constructor?a&&p(x,"prototype",{writable:!1}):x.prototype&&(x.prototype=void 0)}catch{}var C=d(x);return r(C,"source")||(C.source=v(b,typeof w=="string"?w:"")),x};Function.prototype.toString=S(function(){return i(this)&&u(this).source||l(this)},"toString")},2248(h,t,e){var s=e(9504),n=Map.prototype;h.exports={Map,set:s(n.set),get:s(n.get),has:s(n.has),remove:s(n.delete),proto:n}},741(h){var t=Math.ceil,e=Math.floor;h.exports=Math.trunc||function(n){var i=+n;return(i>0?e:t)(i)}},7819(h,t,e){var s=e(9039);h.exports=!s(function(){var n="9007199254740993",i=JSON.rawJSON(n);return!JSON.isRawJSON(i)||JSON.stringify(i)!==n})},6043(h,t,e){var s=e(9306),n=TypeError,i=function(r){var a,o;
1this.promise=new r(function(l,c){if(a!==void 0||o!==void 0)throw new n("Bad Promise constructor");a=l,o=c}),this.resolve=s(a),this.reject=s(o)};h.exports.f=function(r){return new i(r)}},2603(h,t,e){var s=e(655);h.exports=function(n,i){return n===void 0?arguments.length<2?"":i:s(n)}},4149(h){var t=RangeError;h.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}},2360(h,t,e){var s=e(8551),n=e(6801),i=e(8727),r=e(421),a=e(397),o=e(4055),l=e(6119),c=">",d="<",u="prototype",f="script",p=l("IE_PROTO"),g=function(){},m=function(x){return d+f+c+x+d+"/"+f+c},v=function(x){x.write(m("")),x.close();var w=x.parentWindow.Object;return x=null,w},y=function(){var x=o("iframe"),w="java"+f+":",E;return x.style.display="none",a.appendChild(x),x.src=String(w),E=x.contentWindow.document,E.open(),E.write(m("document.F=Object")),E.close(),E.F},b,S=function(){try{b=new ActiveXObject("htmlfile")}catch{}S=typeof document<"u"?document.domain&&b?v(b):y():v(b);for(var x=i.length;x--;)delete S[u][i[x]];return S()};r[p]=!0,h.exports=Object.create||function(w,E){var C;return w!==null?(g[u]=s(w),C=new g,g[u]=null,C[p]=w):C=S(),E===void 0?C:n.f(C,E)}},6801(h,t,e){var s=e(3724),n=e(8686),i=e(4913),r=e(8551),a=e(5397),o=e(1072);t.f=s&&!n?Object.defineProperties:function(c,d){r(c);for(var u=a(d),f=o(d),p=f.length,g=0,m;p>g;)i.f(c,m=f[g++],u[m]);return c}},4913(h,t,e){var s=e(3724),n=e(5917),i=e(8686),r=e(8551),a=e(6969),o=TypeError,l=Object.defineProperty,c=Object.getOwnPropertyDescriptor,d="enumerable",u="configurable",f="writable";t.f=s?i?function(g,m,v){if(r(g),m=a(m),r(v),typeof g=="function"&&m==="prototype"&&"value"in v&&f in v&&!v[f]){var y=c(g,m);y&&y[f]&&(g[m]=v.value,v={configurable:u in v?v[u]:y[u],enumerable:d in v?v[d]:y[d],writable:!1})}return l(g,m,v)}:l:function(g,m,v){if(r(g),m=a(m),r(v),n)try{return l(g,m,v)}catch{}if("get"in v||"set"in v)throw new o("Accessors not supported");return"value"in v&&(g[m]=v.value),g}},7347(h,t,e){var s=e(3724),n=e(9565),i=e(8773),r=e(6980),a=e(5397),o=e(6969),l=e(9297),c=e(5917),d=Object.getOwnPropertyDescriptor;t.f=s?d:function(f,p){if(f=a(f),p=o(p),c)try{return d(f,p)}catch{}if(l(f,p))return r(!n(i.f,f,p),f[p])}},8480(h,t,e){var s=e(1828),n=e(8727),i=n.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(a){return s(a,i)}},3717(h,t){t.f=Object.getOwnPropertySymbols},2787(h,t,e){var s=e(9297),n=e(4901),i=e(8981),r=e(6119),a=e(2211),o=r("IE_PROTO"),l=Object,c=l.prototype;h.exports=a?l.getPrototypeOf:function(d){var u=i(d);if(s(u,o))return u[o];var f=u.constructor;return n(f)&&u instanceof f?f.prototype:u instanceof l?c:null}},1625(h,t,e){var s=e(9504);h.exports=s({}.isPrototypeOf)},1828(h,t,e){var s=e(9504),n=e(9297),i=e(5397),r=e(9617).indexOf,a=e(421),o=s([].push);h.exports=function(l,c){var d=i(l),u=0,f=[],p;for(p in d)!n(a,p)&&n(d,p)&&o(f,p);for(;c.length>u;)n(d,p=c[u++])&&(~r(f,p)||o(f,p));return f}},1072(h,t,e){var s=e(1828),n=e(8727);h.exports=Object.keys||function(r){return s(r,n)}},8773(h,t){var e={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,n=s&&!e.call({1:2},1);t.f=n?function(r){var a=s(this,r);return!!a&&a.enumerable}:e},2967(h,t,e){var s=e(6706),n=e(34),i=e(7750),r=e(3506);
1h.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var a=!1,o={},l;try{l=s(Object.prototype,"__proto__","set"),l(o,[]),a=o instanceof Array}catch{}return function(d,u){return i(d),r(u),n(d)&&(a?l(d,u):d.__proto__=u),d}})():void 0)},4270(h,t,e){var s=e(9565),n=e(4901),i=e(34),r=TypeError;h.exports=function(a,o){var l,c;if(o==="string"&&n(l=a.toString)&&!i(c=s(l,a))||n(l=a.valueOf)&&!i(c=s(l,a))||o!=="string"&&n(l=a.toString)&&!i(c=s(l,a)))return c;throw new r("Can't convert object to primitive value")}},5031(h,t,e){var s=e(7751),n=e(9504),i=e(8480),r=e(3717),a=e(8551),o=n([].concat);h.exports=s("Reflect","ownKeys")||function(c){var d=i.f(a(c)),u=r.f;return u?o(d,u(c)):d}},8235(h,t,e){var s=e(9504),n=e(9297),i=SyntaxError,r=parseInt,a=String.fromCharCode,o=s("".charAt),l=s("".slice),c=s(/./.exec),d={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2`,"\\r":"\r","\\t":"	"},u=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;h.exports=function(p,g){for(var m=!0,v="";g<p.length;){var y=o(p,g);if(y==="\\"){var b=l(p,g,g+2);if(n(d,b))v+=d[b],g+=2;else if(b==="\\u"){g+=2;var S=l(p,g,g+4);if(!c(u,S))throw new i("Bad Unicode escape at: "+g);v+=a(r(S,16)),g+=4}else throw new i('Unknown escape sequence: "'+b+'"')}else if(y==='"'){m=!1,g++;break}else{if(c(f,y))throw new i("Bad control character in string literal at: "+g);v+=y,g++}}if(m)throw new i("Unterminated string at: "+g);return{value:v,end:g}}},1103(h){h.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}},3438(h,t,e){var s=e(8551),n=e(34),i=e(6043);h.exports=function(r,a){if(s(r),n(a)&&a.constructor===r)return a;var o=i.f(r),l=o.resolve;return l(a),o.promise}},7750(h,t,e){var s=e(4117),n=TypeError;h.exports=function(i){if(s(i))throw new n("Can't call method on "+i);return i}},9286(h,t,e){var s=e(4402),n=e(8469),i=s.Set,r=s.add;h.exports=function(a){var o=new i;return n(a,function(l){r(o,l)}),o}},3440(h,t,e){var s=e(7080),n=e(4402),i=e(9286),r=e(5170),a=e(3789),o=e(8469),l=e(507),c=n.has,d=n.remove;h.exports=function(f){var p=s(this),g=a(f),m=i(p);return r(m)<=g.size?o(m,function(v){g.includes(v)&&d(m,v)}):l(g.getIterator(),function(v){c(m,v)&&d(m,v)}),m}},4402(h,t,e){var s=e(9504),n=Set.prototype;h.exports={Set,add:s(n.add),has:s(n.has),remove:s(n.delete),proto:n}},8750(h,t,e){var s=e(7080),n=e(4402),i=e(5170),r=e(3789),a=e(8469),o=e(507),l=n.Set,c=n.add,d=n.has;h.exports=function(f){var p=s(this),g=r(f),m=new l;return i(p)>g.size?o(g.getIterator(),function(v){d(p,v)&&c(m,v)}):a(p,function(v){g.includes(v)&&c(m,v)}),m}},4449(h,t,e){var s=e(7080),n=e(4402).has,i=e(5170),r=e(3789),a=e(8469),o=e(507),l=e(9539);h.exports=function(d){var u=s(this),f=r(d);if(i(u)<=f.size)return a(u,function(g){if(f.includes(g))return!1},!0)!==!1;var p=f.getIterator();return o(p,function(g){if(n(u,g))return l(p.iterator,"normal",!1)})!==!1}},3838(h,t,e){var s=e(7080),n=e(5170),i=e(8469),r=e(3789);h.exports=function(o){var l=s(this),c=r(o);return n(l)>c.size?!1:i(l,function(d){if(!c.includes(d))return!1},!0)!==!1}},8527(h,t,e){var s=e(7080),n=e(4402).has,i=e(5170),r=e(3789),a=e(507),o=e(9539);h.exports=function(c){var d=s(this),u=r(c);if(i(d)<u.size)return!1;var f=u.getIterator();return a(f,function(p){if(!n(d,p))return o(f.iterator,"normal",!1)})!==!1}},8469(h,t,e){var s=e(9504),n=e(507),i=e(4402),r=i.Set,a=i.proto,o=s(a.forEach),l=s(a.keys),c=l(new r).next;h.exports=function(d,u,f){return f?n({iterator:l(d),next:c},u):o(d,u)}},4916(h,t,e){var s=e(7751),n=function(r){return{size:r,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},i=function(r){return{size:r,has:function(){return!0},keys:function(){throw new Error("e")}}};h.exports=function(r,a){var o=s("Set");try{new o()[r](n(0));try{return new o()[r](n(-1)),!1}catch{if(!a)return!0;try{return new o()[r](i(-1/0)),!1}catch{var l=new o([1,2]);return a(l[r](i(1/0)))}}}catch{return!1}}},9835(h){h.exports=function(t){try{var e=new Set,s={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](s);return n.size===1&&n.values().next().value===4}catch{return!1}}},5170(h,t,e){var s=e(6706),n=e(4402);h.exports=s(n.proto,"size","get")||function(i){return i.size}},3650(h,t,e){var s=e(7080),n=e(4402),i=e(9286),r=e(3789),a=e(507),o=n.add,l=n.has,c=n.remove;h.exports=function(u){var f=s(this),p=r(u).getIterator(),g=i(f);return a(p,function(m){l(f,m)?c(g,m):o(g,m)}
2),g}},4204(h,t,e){var s=e(7080),n=e(4402).add,i=e(9286),r=e(3789),a=e(507);h.exports=function(l){var c=s(this),d=r(l).getIterator(),u=i(c);return a(d,function(f){n(u,f)}),u}},6119(h,t,e){var s=e(5745),n=e(3392),i=s("keys");h.exports=function(r){return i[r]||(i[r]=n(r))}},7629(h,t,e){var s=e(6395),n=e(4576),i=e(9433),r="__core-js_shared__",a=h.exports=n[r]||i(r,{});(a.versions||(a.versions=[])).push({version:"3.50.0",mode:s?"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.50.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(h,t,e){var s=e(7629),n=Object.create||Object;h.exports=function(i,r){return s[i]||(s[i]=r||n(null))}},4495(h,t,e){var s=e(9519),n=e(9039),i=e(4576),r=i.String;h.exports=!!Object.getOwnPropertySymbols&&!n(function(){var a=Symbol("symbol detection");return!r(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&s&&s<41})},1240(h,t,e){var s=e(9504);h.exports=s(1.1.valueOf)},5610(h,t,e){var s=e(1291),n=Math.max,i=Math.min;h.exports=function(r,a){var o=s(r);return o<0?n(o+a,0):i(o,a)}},5854(h,t,e){var s=e(2777),n=TypeError;h.exports=function(i){var r=s(i,"number");if(typeof r=="number")throw new n("Can't convert number to bigint");return BigInt(r)}},5397(h,t,e){var s=e(7055),n=e(7750);h.exports=function(i){return s(n(i))}},1291(h,t,e){var s=e(741);h.exports=function(n){var i=+n;return i!==i||i===0?0:s(i)}},8014(h,t,e){var s=e(1291),n=Math.min;h.exports=function(i){var r=s(i);return r>0?n(r,9007199254740991):0}},8981(h,t,e){var s=e(7750),n=Object;h.exports=function(i){return n(s(i))}},9590(h,t,e){var s=e(1291),n=RangeError;h.exports=function(i){var r=s(i);if(r<0)throw new n("The argument can't be less than 0");return r}},2777(h,t,e){var s=e(9565),n=e(34),i=e(757),r=e(5966),a=e(4270),o=e(8227),l=TypeError,c=o("toPrimitive");h.exports=function(d,u){if(!n(d)||i(d))return d;var f=r(d,c),p;if(f){if(u===void 0&&(u="default"),p=s(f,d,u),!n(p)||i(p))return p;throw new l("Can't convert object to primitive value")}return u===void 0&&(u="number"),a(d,u)}},6969(h,t,e){var s=e(2777),n=e(757);h.exports=function(i){var r=s(i,"string");return n(r)?r:r+""}},2140(h,t,e){var s=e(8227),n=s("toStringTag"),i={};i[n]="z",h.exports=String(i)==="[object z]"},655(h,t,e){var s=e(6955),n=String;h.exports=function(i){if(s(i)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return n(i)}},6823(h){var t=String;h.exports=function(e){try{return t(e)}catch{return"Object"}}},3392(h,t,e){var s=e(9504),n=0,i=Math.random(),r=s(1.1.toString);h.exports=function(a){return"Symbol("+(a===void 0?"":a)+")_"+r(++n+i,36)}},9143(h,t,e){var s=e(4576),n=e(9504),i=e(3972),r=e(3463),a=e(9297),o=e(2804),l=e(944),c=e(5169),d=o.c2i,u=o.c2iUrl,f=s.SyntaxError,p=s.TypeError,g=s.Array,m=n("".charAt),v=Math.floor,y=function(x,w){for(var E=x.length;w<E;w++){var C=m(x,w);if(C!==" "&&C!=="	"&&C!==`
3`&&C!=="\f"&&C!=="\r")break}return w},b=function(x,w,E){var C=x.length;C<4&&(x+=C===2?"AA":"A");var T=(w[m(x,0)]<<18)+(w[m(x,1)]<<12)+(w[m(x,2)]<<6)+w[m(x,3)],O=[T>>16&255,T>>8&255,T&255];if(C===2){if(E&&O[1]!==0)throw new f("Extra bits");return[O[0]]}if(C===3){if(E&&O[2]!==0)throw new f("Extra bits");return[O[0],O[1]]}return O},S=function(x,w,E){for(var C=w.length,T=0;T<C;T++)x[E+T]=w[T];return E+C};h.exports=function(x,w,E,C){r(x),i(w);var T=l(w)==="base64"?d:u,O=w?w.lastChunkHandling:void 0;if(O===void 0&&(O="loose"),O!=="loose"&&O!=="strict"&&O!=="stop-before-partial")throw new p("Incorrect `lastChunkHandling` option");E&&c(E.buffer);var I=x.length,M=E||g(v(I*3/4)),N=0,D=0,$="",k=0;if(C)for(;;){if(k=y(x,k),k===I){if($.length>0){if(O==="stop-before-partial")break;if(O==="loose"){if($.length===1)throw new f("Malformed padding: exactly one additional character");N=S(M,b($,T,!1),N)}else throw new f("Missing padding")}D=I;break}var F=m(x,k);if(++k,F==="="){if($.length<2)throw new f("Padding is too early");if(k=y(x,k),$.length===2){if(k===I){if(O==="stop-before-partial")break;throw new f("Malformed padding: only one =")}m(x,k)==="="&&(++k,k=y(x,k))}if(k<I)throw new f("Unexpected character after padding");N=S(M,b($,T,O==="strict"),N),D=I;break}if(!a(T,F))throw new f("Unexpected character");var W=C-N;if(W===1&&$.length===2||W===2&&$.length===3||($+=F,$.length===4&&(N=S(M,b($,T,!1),N),$="",D=k,N===C)))break}return E||(M.length=N),{bytes:M,read:D,written:N}}},2303(h,t,e){var s=e(4576),n=e(9504),i=s.Uint8Array,r=s.SyntaxError,a=Math.min,o=n("".match);h.exports=function(l,c){var d=l.length;if(d%2!==0)throw new r("String should be an even number of characters");for(var u=c?a(c.length,d/2):d/2,f=c||new i(u),p=o(l,/[\S\s]{2}/g),g=0;g<u;g++){var m=+("0x"+p[g]+"0");if(m!==m)throw new r("String should only contain hex characters");f[g]=m>>4}return{bytes:f,read:g<<1}}},7416(h,t,e){var s=e(9039),n=e(8227),i=e(3724),r=e(6395),a=n("iterator");h.exports=!s(function(){var o=new URL("b?a=1&b=2&c=3","https://a"),l=o.searchParams,c=new URLSearchParams("a=1&a=2&b=3"),d="";return o.pathname="c%20d",l.forEach(function(u,f){l.delete("b"),d+=f+u}),c.delete("a",2),c.delete("b",void 0),r&&(!o.toJSON||!c.has("a",1)||c.has("a",2)||!c.has("a",void 0)||c.has("b"))||!l.size&&(r||!i)||!l.sort||o.href!=="https://a/c%20d?a=1&c=3"||l.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!l[a]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||d!=="a1c3"||new URL("https://x",void 0).host!=="x"})},7040(h,t,e){var s=e(4495);h.exports=s&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},8686(h,t,e){var s=e(3724),n=e(9039);h.exports=s&&n(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})},2812(h){var t=TypeError;h.exports=function(e,s){if(e<s)throw new t("Not enough arguments");return e}},8622(h,t,e){var s=e(4576),n=e(4901),i=s.WeakMap;h.exports=n(i)&&/native code/.test(String(i))},4995(h,t,e){var s=e(9504),n=WeakMap.prototype;h.exports={WeakMap,set:s(n.set),get:s(n.get),has:s(n.has),remove:s(n.delete)}},8227(h,t,e){var s=e(4576),n=e(5745),i=e(9297),r=e(3392),a=e(4495),o=e(7040),l=s.Symbol,c=n("wks"),d=o?l.for||l:l&&l.withoutSetter||r;h.exports=function(u){return i(c,u)||(c[u]=a&&i(l,u)?l[u]:d("Symbol."+u)),c[u]}},4423(h,t,e){var s=e(6518),n=e(9617).includes,i=e(9039),r=e(6469),a=i(function(){return!Array(1).includes()}
vendor: 4,291 bytes, line 3
3),o=i(function(){return[,1].includes(void 0,1)});s({target:"Array",proto:!0,forced:a||o},{includes:function(c){return n(this,c,arguments.length>1?arguments[1]:void 0)}}),r("includes")},4114(h,t,e){var s=e(6518),n=e(8981),i=e(6198),r=e(4527),a=e(6837),o=e(9039),l=o(function(){return[].push.call({length:4294967296},1)!==4294967297}),c=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(u){return u instanceof TypeError}},d=l||!c();s({target:"Array",proto:!0,arity:1,forced:d},{push:function(f){var p=n(this),g=i(p),m=arguments.length;a(g+m);for(var v=0;v<m;v++)p[g]=arguments[v],g++;return r(p,g),g}})},8111(h,t,e){var s=e(6518),n=e(4576),i=e(679),r=e(8551),a=e(4901),o=e(2787),l=e(2106),c=e(4659),d=e(9039),u=e(9297),f=e(8227),p=e(7657).IteratorPrototype,g=e(3724),m=e(6395),v="constructor",y="Iterator",b=f("toStringTag"),S=TypeError,x=n[y],w=m||!a(x)||x.prototype!==p||!d(function(){x({})}),E=function(){if(i(this,p),o(this)===p)throw new S("Abstract class Iterator not directly constructable")},C=function(T,O){g?l(p,T,{configurable:!0,get:function(){return O},set:function(I){if(r(this),this===p)throw new S("You can't redefine this property");u(this,T)?this[T]=I:c(this,T,I)}}):p[T]=O};u(p,b)||C(b,y),(w||!u(p,v)||p[v]===Object)&&C(v,E),E.prototype=p,s({global:!0,constructor:!0,forced:w},{Iterator:E})},9314(h,t,e){var s=e(6518),n=e(9565),i=e(8551),r=e(1767),a=e(4149),o=e(9590),l=e(9539),c=e(9462),d=e(684),u=e(4549),f=e(6395),p=RangeError,g=1/0,m=!f&&!d("drop",0),v=!f&&!m&&u("drop",RangeError),y=f||m||v||!(function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(S){return S instanceof p}})(),b=c(function(){for(var S=this.iterator,x=this.next,w,E;this.remaining;)if(this.remaining--,w=i(n(x,S)),E=this.done=!!w.done,E)return;if(w=i(n(x,S)),E=this.done=!!w.done,!E)return w.value});s({target:"Iterator",proto:!0,real:!0,forced:y},{drop:function(x){i(this);var w;try{if(w=o(a(+x)),w>9007199254740991&&w!==g)throw new p("The argument should be a safe integer")}catch(E){l(this,"throw",E)}return v?n(v,this,w):new b(r(this),{remaining:w})}})},1148(h,t,e){var s=e(6518),n=e(9565),i=e(2652),r=e(9306),a=e(8551),o=e(1767),l=e(9539),c=e(4549),d=c("every",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{every:function(f){a(this);try{r(f)}catch(m){l(this,"throw",m)}if(d)return n(d,this,f);var p=o(this),g=0;return!i(p,function(m,v){if(!f(m,g++))return v()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(h,t,e){var s=e(6518),n=e(9565),i=e(9306),r=e(8551),a=e(1767),o=e(9462),l=e(6319),c=e(6395),d=e(9539),u=e(684),f=e(4549),p=!c&&!u("filter",function(){}),g=!c&&!p&&f("filter",TypeError),m=c||p||g,v=o(function(){for(var y=this.iterator,b=this.predicate,S=this.next,x,w,E;;){if(x=r(n(S,y)),w=this.done=!!x.done,w)return;if(E=x.value,l(y,b,[E,this.counter++],!0))return E}});s({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(b){r(this);try{i(b)}catch(S){d(this,"throw",S)}return g?n(g,this,b):new v(a(this),{predicate:b})}})},116(h,t,e){var s=e(6518),n=e(9565),i=e(2652),r=e(9306),a=e(8551),o=e(1767),l=e(9539),c=e(4549),d=c("find",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{find:function(f){a(this);try{r(f)}catch(m){l(this,"throw",m)}if(d)return n(d,this,f);var p=o(this),g=0;return i(p,function(m,v){if(f(m,g++))return v(m)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(h,t,e){var s=e(6518),n=e(9565),i=e(9306),r=e(8551),a=e(1767),o=e(8646),l=e(9462),c=e(9539),d=e(9039),u=e(6395),f=e(684),p=e(4549),g=!u&&d(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),m=!u&&!g&&!f("flatMap",function(){}),v=!u&&!g&&!m&&p("flatMap",TypeError),y=u||g||m||v,b=l(function(){for(var S=this.iterator,x=this.mapper,w,E;;){if(E=this.inner)try{if(w=r(n(E.next,E.iterator)),!w.done)return w.value;this.inner=null}catch(C){c(S,"throw",C)}if(w=r(n(this.next,S)),this.done=!!w.done)return;try{this.inner=o(x(w.value,this.counter++),!1)}catch(C){c(S,"throw",C)}}});s({target:"Iterator",proto:!0,real:!0,forced:y},{flatMap:function(x){r(this);try{i(x)}catch(w){c(this,"throw",w)}return v?n(v,this,x):new b(a(this),{mapper:x,inner:null})}})},7588(h,t,e){var s=e(6518),n=e(9565),i=e(2652),r=e(9306),a=e(8551),o=e(1767),l=e(9539),c=e(4549),d=c("forEac
3h",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{forEach:function(f){a(this);try{r(f)}catch(m){l(this,"throw",m)}if(d)return n(d,this,f);var p=o(this),g=0;i(p,function(m){f(m,g++)},{IS_RECORD:!0})}})},1701(h,t,e){var s=e(6518),n=e(9565),i=e(9306),r=e(8551),a=e(1767),o=e(9462),l=e(6319),c=e(9539),d=e(684),u=e(4549),f=e(6395),p=!f&&!d("map",function(){}),g=!f&&!p&&u("map",TypeError),m=f||p||g,v=o(function(){var y=this.iterator,b=r(n(this.next,y)),S=this.done=!!b.done;if(!S)return l(y,this.mapper,[b.value,this.counter++],!0)});s({target:"Iterator",proto:!0,real:!0,forced:m},{map:function(b){r(this);try{i(b)}catch(S){c(this,"throw",S)}return g?n(g,this,b):new v(a(this),{mapper:b})}})},3579(h,t,e){var s=e(6518),n=e(9565),i=e(2652),r=e(9306),a=e(8551),o=e(1767),l=e(9539),c=e(4549),d=c("some",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{some:function(f){a(this);try{r(f)}catch(m){l(this,"throw",m)}if(d)return n(d,this,f);var p=o(this),g=0;return i(p,function(m,v){if(f(m,g++))return v()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(h,t,e){var s=e(6518),n=e(9565),i=e(8551),r=e(1767),a=e(4149),o=e(9590),l=e(9462),c=e(9539),d=e(684),u=e(4549),f=e(6395),p=RangeError,g=1/0,m=!f&&!d("take",1),v=!f&&!m&&u("take",RangeError),y=f||m||v||!(function(){try{Iterator.prototype.take.call({next:function(){return{done:!0}}},9007199254740992)}catch(S){return S instanceof p}})(),b=l(function(){var S=this.iterator;if(!this.remaining--)return this.done=!0,c(S,"normal",void 0);var x=i(n(this.next,S)),w=this.done=!!x.done;if(!w)return x.value});s({target:"Iterator",proto:!0,real:!0,forced:y},{take:function(x){i(this);var w;try{if(w=o(a(+x)),w>9007199254740991&&w!==g)throw new p("The argument should be a safe integer")}catch(E){c(this,"throw",E)}return v?n(v,this,w):new b(r(this),{remaining:w})}})},1806(h,t,e){var s=e(6518),n=e(8551),i=e(4659),r=e(2652),a=e(1767);s({target:"Iterator",proto:!0,real:!0},{toArray:function(){var l=[],c=0;return r(a(n(this)),function(d){i(l,c++,d)},{IS_RECORD:!0}),l}})},9112(h,t,e){var s=e(6518),n=e(3724),i=e(4576),r=e(7751),a=e(9504),o=e(9565),l=e(4901),c=e(34),d=e(4376),u=e(9297),f=e(655),p=e(6198),g=e(4659),m=e(9039),v=e(8235),y=e(4495),b=i.JSON,S=i.Number,x=i.SyntaxError,w=b&&b.parse,E=r("Object","keys"),C=Object.getOwnPropertyDescriptor,T=a("".charAt),O=a("".slice),I=a(/./.exec),M=a([].push),N=/^\d$/,D=/^[1-9]$/,$=/^[\d-]$/,k=/^[\t\n\r ]$/,F=0,W=1,G=function(B,R){B=f(B);var j=new tt(B,0),K=j.parse(),ct=K.value,X=j.skip(k,K.end);if(X<B.length)throw new x('Unexpected extra character: "'+T(B,X)+'" after the parsed data at: '+X);return l(R)?at({"":ct},"",R,K):ct},at=function(B,R,j,K){var ct=B[R],X=K&&ct===K.value,nt=X&&typeof K.source=="string"?{source:K.source}:{},ut,kt,ft,At,Wt;if(c(ct)){var Pe=d(ct),Ie=X?K.nodes:Pe?[]:{};if(Pe)for(ut=Ie.length,ft=p(ct),At=0;At<ft;At++)bt(ct,At,at(ct,""+At,j,At<ut?Ie[At]:void 0));else for(kt=E(ct),ft=p(kt),At=0;At<ft;At++)Wt=kt[At],bt(ct,Wt,at(ct,Wt,j,u(Ie,Wt)?Ie[Wt]:void 0))}return o(j,B,R,ct,nt)},bt=function(B,R,j){if(n){var K=C(B,R);if(K&&!K.configurable)return}j===void 0?delete B[R]:g(B,R,j)},J=function(B,R,j,K){this.value=B,this.end=R,this.source=j,this.nodes=K},tt=function(B,R){this.source=B,this.index=R};tt.prototype={fork:function(B){return new tt(this.source,B)},parse:function(){var B=this.source,R=this.skip(k,this.index),j=this.fork(R),K=T(B,R);if(I($,K))return j.number();switch(K){case"{":return j.object();case"[":return j.array();case'"':return j.string();case"t":return j.keyword(!0);case"f":return j.keyword(!1);case"n":return j.keyword(null)}throw new x('Unexpected character: "'+K+'" at: '+R)},node:function(B,R,j,K,ct){return new J(R,K,B?null:O(this.source,j,K),ct)},object:function(){for(var B=this.source,R=this.index+1,j=!1,K={},ct={},X=!1;R<B.length;){if(R=this.until(['"',"}"],R),T(B,R)==="}"&&!j){R++,X=!0;break}var nt=this.fork(R).string(),ut=nt.value;R=nt.end,R=this.until([":"],R)+1,R=this.skip(k,R),nt=this.fork(R).parse(),g(ct,ut,nt),g(K,ut,nt.value),R=this.until([",","}"],nt.end);var kt=T(B,R);if(kt===",")j=!0,R++;else if(kt==="}"){R++,X=!0;break}}if(!X)throw new x("Unterminated object at: "+R);return this.node(W,K,this.index,R,ct)},array:function(){for(var B=this.source,R=this.index+1,j=!1,K=[],ct=[],X=!1;R<B.length;){if(R=this.skip(k,R),T(B,R)==="]"&&!j){R++,X=!0;break}var nt=this.fork(R).parse();if(M(ct,nt),M(K,nt.value),R=this.until([",","]"],nt.end),T(B,R)===",")j=!0,R++;else if(T(B,R)==="]"){R++,X=!0;break}}if(!X)throw new x("Unterminated array at: "+R);return this.node(W,K,this.index,R,ct)},string:function(){var B=this.index,R=v(this.source,this.index+1);return this.node(F,R.value,B,R.end)},number:function(){var B=this.source,R=this.index,j=R;if(T(B,j)==="-"&&j++,T(B,j)==="0")j++;else if(I(D,T(B,j)))j=this.skip(N,j+1);else throw new x("Failed to parse number at: "+j);if(T(B,j)==="."){var K=j+1;if(j=this.skip(N,K),K===j)throw new x("Failed to parse number's fraction at: "+j)}if(T(B,j)==="e"||T(B,j)==="E"){j++,(T(B,j)==="+"||T(B,j)==="-")&&j++;var ct=j;if(j=this.skip(N,j),ct===j)throw new x("Failed to parse number's exponent value at: "+j)}return this.node(F,S(O(B,R,j)),R,j)},keyword:function(B){var R=""+B,j=this.index,K=j+R.length;if(O(this.source,j,K)!==R)throw new x("Failed to parse value at: "+j);return this.node(F,B,j,K)},skip:function(B,R){for(var j=this.source;R<j.length&&I(B,T(j,R));R++);return R},until:function(B,R){R=this.skip(k,R);for(var j=T(this.source,R),K=0;K<B.length;K++)if(B[K]===j)return R;throw new x('Unexpected character: "'+j+'" at: '+R)}};var dt=m(function(){var B="9007199254740993",R;return w(B,function(j,K,ct){R=ct.source}),R!==B}),_t=y&&!m(function(){return 1/w("-0 	")!==-1/0});s({target:"JSON",stat:!0,forced:dt},{parse:function(R,j){return _t&&!l(j)?w(R):G(R,j)}})},3110(h,t,e){var s=e(6518),n=e(7751),i=e(9565),r=e(9504),a=e(9039),o=e(4376),l=e(4901),c=e(34),d=e(2360),u=e(5810),f=e(757),p=e(2195),g=e(1240),m=e(9617).includes,v=e(9297),y=e(655),b=e(8235),S=e(3392),x=e(4495),w=e(7819),E=String,C=TypeError,T=n("JSON","stringify"),O=n("BigInt"),I=r("".valueOf),M=r((!0).valueOf),N=O&&r(O.prototype.valueOf),D=r(
vendor: 5,990 bytes, line 3
3/./.exec),$=r("".charAt),k=r("".charCodeAt),F=r("".replace),W=r("".slice),G=r([].push),at=r([].pop),bt=r(1.1.toString),J=/[\uD800-\uDFFF]/g,tt=/^[\uD800-\uDBFF]$/,dt=/^[\uDC00-\uDFFF]$/,_t=/^\d+$/,B=S(),R=S(),j=S(),K=B.length,ct=R.length,X=!x||a(function(){var it=n("Symbol")("stringify detection");return T([it])!=="[null]"||T({a:it})!=="{}"||T(Object(it))!=="{}"}),nt=a(function(){return T("\uDF06\uD834")!=='"\\udf06\\ud834"'||T("\uDEAD")!=='"\\udead"'}),ut=w?n("JSON","isRawJSON"):u,kt=X?function(it,rt,gt){return T(it,function(wt,Dt){var Pt=i(rt,this,wt,Dt);if(!f(Pt))return Pt},gt)}:T,ft=function(it,rt,gt){var wt=$(gt,rt-1),Dt=$(gt,rt+1);return D(tt,it)&&!D(dt,Dt)||D(dt,it)&&!D(tt,wt)?"\\u"+bt(k(it,0),16):it},At=function(it){if(o(it)){for(var rt=it.length,gt=[],wt=d(null),Dt=0;Dt<rt;Dt++){var Pt=it[Dt],$t;if(typeof Pt=="string")$t=Pt;else if(typeof Pt=="number"||p(Pt)==="Number"||p(Pt)==="String")$t=y(Pt);else continue;v(wt,$t)||(wt[$t]=!0,G(gt,$t))}return gt}},Wt=function(it,rt){try{return it(rt),!0}catch{return!1}},Pe=function(it){var rt=p(it);return rt==="Number"&&Wt(g,it)||rt==="String"&&Wt(I,it)||rt==="Boolean"&&Wt(M,it)||!!N&&rt==="BigInt"&&Wt(N,it)},Ie=function(it){if(!c(it)||l(it)||o(it))return!1;try{return!Pe(it)}catch{return!0}},Zs=function(it,rt){return{toJSON:function(){var gt=it[rt];if(c(gt)||typeof gt=="bigint"){var wt=gt.toJSON;l(wt)&&(gt=i(wt,gt,rt))}return gt}}},qs=function(it){for(var rt=0,gt=it.length;rt<gt;rt++)if(D(_t,it[rt]))return R;return""},ze=function(it,rt,gt){for(var wt=d(null),Dt=0,Pt=rt.length;Dt<Pt;Dt++){var $t=rt[Dt];wt[gt+$t]=Zs(it,$t)}return wt[j]=null,wt};T&&s({target:"JSON",stat:!0,arity:3,forced:X||nt||!w},{stringify:function(rt,gt,wt){var Dt=l(gt)?gt:void 0,Pt=Dt?void 0:At(gt),$t=Pt&&qs(Pt),os=[],me=[],Ps=[],ls,Ge=!1,Fe=!0,re=kt(rt,function(Oe,vt){if(Oe=E(Oe),Pt){if(Oe===j){at(me),ls=at(Ps);return}if(Fe)Fe=!1;else if(this!==ls&&!o(this)&&!m(Pt,Oe))return}else Dt&&(vt=i(Dt,this,Oe,vt));if(ut(vt))return w?vt:(Ge=!0,B+(G(os,vt.rawJSON)-1));if(Pt&&Ie(vt)){if(m(me,vt))throw new C("Converting circular structure to JSON");var Zt=ze(vt,Pt,$t);return G(me,vt),G(Ps,ls),ls=Zt,$t&&(Ge=!0),Zt}return vt},wt);if(typeof re!="string"||(nt&&(re=F(re,J,ft)),!Ge))return re;for(var Ve="",tn=re.length,ve=0;ve<tn;ve++){var cs=$(re,ve);if(cs==='"'){var hs=b(re,++ve).end-1,he=W(re,ve,hs);W(he,0,K)===B?Ve+=os[W(he,K)]:W(he,0,ct)===R?Ve+='"'+W(he,ct)+'"':Ve+='"'+he+'"',ve=hs}else Ve+=cs}return Ve}})},2731(h,t,e){var s=e(6518),n=e(9306),i=e(2248),r=e(6395),a=i.get,o=i.has,l=i.set;s({target:"Map",proto:!0,real:!0,forced:r},{getOrInsertComputed:function(d,u){var f=o(this,d);if(n(u),f)return a(this,d);d===0&&1/d===-1/0&&(d=0);var p=u(d);return l(this,d,p),p}})},5367(h,t,e){var s=e(6518),n=e(2248),i=e(6395),r=n.get,a=n.has,o=n.set;s({target:"Map",proto:!0,real:!0,forced:i},{getOrInsert:function(c,d){return a(this,c)?r(this,c):(o(this,c,d),d)}})},3068(h,t,e){var s=e(6518),n=e(9504),i=e(2652),r=RangeError,a=TypeError,o=1/0,l=NaN,c=Math.abs,d=Math.pow,u=n([].push),f=d(2,1023),p=d(2,53)-1,g=Number.MAX_VALUE,m=d(2,971),v={},y={},b={},S={},x={},w=function(E,C){var T=E+C,O=C-(T-E);return{hi:T,lo:O}};s({target:"Math",stat:!0},{sumPrecise:function(C){var T=[],O=0,I=S;switch(i(C,function(B){if(++O>p)throw new r("Maximum allowed index exceeded");if(typeof B!="number")throw new a("Value is not a number");I!==v&&(B!==B?I=v:B===o?I=I===y?v:b:B===-o?I=I===b?v:y:(B!==0||1/B===o)&&(I===S||I===x)&&(I=x,u(T,B)))}),I){case v:return l;case y:return-o;case b:return o;case S:return-0}for(var M=[],N=0,D,$,k,F,W,G,at=0;at<T.length;at++){D=T[at];for(var bt=0,J=0;J<M.length;J++){if($=M[J],c(D)<c($)&&(G=D,D=$,$=G),k=w(D,$),F=k.hi,W=k.lo,c(F)===o){var tt=F===o?1:-1;N+=tt,D=D-tt*f-tt*f,c(D)<c($)&&(G=D,D=$,$=G),k=w(D,$),F=k.hi,W=k.lo}W!==0&&(M[bt++]=W),D=F}M.length=bt,D!==0&&u(M,D)}var dt=M.length-1;if(F=0,W=0,N!==0){var _t=dt>=0?M[dt]:0;if(dt--,c(N)>1||N>0&&_t>0||N<0&&_t<0)return N>0?o:-o;if(k=w(N*f,_t/2),F=k.hi,W=k.lo,W*=2,c(2*F)===o)return F>0?F===f&&W===-(m/2)&&dt>=0&&M[dt]<0?g:o:F===-f&&W===m/2&&dt>=0&&M[dt]>0?-g:-o;W!==0&&(M[++dt]=W,W=0),F*=2}for(;dt>=0&&(k=w(F,M[dt--]),F=k.hi,W=k.lo,W===0););return dt>=0&&(W<0&&M[dt]<0||W>0&&M[dt]>0)&&($=W*2,D=F+$,$===D-F&&(F=D)),F}})},1689(h,t,e){var s=e(6518),n=e(4576),i=e(8745),r=e(7680),a=e(3438),o=e(6043),l=e(9306),c=e(1103),d=e(9039),u=n.Promise,f=!1,p=!u||!u.try||d(function(){var g=u.resolve();return u.try(function(m){return f=m===8,g},8)!==g})||!f;s({target:"Promise",stat:!0,forced:p},{try:function(g){var m=arguments.length>1?r(arguments,1):[],v=c(function(){return i(l(g),void 0,m)});if(!v.error)return a(this,v.value);var y=o.f(this),b=y.reject;return b(v.value),y.promise}})},7642(h,t,e){var s=e(6518),n=e(3440),i=e(9039),r=e(4916),a=!r("difference",function(l){return l.size===0}),o=a||i(function(){var l={size:1,has:function(){return!0},keys:function(){var d=0;return{next:function(){var u=d++>1;return c.has(1)&&c.clear(),{done:u,value:2}}}}},c=new Set([1,2,3,4]);return c.difference(l).size!==3});s({target:"Set",proto:!0,real:!0,forced:o},{difference:n})},8004(h,t,e){var s=e(6518),n=e(9039),i=e(8750),r=e(4916),a=!r("intersection",function(o){return o.size===2&&o.has(1)&&o.has(2)})||n(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});s({target:"Set",proto:!0,real:!0,forced:a},{intersection:i})},3853(h,t,e){var s=e(6518),n=e(4449),i=e(4916),r=!i("isDisjointFrom",function(a){return!a});s({target:"Set",proto:!0,real:!0,forced:r},{isDisjointFrom:n})},5876(h,t,e){var s=e(6518),n=e(3838),i=e(4916),r=!i("isSubsetOf",function(a){return a});s({target:"Set",proto:!0,real:!0,forced:r},{isSubsetOf:n})},2475(h,t,e){var s=e(6518),n=e(8527),i=e(4916),r=!i("isSupersetOf",function(a){return!a});s({target:"Set",proto:!0,real:!0,forced:r},{isSupersetOf:n})},5024(h,t,e){var s=e(6518),n=e(3650),i=e(9835),r=e(4916),a=!r("symmetricDifference")||!i("symmetricDifference");s({target:"Set",proto:!0,real:!0,forced:a},{symmetricDifference:n})}
3,1698(h,t,e){var s=e(6518),n=e(4204),i=e(9835),r=e(4916),a=!r("union")||!i("union");s({target:"Set",proto:!0,real:!0,forced:a},{union:n})},9577(h,t,e){var s=e(4644),n=e(1108),i=e(6198),r=e(1291),a=e(5854),o=s.aTypedArray,l=s.getTypedArrayConstructor,c=s.exportTypedArrayMethod,d=RangeError,u=(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(p){return p===8}})(),f=u&&(function(){try{new Int8Array(1).with(-.5,1)}catch{return!0}})();c("with",function(p,g){var m=o(this),v=i(m),y=r(p),b=y<0?v+y:y,S=n(m)?a(g):+g;if(b>=v||b<0)throw new d("Incorrect index");for(var x=new(l(m))(v),w=0;w<v;w++)x[w]=w===b?S:m[w];return x},!u||f)},5213(h,t,e){var s=e(6518),n=e(4576),i=e(5370),r=e(9143),a=n.Uint8Array,o=!a||!a.fromBase64||!(function(){try{a.fromBase64("a");return}catch{}try{a.fromBase64("",null)}catch{return!0}})();a&&s({target:"Uint8Array",stat:!0,forced:o},{fromBase64:function(c){var d=r(c,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return i(a,d.bytes)}})},6632(h,t,e){var s=e(6518),n=e(4576),i=e(9143),r=e(4154),a=n.Uint8Array,o=!a||!a.prototype.setFromBase64||!(function(){var l=new a([255,255,255,255,255]);try{l.setFromBase64("",null);return}catch{}try{l.setFromBase64("a");return}catch{}try{l.setFromBase64("MjYyZg===")}catch{return l[0]===50&&l[1]===54&&l[2]===50&&l[3]===255&&l[4]===255}})();a&&s({target:"Uint8Array",proto:!0,forced:o},{setFromBase64:function(c){r(this);var d=i(c,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:d.read,written:d.written}}})},4226(h,t,e){var s=e(6518),n=e(4576),i=e(3463),r=e(4154),a=e(5169),o=e(2303);function l(){try{var c=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(c).setFromHex("cafed00d")}catch{return!0}}n.Uint8Array&&s({target:"Uint8Array",proto:!0,forced:l()},{setFromHex:function(d){r(this),i(d),a(this.buffer);var u=o(d,this).read;return{read:u,written:u/2}}})},9486(h,t,e){var s=e(6518),n=e(4576),i=e(9504),r=e(3972),a=e(4154),o=e(5169),l=e(2804),c=e(944),d=l.i2c,u=l.i2cUrl,f=Math.floor,p=Math.ceil,g=i("".charAt),m=n.Uint8Array,v=n.Array,y=i([].join),b=!m||!m.prototype.toBase64||!(function(){try{var S=new m;S.toBase64(null)}catch{return!0}})();m&&s({target:"Uint8Array",proto:!0,forced:b},{toBase64:function(){var x=a(this),w=arguments.length?r(arguments[0]):void 0,E=c(w)==="base64"?d:u,C=!!w&&!!w.omitPadding;o(this.buffer);for(var T=0,O=x.length,I=v(C?f(O/3)*4+(O%3?O%3+1:0):p(O/3)*4),M=0,N,D=function($){return g(E,N>>6*$&63)};T+2<O;T+=3)N=(x[T]<<16)+(x[T+1]<<8)+x[T+2],I[M++]=D(3),I[M++]=D(2),I[M++]=D(1),I[M++]=D(0);return T+2===O?(N=(x[T]<<16)+(x[T+1]<<8),I[M++]=D(3),I[M++]=D(2),I[M++]=D(1),C||(I[M++]="=")):T+1===O&&(N=x[T]<<16,I[M++]=D(3),I[M++]=D(2),C||(I[M++]="=",I[M++]="=")),y(I,"")}})},456(h,t,e){var s=e(6518),n=e(4576),i=e(9504),r=e(4154),a=e(5169),o=i(1.1.toString),l=i([].join),c=Array,d=n.Uint8Array,u=!d||!d.prototype.toHex||!(function(){try{var f=new d([255,255,255,255,255,255,255,255]);return f.toHex()==="ffffffffffffffff"}catch{return!1}})();d&&s({target:"Uint8Array",proto:!0,forced:u},{toHex:function(){r(this),a(this.buffer);for(var p=c(this.length),g=0,m=this.length;g<m;g++){var v=o(this[g],16);p[g]=v.length===1?"0"+v:v}return l(p,"")}})},9452(h,t,e){var s=e(6518),n=e(9306),i=e(6557),r=e(4328),a=e(4995),o=e(6395),l=a.get,c=a.has,d=a.set,u=o||!(function(){try{WeakMap.prototype.getOrInsertComputed&&new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(f){return f instanceof TypeError}})();s({target:"WeakMap",proto:!0,real:!0,forced:u},{getOrInsertComputed:function(p,g){if(o||i(this),r(p),n(g),c(this,p))return l(this,p);var m=g(p);return d(this,p,m),m}})},8454(h,t,e){var s=e(6518),n=e(4995),i=e(6395),r=n.get,a=n.has,o=n.set;s({target:"WeakMap",proto:!0,real:!0,forced:i},{getOrInsert:function(c,d){return a(this,c)?r(this,c):(o(this,c,d),d)}})},4979(h,t,e){var s=e(6518),n=e(4576),i=e(7751),r=e(6980),a=e(4913).f,o=e(9297),l=e(679),c=e(3167),d=e(2603),u=e(5002),f=e(6193),p=e(3724),g=e(6395),m="DOMException",v=i("Error"),y=i(m),b=function(){l(this,S);var k=arguments.length,F=d(k<1?void 0:arguments[0]),W=d(k<2?void 0:arguments[1],"Error"),G=new y(F,W),at=new v(F);return at.name=m,a(G,"stack",r(1,f(at.stack,1))),c(G,this,b),G},S=b.prototype=y.prototype,x="stack"in new v(m),w="stack"in new y(1,2),E=y&&p&&Object.getOwnPropertyDescriptor(n,m),C=!!E&&!(E.writable&&E.configurable),T=
3x&&!C&&!w;s({global:!0,constructor:!0,forced:g||T},{DOMException:T?b:y});var O=i(m),I=O.prototype;if(I.constructor!==O){g||a(I,"constructor",r(1,O));for(var M in u)if(o(u,M)){var N=u[M],D=N.s;o(O,D)||a(O,D,r(6,N.c))}}},5781(h,t,e){var s=e(6518),n=e(7751),i=e(2812),r=e(655),a=e(7416),o=n("URL");s({target:"URL",stat:!0,forced:!a},{parse:function(c){var d=i(arguments.length,1),u=r(c),f=d<2||arguments[1]===void 0?void 0:r(arguments[1]);try{return new o(u,f)}catch{return null}}})}};const br={};function st(h){const t=br[h];if(t!==void 0)return t.exports;const e=br[h]={exports:{}};return Ao[h].call(e.exports,e,e.exports,st),e.exports}st.d=(h,t)=>{if(Array.isArray(t))for(var e=0;e<t.length;){var s=t[e++],n=t[e++];st.o(h,s)?n===0&&e++:n===0?Object.defineProperty(h,s,{enumerable:!0,value:t[e++]}):Object.defineProperty(h,s,{enumerable:!0,get:n})}else for(var s in t)st.o(t,s)&&!st.o(h,s)&&Object.defineProperty(h,s,{enumerable:!0,get:t[s]})};st.o=(h,t)=>Object.prototype.hasOwnProperty.call(h,t);st(4423);st(4114);st(8111);st(2489);st(5367);st(2731);st(7642);st(8004);st(3853);st(5876);st(2475);st(5024);st(1698);st(9577);st(6632);st(4226);st(9486);st(456);st(5781);const se=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),De=[1/0,1/0,-1/0,-1/0],Je=new Float32Array(De),ci=[.001,0,0,.001,0,0],Gt="http://www.w3.org/2000/svg",te={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},_e={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},bs="pdfjs_internal_id_",Es="pdfjs_internal_editor_",q={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},lt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},wo={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ft={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},xn={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},It={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},ms={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Rn={ERRORS:0,WARNINGS:1,INFOS:5},Te={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},ks={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},So={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Nn=Rn.WARNINGS;function Eo(h){Number.isInteger(h)&&(Nn=h)}function To(){return Nn}
vendor: 13,472 bytes, line 3
3function kn(h){Nn>=Rn.INFOS&&console.info(`Info: ${h}`)}function Q(h){Nn>=Rn.WARNINGS&&console.warn(`Warning: ${h}`)}function ht(h){throw new Error(h)}function Ot(h,t){h||ht(t)}function Co(h){switch(h?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function na(h,t=null,e=null){if(!h)return null;if(e&&typeof h=="string"&&(e.addDefaultProtocol&&h.startsWith("www.")&&h.match(/\./g)?.length>=2&&(h=`http://${h}`),e.tryConvertEncoding))try{h=Oo(h)}catch{}const s=t?URL.parse(h,t):URL.parse(h);return Co(s)?s:null}function ia(h,t,e=!1){const s=URL.parse(h);return s?(s.hash=t,s.href):e&&na(h,"http://example.com")?h.split("#",1)[0]+`${t?`#${t}`:""}`:""}function hi(h){return h.substring(h.lastIndexOf("/")+1)}function Y(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const rs=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class di extends rs{constructor(t,e){super(t,"PasswordException"),this.code=e}}class si extends rs{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class ui extends rs{constructor(t){super(t,"InvalidPDFException")}}class En extends rs{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class Po extends rs{constructor(t){super(t,"FormatError")}}class $e extends rs{constructor(t){super(t,"AbortException")}}function Io(h){(typeof h!="object"||h?.length===void 0)&&ht("Invalid argument for bytesToString");const t=h.length,e=8192;if(t<e)return String.fromCharCode.apply(null,h);const s=[];for(let n=0;n<t;n+=e){const i=Math.min(n+e,t),r=h.subarray(n,i);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function Dn(h){typeof h!="string"&&ht("Invalid argument for stringToBytes");const t=h.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=h.charCodeAt(s)&255;return e}class mt{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return Y(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return Y(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Y(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return Y(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return Y(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return Y(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),Y(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return Y(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",Y(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return Y(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class L{static get hexNums(){return Y(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}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,s=0){const n=t[s],i=t[s+1];t[s]=n*e[0]+i*e[2]+e[4],t[s+1]=n*e[1]+i*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const n=e[0],i=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){const d=t[s+c],u=t[s+c+1];t[s+c]=d*n+u*r+o,t[s+c+1]=d*i+u*a+l}}static applyInverseTransform(t,e){const s=t[0],n=t[1],i=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/i,t[1]=(-s*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/i}static axialAlignedBoundingBox(t,e,s){const n=e[0],i=e[1],r=e[2],a=e[3],o=e[4],l=e[5],c=t[0],d=t[1],u=t[2],f=t[3];let p=n*c+o,g=p,m=n*u+o,v=m,y=a*d+l,b=y,S=a*f+l,x=S;if(i!==0||r!==0){const w=i*c,E=i*u,C=r*d,T=r*f;p+=C,v+=C,m+=T,g+=T,y+=w,x+=w,S+=E,b+=E}s[0]=Math.min(s[0],p,m,g,v),s[1]=Math.min(s[1],y,S,b,x),s[2]=Math.max(s[2],p,m,g,v),s[3]=Math.max(s[3],y,S,b,x)}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 s=t[0],n=t[1],i=t[2],r=t[3],a=s**2+n**2,o=s*i+n*r,l=i**2+r**2,c=(a+l)/2,d=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||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 s=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(s>n)return null;const i=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 i>r?null:[s,i,n,r]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,n,i){i[0]=Math.min(i[0],t,s),i[1]=Math.min(i[1],e,n),i[2]=Math.max(i[2],t,s),i[3]=Math.max(i[3],e,n)}static#t(t,e,s,n,i,r,a,o,l,c){if(l<=0||l>=1)return;const d=1-l,u=l*l,f=u*l,p=d*(d*(d*t+3*l*e)+3*u*s)+f*n,g=d*(d*(d*i+3*l*r)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,n,i,r,a,o,l,c,d,u){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,n,i,r,a,o,-d/c,u);return}const f=c**2-4*d*l;if(f<0)return;const p=Math.sqrt(f),g=2*l;this.#t(t,e,s,n,i,r,a,o,(-c+p)/g,u),this.#t(t,e,s,n,i,r,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,s,n,i,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,s,i,a,e,n,r,o,3*(-t+3*(s-i)+a),6*(t-2*s+i),3*(s-t),l),this.#e(t,s,i,a,e,n,r,o,3*(-e+3*(n-r)+o),6*(e-2*n+r),3*(n-e),l)}}function Oo(h){return decodeURIComponent(escape(h))}let ni=null,xr=null;function Mo(h){return ni||(ni=/([\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,xr=new Map([["ſt","ſt"]])),h.replaceAll(ni,(t,e,s)=>e?e.normalize("NFKC"):xr.get(s))}function ra(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const h=new Uint8Array(32);return crypto.getRandomValues(h),Io(h)}function Ro(h,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,n,...i]=e;if(!h(s)&&!Number.isInteger(s)||!t(n))return!1;const r=i.length;let a=!0;switch(n.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return r===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(r!==4)return!1;a=!1;break;default:return!1}for(const o of i)if(!(typeof o=="number"||a&&o===null))return!1;return!0}const Cs=()=>[],Ti=()=>new Map,fi=()=>Object.create(null),No=()=>new Set;typeof Blob.prototype.bytes!="function"&&(Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});typeof Response.prototype.bytes!="function"&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(h){return[...this].join(h)});st(1701);function xt(h,t,e){return Math.min(Math.max(h,t),e)}class Ys{constructor({viewBox:t,userUnit:e,scale:s,rotation:n,offsetX:i=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=n,this.offsetX=i,this.offsetY=r,s*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,d,u,f;switch(n%=360,n<0&&(n+=360),n){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,v;c===0?(p=Math.abs(l-t[1])*s+i,g=Math.abs(o-t[0])*s+r,m=(t[3]-t[1])*s,v=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+i,g=Math.abs(l-t[1])*s+r,m=(t[2]-t[0])*s,v=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,f*s,p-c*s*o-u*s*l,g-d*s*o-f*s*l],this.width=m,this.height=v}get rawDims(){const t=this.viewBox;return Y(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:s=this.offsetX,offsetY:n=this.offsetY,dontFlip:i=!1}={}){return new Ys({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:i})}convertToViewportPoint(t,e){const s=[t,e];return L.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return L.applyInverseTransform(s,this.transform),s}}class Hs{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function n(i){if(!i)return;let r=null;const a=i.name;if(a==="#text")r=i.value;else if(Hs.shouldBuildText(a))i?.attributes?.textContent?r=i.attributes.textContent:i.value&&(r=i.value);else return;if(r!==null&&e.push({str:r}),!!i.children)for(const o of i.children)n(o)}return n(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const ko=/url\(|image-set\(/i,Do=/^on/i;class aa{static get _allowedHtmlElements(){return Y(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return Y(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return Y(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return Y(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return Y(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,n,i){const r=n.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null&&(t.textContent=r.value),i==="print")break;t.addEventListener("input",a=>{n.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn?t.setAttribute("checked",!0):r.value===s.attributes.xfaOff&&t.removeAttribute("checked"),i==="print")break;t.addEventListener("change",a=>{n.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null&&t.setAttribute("value",r.value),i==="print")break;t.addEventListener("input",a=>{n.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(const a of s.children)a.attributes.value===r.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;n.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:n,linkService:i}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;r.type==="radio"&&(r.name=`${r.name}-${n}`);for(const[o,l]of Object.entries(r))if(l!=null&&!Do.test(o)&&!(n==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(n==="richText"){const c=this._allowedRichTextStyles;for(const[d,u]of Object.entries(l))c.has(d)&&!ko.test(u)&&(t.style[d]=u)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&i?.addLinkAttributes(t,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===Gt&&this._allowedSvgElements.has(t)?document.createElementNS(Gt,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){const e=t.annotationStorage,s=t.linkService,n=t.xfaHtml,i=t.intent||"display",r=this.#t(n.name,n.attributes?.xmlns,i)??document.createElement("div");n.attributes&&this.setAttributes({html:r,element:n,intent:i,linkService:s});const a=i!=="richText",o=t.div;if(o.append(r),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];
3if(n.children.length===0){if(n.value){const d=document.createTextNode(n.value);r.append(d),a&&Hs.shouldBuildText(n.name)&&l.push(d)}return{textDivs:l}}const c=[[n,-1,r]];for(;c.length>0;){const[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const p=d.children[++c.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const v=document.createTextNode(p.value);l.push(v),f.append(v);continue}const m=this.#t(g,p.attributes?.xmlns,i);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:i,linkService:s}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){const v=document.createTextNode(p.value);a&&Hs.shouldBuildText(g)&&l.push(v),m.append(v)}}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.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}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:n,height:i}=t.attributes.style;return new Ys({viewBox:[0,0,parseInt(n,10),parseInt(i,10)],userUnit:1,scale:e,rotation:s})}}class Ts{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Ci(h,t="text"){if(_s(h,document.baseURI)){const e=await fetch(h);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const n=new XMLHttpRequest;n.open("GET",h,!0),n.responseType=t==="bytes"?"arraybuffer":t,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(n.status===200||n.status===0){switch(t){case"bytes":e(new Uint8Array(n.response));return;case"blob":case"json":e(n.response);return}e(n.responseText);return}s(new Error(n.statusText))}},n.send(null)})}class Pi extends rs{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Fn(h){const t=h.length;let e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function Ii(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function Fo(h){return[h]=h.split(/[#?]/,1),hi(h)}function Lo(h,t="document.pdf"){if(typeof h!="string")return t;if(Fn(h))return Q('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(h);if(!s)return t;const n=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=hi(o),o.length===4&&i.test(o))?a:o}catch{return a}},i=/\.pdf$/i,r=hi(s.pathname);if(i.test(r))return n(r);if(s.searchParams.size>0){const a=l=>[...l].findLast(c=>i.test(c)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return n(o)}if(s.hash){const{hash:a}=s;let o=-1;for(const{index:l}of a.matchAll(/\.pdf\b/gi))o=l;if(o>0){let l=o;for(;l>0&&!"/?#=".includes(a[l-1]);)l--;if(l<o)return n(a.slice(l,o+4))}}return t}class Ar{#t=new Map;times=[];time(t){this.#t.has(t)&&Q(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||Q(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
4`).join("")}}function _s(h,t){const e=t?URL.parse(h,t):URL.parse(h);return/https?:/.test(e?.protocol??"")}function pe(h){h.preventDefault()}function Lt(h){h.preventDefault(),h.stopPropagation()}class pi{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const s=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let i=parseInt(e[3],10);i=i>=1&&i<=31?i: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";
4let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,l==="-"?(r+=c,a+=d):l==="+"&&(r-=c,a-=d),new Date(Date.UTC(s,n,i,r,a,o))}}function Ks(h){if(h.startsWith("#")){const e=h.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(h.startsWith("rgb(")){const[e,s,n]=h.slice(4,-1).split(",").map(i=>parseInt(i,10));return[e,s,n,1]}if(h.startsWith("rgba(")){const e=h.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=h.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Qs(h){const t=Ks(h);return t?t.slice(0,3):(Q(`Not a valid color format: "${h}"`),[0,0,0])}function Bo(h){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of h.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;h.set(e,Qs(s))}t.remove()}function yt(h){const{a:t,b:e,c:s,d:n,e:i,f:r}=h.getTransform();return[t,e,s,n,i,r]}function we(h){const{a:t,b:e,c:s,d:n,e:i,f:r}=h.getTransform().invertSelf();return[t,e,s,n,i,r]}function ns(h,t,e=!1,s=!0){if(t instanceof Ys){const{pageWidth:n,pageHeight:i}=t.rawDims,{style:r}=h,a=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-y))`;!e||t.rotation%180===0?(r.width=a,r.height=o):(r.width=o,r.height=a)}s&&h.setAttribute("data-main-rotation",t.rotation)}class ge{constructor(){const{pixelRatio:t}=ge;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,n,i=-1){let r=1/0,a=1/0,o=1/0;s=ge.capPixels(s,i),s>0&&(r=Math.sqrt(s/(t*e))),n!==-1&&(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):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const gi=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class jo{static get isDarkMode(){return Y(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class _o{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:s}=window.getComputedStyle(t);return t.remove(),Y(this,"commentForegroundColor",Qs(s))}}function Uo(h,t){t=xt(t??1,0,1);const e=255*(1-t);return h.map(s=>Math.round(s*t+e))}function wr(h,t){const e=h[0]/255,s=h[1]/255,n=h[2]/255,i=Math.max(e,s,n),r=Math.min(e,s,n),a=(i+r)/2;if(i===r)t[0]=t[1]=0;else{const o=i-r;switch(t[1]=a<.5?o/(i+r):o/(2-i-r),i){case e:t[0]=((s-n)/o+(s<n?6:0))*60;break;case s:t[0]=((n-e)/o+2)*60;break;case n:t[0]=((e-s)/o+4)*60;break}}t[2]=a}function mi(h,t){const e=h[0],s=h[1],n=h[2],i=(1-Math.abs(2*n-1))*s,r=i*(1-Math.abs(e/60%2-1)),a=n-i/2;switch(Math.floor(e/60)){case 0:t[0]=i+a,t[1]=r+a,t[2]=a;break;case 1:t[0]=r+a,t[1]=i+a,t[2]=a;break;case 2:t[0]=a,t[1]=i+a,t[2]=r+a;break;case 3:t[0]=a,t[1]=r+a,t[2]=i+a;break;case 4:t[0]=r+a,t[1]=a,t[2]=i+a;break;case 5:case 6:t[0]=i+a,t[1]=a,t[2]=r+a;break}}function vi(h){return h<=.03928?h/12.92:((h+.055)/1.055)**2.4}function Sr(h,t,e){mi(h,e),e.map(vi);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];mi(t,e),e.map(vi);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const Er=new Map;function $o(h,t){const e=h[0]+h[1]*256+h[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=Er.get(e);if(s)return s;const n=new Float32Array(9),i=n.subarray(0,3),r=n.subarray(3,6);wr(h,r);const a=n.subarray(6,9);wr(t,a);const o=a[2]<.5,l=o?12:4.5;if(r[2]=o?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]),Sr(r,a,i)<l){let c,d;o?(c=r[2],d=1):(c=0,d=r[2]);const u=.005;for(;d-c>u;){const f=r[2]=(c+d)/2;o===Sr(r,a,i)<l?c=f:d=f}r[2]=o?d:c}return mi(r,i),s=L.makeHexColor(Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255
4)),Er.set(e,s),s}function oa({html:h,dir:t,className:e},s){const n=document.createDocumentFragment();if(typeof h=="string"){const i=document.createElement("p");i.dir=t||"auto";const r=h.split(/\r\n?|\n/);for(let a=0,o=r.length;a<o;++a){const l=r[a];i.append(document.createTextNode(l)),a<o-1&&i.append(document.createElement("br"))}n.append(i)}else aa.render({xfaHtml:h,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",e),s.append(n)}function la(h){const t=new Path2D;if(!h)return t;for(let e=0,s=h.length;e<s;)switch(h[e++]){case ks.moveTo:t.moveTo(h[e++],h[e++]);break;case ks.lineTo:t.lineTo(h[e++],h[e++]);break;case ks.curveTo:t.bezierCurveTo(h[e++],h[e++],h[e++],h[e++],h[e++],h[e++]);break;case ks.quadraticCurveTo:t.quadraticCurveTo(h[e++],h[e++],h[e++],h[e++]);break;case ks.closePath:t.closePath();break;default:Q(`Unrecognized drawing path operator: ${h[e-1]}`);break}return t}st(4972);st(8454);st(9452);st(4979);st(3579);st(3110);st(9314);st(1148);st(116);st(9112);class Us{#t=null;#e=null;#s;#n=null;#i=null;#a=null;#r=null;#o=null;static#l=null;constructor(t){this.#s=t,Us.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",pe,{signal:e}),t.addEventListener("pointerdown",Us.#c,{signal:e}));const s=this.#n=document.createElement("div");s.className="buttons",t.append(s);const n=this.#s.toolbarPosition;if(n){const{style:i}=t,r=this.#s._uiManager.direction==="ltr"?1-n[0]:n[0];i.insetInlineEnd=`${100*r}%`,i.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#c(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,Lt(t)}#d(t){this.#s._focusEventsAllowed=!0,Lt(t)}#f(t){const e=this.#s._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",pe,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#i?.shown(),this.#a?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",Us.#l[t]),this.#f(s)&&s.addEventListener("click",n=>{e.delete()},{signal:e._signal}),this.#n.append(s)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#f(e),this.#n.append(e,this.#g),this.#i=t}addComment(t,e=null){if(this.#a)return;const s=t.renderForToolbar();if(!s)return;this.#f(s);const n=this.#r=this.#g;e?(this.#n.insertBefore(s,e),this.#n.insertBefore(n,e)):this.#n.append(s,n),this.#a=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;const e=t.renderButton();this.#f(e),this.#n.append(e,this.#g)}async addEditSignatureButton(t){const e=this.#o=await t.renderEditButton(this.#s);this.#f(e),this.#n.append(e,this.#g)}removeButton(t){t==="comment"&&(this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=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);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const n=this.#n.querySelector(s);n&&t==="comment"&&this.addComment(e,n)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class Ho{#t=null;#e=null;#s;constructor(t){this.#s=t}#n(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#s.direction;const e=this.#s._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",pe,{signal:e});const s=this.#t=document.createElement("div");return s.className="buttons",t.append(s),this.#s.hasCommentManager()&&this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")}),this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#i(t,e){let s=0,n=0;for(const i of t){const r=i.y+i.height;if(r<s)continue;const a=i.x+(e?i.width:0);if(r>s){n=a,s=r;continue}e?a>n&&(n=a):a<n&&(n=a)}return[e?1-n:n,s]}show(t,e,s){const[n,i]=this.#i(e,s),{style:r}=this.#e||=this.#n();t.append(this.#e),r.insetInlineEnd=`${100*n}%`,r.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#a(t,e,s,n){const i=document.createElement("button");i.classList.add("basic",t),i.tabIndex=0,i.setAttribute("data-l10n-id",e);const r=document.createElement("span");i.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);const a=this.#s._signal;a instanceof AbortSignal&&!a.aborted&&(i.addEventListener("contextmenu",pe,{signal:a}),i.addEventListener("click",n,{signal:a})),this.#t.append(i)}}
4const zo="59968104-cc61-4cf9-b570-014b35b3709c",ii=Object.freeze({internal:zo});function ca(h,t,e){for(const s of e)t.addEventListener(s,h[s].bind(h))}class pt{static#t=NaN;static#e=null;static#s=NaN;static#n=null;static initializeAndAddPointerId(t){(pt.#e||=new Set).add(t)}static setPointer(t,e){pt.#t||=e,pt.#n??=t}static setTimeStamp(t){pt.#s=t}static isSamePointerId(t){return pt.#t===t}static isSamePointerIdOrRemove(t){return pt.#t===t?!0:(pt.#e?.delete(t),!1)}static isSamePointerType(t){return pt.#n===t}static isInitializedAndDifferentPointerType(t){return pt.#n!==null&&!pt.isSamePointerType(t)}static isSameTimeStamp(t){return pt.#s===t}static isUsingMultiplePointers(){return pt.#e?.size>=1}static clearPointerType(){pt.#n=null}static clearPointerIds(){pt.#t=NaN,pt.#e=null}static clearTimeStamp(){pt.#s=NaN}}class Go{#t=0;get id(){return`${Es}${this.#t++}`}}class Oi{#t=ra();#e=0;#s=null;static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Gt}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),n=new Image;n.src=t;const i=n.decode().then(()=>(s.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return Y(this,"_isSVGFittingCanvas",i)}async#n(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let n;if(typeof e=="string"?(s.url=e,n=await Ci(e,"blob")):e instanceof File?n=s.file=e:e instanceof Blob&&(n=e),n.type==="image/svg+xml"){const i=Oi._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{const d=s.svgUrl=r.result;a.src=await i?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=r.onerror=c});r.readAsDataURL(n),await o}else s.bitmap=await createImageBitmap(n);s.refCounter=1}catch(n){Q(n),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:n,type:i}=t;return this.#n(`${e}_${s}_${n}_${i}`,t)}async getFromUrl(t){return this.#n(t,t)}async getFromBlob(t,e){const s=await e;return this.#n(t,s)}async getFromId(t){this.#s||=new Map;const e=this.#s.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:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),s={bitmap:n.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class Vo{#t=[];#e=!1;#s;#n=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:n,type:i=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(n&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:i};if(this.#n===-1){this.#t.length>0&&(this.#t.length=0),this.#n=0,this.#t.push(o);return}if(r&&this.#t[this.#n].type===i){a&&(o.undo=this.#t[this.#n].undo),this.#t[this.#n]=o;return}const l=this.#n+1;l===this.#s?this.#t.splice(0,1):(this.#n=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(this.#n===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1,this.#n-=1}redo(){if(this.#n<this.#t.length-1){this.#n+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#n];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#n!==-1}hasSomethingToRedo(){return this.#n<this.#t.length-1}cleanType(t){if(this.#n!==-1){for(let e=this.#n;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#n-e),this.#n=e;return}this.#t.length=0,this.#n=-1}}destroy(){this.#t=null}}class ne{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;const{isMac:e}=mt.platform;for(const[s,n,i={}]of t){const r=s.some(a=>a.startsWith("mac+"));for(const a of s){let o=a;if(r){const d=a.startsWith("mac+");if(e!==d)continue;d&&(o=a.slice(4))}const[l,c]=ne.#t(o);l!==null&&this.callbacks.getOrInsertComputed(l,Cs).push({callback:n,options:i,modifiers:c})}}}static#t(t){let e=null,s=0;for(let n of t.split("+")){if(n=n.trim(),!n)continue;const i=n.toUpperCase(),r=ne[i];if(r){s|=r;continue}if(e!==null){Q(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=i==="SPACE"?" ":n}return e===null&&Q(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]}static#e(t){const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?e[1]?.toLowerCase()??e[2]:null}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const c=ne.#e(e.code);
vendor: 4,299 bytes, line 4
4if(c===null||c===e.key||(s=this.callbacks.get(c),!s))return}const n=(e.altKey?ne.ALT:0)|(e.ctrlKey?ne.CTRL:0)|(e.metaKey?ne.META:0)|(e.shiftKey?ne.SHIFT:0),i=s.find(c=>c.modifiers===n);if(!i)return;const{callback:r,options:{bubbles:a=!1,args:o=[],checker:l=null}}=i;l&&!l(t,e)||(r.bind(t,...o,e)(),a||Lt(e))}}class Mi{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Bo(t),Y(this,"_colors",t)}convert(t){const e=Qs(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,n]of this._colors)if(n.every((i,r)=>i===e[r]))return Mi._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?L.makeHexColor(...e):t}}class He{#t=new AbortController;#e=null;#s=null;#n=new Map;#i=new Map;#a=null;#r=null;#o=null;#l=null;#c=null;#u=new Vo;#d=null;#f=null;#g=null;#m=0;#h=new Set;#p=null;#v=null;#y=new Set;_editorUndoBar=null;#b=!1;#x=!1;#S=!1;#w=null;#E=null;#T=null;#M=null;#I=!1;#P=null;#N=new Go;#R=!1;#k=!1;#U=!1;#D=null;#L=null;#G=null;#B=null;#$=null;#C=q.NONE;#A=new Set;#j=null;#H=null;#V=null;#Q=null;#Y=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#F=[0,0];#W=null;#X=null;#tt=null;#et=null;#_=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=He.prototype,e=r=>r.#X.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},n=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return Y(this,"_keyboardManager",new ne([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(a)&&!r.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}]]))}constructor(t,e,s,n,i,r,a,o,l,c,d,u,f,p,g,m){const v=this._signal=this.#t.signal;this.#X=t,this.#tt=e,this.#et=s,this.#o=n,this.#d=i,this.#H=r,this.#Y=o,this._eventBus=a;const y={signal:v,...ii};a.on("editingaction",this.onEditingAction.bind(this),y),a.on("pagechanging",this.onPageChanging.bind(this),y),a.on("scalechanging",this.onScaleChanging.bind(this),y),a.on("rotationchanging",this.onRotationChanging.bind(this),y),a.on("setpreference",this.onSetPreference.bind(this),y),a.on("switchannotationeditorparams",b=>this.updateParams(b.type,b.value),y),window.addEventListener("pointerdown",()=>{this.#k=!0},{capture:!0,signal:v}),window.addEventListener("pointerup",()=>{this.#k=!1},{capture:!0,signal:v}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:v}),this.#lt(),this.#pt(),this.#nt(),this.#l=o.annotationStorage,this.#w=o.filterFactory,this.#V=l,this.#M=c||null,this.#b=d,this.#x=u,this.#S=f,this.#$=p||null,this.viewParameters={realScale:Ts.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=m!==!1,i?.setSidebarUiManager(this)}destroy(){this.#_?.resolve(),this.#_=null,this.#t?.abort(),this.#t=null,this._signal=null;
4for(const t of this.#i.values())t.destroy();this.#i.clear(),this.#n.clear(),this.#y.clear(),this.#B?.clear(),this.#e=null,this.#A.clear(),this.#u.destroy(),this.#o?.destroy(),this.#d?.destroy(),this.#H?.destroy(),this.#P?.hide(),this.#P=null,this.#G?.destroy(),this.#G=null,this.#s=null,this.#E&&(clearTimeout(this.#E),this.#E=null),this.#W&&(clearTimeout(this.#W),this.#W=null),this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#$}get useNewAltTextFlow(){return this.#x}get useNewAltTextWhenAddingImage(){return this.#S}get hcmFilter(){return Y(this,"hcmFilter",this.#V?this.#w.addHCMFilter(this.#V.foreground,this.#V.background):"none")}get direction(){return Y(this,"direction",getComputedStyle(this.#X).direction)}get _highlightColors(){return Y(this,"_highlightColors",this.#M?new Map(this.#M.split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return Y(this,"highlightColors",null);const e=new Map,s=!!this.#V;for(const[n,i]of t){const r=n.endsWith("_HCM");if(s&&r){e.set(n.replace("_HCM",""),i);continue}!s&&!r&&e.set(n,i)}return Y(this,"highlightColors",e)}get highlightColorNames(){return Y(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.#g=t}setMainHighlightColorPicker(t){this.#G=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#d}editComment(t,e,s,n){this.#d?.showDialog(this,t,e,s,n)}selectComment(t,e){this.#i.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#d?.updateComment(t.getData())}updatePopupColor(t){this.#d?.updatePopupColor(t)}removeComment(t){this.#d?.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},n=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:n,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#d?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#d?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(t){if(this.#i.has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),n=i=>{i.pageNumber===t&&(this._eventBus.off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n,ii),await s}getSignature(t){this.#H?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#H}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...ii}),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}){t==="enableNewAltTextWhenAddingImage"&&(this.#S=e)}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#i.delete(t),this.#m===t&&(this.#m=0)}focusMainContainer(){this.#X.focus()}findParent(t,e){for(const s of this.#i.values()){const{x:n,y:i,width:r,height:a}=s.div.getBoundingClientRect();if(t>=n&&t<=n+r&&e>=i&&e<=i+a)return s}return null}disableUserSelect(t=!1){this.#tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Ts.PDF_TO_CSS_UNITS;for(const e of this.#y)e.onScaleChanging();this.#g?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#q({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#st(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of this.#i.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:a}=s,o=s.toString(),c=this.#q(s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const u=this.#st(c),f=this.#C===q.NONE,p=()=>{const g=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:a,text:o});f&&this.showAllEditors("highlight",!0,!0),e&&g?.editComment()};if(f){this.switchToMode(q.HIGHLIGHT,p);return}p()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#at(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#q(t).closest(".textLayer"),n=this.getSelectionBoxes(s);n&&(this.#P||=new Ho(this),this.#P.show(s,n,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;const e=`${Es}${t}`,s=this.#l.getRawValue(e);return s&&this.#l.remove(e),s}
4addToAnnotationStorage(t){!t.isEmpty()&&this.#l&&!this.#l.has(t.id)&&this.#l.setValue(t.id,t)}a11yAlert(t,e=null){const s=this.#et;s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}#ot(){const t=document.getSelection();if(!t||t.isCollapsed){this.#j&&(this.#P?.hide(),this.#j=null,this.#O({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#j)return;const n=this.#q(t).closest(".textLayer");if(!n){this.#j&&(this.#P?.hide(),this.#j=null,this.#O({hasSelectedText:!1}));return}if(this.#P?.hide(),this.#j=e,this.#O({hasSelectedText:!0}),!(this.#C!==q.HIGHLIGHT&&this.#C!==q.NONE)&&(this.#C===q.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#I=this.isShiftKeyDown,!this.isShiftKeyDown)){const i=this.#C===q.HIGHLIGHT?this.#st(n):null;if(i?.toggleDrawing(),this.#k){const r=new AbortController,a=this.combinedSignal(r),o=l=>{l.type==="pointerup"&&l.button!==0||(r.abort(),i?.toggleDrawing(!0),l.type==="pointerup"&&this.#J("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else i?.toggleDrawing(!0),this.#J("main_toolbar")}}#J(t=""){this.#C===q.HIGHLIGHT?this.highlightSelection(t):this.#b&&this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ct(){if(this.#T)return;this.#T=new AbortController;const t=this.combinedSignal(this.#T);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ht(){this.#T?.abort(),this.#T=null}blur(){if(this.isShiftKeyDown=!1,this.#I&&(this.#I=!1,this.#J("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#A)if(e.div.contains(t)){this.#L=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#L)return;const[t,e]=this.#L;this.#L=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#nt(){if(this.#D)return;this.#D=new AbortController;const t=this.combinedSignal(this.#D);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#D?.abort(),this.#D=null}#ut(){if(this.#f)return;this.#f=new AbortController;const t=this.combinedSignal(this.#f);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})}#ft(){this.#f?.abort(),this.#f=null}#pt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#nt(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#v)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#v)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#A){const n=s.serialize(!0);n&&e.push(n)}e.length!==0&&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 i of e.items)for(const r of this.#v)if(r.isHandlingMimeForPasting(i.type)){r.paste(i,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(i){Q(`paste: "${i.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const n=this.currentLayer;try{const i=[];for(const o of s){const l=await n.deserialize(o);if(!l)return;i.push(l)}const r=()=>{for(const o of i)this.#it(o);this.#rt(i)},a=()=>{for(const o of i)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(i){Q(`paste: "${i.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==q.NONE&&!this.isEditorHandlingKeyboard&&He._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#I&&(this.#I=!1,this.#J("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");break}}updatePageIndex(t,e){for(const n of this.#r.get(t)||[])n.pageIndex=e;const s=this.#a.get(t);s&&(s.pageIndex=e,this.#i.set(e,s),this.#R?s.enable():s.disable())}startUpdatePages(){this.#a=new Map(this.#i),this.#i.clear();const t=this.#r=new Map,e=s=>{t.getOrInsertComputed(s.pageIndex,Cs).push(s)};for(const s of this.#n.values())e(s);for(const[s,n]of this.#l)s.startsWith(Es)&&!this.#n.has(s)&&Number.isInteger(n?.pageIndex)&&e(n)}endUpdatePages(){this.#a=null,this.#r=null}clonePage(t,e){for(const s of this.getEditors(t)){const n=s.serialize(s.mode!==q.HIGHLIGHT);n&&(n.pageIndex=e,n.id=this.getId(),n.isClone=!0,delete n.popupRef,this.#l.setValue(n.id,n))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;
4for(const[n,i]of this.#l)i.pageIndex===s&&i.isClone&&(this.#l.remove(n),e.push(t.deserialize(i).then(r=>{r&&(r.isClone=!0,t.addOrRebuild(r))})));return Promise.all(e)}#O(t){Object.entries(t).some(([s,n])=>this.#K[s]!==n)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#C===q.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#z([[lt.HIGHLIGHT_FREE,!0]]))}#z(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#ct(),this.#ut(),this.#O({isEditing:this.#C!==q.NONE,isEmpty:this.#Z(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ht(),this.#ft(),this.#O({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#v){this.#v=t;for(const e of this.#v)this.#z(e.defaultPropertiesToUpdate)}}getId(){return this.#N.id}get currentLayer(){return this.#i.get(this.#m)}getLayer(t){return this.#i.get(t)}get currentPageIndex(){return this.#m}addLayer(t){this.#i.set(t.pageIndex,t),this.#R?t.enable():t.disable()}removeLayer(t){this.#i.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,n=!1,i=!1,r=!1){if(this.#C!==t&&!(this.#_&&(await this.#_.promise,!this.#_))){if(this.#_=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===q.POPUP&&this.#d?.hideSidebar(),this.#d?.destroyPopup(),this.#C=t,t===q.NONE){this.setEditingState(!1),this.#mt();for(const a of this.#n.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#_.resolve();return}for(const a of this.#n.values())a.addStandaloneCommentButton();t===q.SIGNATURE&&await this.#H?.loadSignatures(),s&&pt.clearPointerType(),this.setEditingState(!0),await this.#gt(),this.unselectAll();for(const a of this.#i.values())a.updateMode(t);if(t===q.POPUP){this.#s||=await this.#Y.getAnnotationsByType(new Set(this.#v.map(l=>l._editorType)));const a=new Set,o=[];for(const l of this.#n.values()){const{annotationElementId:c,hasComment:d,deleted:u}=l;c&&a.add(c),d&&!u&&o.push(l.getData())}for(const l of this.#s){const{id:c,popupRef:d,contentsObj:u}=l;d&&u?.str&&!a.has(c)&&!this.#h.has(c)&&o.push(l)}this.#d?.showSidebar(o)}if(!e){n&&this.addNewEditorFromKeyboard(),this.#_.resolve();return}for(const a of this.#n.values())a.uid===e?(this.setSelected(a),r?a.editComment():i?a.enterInEditMode():a.focus()):a.unselect();this.#_.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#v){switch(t){case lt.CREATE:this.currentLayer.addNewEditor(e);return;case lt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#Q||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of this.#A)s.updateParams(t,e);else for(const s of this.#v)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const i of this.#n.values())i.editorType===t&&i.show(e);(this.#Q?.get(lt.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#z([[lt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#U!==t){this.#U=t;for(const e of this.#i.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#R){this.#R=!0;const t=[];for(const e of this.#i.values())t.push(e.enable());await Promise.all(t);for(const e of this.#n.values())e.enable()}}#mt(){if(this.unselectAll(),this.#R){this.#R=!1;for(const t of this.#i.values())t.disable();for(const t of this.#n.values())t.disable()}}*getEditors(t){for(const e of this.#n.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#E&&clearTimeout(this.#E),this.#E=setTimeout(()=>{this.focusMainContainer(),this.#E=null},0)),this.#n.delete(t.id),t.annotationElementId&&this.#B?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#h.has(t.annotationElementId))&&this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#h.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}
4isDeletedAnnotationElement(t){return this.#h.has(t)}removeDeletedAnnotationElement(t){this.#h.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#it(t){const e=this.#i.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#z(t.propertiesToUpdate))}get#vt(){let t=null;for(t of this.#A);return t}updateUI(t){this.#vt===t&&this.#z(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#z(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#A.has(t)){this.#A.delete(t),t.unselect(),this.#O({hasSelectedEditor:this.hasSelection});return}this.#A.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#O({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#g?.commitOrRemove();for(const e of this.#A)e!==t&&e.unselect();this.#d?.destroyPopup(),this.#A.clear(),this.#A.add(t),t.select(),this.#z(t.propertiesToUpdate),this.#O({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#A.values().next().value}unselect(t){t.unselect(),this.#A.delete(t),this.#O({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#A.size!==0}get isEnterHandled(){return this.#A.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#O({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Z()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#O({hasSomethingToUndo:!0,hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#Z()})}addCommands(t){this.#u.add(t),this.#O({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Z()})}cleanUndoStack(t){this.#u.cleanType(t)}#Z(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(const t of this.#n.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.#A],s=()=>{this._editorUndoBar?.show(n,e.length===1?e[0].editorType:e.length);for(const i of e)i.remove()},n=()=>{for(const i of e)this.#it(i)};this.addCommands({cmd:s,undo:n,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#rt(t){for(const e of this.#A)e.unselect();this.#A.clear();for(const e of t)e.isEmpty()||(this.#A.add(e),e.select());this.#O({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#A)t.commit();this.#rt(this.#n.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==q.NONE))&&!this.#g?.commitOrRemove()&&(this.#d?.destroyPopup(),!!this.hasSelection)){for(const t of this.#A)t.unselect();this.#A.clear(),this.#O({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#F[0]+=t,this.#F[1]+=e;const[n,i]=this.#F,r=[...this.#A],a=1e3;this.#W&&clearTimeout(this.#W),this.#W=setTimeout(()=>{this.#W=null,this.#F[0]=this.#F[1]=0,this.addCommands({cmd:()=>{for(const o of r)this.#n.has(o.id)&&(o.translateInPage(n,i),o.translationDone())},undo:()=>{for(const o of r)this.#n.has(o.id)&&(o.translateInPage(-n,-i),o.translationDone())},mustExec:!1})},a);for(const o of r)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#p=new Map;for(const t of this.#A)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);const t=this.#p;this.#p=null;let e=!1;for(const[{x:n,y:i,pageIndex:r},a]of t)a.newX=n,a.newY=i,a.newPageIndex=r,e||=n!==a.savedX||i!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;const s=(n,i,r,a)=>{if(this.#n.has(n.id)){const o=this.#i.get(a);o?n._setParentAndPosition(o,i,r):(n.pageIndex=a,n.x=i,n.y=r)}};return this.addCommands({cmd:()=>{for(const[n,{newX:i,newY:r,newPageIndex:a}]of t)s(n,i,r,a)},undo:()=>{for(const[n,{savedX:i,savedY:r,savedPageIndex:a}]of t)s(n,i,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#p)for(const s of this.#p.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){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()||this.#A.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}isEditingMode(){return this.#C!==q.NONE}get imageManager(){return Y(this,"imageManager",new Oi)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,c=e.rangeCount;l<c;
4l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:s,y:n,width:i,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,c,d,u)=>({x:(c-n)/r,y:1-(l+d-s)/i,width:u/r,height:d/i});break;case"180":a=(l,c,d,u)=>({x:1-(l+d-s)/i,y:1-(c+u-n)/r,width:d/i,height:u/r});break;case"270":a=(l,c,d,u)=>({x:1-(c+u-n)/r,y:(l-s)/i,width:u/r,height:d/i});break;default:a=(l,c,d,u)=>({x:(l-s)/i,y:(c-n)/r,width:d/i,height:u/r});break}const o=[];for(let l=0,c=e.rangeCount;l<c;l++){const d=e.getRangeAt(l);if(!d.collapsed)for(const{x:u,y:f,width:p,height:g}of d.getClientRects())p===0||g===0||o.push(a(u,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#c||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#c?.delete(t)}renderAnnotationElement(t){const e=this.#c?.get(t.data.id);if(!e)return;const s=this.#l.getRawValue(e);s&&(this.#C===q.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){const n=this.#B?.get(t);n&&(n.setCanvas(e,s),this.#B.delete(t))}addMissingCanvas(t,e){(this.#B||=new Map).set(t,e)}}class Ce{#t=null;#e=!1;#s=null;#n=null;#i=null;#a=null;#r=!1;#o=null;#l=null;#c=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#d=t._uiManager.useNewAltTextFlow,Ce.#f||=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){Ce._l10n??=t}async render(){const t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#n=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",Ce.#f.missing),e.setAttribute("data-l10n-id",Ce.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=this.#l._uiManager._signal;t.addEventListener("contextmenu",pe,{signal:s}),t.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:s});const n=i=>{i.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#d&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",i=>{i.target===t&&i.key==="Enter"&&(this.#r=!0,n(i))},{signal:s}),await this.#m(),t}get#g(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#s&&(this.#s.focus({focusVisible:this.#r}),this.#r=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){this.#t===null&&(this.#c=t,this.#u=await Ce._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){const e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#c===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:n,cancel:i=!1}){s&&(this.#c=s,this.#u=n),!(this.#t===t&&this.#e===e)&&(i||(this.#t=t,this.#e=e),this.#m())}toggle(t=!1){this.#s&&(!t&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#s.disabled=!t)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#s?.remove(),this.#s=null,this.#n=null,this.#i=null,this.#o?.remove(),this.#o=null}async#m(){const t=this.#s;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Ce.#f[this.#g]),this.#n?.setAttribute("data-l10n-id",Ce.#f[`${this.#g}-label`]),!this.#t){this.#i?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#i?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#i;if(!e){this.#i=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;const n=100,i=this.#l._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},n)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#a&&(clearTimeout(this.#a),this.#a=null),this.#i?.classList.remove("show")},{signal:i})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class hn{#t=null;#e=null;#s=!1;#n=null;#i=null;#a=null;#r=null;#o=null;#l=!1;#c=null;constructor(t){this.#n=t}renderForToolbar(){const t=this.#e=document.createElement("button");
4return t.className="comment",this.#u(t,!1)}renderForStandalone(){const t=this.#t=document.createElement("button");t.className="annotationCommentButton";const e=this.#n.commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#n._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=this.#n.commentButtonColor;n&&(s.backgroundColor=n)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;const t=this.#n.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#n._uiManager.updatePopupColor(this.#n)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#n.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#c)return this.#c;if(!this.#t)return null;const{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:n,y:i,width:r,height:a}=this.#n.parent.boundingClientRect;return[(t-n)/r,(e+s-i)/a]}set commentPopupPositionInLayer(t){this.#c=t}hasDefaultPopupPosition(){return this.#c===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#n._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.#n._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=this.#n._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",pe,{signal:s}),e&&(t.addEventListener("focusin",i=>{this.#n._focusEventsAllowed=!1,Lt(i)},{capture:!0,signal:s}),t.addEventListener("focusout",i=>{this.#n._focusEventsAllowed=!0,Lt(i)},{capture:!0,signal:s})),t.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:s});const n=i=>{i.preventDefault(),t===this.#e?this.edit():this.#n.toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:s}),t.addEventListener("keydown",i=>{i.target===t&&i.key==="Enter"&&(this.#s=!0,n(i))},{signal:s}),t.addEventListener("pointerenter",()=>{this.#n.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#n.toggleComment(!1,!1)},{signal:s}),t}edit(t){const e=this.commentPopupPositionInLayer;let s,n;if(e)[s,n]=e;else{[s,n]=this.#n.commentButtonPosition;const{width:c,height:d,x:u,y:f}=this.#n;s=u+s*c,n=f+n*d}const i=this.#n.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=i;this.#n._uiManager.editComment(this.#n,r+s*o,a+n*l,{...t,parentDimensions:i})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#s}),this.#s=!1)}isDeleted(){return this.#l||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#i}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#r&&(this.#a=null),t===null){this.#r="",this.#l=!0;return}this.#r=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:s}){this.#r=t,this.#a=e,this.#o=s,this.#l=!1}setInitialText(t,e=null){this.#i=t,this.data=t,this.#o=null,this.#a=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#r="",this.#a=null,this.#o=null,this.#n=null,this.#s=!1,this.#l=!1}}function Tr(h){h.preventDefault()}const Cr=1e-4;function ri(h){return h.cancelable?(Lt(h),!0):(h.stopPropagation(),!1)}class ha{#t;#e=!1;#s=null;#n;#i;#a;#r;#o;#l=!1;#c=null;#u;#d=new Set;#f=null;#g;#m=null;#h=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:n=null,onPinching:i=null,onPinchEnd:r=null,onPanning:a=null,signal:o}){this.#t=t,this.#s=s,this.#n=e,this.#i=n,this.#a=i,this.#r=r,this.#o=a,this.#g=new AbortController,this.#u=AbortSignal.any([o,this.#g.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/ge.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/ge.pixelRatio}#p(t){if(this.#n?.())return;this.#y(t);const e=this.#d;for(const{identifier:s}of t.changedTouches)e.add(s);if(e.size===1){this.#v();return}if(!this.#m){this.#m=new AbortController;const s=AbortSignal.any([this.#u,this.#m.signal]),n=this.#t,i={signal:s,capture:!1,passive:!1};n.addEventListener("touchmove",this.#S.bind(this),i);const r=this.#w.bind(this);n.addEventListener("touchend",r,i),n.addEventListener("touchcancel",r,i),i.capture=!0,n.addEventListener("pointerdown",Lt,i),n.addEventListener("pointermove",Lt,i),n.addEventListener("pointercancel",Tr,i),n.addEventListener("pointerup",Tr,i),this.#i?.()}this.#l=ri(t),this.#x(t)}#v(){if(this.#c)return;const t=this.#c=new AbortController,e=AbortSignal.any([this.#u,t.signal]),s=this.#t,n={capture:!0,signal:e,passive:!1},i=r=>{r.pointerType==="touch"&&(this.#c?.abort(),this.#c=null)};s.addEventListener("pointerdown",r=>{r.pointerType==="touch"&&(Lt(r),i(r))},n),s.addEventListener("pointerup",i,n),s.addEventListener("pointercancel",i,n)}#y(t){const e=this.#d;if(e.size===0)return;const s=this.#d=new Set;for(const{identifier:n}of t.touches)e.has(n)&&s.add(n)}#b(t){const e=this.#d,s=[];for(const n of t.touches)e.has(n.identifier)&&s.push(n);return s}#x(t){const e=this.#b(t);if(e.length!==2||this.#s?.()){this.#f=null;return}const[s,n]=e;this.#f={touch0X:s.screenX,touch0Y:s.screenY,touch1X:n.screenX,touch1Y:n.screenY,panX:(s.clientX+n.clientX)/2,panY:(s.clientY+n.clientY)/2,screenPanX:(s.screenX+n.screenX)/2,screenPanY:(s.screenY+n.screenY)/2}}#S(t){if(!this.#f)return;const e=this.#b(t);if(e.length!==2)return;const s=this.#l;if(this.#l=ri(t),!this.#l)return;if(!s){this.#x(t);return}const[n,i]=e,{screenX:r,screenY:a}=n,{screenX:o,screenY:l}=i,c=this.#f,{touch0X:d,touch0Y:u,touch1X:f,touch1Y:p,panX:g,panY:m}=c,v=f-d,y=p-u,b=o-r,S=l-a,x=(n.clientX+i.clientX)/2,w=(n.clientY+i.clientY)/2;c.panX=x,c.panY=w;const E=x-g,C=w-m,T=(r+o)/2,O=(a+l)/2,I=Math.hypot(T-c.screenPanX,O-c.screenPanY);c.screenPanX=T,c.screenPanY=O;const M=Math.hypot(b,S),N=Math.hypot(v,y),D=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*I;
vendor: 4,740 bytes, line 4
4if(M<Cr||N<Cr||Math.abs(N-M)<=D){(E||C)&&this.#o?.(E,C);return}c.touch0X=r,c.touch0Y=a,c.touch1X=o,c.touch1Y=l;const $=Math.sign(M-N);if(!this.#e){this.#e=!0,this.#h=$,(E||C)&&this.#o?.(E,C);return}if(this.#h){const k=this.#h;if(this.#h=0,$!==k&&Math.abs(M-N)<=2*I){this.#e=!1,(E||C)&&this.#o?.(E,C);return}}this.#a?.([g,m],N,M,E,C)}#w(t){if(this.#y(t),this.#d.size>=2){this.#x(t);return}const e=!!this.#f;this.#E(),this.#d.size===1&&this.#v(),e&&ri(t)}#E(){this.#f=null,this.#e=!1,this.#h=0,this.#l=!1,this.#m&&(this.#m.abort(),this.#m=null,this.#r?.())}destroy(){this.#E(),this.#d.clear(),this.#g?.abort(),this.#g=null,this.#c?.abort(),this.#c=null}}class V{#t=null;#e=null;#s=null;#n=null;#i=null;#a=!1;#r=null;#o="";#l=null;#c=null;#u=null;#d=null;#f=null;#g="";#m=!1;#h=null;#p=!1;#v=!1;#y=!1;#b=null;#x=0;#S=0;#w=null;#E=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#T=!1;#M=V._zIndex++;static _borderLineWidth=-1;static _colorManager=new Mi;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=V.prototype._resizeWithKeyboard,e=He.TRANSLATE_SMALL,s=He.TRANSLATE_BIG;return Y(this,"_resizerKeyboardManager",new ne([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],V.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:s,pageHeight:n,pageX:i,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,n],this.pageTranslation=[i,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 Y(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Wo({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(V._l10n??=t,V._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),V._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"}),V._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);V._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ht("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#T}set _isDraggable(t){this.#T=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/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
vendor: 6,471 bytes, line 4
4setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#M}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#F(),this.#d?.remove(),this.#d=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||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,s,n){const[i,r]=this.parentDimensions;[s,n]=this.screenToPageTranslation(s,n),this.x=(t+s)/i,this.y=(e+n)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,n]=this.parentDimensions;this.setAt(t*s,e*n,this.width*s,this.height*n),this._onTranslated()}#I([t,e],s,n){[s,n]=this.screenToPageTranslation(s,n),this.x+=s/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#I(this.parentDimensions,t,e)}translateInPage(t,e){this.#h||=[this.x,this.y,this.width,this.height],this.#I(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#h||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[n,i]}=this;if(this.x+=t/n,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(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:c}=s;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#h&&(this.#h[0]!==this.x||this.#h[1]!==this.y)}get _hasBeenResized(){return!!this.#h&&(this.#h[2]!==this.width||this.#h[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=V,n=s/t,i=s/e;switch(this.rotation){case 90:return[-n,i];case 180:return[n,i];case 270:return[n,-i];default:return[-n,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,n]}=this;let{x:i,y:r,width:a,height:o}=this;if(a*=s,o*=n,i*=s,r*=n,this._mustFixPosition)switch(t){case 0:i=xt(i,0,s-a),r=xt(r,0,n-o);break;case 90:i=xt(i,0,s-o),r=xt(r,a,n);break;case 180:i=xt(i,a,s),r=xt(r,o,n);break;case 270:i=xt(i,o,s),r=xt(r,0,n-a);break}this.x=i/=s,this.y=r/=n;const[l,c]=this.getBaseTranslation();i+=l,r+=c,e.left=`${(100*i).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#P(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return V.#P(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return V.#P(t,e,360-this.parentRotation)}#N(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,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,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#R(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.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 s of t){const n=document.createElement("div");this.#l.append(n),n.classList.add("resizer",s),n.setAttribute("data-resizer-name",s),n.addEventListener("pointerdown",this.#k.bind(this,s),{signal:e}),n.addEventListener("contextmenu",pe,{signal:e}),n.tabIndex=-1}this.div.prepend(this.#l)}#k(t,e){e.preventDefault();const{isMac:s}=mt.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,this.#c=[e.screenX,e.screenY];const i=new AbortController,r=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#L.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Lt,{passive:!1,signal:r}),window.addEventListener("contextmenu",pe,{signal:r}),this.#u={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=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#D()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#U(t,e,s,n){this.width=s,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#D(){if(!this.#u)return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:n}=this.#u;this.#u=null;const i=this.x,r=this.y,a=this.width,o=this.height;i===t&&r===e&&a===s&&o===n||this.addCommands({cmd:this.#U.bind(this,i,r,a,o),undo:this.#U.bind(this,t,e,s,n),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#L(t,e){const[s,n]=this.parentDimensions,i=this.x,r=this.y,a=this.width,o=this.height,l=V.MIN_SIZE/s,c=V.MIN_SIZE/n,d=this.#N(this.rotation),u=(k,F)=>[d[0]*k+d[2]*F,d[1]*k+d[3]*F],f=this.#N(360-this.rotation),p=(k,F)=>[f[0]*k+f[2]*F,f[1]*k+f[3]*F];let g,m,v=!1,y=!1;switch(t){case"topLeft":v=!0,g=(k,F)=>[0,0],m=(k,F)=>[k,F];break;case"topMiddle":g=(k,F)=>[k/2,0],m=(k,F)=>[k/2,F];break;case"topRight":v=!0,g=(k,F)=>[k,0],m=(k,F)=>[0,F];break;case"middleRight":y=!0,g=(k,F)=>[k,F/2],m=(k,F)=>[0,F/2];break;case"bottomRight":v=!0,g=(k,F)=>[k,F],m=(k,F)=>[0,0];break;case"bottomMiddle":g=(k,F)=>[k/2,F],m=(k,F)=>[k/2,0];break;case"bottomLeft":v=!0,g=(k,F)=>[0,F],m=(k,F)=>[k,0];break;case"middleLeft":y=!0,g=(k,F)=>[0,F/2],m=(k,F)=>[k,F/2];break}const b=g(a,o),S=m(a,o);let x=u(...S);
4const w=V._round(i+x[0]),E=V._round(r+x[1]);let C=1,T=1,O,I;if(e.fromKeyboard)({deltaX:O,deltaY:I}=e);else{const{screenX:k,screenY:F}=e,[W,G]=this.#c;[O,I]=this.screenToPageTranslation(k-W,F-G),this.#c[0]=k,this.#c[1]=F}if([O,I]=p(O/s,I/n),v){const k=Math.hypot(a,o);C=T=Math.max(Math.min(Math.hypot(S[0]-b[0]-O,S[1]-b[1]-I)/k,1/a,1/o),l/a,c/o)}else y?C=xt(Math.abs(S[0]-b[0]-O),l,1)/a:T=xt(Math.abs(S[1]-b[1]-I),c,1)/o;const M=V._round(a*C),N=V._round(o*T);x=u(...m(M,N));const D=w-x[0],$=E-x[1];this.#h||=[this.x,this.y,this.width,this.height],this.width=M,this.height=N,this.x=D,this.y=$,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#v)return this._editToolbar;this._editToolbar=new Us(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);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.#s?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#s||(Ce.initialize(V._l10n),this.#s=new Ce(this),this.#t&&(this.#s.data=this.#t,this.#t=null)),this.#s}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#n?.focusButton()}addCommentButton(){return this.canAddComment?this.#n||=new hn(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#i){this._uiManager.isEditingMode()&&this.#i.classList.remove("hidden");return}this.hasComment&&(this.#i=this.#n.renderForStandalone(),this.div.append(this.#i))}}removeStandaloneCommentButton(){this.#n.removeStandaloneCommentButton(),this.#i=null}hideStandaloneCommentButton(){this.#i?.classList.add("hidden")}get comment(){if(!this.#n)return null;const{data:{richText:t,text:e,date:s,deleted:n}}=this.#n;return{text:e,richText:t,date:s,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#n||=new hn(this),typeof t=="object"&&t!==null?this.#n.restoreData(t):this.#n.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:s}){if(!e||(this.#n||=new hn(this),this.#n.setInitialText(t,s),!this.annotationElementId))return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){return this.#n?.hasBeenEdited()}get hasDeletedComment(){return this.#n?.isDeleted()}get hasComment(){return!!this.#n&&!this.#n.isEmpty()&&!this.#n.isDeleted()}async editComment(t){this.#n||=new hn(this),this.#n.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#n.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,n]=t.rect,[i]=this.pageDimensions,[r]=this.pageTranslation,a=r+i+1,o=n-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#n.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.#a?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#j();const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[n,i]=this.getInitialTranslation();return this.translate(n,i),ca(this,t,["keydown","pointerdown","dblclick"]),this.#H(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#G(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#B(t,e,s){let i=.7*(s/e)+1-.7;
4if(i===1)return;const r=this.#N(this.rotation),a=(w,E)=>[r[0]*w+r[2]*E,r[1]*w+r[3]*E],[o,l]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=V.MIN_SIZE/o,g=V.MIN_SIZE/l;i=Math.max(Math.min(i,1/u,1/f),p/u,g/f);const m=V._round(u*i),v=V._round(f*i);if(m===u&&v===f)return;this.#h||=[c,d,u,f];const y=a(u/2,f/2),b=V._round(c+y[0]),S=V._round(d+y[1]),x=a(m/2,v/2);this.x=b-x[0],this.y=S-x[1],this.width=m,this.height=v,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#$(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#D()}pointerdown(t){const{isMac:e}=mt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#A(t);return}this.#C(t)}#C(t){const{isMac:e}=mt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#A(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const n=new AbortController,i=this._uiManager.combinedSignal(n),r={capture:!0,passive:!1,signal:i},a=l=>{n.abort(),this.#r=null,this.#m=!1,this._uiManager.endDragSession()||this.#C(l),s&&this._onStopDragging()};e&&(this.#x=t.clientX,this.#S=t.clientY,this.#r=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",l=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:u}=l;if(u!==this.#r){Lt(l);return}const[f,p]=this.screenToPageTranslation(c-this.#x,d-this.#S);this.#x=c,this.#S=d,this._uiManager.dragSelectedEditors(f,p),this.div.scrollIntoView({block:"nearest"})},r),window.addEventListener("touchmove",Lt,r),window.addEventListener("pointerdown",l=>{l.pointerType===this.#o&&(this.#E||l.isPrimary)&&a(l),Lt(l)},r));const o=l=>{if(!this.#r||this.#r===l.pointerId){a(l);return}Lt(l)};window.addEventListener("pointerup",o,{signal:i}),window.addEventListener("blur",o,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const n=this.parentScale,[i,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/n,c=e/n,d=this.x*i,u=this.y*r,f=this.width*i,p=this.height*r;switch(s){case 0:return[d+l+a,r-u-c-p+o,d+l+f+a,r-u-c+o];case 90:return[d+c+a,r-u+l+o,d+c+p+a,r-u+l+f+o];case 180:return[d-l-f+a,r-u+c+o,d-l+a,r-u+c+p+o];case 270:return[d-c-p+a,r-u-l-f+o,d-c+a,r-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,n,i,r]=t,a=i-s,o=r-n;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-n,o,a];case 180:return[i,e-n,a,o];case 270:return[i,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&V._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#n?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:n,deleted:i,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:s||c,popupRef:!i,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#v=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#v=!1,!0):!1}isInEditMode(){return this.#v}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:n}=this.getClientDimensions(),{innerHeight:i,innerWidth:r}=window;return e<r&&n>0&&t<i&&s>0}#j(){if(this.#f||!this.div)return;this.#f=new AbortController;const t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#H(){this.#E||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||(this.#E=new ha({container:this.div,isPinchingDisabled:()=>
vendor: 5,793 bytes, line 4
4!this.isSelected,onPinchStart:this.#G.bind(this),onPinching:this.#B.bind(this),onPinchEnd:this.#$.bind(this),signal:this._uiManager._signal}))}rebuild(){this.#j(),this.#H()}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,s){const n=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,n.#t=t.accessibilityData,n._isCopy=t.isCopy||!1;const[i,r]=n.pageDimensions,[a,o,l,c]=n.getRectInCurrentCoords(t.rect,r);return n.x=a/i,n.y=o/r,n.width=l/i,n.height=c/r,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.#E?.destroy(),this.#E=null,this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#F(),this.removeEditToolbar(),this.#w){for(const t of this.#w.values())clearTimeout(t);this.#w=null}this.parent=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#R(),this.#l.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,n,i,r]=this.getPDFRect();return[V._round(s+(i-s)*t),V._round(n+(r-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#n.commentPopupPositionInLayer}set commentPopupPosition(t){this.#n.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#n.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#n.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#n?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#l.children;if(!this.#e){this.#e=Array.from(e);const r=this.#V.bind(this),a=this.#Q.bind(this),o=this._uiManager._signal;for(const l of this.#e){const c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#Y.bind(this,c),{signal:o}),l.setAttribute("data-l10n-id",V._l10nResizer[c])}}const s=this.#e[0];let n=0;for(const r of e){if(r===s)break;n++}const i=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(i!==n){if(i<n)for(let a=0;a<n-i;a++)this.#l.append(this.#l.firstElementChild);else if(i>n)for(let a=0;a<i-n;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(const a of e){const l=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",V._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#V(t){V._resizerKeyboardManager.exec(this,t)}#Q(t){this.#y&&t.relatedTarget?.parentNode!==this.#l&&this.#F()}#Y(t){this.#g=this.#y?t:""}#K(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#y&&this.#L(this.#g,{deltaX:t,deltaY:e,fromKeyboard:!0})}#F(){this.#y=!1,this.#K(-1),this.#D()}_stopResizingWithKeyboard(){this.#F(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#s?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#s?.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){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=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.#w||=new Map;const{action:s}=t;let n=this.#w.get(s);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),this.#w.delete(s),this.#w.size===0&&(this.#w=null)},V._telemetryTimeout),this.#w.set(s,n);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
4show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#a=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#a=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class Wo extends V{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Pr=3285377520,oe=4294901760,Se=65535;class yi{constructor(t){this.h1=t?t&4294967295:Pr,this.h2=t?t&4294967295:Pr}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,m=t.length;g<m;g++){const v=t.charCodeAt(g);v<=255?e[s++]=v:(e[s++]=v>>>8,e[s++]=v&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const n=s>>
42,i=s-n*4,r=new Uint32Array(e.buffer,0,n);let a=0,o=0,l=this.h1,c=this.h2;const d=3432918353,u=461845907,f=d&Se,p=u&Se;for(let g=0;g<n;g++)g&1?(a=r[g],a=a*d&oe|a*f&Se,a=a<<15|a>>>17,a=a*u&oe|a*p&Se,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(o=r[g],o=o*d&oe|o*f&Se,o=o<<15|o>>>17,o=o*u&oe|o*p&Se,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,i){case 3:a^=e[n*4+2]<<16;case 2:a^=e[n*4+1]<<8;case 1:a^=e[n*4],a=a*d&oe|a*f&Se,a=a<<15|a>>>17,a=a*u&oe|a*p&Se,n&1?l^=a:c^=a}this.h1=l,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&oe|t*36045&Se,e=e*4283543511&oe|((e<<16|t>>>16)*2950163797&oe)>>>16,t^=e>>>1,t=t*444984403&oe|t*60499&Se,e=e*3301882366&oe|((e<<16|t>>>16)*3120437893&oe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const zs=Object.freeze({map:null,hash:"",transfer:void 0});class Ri{#t=!1;#e=null;#s=null;#n=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const s=this.#n.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#n.get(t)}remove(t){const e=this.#n.get(t);e!==void 0&&(e instanceof V&&this.#s.delete(e.annotationElementId),this.#n.delete(t),this.#n.size===0&&this.resetModified(),!this.#n.values().some(s=>s instanceof V)&&this.onAnnotationEditor?.(null))}setValue(t,e){const s=this.#n.get(t);let n=!1;if(s!==void 0)for(const[i,r]of Object.entries(e))s[i]!==r&&(n=!0,s[i]=r);else n=!0,this.#n.set(t,e);n&&this.#i(),e instanceof V&&((this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#n.has(t)}get size(){return this.#n.size}#i(){this.#t||(this.#t=!0,this.onSetModified?.())}resetModified(){this.#t&&(this.#t=!1,this.onResetModified?.())}get print(){return new da(this)}get serializable(){if(this.#n.size===0)return zs;const t=new Map,e=new yi,s=[],n=Object.create(null);let i=!1;for(const[r,a]of this.#n){const o=a instanceof V?a.serialize(!1,n):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(const r of t.values())r.bitmap&&s.push(r.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:zs}get editorStats(){let t=null;const e=new Map;let s=0,n=0;for(const i of this.#n.values()){if(!(i instanceof V)){i.popup&&(i.popup.deleted?n+=1:s+=1);continue}i.isCommentDeleted?n+=1:i.hasEditedComment&&(s+=1);const r=i.telemetryFinalData;if(!r)continue;const{type:a}=r;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(i).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[l,c]of Object.entries(r)){if(l==="type")continue;const d=o.getOrInsertComputed(l,Ti);d.set(c,(d.get(c)??0)+1)}}if((n>0||s>0)&&(t||=Object.create(null),t.comments={deleted:n,edited:s}),!t)return null;for(const[i,r]of e)t[i]=r.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){const s=this.#s?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;const t=[];if(this.#s)for(const s of this.#s.values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new yi;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#n.entries()}}class da extends Ri{#t=zs;constructor(t){super();const{serializable:e}=t;if(e===zs)return;const{map:s,hash:n,transfer:i}=e,r=structuredClone(s,i?{transfer:i}:null);this.#t={map:r,hash:n,transfer:[]}}get print(){ht("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return Y(this,"modifiedIds",{ids:new Set,hash:""})}}st(7588);const ps="__forcedDependency",{floor:Ir,ceil:Or}=Math;function Mr(h,t,e,s,n,i){h[t*4+0]=Math.min(h[t*4+0],e),h[t*4+1]=Math.min(h[t*4+1],s),h[t*4+2]=Math.max(h[t*4+2],n),h[t*4+3]=Math.max(h[t*4+3],i)}function Xo(h,t,e,s,n){let i;h?(h<0&&(i=n[0],n[0]=n[2],n[2]=i),n[0]*=h,n[2]*=h,t<0&&(i=n[1],n[1]=n[3],n[3]=i),n[1]*=t,n[3]*=t):n.fill(0),n[0]+=e,n[1]+=s,n[2]+=e,n[3]+=s}const bi=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Yo{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===bi}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}const Rr=(h,t)=>h?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));class Ko{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(De);_pendingBBoxIdx=-1;#n;#i;#a;#r;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#n=t.width,this.#i=t.height,this.#o(e)}growOperationsCount(t){t>=this.#r.length&&this.#o(t,this.#r)}#o(t,e){const s=new ArrayBuffer(t*4);this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),e&&e.length>0?(this.#r.set(e),this.#r.fill(bi,e.length)):this.#r.fill(bi)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;const n=this._savesStack.pop();return n!==void 0&&(e?.(n,t),this.#r[t]=this.#r[n]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e?.(s,t),this.#r[t]=this.#r[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e?.(s,t),this.#r[t]=this.#r[s]),this}pushBaseTransform(t){return this.#t.push(L.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){return this.#t.length>1&&this.#t.pop(),this}
vendor: 5,325 bytes, line 4
4resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#s.set(De,0)),this}recordClipBox(t,e,s,n,i,r){const a=L.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=De.slice();L.axialAlignedBoundingBox([s,i,n,r],a,o);const l=L.intersect(this.#e,o);return l?(this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3]):(this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0),this}recordBBox(t,e,s,n,i,r){const a=this.#e;if(a[0]===1/0)return this;const o=L.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return L.axialAlignedBoundingBox([s,i,n,r],o,this.#s),this;const l=De.slice();return L.axialAlignedBoundingBox([s,i,n,r],o,l),this.#s[0]=xt(l[0],a[0],this.#s[0]),this.#s[1]=xt(l[1],a[1],this.#s[1]),this.#s[2]=xt(l[2],this.#s[2],a[2]),this.#s[3]=xt(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#n,this.#e[2]),this.#s[3]=Math.min(this.#i,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const n=Ir(this.#s[0]*256/this.#n),i=Ir(this.#s[1]*256/this.#i),r=Or(this.#s[2]*256/this.#n),a=Or(this.#s[3]*256/this.#i);if(Mr(this.#a,t,n,i,r,a),s)for(const o of s)for(const l of o)l!==t&&Mr(this.#a,l,n,i,r,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3])),this}take(){return new Yo(this.#r,this.#a)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,n=1,i=0,r=0,a){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Qo{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[ps]:[]};#s=new Map;#n=new Set;#i=new Map;#a;#r;#o;constructor(t,e=!1){this.#o=t,e&&(this.#a=new Map,this.#r=(s,n)=>{Rr(this.#a,n).dependencies.add(s)})}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[ps]:{__proto__:this.#e[ps]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#r);const e=Object.getPrototypeOf(this.#t);return e===null?this:(this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this)}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#r),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#r),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ps,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#n)this.recordFutureForcedDependency(ps,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,n,i,r){return this.#o.recordClipBox(t,e,s,n,i,r),this}recordBBox(t,e,s,n,i,r){return this.#o.recordBBox(t,e,s,n,i,r),this}recordCharacterBBox(t,e,s,n=1,i=0,r=0,a){const o=s.bbox;let l,c;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#i.get(s),l!==!1&&(c=[0,0,0,0],L.axialAlignedBoundingBox(o,s.fontMatrix,c),(n!==1||i!==0||r!==0)&&Xo(n,-n,i,r,c),l)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!a)return this.recordFullPageBBox(t);const d=a();return o&&c&&l===void 0&&(l=c[0]<=i-d.actualBoundingBoxLeft&&c[2]>=i+d.actualBoundingBoxRight&&c[1]<=r-d.actualBoundingBoxAscent&&c[3]>=r+d.actualBoundingBoxDescent,this.#i.set(s,l),l)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,i-d.actualBoundingBoxLeft,i+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){const s=this.#n,n=this.#t,i=this.#e;for(const r of e)r in this.#t?s.add(n[r]):r in i&&i[r].forEach(s.add,s);return this}recordNamedDependency(t,e){return this.#s.has(e)&&this.#n.add(this.#s.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ps]),this.#a){const n=Rr(this.#a,t),{dependencies:i}=n;
4this.#n.forEach(i.add,i),this.#o._savesStack.forEach(i.add,i),this.#o._markedContentStack.forEach(i.add,i),i.delete(t),n.isRenderingOperation=!0}const s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.recordOperation(t,e,[this.#n,this.#o._savesStack,this.#o._markedContentStack]),s&&this.#n.clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(this.#n);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const n of s)this.recordIncrementalData("sameLineText",n);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(t),s&&this.#n.clear(),this}take(){return this.#i.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}}class Gs{#t;#e;#s;#n=0;#i=0;constructor(t,e,s){if(t instanceof Gs&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#i++,this.#t.save(this.#e),this}restore(t){return this.#i>0&&(this.#t.restore(this.#e),this.#i--),this}recordOpenMarker(t){return this.#n++,this}getOpenMarker(){return this.#n>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#n--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#s||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,s,n,i,r){return this.#s||this.#t.recordClipBox(this.#e,e,s,n,i,r),this}recordBBox(t,e,s,n,i,r){return this.#s||this.#t.recordBBox(this.#e,e,s,n,i,r),this}recordCharacterBBox(t,e,s,n,i,r,a){return this.#s||this.#t.recordCharacterBBox(this.#e,e,s,n,i,r,a),this}recordFullPageBBox(t){return this.#s||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#s||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const le={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class Tn{#t;#e;#s=4;#n=0;#i=new Tn.#a(this.#s*6);static#a=mt.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,n){if(this.#n===this.#s){this.#s*=2;const a=new Tn.#a(this.#s*6);a.set(this.#i),this.#i=a}const i=yt(t);let r;if(n[0]!==1/0){const a=De.slice();L.axialAlignedBoundingBox([0,-s,e,0],i,a);const o=L.intersect(n,a);if(!o)return;const[l,c,d,u]=o;if(l!==a[0]||c!==a[1]||d!==a[2]||u!==a[3]){const f=Math.atan2(i[1],i[0]),p=Math.abs(Math.sin(f)),g=Math.abs(Math.cos(f));if(p<1e-6||g<1e-6||Math.abs(p-g)<1e-6)r=[l,c,l,u,d,c];else{const m=d-l,v=u-c,y=p*p,b=g*g,S=g*p,x=b-y,w=(v*b-m*S)/x,E=(v*S-m*y)/x;r=[l+E,c,l,c+w,d,u-w]}}}r||(r=[0,-s,0,0,e,-s],L.applyTransform(r,i,0),L.applyTransform(r,i,2),L.applyTransform(r,i,4)),r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#i.set(r,this.#n*6),this.#n++}take(){return this.#i.subarray(0,this.#n*6)}}const Nr=new RegExp("\\p{Cc}","u");function Jo(h){const t=h[0];if(h.length<2||t!=='"'&&t!=="'"||h.at(-1)!==t)return!1;const e=h.length-1;for(let s=1;s<e;s++){const n=h[s];if(n===t||Nr.test(n)||n==="\\"&&(++s>=e||Nr.test(h[s])))return!1}return!0}function kr(h){return Jo(h)?h:`"${h.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}class Zo{#t=new Set;#e=null;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){const e=this.#s();e.insertRule(t,e.cssRules.length)}#s(){if(this.#e)return this.#e;
4const t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:e}=this._document;if(e){const s=new t;return e.push(s),this.#e=s}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),this.#e=this.styleElement.sheet}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),this.#t.clear(),this.#e){const{adoptedStyleSheets:t}=this._document;t?.includes(this.#e)&&(this._document.adoptedStyleSheets=t.filter(e=>e!==this.#e)),this.#e=null}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||this.#t.has(t.loadedName))){if(Ot(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:i,style:r}=t,a=new FontFace(n,i,r);this.addNativeFontFace(a);try{await a.load(),this.#t.add(n),s?.(t)}catch{Q(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}ht("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(n){throw Q(`Failed to load font '${s.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const n=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,n)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return Y(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return Y(this,"isSyncFontLoadingSupported",se||mt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(Ot(!n.done,"completeRequest() cannot be called twice."),n.done=!0;s.length>0&&s[0].done;){const i=s.shift();setTimeout(i.callback,0)}}const{loadingRequests:s}=this,n={done:!1,complete:e,callback:t};return s.push(n),n}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Y(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(x,w){return x.charCodeAt(w)<<24|x.charCodeAt(w+1)<<16|x.charCodeAt(w+2)<<8|x.charCodeAt(w+3)&255}function n(x){return String.fromCharCode(x>>24&255,x>>16&255,x>>
48&255,x&255)}function i(x,w,E,C){const T=x.substring(0,w),O=x.substring(w+E);return T+C+O}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let c=0;function d(x,w){if(++c>30){Q("Load test font never loaded."),w();return}if(l.font="30px "+x,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){w();return}setTimeout(d.bind(null,x,w))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const g=16,m=1482184792;let v=s(f,g);for(r=0,a=u.length-3;r<a;r+=4)v=v-m+s(u,r)|0;r<u.length&&(v=v-m+s(u+"XXX",r)|0),f=i(f,g,4,n(v));const y=`url(data:font/opentype;base64,${btoa(f)});`,b=`@font-face {font-family:"${u}";src:${y}}`;this.insertRule(b);const S=this._document.createElement("div");S.style.visibility="hidden",S.style.width=S.style.height="10px",S.style.position="absolute",S.style.top=S.style.left="0px";for(const x of[t.loadedName,u]){const w=this._document.createElement("span");w.textContent="Hi",w.style.fontFamily=x,S.append(w)}this._document.body.append(S),d(u,()=>{S.remove(),e.complete()})}}class qo{compiledGlyphs=Object.create(null);#t;constructor(t,e=null,s,n){this.#t=t,this._inspectFont=e,s&&(this.charProcOperatorList=s),n&&Object.assign(this,n)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(kr(this.cssFontInfo.fontFamily),this.data,e)}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)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:${kr(this.cssFontInfo.fontFamily)};${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let n;try{n=t.get(s)}catch(r){Q(`getPathGenerator - ignoring character: "${r}".`)}const i=la(n?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=i}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace}set disableFontFace(t){Y(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}}class tl{static strings=["fontFamily","fontWeight","italicAngle"]}class el{static strings=["css","loadedName","baseFontName","src"]}class de{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class Ye{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class Cn{static get decoder(){return Y(this,"decoder",new TextDecoder)}static get encoder(){return Y(this,"encoder",new TextEncoder)}}class sl{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){Ot(t<tl.strings.length,"Invalid string index");const{decoder:e}=Cn;let s=0;for(let i=0;i<t;i++)s+=this.#e.getUint32(s)+4;const n=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,n))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}class nl{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}get guessFallback(){return this.#e.getUint8(0)!==0}#s(t){Ot(t<el.strings.length,"Invalid string index");const{decoder:e}=Cn;let s=5;for(let i=0;i<t;i++)s+=this.#e.getUint32(s)+4;const n=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,n))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){const{decoder:t}=Cn;let e=1;e+=4+this.#e.getUint32(e);const s=this.#e.getUint32(e),n=t.decode(new Uint8Array(this.#t,e+4,s));e+=4+s;const i=this.#e.getUint32(e),r=t.decode(new Uint8Array(this.#t,e+4,i));return{style:n,weight:r}}}class il{#t;#e;constructor({buffer:t,extra:e}){this.#t=t,this.#e=new DataView(t),e&&Object.assign(this,e)}#s(t){Ot(t<de.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,n=this.#e.getUint8(e)>>s&3;return n===0?void 0:n===2}get black(){return this.#s(0)}get bold(){return this.#s(1)}get disableFontFace(){return this.#s(2)}get fontExtraProperties(){return this.#s(3)}get isInvalidPDFjsFont(){return this.#s(4)}get isType3Font(){return this.#s(5)}get italic(){return this.#s(6)}get missingFile(){return this.#s(7)}get remeasure(){return this.#s(8)}get vertical(){return this.#s(9)}#n(t){return Ot(t<de.numbers.length,"Invalid number index"),this.#e.getFloat64(de.OFFSET_NUMBERS+t*8)}get ascent(){return this.#n(0)}get defaultWidth(){return this.#n(1)}get descent(){return this.#n(2)}#i(t,e,s,n){const i=this.#e.getUint8(t);if(i===0)return;Ot(i===e,"Invalid array length."),t+=1;const r=new Array(i);for(let a=0;a<i;a++)r[a]=this.#e[s](t,!0),t+=n;return r}get bbox(){return this.#i(de.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#i(de.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#i(de.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#a(t){Ot(t<de.strings.length,"Invalid string index");const{decoder:e}=Cn;let s=de.OFFSET_STRINGS+4;for(let i=0;i<t;i++)s+=this.#e.getUint32(s)+4;const n=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,n))}get fallbackName(){return this.#a(0)}get loadedName(){return this.#a(1)}get mimetype(){return this.#a(2)}get name(){return this.#a(3)}#r(){let t=de.OFFSET_STRINGS;const e=this.#e.getUint32(t);t+=4+e;const s=this.#e.getUint32(t);t+=4+s;const n=this.#e.getUint32(t);t+=4+n;const i=this.#e.getUint32(t);return{offset:t,length:i}}get data(){const{offset:t,length:e}=this.#r();return e===0?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){const{offset:t,length:e}=this.#r();e!==0&&(this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t))}get cssFontInfo(){let t=de.OFFSET_STRINGS;const e=this.#e.getUint32(t);t+=4+e;const s=this.#e.getUint32(t);t+=4+s;const n=this.#e.getUint32(t);if(n===0)return null;const i=new Uint8Array(n);return i.set(new Uint8Array(this.#t,t+4,n)),new sl(i.buffer)}get systemFontInfo(){let t=de.OFFSET_STRINGS;const e=this.#e.getUint32(t);t+=4+e;const s=this.#e.getUint32(t);if(s===0)return null;const n=new Uint8Array(s);return n.set(new Uint8Array(this.#t,t+4,s)),new nl(n.buffer)}}class rl{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[Ye.KIND],s=!!this.data[Ye.HAS_BBOX],n=!!this.data[Ye.HAS_BACKGROUND],i=t.getUint32(Ye.N_COORD,!0),r=t.getUint32(Ye.N_COLOR,!0),a=t.getUint32(Ye.N_STOP,!0);let o=20;const l=new Float32Array(this.buffer,o,i*2);o+=i*8;const c=new Uint8Array(this.buffer,o,r*4);o+=r*4;const d=[];for(let p=0;p<a;++p){const g=t.getFloat32(o,!0);o+=4;const m=t.getUint32(o,!0);o+=4,d.push([g,`#${m.toString(16).padStart(6,"0")}`])}let u=null;if(s){u=[];for(let p=0;p<4;
4++p)u.push(t.getFloat32(o,!0)),o+=4}let f=null;if(n&&(f=new Uint8Array(this.buffer,o,3),o+=3),e===1)return["RadialAxial","axial",u,d,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",u,d,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){const p=this.data[Ye.SHADING_TYPE];let g=null;if(l.length>0){g=De.slice();for(let m=0,v=l.length;m<v;m+=2)L.pointBoundingBox(l[m],l[m+1],g)}return["Mesh",p,l,c,i,g,u,f]}throw new Error(`Unsupported pattern kind: ${e}`)}}class al{#t;constructor(t){this.#t=t}get path(){return mt.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}}function ol(h){if(h instanceof URL)return h;if(typeof h=="string"){if(se){if(/^[a-z][a-z0-9\-+.]+:/i.test(h))return new URL(h);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(h))}const t=URL.parse(h,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function ll(h){if(se&&typeof Buffer<"u"&&h instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength)return h;if(typeof h=="string")return Dn(h);if(h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof h=="object"&&!isNaN(h?.length))return new Uint8Array(h);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function dn(h){if(typeof h!="string")return null;if(h.endsWith("/"))return h;throw new Error(`Invalid factory url: "${h}" must include trailing slash.`)}const xi=h=>typeof h=="object"&&Number.isInteger(h?.num)&&h.num>=0&&Number.isInteger(h?.gen)&&h.gen>=0,cl=h=>typeof h=="object"&&typeof h?.name=="string",hl=Ro.bind(null,xi,cl);class dl{#t=new Map;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[n]of this.#t)n.call(this,s)})}addEventListener(t,e,s=null){let n=null;if(s?.signal instanceof AbortSignal){const{signal:i}=s;if(i.aborted){Q("LoopbackPort - cannot use an `aborted` signal.");return}const r=()=>this.removeEventListener(t,e);n=()=>i.removeEventListener("abort",r),i.addEventListener("abort",r)}this.#t.set(e,n)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}st(1689);const un={DATA:1,ERROR:2},Nt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Dr(){}function Qt(h){if(h instanceof $e||h instanceof ui||h instanceof di||h instanceof En||h instanceof si)return h;switch(h instanceof Error||typeof h=="object"&&h!==null||ht('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),h.name){case"AbortException":return new $e(h.message);case"InvalidPDFException":return new ui(h.message);case"PasswordException":return new di(h.message,h.code);case"ResponseException":return new En(h.message,h.status,h.missing);case"UnknownErrorException":return new si(h.message,h.details)}return new si(h.message,h.toString())}class Bs{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#n(t);return}if(t.callback){const s=t.callbackId,n=this.callbackCapabilities[s];if(!n)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===un.DATA)n.resolve(t.data);else if(t.callback===un.ERROR)n.reject(Qt(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,n=t.sourceName,i=this.comObj;Promise.try(e,t.data).then(function(r){i.postMessage({sourceName:s,targetName:n,callback:un.DATA,callbackId:t.callbackId,data:r})},function(r){i.postMessage({sourceName:s,targetName:n,callback:un.ERROR,callbackId:t.callbackId,reason:Qt(r)})});return}if(t.streamId){this.#s(t);return}e(t.data)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}
4sendWithPromise(t,e,s){const n=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[n]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},s)}catch(r){i.reject(r)}return i.promise}sendWithStream(t,e,s,n){const i=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:l=>{const c=Promise.withResolvers();return this.streamControllers[i]={controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:i,data:e,desiredSize:l.desiredSize},n),c.promise},pull:l=>{const c=Promise.withResolvers();return this.streamControllers[i].pullCall=c,o.postMessage({sourceName:r,targetName:a,stream:Nt.PULL,streamId:i,desiredSize:l.desiredSize}),c.promise},cancel:l=>{Ot(l instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[i].cancelCall=c,this.streamControllers[i].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Nt.CANCEL,streamId:i,reason:Qt(l)}),c.promise}},s)}#s(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,i=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(l,c=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:s,targetName:n,stream:Nt.ENQUEUE,streamId:e,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:s,targetName:n,stream:Nt.CLOSE,streamId:e}),delete r.streamSinks[e])},error(l){Ot(l instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:s,targetName:n,stream:Nt.ERROR,streamId:e,reason:Qt(l)}))},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(){i.postMessage({sourceName:s,targetName:n,stream:Nt.START_COMPLETE,streamId:e,success:!0})},function(l){i.postMessage({sourceName:s,targetName:n,stream:Nt.START_COMPLETE,streamId:e,reason:Qt(l)})})}#n(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,i=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Nt.START_COMPLETE:t.success?r.startCall.resolve():r.startCall.reject(Qt(t.reason));break;case Nt.PULL_COMPLETE:t.success?r.pullCall.resolve():r.pullCall.reject(Qt(t.reason));break;case Nt.PULL:if(!a){i.postMessage({sourceName:s,targetName:n,stream:Nt.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Dr).then(function(){i.postMessage({sourceName:s,targetName:n,stream:Nt.PULL_COMPLETE,streamId:e,success:!0})},function(l){i.postMessage({sourceName:s,targetName:n,stream:Nt.PULL_COMPLETE,streamId:e,reason:Qt(l)})});break;case Nt.ENQUEUE:if(Ot(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Nt.CLOSE:if(Ot(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#i(r,e);break;case Nt.ERROR:Ot(r,"error should have stream controller"),r.controller.error(Qt(t.reason)),this.#i(r,e);break;case Nt.CANCEL_COMPLETE:t.success?r.cancelCall.resolve():r.cancelCall.reject(Qt(t.reason)),this.#i(r,e);break;case Nt.CANCEL:if(!a)break;const o=Qt(t.reason);Promise.try(a.onCancel||Dr,o).then(function(){i.postMessage({sourceName:s,targetName:n,stream:Nt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){i.postMessage({sourceName:s,targetName:n,stream:Nt.CANCEL_COMPLETE,streamId:e,reason:Qt(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#i(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class ua{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:ht(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const n=`${s}${e}`;return this._fetch(n,t).catch(i=>{throw new Error(`Unable to load ${this.#t[t]} data at: ${n}`)})}async _fetch(t,e){ht("Abstract method `_fetch` called.")}}class Fr extends ua{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",n=await Ci(t,s);return n instanceof Uint8Array?n:Dn(n)}}class fa{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){ht("Abstract method `_createCanvas` called.")}}class ul extends fa{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class pa{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,n,i){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class fl extends pa{#t;#e;#s;#n;#i;#a;#r=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#n=t,this.#i=e}get#o(){return this.#e||=new Map}get#l(){return this.#a||=new Map}get#c(){if(!this.#s){const t=this.#i.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#i.createElementNS(Gt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#i.createElementNS(Gt,"defs"),t.append(s),s.append(this.#s),this.#i.body.append(t)}return this.#s}#u(t){if(t.length===1){const o=t[0],l=new Array(256);for(let d=0;d<256;d++)l[d]=o[d]/255;const c=l.join(",");return[c,c,c]}const[e,s,n]=t,i=new Array(256),r=new Array(256),a=new Array(256);for(let o=0;o<256;o++)i[o]=e[o]/255,r[o]=s[o]/255,a[o]=n[o]/255;return[i.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";const e=this.#i.URL;e!==this.#i.baseURI&&(Fn(e)?Q('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=ia(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;const[s,n,i]=this.#u(t),r=t.length===1?s:`${s}${n}${i}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;const a=`g_${this.#n}_transfer_map_${this.#r++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);const l=this.#m(a);return this.#p(s,n,i,l),o}addHCMFilter(t,e){const s=`${t}-${e}`,n="base";let i=this.#l.get(n);if(i?.key===s||(i?(i.filter?.remove(),i.key=s,i.url="none",i.filter=null):(i={key:s,url:"none",filter:null},this.#l.set(n,i)),!t||!e))return i.url;const r=this.#y(t);t=L.makeHexColor(...r);const a=this.#y(e);if(e=L.makeHexColor(...a),this.#x(),t==="#000000"&&e==="#ffffff"||t===e)return i.url;const l=Array.from({length:256},(f,p)=>vi(p/255)).join(","),c=`g_${this.#n}_hcm_filter`,d=i.filter=this.#m(c);this.#p(l,l,l,d),this.#g(d);const u=(f,p)=>{const g=r[f]/255,m=a[f]/255,v=new Array(p+1);for(let y=0;y<=p;y++)v[y]=g+y/p*(m-g);return v.join(",")};return this.#p(u(0,5),u(1,5),u(2,5),d),i.url=this.#d(c),i.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){const e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return e==="none"||!mt.platform.isFirefox?null:{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;const[s]=this.#u([t]),n=`alpha_${s}`;if(e=this.#o.get(n),e)return this.#o.set(t,e),e;const i=`g_${this.#n}_alpha_map_${this.#r++}`,r=this.#d(i);this.#o.set(t,r),this.#o.set(n,r);const a=this.#m(i);return this.#v(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,n;if(t?([s]=this.#u([t]),n=`luminosity_${s}`):n="luminosity",e=this.#o.get(n),e)return this.#o.set(t,e),e;const i=`g_${this.#n}_luminosity_map_${this.#r++}`,r=this.#d(i);this.#o.set(t,r),this.#o.set(n,r);const a=this.#m(i);return this.#f(a),t&&this.#v(s,a),r}addKnockoutFilter(t=0){const e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,n=this.#o.get(s);if(n)return n;const i=`g_${this.#n}_knockout_filter_${this.#r++}`,r=this.#d(i);this.#o.set(s,r);const a=this.#m(i),o=this.#i.createElementNS(Gt,"feComponentTransfer");a.append(o);const l=this.#i.createElementNS(Gt,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),r}addHighlightHCMFilter(t,e,s,n,i){const r=`${e}-${s}-${n}-${i}`;let a=this.#l.get(t);if(a?.key===r||(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#l.set(t,a)),!e||!s))return a.url;const[o,l]=[e,s].map(this.#y.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,f]=[n,i].map(this.#S.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#x();const p=(v,y,b)=>{const S=new Array(256),x=(d-c)/b,w=v/255,E=(y-v)/(255*b);let C=0;for(let T=0;T<=b;T++){const O=Math.round(c+T*x),I=w+T*E;for(let M=C;M<=O;M++)S[M]=I;C=O+1}for(let T=C;T<256;T++)S[T]=S[C-1];return S.join(",")},g=`g_${this.#n}_hcm_${t}_filter`,m=a.filter=this.#m(g);return this.#g(m),this.#p(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),m),a.url=this.#d(g),a.url}destroy(t=!1){t&&this.#a?.size||(this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#a?.clear(),this.#a=null,this.#r=0)}#f(t){const e=this.#i.createElementNS(Gt,"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)}#g(t){const e=this.#i.createElementNS(Gt,"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)}#m(t){const e=this.#i.createElementNS(Gt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#h(t,e,s){const n=this.#i.createElementNS(Gt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",s),t.append(n)}#p(t,e,s,n){const i=this.#i.createElementNS(Gt,"feComponentTransfer");n.append(i),this.#h(i,"feFuncR",t),this.#h(i,"feFuncG",e),this.#h(i,"feFuncB",s)}#v(t,e){const s=this.#i.createElementNS(Gt,"feComponentTransfer");e.append(s),this.#h(s,"feFuncA",t)}#y(t){return this.#c.style.color="CanvasText",this.#c.style.backgroundColor=t,Qs(getComputedStyle(this.#c).getPropertyValue("background-color"))}#b(t){return this.#c.style.color="CanvasText",this.#c.style.backgroundColor=t,Ks(getComputedStyle(this.#c).getPropertyValue("background-color"))}#x(){this.#c.style.color="",this.#c.style.backgroundColor=""}#S(t){const[e,s,n,i]=this.#b(t);if(i===1)return[e,s,n];const[r,a,o]=this.#y("Canvas");return[ai(e,r,i),ai(s,a,i),ai(n,o,i)]}}function ai(h,t,e){return Math.round(e*h+(1-e)*t)}if(se){let h;try{const t=process.getBuiltinModule("module").createRequire(import.meta.url);try{h=t("@napi-rs/canvas")}catch(e){Q(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){Q(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(h?.DOMMatrix?globalThis.DOMMatrix=h.DOMMatrix:Q("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.Path2D||(h?.Path2D?globalThis.Path2D=h.Path2D:Q("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function pl(h){const e=await process.getBuiltinModule("fs/promises").readFile(h);return new Uint8Array(e)}class gl extends pa{}class ml extends fa{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class vl extends ua{async _fetch(t,e){return pl(t)}}function ga({src:h,srcPos:t=0,dest:e,width:s,height:n,nonBlackColor:i=4294967295,inverseDecode:r=!1}){const a=mt.isLittleEndian?4278190080:255,[o,l]=r?[i,a]:[a,i],c=s>>3,d=s&7,u=o^l,f=h.length;
4e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<n;++g){for(const v=t+c;t<v;++t,p+=8){const y=h[t];e[p]=o^-(y>>7&1)&u,e[p+1]=o^-(y>>6&1)&u,e[p+2]=o^-(y>>5&1)&u,e[p+3]=o^-(y>>4&1)&u,e[p+4]=o^-(y>>3&1)&u,e[p+5]=o^-(y>>2&1)&u,e[p+6]=o^-(y>>1&1)&u,e[p+7]=o^-(y&1)&u}if(d===0)continue;const m=t<f?h[t++]:255;for(let v=0;v<d;++v,++p)e[p]=o^-(m>>7-v&1)&u}return{srcPos:t,destPos:p}}function yl({src:h,srcPos:t=0,dest:e,destPos:s=0,width:n,height:i}){let r=0;const a=n*i*3,o=a>>2,l=new Uint32Array(h.buffer,t,o),c=mt.isLittleEndian?4278190080:255;if(mt.isLittleEndian){for(;r<o-2;r+=3,s+=4){const d=l[r],u=l[r+1],f=l[r+2];e[s]=d|c,e[s+1]=d>>>24|u<<8|c,e[s+2]=u>>>16|f<<16|c,e[s+3]=f>>>8|c}for(let d=r*4,u=t+a;d<u;d+=3)e[s++]=h[d]|h[d+1]<<8|h[d+2]<<16|c}else{for(;r<o-2;r+=3,s+=4){const d=l[r],u=l[r+1],f=l[r+2];e[s]=d|c,e[s+1]=d<<24|u>>>8|c,e[s+2]=u<<16|f>>>16|c,e[s+3]=f<<8|c}for(let d=r*4,u=t+a;d<u;d+=3)e[s++]=h[d]<<24|h[d+1]<<16|h[d+2]<<8|c}return{srcPos:t+a,destPos:s}}const bl=`
5struct Uniforms {
6  offsetX      : f32,
7  offsetY      : f32,
8  scaleX       : f32,
9  scaleY       : f32,
10  paddedWidth  : f32,
11  paddedHeight : f32,
12  borderSize   : f32,
13  _pad         : f32,
14};
15
16@group(0) @binding(0) var<uniform> u : Uniforms;
17
18struct VertexInput {
19  @location(0) position : vec2<f32>,
20  @location(1) color    : vec4<f32>,
21};
22
23struct VertexOutput {
24  @builtin(position) position : vec4<f32>,
25  @location(0)       color    : vec3<f32>,
26};
27
28@vertex
29fn vs_main(in : VertexInput) -> VertexOutput {
30  var out : VertexOutput;
31  let cx = (in.position.x + u.offsetX) * u.scaleX;
32  let cy = (in.position.y + u.offsetY) * u.scaleY;
33  out.position = vec4<f32>(
34    ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
35    1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
36    0.0,
37    1.0
38  );
39  out.color = in.color.rgb;
40  return out;
41}
42
43@fragment
44fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
45  return vec4<f32>(in.color, 1.0);
46}
47`;class xl{#t=null;#e=null;#s=null;#n=null;async#i(){if(!globalThis.navigator?.gpu)return!1;try{const t=await navigator.gpu.requestAdapter();return t?(this.#n=navigator.gpu.getPreferredCanvasFormat(),this.#e=await t.requestDevice(),!0):!1}catch{return!1}}init(){return this.#t||=this.#i()}get isReady(){return this.#e!==null}loadMeshShader(){if(!this.#e||this.#s)return;const t=this.#e.createShaderModule({code:bl});this.#s=this.#e.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#n}]},primitive:{topology:"triangle-list"}})}draw(t,e,s,n,i,r,a,o){this.loadMeshShader();const l=this.#e,{offsetX:c,offsetY:d,scaleX:u,scaleY:f}=n,p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);const g=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(g,0,e);const m=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(m,0,new Float32Array([c,d,u,f,r,a,o,0]));const v=l.createBindGroup({layout:this.#s.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:m}}]}),y=new OffscreenCanvas(r,a),b=y.getContext("webgpu");b.configure({device:l,format:this.#n,alphaMode:i?"opaque":"premultiplied"});const S=i?{r:i[0]/255,g:i[1]/255,b:i[2]/255,a:1}:{r:0,g:0,b:0,a:0},x=l.createCommandEncoder(),w=x.beginRenderPass({colorAttachments:[{view:b.getCurrentTexture().createView(),clearValue:S,loadOp:"clear",storeOp:"store"}]});return s>0&&(w.setPipeline(this.#s),w.setBindGroup(0,v),w.setVertexBuffer(0,p),w.setVertexBuffer(1,g),w.draw(s)),w.end(),l.queue.submit([x.finish()]),p.destroy(),g.destroy(),m.destroy(),y.transferToImageBitmap()}}const Ln=new xl;function Al(){return Ln.init()}function wl(){return Ln.isReady}function Sl(){Ln.loadMeshShader()}function El(h,t,e,s,n,i,r,a){return Ln.draw(h,t,e,s,n,i,r,a)}const jt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function An(h,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],n=new Path2D;n.rect(t[0],t[1],e,s),h.clip(n)}class Ni{matrix=null;isModifyingCurrentTransform(){return!1}getPattern(){ht("Abstract method `getPattern` called.")}}class Tl extends Ni{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]}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,n=this._p0,i=this._p1;
47if(e&&(n=n.slice(),i=i.slice(),L.applyTransform(n,e),L.applyTransform(i,e)),this._type==="axial")s=t.createLinearGradient(n[0],n[1],i[0],i[1]);else if(this._type==="radial"){let r=this._r0,a=this._r1;if(e){const o=new Float32Array(2);L.singularValueDecompose2dScale(e,o),r*=o[0],a*=o[0]}s=t.createRadialGradient(n[0],n[1],r,i[0],i[1],a)}for(const r of this._colorStops)s.addColorStop(r[0],r[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,n=this._p0;e&&(s=s.slice(),n=n.slice(),L.applyTransform(s,e),L.applyTransform(n,e));let i=this._r1,r=this._r0;if(e){const l=new Float32Array(2);L.singularValueDecompose2dScale(e,l),i*=l[0],r*=l[0]}const a=t.createRadialGradient(s[0],s[1],i,n[0],n[1],r),o=this._colorStops.map(([l,c])=>[1-l,c]).reverse();for(const[l,c]of o)a.addColorStop(l,c);return a}getPattern(t,e,s,n){let i;if(n===jt.STROKE||n===jt.FILL){if(this.isOriginBased()){let u=L.transform(s,e.baseTransform);this.matrix&&(u=L.transform(u,this.matrix));const f=.001,p=Math.hypot(u[0],u[1]),g=Math.hypot(u[2],u[3]),m=(u[0]*u[2]+u[1]*u[3])/(p*g);if(Math.abs(m)<f)if(this.isRadial()){if(Math.abs(p-g)<f)return this._createGradient(t,u)}else return this._createGradient(t,u)}const r=e.current.getClippedPathBoundingBox(n,yt(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.canvasFactory.create(a,o),c=l.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),s=L.transform(s,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),An(c,this._bbox),this.areConic()&&(c.fillStyle=this._createReversedGradient(c),c.fill()),c.fillStyle=this._createGradient(c),c.fill(),i=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);const d=new DOMMatrix(s);i.setTransform(d)}else this.areConic()&&(t.save(),An(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),An(t,this._bbox),i=this._createGradient(t);return i}}function Cl(h,t,e,s,n,i,r,a){const o=t.coords,l=t.colors,c=h.data,d=h.width*4;let u;o[e*2+1]>o[s*2+1]&&(u=e,e=s,s=u,u=i,i=r,r=u),o[s*2+1]>o[n*2+1]&&(u=s,s=n,n=u,u=r,r=a,a=u),o[e*2+1]>o[s*2+1]&&(u=e,e=s,s=u,u=i,i=r,r=u);const f=(o[e*2]+t.offsetX)*t.scaleX,p=(o[e*2+1]+t.offsetY)*t.scaleY,g=(o[s*2]+t.offsetX)*t.scaleX,m=(o[s*2+1]+t.offsetY)*t.scaleY,v=(o[n*2]+t.offsetX)*t.scaleX,y=(o[n*2+1]+t.offsetY)*t.scaleY;if(p>=y)return;const b=l[i*4],S=l[i*4+1],x=l[i*4+2],w=l[r*4],E=l[r*4+1],C=l[r*4+2],T=l[a*4],O=l[a*4+1],I=l[a*4+2],M=Math.round(p),N=Math.round(y);let D,$,k,F,W,G,at,bt;for(let J=M;J<=N;J++){if(J<m){const R=J<p?0:(p-J)/(p-m);D=f-(f-g)*R,$=b-(b-w)*R,k=S-(S-E)*R,F=x-(x-C)*R}else{let R;J>y?R=1:m===y?R=0:R=(m-J)/(m-y),D=g-(g-v)*R,$=w-(w-T)*R,k=E-(E-O)*R,F=C-(C-I)*R}let tt;J<p?tt=0:J>y?tt=1:tt=(p-J)/(p-y),W=f-(f-v)*tt,G=b-(b-T)*tt,at=S-(S-O)*tt,bt=x-(x-I)*tt;const dt=Math.round(Math.min(D,W)),_t=Math.round(Math.max(D,W));let B=d*J+dt*4;for(let R=dt;R<=_t;R++)tt=(D-R)/(D-W),tt<0?tt=0:tt>1&&(tt=1),c[B++]=$-($-G)*tt|0,c[B++]=k-(k-at)*tt|0,c[B++]=F-(F-bt)*tt|0,c[B++]=255}}class Pl extends Ni{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],Sl()}_createMeshCanvas(t,e,s){const a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),l=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,d=Math.min(Math.ceil(Math.abs(l*t[0]*1.1)),3e3)||1,u=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3)||1,f=l?l/d:1,p=c?c/u:1,g={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-o,scaleX:1/f,scaleY:1/p},m=d+4,v=u+4,y=s.create(m,v);if(wl()&&this._vertexCount>48)y.context.drawImage(El(this._posData,this._colData,this._vertexCount,g,e,m,v,2),0,0);else{const b=y.context.createImageData(d,u);if(e){const S=b.data;for(let x=0,w=S.length;x<w;x+=4)S[x]=e[0],S[x+1]=e[1],S[x+2]=e[2],S[x+3]=255}for(let S=0,x=this._vertexCount;S<x;S+=3)Cl(b,g,S,S+1,S+2,S,S+1,S+2);y.context.putImageData(b,2,2)}return{canvas:y.canvas,offsetX:a-2*f,offsetY:o-2*p,scaleX:f,scaleY:p}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,n){An(t,this._bbox);const i=new Float32Array(2);if(n===jt.SHADING)L.singularValueDecompose2dScale(yt(t),i);
vendor: 4,124 bytes, line 47
47else if(this.matrix){L.singularValueDecompose2dScale(this.matrix,i);const[o,l]=i;L.singularValueDecompose2dScale(e.baseTransform,i),i[0]*=o,i[1]*=l}else L.singularValueDecompose2dScale(e.baseTransform,i);const r=this._createMeshCanvas(i,n===jt.SHADING?null:this._background,e.canvasFactory);n!==jt.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY);const a=t.createPattern(r.canvas,"no-repeat");return e.canvasFactory.destroy(r),a}}class Il extends Ni{getPattern(){return"hotpink"}}function Ol(h){switch(h[0]){case"RadialAxial":return new Tl(h);case"Mesh":return new Pl(h);case"Dummy":return new Il}throw new Error(`Unknown IR type: ${h[0]}`)}const Lr={COLORED:1,UNCOLORED:2};class $s{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,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.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=n,this.patternBaseMatrix=this.matrix?L.transform(n,this.matrix):n}canSkipPatternCanvas([t,e,s,n]){const[i,r,a,o]=this.bbox,l=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>l+1e-6||e>c+1e-6)return null;const d=Math.floor((s-a)/l)+1,u=Math.ceil((s+t-i)/l)-1,f=Math.floor((n-o)/c)+1,p=Math.ceil((n+e-r)/c)-1;return u<=d&&p<=f?[d,f]:null}updatePatternDims(t,e){const s=L.inverseTransform(this.patternBaseMatrix),n=[t[0],t[1]],i=[t[2],t[3]];L.applyTransform(n,s),L.applyTransform(i,s),e[0]=Math.abs(i[0]-n[0]),e[1]=Math.abs(i[1]-n[1]),e[2]=Math.min(n[0],i[0]),e[3]=Math.min(n[1],i[1])}_renderTileCanvas(t,e,s,n){const[i,r,a,o]=this.bbox,l=t.canvasFactory.create(s.size,n.size),c=l.context,d=this.canvasGraphicsFactory.createCanvasGraphics(c,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),c.translate(-s.scale*i,-n.scale*r),d.transform(0,s.scale,0,0,n.scale,0,0),c.save(),d.dependencyTracker?.save(),this.clipBbox(d,i,r,a,o),d.baseTransform=yt(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),d.dependencyTracker?.restore(),c.restore(),l}_getCombinedScales(){const t=new Float32Array(2);L.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return L.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[n,i],r){const[a,o,l,c]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new Gs(d,r)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(n*this.xstep,i*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const u=l-a,f=c-o,[p,g]=this._getCombinedScales(),m=this.getSizeAndScale(u,this.ctx.canvas.width,p),v=this.getSizeAndScale(f,this.ctx.canvas.height,g),y=this._renderTileCanvas(t,r,m,v);t.ctx.drawImage(y.canvas,a,o,u,f),t.canvasFactory.destroy(y)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=yt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,n,i,r]=this.bbox,a=i-s,o=r-n;let{xstep:l,ystep:c}=this;l=Math.abs(l),c=Math.abs(c),kn("TilingType: "+this.tilingType);const[d,u]=this._getCombinedScales();let f=a,p=o,g=!1,m=!1;Math.ceil(l*d)>=Math.ceil(a*d)?f=l:g=!0,Math.ceil(c*u)>=Math.ceil(o*u)?p=c:m=!0;const v=this.getSizeAndScale(f,this.ctx.canvas.width,d),y=this.getSizeAndScale(p,this.ctx.canvas.height,u),b=this._renderTileCanvas(t,e,v,y);if(g||m){const S=b.canvas;g&&(f=l),m&&(p=c);const x=this.getSizeAndScale(f,this.ctx.canvas.width,d),w=this.getSizeAndScale(p,this.ctx.canvas.height,u),E=x.size,C=w.size,T=t.canvasFactory.create(E,C),O=T.context,I=g?Math.floor(a/l):0,M=m?Math.floor(o/c):0;for(let N=0;N<=I;N++)for(let D=0;D<=M;D++)O.drawImage(S,E*N,C*D,E,C,0,0,E,C);return t.canvasFactory.destroy(b),{canvas:T.canvas,canvasEntry:T,scaleX:x.scale,scaleY:w.scale,offsetX:s,offsetY:n}}
47return{canvas:b.canvas,canvasEntry:b,scaleX:v.scale,scaleY:y.scale,offsetX:s,offsetY:n}}getSizeAndScale(t,e,s){const n=Math.max($s.MAX_PATTERN_SIZE,e);let i=Math.ceil(t*s);return i>=n?i=n:s=i/t,{scale:s,size:i}}clipBbox(t,e,s,n,i){const r=n-e,a=i-s,o=new Path2D;o.rect(e,s,r,a),L.axialAlignedBoundingBox([e,s,n,i],yt(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,i=t.current;switch(i.patternFill=i.patternStroke=!1,e){case Lr.COLORED:const{fillStyle:r,strokeStyle:a}=this.ctx;n.fillStyle=i.fillColor=r,n.strokeStyle=i.strokeColor=a;break;case Lr.UNCOLORED:n.fillStyle=n.strokeStyle=s,i.fillColor=i.strokeColor=s;break;default:throw new Po(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,n,i){const r=n!==jt.SHADING?L.transform(s,this.patternBaseMatrix):s,a=this.createPatternCanvas(e,i);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 e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}const Ml=16,Rl=100,Nl=15,Br=10,Jt=16,ie=new Float32Array(2);function jr(h,t){if(h._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const n=h[s];typeof n!="function"||typeof t[s]!="function"||(e.set(s,n),h[s]=function(...i){return t[s](...i),n.apply(this,i)})}h._removeMirroring=()=>{for(const[s,n]of e)h[s]=n;delete h._removeMirroring}}function fn(h,t,e,s,n,i,r,a,o,l){const[c,d,u,f,p,g]=yt(h);if(d===0&&u===0){const y=r*c+p,b=Math.round(y),S=a*f+g,x=Math.round(S),w=(r+o)*c+p,E=Math.abs(Math.round(w)-b)||1,C=(a+l)*f+g,T=Math.abs(Math.round(C)-x)||1;return h.setTransform(Math.sign(c),0,0,Math.sign(f),b,x),h.drawImage(t,e,s,n,i,0,0,E,T),h.setTransform(c,d,u,f,p,g),[E,T]}if(c===0&&f===0){const y=a*u+p,b=Math.round(y),S=r*d+g,x=Math.round(S),w=(a+l)*u+p,E=Math.abs(Math.round(w)-b)||1,C=(r+o)*d+g,T=Math.abs(Math.round(C)-x)||1;return h.setTransform(0,Math.sign(d),Math.sign(u),0,b,x),h.drawImage(t,e,s,n,i,0,0,T,E),h.setTransform(c,d,u,f,p,g),[T,E]}h.drawImage(t,e,s,n,i,r,a,o,l);const m=Math.hypot(c,d),v=Math.hypot(u,f);return[m*o,v*l]}class _r{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=ci;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=Ft.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=Je.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=jt.FILL,e=null){const s=this.minMax.slice();if(t===jt.STROKE){e||ht("Stroke bounding box must include transform."),L.singularValueDecompose2dScale(e,ie);const n=ie[0]*this.lineWidth/2,i=ie[1]*this.lineWidth/2;s[0]-=n,s[1]-=i,s[2]+=n,s[3]+=i}return s}updateClipFromPath(){const t=L.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(Je,0)}getClippedPathBoundingBox(t=jt.FILL,e=null){return L.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ur(h,t){const{width:e,height:s,kind:n}=t,i=s%Jt,r=(s-i)/Jt,a=i===0?r:r+1,o=h.createImageData(e,Jt);let l=0;const c=t.data,d=o.data;let u;if(n===xn.GRAYSCALE_1BPP)for(u=0;u<a;u++)({srcPos:l}=ga({src:c,srcPos:l,dest:d,width:e,height:u<r?Jt:i})),h.putImageData(o,0,u*Jt);else if(n===xn.RGBA_32BPP){let f=0,p=e*Jt*4;for(u=0;u<r;u++)d.set(c.subarray(l,l+p)),l+=p,h.putImageData(o,0,f),f+=Jt;u<a&&(p=e*i*4,d.set(c.subarray(l,l+p)),h.putImageData(o,0,f))}else if(n===xn.RGB_24BPP)for(u=0;
47u<a;u++)({srcPos:l}=yl({src:c,srcPos:l,dest:new Uint32Array(d.buffer),width:e,height:u<r?Jt:i})),h.putImageData(o,0,u*Jt);else throw new Error(`bad image kind: ${n}`)}function $r(h,t){if(t.bitmap){h.drawImage(t.bitmap,0,0);return}const{width:e,height:s}=t,n=s%Jt,i=(s-n)/Jt,r=n===0?i:i+1,a=h.createImageData(e,Jt);let o=0;const l=t.data,c=a.data;for(let d=0;d<r;d++)({srcPos:o}=ga({src:l,srcPos:o,dest:c,width:e,height:d<i?Jt:n,nonBlackColor:0})),h.putImageData(a,0,d*Jt)}function Ke(h,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)h[s]!==void 0&&(t[s]=h[s]);h.setLineDash!==void 0&&(t.setLineDash(h.getLineDash()),t.lineDashOffset=h.lineDashOffset)}function pn(h){h.strokeStyle=h.fillStyle="#000000",h.fillRule="nonzero",h.globalAlpha=1,h.lineWidth=1,h.lineCap="butt",h.lineJoin="miter",h.miterLimit=10,h.globalCompositeOperation="source-over",h.font="10px sans-serif",h.setLineDash!==void 0&&(h.setLineDash([]),h.lineDashOffset=0);const{filter:t}=h;t!=="none"&&t!==""&&(h.filter="none")}function Hr(h,t){if(t)return!0;L.singularValueDecompose2dScale(h,ie);const e=Math.fround(ge.pixelRatio*Ts.PDF_TO_CSS_UNITS);return ie[0]<=e&&ie[1]<=e}const kl=["butt","round","square"],Dl=["miter","round","bevel"],Fl={},zr={};class ss{static#t=null;#e=0;#s=0;#n=null;#i=null;#a=null;#r=null;#o=1;#l;#c=null;#u=[];constructor(t,e,s,n,i,{optionalContentConfig:r,markedContentStack:a=null},o,l,c,d){this.ctx=t,this.current=new _r(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=n,this.filterFactory=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,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=c??null,this.imagesTracker=d??null}getObject(t,e,s=null){return typeof e=="string"?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:n=null}){const i=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,i,r),this.ctx.fillStyle=a,s){const o=this.transparentCanvasEntry=this.canvasFactory.create(i,r);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=o,this.ctx.save(),this.ctx.transform(...yt(this.compositeCtx))}this.ctx.save(),pn(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=yt(this.ctx)}executeOperatorList(t,e,s,n,i){const r=t.argsArray,a=t.fnArray;let o=e||0;const l=r.length;if(l===o)return o;const c=l-o>Br&&typeof s=="function",d=c?Date.now()+Nl:0;let u=0;const f=this.commonObjs,p=this.objs;let g,m;for(;;){if(n!==void 0){if(o===n.nextBreakPoint)return n.breakIt(o,s),o;if(n.shouldSkip(o)){if(++o===l)return o;continue}}if(!i||i(o))if(g=a[o],m=r[o]??null,g!==Te.dependency)m===null?this[g](o):this[g](o,...m);else for(const v of m){this.dependencyTracker?.recordNamedData(v,o);const y=v.startsWith("g_")?f:p;if(!y.has(v))return y.get(v,s),o}if(o++,o===l)return o;if(c&&++u>Br){if(Date.now()>d)return s(),o;u=0}}}#d(){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(
47),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}endDrawing(){this.#d();for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of this.#u)this.#x(t);this.#u.length=0,this.#n=null,this.#i=null,this.#a=null,this.#r=null,this.#o=1,this.#c=null,this.#s=0,this.#e=0,this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#f()}#f(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){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 s=t.width??t.displayWidth,n=t.height??t.displayHeight,i=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=[];let o=i,l=r,c=s,d=n;for(;o>2&&c>1||l>2&&d>1;){let v=c,y=d;o>2&&c>1&&(v=Math.ceil(c/2),o/=c/v),l>2&&d>1&&(y=Math.ceil(d/2),l/=d/y),a.push({newWidth:v,newHeight:y}),c=v,d=y}if(a.length===0)return{img:t,paintWidth:s,paintHeight:n,tmpCanvas:null};if(a.length===1){const{newWidth:v,newHeight:y}=a[0],b=this.canvasFactory.create(v,y);return b.context.drawImage(t,0,0,s,n,0,0,v,y),{img:b.canvas,paintWidth:v,paintHeight:y,tmpCanvas:b}}let u=this.canvasFactory.create(1,1),f=this.canvasFactory.create(1,1),p=s,g=n,m=t;for(const{newWidth:v,newHeight:y}of a)this.canvasFactory.reset(f,v,y),f.context.drawImage(m,0,0,p,g,0,0,v,y),[u,f]=[f,u],m=u.canvas,p=v,g=y;return this.canvasFactory.destroy(f),{img:u.canvas,paintWidth:p,paintHeight:g,tmpCanvas:u}}_createMaskCanvas(t,e){const s=this.ctx,{width:n,height:i}=e,r=this.current.fillColor,a=this.current.patternFill,o=yt(s);let l,c,d,u;if((e.bitmap||e.data)&&e.count>1){const I=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),r]),l=this._cachedBitmapsMap.getOrInsertComputed(I,Ti);const M=l.get(c);if(M&&!a){const N=Math.round(Math.min(o[0],o[2])+o[4]),D=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,le.transformAndFill),{canvas:M,offsetX:N,offsetY:D}}d=M}d||(u=this.canvasFactory.create(n,i),$r(u.context,e));let f=L.transform(o,[1/n,0,0,-1/i,0,0]);f=L.transform(f,[1,0,0,1,0,-i]);const p=Je.slice();L.axialAlignedBoundingBox([0,0,n,i],f,p);const[g,m,v,y]=p,b=Math.round(v-g)||1,S=Math.round(y-m)||1,x=this.canvasFactory.create(b,S),w=x.context,E=g,C=m;w.translate(-E,-C),w.transform(...f);let T=null;if(!d){const I=this._scaleImage(u.canvas,we(w));d=I.img,T=I.tmpCanvas,d!==u.canvas&&(this.canvasFactory.destroy(u),u=null),l&&a&&(l.set(c,d),T=null,u=null)}w.imageSmoothingEnabled=Hr(yt(w),e.interpolate),fn(w,d,0,0,d.width,d.height,0,0,n,i),T&&this.canvasFactory.destroy(T),u&&this.canvasFactory.destroy(u),w.globalCompositeOperation="source-in";const O=L.transform(we(w),[1,0,0,1,-E,-C]);return w.fillStyle=a?r.getPattern(s,this,O,jt.FILL,t):r,w.fillRect(0,0,n,i),l&&!a&&l.set(c,x.canvas),this.dependencyTracker?.recordDependencies(t,le.transformAndFill),{canvas:x.canvas,canvasEntry:l&&!a?null:x,offsetX:Math.round(E),offsetY:Math.round(C)}}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=kl[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Dl[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[s,n]of e)switch(s){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;
47case"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.ctx.globalAlpha=this.current.fillAlpha=n;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=n;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=n?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){const{canvas:e,subtype:s,backdrop:n,transferMap:i}=t,r=s==="Luminosity"||s==="Alpha"&&i;if(!r&&!(s==="Luminosity"&&n)){this.smaskPreparedFor=t;return}let a;if(s==="Luminosity"&&n){const[y,b,S]=Ks(n),x=Math.round(.3*y+.59*b+.11*S);a=i?.[x]??x}else a=i?.[0]??0;const o=4,{width:l,height:c}=this.ctx.canvas,d=e.width*e.height,u=l*c<o*d,f=r?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(i):this.filterFactory.addLuminosityFilter(i),subtype:s,transferMap:i}:null,p=s==="Luminosity"?n:null;let g,m,v;u?(g=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,l,c,p,f),m=0,v=0):(g=this._bakeSMaskCanvas(e,0,0,e.width,e.height,p,f),m=t.offsetX,v=t.offsetY),this.smaskPreparedEntry=g,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=m,this.smaskPreparedOffsetY=v,this.smaskPreparedOOBAlpha=!u&&a!==0?a:null}_bakeSMaskCanvas(t,e,s,n,i,r,a){!r&&!a&&ht("_bakeSMaskCanvas with neither backdrop nor filter");const o=this.canvasFactory.create(n,i),l=o.context;if(l.drawImage(t,e,s),r&&(l.globalCompositeOperation="destination-atop",l.fillStyle=r,l.fillRect(0,0,n,i)),!a)return o;const c=this.canvasFactory.create(n,i),d=c.context;d.filter=a.url;const u=mt.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(o.canvas,0,0),mt.isCanvasFilterSupported&&(d.filter="none"),!u){const f=d.getImageData(0,0,n,i),{data:p}=f,{transferMap:g}=a;if(a.subtype==="Luminosity")for(let m=0,v=p.length;m<v;m+=4){const y=.3*p[m]+.59*p[m+1]+.11*p[m+2]+.5|0;p[m]=p[m+1]=p[m+2]=0,p[m+3]=g?.[y]??y}else for(let m=3,v=p.length;m<v;m+=4)p[m]=g[p[m]];d.putImageData(f,0,0)}return this.canvasFactory.destroy(o),c}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:s}=this.ctx.canvas,n=this.canvasFactory.create(e,s);this.smaskScratchCanvas=n,this.suspendedCtx=this.ctx;const i=this.ctx=n.context;i.setTransform(this.suspendedCtx.getTransform()),Ke(this.suspendedCtx,i),jr(i,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ke(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#g(t,e=null,s=1){const{width:n,height:i}=t,r=e??this.canvasFactory.create(n,i),a=r.context;s=Math.round(s*255)/255;const o=s<1;o&&this.#l===void 0&&(this.#l=mt.isCanvasFilterSupported?new Map:"none");let l="none";if(o&&this.#l instanceof Map&&(l=this.#l.getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!o||l!=="none")return e&&(a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,n,i),a.restore(
47)),a.filter=l,a.drawImage(t,0,0),a.filter="none",r;const c=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,n,i),d=a.createImageData(n,i),u=c.data,f=d.data,p=s>0?1/s:1e6;for(let g=3,m=u.length;g<m;g+=4)f[g]=Math.min(Math.round(u[g]*p),255);return a.putImageData(d,0,0),r}#m(t,e,s,n){let i=t?.[e]??null;if(i&&(i.canvas.width!==s||i.canvas.height!==n)&&(this.canvasFactory.destroy(i),i=null),!i)return i=this.canvasFactory.create(s,n),t&&(t[e]=i),i;const r=i.context;return r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,s,n),r.restore(),i}#h(t,e,s={}){const{backdropCanvas:n=null,destTransform:i=[1,0,0,1,0,0],backdropOffset:r=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:c="none",knockoutAlpha:d=1}=s,{width:u,height:f}=e,p=this.#g(e,a,d),g=t.globalCompositeOperation;if(t.save(),t.setTransform(...i),t.globalAlpha=1,mt.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(p.canvas,0,0),n){const[m,v]=r,y=this.#m(o,"knockoutBackdropEntry",u,f),b=y.context;b.drawImage(n,m,v,u,f,0,0,u,f),b.globalCompositeOperation="destination-in",b.drawImage(p.canvas,0,0),b.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(y.canvas,0,0),o||this.canvasFactory.destroy(y)}t.globalCompositeOperation=g,t.globalAlpha=l,mt.isCanvasFilterSupported&&(t.filter=c??"none"),t.drawImage(e,0,0),t.restore(),a||this.canvasFactory.destroy(p)}#p(t=1){if(this.#e===0||this.#s>0||!this.contentVisible)return!1;this.#s++,this.#o=t;const e=this.#u.at(-1),{canvas:s}=this.ctx,n=this.#m(e,"knockoutTempEntry",s.width,s.height);this.#n=n;const i=n.context;return i.save(),i.setTransform(this.ctx.getTransform()),Ke(this.ctx,i),this.#r=i.globalCompositeOperation,i.globalCompositeOperation="source-over",jr(i,this.ctx),this.#c=e,this.#i=this.ctx,this.#a=this.suspendedCtx,this.ctx=i,this.inSMaskMode&&(this.suspendedCtx=i),!0}#v(t){if(!t)return;const e=this.#n,s=this.#i,n=this.#a,i=e.context;this.#n=null,this.#i=null,this.#a=null,this.inSMaskMode&&this.suspendedCtx===i&&this.ctx!==i&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=n),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#r,this.#r=null,Ke(this.ctx,s),this.ctx=s;const r=this.#c;this.#c=null;const a=this.#o;this.#o=1;try{this.#h(n??s,e.canvas,{backdropCanvas:r?.backdropCtx?.canvas??null,backdropOffset:r?.backdropCtx?[r.offsetX,r.offsetY]:[0,0],reuseMaskEntry:r?.knockoutMaskEntry??null,poolMeta:r,knockoutAlpha:a})}finally{i.restore(),this.#s--,r||this.canvasFactory.destroy(e)}}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx,n=this.#s>0&&s===this.ctx;this.composeSMask(n?null:s,e,this.ctx,t),!n&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,s,n){const i=n[0],r=n[1],a=n[2]-i,o=n[3]-r;if(a===0||o===0)return;const l=this.smaskPreparedEntry;if(l){let c=i,d=r,u=a,f=o;const p=this.smaskPreparedOOBAlpha,g=p!==null;if(g){c=Math.max(i,e.offsetX),d=Math.max(r,e.offsetY);const m=Math.min(i+a,e.offsetX+e.canvas.width),v=Math.min(r+o,e.offsetY+e.canvas.height);u=m-c,f=v-d}if(u>0&&f>0){const m=c-this.smaskPreparedOffsetX,v=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(c,d,u,f),s.clip(y),s.globalCompositeOperation="destination-in",s.drawImage(l.canvas,m,v,u,f,c,d,u,f),s.restore()}g&&p<255&&this._applySMaskOOBAlpha(s,i,r,a,o,c,d,c+u,d+f,p)}else this.genericComposeSMask(e,s,a,o,i,r);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,i,r,a,o,i,r,a,o),t.restore())}_applySMaskOOBAlpha(t,e,s,n,i,r,a,o,l,c){const d=r<o&&a<l;if(d&&r===e&&a===s&&o===e+n&&l===s+i)return;const u=new Path2D;u.rect(e,s,n,i),d&&u.rect(r,a,o-r,l-a),t.save(),t.globalAlpha=c/255,t.setTransform(1,0,0,1,0,0),t.clip(u,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,n,i),t.restore(
47)}genericComposeSMask(t,e,s,n,i,r){const{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const c=new Path2D;c.rect(i,r,s,n),e.clip(c),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,i-o,r-l,s,n,i,r,s,n),e.restore()}save(t){this.inSMaskMode&&Ke(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){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Ke(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,n,i,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,s,n,i,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,n){let[i]=s;if(!n){i||=s[0]=new Path2D,e!==Te.stroke&&e!==Te.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,i);return}if(this.dependencyTracker!==null){const a=e===Te.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-a,n[2]+a,n[1]-a,n[3]+a).recordDependencies(t,["transform"])}i instanceof Path2D||(i=s[0]=la(i)),L.axialAlignedBoundingBox(n,yt(this.ctx),this.current.minMax);const r=this.current.tilingPatternDims;if(r&&e!==Te.stroke&&e!==Te.closeStroke&&this.current.fillColor instanceof $s){const a=L.intersect(this.current.clipBox,this.current.minMax);a?this.current.fillColor.updatePatternDims(a,r):this.current.tilingPatternDims=null}this[e](t,i),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){const n=s&&this.#p(this.current.strokeAlpha),i=this.ctx,r=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&r?.getPattern){const a=r.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=r.getPattern(i,this,we(i),jt.STROKE,t),a){const o=new Path2D;o.addPath(e,i.getTransform().invertSelf().multiplySelf(a)),e=o}this.rescaleAndStroke(e,!1),i.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,le.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(jt.STROKE,yt(this.ctx))),i.globalAlpha=this.current.fillAlpha,this.#v(n)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){const n=s&&this.#p(this.current.fillAlpha),i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,le.fill),a){const c=this.current.tilingPatternDims,d=c&&r.canSkipPatternCanvas(c);if(d){r.drawPattern(this,e,this.pendingEOFill,d,t),this.pendingEOFill=!1,s&&this.consumePath(t,e,l),this.current.tilingPatternDims=null,this.#v(n);return}const u=r.isModifyingCurrentTransform()?i.getTransform():null;if(this.dependencyTracker?.save(t),i.save(),i.fillStyle=r.getPattern(i,this,we(i),jt.FILL,t),u){const f=new Path2D;f.addPath(e,i.getTransform().invertSelf().multiplySelf(u)),e=f}o=!0}this.contentVisible&&l!==null&&(this.pendingEOFill?(i.fill(e,"evenodd"),this.pendingEOFill=!1):i.fill(e)),o&&(i.restore(),this.dependencyTracker?.restore(t)),s&&this.consumePath(t,e,l),this.#v(n)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=this.#p(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#v(s)}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){const s=this.#p(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,le.rawFillPath).recordOperation(t),this.#v(s)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Fl}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=zr}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,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:n}=this;e!==void 0&&n.recordFutureForcedDependency("textClip",n.getOpenMarker()).recordFutureForcedDependency("textClip",t),n.recordCloseMarker(t)}if(e!==void 0){const n=new Path2D,i=s.getTransform().invertSelf();for(const{transform:r,x:a,y:o,fontSize:l,path:c}of e)c&&n.addPath(c,new DOMMatrix(r).preMultiplySelf(i).translate(a,o).scale(l,-l));s.clip(n)}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,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),i=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(i.fontMatrix=n.fontMatrix||ci,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&Q("Invalid font matrix for font "+e),s<0?(s=-s,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=s,n.isType3Font)return;const r=n.loadedName||"sans-serif",a=n.systemFontInfo?.css||`"${r}", ${n.fallbackName}`;let o="normal";n.black?o="900":n.bold&&(o="bold");const l=n.italic?"italic":"normal",c=xt(s,Ml,Rl);this.current.fontSizeScale=s/c,this.ctx.font=`${l} ${o} ${c}px ${a}`}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,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#y(t,e,s){const n=new Path2D;return n.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),n}paintChar(t,e,s,n,i,r){const a=this.ctx,o=this.current,l=o.font,c=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,u=c&Ft.FILL_STROKE_MASK,f=!!(c&Ft.ADD_TO_PATH_FLAG),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;let m;if((l.disableFontFace||f||p||g)&&!l.missingFile&&(m=l.getPathGenerator(this.commonObjs,e)),m&&(l.disableFontFace||p||g)){a.save(),a.translate(s,n),a.scale(d,-d
47),this.dependencyTracker?.recordCharacterBBox(t,a,l);let v;if(u===Ft.FILL||u===Ft.FILL_STROKE)if(i){v=a.getTransform(),a.setTransform(...i);const y=this.#y(m,v,i);a.fill(y)}else a.fill(m);if(u===Ft.STROKE||u===Ft.FILL_STROKE)if(r){v||=a.getTransform(),a.setTransform(...r);const{a:y,b,c:S,d:x}=v,w=L.inverseTransform(r),E=L.transform([y,b,S,x,0,0],w);L.singularValueDecompose2dScale(E,ie),a.lineWidth*=Math.max(ie[0],ie[1])/d,a.stroke(this.#y(m,v,r))}else a.lineWidth/=d,a.stroke(m);a.restore()}else(u===Ft.FILL||u===Ft.FILL_STROKE)&&(a.fillText(e,s,n),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,s,n,()=>a.measureText(e))),(u===Ft.STROKE||u===Ft.FILL_STROKE)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,l,d,s,n,()=>a.measureText(e)).recordDependencies(t,le.stroke),a.strokeText(e,s,n));f&&((this.pendingTextPaths||=[]).push({transform:yt(a),x:s,y:n,fontSize:d,path:m}),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,s,n))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let n=!1;for(let i=3;i<s.length;i+=4)if(s[i]>0&&s[i]<255){n=!0;break}return Y(this,"isFontSubpixelAAEnabled",n)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,le.showText).resetBBox(t),this.current.textRenderingMode&Ft.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,n=s.font;if(n.isType3Font){const M=this.#p(s.fillAlpha);this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),this.#v(M);return}const i=s.fontSize;if(i===0){this.dependencyTracker?.recordOperation(t);return}const r=this.#p(s.fillAlpha),a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,c=s.wordSpacing,d=s.fontDirection,u=s.textHScale*d,f=e.length,p=n.vertical,g=p?1:-1,m=n.defaultVMetrics,v=i*s.fontMatrix[0],y=s.textRenderingMode===Ft.FILL&&!n.disableFontFace&&!s.patternFill;a.save(),s.textMatrix&&a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),d>0?a.scale(u,-1):a.scale(u,1);let b,S;const x=s.textRenderingMode&Ft.FILL_STROKE_MASK,w=x===Ft.FILL||x===Ft.FILL_STROKE,E=x===Ft.STROKE||x===Ft.FILL_STROKE;let C=s.lineWidth;const T=s.textMatrixScale;if(T===0||C===0?E&&(C=this.getSinglePixelWidth()):C/=T,o!==1&&(a.scale(o,o),C/=o),a.lineWidth=C,w&&s.patternFill){a.save();const M=s.fillColor.getPattern(a,this,we(a),jt.FILL,t);b=yt(a),a.restore(),a.fillStyle=M}if(E&&s.patternStroke){a.save();const M=s.strokeColor.getPattern(a,this,we(a),jt.STROKE,t);S=yt(a),a.restore(),a.strokeStyle=M}if(n.isInvalidPDFjsFont){const M=[];let N=0;for(const $ of e)M.push($.unicode),N+=$.width;const D=M.join("");if(a.fillText(D,0,0),this.dependencyTracker!==null){const $=a.measureText(D);this.dependencyTracker.recordBBox(t,this.ctx,-$.actualBoundingBoxLeft,$.actualBoundingBoxRight,-$.actualBoundingBoxAscent,$.actualBoundingBoxDescent).recordShowTextOperation(t)}
47s.x+=N*v*u,a.restore(),this.compose(),this.#v(r);return}let O=0,I;for(I=0;I<f;++I){const M=e[I];if(typeof M=="number"){O+=g*M*i/1e3;continue}let N=!1;const D=(M.isSpace?c:0)+l,$=M.fontChar,k=M.accent;let F,W,G=M.width;if(p){const J=M.vmetric||m,tt=-(M.vmetric?J[1]:G*.5)*v,dt=J[2]*v;G=J?-J[0]:G,F=tt/o,W=(O+dt)/o}else F=O/o,W=0;let at;if(n.remeasure&&G>0){at=a.measureText($);const J=at.width*1e3/i*o;if(G<J&&this.isFontSubpixelAAEnabled){const tt=G/J;N=!0,a.save(),a.scale(tt,1),F/=tt}else G!==J&&(F+=(G-J)/2e3*i/o)}if(this.contentVisible&&(M.isInFont||n.missingFile)){if(y&&!k)a.fillText($,F,W),this.dependencyTracker?.recordCharacterBBox(t,a,at?{bbox:null}:n,i/o,F,W,()=>at??a.measureText($));else if(this.paintChar(t,$,F,W,b,S),k){const J=F+i*k.offset.x/o,tt=W-i*k.offset.y/o;this.paintChar(t,k.fontChar,J,tt,b,S)}}const bt=p?G*v-D*d:G*v+D*d;O+=bt,N&&a.restore()}p?s.y-=O:s.x+=O*u,a.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#v(r)}showType3Text(t,e){const s=this.ctx,n=this.current,i=n.font,r=n.fontSize,a=n.fontDirection,o=i.vertical?1:-1,l=n.charSpacing,c=n.wordSpacing,d=n.textHScale*a,u=n.fontMatrix||ci,f=e.length,p=n.textRenderingMode===Ft.INVISIBLE;let g,m,v,y;if(p||r===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),n.textMatrix&&s.transform(...n.textMatrix),s.translate(n.x,n.y+n.textRise),s.scale(d,a);const b=this.dependencyTracker;for(this.dependencyTracker=b?new Gs(b,t):null,g=0;g<f;++g){if(m=e[g],typeof m=="number"){y=o*m*r/1e3,this.ctx.translate(y,0),n.x+=y*d;continue}const S=(m.isSpace?c:0)+l,x=i.charProcOperatorList.get(m.operatorListId);x?this.contentVisible&&(this.save(),x.fnArray[0]===Te.setCharWidth&&(n.fillAlpha=n.strokeAlpha=1,s.globalAlpha=1),s.scale(r,r),s.transform(...u),this.executeOperatorList(x),this.restore()):Q(`Type3 character "${m.operatorListId}" is not available.`);const w=[m.width,0];L.applyTransform(w,u),v=w[0]*r+S,s.translate(v,0),n.x+=v*d}s.restore(),b&&(this.dependencyTracker=b)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,n,i,r,a){const o=new Path2D;o.rect(n,i,r-n,a-i),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,n,r,i,a).recordClipBox(t,this.ctx,n,r,i,a),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const n=this.baseTransform||yt(this.ctx),i={createCanvasGraphics:(r,a)=>new ss(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Gs(this.dependencyTracker,a,!0):null)};s=new $s(e,this.ctx,i,n)}else s=this._getPattern(t,e[1],e[2]);return s}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);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof $s?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
47setStrokeTransparent(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,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){const n=this.cachedPatterns.getOrInsertComputed(e,()=>Ol(this.getObject(t,e)));return s&&(n.matrix=s),n}shadingFill(t,e){if(!this.contentVisible)return;const s=this.#p(this.current.fillAlpha),n=this.ctx;this.save(t);const i=this._getPattern(t,e);n.fillStyle=i.getPattern(n,this,we(n),jt.SHADING,t);const r=we(n);if(r){const{width:a,height:o}=n.canvas,l=Je.slice();L.axialAlignedBoundingBox([0,0,a,o],r,l);const[c,d,u,f]=l;this.ctx.fillRect(c,d,u-c,f-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,le.transform).recordDependencies(t,le.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#v(s)}beginInlineImage(){ht("Should not call beginInlineImage")}beginImageData(){ht("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=yt(this.ctx),s)){L.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[n,i,r,a]=s,o=new Path2D;o.rect(n,i,r-n,a-i),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,n,r,i,a),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);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const n=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&this.#e===0&&n.globalAlpha===1&&n.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let S=new Path2D;const[x,w,E,C]=e.bbox;if(S.rect(x,w,E-x,C-w),e.matrix){const T=new Path2D;T.addPath(S,new DOMMatrix(e.matrix)),S=T}n.clip(S)}this.groupStack.push(null),this.#u.push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&this.#e===0&&kn("TODO: Fully support non-isolated non-knockout groups.");const i=yt(n);e.matrix&&n.transform(...e.matrix);const r=[0,0,n.canvas.width,n.canvas.height];let a;e.bbox?(a=Je.slice(),L.axialAlignedBoundingBox(e.bbox,yt(n),a),a=L.intersect(a,r)||[0,0,0,0]):a=r;const o=Math.floor(a[0]),l=Math.floor(a[1]),c=Math.max(Math.ceil(a[2])-o,1),d=Math.max(Math.ceil(a[3])-l,1);this.current.startNewPathAndClipBox([0,0,c,d]);const u=this.canvasFactory.create(c,d);e.smask&&this.smaskGroupCanvases.push(u);const f=u.context,p=e.knockout&&!e.isolated?n:null,g=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#e>0,m=e.knockout?this.canvasFactory.create(c,d):null,v=this.#e;e.knockout?this.#e++:this.#e=0,f.translate(-o,-l),f.transform(...i);const y=!e.isolated&&!e.smask&&e.needsIsolation,b=y&&!s&&v===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&n.globalAlpha===1&&n.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none";if(y&&(s||b)&&(f.save(),f.setTransform(1,0,0,1,0,0),f.drawImage(n.canvas,-o,-l),f.restore()),e.bbox){let S=new Path2D;const[x,w,E,C]=e.bbox;if(S.rect(x,w,E-x,C-w),e.matrix){const T=new Path2D;T.addPath(S,new DOMMatrix(e.matrix)),S=T}f.clip(S)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:f,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(n.setTransform(1,0,0,1,0,0),n.translate(o,l),n.save()),Ke(n,f),this.ctx=f,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(n),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(n),this.#u.push({backdropCtx:p,savedKnockoutLevel:v,offsetX:o,offsetY:l,hasInnerBackdrop:g,replaceBackdrop:b,knockoutMaskEntry:m,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,n=this.groupStack.pop(),i=this.#u.pop();if(i&&(this.#e=i.savedKnockoutLevel),n===null){this.restore(t);return}if(e.isGray&&this.#b(s),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(
47),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),this.#x(i);else{this.ctx.restore();const r=yt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...r);const a=Je.slice();L.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],r,a);const o=this.#u.at(-1);if(this.#e>0)if(i.hasInnerBackdrop){const{width:l,height:c}=s.canvas,d=this.canvasFactory.create(l,c),u=d.context;u.drawImage(n.canvas,i.offsetX,i.offsetY,l,c,0,0,l,c),u.globalCompositeOperation="source-over",u.drawImage(s.canvas,0,0);const f=this.#g(s.canvas);u.globalCompositeOperation="destination-in",u.drawImage(f.canvas,0,0);const p=this.ctx.globalCompositeOperation,g=this.ctx.globalAlpha,m=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...r),this.ctx.globalAlpha=1,mt.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(f.canvas,0,0),this.ctx.globalCompositeOperation=p,this.ctx.globalAlpha=g,mt.isCanvasFilterSupported&&(this.ctx.filter=m??"none"),this.ctx.drawImage(d.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(f),this.canvasFactory.destroy(d)}else{const l=o?.backdropCtx??null;this.#h(this.ctx,s.canvas,{backdropCanvas:l?.canvas??null,destTransform:r,backdropOffset:l?[o.offsetX+i.offsetX,o.offsetY+i.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(i.replaceBackdrop){const l=new Path2D;l.rect(0,0,s.canvas.width,s.canvas.height),this.ctx.clip(l),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(s.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),this.#x(i),this.compose(a)}}#b(t){const{canvas:e}=t,{width:s,height:n}=e;if(mt.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}const i=t.getImageData(0,0,s,n),{data:r}=i;for(let a=0,o=r.length;a<o;a+=4){const l=r[a]*.2126+r[a+1]*.7152+r[a+2]*.0722+.5|0;r[a]=r[a+1]=r[a+2]=l}t.putImageData(i,0,0)}#x(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))}beginAnnotation(t,e,s,n,i,r,a){if(this.#d(),pn(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const o=s[2]-s[0],l=s[3]-s[1];if(r&&this.annotationCanvasMap){n=n.slice(),n[4]-=s[0],n[5]-=s[1],L.singularValueDecompose2dScale(yt(this.ctx),ie);const{viewportScale:c}=this,d=Math.ceil(o*this.outputScaleX*c),u=Math.ceil(l*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:f,context:p}=this.annotationCanvas;if(a){const g=this.annotationCanvasMap.getOrInsertComputed(e,Cs);f.setAttribute("data-canvas-name",a);const m=g.findIndex(v=>v.getAttribute("data-canvas-name")===a);m===-1?g.push(f):g[m]=f}else this.annotationCanvasMap.set(e,f);this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(ie[0],0,0,-ie[1],0,l*ie[1]),pn(this.ctx)}else{pn(this.ctx),this.endPath(t);const c=new Path2D;c.rect(s[0],s[1],o,l),this.ctx.clip(c)}}this.current=new _r(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...n),this.transform(t,...i),this.baseTransform=yt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#f(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const n=this.#p(this.current.fillAlpha),i=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,r.offsetX,r.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),i.restore(
47),r.canvasEntry&&this.canvasFactory.destroy(r.canvasEntry),this.compose(),this.#v(n)}paintImageMaskXObjectRepeat(t,e,s,n=0,i=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.#p(this.current.fillAlpha),l=this.ctx;l.save();const c=yt(l);l.transform(s,n,i,r,0,0);const d=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,d.offsetX-c[4],d.offsetY-c[5]),this.dependencyTracker?.resetBBox(t);for(let u=0,f=a.length;u<f;u+=2){const p=L.transform(c,[s,n,i,r,a[u],a[u+1]]);l.drawImage(d.canvas,p[4],p[5]),this.dependencyTracker?.recordBBox(t,this.ctx,p[4],p[4]+d.canvas.width,p[5],p[5]+d.canvas.height)}l.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t),this.#v(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.#p(this.current.fillAlpha),n=this.ctx,i=this.current.fillColor,r=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,le.transformAndFill);for(const a of e){const{data:o,width:l,height:c,transform:d}=a,u=this.canvasFactory.create(l,c),f=u.context;f.save();const p=this.getObject(t,o,a);$r(f,p),f.globalCompositeOperation="source-in",f.fillStyle=r?i.getPattern(f,this,we(n),jt.FILL,t):i,f.fillRect(0,0,l,c),f.restore(),n.save(),n.transform(...d),n.scale(1,-1),fn(n,u.canvas,0,0,l,c,0,-1,1,1),this.canvasFactory.destroy(u),this.dependencyTracker?.recordBBox(t,n,0,l,0,c),n.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#v(s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){Q("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,n,i){if(!this.contentVisible)return;const r=this.getObject(t,e);if(!r){Q("Dependent image isn't ready yet");return}const a=r.width,o=r.height,l=[];for(let c=0,d=i.length;c<d;c+=2)l.push({transform:[s,0,0,n,i[c],i[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:s,height:n}=t,i=this.canvasFactory.create(s,n),r=i.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",{img:i.canvas,canvasEntry:i}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const s=e.width,n=e.height,i=this.#p(this.current.fillAlpha),r=this.ctx;this.save(t);const{filter:a}=r;a!=="none"&&a!==""&&(r.filter="none"),r.scale(1/s,-1/n);let o,l=null;if(e.bitmap){const d=this.applyTransferMapsToBitmap(e);o=d.img,l=d.canvasEntry}else{const d=this.canvasFactory.create(s,n);Ur(d.context,e),o=this.applyTransferMapsToCanvas(d.context),l=d}const c=this._scaleImage(o,we(r));r.imageSmoothingEnabled=Hr(yt(r),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,r,0,s,-n,0).recordDependencies(t,le.imageXObject).recordOperation(t),this.imagesTracker?.record(r,s,n,this.dependencyTracker.clipBox)),fn(r,c.img,0,0,c.paintWidth,c.paintHeight,0,-n,s,n),c.tmpCanvas&&this.canvasFactory.destroy(c.tmpCanvas),l&&this.canvasFactory.destroy(l),this.compose(),this.restore(t),this.#v(i)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;const n=this.#p(this.current.fillAlpha),i=this.ctx;let r,a=null;if(e.bitmap)r=e.bitmap;else{const o=e.width,l=e.height,c=this.canvasFactory.create(o,l);Ur(c.context,e),r=this.applyTransferMapsToCanvas(c.context),a=c}this.dependencyTracker?.resetBBox(t);for(const o of s)i.save(),i.transform(...o.transform),i.scale(1,-1),fn(i,r,o.x,o.y,o.w,o.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,1,-1,0),i.restore();a&&this.canvasFactory.destroy(a),this.dependencyTracker?.recordOperation(t),this.compose(),this.#v(n)}paintSolidColorImageMask(t){if(!this.contentVisible)return;const e=this.#p(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,le.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#v(e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){this.dependencyTracker?.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):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,s){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const i=this.ctx;this.pendingClip?(n||(this.pendingClip===zr?i.clip(e,"evenodd"):i.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=yt(this.ctx);if(t[1]===0&&t[2]===0)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]),s=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:n,d:i}=this.ctx.getTransform();let r,a;
47if(s===0&&n===0){const o=Math.abs(e),l=Math.abs(i);if(o===l)if(t===0)r=a=1/o;else{const c=o*t;r=a=c<1?1/c:1}else if(t===0)r=1/o,a=1/l;else{const c=o*t,d=l*t;r=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*i-s*n),l=Math.hypot(e,s),c=Math.hypot(n,i);if(t===0)r=c/o,a=l/o;else{const d=t*o;r=c>d?c/d:1,a=l>d?l/d:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:n}}=this,[i,r]=this.getScaleForStroking();if(i===r){s.lineWidth=(n||1)*i,s.stroke(t);return}const a=ss.#t??=new DOMMatrix,o=s.getLineDash();e&&s.save(),s.scale(i,r),a.a=1/i,a.d=1/r;const l=new Path2D;if(l.addPath(t,a),o.length>0){const c=Math.max(i,r);s.setLineDash(o.map(d=>d/c)),s.lineDashOffset/=c}s.lineWidth=n||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const h in Te)ss.prototype[h]!==void 0&&(ss.prototype[Te[h]]=ss.prototype[h]);class Bn{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,s){this._source=t,this.#t=e,this.#e=s}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return Ot(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new this.#e(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){this._fullReader?.cancel(t);for(const e of new Set(this._rangeReaders))e.cancel(t)}}class jn{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(){ht("Abstract method `read` called")}cancel(t){ht("Abstract method `cancel` called")}}class _n{_stream=null;constructor(t,e,s){this._stream=t}async read(){ht("Abstract method `read` called")}cancel(t){ht("Abstract method `cancel` called")}}function Ll(h){let t=!0,e=s("filename\\*","i").exec(h);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=l(c),i(c)}if(e=r(h),e){const c=l(e);return i(c)}if(e=s("filename","i").exec(h),e){e=e[1];let c=a(e);return c=l(c),i(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function n(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(c,{fatal:!0}),f=Dn(d);d=u.decode(f),t=!1}catch{}}return d}function i(c){return t&&/[\x80-\xff]/.test(c)&&(c=n("utf-8",c),t&&(c=n("iso-8859-1",c))),c}function r(c){const d=[];let u;const f=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=f.exec(c))!==null;){let[,g,m,v]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[m,v]}const p=[];for(let g=0;g<d.length&&g in d;++g){let[m,v]=d[g];v=a(v),m&&(v=unescape(v),g===0&&(v=o(v))),p.push(v)}return p.join("")}function a(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){const f=d[u].indexOf('"');f!==-1&&(d[u]=d[u].slice(0,f),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){const d=c.indexOf("'");if(d===-1)return c;const u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return n(u,p)}function l(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-f]{2})/gi,function(g,m){return String.fromCharCode(parseInt(m,16))}),n(u,p);try{p=atob(p)}catch{}return n(u,p)})}return""}function ma(h,t){const e=new Headers;if(!h||!t||typeof t!="object")return e;for(const s in t){const n=t[s];n!==void 0&&e.append(s,n)}return e}function Bl(h){let t=h.length;for(;t>0&&h[t-1]!==" "&&/\s/.test(h[t-1]);)t--;return h.slice(0,t)}function Un(h){return URL.parse(h)?.origin??null}function va({responseHeaders:h,isHttp:t,rangeChunkSize:e,disableRange:s}){const n={contentLength:0,isRangeSupported:!1},i=parseInt(h.get("Content-Length"),10);return!Number.isInteger(i)||(n.contentLength=i,i<=2*e)||s||!t||h.get("Accept-Ranges")!=="bytes"||(h.get("Content-Encoding")||"identity")==="identity"&&(n.isRangeSupported=!0),n}function ya(h){const t=h.get("Content-Disposition");if(t){let e=Ll(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ii(e))return e}return null}
47function $n(h,t){return new En(`Unexpected server response (${h}) while retrieving PDF "${t.href}".`,h,h===404||h===0&&t.protocol==="file:")}function ba(h,t){if(h!==t)throw new Error(`Expected range response-origin "${h}" to match "${t}".`)}function xa(h,t,e,s){return fetch(h,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function Aa(h,t){if(h!==200&&h!==206)throw $n(h,t)}function Hn(h){if(h instanceof Uint8Array)return h.buffer;if(h instanceof ArrayBuffer)return h;throw new Error(`getArrayBuffer - unexpected data: ${h}`)}class jl extends Bn{_responseOrigin=null;constructor(t){super(t,_l,Ul);const{httpHeaders:e,url:s}=t;Ot(/https?:/.test(s.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=ma(!0,e)}}class _l extends jn{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:s,rangeChunkSize:n,url:i,withCredentials:r}=t._source;this._isStreamingSupported=!s;const a=new Headers(t.headers);xa(i,a,r,this._abortController).then(o=>{t._responseOrigin=Un(o.url),Aa(o.status,i),this._reader=o.body.getReader();const l=o.headers,{contentLength:c,isRangeSupported:d}=va({responseHeaders:l,isHttp:!0,rangeChunkSize:n,disableRange:e});this._contentLength=c,this._isRangeSupported=d,this._filename=ya(l),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $e("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:Hn(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ul extends _n{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);const{url:n,withCredentials:i}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`),xa(n,r,i,this._abortController).then(a=>{const o=Un(a.url);ba(o,t._responseOrigin),Aa(a.status,n),this._reader=a.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:Hn(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function Gr(h){return h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength?h.buffer:new Uint8Array(h).buffer}function zn(){for(const h of this._requests)h.resolve({value:void 0,done:!0});this._requests.length=0}class $l extends Bn{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,Hl,zl);const{pdfDataRangeTransport:e}=t,{initialData:s,progressiveDone:n}=e;if(s?.length>0){const r=Gr(s);this._queuedChunks.push(r)}this._progressiveDone=n;const i=r=>{switch(r.type){case"range":case"progressiveRead":this.#t(r.begin,r.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0;break}};e.transportReady(i)}#t(t,e){const s=Gr(e);if(t===void 0)this._fullReader?this._fullReader._enqueue(s):this._queuedChunks.push(s);else{const n=this._rangeReaders.keys().find(i=>i._begin===t);Ot(n,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),n._enqueue(s)}}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){const s=super.getRangeReader(t,e);return s&&(s.onDone=()=>this._rangeReaders.delete(s),this._source.pdfDataRangeTransport.requestDataRange(t,e)),s}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class Hl extends jn{#t=zn.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:s,disableStream:n}=t._source,{length:i,contentDispositionFilename:r}=e;this._queuedChunks=t._queuedChunks||[];for(const o of this._queuedChunks)this._loaded+=o.byteLength;this._done=t._progressiveDone,this._contentLength=i,this._isStreamingSupported=!n,this._isRangeSupported=!s,Ii(r)&&(this._filename=r),this._headersCapability.resolve();const a=this._loaded;Promise.resolve().then(()=>{a>0&&this._loaded===a&&this._callOnProgress()})}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):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.#t()}progressiveDone(){this._done||=!0,this._queuedChunks.length===0&&this.#t()}}class zl extends _n{#t=zn.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,s){super(t,e,s),this._begin=e}_enqueue(t){this._done||(this._requests.length===0?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#t()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,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.#t(),this.onDone?.()}}const oi=200,Vr=206;
47function Gl(h){return typeof h!="string"?h:Dn(h).buffer}class Vl extends Bn{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,Wl,Xl);const{httpHeaders:e,url:s}=t;this.url=s,this.isHttp=/https?:/.test(s.protocol),this.headers=ma(this.isHttp,e)}_request(t){const e=new XMLHttpRequest,s={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,s),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(const[n,i]of this.headers)e.setRequestHeader(n,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.validateStatus=n=>n===Vr||n===oi):s.validateStatus=n=>n===oi,e.responseType="arraybuffer",Ot(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#s.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#s(t,e){const s=this.#t.get(t);if(!s||(t.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),t.readyState!==4)||!this.#t.has(t))return;if(this.#t.delete(t),t.status===0&&this.isHttp){s.onError(t.status);return}const n=t.status||oi;if(!s.validateStatus(n)){s.onError(t.status);return}const i=Gl(t.response);if(n===Vr){const r=t.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(r)?s.onDone(i):(Q('Missing or invalid "Content-Range" header.'),s.onError(0))}else i?s.onDone(i):s.onError(t.status)}_abortRequest(t){this.#t.has(t)&&(this.#t.delete(t),t.abort())}getRangeReader(t,e){const s=super.getRangeReader(t,e);return s&&(s.onClosed=()=>this._rangeReaders.delete(s)),s}}class Wl extends jn{#t=zn.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#n.bind(this),onProgress:this.#i.bind(this)})}#e(){const t=this._stream,{disableRange:e,rangeChunkSize:s}=t._source,n=this._fullRequestXhr;t._responseOrigin=Un(n.responseURL);const i=n.getAllResponseHeaders(),r=new Headers(i?Bl(i.trimStart()).split(/[\r\n]+/).map(l=>{const[c,...d]=l.split(": ");return[c,d.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=va({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:s,disableRange:e});this._contentLength=a,this._isRangeSupported=o,this._filename=ya(r),this._isRangeSupported&&t._abortRequest(n),this._headersCapability.resolve()}#s(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,this._cachedChunks.length===0&&this.#t()}#n(t){this._storedError=$n(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#i(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.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class Xl extends _n{#t=zn.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,s){super(t,e,s),this._requestXhr=t._request({begin:e,end:s,onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#n.bind(this),onProgress:null})}#e(){const t=Un(this._requestXhr?.responseURL);try{ba(t,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#n(0)}}#s(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#t(),this.onClosed?.()}#n(t){this._storedError??=$n(t,this._stream.url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}
47cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function wa(h,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),n=e.createReadStream(h,t);return s.toWeb(n)}class Yl extends Bn{constructor(t){super(t,Kl,Ql);const{url:e}=t;Ot(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class Kl extends jn{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:s,rangeChunkSize:n,url:i}=t._source;this._isStreamingSupported=!s,process.getBuiltinModule("fs/promises").lstat(i).then(a=>{const o=wa(i);this._reader=o.getReader();const{size:l}=a;this._contentLength=l,this._isRangeSupported=!e&&l>2*n,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $e("Streaming is disabled.")),this._headersCapability.resolve()}).catch(a=>{a.code==="ENOENT"&&(a=$n(0,i)),this._headersCapability.reject(a)})}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:Hn(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class Ql extends _n{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);const{url:n}=t._source;try{const i=wa(n,{start:e,end:s-1});this._reader=i.getReader(),this._readCapability.resolve()}catch(i){this._readCapability.reject(i)}}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:Hn(t),done:!1}}cancel(t){this._reader?.cancel(t)}}function Jl(h){return _s(h)?jl:se?Yl:Vl}class ws{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}class Zl{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}const Qe=Symbol("INTERNAL");class ql{#t=!1;#e=!1;#s=!1;#n=!0;constructor(t,{name:e,intent:s,usage:n,rbGroups:i}){this.#t=!!(t&te.DISPLAY),this.#e=!!(t&te.PRINT),this.name=e,this.intent=s,this.usage=n,this.rbGroups=i}get visible(){if(this.#s)return this.#n;if(!this.#n)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Qe&&ht("Internal method `_setVisible` called."),this.#s=s,this.#n=e}get serializable(){return{userSet:this.#s,visible:this.#n}}}class ki{#t=null;#e=new Map;#s=null;#n=null;#i;creator=null;name=null;constructor(t,e=te.DISPLAY,s=null){if(this.#i=t,this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,this.#n=t.order;for(const n of t.groups)this.#e.set(n.id,new ql(e,n));if(s){s.size!==this.#e.size&&ht("Incorrect serialized groupState.");for(const[n,i]of s)this.#e.get(n)._setVisible(Qe,i.visible,i.userSet)}else{if(t.baseState==="OFF")for(const n of this.#e.values())n._setVisible(Qe,!1);for(const n of t.on)this.#e.get(n)._setVisible(Qe,!0);for(const n of t.off)this.#e.get(n)._setVisible(Qe,!1)}this.#s=this.getHash()}}#a(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let n=1;n<e;n++){const i=t[n];let r;if(Array.isArray(i))r=this.#a(i);else if(this.#e.has(i))r=this.#e.get(i).visible;else return Q(`Optional content group not found: ${i}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return kn("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(Q(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#a(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return Q(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return Q(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return Q(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return Q(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return Q(`Unknown optional content policy ${t.policy}.`),!0}return Q(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){const n=this.#e.get(t);if(!n){Q(`Optional content group not found: ${t}`);return}if(s&&e&&n.rbGroups.length)for(const i of n.rbGroups)for(const r of i)r!==t&&this.#e.get(r)?._setVisible(Qe,!1,!0);n._setVisible(Qe,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":s=n;continue}const i=this.#e.get(n);if(i)switch(s){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!i.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#n?this.#n.slice():[...this.#e.keys()]:null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new yi;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}get serializable(){const t=new Map;for(const[e,s]of this.#e)t.set(e,s.serializable);return{data:this.#i,renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new ki(t,e,s)}}class tc{#t=null;#e=null;#s=0;#n=null;#i=null;get pagesNumber(){return this.#s}set pagesNumber(t){this.#s!==t&&(this.#s=t,this.#t=null,this.#e=null)}#a(){if(this.#t)return;const t=this.#s,e=this.#t=new Uint32Array(t);for(let s=0;s<t;s++)e[s]=s+1;this.#e=new Int32Array(e)}#r(){const t=new Map,e=this.#t;for(let s=0,n=this.#s;s<n;s++){const i=e[s],r=t.get(i);r?r.push(s+1):t.set(i,[s+1])}return t}movePages(t,e,s){this.#a();const n=this.#t,i=e.length,r=new Uint32Array(i);let a=0;for(let u=0;u<i;u++){const f=e[u]-1;r[u]=n[f],f<s&&a++}const o=this.#s,l=o-i,c=new Int32Array(o),d=xt(s-a,0,l);for(let u=0,f=0;u<o;u++)t.has(u+1)||(n[f]=n[u],c[f++]=u+1);n.copyWithin(d+i,d,l),n.set(r,d),c.copyWithin(d+i,d,l),c.set(e,d),this.#e=c,n.every((u,f)=>u===f+1)&&(this.#t=null)}deletePages(t){this.#a();const e=this.#t,s=this.#r();this.#i={pageNumberToId:e.slice(),pagesNumber:this.#s,prevPageNumbers:this.#e.slice()};const n=this.#s-t.length;this.#s=n;const i=this.#t=new Uint32Array(n);this.#e=new Int32Array(n);let r=0,a=0;for(const o of t){const l=o-1;l!==r&&(i.set(e.subarray(r,l),a),a+=l-r),r=l+1}r<e.length&&i.set(e.subarray(r),a),this.#o(s,new Set(t))}cancelDelete(){this.#i&&(this.#t=this.#i.pageNumberToId,this.#s=this.#i.pagesNumber,this.#e=this.#i.prevPageNumbers,this.#i=null)}cleanSavedData(){this.#i=null}copyPages(t){this.#a(),this.#n={pageNumbers:t,pageIds:t.map(e=>this.#t[e-1])}}cancelCopy(){this.#n=null}pastePages(t){this.#a();const e=this.#t,s=this.#r(),{pageNumbers:n,pageIds:i}=this.#n,r=this.#s+n.length;this.#s=r;const a=this.#t=new Uint32Array(r);this.#e=new Int32Array(r),a.set(e.subarray(0,t),0),a.set(i,t),a.set(e.subarray(t),t+n.length),this.#o(s,null,t,n),this.#n=null}#o(t,e=null,s=-1,n=null){const i=this.#e,r=this.#t,a=s+(n?.length??0),o=new Map;for(let l=0,c=this.#s;l<c;l++){if(l>=s&&l<a){i[l]=-n[l-s];continue}const d=r[l],u=t.get(d);let f=o.get(d)||0;if(e&&u)for(;f<u.length&&e.has(u[f]);)f++;i[l]=u?.[f],o.set(d,f+1)}}hasBeenAltered(){return this.#t!==null}#l(t=null){if(!this.#t)return null;const e=new Int32Array(this.#s).fill(-1),s=new Map;if(t)for(const n of t){const i=this.getPageId(n),r=s.get(i)??0;s.set(i,r+1),e[n-1]=r}else for(let n=0,i=this.#s;n<i;n++){const r=this.#t[n],a=s.get(r)??0;s.set(r,a+1),e[n]=a}return e}getPageMappingForSaving(t=null,e=this.#l()){t??=this.#r();let s=0;for(const i of t.values())s=Math.max(s,i.length);const n=new Array(s);for(let i=0;i<s;i++)n[i]={document:null,pageIndices:[],includePages:[]};for(const[i,r]of t)for(let a=0,o=r.length;a<o;a++)n[a].includePages.push([i-1,r[a]-1]);for(const{includePages:i,pageIndices:r}of n){i.sort((a,o)=>a[0]-o[0]);for(let a=0,o=i.length;a<o;a++)r.push(i[a][1]),i[a]=i[a][0]}return{pageInfos:n,copyLevels:e}}extractPages(t){t=Array.from(t).sort((s,n)=>s-n);const e=new Map;for(let s=0,n=t.length;s<n;s++){const i=this.getPageId(t[s]);e.getOrInsertComputed(i,Cs).push(s+1)}return this.getPageMappingForSaving(e,this.#l(t))}getPrevPageNumber(t){return this.#e?.[t-1]??0}getPageNumber(t){if(!this.#t)return t;const e=this.#t;for(let s=0,n=this.#s;s<n;s++)if(e[s]===t)return s+1;return 0}getPageId(t){return this.#t?.[t-1]??t}getMapping(){return this.#t?.subarray(0,this.pagesNumber)}}const vs=Symbol("INITIAL_DATA"),Wr=()=>({...Promise.withResolvers(),data:vs});class Sa{#t=new Map;get(t,e=null){if(e){const n=this.#t.getOrInsertComputed(t,Wr);return n.promise.then(()=>e(n.data)),null}const s=this.#t.get(t);if(!s||s.data===vs)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t.get(t);return!!e&&e.data!==vs}delete(t){const e=this.#t.get(t);return!e||e.data===vs?!1:(this.#t.delete(t),!0)}resolve(t,e=null){const s=this.#t.getOrInsertComputed(t,Wr);if(s.data!==vs)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){for(const{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(const[t,{data:e}]of this.#t)e!==vs&&(yield[t,e])}}const ec=1e5,Xr=30;class ee{#t=Promise.withResolvers();#e=null;#s=!1;#n=!!globalThis.FontInspector?.enabled;#i=null;#a=null;#r=null;#o=0;#l=0;#c=null;#u=null;#d=0;#f=0;#g=Object.create(null);#m=[];#h=null;#p=[];#v=new WeakMap;#y=null;static#b=new Map;static#x=new Map;static#S=new WeakMap;static#w=null;static#E=new Set;constructor({textContentSource:t,images:e,container:s,viewport:n}){if(t instanceof ReadableStream)this.#h=t;else if(typeof t=="object")this.#h=new ReadableStream({start(l){l.enqueue(t),l.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#u=s,this.#i=e,this.#f=n.scale*ge.pixelRatio,this.#d=n.rotation,this.#r={div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:r,pageX:a,pageY:o}=n.rawDims;this.#y=[1,0,0,-1,-a,o+r],this.#l=i,this.#o=r,ee.#R(),s.style.setProperty("--min-font-size",ee.#w),ns(s,n),this.#t.promise.finally(()=>{ee.#E.delete(this),this.#r=null,this.#g=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=mt.platform;return Y(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){this.#i&&this.#e.append(this.#i.render());const t=()=>{this.#c.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#a??=e.lang,Object.assign(this.#g,e.styles),this.#T(e.items),t()},this.#t.reject)};return this.#c=this.#h.getReader(),ee.#E.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*ge.pixelRatio,n=t.rotation;if(n!==this.#d&&(e?.(),this.#d=n,ns(this.#u,{rotation:n})),s!==this.#f){e?.(),this.#f=s;const i={div:null,properties:null,ctx:ee.#P(this.#a)};for(const r of this.#p)i.properties=this.#v.get(r),i.div=r,this.#I(i)}}cancel(){const t=new $e("TextLayer task cancelled.");this.#c?.cancel(t).catch(()=>{}),this.#c=null,this.#t.reject(t)}get textDivs(){return this.#p}get textContentItemsStr(){return this.#m}#T(t){if(this.#s)return;this.#r.ctx??=ee.#P(this.#a);const e=this.#p,s=this.#m;for(const n of t){if(e.length>ec){Q("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(n.str===void 0){if(n.type==="beginMarkedContentProps"||n.type==="beginMarkedContent"){const i=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),n.id&&this.#e.setAttribute("id",n.id),n.tag==="Artifact"&&(this.#e.ariaHidden=!0),i.append(this.#e)}else n.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(n.str),this.#M(n)}}#M(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#p.push(e);const n=L.transform(this.#y,t.transform);let i=Math.atan2(n[1],n[0]);const r=this.#g[t.fontName];r.vertical&&(i+=Math.PI/2);let a=this.#n&&r.fontSubstitution||r.fontFamily;a=ee.fontFamilyMap.get(a)||a;const o=Math.hypot(n[2],n[3]),l=o*ee.#k(a,r,this.#a);let c,d;
47i===0?(c=n[4],d=n[5]-l):(c=n[4]+l*Math.sin(i),d=n[5]-l*Math.cos(i));const u=e.style;u.left=`${(100*c/this.#l).toFixed(2)}%`,u.top=`${(100*d/this.#o).toFixed(2)}%`,u.setProperty("--font-height",`${o.toFixed(2)}px`),u.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#n&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),i!==0&&(s.angle=i*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const p=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);p!==g&&Math.max(p,g)/Math.min(p,g)>1.5&&(f=!0)}if(f&&(s.canvasWidth=r.vertical?t.height:t.width),this.#v.set(e,s),this.#r.div=e,this.#r.properties=s,this.#I(this.#r),s.hasText&&this.#e.append(e),s.hasEOL){const p=document.createElement("br");p.setAttribute("role","presentation"),this.#e.append(p)}}#I(t){const{div:e,properties:s,ctx:n}=t,{style:i}=e;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:r}=i,{canvasWidth:a,fontSize:o}=s;ee.#N(n,o*this.#f,r);const{width:l}=n.measureText(e.textContent);l>0&&i.setProperty("--scale-x",a*this.#f/l)}s.angle!==0&&i.setProperty("--rotate",`${s.angle}deg`)}static cleanup(){if(!(this.#E.size>0)){this.#b.clear();for(const{canvas:t}of this.#x.values())t.remove();this.#x.clear()}}static#P(t=null){let e=this.#x.get(t||="");if(!e){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#x.set(t,e),this.#S.set(e,{size:0,family:""})}return e}static#N(t,e,s){const n=this.#S.get(t);e===n.size&&s===n.family||(t.font=`${e}px ${s}`,n.size=e,n.family=s)}static#R(){if(this.#w!==null)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.#w=t.getBoundingClientRect().height,t.remove()}static#k(t,e,s){const n=this.#b.get(t);if(n)return n;const i=this.#P(s);i.canvas.width=i.canvas.height=Xr,this.#N(i,Xr,t);const r=i.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let l=.8;return a?l=a/(a+o):(mt.platform.isFirefox&&Q("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.desce
47nt)),this.#b.set(t,l),l}}const sc=100;function Ea(h={}){const t=new Di,{docId:e}=t,s=h.url?ol(h.url):null,n=h.data?ll(h.data):null,i=h.httpHeaders||null,r=h.withCredentials===!0,a=h.password??null,o=h.range instanceof Ta?h.range:null,l=Number.isInteger(h.rangeChunkSize)&&h.rangeChunkSize>0?h.rangeChunkSize:2**16;let c=h.worker instanceof Vs?h.worker:null;const d=h.verbosity,u=typeof h.docBaseUrl=="string"&&!Fn(h.docBaseUrl)?h.docBaseUrl:null,f=dn(h.cMapUrl),p=h.cMapPacked!==!1,g=dn(h.iccUrl),m=dn(h.standardFontDataUrl),v=dn(h.wasmUrl),y=h.stopAtErrors!==!0,b=Number.isInteger(h.maxImageSize)&&h.maxImageSize>-1?h.maxImageSize:-1,S=typeof h.isOffscreenCanvasSupported=="boolean"?h.isOffscreenCanvasSupported:!se,x=typeof h.isImageDecoderSupported=="boolean"?h.isImageDecoderSupported:!se,w=Number.isInteger(h.canvasMaxAreaInBytes)?h.canvasMaxAreaInBytes:-1,E=typeof h.disableFontFace=="boolean"?h.disableFontFace:se,C=h.fontExtraProperties===!0,T=h.enableXfa===!0,O=h.ownerDocument||globalThis.document,I=h.disableRange===!0,M=h.disableStream===!0,N=h.disableAutoFetch===!0,D=h.pdfBug===!0,$=h.CanvasFactory||(se?ml:ul),k=h.FilterFactory||(se?gl:fl),F=h.BinaryDataFactory||(se?vl:Fr),W=h.enableHWA===!0,at=h.enableWebGPU===!0?Al():Promise.resolve(!1),bt=h.useWasm!==!1,J=h.pagesMapper||new tc,tt=typeof h.useSystemFonts=="boolean"?h.useSystemFonts:!se&&!E,dt=typeof h.useWorkerFetch=="boolean"?h.useWorkerFetch:!!(F===Fr&&f&&p&&m&&v&&_s(f,document.baseURI)&&_s(m,document.baseURI)&&_s(v,document.baseURI)),_t=null;Eo(d);const B={canvasFactory:new $({ownerDocument:O,enableHWA:W}),filterFactory:new k({docId:e,ownerDocument:O}),binaryDataFactory:dt?null:new F({cMapUrl:f,standardFontDataUrl:m,wasmUrl:v})};c||(c=Vs.create({verbosity:d,port:ws.workerPort}),t._worker=c);const R={docId:e,apiVersion:"6.3.289",data:n,password:a,disableAutoFetch:N,rangeChunkSize:l,docBaseUrl:u,enableXfa:T,evaluatorOptions:{maxImageSize:b,disableFontFace:E,ignoreErrors:y,isOffscreenCanvasSupported:S,isImageDecoderSupported:x,canvasMaxAreaInBytes:w,fontExtraProperties:C,useSystemFonts:tt,useWasm:bt,useWorkerFetch:dt,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:v,hasGPU:!1}},j={ownerDocument:O,pdfBug:D,styleElement:_t,enableHWA:W,loadingParams:{disableAutoFetch:N,enableXfa:T}};return Promise.all([c.promise,at]).then(function([,K]){if(c.destroyed)throw new Error("Worker was destroyed");R.evaluatorOptions.hasGPU=K;const ct=c.messageHandler.sendWithPromise("GetDocRequest",R,n?[n.buffer]:null);let X;if(!n)if(o)X=new $l({pdfDataRangeTransport:o,disableRange:I,disableStream:M});else if(s){const nt=Jl(s);X=new nt({url:s,httpHeaders:i,withCredentials:r,rangeChunkSize:l,disableRange:I,disableStream:M})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return ct.then(nt=>{if(c.destroyed)throw new Error("Worker was destroyed");const ut=new Bs(e,nt,c.port),kt=new ic(ut,t,X,j,B,J);if(t._transport=kt,t.destroyed)throw new Error("Loading aborted");ut.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}class Di{static#t=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${Di.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,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 Ta{#t=Promise.withResolvers();#e=null;constructor(t,e,s=!1,n=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=n}onDataRange(t,e){this.#e({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#t.promise.then(()=>{this.#e({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#t.promise.then(()=>{this.#e({type:"progressiveDone"})})}transportReady(t){this.#e=t,this.#t.resolve()}requestDataRange(t,e){ht("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class nc{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 Y(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()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}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}
vendor: 2,412 bytes, line 47
47=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,e=null){return this._transport.extractPages(t,e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(t){return this._transport.getSignatureData(t)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Fi{#t=!1;#e=null;constructor(t,e,s,n,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Ar:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Sa,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=n,this.imageCoordinates=null}clone(t){const e=new Fi(t,this._pageInfo,this._transport,this.#e,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:n=0,dontFlip:i=!1}={}){return new Ys({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:i})}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 Y(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}
47render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:n="display",annotationMode:i=_e.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1,recordImages:f=!1,recordOperations:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");const m=this._transport.getRenderingIntent(n,i,d,u),{renderingIntent:v,cacheKey:y}=m;this.#t=!1,o||=this._transport.getOptionalContentConfig(v);const b=this._intentStates.getOrInsertComputed(y,fi);b.streamReaderCancelTimeout&&(clearTimeout(b.streamReaderCancelTimeout),b.streamReaderCancelTimeout=null);const S=!!(v&te.PRINT);b.displayReadyCapability||(b.displayReadyCapability=Promise.withResolvers(),b.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(m));const x=!!(this._pdfBug&&globalThis.StepperManager?.enabled),w=!!e&&!this.recordedBBoxes&&(p||x),E=!!e&&!this.imageCoordinates&&f,C=N=>{if(b.renderTasks.delete(I),w){const D=I.gfx?.dependencyTracker.take();D&&(I.stepper?.setOperatorBBoxes(D,I.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=D))}E&&!N&&(this.imageCoordinates=I.gfx?.imagesTracker.take()),S&&(this.#t=!0),this.#s(),N?(I.capability.reject(N),this._abortOperatorList({intentState:b,reason:N instanceof Error?N:new Error(N)})):I.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let T=null,O=null;(w||E)&&(O=new Ko(e,b.operatorList.length)),w&&(T=new Qo(O,x));const I=new xs({callback:C,params:{canvas:e,canvasContext:t,dependencyTracker:T??O,imagesTracker:E?new Tn(e):null,viewport:s,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:b.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!S,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:g});(b.renderTasks||=new Set).add(I);const M=I.task;return Promise.all([b.displayReadyCapability.promise,o]).then(([N,D])=>{if(this.destroyed){C();return}if(this._stats?.time("Rendering"),!(D.renderingIntent&v))throw new Error("Mu
47st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:N,optionalContentConfig:D}),I.operatorListChanged()}).catch(C),M}getOperatorList({intent:t="display",annotationMode:e=_e.ENABLE,printAnnotationStorage:s=null,isEditing:n=!1}={}){function i(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}const r=this._transport.getRenderingIntent(t,e,s,n,!0),a=this._intentStates.getOrInsertComputed(r.cacheKey,fi);let o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=i,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(n){return n.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>Hs.textContent(n));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const n of e)s.lang??=n.lang,Object.assign(s.styles,n.styles),s.items.push(...n.items);return s}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 s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;const e=this.#s();return t&&e&&(this._stats&&=new Ar),e}#s(){if(!this.#t||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.#t=!1,!0}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,n=t.length;s<n;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#s()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:n}){const{map:i,transfer:r}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:i,modifiedIds:n},void 0,r).getReader(),l=this._intentStates.get(e);l.streamReader=o;const c=()=>{o.read().then(({value:d,done:u})=>{if(u){l.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,l),c())},d=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const u of l.renderTasks)u.operatorListChanged();this.#s()}if(l.displayReadyCapability)l.displayReadyCapability.reject(d);else if(l.opListReadCapability)l.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Pi){let n=sc;e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n);return}}if(t.streamReader.cancel(new $e(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[n,i]of this._intentStates)if(i===t){this._intentStates.delete(n);break}this.cleanup()}}}get stats(){return this._stats}}var Ue,fe,ke,qe,Mn,ts,es,Vt,wn,Ca,Pa,js,Ss,Sn;const Mt=class Mt{constructor({name:t=null,port:e=null,verbosity:s=To()}={}){xe(this,Vt);xe(this,Ue,Promise.withResolvers());xe(this,fe,null);xe(this,ke,null);xe(this,qe,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(Tt(Mt,es).has(e))throw new Error("Cannot use more than one PDFWorker per port.");Tt(Mt,es).set(e,this),Ae(this,Vt,Ca).call(this,e)}else Ae(this,Vt,Pa).call(this)}get promise(){return Tt(this,Ue).promise}get port(){return Tt(this,ke)}get messageHandler(){return Tt(this,fe)}destroy(){this.destroyed=!0,Tt(this,qe)?.terminate(),Kt(this,qe,null),Tt(Mt,es).delete(Tt(this,ke)),Kt(this,ke,null),Tt(this,fe)?.destroy(),Kt(this,fe,null)}static create(t){const e=Tt(this,es).get(t?.port);
47if(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 Mt(t)}static get workerSrc(){if(ws.workerSrc)return ws.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Y(this,"_setupFakeWorkerGlobal",(async()=>Tt(this,Ss,Sn)?Tt(this,Ss,Sn):(await import(this.workerSrc)).WorkerMessageHandler)())}};Ue=new WeakMap,fe=new WeakMap,ke=new WeakMap,qe=new WeakMap,Mn=new WeakMap,ts=new WeakMap,es=new WeakMap,Vt=new WeakSet,wn=function(){Tt(this,Ue).resolve(),Tt(this,fe).send("configure",{verbosity:this.verbosity})},Ca=function(t){Kt(this,ke,t),Kt(this,fe,new Bs("main","worker",t)),Tt(this,fe).on("ready",()=>{}),Ae(this,Vt,wn).call(this)},Pa=function(){if(Tt(Mt,ts)||Tt(Mt,Ss,Sn)){Ae(this,Vt,js).call(this);return}let{workerSrc:t}=Mt;try{Mt._isSameOrigin(window.location,t)||(t=Mt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Bs("main","worker",e),n=()=>{i.abort(),s.destroy(),e.terminate(),this.destroyed?Tt(this,Ue).reject(new Error("Worker was destroyed")):Ae(this,Vt,js).call(this)},i=new AbortController;e.addEventListener("error",()=>{Tt(this,qe)||n()},{signal:i.signal}),s.on("test",a=>{if(i.abort(),this.destroyed||!a){n();return}Kt(this,fe,s),Kt(this,ke,e),Kt(this,qe,e),Ae(this,Vt,wn).call(this)}),s.on("ready",a=>{if(i.abort(),this.destroyed){n();return}try{r()}catch{Ae(this,Vt,js).call(this)}});const r=()=>{const a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{kn("The worker has been disabled.")}Ae(this,Vt,js).call(this)},js=function(){Tt(Mt,ts)||(Q("Setting up fake worker."),Kt(Mt,ts,!0)),Mt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){Tt(this,Ue).reject(new Error("Worker was destroyed"));return}const e=new dl;Kt(this,ke,e);const s=`fake${ar(Mt,Mn)._++}`,n=new Bs(s+"_worker",s,e);t.setup(n,e),Kt(this,fe,new Bs(s,s+"_worker",e)),Ae(this,Vt,wn).call(this)}).catch(t=>{Tt(this,Ue).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Ss=new WeakSet,Sn=function(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}},xe(Mt,Ss),xe(Mt,Mn,0),xe(Mt,ts,!1),xe(Mt,es,new WeakMap),se&&(Kt(Mt,ts,!0),ws.workerSrc||="./pdf.worker.mjs"),Mt._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!s?.origin||s.origin==="null")return!1;const n=new URL(e,s);return s.origin===n.origin},Mt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Vs=Mt;class ic{downloadInfoCapability=Promise.withResolvers();#t=null;#e=new Map;#s=null;#n=new Map;#i=new Map;#a=new Map;#r=null;constructor(t,e,s,n,i,r){this.messageHandler=t,this.loadingTask=e,this.#s=s,this.commonObjs=new Sa,this.fontLoader=new Zo({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.enableHWA=n.enableHWA,this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.binaryDataFactory=i.binaryDataFactory,this.pagesMapper=r,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;this.#n.set(e,t),this.#i.set(e,Promise.resolve(t))}#o(t,e=null){return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#l({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?xt(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return Y(this,"annotationStorage",new Ri)}getRenderingIntent(t,e=_e.ENABLE,s=null,n=!1,i=!1){let r=te.DISPLAY,a=zs;switch(t){case"any":r=te.ANY;break;case"display":break;case"print":r=te.PRINT;break;default:Q(`getRenderingIntent - invalid intent: ${t}`)}const o=r&te.PRINT&&s instanceof da?s:this.annotationStorage;switch(e){case _e.DISABLE:r+=te.ANNOTATIONS_DISABLE;break;case _e.ENABLE:break;case _e.ENABLE_FORMS:r+=te.ANNOTATIONS_FORMS;break;case _e.ENABLE_STORAGE:r+=te.ANNOTATIONS_STORAGE,a=o.serializable;break;default:Q(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(r+=te.IS_EDITING),i&&(r+=te.OPLIST);const{ids:l,hash:c}=o.modifiedIds,d=[r,a.hash,c];return{renderingIntent:r,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#n.values())t.push(s._destroy());this.#n.clear(),this.#i.clear(),this.#a.clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();
47const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),ee.cleanup(),this.#s?.cancelAllRequests(new $e("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",(s,n)=>{Ot(this.#s,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#s.getFullReader(),this.#t.onProgress=i=>this.#l(i),n.onPull=()=>{this.#t.read().then(function({value:i,done:r}){if(r){n.close();return}Ot(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(i),1,[i])}).catch(i=>{n.error(i)})},n.onCancel=i=>{this.#t.cancel(i),n.ready.catch(r=>{if(!this.destroyed)throw r})}}),t.on("ReaderHeadersReady",async s=>{await this.#t.headersReady;const{isStreamingSupported:n,isRangeSupported:i,contentLength:r}=this.#t;return n&&i&&(this.#t.onProgress=null),{isStreamingSupported:n,isRangeSupported:i,contentLength:r}}),t.on("GetRangeReader",(s,n)=>{Ot(this.#s,"GetRangeReader - no `BasePDFStream` instance available.");const i=this.#s.getRangeReader(s.begin,s.end);if(!i){n.close();return}n.onPull=()=>{i.read().then(function({value:r,done:a}){if(a){n.close();return}Ot(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{n.error(r)})},n.onCancel=r=>{i.cancel(r),n.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new nc(s,this))}),t.on("DocException",s=>{e._capability.reject(Qt(s))}),t.on("PasswordRequest",s=>{this.#r=Promise.withResolvers();try{if(!e.onPassword)throw Qt(s);const n=i=>{i instanceof Error?this.#r.reject(i):this.#r.resolve({password:i})};e.onPassword(n,s.code)}catch(n){this.#r.reject(n)}return this.#r.promise}),t.on("DataLoaded",s=>{this.#l({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;this.#n.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,n,i])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(n){case"Font":if("error"in i){const d=i.error;Q(`Error during font loading: ${d}`),this.commonObjs.resolve(s,d);break}const r=new il(i),a=this._params.pdfBug&&globalThis.FontInspector?.enabled?(d,u)=>globalThis.FontInspector.fontAdded(d,u):null,o=new qo(r,a,i.charProcOperatorList,i.extra);this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{o.fontExtraProperties||o.clearData(),this.commonObjs.resolve(s,o)});break;case"CopyLocalImage":const{imageRef:l}=i;Ot(l,"The imageRef must be defined.");for(const d of this.#n.values())for(const[,u]of d.objs){if(u?.ref!==l)continue;if(!u.dataLen)return null;const f=structuredClone(u);return this.commonObjs.resolve(s,f),u.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new al(i));break;case"Image":this.commonObjs.resolve(s,i);break;case"Pattern":const c=new rl(i);this.commonObjs.resolve(s,c.getIR());break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([s,n,i,r])=>{if(this.destroyed)return;const a=this.#n.get(n);if(!a.objs.has(s)){if(a._intentStates.size===0){r?.bitmap?.close();return}switch(i){case"Image":case"Pattern":a.objs.resolve(s,r);break;default:throw new Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",s=>{this.destroyed||this.#l(s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Q("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;
47return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#t?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t,e=null){const s={pageInfos:t};let n;const i=globalThis.ImageBitmap;if(typeof i=="function"){const r=Array.isArray(t)?t:[t];for(const a of r)a?.image instanceof i&&(n||=[]).push(a.image)}if(this.annotationStorage.size>0){const r=this.annotationStorage.serializable;let{map:a}=r;r.transfer?.length&&(n?n.push(...r.transfer):n=r.transfer);const o=this.pagesMapper.getMapping();if(o){const l=new Map;for(const[c,d]of a){if(d?.pageIndex!==void 0&&d.pageIndex>=0&&d.pageIndex<o.length){const u=e?.[d.pageIndex]??0,f=o[d.pageIndex]-1;if(f!==d.pageIndex||u!==0){l.set(c,{...d,pageIndex:f,copyLevel:u});continue}}l.set(c,d)}a=l}s.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",s,n).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,n=this.#i.get(e);if(n)return n;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&this.#a.set(r.refStr,s);const a=new Fi(e,r,this,this.pagesMapper,this._params.pdfBug);return this.#n.set(e,a),a});return this.#i.set(e,i),i}async getPageIndex(t){if(!xi(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#o("GetFieldObjects")}getSignatures(){return this.#o("GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return this.#o("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?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)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#o("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.#o("GetOptionalContentConfig").then(e=>new ki(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>({info:e[0],metadata:e[1]?new Zl(e[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithProm
47ise("Cleanup",null);for(const e of this.#n.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),ee.cleanup()}}cachedPageNumber(t){if(!xi(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=this.#a.get(e);if(s>=0){const n=this.pagesMapper.getPageNumber(s+1);if(n!==0)return n}return null}}class rc{_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}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class xs{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:n,annotationCanvasMap:i,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null,enableHWA:f=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=n,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new rc(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=f,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,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(xs.#e.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.");xs.#e.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:s,transform:n,background:i,dependencyTracker:r,imagesTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new ss(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r,a),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:i}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),xs.#e.delete(this._canvas),t||=new Pi(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=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(),xs.#e.delete(this._canvas),this.callback())))}}const ac="6.3.289",oc="1c8020a7d";st(3068);class ce{#t=null;#e=null;#s;#n=null;#i=!1;#a=!1;#r=null;#o;#l=null;#c=null;static#u=null;static get _keyboardManager(){return Y(this,"_keyboardManager",new ne([[["Escape"],ce.prototype._hideDropdownFromKeyboard],[["Space"],ce.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],ce.prototype._moveToNext],[["ArrowUp","ArrowLeft"],ce.prototype._moveToPrevious],[["Home"],ce.prototype._moveToBeginning],[["End"],ce.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#a=!1,this.#r=t):this.#a=!0,this.#c=t?._uiManager||e,this.#o=this.#c._eventBus,this.#s=t?.color?.toUpperCase()||this.#c?.highlightColors.values().next().value||"#FFFF98",ce.#u||=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.#t=document.createElement("button");
47t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#r&&(t.ariaControls=`${this.#r.id}_colorpicker_dropdown`);const e=this.#c._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#g.bind(this),{signal:e});const s=this.#e=document.createElement("span");return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=this.#s,t.append(s),t}renderMainDropdown(){const t=this.#n=this.#d();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#d(){const t=document.createElement("div"),e=this.#c._signal;t.addEventListener("contextmenu",pe,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#r&&(t.id=`${this.#r.id}_colorpicker_dropdown`);for(const[s,n]of this.#c.highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",n),i.title=s,i.setAttribute("data-l10n-id",ce.#u[s]);const r=document.createElement("span");i.append(r),r.className="swatch",r.style.backgroundColor=n,i.ariaSelected=n===this.#s,i.addEventListener("click",this.#f.bind(this,n),{signal:e}),t.append(i)}return t.addEventListener("keydown",this.#g.bind(this),{signal:e}),t}#f(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:lt.HIGHLIGHT_COLOR,value:t}),this.update(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}const e=t.target.getAttribute("data-color");e&&this.#f(e,t)}_moveToNext(t){if(!this.#p){this.#m(t);return}if(t.target===this.#t){this.#n.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#n?.firstElementChild||t.target===this.#t){this.#p&&this._hideDropdownFromKeyboard();return}this.#p||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#p){this.#m(t);return}this.#n.firstElementChild?.focus()}_moveToEnd(t){if(!this.#p){this.#m(t);return}this.#n.lastElementChild?.focus()}#g(t){ce._keyboardManager.exec(this,t)}#m(t){if(this.#p){this.hideDropdown();return}if(this.#i=t.detail===0,this.#l||(this.#l=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#c.combinedSignal(this.#l)})),this.#t.ariaExpanded="true",this.#n){this.#n.classList.remove("hidden");return}const e=this.#n=this.#d();this.#t.append(e)}#h(t){this.#n?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#n?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#l?.abort(),this.#l=null}get#p(){return this.#n&&!this.#n.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#a){if(!this.#p){this.#r?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#i})}}update(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#n)return;const e=this.#c.highlightColors.values();for(const s of this.#n.children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#n?.remove(),this.#n=null}}class Ws{#t=null;#e=!1;#s=null;#n=null;static#i=null;constructor(t){this.#s=t,this.#n=t._uiManager,Ws.#i||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:n,color:i,opacity:r}=this.#s,a=this.#e=mt.isAlphaColorInputSupported&&n!==void 0,o=this.#t=document.createElement("input");if(o.type="color",a){o.setAttribute("alpha","");const l=L.hexNums[Math.round((r??1)*255)];o.value=(i||"#000000")+l}else o.value=i||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",Ws.#i[t]),o.addEventListener("input",()=>{if(a){const l=Ks(o.value);if(!l)return;const[c,d,u,f]=l,p=L.makeHexColor(c,d,u);s!==void 0?this.#n.updateParams(s,{color:p,opacity:f}):(this.#n.updateParams(e,p),this.#n.updateParams(n,f))}else this.#n.updateParams(e,o.value)},{signal:this.#n._signal}),o}update(t){if(this.#t)if(this.#e){const e=L.hexNums[Math.round(this.#s.opacity*255)];this.#t.value=t+e}else this.#t.value=t}updateOpacity(t){if(!this.#t||!this.#e)return;const e=L.hexNums[Math.round(t*255)];this.#t.value=this.#s.color+e}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}st(531);function Yr(h){return Math.floor(xt(h,0,1)*255).toString(16).padStart(2,"0")}function Ds(h){return xt(h,0,1)*255}class Kr{static CMYK_G([t,e,s,n]){return["G",1-Math.min(1,.3*t+.59*s+.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=Ds(t),[t,t,t]}static G_HTML([t]){const e=Yr(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Ds)}static RGB_HTML(t){return`#${t.map(Yr).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,s+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,s,n]){return[Ds(1-Math.min(1,t+n)),Ds(1-Math.min(1,s+n)),Ds(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,s]){const n=1-t,i=1-e,r=1-s,a=Math.min(n,i,r);return["CMYK",n,i,r,a]}}class lc{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),s||(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(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){ht("Abstract method `_createSVG` called.")}}class Pn extends lc{_createSVG(t){return document.createElementNS(Gt,t)}}const cc=9,is=new WeakSet,hc=new Date().getTimezoneOffset()*60*1e3;class li{static create(t){switch(t.data.annotationType){case It.LINK:return new Li(t);case It.TEXT:return new uc(t);case It.WIDGET:switch(t.data.fieldType){case"Tx":return new fc(t);case"Btn":return t.data.radioButton?new mc(t):t.data.checkBox?new gc(t):new vc(t);case"Ch":return new yc(t);case"Sig":return new pc(t)}return new as(t);case It.POPUP:return new Ai(t);case It.FREETEXT:return new Ia(t);case It.LINE:return new xc(t);case It.SQUARE:return new Ac(t);case It.CIRCLE:return new wc(t);case It.POLYLINE:return new Oa(t);case It.CARET:return new Ec(t);case It.INK:return new Bi(t);case It.POLYGON:return new Sc(t);case It.HIGHLIGHT:return new Ma(t);case It.UNDERLINE:return new Tc(t);case It.SQUIGGLY:return new Cc(t);case It.STRIKEOUT:return new Pc(t);case It.STAMP:return new Ra(t);case It.FILEATTACHMENT:return new Ic(t);case It.RICHMEDIA:case It.SCREEN:case It.SOUND:return new Na(t);default:return new Ct(t)}}}class Ct{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!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(s)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Ct._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}
47get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:n}=this.data;let i=-1/0,r=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)e[a+1]>r?(r=e[a+1],i=e[a+2]):e[a+1]===r&&(i=Math.max(i,e[a+2]));return[i,r]}if(s?.length>=1){for(const a of s)for(let o=0,l=a.length;o<l;o+=2)a[o+1]>r?(r=a[o+1],i=a[o]):a[o+1]===r&&(i=Math.max(i,a[o]));if(i!==1/0)return[i,r]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:n,pageX:i,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-i)/s,t[1]=100*(t[1]-r)/n,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${Es}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${Es}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#s?.popup||this.popup)?.remove(),this.#s=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#t||={rect:this.data.rect.slice(0)});const{rect:e,popup:s}=t;e&&this.#n(e);let n=this.#s?.popup||this.popup;!n&&s?.text&&(this._createPopup(s),n=this.#s.popup),n&&(n.updateEdited(t),s?.deleted&&(n.remove(),this.#s=null,this.popup=null))}resetEdited(){this.#t&&(this.#n(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#n(t){const{container:{style:e},data:{rect:s,rotation:n},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:r,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t),e.left=`${100*(t[0]-a)/i}%`,e.top=`${100*(r-t[3]+o)/r}%`,n===0?(e.width=`${100*(t[2]-t[0])/i}%`,e.height=`${100*(t[3]-t[1])/r}%`):this.setRotation(n)}_createContainer(t){const{data:e,parent:{page:s,viewport:n}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),!(this instanceof as)&&!(this instanceof Li)&&!(this instanceof Na)&&(i.tabIndex=0);const{style:r}=i;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof Ai){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,i),i}const{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,m=e.borderStyle.verticalCornerRadius;if(g>0||m>0){const y=`calc(${g}px * var(--total-scale-factor)) / calc(${m}px * var(--total-scale-factor))`;r.borderRadius=y}switch(e.borderStyle.style){case ms.SOLID:r.borderStyle="solid";break;case ms.DASHED:r.borderStyle="dashed";break;case ms.BEVELED:Q("Unimplemented border style: beveled");break;case ms.INSET:Q("Unimplemented border style: inset");break;case ms.UNDERLINE:r.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(this.#e=!0,r.borderColor=L.makeHexColor(...v)):r.borderWidth=0}const l=L.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:f}=n.rawDims;r.left=`${100*(l[0]-u)/c}%`,r.top=`${100*(l[1]-f)/d}%`;const{rotation:p}=e;return e.hasOwnCanvas||p===0?(r.width=`${100*a/c}%`,r.height=`${100*o/d}%`):this.setRotation(p,i),i}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:n}=this.parent.viewport.rawDims;let{width:i,height:r}=this;t%180!==0&&([i,r]=[r,i]),e.style.width=`${100*i/s}%`,e.style.height=`${100*r/n}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,n)=>{const i=n.detail[e],r=i[0],a=i.slice(1);n.target.style[s]=Kr[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:Kr[`${r}_rgb`](a)})};return Y(this,"_commonActions",{display:e=>{const{display:s}=e.detail,n=s%2===1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>
47e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor: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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const n of Object.keys(e.detail))(t[n]||s[n])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[n,i]of Object.entries(e)){const r=s[n];if(r){const a={detail:{[n]:i},target:t};r(a),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,n,i]=this.data.rect.map(Math.fround);if(t.length===8){const[g,m,v,y]=t.subarray(2,6);if(n===g&&i===m&&e===v&&s===y)return}const{style:r}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:m}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Gt}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${g}" stroke-width="${m}">`],this.container.classList.add("hasBorder")}const o=n-e,l=i-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const u=c.createElement("defs");d.append(u);const f=c.createElement("clipPath"),p=`clippath_${this.data.id}`;f.setAttribute("id",p),f.setAttribute("clipPathUnits","objectBoundingBox"),u.append(f);for(let g=2,m=t.length;g<m;g+=8){const v=t[g],y=t[g+1],b=t[g+2],S=t[g+3],x=c.createElement("rect"),w=(b-e)/o,E=(i-y)/l,C=(v-b)/o,T=(y-S)/l;x.setAttribute("x",w),x.setAttribute("y",E),x.setAttribute("width",C),x.setAttribute("height",T),f.append(x),a?.push(`<rect vector-effect="non-scaling-stroke" x="${w}" y="${E}" width="${C}" height="${T}"/>`)}this.#e&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let s,n;t?(s={str:t.text},n=t.date):(s=e.contentsObj,n=e.modificationDate),this.#s=new Ai({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,contentsObj:s,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.#s||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#s}render(){ht("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const n=this._fieldObjects.get(t)||[];for(const{page:i,id:r,exportValues:a}of n){if(i===-1||r===e)continue;const o=typeof a=="string"?a:null,l=document.querySelector(`[data-element-id="${r}"]`);if(l&&!is.has(l)){Q(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:l})}return s}for(const n of document.getElementsByName(t)){const{exportValue:i}=n,r=n.getAttribute("data-element-id");r!==e&&is.has(n)&&s.push({id:r,exportValue:i,domElement:n})}return s}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})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}
47_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":L.makeHexColor(...e)}}class dc extends Ct{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 Li extends Ct{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,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let n=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(s,t.action,t.overlaidText),n=!0):t.attachment?(this.#e(s,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),n=!0):t.setOCGState?(this.#s(s,t.setOCGState,t.overlaidText),n=!0):t.dest?(this._bindLink(s,t.dest,t.overlaidText),n=!0):(t.actions&&(t.actions.has("Action")||t.actions.has("Mouse Up")||t.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),n=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(s,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&(this.contentElement=s,this.container.append(s)),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t(),s&&(t.title=s)}_bindNamedAction(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s&&(t.title=s),this.#t()}#e(t,e,s,n="",i=null){t.href=this.linkService.getAnchorUrl(""),s.description?t.title=s.description:n&&(t.title=n);const r=async()=>{const a=await this.linkService.getAttachmentContent(e);a&&this.downloadManager?.openOrDownloadData(a,s.filename,i)};t.onclick=()=>(r(),!1),this.#t()}#s(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s&&(t.title=s),this.#t()}_bindJSAction(t,{actions:e,id:s,overlaidText:n}){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of e.keys()){const a=i.get(r);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:r}}),!1))}n&&(t.title=n),t.onclick||=()=>!1,this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){Q('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:n,refs:i,include:r}=e,a=[];if(n.length!==0||i.length!==0){const c=new Set(i);for(const d of n){const u=this._fieldObjects.get(d)||[];for(const{id:f}of u)c.add(f)}for(const d of this._fieldObjects.values())for(const u of d)c.has(u.id)===r&&a.push(u)}else for(const c of this._fieldObjects.values())a.push(...c);const o=this.annotationStorage,l=[];for(const c of a){const{id:d}=c;switch(l.push(d),c.type){case"text":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}case"checkbox":case"radiobutton":{const f=c.defaultValue===c.exportValues;o.setValue(d,{value:f});break}case"combobox":case"listbox":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!is.has(u)){Q(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}}class uc extends Ct{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}}
47class as extends Ct{render(){return this.container}_getKeyModifier(t){return mt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,n,i){s.includes("mouse")?t.addEventListener(s,r=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})}):t.addEventListener(s,r=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(r)}})})}_setEventListeners(t,e,s,n){const{actions:i}=this.data;for(const[r,a]of s)(a==="Action"||i?.has(a))&&((a==="Focus"||a==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,r,a,n),a==="Focus"&&!i?.has("Blur")?this._setEventListener(t,e,"blur","Blur",null):a==="Blur"&&!i?.has("Focus")&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||cc,i=t.style;let r;const a=2,o=l=>Math.round(10*l)/10;if(this.data.multiLine){const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(l/(1.35*n))||1,d=l/c;r=Math.min(n,o(d/1.35))}else{const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a);r=Math.min(n,o(l/1.35))}i.fontSize=`calc(${r}px * var(--total-scale-factor))`,i.color=L.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(i.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class fc extends as{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,n){const i=this.annotationStorage;
47for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=s),i.setValue(r.id,{[n]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const n=t.getValue(e,{value:this.data.fieldValue});let i=n.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&i.length>r&&(i=i.slice(0,r));let a=n.formattedValue||this.data.textContent?.join(`
48`)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:i,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=a??i,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",a??i),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),is.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:l,datetimeType:c,timeStep:d}=this.data,u=!!c&&this.enableScripting;l&&(s.title=l),this._setRequired(s,this.data.required),r&&(s.maxLength=r),s.addEventListener("input",p=>{t.setValue(e,{value:p.target.value}),this.setPropertyOnSiblings(s,"value",p.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",p=>{const g=this.data.defaultFieldValue??"";s.value=o.userValue=g,o.formattedValue=null});let f=p=>{const{formattedValue:g}=o;g!=null&&(p.target.value=g),p.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{if(o.focused)return;const{target:m}=g;if(u&&(m.type=c,d&&(m.step=d)),o.userValue){const v=o.userValue;if(u)if(c==="time"){const y=new Date(v),b=[y.getHours(),y.getMinutes(),y.getSeconds()];m.value=b.map(S=>S.toString().padStart(2,"0")).join(":")}else m.value=new Date(v-hc).toISOString().split(c==="date"?"T":".",1)[0];else m.value=v}o.lastCommittedValue=m.value,o.commitKey=1,this.data.actions?.has("Focus")||(o.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.container.classList.add("sandboxModified");const m={value(v){o.userValue=v.detail.value??"",u||t.setValue(e,{value:o.userValue.toString()}),v.target.value=o.userValue},formattedValue(v){const{formattedValue:y}=v.detail;o.formattedValue=y,y!=null&&v.target!==document.activeElement&&(v.target.value=y);const b={formattedValue:y};u&&(b.value=y),t.setValue(e,b)},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{const{charLimit:y}=v.detail,{target:b}=v;if(y===0){b.removeAttribute("maxLength");return}b.setAttribute("maxLength",y);let S=o.userValue;!S||S.length<=y||(S=S.slice(0,y),b.value=o.userValue=S,t.setValue(e,{value:S}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:S,willCommit:!0,commitKey:1,selStart:b.selectionStart,selEnd:b.selectionEnd}}))}};this._dispatchEventFromSandbox(m,g)}),s.addEventListener("keydown",g=>{o.commitKey=1;let m=-1;if(g.key==="Escape"?m=0:g.key==="Enter"&&!this.data.multiLine?m=2:g.key==="Tab"&&(o.commitKey=3),m===-1)return;const{value:v}=g.target;o.lastCommittedValue!==v&&(o.lastCommittedValue=v,o.userValue=v,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:m,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const p=f;f=null,s.addEventListener("blur",g=>{if(!o.focused||!g.relatedTarget)return;this.data.actions?.has("Blur")||(o.focused=!1);const{target:m}=g;let{value:v}=m;if(u){if(v&&c==="time"){const y=v.split(":").map(b=>parseInt(b,10));v=new Date(2e3,0,1,y[0],y[1],y[2]||0).valueOf(),m.step=""}else v.includes("T")||(v=`${v}T00:00`),v=new Date(v).valueOf();m.type="text"}o.userValue=v,o.lastCommittedValue!==v&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,
48commitKey:o.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}),p(g)}),this.data.actions?.has("Keystroke")&&s.addEventListener("beforeinput",g=>{o.lastCommittedValue=null;const{data:m,target:v}=g,{value:y,selectionStart:b,selectionEnd:S}=v;let x=b,w=S;switch(g.inputType){case"deleteWordBackward":{const E=/\w/;for(;x>0&&!E.test(y[x-1]);)x--;for(;x>0&&E.test(y[x-1]);)x--;break}case"deleteWordForward":{const E=y.substring(b).match(/^\W*\w*/);E&&(w+=E[0].length);break}case"deleteContentBackward":b===S&&(x-=1);break;case"deleteContentForward":b===S&&(w+=1);break}g.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,change:m||"",willCommit:!1,selStart:x,selEnd:w}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(f&&s.addEventListener("blur",f),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${g}px * var(--total-scale-factor))`);const m=this.data.textAlignment;if(m===1||m===2){const v=()=>{const y=r-s.value.length;s.style.setProperty("--comb-offset",`${m===1?y>>1:y}`)};v();for(const y of["input","blur","resetform","updatefromsandbox"])s.addEventListener(y,v)}}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class pc extends as{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class gc extends as{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof n=="string"&&(n=n!=="Off",t.setValue(s,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return is.add(i),i.setAttribute("data-element-id",s),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,n&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=0,i.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const l of this._getElementsByName(a,s)){const c=o&&l.exportValue===e.exportValue;l.domElement&&(l.domElement.checked=c),t.setValue(l.id,{value:c})}t.setValue(s,{value:o})}),i.addEventListener("resetform",r=>{const a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",r=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],r=>r.target.checked)),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class mc extends as{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof n=="string"&&(n=n!==e.buttonValue,t.setValue(s,{value:n})),n)for(const r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});const i=document.createElement("input");if(is.add(i),i.setAttribute("data-element-id",s),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=e.fieldName,n&&i.setAttribute("checked",!0),i.tabIndex=0,i.addEventListener("change",r=>{const{name:a,checked:o}=r.target;for(const l of this._getElementsByName(a,s))t.setValue(l.id,{value:!1});t.setValue(s,{value:o})}),i.addEventListener("resetform",r=>{const a=e.defaultFieldValue;r.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const r=e.buttonValue;i.addEventListener("updatefromsandbox",a=>{const o={value:l=>{const c=r===l.detail.value;for(const d of this._getElementsByName(l.target.name)){const u=c&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}
vendor: 8,803 bytes, line 48
48class vc extends Li{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",s=>{this._dispatchEventFromSandbox({},s)})),t}}class yc extends as{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");is.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 i=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",d=>{const u=this.data.defaultFieldValue;for(const f of n.options)f.selected=f.value===u});const r=(d,u)=>{const f=u.replaceAll(" "," ");d.textContent=f,f!==u&&d.setAttribute("display-value",u)};for(const d of this.data.options){const u=document.createElement("option");r(u,d.displayValue),u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),i=!1),n.append(u)}let a=null;if(i){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),n.prepend(d),a=()=>{d.remove(),n.removeEventListener("input",a),a=null},n.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:f,multiple:p}=n;return p?Array.prototype.filter.call(f,g=>g.selected).map(g=>g[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const c=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.getAttribute("display-value")||f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",d=>{const u={value(f){a?.();const p=f.detail.value,g=new Set(Array.isArray(p)?p:[p]);for(const m of n.options)m.selected=g.has(m.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){n.multiple=!0},remove(f){const p=n.options,g=f.detail.remove;p[g].selected=!1,n.remove(g),p.length>0&&Array.prototype.findIndex.call(p,v=>v.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},clear(f){for(;n.length!==0;)n.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:p,displayValue:g,exportValue:m}=f.detail.insert,v=n.children[p],y=document.createElement("option");r(y,g),y.value=m,v?v.before(y):n.append(y),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},items(f){const{items:p}=f.detail;for(;n.length!==0;)n.remove(0);for(const g of p){const{displayValue:m,exportValue:v}=g,y=document.createElement("option");r(y,m),y.value=v,n.append(y)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},indices(f){const p=new Set(f.detail.indices);for(const g of f.target.options)g.selected=p.has(g.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),n.addEventListener("input",d=>{const u=o(!0),f=o(!1);t.setValue(e,{value:u}),d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,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"]],d=>d.target.value)):n.addEventListener("input",function(d){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ai extends Ct{constructor(t){const{data:e,elements:s,parent:n}=t,i=!!n._commentManager;if(super(t,{isRenderable:!i&&Ct._hasPopupData(e)}),this.elements=s,i&&Ct._hasPopupData(e)){const r=this.popup=this.#t();for(const a of s)a.popup=r}else this.popup=null}#t(){return new bc({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.#t(),s=[];for(const n of this.elements)n.popup=e,n.container.ariaHasPopup="dialog",s.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",s.map(n=>`${bs}${n}`).join(",")),this.container}}class bc{#t=null;#e=this.#G.bind(this);#s=this.#A.bind(this);#n=this.#C.bind(this);#i=this.#$.bind(this);#a=null;#r=null;#o=null;#l=null;#c=null;#u=null;#d=null;#f=!1;#g=null;#m=null;#h=null;#p=null;#v=null;#y=null;#b=null;#x=null;#S=null;#w=null;#E=!1;#T=null;#M=null;constructor({container:t,color:e,elements:s,titleObj:n,modificationDate:i,contentsObj:r,richText:a,parent:o,rect:l,parentRect:c,open:d,commentManager:u=null}){this.#r=t,this.#S=n,this.#o=r,this.#x=a,this.#u=o,this.#a=e,this.#b=l,this.#d=c,this.#c=s,this.#t=u,this.#T=s[0],this.#l=pi.toDateObject(i),this.trigger=s.flatMap(f=>f.getElementsToTriggerPopup()),u||(this.#I(),this.#r.hidden=!0,d&&this.#$())}#I(){if(this.#m)return;this.#m=new AbortController;const{signal:t}=this.#m;for(const e of this.trigger)e.addEventListener("click",this.#i,{signal:t}),e.addEventListener("pointerenter",this.#n,{signal:t}),e.addEventListener("pointerleave",this.#s,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#c)e.container?.addEventListener("keydown",this.#e,{signal:t})}#P(){const t=this.#c.find(e=>e.hasCommentButton);t&&(this.#v=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#p){this.#p.parentNode||this.#T.container.after(this.#p);return}if(this.#v||this.#P(),!this.#v)return;const{signal:t}=this.#m=new AbortController,e=this.#T.hasOwnCommentButton,s=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},n=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},i=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(e){this.#p=this.#T.container;for(const r of this.trigger)r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",n,{signal:t}),r.addEventListener("pointerleave",i,{signal:t}),r.classList.add("popupTriggerArea")}else{const r=this.#p=document.createElement("button");r.className="annotationCommentButton";const a=this.#T.container;r.style.zIndex=parseInt(a.style.zIndex,10)+1,r.tabIndex=0,r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#R(),this.#N(),r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",n,{signal:t}),r.addEventListener("pointerleave",i,{signal:t}),a.after(r)}}#N(){if(this.#T.extraPopupElement&&!this.#T.editor)return;this.#p||this.renderCommentButton();const[t,e]=this.#v,{style:s}=this.#p;s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`}#R(){this.#T.extraPopupElement||(this.#p||this.renderCommentButton(),this.#p.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#T.commentData;return t?this.#u._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#p?.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:n,modificationDate:i}=this.#T.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:n,modificationDate:i}}get elementBeforePopup(){return this.#p}get comment(){return this.#M||=this.#T.commentText,this.#M}set comment(t){t!==this.comment&&(this.#T.commentText=this.#M=t)}focus(){this.#T.container?.focus()}get parentBoundingClientRect(){return this.#T.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#p&&(this.#p.classList.toggle("selected",t),this.#p.ariaExpanded=e)}setSelectedCommentButton(t){this.#p.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#y)return this.#y;const{x:t,y:e,height:s}=this.#p.getBoundingClientRect(),{x:n,y:i,width:r,height:a}=this.#T.layer.getBoundingClientRect();return[(t-n)/r,(e+s-i)/a]}set commentPopupPosition(t){this.#y=t}hasDefaultPopupPosition(){return this.#y===null}get commentButtonPosition(){return this.#v}
48get commentButtonWidth(){return this.#p.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=this.#y||this.commentButtonPosition.map(l=>l/100),n=this.parentBoundingClientRect,{x:i,y:r,width:a,height:o}=n;this.#t.showDialog(null,this,i+e*a,r+s*o,{...t,parentDimensions:n})}render(){if(this.#g)return;const t=this.#g=document.createElement("div");if(t.className="popup",this.#a){const s=t.style.outlineColor=L.makeHexColor(...this.#a);t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#S?.str){const s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=this.#S}if(t.append(e),this.#l){const s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),s.dateTime=this.#l.toISOString(),e.append(s)}oa({html:this.#k||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#r.append(t)}get#k(){const t=this.#x,e=this.#o;return t?.str&&(!e?.str||e.str===t.str)&&this.#x.html||null}get#U(){return this.#k?.attributes?.style?.fontSize||0}get#D(){return this.#k?.attributes?.style?.color||null}#L(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:this.#D,fontSize:this.#U?`calc(${this.#U}px * var(--total-scale-factor))`:""}};for(const i of t.split(`
49`))e.push({name:"span",value:i,attributes:n});return s}#G(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#f)&&this.#$()}updateEdited({rect:t,popup:e,deleted:s}){if(this.#t){s?(this.remove(),this.#M=null):e&&(e.deleted?this.remove():(this.#R(),this.#M=e.text)),t&&(this.#v=null,this.#P(),this.#N());return}if(s||e?.deleted){this.remove();return}this.#I(),this.#w||={contentsObj:this.#o,richText:this.#x},t&&(this.#h=null),e&&e.text&&(this.#x=this.#L(e.text),this.#l=pi.toDateObject(e.date),this.#o=null),this.#g?.remove(),this.#g=null}resetEdited(){this.#w&&({contentsObj:this.#o,richText:this.#x}=this.#w,this.#w=null,this.#g?.remove(),this.#g=null,this.#h=null)}remove(){if(this.#m?.abort(),this.#m=null,this.#g?.remove(),this.#g=null,this.#E=!1,this.#f=!1,this.#p?.remove(),this.#p=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#B(){if(this.#h!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:i}}}=this.#u;let r=!!this.#d,a=r?this.#d:this.#b;for(const p of this.#c)if(!a||L.intersect(p.data.rect,a)!==null){a=p.data.rect,r=!0;break}const o=L.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),c=r?a[2]-a[0]+5:0,d=o[0]+c,u=o[1];this.#h=[100*(d-n)/e,100*(u-i)/s];const{style:f}=this.#r;f.left=`${this.#h[0]}%`,f.top=`${this.#h[1]}%`}#$(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}this.#f=!this.#f,this.#f?(this.#C(),this.#r.addEventListener("click",this.#i),this.#r.addEventListener("keydown",this.#e)):(this.#A(),this.#r.removeEventListener("click",this.#i),this.#r.removeEventListener("keydown",this.#e))}#C(){this.#g||this.render(),this.isVisible?this.#f&&this.#r.classList.add("focused"):(this.#B(),this.#r.hidden=!1,this.#r.style.zIndex=parseInt(this.#r.style.zIndex,10)+1e3)}#A(){this.#r.classList.remove("focused"),!(this.#f||!this.isVisible)&&(this.#r.hidden=!0,this.#r.style.zIndex=parseInt(this.#r.style.zIndex,10)-1e3)}forceHide(){this.#E=this.isVisible,this.#E&&(this.#r.hidden=!0)}maybeShow(){this.#t||(this.#I(),this.#E&&(this.#g||this.#C(),this.#E=!1,this.#r.hidden=!1))}get isVisible(){return!this.#t&&this.#r.hidden===!1}}class Ia extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=q.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 s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}
vendor: 6,176 bytes, line 49
49class xc extends Ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:s}=this,n=this.svgFactory.create(e,s,!0),i=this.#t=this.svgFactory.createElement("svg:line");return i.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),i.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),i.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),i.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),n.append(i),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ac extends Ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:s}=this,n=this.svgFactory.create(e,s,!0),i=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",i/2),r.setAttribute("y",i/2),r.setAttribute("width",e-i),r.setAttribute("height",s-i),r.setAttribute("stroke-width",i||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.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class wc extends Ct{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:s}=this,n=this.svgFactory.create(e,s,!0),i=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-i/2),r.setAttribute("ry",s/2-i/2),r.setAttribute("stroke-width",i||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.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Oa extends Ct{#t=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:s,popupRef:n},width:i,height:r}=this;if(!e)return this.container;const a=this.svgFactory.create(i,r,!0);let o=[];for(let c=0,d=e.length;c<d;c+=2){const u=e[c]-t[0],f=t[3]-e[c+1];o.push(`${u},${f}`)}o=o.join(" ");const l=this.#t=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",s.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.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Sc extends Oa{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ec extends Ct{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 Bi extends Ct{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?q.HIGHLIGHT:q.INK}#s(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:s,borderStyle:n,popupRef:i}}=this,{transform:r,width:a,height:o}=this.#s(e,t),l=this.svgFactory.create(a,o,!0),c=this.#t=this.svgFactory.createElement("svg:g");l.append(c),c.setAttribute("stroke-width",n.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",r);for(const d of s){const u=this.svgFactory.createElement(this.svgElementName);this.#e.push(u),u.setAttribute("points",d.join(",")),c.append(u)}return!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:n}=t,i=this.#t;if(e>=0&&i.setAttribute("stroke-width",e||1),s)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",s[r].join(","));if(n){const{transform:r,width:a,height:o}=this.#s(this.data.rotation,n);i.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),i.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ma extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=q.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 s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}
49class Tc extends Ct{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 s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Cc extends Ct{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 s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Pc extends Ct{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 s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ra extends Ct{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=q.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 Ic extends Ct{#t=null;constructor(t){super(t,{isRenderable:!0});const{fileId:e,file:s}=this.data;this.filename=s.filename,this.content=s.content,this.fileId=e,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:n}=mt.platform;return t.addEventListener("keydown",i=>{i.key==="Enter"&&(n?i.metaKey:i.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}async#e(){const{fileId:t,filename:e,content:s}=this,n=await this.linkService.getAttachmentContent(t)||s;n&&this.downloadManager?.openOrDownloadData(n,e)}}class Na extends Ct{#t=new AbortController;#e=null;#s=null;constructor(t){super(t,{isRenderable:!!t.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");const{filename:t}=this.data.richMedia,e=document.createElement("button");return e.className="mediaPlayButton",e.type="button",e.title=e.ariaLabel=t,e.addEventListener("click",()=>this.#n(e),{signal:this.#t.signal}),this.container.append(e),this.container}async#n(t){const{fileId:e,filename:s,contentType:n}=this.data.richMedia;t.disabled=!0;let i;try{i=await this.linkService.getAttachmentContent(e)}catch{return}finally{t.disabled=!1}if(!i||!t.isConnected)return;const{signal:r}=this.#t,a=URL.createObjectURL(new Blob([i],{type:n}));this.#e=a;const o=n.startsWith("audio/"),l=document.createElement(o?"audio":"video");if(this.#s=l,l.className="mediaContent",this._setBackgroundColor(l),l.src=a,l.title=s,l.controls=!0,l.autoplay=!0,l.tabIndex=0,o){let c=!1,d=!1;const u=()=>{l.controls=c||d};this.container.addEventListener("pointerenter",()=>{c=!0,u()},{signal:r}),this.container.addEventListener("pointerleave",()=>{c=!1,u()},{signal:r}),this.container.addEventListener("focusin",()=>{d=!0,u()},{signal:r}),this.container.addEventListener("focusout",()=>{d=!1,u()},{signal:r})}l.addEventListener("emptied",()=>this.#i(a),{once:!0,signal:r}),t.replaceWith(l),l.play().catch(()=>{})}#i(t=this.#e){t&&t===this.#e&&(URL.revokeObjectURL(t),this.#e=null)}destroy(){this.#t.abort(),this.#s&&(this.#s.pause(),this.#s.removeAttribute("src"),this.#s.load(),this.#s=null),this.#i()}}class ji{#t=null;#e=null;#s=null;#n=new Map;#i=null;#a=null;#r=[];#o=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:n,page:i,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:c}){this.div=t,this.#t=e,this.#e=s,this.#i=a||null,this.#a=l||null,this.#s=c||new Ri,this.page=i,this.viewport=r,this._annotationEditorUIManager=n,this._commentManager=o||null}hasEditableAnnotations(){return this.#n.size>0}async render(t){const{annotations:e,optionalContentConfig:s}=t,n=this.div;ns(n,this.viewport);const i=new Map,r=[],a={data:null,layer:n,linkService:this.#a,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Pn,annotationStorage:this.#s,enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const l=o.annotationType===It.POPUP;if(l){const u=i.get(o.id);if(!u)continue;if(!this._commentManager){r.push(o);continue}a.elements=u}else if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue;a.data=o;const c=li.create(a);if(!c.isRenderable)continue;l||(this.#r.push(c),o.popupRef&&i.getOrInsertComputed(o.popupRef,Cs).push(c));const d=c.render();o.hidden&&(d.style.visibility="hidden"),c.updateOC(s),c._isEditable&&(this.#n.set(c.data.id,c),this._annotationEditorUIManager?.renderAnnotationElement(c))}await this.#l();for(const o of r){const l=a.elements=i.get(o.id);a.data=o;const c=li.create(a);if(!c.isRenderable)continue;const d=c.render();
49c.contentElement.id=`${bs}${o.id}`,o.hidden&&(d.style.visibility="hidden"),l.at(-1).container.after(d)}this.#c()}async#l(){if(this.#r.length===0)return;this.div.replaceChildren();const t=[];if(!this.#o){this.#o=!0;for(const{contentElement:s,data:{hidden:n,id:i,oc:r}}of this.#r){const a=s.id=`${bs}${i}`,o=s.localName==="a"&&!n&&!r;t.push(this.#i?.getAriaAttributes(a,{enableLinkOwnership:o}).then(l=>{if(l)for(const[c,d]of l)s.setAttribute(c,d)}))}}this.#r.sort(({data:{rect:[s,n,i,r]}},{data:{rect:[a,o,l,c]}})=>{if(s===i&&n===r)return 1;if(a===l&&o===c)return-1;const d=r,u=n,f=(n+r)/2,p=c,g=o,m=(o+c)/2;if(f>=p&&m<=u)return-1;if(m>=d&&f<=g)return 1;const v=(s+i)/2,y=(a+l)/2;return v-y});const e=document.createDocumentFragment();for(const s of this.#r)e.append(s.container),this._commentManager?(s.extraPopupElement?.popup||s.popup)?.renderCommentButton():s.extraPopupElement&&e.append(s.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#t){const s=await this.#i?.getAnnotationIds();for(const{contentElement:n}of this.#r)s?.has(n.id)||this.#t.addPointerInTextLayer(n,!1)}}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:this.#a,svgFactory:new Pn,parent:this};for(const s of t){s.borderStyle||=ji._defaultBorderStyle,e.data=s;const n=li.create(e);n.isRenderable&&(n.render(),n.contentElement.id=`${bs}${s.id}`,this.#r.push(n))}await this.#l()}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,ns(s,{rotation:t.rotation});for(const n of this.#r)n.updateOC(e);this.#c(),s.hidden=!1}destroy(){for(const t of this.#r)t.destroy?.(),this.#t?.removePointerInTextLayer(t.contentElement);this.#r.length=0,this.#n.clear(),this.div.replaceChildren()}#c(){if(!this.#e)return;const t=this.div;for(const[e,s]of this.#e){const n=t.querySelector(`[data-annotation-id="${e}"]`);if(!n)continue;if(Array.isArray(s))for(const l of s)l.className="annotationContent",l.ariaHidden=!0;else s.className="annotationContent",s.ariaHidden=!0;const i=[];for(const l of n.children)l.nodeName==="CANVAS"&&i.push(l);for(const l of i)l.remove();const r=Array.isArray(s)?s[0]:s,{firstChild:a}=n;if(a?a.classList.contains("annotationContent")?a.after(r):a.before(r):n.append(r),Array.isArray(s)){let l=r;
49for(let c=1,d=s.length;c<d;c++)l.after(s[c]),l=s[c]}this.#e.delete(e);const o=this.#n.get(e);o&&(o._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,n.id,s),o._hasNoCanvas=!1):o.canvas=s)}}refreshCanvases(){this.#c()}getEditableAnnotations(){return this.#n.values()}getEditableAnnotation(t){return this.#n.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:n}=t,i=new dc({data:{id:s,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#a,annotationStorage:this.#s});return i.render(),i.contentElement.id=`${bs}${s}`,i.createOrUpdatePopup(),this.#r.push(i),i}removeAnnotation(t){const e=this.#r.findIndex(n=>n.data.id===t);if(e<0)return;const[s]=this.#r.splice(e,1);this.#t?.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);this.#l()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return Y(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:ms.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const gn=/\r\n?|\n/g;class Bt extends V{#t="";#e=`${this.id}-editor`;#s=null;#n;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Bt.prototype,e=i=>i.isEmpty(),s=He.TRANSLATE_SMALL,n=He.TRANSLATE_BIG;return Y(this,"_keyboardManager",new ne([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],t.commitOrRemove],[["Escape"],t.commitOrRemove],[["ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}static _type="freetext";static _editorType=q.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||Bt._defaultColor||V._defaultLineColor,this.#n=t.fontSize||Bt._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert(V._l10nAlert.freetext),this.canAddComment=!1}static initialize(t,e){V.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case lt.FREETEXT_SIZE:Bt._defaultFontSize=e;break;case lt.FREETEXT_COLOR:Bt._defaultColor=e;break}}updateParams(t,e){switch(t){case lt.FREETEXT_SIZE:this.#i(e);break;case lt.FREETEXT_COLOR:this.#a(e);break}}static get defaultPropertiesToUpdate(){return[[lt.FREETEXT_SIZE,Bt._defaultFontSize],[lt.FREETEXT_COLOR,Bt._defaultColor||V._defaultLineColor]]}get propertiesToUpdate(){return[[lt.FREETEXT_SIZE,this.#n],[lt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Ws(this),[["colorPicker",this._colorPicker]]}get colorType(){return lt.FREETEXT_COLOR}#i(t){const e=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--total-scale-factor))`,this.translate(0,-(n-this.#n)*this.parentScale),this.#n=n,this.#o()},s=this.#n;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:lt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#a(t){const e=n=>{this.color=n,this.onUpdatedColor()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:lt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Bt._internalPadding*t,-(Bt._internalPadding+this.#n)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;const t=this._uiManager.combinedSignal(this.#s);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.#e),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}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()}#r(){const t=[];
49this.editorDiv.normalize();let e=null;for(const s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(Bt.#l(s)),e=s);return t.join(`
50`)}#o(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:n,div:i}=this,r=i.style.display,a=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",n.div.append(this.div),s=i.getBoundingClientRect(),i.remove(),i.style.display=r,i.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#t,e=this.#t=this.#r().trimEnd();if(t===e)return;const s=n=>{if(this.#t=n,!n){this.remove();return}this.#c(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Bt._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.#e),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:s}=this.editorDiv;if(s.fontSize=`calc(${this.#n}px * var(--total-scale-factor))`,s.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[n,i]=this.parentDimensions;if(this.annotationElementId){const{position:r}=this._initialData;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[l,c]=this.pageDimensions,[d,u]=this.pageTranslation;let f,p;switch(this.rotation){case 0:f=t+(r[0]-d)/l,p=e+this.height-(r[1]-u)/c;break;case 90:f=t+(r[0]-d)/l,p=e-(r[1]-u)/c,[a,o]=[o,-a];break;case 180:f=t-this.width+(r[0]-d)/l,p=e-(r[1]-u)/c,[a,o]=[-a,-o];break;case 270:f=t+(r[0]-d-this.height*c)/l,p=e+(r[1]-u-this.width*l)/c,[a,o]=[-o,a];break}this.setAt(f*n,p*i,a,o)}else this._moveAfterPaste(t,e);this.#c(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(gn,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const n=Bt.#d(e.getData("text")||"").replaceAll(gn,`
51`);if(!n)return;const i=window.getSelection();if(!i.rangeCount)return;this.editorDiv.normalize(),i.deleteFromDocument();const r=i.getRangeAt(0);if(!n.includes(`
52`)){r.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),i.collapseToStart();return}const{startContainer:a,startOffset:o}=r,l=[],c=[];if(a.nodeType===Node.TEXT_NODE){const f=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(gn,"")),f!==this.editorDiv){let p=l;for(const g of this.editorDiv.childNodes){if(g===f){p=c;continue}p.push(Bt.#l(g))}}l.push(a.nodeValue.slice(0,o).replaceAll(gn,""))}else if(a===this.editorDiv){let f=l,p=0;for(const g of this.editorDiv.childNodes)p++===o&&(f=c),f.push(Bt.#l(g))}this.#t=`${l.join(`
53`)}${n}${c.join(`
54`)}`,this.#c();const d=new Range;let u=Math.sumPrecise(l.map(f=>f.length));for(const{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){const p=f.nodeValue.length;if(u<=p){d.setStart(f,u),d.setEnd(f,u);break}u-=p}i.removeAllRanges(),i.addRange(d)}#c(){if(this.editorDiv.replaceChildren(),!!this.#t)for(const t of this.#t.split(`
55`)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#d(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=Bt._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let n=null;if(t instanceof Ia){const{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:l,id:c,popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},textContent:m,textPosition:v,parent:{page:{pageNumber:y}}}=t;if(!m?.length)return null;n=t={annotationType:q.FREETEXT,color:Array.from(a),fontSize:r,value:m.join(`
56`),position:v,pageIndex:y-1,rect:o.slice(0),rotation:l,annotationElementId:c,id:c,deleted:!1,popupRef:d,comment:f?.str||null,richText:u,creationDate:p,modificationDate:g}}const i=await super.deserialize(t,e,s);return i.#n=t.fontSize,i.color=L.makeHexColor(...t.color),i.#t=Bt.#d(t.value),i._initialData=n,t.comment&&i.setCommentData(t),i}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=V._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#n,value:this.#u()});return this.addComment(s),t?(s.isCopy=!0,s):this.annotationElementId&&!this.#f(s)?null:(s.id=this.annotationElementId,s)}#f(t){const{value:e,fontSize:s,color:n,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==n[a])||t.pageIndex!==i}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:s}=e;s.fontSize=`calc(${this.#n}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(const n of this.#t.split(`
57`)){const i=document.createElement("div");i.append(n?document.createTextNode(n):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class _i{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){ht("Not implemented")}}class ot extends V{#t=null;#e;_clipPathId=null;_colorPicker=null;_drawId=null;_drawOutlines=null;_focusDrawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#n=null;static#i=null;static#a=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#r(t),this.#m())}#r({drawOutlines:t,drawId:e,drawingOptions:s,clipPathId:n}){this._drawOutlines=t,this._drawingOptions||=s,this.annotationElementId||this._uiManager.a11yAlert(V._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this._clipPathId=n??null,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties),this.#l(this.parent)):this._drawId=this.#o(t,this.parent),this.#v(t.box)}#o(t,e){const{id:s,clipPathId:n}=e.drawLayer.draw(ot._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,this.constructor._hasCl
57ipPath);return this.constructor._hasClipPath&&(this._clipPathId=n),this.#l(e),s}#l(t){const e=this._drawOutlines.getFocusSVGProperties(this.#f);e&&(this._focusDrawId=t.drawLayer.drawOutline(e,this._drawOutlines.focusMustRemoveSelfIntersections))}#c(t=this.#f){this._focusDrawId!==null&&this.parent?.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(t))}#u(t){this._focusDrawId!==null&&this.parent?.drawLayer.updateProperties(this._focusDrawId,{rootClass:t})}#d(){const{parent:t,_drawId:e,_focusDrawId:s,_isVisible:n}=this;if(!t||e===null)return;const i={hidden:!n};t.drawLayer.updateProperties(e,{rootClass:i}),s!==null&&t.drawLayer.updateProperties(s,{rootClass:i})}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[n,i]of Object.entries(e))s.has(n)?Object.assign(t[n],i):t[n]=i;return t}static getDefaultDrawingOptions(t){ht("Not implemented")}static get typesMap(){ht("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}get#f(){return(this.parentRotation-this._drawRotation+360)%360}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(ot.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,n]of this.typesMap)t.push([s,e[n]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,n]of this.constructor.typesMap)t.push([s,e[n]]);return t}_updateProperty(t,e,s){const n=this._drawingOptions,i=n[e],r=a=>{n.updateProperty(e,a);const o=this._drawOutlines.updateProperty(e,a);o&&this.#v(o),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:r.bind(this,s),undo:r.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e,s=this.colorAndOpacityType){const n=this.constructor.typesMap.get(this.colorType),i=this._opacityName,r=this._drawingOptions,a=r[n],o=r[i],l=(c,d)=>{r.updateProperty(n,c),r.updateProperty(i,d),this._drawOutlines.updateProperty(n,c),this._drawOutlines.updateProperty(i,d),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:l.bind(this,t,e),undo:l.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:s,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(this.#p()),{bbox:this.#y()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(this.#p()),{bbox:this.#y()})),this.#c()}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#y()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#y()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}get _mustBeDisabledOnCommit(){return!0}commit(){super.commit(),this._mustBeDisabledOnCommit&&(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.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),this.#g(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#m(),this.#v(this._drawOutlines.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#g()):t&&(this._uiManager.addShouldRescale(this),this.#m(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.#d(),e&&this.select()}
57#g(){if(this._drawId===null||!this.parent)return;const{drawLayer:t}=this.parent;t.remove(this._drawId),this._drawId=null,this._focusDrawId!==null&&(t.remove(this._focusDrawId),this._focusDrawId=null),this._drawingOptions.reset()}#m(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){const{drawLayer:e}=this.parent;e.updateParent(this._drawId,t.drawLayer),this._focusDrawId!==null&&e.updateParent(this._focusDrawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#o(this._drawOutlines,t),this._clipPathId&&this.#t&&(this.#t.style.clipPath=this._clipPathId)}}#h([t,e,s,n]){const{parentDimensions:[i,r],_drawRotation:a}=this;switch(a){case 90:return[e,1-t,s*(r/i),n*(i/r)];case 180:return[1-t,1-e,s,n];case 270:return[1-e,t,s*(r/i),n*(i/r)];default:return[t,e,s,n]}}#p(){const{x:t,y:e,width:s,height:n,parentDimensions:[i,r],_drawRotation:a}=this;switch(a){case 90:return[1-e,t,s*(i/r),n*(r/i)];case 180:return[1-t,1-e,s,n];case 270:return[e,1-t,s*(i/r),n*(r/i)];default:return[t,e,s,n]}}#v(t){[this.x,this.y,this.width,this.height]=this.#h(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#y(t=this.parentRotation){const{x:e,y:s,width:n,height:i,_drawRotation:r,parentDimensions:[a,o]}=this;switch((r*4+t)/90){case 1:return[1-s-i,e,i,n];case 2:return[1-e-n,1-s-i,n,i];case 3:return[s,1-e-n,i,n];case 4:return[e,s-n*(a/o),i*(o/a),n*(a/o)];case 5:return[1-s,e,n*(a/o),i*(o/a)];case 6:return[1-e-i*(o/a),1-s,i*(o/a),n*(a/o)];case 7:return[s-n*(a/o),1-e-i*(o/a),n*(a/o),i*(o/a)];case 8:return[e-n,s-i,n,i];case 9:return[1-s,e-n,i,n];case 10:return[1-e,1-s,n,i];case 11:return[s-i,1-e,i,n];case 12:return[e-i*(o/a),s,i*(o/a),n*(a/o)];case 13:return[1-s-n*(a/o),e-i*(o/a),n*(a/o),i*(o/a)];case 14:return[1-e,1-s-n*(a/o),i*(o/a),n*(a/o)];case 15:return[s,1-e,n*(a/o),i*(o/a)];default:return[e,s,n,i]}}rotate(t=this.parentRotation){if(!this.parent||this._drawId===null)return;const e=(t-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties({bbox:this.#y(t)},this._drawOutlines.updateRotation(e))),this.#c(e)}show(t=this._isVisible){super.show(t),this.#d()}select(){super.select(),this.#u({hovered:!1,selected:!0})}unselect(){super.unselect(),this.#u({selected:!1})}pointerover(){this.isSelected||this.#u({hovered:!0})}pointerleave(){this.isSelected||this.#u({hovered:!1})}onScaleChanging(){if(!this.parent)return;const t=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);t&&this.#v(t)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();this.constructor._hasDrawClass&&s.classList.add("draw");const n=this.#t=document.createElement("div");return s.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this._clipPathId&&(n.style.clipPath=this._clipPathId),ca(this,n,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t){ht("Not implemented")}static _getDrawingTarget(t,{target:e}){return e}static _getPointerCoords({offsetX:t,offsetY:e,clientX:s,clientY:n},i=null){if(!i)return[t,e];let r=s-i.clientX,a=n-i.clientY;switch(this._currentParent.viewport.rotation){case 90:[r,a]=[a,-r];break;case 180:[r,a]=[-r,-a];break;case 270:[r,a]=[-a,r];break}return[i.offsetX+r,i.offsetY+a]}static _addDrawingListeners(t,e){}static _endDrawingSession(t=!1){return this._currentParent.endDrawingSession(t)}static startDrawing(t,e,s,n){const{pointerId:i,pointerType:r}=n;if(pt.isInitializedAndDifferentPointerType(r))return;const a=this._getDrawingTarget(t,n),[o,l]=this._getPointerCoords(n),{viewport:{rotation:c}}=t,{x:d,y:u,width:f,height:p}=a.getBoundingClientRect(),g=ot.#n=new AbortController,m=t.combinedSignal(g);if(pt.setPointer(r,i),window.addEventListener("pointerup",b=>{pt.isSamePointerIdOrRemove(b.pointerId)&&this._endDraw(b)},{signal:m}),window.addEventListener("pointercancel",b=>{pt.isSamePointerIdOrRemove(b.pointerId)&&this._endDrawingSession()},{signal:m}),window.addEventListener("pointerdown",b=>{pt.isSamePointerType(b.pointerType)&&(pt.initializeAndAddPointerId(b.pointerId),ot.#s.isCancellable()&&(ot.#s.removeLastElement(),ot.#s.isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",pe,{signal:m}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),a.addEventListener("touchmove",b=>{pt.isSameTimeStamp(b.timeStamp)&&Lt(b)},{signal:m}),this._addDrawingListeners(a,m),t.toggleDrawing(),e._editorUndoBar?.hide(),ot.#s){t.drawLayer.updateProperties(this._currentDrawId,ot.#s.startNew(o,l,f,p,c));return}e.updateUIForDefaultProperties(this),ot.#s=this.createDrawerInstance({x:o,y:l,box:[d,u,f,p],rotation:c,parent:t,isLTR:s}),ot.#i=this.getDefaultDrawingOptions(),this._currentParent=t;
57const{id:v,clipPathId:y}=t.drawLayer.draw(this._mergeSVGProperties(ot.#i.toSVGProperties(),ot.#s.defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=v,ot.#a=this._hasClipPath?y:null}static _drawMove(t){if(pt.isSameTimeStamp(t.timeStamp),!ot.#s||!pt.isSamePointerId(t.pointerId))return;if(pt.isUsingMultiplePointers()){this._endDraw(t);return}let e;const s=t.getCoalescedEvents?.();if(s?.length){const n=[];for(const i of s)n.push(...this._getPointerCoords(i,t));e=ot.#s.addPoints(n)}else e=ot.#s.add(...this._getPointerCoords(t));this._currentParent.drawLayer.updateProperties(this._currentDrawId,e),pt.setTimeStamp(t.timeStamp),Lt(t)}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,ot.#s=null,ot.#i=null,ot.#a=null,pt.clearTimeStamp()),ot.#n&&(ot.#n.abort(),ot.#n=null,pt.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),e.drawLayer.updateProperties(this._currentDrawId,t?.target===e.div?ot.#s.end(...this._getPointerCoords(t)):ot.#s.end()),this.supportMultipleDrawings){const s=ot.#s,n=this._currentDrawId,i=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(n,s.setLastElement(i))},undo:()=>{e.drawLayer.updateProperties(n,s.removeLastElement())},mustExec:!1,type:lt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(lt.DRAW_STEP),!ot.#s.isEmpty()){const{pageDimensions:[s,n],scale:i}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:ot.#a,drawOutlines:ot.#s.getOutlines(s*i,n*i,i,this._INNER_MARGIN),drawingOptions:ot.#i,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,n,i,r,a){ht("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:n,pageHeight:i,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,n,i,this._INNER_MARGIN,t,s),l=await super.deserialize(t,e,s);return l.createDrawingOptions(t),l.#r({drawOutlines:o}),l.#m(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,s]=this.pageTranslation,[n,i]=this.pageDimensions;return this._drawOutlines.serialize([e,s,n,i],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class H{static PRECISION=1e-4;focusOutline=null;toSVGPath(){ht("Abstract method `toSVGPath` must be implemented.")}get box(){ht("Abstract getter `box` must be implemented.")}serialize(t,e){ht("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){ht("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,n],i){switch(i){case 90:return[1-e-n,t,n,s];case 180:return[1-t-s,1-e-n,s,n];case 270:return[e,1-t-s,n,s]}return[t,e,s,n]}static _rescale(t,e,s,n,i,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]=s+t[a+1]*i;return r}static _rescaleAndSwap(t,e,s,n,i,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]=s+t[a]*i;return r}static _translate(t,e,s,n){n||=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i+=2)n[i]=e+t[i],n[i+1]=s+t[i+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,n,i){switch(i){case 90:return[1-e/s,t/n];case 180:return[1-t/s,1-e/n];case 270:return[e/s,1-t/n];default:return[t/s,e/n]}}static createBezierPoints(t,e,s,n,i,r){return[(t+5*s)/6,(e+5*n)/6,(5*s+i)/6,(5*n+r)/6,(s+i)/2,(n+r)/2]}}class Ze{#t;#e=[];#s;#n;#i=[];#a=new Float32Array(18);#r;#o;#l;#c;#u;#d;#f=[];static#g=8;static#m=2;static#h=Ze.#g+Ze.#m;
57constructor(t,e,s,n,i,r,a=0){this.#t=s,this.#d=i*n,this.#n=r,this.#a.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#c=Ze.#g*n,this.#l=Ze.#h*n,this.#u=n,this.#f.push(t,e)}isEmpty(){return isNaN(this.#a[8])}isCancellable(){return this.#f.length<=10}removeLastElement(){return this.#a.fill(NaN),this.#i.length=this.#e.length=this.#f.length=0,{path:{d:""}}}#p(){const t=this.#a.subarray(4,6),e=this.#a.subarray(16,18),[s,n,i,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/i,(this.#o+(t[1]-e[1])/2-n)/r,(this.#r+(e[0]-t[0])/2-s)/i,(this.#o+(e[1]-t[1])/2-n)/r]}add(t,e){this.#r=t,this.#o=e;const[s,n,i,r]=this.#t;let[a,o,l,c]=this.#a.subarray(8,12);const d=t-l,u=e-c,f=Math.hypot(d,u);if(f<this.#l)return!1;const p=f-this.#c,g=p/f,m=g*d,v=g*u;let y=a,b=o;a=l,o=c,l+=m,c+=v,this.#f?.push(t,e);const S=-v/p,x=m/p,w=S*this.#d,E=x*this.#d;return this.#a.set(this.#a.subarray(2,8),0),this.#a.set([l+w,c+E],4),this.#a.set(this.#a.subarray(14,18),12),this.#a.set([l-w,c-E],16),isNaN(this.#a[6])?(this.#i.length===0&&(this.#a.set([a+w,o+E],2),this.#i.push(NaN,NaN,NaN,NaN,(a+w-s)/i,(o+E-n)/r),this.#a.set([a-w,o-E],14),this.#e.push(NaN,NaN,NaN,NaN,(a-w-s)/i,(o-E-n)/r)),this.#a.set([y,b,a,o,l,c],6),!this.isEmpty()):(this.#a.set([y,b,a,o,l,c],6),Math.abs(Math.atan2(b-o,y-a)-Math.atan2(v,m))<Math.PI/2?([a,o,l,c]=this.#a.subarray(2,6),this.#i.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/i,((o+c)/2-n)/r),[a,o,y,b]=this.#a.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+a)/2-s)/i,((b+o)/2-n)/r),!0):([y,b,a,o,l,c]=this.#a.subarray(0,6),this.#i.push(((y+5*a)/6-s)/i,((b+5*o)/6-n)/r,((5*a+l)/6-s)/i,((5*o+c)/6-n)/r,((a+l)/2-s)/i,((o+c)/2-n)/r),[l,c,a,o,y,b]=this.#a.subarray(12,18),this.#e.push(((y+5*a)/6-s)/i,((b+5*o)/6-n)/r,((5*a+l)/6-s)/i,((5*o+c)/6-n)/r,((a+l)/2-s)/i,((o+c)/2-n)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#i,e=this.#e;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#v();const s=[];
57s.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?s.push(`L${t[n+4]} ${t[n+5]}`):s.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);this.#b(s);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?s.push(`L${e[n+4]} ${e[n+5]}`):s.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return this.#y(s),s.join(" ")}#v(){const[t,e,s,n]=this.#t,[i,r,a,o]=this.#p();return`M${(this.#a[2]-t)/s} ${(this.#a[3]-e)/n} L${(this.#a[4]-t)/s} ${(this.#a[5]-e)/n} L${i} ${r} L${a} ${o} L${(this.#a[16]-t)/s} ${(this.#a[17]-e)/n} L${(this.#a[14]-t)/s} ${(this.#a[15]-e)/n} Z`}#y(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){const[e,s,n,i]=this.#t,r=this.#a.subarray(4,6),a=this.#a.subarray(16,18),[o,l,c,d]=this.#p();t.push(`L${(r[0]-e)/n} ${(r[1]-s)/i} L${o} ${l} L${c} ${d} L${(a[0]-e)/n} ${(a[1]-s)/i}`)}newFreeDrawOutline(t,e,s,n,i,r){return new ka(t,e,s,n,i,r)}getOutlines(){const t=this.#i,e=this.#e,s=this.#a,[n,i,r,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let d=0,u=o.length-2;d<u;d+=2)o[d]=(this.#f[d]-n)/r,o[d+1]=(this.#f[d+1]-i)/a;if(o[o.length-2]=(this.#r-n)/r,o[o.length-1]=(this.#o-i)/a,isNaN(s[6])&&!this.isEmpty())return this.#x(o);const l=new Float32Array(this.#i.length+24+this.#e.length);let c=t.length;for(let d=0;d<c;d+=2){if(isNaN(t[d])){l[d]=l[d+1]=NaN;continue}l[d]=t[d],l[d+1]=t[d+1]}c=this.#w(l,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(e[d+u])){l[c]=l[c+1]=NaN,c+=2;continue}l[c]=e[d+u],l[c+1]=e[d+u+1],c+=2}return this.#S(l,c),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#s,this.#n)}#x(t){const e=this.#a,[s,n,i,r]=this.#t,[a,o,l,c]=this.#p(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/i,(e[3]-n)/r,NaN,NaN,NaN,NaN,(e[4]-s)/i,(e[5]-n)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,(e[16]-s)/i,(e[17]-n)/r,NaN,NaN,NaN,NaN,(e[14]-s)/i,(e[15]-n)/r],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#s,this.#n)}#S(t,e){const s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#w(t,e){const s=this.#a.subarray(4,6),n=this.#a.subarray(16,18),[i,r,a,o]=this.#t,[l,c,d,u]=this.#p();return t.set([NaN,NaN,NaN,NaN,(s[0]-i)/a,(s[1]-r)/o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(n[0]-i)/a,(n[1]-r)/o],e),e+=24}}class ka extends H{#t;#e=new Float32Array(4);#s;#n;#i;#a;#r;constructor(t,e,s,n,i,r){super(),this.#r=t,this.#i=e,this.#t=s,this.#a=n,this.#s=i,this.#n=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(r);const[a,o,l,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/l,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/l,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6){if(isNaN(this.#r[e])){t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`);continue}t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,n],i){const r=s-t,a=n-e;let o,l;switch(i){case 0:o=H._rescale(this.#r,t,n,r,-a),l=H._rescale(this.#i,t,n,r,-a);break;case 90:o=H._rescaleAndSwap(this.#r,t,e,r,a),l=H._rescaleAndSwap(this.#i,t,e,r,a);break;case 180:o=H._rescale(this.#r,s,e,-r,a),l=H._rescale(this.#i,s,e,-r,a);break;case 270:o=H._rescaleAndSwap(this.#r,s,n,-r,-a),l=H._rescaleAndSwap(this.#i,s,n,-r,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){const e=this.#r;let s=e[4],n=e[5];const i=[s,n,s,n];let r=s,a=n,o=s,l=n;const c=t?Math.max:Math.min,d=new Float32Array(4);for(let f=6,p=e.length;f<p;f+=6){const g=e[f+4],m=e[f+5];isNaN(e[f])?(L.pointBoundingBox(g,m,i),a>m?(r=g,a=m):a===m&&(r=c(r,g)),l<m?(o=g,l=m):l===m&&(o=c(o,g))):(d.set(De,0),L.bezierBoundingBox(s,n,...e.slice(f,f+6),d),L.rectBoundingBox(...d,i),a>d[1]?(r=d[0],a=d[1]):a===d[1]&&(r=c(r,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=c(o,d[2]))),s=g,n=m}const u=this.#e;u[0]=i[0]-this.#s,u[1]=i[1]-this.#s,u[2]=i[2]-i[0]+2*this.#s,u[3]=i[3]-i[1]+2*this.#s,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,s,n,i,r,a=0){return new Ze(t,e,s,n,i,r,a)}updateThickness(t){const e=this.getNewOutline(t);return this.#r=e.#r,this.#i=e.#i,this.#e.set(e.#e),this.firstPoint=e.firstPoint,this.lastPoint=e.lastPoint,this.#e}getNewOutline(t,e){const[s,n,i,r]=this.#e,[a,o,l,c]=this.#t,d=i*l,u=r*c,f=s*l+a,p=n*c+o,g=this.#i,m=this.newOutliner(g[0]*
57d+f,g[1]*u+p,this.#t,this.#a,t,this.#n,e??this.#s);for(let v=2,y=g.length;v<y;v+=2)m.add(g[v]*d+f,g[v+1]*u+p);return m.getOutlines()}}function Da(h){return{bbox:h.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:h.isFree},path:{d:h.toSVGPath()}}}function Fa(h,t){const{focusOutline:e}=h;return{bbox:H._rotateBox(e.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:h.isFree},path:{d:e.toSVGPath()}}}class wi{#t;#e;#s;#n=[];#i=[];constructor(t,e=0,s=0,n=!0){const i=De.slice(),r=10**-4;for(const{x:g,y:m,width:v,height:y}of t){const b=Math.floor((g-e)/r)*r,S=Math.ceil((g+v+e)/r)*r,x=Math.floor((m-e)/r)*r,w=Math.ceil((m+y+e)/r)*r,E=[b,x,w,!0],C=[S,x,w,!1];this.#n.push(E,C),L.rectBoundingBox(b,x,S,w,i)}const a=i[2]-i[0]+2*s,o=i[3]-i[1]+2*s,l=i[0]-s,c=i[1]-s;let d=n?-1/0:1/0,u=1/0;const f=this.#n.at(n?-1:-2),p=[f[0],f[2]];for(const g of this.#n){const[m,v,y,b]=g;!b&&n?v<u?(u=v,d=m):v===u&&(d=Math.max(d,m)):b&&!n&&(v<u?(u=v,d=m):v===u&&(d=Math.min(d,m))),g[0]=(m-l)/a,g[1]=(v-c)/o,g[2]=(y-c)/o}this.#t=new Float32Array([l,c,a,o]),this.#e=[d,u],this.#s=p}getOutlines(){this.#n.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#n)e[3]?(t.push(...this.#c(e)),this.#o(e)):(this.#l(e),t.push(...this.#c(e)));return this.#a(t)}#a(t){const e=[],s=new Set;for(const r of t){const[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){const o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}const n=[];let i;for(;s.size>0;){const r=s.values().next().value;let[a,o,l,c,d]=r;s.delete(r);let u=a,f=o;for(i=[a,l],n.push(i);;){let p;if(s.has(c))p=c;else if(s.has(d))p=d;else break;s.delete(p),[a,o,l,c,d]=p,u!==a&&(i.push(u,f,a,f===o?o:l),u=a),f=f===o?l:o}i.push(u,f)}return new Si(n,this.#t,this.#e,this.#s)}#r(t){const e=this.#i;let s=0,n=e.length-1;for(;s<=n;){const i=s+n>>1,r=e[i][0];if(r===t)return i;r<t?s=i+1:n=i-1}return n+1}#o([,t,e]){const s=this.#r(t);this.#i.splice(s,0,[t,e])}#l([,t,e]){const s=this.#r(t);for(let n=s;n<this.#i.length;n++){const[i,r]=this.#i[n];if(i!==t)break;if(i===t&&r===e){this.#i.splice(n,1);return}}for(let n=s-1;n>=0;n--){const[i,r]=this.#i[n];if(i!==t)break;if(i===t&&r===e){this.#i.splice(n,1);return}}}#c(t){const[e,s,n]=t,i=[[e,s,n]],r=this.#r(n);for(let a=0;a<r;a++){const[o,l]=this.#i[a];for(let c=0,d=i.length;c<d;c++){const[,u,f]=i[c];if(!(l<=u||f<=o)){if(u>=o){if(f>l)i[c][1]=l;else{if(d===1)return[];i.splice(c,1),c--,d--}continue}i[c][2]=o,f>l&&i.push([e,l,f])}}}return i}}class Si extends H{#t;#e=null;#s;constructor(t,e,s,n){super(),this.#s=t,this.#t=e,this.firstPoint=s,this.lastPoint=n}static build(t,e){const s=new wi(t,.001).getOutlines();return s.#e=t,s.focusOutline=new wi(t,.0025,.001,e).getOutlines(),s}get isFree(){return!1}get defaultSVGProperties(){return Da(this)}getFocusSVGProperties(t){return Fa(this,t)}updateRotation(t){return{root:{"data-main-rotation":t}}}serializeQuadPoints([t,e],[s,n]){const i=this.#e,r=new Float32Array(i.length*8);let a=0;for(const{x:o,y:l,width:c,height:d}of i){const u=o*s+t,f=(1-l)*n+e;r[a]=r[a+4]=u,r[a+1]=r[a+3]=f,r[a+2]=r[a+6]=u+c*s,r[a+5]=r[a+7]=f-d*n,a+=8}return r}toSVGPath(){const t=[];for(const e of this.#s){let[s,n]=e;t.push(`M${s} ${n}`);for(let i=2;i<e.length;i+=2){const r=e[i],a=e[i+1];r===s?(t.push(`V${a}`),n=a):a===n&&(t.push(`H${r}`),s=r)}t.push("Z")}return t.join(" ")}serialize([t,e,s,n],i){const r=[],a=s-t,o=n-e;for(const l of this.#s){const c=new Array(l.length);for(let d=0;d<l.length;d+=2)c[d]=t+l[d]*a,c[d+1]=n-l[d+1]*o;r.push(c)}return r}get box(){return this.#t}}class Ui extends Ze{newFreeDrawOutline(t,e,s,n,i,r){return new $i(t,e,s,n,i,r)}}class Oc{#t;#e;constructor(t,e,s,n,i,r,a){this.#t=new Ui(t,e,s,n,i,r,a),this.#e=i}add(t,e){return this.#t.add(t,e)?{path:{d:this.#t.toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,n=t.length;s<n;s+=2)e=this.#t.add(t[s],t[s+1])||e;return e?{path:{d:this.#t.toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return this.#t.isEmpty()}isCancellable(){return this.#t.isCancellable()}removeLastElement(){return this.#t.removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=this.#t.getOutlines();return t.buildFocusOutline(2*this.#e),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:this.#t.toSVGPath()}}}}class $i extends ka{static#t=1.5;newOutliner(t,e,s,n,i,r,a=0){return new Ui(t,e,s,n,i,r,a)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+$i.#t,.0025)}get defaultSVGProperties(){return Da(this)}getFocusSVGProperties(t){return Fa(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;const s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}}class Hi extends _i{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new Hi;return t.updateAll(this),t}}class ue extends ot{#t=null;#e=0;#s=null;#n=0;#i="";#a="";static _DEFAULT_OPACITY=1;static _DEFAULT_THICKNESS=12;static _defaultDrawingOptions=null;static _type="highlight";static _editorType=q.HIGHLIGHT;static get _keyboardManager(){const t=ue.prototype;return Y(this,"_keyboardManager",new ne([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.#t=t.anchorNode||null,this.#e=t.anchorOffset||0,this.#s=t.focusNode||null,this.#n=t.focusOffset||0,this.#i=t.methodOfCreation||(this._drawOutlines?.isFree?"main_toolbar":""),this.#a=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static initialize(t,e){V.initialize(t,e),this._defaultDrawingOptions||=new Hi({fill:e.highlightColors?.values().next().value||"#fff066","fill-opacity":ue._DEFAULT_OPACITY,thickness:ue._DEFAULT_THICKNESS})}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get typesMap(){return Y(this,"typesMap",new Map([[lt.HIGHLIGHT_COLOR,"fill"],[lt.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(t){const{boxes:e,drawOutlines:s}=t;!e&&!s||(this._drawingOptions||=t.drawingOptions||ue.getDefaultDrawingOptions(),e&&(t={...t,drawOutlines:Si.build(e,this._uiManager.direction==="ltr")}),super._addOutlines(t))}get colorType(){return lt.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){return this._drawOutlines?.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){return!this._drawOutlines?.isFree}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:this.#i}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}translateInPage(t,e){}get toolbarPosition(){return this.#r(this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return this.#r(this._drawOutlines.firstPoint)}#r([t,e]){const[s,n,i,r]=this._drawOutlines.box;return[(t-s)/i,(e-n)/r]}updateParams(t,e){switch(t){case lt.HIGHLIGHT_COLOR:this._updateColorAndOpacity(e,ue._DEFAULT_OPACITY,t),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);break;case lt.HIGHLIGHT_THICKNESS:super.updateParams(t,e),this._reportTelemetry({action:"thickness_changed",thickness:e},!0);break}}get propertiesToUpdate(){const t=super.propertiesToUpdate;return t.push([lt.HIGHLIGHT_FREE,this._drawOutlines.isFree]),t}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new ce({editor:this}),[["colorPicker",this._colorPicker]]):super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(t,e){return super.getRect(t,e,this._drawRotation)}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}
57render(){if(this.div)return this.div;const t=super.render();return this.#a&&(t.setAttribute("aria-label",this.#a),t.setAttribute("role","mark")),this._drawOutlines.isFree?t.classList.add("free"):t.addEventListener("keydown",this.#o.bind(this),{signal:this._uiManager._signal}),this.enableEditing(),t}#o(t){ue._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#l(!0);break;case 1:case 3:this.#l(!1);break}}#l(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#s,this.#n)}unselect(){super.unselect(),this._drawOutlines.isFree||this.#l(!1)}static createDrawerInstance({x:t,y:e,box:s,parent:n,isLTR:i}){return new Oc(t,e,s,n.scale,this._defaultDrawingOptions.thickness/2,i,.001)}static _getDrawingTarget(t,{target:e}){return e.closest(".textLayer")}static _getPointerCoords({x:t,y:e}){return[t,e]}static _addDrawingListeners(t,e){t.classList.add("free"),e.addEventListener("abort",()=>t.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:e}),window.addEventListener("pointerdown",Lt,{capture:!0,passive:!1,signal:e})}static _endDrawingSession(t=!1){return this.endDrawing(t)}createDrawingOptions({color:t,opacity:e,thickness:s}){const{_defaultDrawingOptions:n,_DEFAULT_OPACITY:i}=ue;this._drawingOptions=ue.getDefaultDrawingOptions({fill:L.makeHexColor(...t),"fill-opacity":e||i,thickness:s||n.thickness})}static deserializeDraw(t,e,s,n,i,r,a){const{quadPoints:o}=r;if(o){const f=[];for(let p=0,g=o.length;p<g;p+=8)f.push({x:(o[p]-t)/s,y:1-(o[p+1]-e)/n,width:(o[p+2]-o[p])/s,height:(o[p+1]-o[p+5])/n});return Si.build(f,a.direction==="ltr")}const l=r.thickness||this._defaultDrawingOptions.thickness,c=(r.inkLists||r.outlines.points)[0],d=new Ui(c[0]-t,n-(c[1]-e),[0,0,s,n],1,l/2,!0,.001);for(let f=0,p=c.length;f<p;f+=2)d.add(c[f]-t,n-(c[f+1]-e));const u=d.getOutlines();return u.buildFocusOutline(l),u}static async deserialize(t,e,s){let n=null;if(t instanceof Ma){const{data:{quadPoints:r,rect:a,rotation:o,id:l,color:c,opacity:d,popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:v}}}=t;n=t={annotationType:q.HIGHLIGHT,color:Array.from(c),opacity:d,quadPoints:r,pageIndex:v-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}else if(t instanceof Bi){const{data:{inkLists:r,rect:a,rotation:o,id:l,color:c,borderStyle:{rawWidth:d},popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:v}}}=t;n=t={annotationType:q.HIGHLIGHT,color:Array.from(c),thickness:d,inkLists:r,pageIndex:v-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}const i=await super.deserialize(t,e,s);return i._initialData=n,t.comment&&i.setCommentData(t),i}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=super.serialize(t);return Object.assign(e,{color:V._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(e.rect,this._drawRotation)}),this.addComment(e),this.annotationElementId&&!this.#c(e)?null:(e.id=this.annotationElementId,e)}#c(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,n)=>s!==e[n])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Mc{#t=new Float64Array(6);#e=new Float64Array(2);#s;#n;#i;#a;#r;#o="";#l=0;#c=new Js;#u;#d;constructor(t,e,s,n,i,r){this.#u=s,this.#d=n,this.#i=i,this.#a=r,[t,e]=this.#f(t,e);const a=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#n=[{line:a,points:this.#r}],this.#t.set(a,0),this.#e.set([t,e],0)}updateProperty(t,e){t==="stroke-width"&&(this.#a=e)}#f(t,e){return H._normalizePoint(t,e,this.#u,this.#d,this.#i)}isEmpty(){return!this.#n?.length}isCancellable(){return this.#r.length<=10}add(t,e){return this.#g(t,e)&&this.toSVGPath(),{path:{d:this.#m()}}}addPoints(t){let e=!1;for(let s=0,n=t.length;s<n;s+=2)this.#g(t[s],t[s+1])&&(e=!0,this.#r.length<=6&&(this.toSVGPath(),e=!1));return e&&this.toSVGPath(),{path:{d:this.#m()}}}#g(t,e){[t,e]=this.#f(t,e),this.#e.set([t,e],0);const[s,n,i,r]=this.#t.subarray(2,6),a=t-i,o=e-r;return Math.hypot(this.#u*a,this.#d*o)<=2?!1:(this.#r.push(t,e),isNaN(s)?(this.#t.set([i,r,t,e],2),this.#s.push(NaN,NaN,NaN,NaN,t,e),!0):(isNaN(this.#t[0])&&this.#s.splice(6,6),this.#t.set([s,n,i,r,t,e],0),this.#s.push(...H.createBezierPoints(s,n,i,r,t,e)),!0))}end(t,e){return t!==void 0&&this.#g(t,e)?{path:{d:this.toSVGPath()}}:this.#r.length===2?{path:{d:this.toSVGPath()}}:{path:{d:this.#o}}}startNew(t,e,s,n,i){this.#u=s,this.#d=n,this.#i=i,[t,e]=this.#f(t,e);const r=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#e.set([t,e],0);const a=this.#n.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#n.push({line:r,points:this.#r}),this.#t.set(r,0),this.#l=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(t){return this.#n?(this.#n.push(t),this.#s=t.line,this.#r=t.points,this.#l=0,{path:{d:this.toSVGPath()}}):this.#c.setLastElement(t)}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop(),this.#o="";for(let t=0,e=this.#n.length;t<e;t++){const{line:s,points:n}=this.#n[t];this.#s=s,this.#r=n,this.#l=0,this.toSVGPath()}return{path:{d:this.#o}}}#m(){const t=H.svgRound(this.#e[0]),e=H.svgRound(this.#e[1]);if(this.#r.length===2){const s=H.svgRound(this.#s[4]),n=H.svgRound(this.#s[5]);return`${this.#o} M ${s} ${n} L ${t} ${e}`}return`${this.#o} L ${t} ${e}`}toSVGPath(){const t=H.svgRound(this.#s[4]),e=H.svgRound(this.#s[5]);if(this.#r.length===2)return this.#o=`${this.#o} M ${t} ${e} Z`,this.#o;if(this.#r.length<=6){const n=this.#o.lastIndexOf("M");this.#o=`${this.#o.slice(0,n)} M ${t} ${e}`,this.#l=6}if(this.#r.length===4){const n=H.svgRound(this.#s[10]),i=H.svgRound(this.#s[11]);return this.#o=`${this.#o} L ${n} ${i}`,this.#l=12,this.#o}const s=[];this.#l===0&&(s.push(`M ${t} ${e}`),this.#l=6);for(let n=this.#l,i=this.#s.length;n<i;n+=6){const[r,a,o,l,c,d]=this.#s.slice(n,n+6).map(H.svgRound);s.push(`C${r} ${a} ${o} ${l} ${c} ${d}`)}return this.#o+=s.join(" "),this.#l=this.#s.length,this.#o}getOutlines(t,e,s,n){const i=this.#n.at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),this.#c.build(this.#n,t,e,s,this.#i,this.#a,n),this.#t=null,this.#s=null,this.#n=null,this.#o=null,this.#c}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Js extends H{#t;#e=0;#s;#n;#i;#a;#r;#o;#l;build(t,e,s,n,i,r,a){this.#i=e,this.#a=s,this.#r=n,this.#o=i,this.#l=r,this.#s=a??0,this.#n=t,this.#d()}get thickness(){return this.#l}setLastElement(t){return this.#n.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#n.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#n){if(t.push(`M${H.svgRound(e[4])} ${H.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${H.svgRound(e[10])} ${H.svgRound(e[11])}`);continue}for(let s=6,n=e.length;s<n;s+=6){const[i,r,a,o,l,c]=e.subarray(s,s+6).map(H.svgRound);t.push(`C${i} ${r} ${a} ${o} ${l} ${c}`)}}return t.join("")}serialize([t,e,s,n],i){const r=[],a=[],[o,l,c,d]=this.#u();let u,f,p,g,m,v,y,b,S;switch(this.#o){case 0:S=H._rescale,u=t,f=e+n,p=s,g=-n,m=t+o*s,v=e+(1-l-d)*n,y=t+(o+c)*s,b=e+(1-l)*n;break;case 90:S=H._rescaleAndSwap,u=t,f=e,p=s,g=n,m=t+l*s,v=e+o*n,y=t+(l+d)*s,b=e+(o+c)*n;break;case 180:S=H._rescale,u=t+s,f=e,p=-s,g=n,m=t+(1-o-c)*s,v=e+l*n,y=t+(1-o)*s,b=e+(l+d)*n;break;case 270:S=H._rescaleAndSwap,u=t+s,f=e+n,p=-s,g=-n,m=t+(1-l-d)*s,v=e+(1-o-c)*n,y=t+(1-l)*s,b=e+(1-o)*n;break}for(const{line:x,points:w}of this.#n)r.push(S(x,u,f,p,g,i?new Array(x.length):null)),a.push(S(w,u,f,p,g,i?new Array(w.length):null));return{lines:r,points:a,rect:[m,v,y,b]}}static deserialize(t,e,s,n,i,{paths:{lines:r,points:a},rotation:o,thickness:l}){const c=[];let d,u,f,p,g;switch(o){case 0:g=H._rescale,d=-t/s,u=e/n+1,f=1/s,p=-1/n;break;case 90:g=H._rescaleAndSwap,d=-e/n,u=-t/s,f=1/n,p=1/s;break;case 180:g=H._rescale,d=t/s+1,u=-e/n,f=-1/s,p=1/n;break;case 270:g=H._rescaleAndSwap,d=e/n+1,u=t/s+1,f=-1/n,p=-1/s;break}if(!r){r=[];for(const v of a){const y=v.length;if(y===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(y===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));continue}const b=new Float32Array(3*(y-2));
vendor: 8,249 bytes, line 57
57r.push(b);let[S,x,w,E]=v.subarray(0,4);b.set([NaN,NaN,NaN,NaN,S,x],0);for(let C=4;C<y;C+=2){const T=v[C],O=v[C+1];b.set(H.createBezierPoints(S,x,w,E,T,O),(C-2)*3),[S,x,w,E]=[w,E,T,O]}}}for(let v=0,y=r.length;v<y;v++)c.push({line:g(r[v].map(b=>b??NaN),d,u,f,p),points:g(a[v].map(b=>b??NaN),d,u,f,p)});const m=new this.prototype.constructor;return m.build(c,s,n,1,o,l,i),m}#c(t=this.#l){const e=this.#s+t/2*this.#r;return this.#o%180===0?[e/this.#i,e/this.#a]:[e/this.#a,e/this.#i]}#u(){const[t,e,s,n]=this.#t,[i,r]=this.#c(0);return[t+i,e+r,s-2*i,n-2*r]}#d(){const t=this.#t=Je.slice();for(const{line:n}of this.#n){if(n.length<=12){for(let a=4,o=n.length;a<o;a+=6)L.pointBoundingBox(n[a],n[a+1],t);continue}let i=n[4],r=n[5];for(let a=6,o=n.length;a<o;a+=6){const[l,c,d,u,f,p]=n.subarray(a,a+6);L.bezierBoundingBox(i,r,l,c,d,u,f,p,t),i=f,r=p}}const[e,s]=this.#c();t[0]=xt(t[0]-e,0,1),t[1]=xt(t[1]-s,0,1),t[2]=xt(t[2]+e,0,1),t[3]=xt(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){const[e,s]=this.#c();this.#l=t;const[n,i]=this.#c(),[r,a]=[n-e,i-s],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],s){const[n,i]=this.#c();this.#i=t,this.#a=e,this.#r=s;const[r,a]=this.#c(),o=r-n,l=a-i,c=this.#t;return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(H.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let s=0,n=0,i=0,r=0,a=0,o=0;switch(this.#e){case 90:n=e/t,i=-t/e,a=t;break;case 180:s=-1,r=-1,a=t,o=e;break;case 270:n=-e/t,i=t/e,o=e;break;default:return""}return`matrix(${s} ${n} ${i} ${r} ${H.svgRound(a)} ${H.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,n]){const[i,r]=this.#c(),[a,o,l,c]=this.#t;if(Math.abs(l-i)<=H.PRECISION||Math.abs(c-r)<=H.PRECISION){const g=t+s/2-(a+l/2),m=e+n/2-(o+c/2);return{path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${m})`}}}const d=(s-2*i)/(l-2*i),u=(n-2*r)/(c-2*r),f=l/s,p=c/n;return{path:{"transform-origin":`${H.svgRound(a)} ${H.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${H.svgRound(i)} ${H.svgRound(r)}) scale(${d} ${u}) translate(${H.svgRound(-i)} ${H.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,n]){const[i,r]=this.#c(),a=this.#t,[o,l,c,d]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=n,Math.abs(c-i)<=H.PRECISION||Math.abs(d-r)<=H.PRECISION){const m=t+s/2-(o+c/2),v=e+n/2-(l+d/2);for(const{line:y,points:b}of this.#n)H._translate(y,m,v,y),H._translate(b,m,v,b);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(s-2*i)/(c-2*i),f=(n-2*r)/(d-2*r),p=-u*(o+i)+t+i,g=-f*(l+r)+e+r;if(u!==1||f!==1||p!==0||g!==0)for(const{line:m,points:v}of this.#n)H._rescale(m,p,g,u,f,m),H._rescale(v,p,g,u,f,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[n,i]=s,r=this.#t,a=t-r[0],o=e-r[1];if(this.#i===n&&this.#a===i)for(const{line:l,points:c}of this.#n)H._translate(l,a,o,l),H._translate(c,a,o,c);else{const l=this.#i/n,c=this.#a/i;this.#i=n,this.#a=i;for(const{line:d,points:u}of this.#n)H._rescale(d,a,o,l,c,d),H._rescale(u,a,o,l,c,u);r[2]*=l,r[3]*=c}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${H.svgRound(t)} ${H.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${H.svgRound(t[0])} ${H.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Gn extends _i{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:V._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Gn(this._viewParameters);return t.updateAll(this),t}}class zi extends ot{static _type="ink";static _editorType=q.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){V.initialize(t,e),this._defaultDrawingOptions=new Gn(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Y(this,"typesMap",new Map([[lt.INK_THICKNESS,"stroke-width"],[lt.INK_COLOR,"stroke"],[lt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:t,y:e,box:[,,s,n],rotation:i}){return new Mc(t,e,s,n,i,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,n,i,r){return Js.deserialize(t,e,s,n,i,r)}static async deserialize(t,e,s){let n=null;if(t instanceof Bi){const{data:{inkLists:r,rect:a,rotation:o,id:l,color:c,opacity:d,borderStyle:{rawWidth:u},popupRef:f,richText:p,contentsObj:g,creationDate:m,modificationDate:v},parent:{page:{pageNumber:y}}}=t;n=t={annotationType:q.INK,color:Array.from(c),thickness:u,opacity:d,paths:{points:r},boxes:null,pageIndex:y-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:f,richText:p,comment:g?.str||null,creationDate:m,modificationDate:v}}const i=await super.deserialize(t,e,s);return i._initialData=n,t.comment&&i.setCommentData(t),i}get toolbarButtons(){return this._colorPicker||=new Ws(this),[["colorPicker",this._colorPicker]]}get colorType(){return lt.INK_COLOR}get colorAndOpacityType(){return lt.INK_COLOR_AND_OPACITY}get opacityType(){return lt.INK_OPACITY}updateParams(t,e){if(t===lt.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===lt.INK_COLOR_AND_OPACITY){super.updateDefaultParams(lt.INK_COLOR,e.color),super.updateDefaultParams(lt.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}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:s}=this;e.updateSVGProperty("stroke-width"),s.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:s}){this._drawingOptions=zi.getDefaultDrawingOptions({stroke:L.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":i,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:V._colorManager.convert(n),opacity:i,thickness:r,paths:{lines:e,points:s}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){const{color:e,thickness:s,opacity:n,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==s||t.opacity!==n||t.pageIndex!==i}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class Ei extends Js{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}st(5213);const mn=8,Fs=3;class ys{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};
57static#e(t,e,s,n){return s-=t,n-=e,s===0?n>0?0:4:s===1?n+6:2-n}static#s=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#n(t,e,s,n,i,r,a){const o=this.#e(s,n,i,r);for(let l=0;l<8;l++){const c=(-l+o-a+16)%8,d=this.#s[2*c],u=this.#s[2*c+1];if(t[(s+d)*e+(n+u)]!==0)return c}return-1}static#i(t,e,s,n,i,r,a){const o=this.#e(s,n,i,r);for(let l=0;l<8;l++){const c=(l+o+a+16)%8,d=this.#s[2*c],u=this.#s[2*c+1];if(t[(s+d)*e+(n+u)]!==0)return c}return-1}static#a(t,e,s,n){const i=t.length,r=new Int32Array(i);for(let c=0;c<i;c++)r[c]=t[c]<=n?1:0;for(let c=1;c<s-1;c++)r[c*e]=r[c*e+e-1]=0;for(let c=0;c<e;c++)r[c]=r[e*s-1-c]=0;let a=1,o;const l=[];for(let c=1;c<s-1;c++){o=1;for(let d=1;d<e-1;d++){const u=c*e+d,f=r[u];if(f===0)continue;let p=c,g=d;if(f===1&&r[u-1]===0)a+=1,g-=1;else if(f>=1&&r[u+1]===0)a+=1,g+=1,f>1&&(o=f);else{f!==1&&(o=Math.abs(f));continue}const m=[d,c],v=g===d+1,y={isHole:v,points:m,id:a,parent:0};l.push(y);let b;for(const I of l)if(I.id===o){b=I;break}b?b.isHole?y.parent=v?b.parent:o:y.parent=v?o:b.parent:y.parent=v?o:0;const S=this.#n(r,e,c,d,p,g,0);if(S===-1){r[u]=-a,r[u]!==1&&(o=Math.abs(r[u]));continue}let x=this.#s[2*S],w=this.#s[2*S+1];const E=c+x,C=d+w;p=E,g=C;let T=c,O=d;for(;;){const I=this.#i(r,e,T,O,p,g,1);x=this.#s[2*I],w=this.#s[2*I+1];const M=T+x,N=O+w;m.push(N,M);const D=T*e+O;if(r[D+1]===0?r[D]=-a:r[D]===1&&(r[D]=a),M===c&&N===d&&T===E&&O===C){r[u]!==1&&(o=Math.abs(r[u]));break}else p=T,g=O,T=M,O=N}}}return l}static#r(t,e,s,n){if(s-e<=4){for(let E=e;E<s-2;E+=2)n.push(t[E],t[E+1]);return}const i=t[e],r=t[e+1],a=t[s-4]-i,o=t[s-3]-r,l=Math.hypot(a,o),c=a/l,d=o/l,u=c*r-d*i,f=o/a,p=1/l,g=Math.atan(f),m=Math.cos(g),v=Math.sin(g),y=p*(Math.abs(m)+Math.abs(v)),b=p*(1-y+y**2),S=Math.max(Math.atan(Math.abs(v+m)*b),Math.atan(Math.abs(v-m)*b));let x=0,w=e;for(let E=e+2;E<s-2;E+=2){const C=Math.abs(u-c*t[E+1]+d*t[E]);C>x&&(w=E,x=C)}x>(l*S)**2?(this.#r(t,e,w+2,n),this.#r(t,w,s,n)):n.push(i,r)}static#o(t){const e=[],s=t.length;return this.#r(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#l(t,e,s,n,i,r){const a=new Float32Array(r**2),o=-2*n**2,l=r>>1;for(let g=0;g<r;g++){const m=(g-l)**2;for(let v=0;v<r;v++)a[g*r+v]=Math.exp((m+(v-l)**2)/o)}const c=new Float32Array(256),d=-2*i**2;for(let g=0;g<256;g++)c[g]=Math.exp(g**2/d);const u=t.length,f=new Uint8Array(u),p=new Uint32Array(256);for(let g=0;g<s;g++)for(let m=0;m<e;m++){const v=g*e+m,y=t[v];let b=0,S=0;for(let w=0;w<r;w++){const E=g+w-l;if(!(E<0||E>=s))for(let C=0;C<r;C++){const T=m+C-l;if(T<0||T>=e)continue;const O=t[E*e+T],I=a[w*r+C]*c[Math.abs(O-y)];b+=O*I,S+=I}}const x=f[v]=Math.round(b/S);p[x]++}return[f,p]}static#c(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e}static#u(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let n=-1/0,i=1/0;for(let a=0,o=s.length;a<o;a++){const l=s[a]=t[a<<2];n=Math.max(n,l),i=Math.min(i,l)}const r=255/(n-i);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-i)*r;return s}static#d(t){let e,s=-1/0,n=-1/0;const i=t.findIndex(o=>o!==0);let r=i,a=i;for(e=i;e<256;e++){const o=t[e];o>s&&(e-r>n&&(n=e-r,a=e-1),s=o,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#f(t){const e=t,{width:s,height:n}=t,{maxDim:i}=this.#t;let r=s,a=n;if(s>i||n>i){let u=s,f=n,p=Math.log2(Math.max(s,n)/i);const g=Math.floor(p);p=p===g?g-1:g;for(let v=0;v<p;v++){r=Math.ceil(u/2),a=Math.ceil(f/2);const y=new OffscreenCanvas(r,a);y.getContext("2d").drawImage(t,0,0,u,f,0,0,r,a),u=r,f=a,t!==e&&t.close(),t=y.transferToImageBitmap()}const m=Math.min(i/r,i/a);r=Math.round(r*m),a=Math.round(a*m)}const l=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,r,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,r,a);const c=l.getImageData(0,0,r,a).data;return[this.#u(c),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:n},i,r,a,o){let l=new OffscreenCanvas(1,1),c=l.getContext("2d",{alpha:!1});const d=200,u=c.font=`${s} ${n} ${d}px ${e}`,{actualBoundingBoxLeft:f,actualBoundingBoxRight:p,actualBoundingBoxAscent:g,actualBoundingBoxDescent:m,fontBoundingBoxAscent:v,fontBoundingBoxDescent:y,width:b}=c.measureText(t),S=1.5,x=Math.ceil(Math.max(Math.abs(f)+Math.abs(p)||0,b)*S),w=Math.ceil(Math.max(Math.abs(g)+Math.abs(m)||d,Math.abs(v)+Math.abs(y)||d)*S);l=new OffscreenCanvas(x,w),c=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=u,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,x,w),c.fillStyle="black",c.fillText(t,x*(S-1)/2,w*(3-S)/2);const E=this.#u(c.getImageData(0,0,x,w).data),C=this.#c(E),T=this.#d(C),O=this.#a(E,x,w,T);return this.processDrawnLines({lines:{curves:O,width:x,height:w},pageWidth:i,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,n,i){const[r,a,o]=this.#f(t),[l,c]=this.#l(r,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),d=this.#d(c),u=this.#a(l,a,o,d);return this.processDrawnLines({lines:{curves:u,width:a,height:o},pageWidth:e,pageHeight:s,rotation:n,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:n,innerMargin:i,mustSmooth:r,areContours:a}){n%180!==0&&([e,s]=[s,e]);const{curves:o,width:l,height:c}=t,d=t.thickness??0,u=[],f=Math.min(e/l,s/c),p=f/e,g=f/s,m=[];for(const{points:y}
vendor: 8,406 bytes, line 57
57of o){const b=r?this.#o(y):y;if(!b)continue;m.push(b);const S=b.length,x=new Float32Array(S),w=new Float32Array(3*(S===2?2:S-2));if(u.push({line:w,points:x}),S===2){x[0]=b[0]*p,x[1]=b[1]*g,w.set([NaN,NaN,NaN,NaN,x[0],x[1]],0);continue}let[E,C,T,O]=b;E*=p,C*=g,T*=p,O*=g,x.set([E,C,T,O],0),w.set([NaN,NaN,NaN,NaN,E,C],0);for(let I=4;I<S;I+=2){const M=x[I]=b[I]*p,N=x[I+1]=b[I+1]*g;w.set(H.createBezierPoints(E,C,T,O,M,N),(I-2)*3),[E,C,T,O]=[T,O,M,N]}}if(u.length===0)return null;const v=a?new Ei:new Js;return v.build(u,e,s,1,n,a?0:d,i),{outline:v,newCurves:m,areContours:a,thickness:d,width:l,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:n,height:i}){let r=1/0,a=-1/0,o=0;for(const y of t){o+=y.length;for(let b=2,S=y.length;b<S;b++){const x=y[b]-y[b-2];r=Math.min(r,x),a=Math.max(a,x)}}let l;r>=-128&&a<=127?l=Int8Array:r>=-32768&&a<=32767?l=Int16Array:l=Int32Array;const c=t.length,d=mn+Fs*c,u=new Uint32Array(d);let f=0;u[f++]=d*Uint32Array.BYTES_PER_ELEMENT+(o-2*c)*l.BYTES_PER_ELEMENT,u[f++]=0,u[f++]=n,u[f++]=i,u[f++]=e?0:1,u[f++]=Math.max(0,Math.floor(s??0)),u[f++]=c,u[f++]=l.BYTES_PER_ELEMENT;for(const y of t)u[f++]=y.length-2,u[f++]=y[0],u[f++]=y[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(u);const m=l.prototype.constructor;for(const y of t){const b=new m(y.length-2);for(let S=2,x=y.length;S<x;S++)b[S-2]=y[S]-y[S-2];g.write(b)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),i=n.getWriter();await i.ready,i.write(e).then(async()=>{await i.ready,await i.close()}).catch(()=>{});let r=null,a=0;for await(const b of s)r||=new Uint8Array(new Uint32Array(b.buffer,0,4)[0]),r.set(b,a),a+=b.length;const o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(l!==0)throw new Error(`Invalid version: ${l}`);const c=o[2],d=o[3],u=o[4]===0,f=o[5],p=o[6],g=o[7],m=[],v=(mn+Fs*p)*Uint32Array.BYTES_PER_ELEMENT;let y;switch(g){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(r.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(r.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(r.buffer,v);break}a=0;for(let b=0;b<p;b++){const S=o[Fs*b+mn],x=new Float32Array(S+2);m.push(x);for(let w=0;w<Fs-1;w++)x[w]=o[Fs*b+mn+w+1];for(let w=0;w<S;w++)x[w+2]=x[w]+y[a++]}return{areContours:u,thickness:f,outlines:m,width:c,height:d}}catch(e){return Q(`decompressSignature: ${e}`),null}}}class Gi extends _i{constructor(){super(),super.updateProperties({fill:V._defaultLineColor,"stroke-width":0})}clone(){const t=new Gi;return t.updateAll(this),t}}class Vi extends Gn{constructor(t){super(t),super.updateProperties({stroke:V._defaultLineColor,"stroke-width":1})}clone(){const t=new Vi(this._viewParameters);return t.updateAll(this),t}}class Ee extends ot{#t=!1;#e=null;#s=null;#n=null;static _type="signature";static _editorType=q.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#s=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){V.initialize(t,e),this._defaultDrawingOptions=new Gi,this._defaultDrawnSignatureOptions=new Vi(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Y(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(this.#s){const{lines:n,mustSmooth:i,areContours:r,description:a,uuid:o,heightInPage:l}=this.#s,{rawDims:{pageWidth:c,pageHeight:d},rotation:u}=this.parent.viewport,f=ys.processDrawnLines({lines:n,pageWidth:c,pageHeight:d,rotation:u,innerMargin:Ee._INNER_MARGIN,mustSmooth:i,areContours:r});this.addSignature(f,l,a,o)}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.#e||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#n=t,this.addEditToolbar()}getUuid(){return this.#n}get description(){return this.#e}set description(t){this.#e=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:s,width:n,height:i}=this.#s,r=Math.max(n,i),a=ys.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:s,width:n,height:i},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,n){const{x:i,y:r}=this,{outline:a}=this.#s=t;this.#t=a instanceof Ei,this.description=s;let o;this.#t?o=Ee.getDefaultDrawingOptions():(o=Ee._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let c=e/l;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=i,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:!!s}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:n}=this.parent.viewport;return ys.process(t,e,s,n,Ee._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:n},rotation:i}=this.parent.viewport;return ys.extractContoursFromText(t,e,s,n,i,Ee._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:n}=this.parent.viewport;return ys.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:n,innerMargin:Ee._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Ee.getDefaultDrawingOptions():(this._drawingOptions=Ee._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,i=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:n});return this.addComment(i),t?(i.paths={lines:e,points:s},i.uuid=this.#n,i.isCopy=!0):i.lines=e,this.#e&&(i.accessibilityData={type:"Figure",alt:this.#e}),i}static deserializeDraw(t,e,s,n,i,r){return r.areContours?Ei.deserialize(t,e,s,n,i,r):Js.deserialize(t,e,s,n,i,r)}static async deserialize(t,e,s){const n=await super.deserialize(t,e,s);return n.#t=t.areContours,n.description=t.accessibilityData?.alt||"",n.#n=t.uuid,n}}class Rc extends V{#t=null;#e=null;#s=null;#n=null;#i=null;#a="";#r=null;#o=!1;#l=null;#c=!1;#u=!1;static _type="stamp";static _editorType=q.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#n=t.bitmapUrl,this.#i=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){V.initialize(t,e)}static isHandlingMimeForPasting(t){return gi.includes(t)}static paste(t,e){e.pasteEditor({mode:q.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}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#c=t.isSvg),t.file&&(this.#a=t.file.name),this.#m()}
57#f(){if(this.#s=null,this._uiManager.enableWaiting(!1),!!this.#r){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){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:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:i,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:n,width:i,height:r,channels:n.length/(i*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}#g(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#d(s,!0)).finally(()=>this.#f());return}if(this.#n){const s=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then(n=>this.#d(n)).finally(()=>this.#f());return}if(this.#i){const s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then(n=>this.#d(n)).finally(()=>this.#f());return}const t=document.createElement("input");t.type="file",t.accept=gi.join(",");const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(n)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#f()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#l&&(clearTimeout(this.#l),this.#l=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#g();return}super.rebuild(),this.div!==null&&(this.#e&&this.#r===null&&this.#g(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#n||this.#i||this.#e||this.#o)}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.#o||(this.#t?this.#m():this.#g()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:n}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(this.#e=s,n&&(this.#t=n),this.#o=!1,this.#m())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#l!==null&&clearTimeout(this.#l);const t=200;this.#l=setTimeout(()=>{this.#l=null,this.#p()},t)}#m(){const{div:t}=this;let{width:e,height:s}=this.#t;const[n,i]=this.pageDimensions,r=.75;if(this.width)e=this.width*n,s=this.height*i;else if(e>r*n||s>r*i){const o=Math.min(r*n/e,r*i/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);const a=this.#r=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/n,this.height=s/i,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#p(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#a&&this.div.setAttribute("aria-description",this.#a),this.annotationElementId||this._uiManager.a11yAlert(V._l10nAlert.stamp)}copyCanvas(t,e,s=!1){t||=224;const{width:n,height:i}=this.#t,r=new ge;let a=this.#t,o=n,l=i,c=null;if(e){if(n>e||i>e){const w=Math.min(e/n,e/i);o=Math.floor(n*w),l=Math.floor(i*w)}c=document.createElement("canvas");const u=c.width=Math.ceil(o*r.sx),f=c.height=Math.ceil(l*r.sy);this.#c||(a=this.#h(u,f));const p=c.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",m="#cfcfd8";this._uiManager.hcmFilter!=="none"?m="black":jo.isDarkMode&&(g="#8f8f9d",m="#42414d");const v=15,y=v*r.sx,b=v*r.sy,S=new OffscreenCanvas(y*2,b*2),x=S.getContext("2d");x.fillStyle=g,x.fillRect(0,0,y*2,b*2),x.fillStyle=m,x.fillRect(0,0,y,b),x.fillRect(y,b,y,b),p.fillStyle=p.createPattern(S,"repeat"),p.fillRect(0,0,u,f),p.drawImage(a,0,0,a.width,a.height,0,0,u,f)}let d=null;if(s){let u,f;if(r.symmetric&&a.width<t&&a.height<t)u=a.width,f=a.height;else if(a=this.#t,n>t||i>t){const m=Math.min(t/n,t/i);u=Math.floor(n*m),f=Math.floor(i*m),this.#c||(a=this.#h(u,f))}const g=new OffscreenCanvas(u,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,f),d={width:u,height:f,data:g.getImageData(0,0,u,f).data}}return{canvas:c,width:o,height:l,imageData:d}}#h(t,e){const{width:s,height:n}=this.#t;let i=s,r=n,a=this.#t;for(;i>2*t||r>2*e;){const o=i,l=r;i>2*t&&(i=Math.ceil(i/2)),r>2*e&&(r=Math.ceil(r/2));const c=new OffscreenCanvas(i,r);c.getContext("2d").drawImage(a,0,0,o,l,0,0,i,r),a=c.transferToImageBitmap()}return a}#p(){const[t,e]=this.parentDimensions,{width:s,height:n}=this,i=new ge,r=Math.ceil(s*t*i.sx),a=Math.ceil(n*e*i.sy),o=this.#r;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#c?this.#t:this.#h(r,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#v(t){if(t){if(this.#c){const n=this._uiManager.imageManager.getSvgUrl(this.#e);if(n)return n}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#c){const[e,s]=this.pageDimensions,n=Math.round(this.width*e*Ts.PDF_TO_CSS_UNITS),i=Math.round(this.height*s*Ts.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(n,i);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.he
vendor: 5,854 bytes, line 57
57ight,0,0,n,i),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let n=null,i=!1;if(t instanceof Ra){const{data:{rect:g,rotation:m,id:v,structParent:y,popupRef:b,richText:S,contentsObj:x,creationDate:w,modificationDate:E},container:C,parent:{page:{pageNumber:T}},canvas:O}=t;let I,M;O?(delete t.canvas,{id:I,bitmap:M}=s.imageManager.getFromCanvas(C.id,O),O.remove()):(i=!0,t._hasNoCanvas=!0);const N=(await e._structTree.getAriaAttributes(`${bs}${v}`))?.get("aria-label")||"";n=t={annotationType:q.STAMP,bitmapId:I,bitmap:M,pageIndex:T-1,rect:g.slice(0),rotation:m,annotationElementId:v,id:v,deleted:!1,accessibilityData:{decorative:!1,altText:N},isSvg:!1,structParent:y,popupRef:b,richText:S,comment:x?.str||null,creationDate:w,modificationDate:E}}const r=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:c,isSvg:d,accessibilityData:u}=t;i?(s.addMissingCanvas(t.id,r),r.#o=!0):c&&s.imageManager.isValidId(c)?(r.#e=c,o&&(r.#t=o)):r.#n=l,r.#c=d;const[f,p]=r.pageDimensions;return r.width=(a[2]-a[0])/f,r.height=(a[3]-a[1])/p,u&&(r.altTextData=u),r._initialData=n,t.comment&&r.setCommentData(t),r.#u=!!n,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#c});if(this.addComment(s),t)return s.bitmapUrl=this.#v(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:n,altText:i}=this.serializeAltText(!1);if(!n&&i&&(s.accessibilityData={type:"Figure",alt:i}),this.annotationElementId){const a=this.#y(s);return a.isSame?null:(a.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1,s.id=this.annotationElementId,delete s.bitmapId,s)}if(e===null)return s;e.stamps||=new Map;const r=this.#c?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#v(!1);else if(this.#c){const a=e.stamps.get(this.#e);r>a.area&&(a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#v(!1))}return s}#y(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,n=t.pageIndex===e,i=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&i,isSameAltText:i}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Ne{#t;#e=!1;#s=null;#n=null;#i=null;#a=new Map;#r=!1;#o=!1;#l=!1;#c=null;#u=null;#d=null;#f=null;#g=null;#m=-1;#h;static _initialized=!1;static#p=new Map([Bt,zi,Rc,ue,Ee].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:n,accessibilityManager:i,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:c}){const d=[...Ne.#p.values()];if(!Ne._initialized){Ne._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),this.#h=t,this.pageIndex=e,this.div=s,this.#t=i,this.#s=r,this.viewport=l,this.#d=o,this.drawLayer=a,this._structTree=n,this.#h.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#h.getMode()===q.NONE}updateToolbar(t){this.#h.updateToolbar(t)}updateMode(t=this.#h.getMode()){switch(this.#w(),t){case q.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case q.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case q.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===q.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of Ne.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#h.setEditingState(t)}addCommands(t){this.#h.addCommands(t)}cleanUndoStack(t){this.#h.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.togglePointerEvents(t)}get#v(){return this.#a.size!==0?this.#a.values():this.#h.getEditors(this.pageIndex)}async enable(){this.#l=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#g?.abort(),this.#g=null;const t=new Set;for(const s of this.#v)s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#h.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));const e=this.#s;if(e)for(const s of e.getEditableAnnotations()){if(s.hide(),this.#h.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const n=await this.deserialize(s);n&&(this.addOrRebuild(n),n.enableEditing())}this.#l=!1,this.#h._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#g){this.#g=new AbortController;const n=this.#h.combinedSignal(this.#g);this.#d.div.addEventListener("pointerdown",i=>{const{clientX:a,clientY:o,timeStamp:l}=i,c=this.#m;if(l-c>500){this.#m=l;return}this.#m=-1;const{classList:d}=this.div;d.toggle("getElements",!0);const u=document.elementsFromPoint(a,o);if(d.toggle("getElements",!1),!this.div.contains(u[0]))return;let f;const p=new RegExp(`^${Es}[0-9]+$`);for(const m of u)if(p.test(m.id)){f=m.id;break}if(!f)return;const g=this.#a.get(f);g?.annotationElementId===null&&(Lt(i),g.dblclick(i))},{signal:n,capture:!0})}const t=this.#s,e=[];
57if(t){const n=new Map,i=new Map;for(const r of this.#v){if(r.disableEditing(),!r.annotationElementId){e.push(r);continue}if(r.serialize()!==null){n.set(r.annotationElementId,r);continue}else i.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}for(const r of t.getEditableAnnotations()){const{id:a}=r.data;if(this.#h.isDeletedAnnotationElement(a)){r.updateEdited({deleted:!0});continue}let o=i.get(a);if(o){o.resetAnnotationElement(r),o.show(!1),r.show();continue}o=n.get(a),o&&(this.#h.addChangedExistingAnnotation(o),o.renderAnnotationElement(r)&&o.show(!1)),r.show()}}this.#w(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of Ne.#p.values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#h.getActive()!==t&&this.#h.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;const t=this.#h.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#y.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting"))}#y(t){this.#h.unselectAll();const{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#d.div.contains(e)){const{isMac:s}=mt.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#h.showAllEditors("highlight",!0,!0),ue.startDrawing(this,this.#h,this.#h.direction==="ltr",t),t.preventDefault()}}enableClick(){if(this.#n)return;this.#n=new AbortController;const t=this.#h.combinedSignal(this.#n);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.#n?.abort(),this.#n=null}attach(t){this.#a.set(t.id,t);const{annotationElementId:e}=t;e&&this.#h.isDeletedAnnotationElement(e)&&this.#h.removeDeletedAnnotationElement(t)}detach(t){this.#a.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#h.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#h.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#h.addDeletedAnnotationElement(t),V.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.#h.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#l),this.#h.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#i&&(t._focusEventsAllowed=!1,this.#i=setTimeout(()=>{this.#i=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#h._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of this.#a.values())if(e.uid===t)return e;return null}get#b(){return Ne.#p.get(this.#h.getMode())}combinedSignal(t){return this.#h.combinedSignal(t)}#x(t){const e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#h.updateMode(t.mode);const{offsetX:s,offsetY:n}=this.#S(),i=this.#h.getId(),r=this.#x({parent:this,id:i,x:s,y:n,uiManager:this.#h,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await Ne.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#h)||null}createAndAddNewEditor(t,e,s={}){const n=this.#h.getId(),i=this.#x({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:this.#h,isCentered:e,...s});return i&&this.add(i),i}get boundingClientRect(){return this.div.getBoundingClientRect()}#S(){const{x:t,y:e,width:s,height:n}=this.boundingClientRect,i=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+n),l=(i+a)/2-t,c=(r+o)/2-e,[d,u]=this.viewport.rotation%180===0?[l,c]:[c,l];return{offsetX:d,offsetY:u}}addNewEditor(t={}){this.createAndAddNewEditor(this.#S(),!0,t)}setSelected(t){this.#h.setSelected(t)}toggleSelected(t){this.#h.toggleSelected(t)}unselect(t){this.#h.unselect(t)}pointerup(t){const{isMac:e}=mt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!this.#r||(this.#r=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings))return;if(!this.#e){this.#e=!0;return}const s=this.#h.getMode();if(s===q.STAMP||s===q.POPUP||s===q.SIGNATURE){this.#h.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#h.getMode()===q.HIGHLIGHT&&this.enableTextSelection(),this.#r){this.#r=!1;return}const{isMac:e}=mt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#r=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}const s=this.#h.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#c){this.#b.startDrawing(this,this.#h,!1,t);return}this.#h.setCurrentDrawingSession(this),this.#c=new AbortController;const e=this.#h.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#b.startDrawing(this,this.#h,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#c?(this.#h.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#u=null,this.#b.endDrawing(t)):null}findNewParent(t,e,s){const n=this.#h.findParent(e,s);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return this.#c?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#c&&this.#b.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#h.getActive()?.parent===this&&(this.#h.commitOrRemove(),this.#h.setActiveEditor(null)),this.#i&&(clearTimeout(this.#i),this.#i=null);for(const t of this.#a.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#a.clear(),this.#h.removeLayer(this)}#w(){for(const t of this.#a.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,ns(this.div,t);for(const e of this.#h.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#h.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#h.commitOrRemove(),this.#w();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ns(this.div,{rotation:s}),e!==s)for(const n of this.#a.values())n.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#h.viewParameters.realScale}}st(1806);function Nc(h,t){return h===t?0:h.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function vn(h){return h?h.nodeType===Node.ELEMENT_NODE?h.closest(".textLayer"):h.parentElement?.closest(".textLayer")||null:null}function kc(h,t,e,s){if(h===e)return t<=s;const n=h.compareDocumentPosition(e);return n&Node.DOCUMENT_POSITION_FOLLOWING?!0:n&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function Qr(h,t,e){if(h.nodeType!==Node.ELEMENT_NODE||!h.classList.contains("textLayer")||t!==h.childNodes.length)return{container:h,offset:t};let s=h.lastChild;return s?.nodeType===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}class Z{#t=null;#e=new Map;#s=null;#n=null;#i=null;#a=null;#r=new Map;static#o=0;static#l=0;static#c=null;static#u=new Set;static#d=!1;static#f=new Set;static#g=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:n=null}){if(this.pageIndex=s,this.#n=t,this.#i=e,n){const i=Z.#g.get(n);if(i?.selectionDiv&&(i.selectionDiv.remove(),Z.#u.delete(i.selectionDiv)),Z.#g.set(n,{drawLayer:this}),Z.#f.add(n),this.#s=n,this.#a=new MutationObserver(r=>{if(!(!this.#t||!this.#s?.isConnected||!Z.#h())){for(const{addedNodes:a}of r)for(const o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){Z.#v();return}}}),this.#a.observe(n,{childList:!0}),Z.#c===null){Z.#c=new AbortController;const{signal:r}=Z.#c;document.addEventListener("selectionchange",Z.#v.bind(Z),{signal:r}),document.addEventListener("pointerdown",()=>{Z.#d=!0},{signal:r}),document.addEventListener("pointerup",()=>{Z.#d=!1},{signal:r}),window.addEventListener("blur",()=>{Z.#d=!1},{signal:r})}}}setParent(t){if(!this.#t){this.#t=t,this.#s?.isConnected&&Z.#h()&&Z.#v();return}if(this.#t!==t){if(this.#e.size>0)for(const e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static#m(t){const e=this.#g.get(t);e?.selectionDiv&&(e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null)}static#h(){const t=document.getSelection();return!!t&&!t.isCollapsed}static#p(){return this.#f.keys().filter(t=>t.isConnected).toArray().sort(Nc)}static#v(){const t=document.getSelection();if(!t||t.isCollapsed){for(const r of this.#u)r.remove();this.#u.clear();return}const e=new WeakMap,s=this.#p(),n=[];for(let r=0,a=t.rangeCount;r<a;r++){const o=t.getRangeAt(r);if(o.collapsed)continue;let{startContainer:l,startOffset:c,endContainer:d,endOffset:u}=o,f=vn(l),p=vn(d);const g=f===null,m=p===null;if(this.#d&&g!==m)return;if(t.rangeCount===1){const{anchorNode:b,anchorOffset:S,focusNode:x,focusOffset:w}=t,E=vn(b),C=vn(x),T=kc(b,S,x,w);E&&C&&T!==null&&(T?(l=b,c=S,f=E,d=x,u=w,p=C):(l=x,c=w,f=C,d=b,u=S,p=E))}const v=s.filter(b=>o.intersectsNode(b));if(v.length===0)continue;let y=!1;if(f||(f=v[0],l=f,c=0,y=!0),p||(p=v.at(-1),d=p,u=p.childNodes.length,y=!0),d.nodeType===Node.ELEMENT_NODE){if(d.classList.contains("endOfContent")){const b=d.previousSibling;if(!b)continue;
57d=b,u=b.nodeType===Node.TEXT_NODE?b.textContent.length:b.childNodes.length}else if(d.classList.contains("textLayer")&&d.childNodes.length===u){const b=Qr(d,u,p);if(!b)continue;d=b.container,u=b.offset}}if(l.nodeType===Node.ELEMENT_NODE){const b=Qr(l,c,f);if(!b)continue;l=b.container,c=b.offset}if(f===p&&!y&&v.includes(f)){n.push([o,f]);continue}for(const b of v){const S=b.firstChild;if(!S)continue;const x=document.createRange();if(b===f?x.setStart(l,c):x.setStartBefore(S),b===p)x.setEnd(d,u);else{const w=b.lastChild;if(!w)continue;if(w.nodeType===Node.ELEMENT_NODE&&w.classList.contains("endOfContent")){const E=w.previousSibling;if(!E)continue;x.setEndAfter(E)}else x.setEndAfter(w)}x.collapsed||n.push([x,b])}}const i=new Set(n.map(r=>r[1]));for(const r of this.#f)i.has(r)||this.#m(r);for(const[r,a]of n){const o=Z.#g.get(a);if(!o)continue;let l=e.get(a);if(!l){const p=a.getBoundingClientRect();l=(g,m,v,y)=>({x:(g-p.x)/p.width,y:(m-p.y)/p.height,width:v/p.width,height:y/p.height}),e.set(a,l)}const c=[];for(let{x:p,y:g,width:m,height:v}of r.getClientRects())m===0||v===0||({x:p,y:g,width:m,height:v}=l(p,g,m,v),!(m===1&&v===1)&&c.push(`M${p} ${g} h${m} v${v} h-${m} Z`));if(c.length===0)continue;const d=o.drawLayer;let u=o.selectionDiv,f=o.path;if(!u){const p=`clip_selection_${Z.#l++}`;u=document.createElement("div"),u.className="selection",u.style.clipPath=`url(#${p})`;const g=d.#n?.createSelectionStyle(d.#i);if(g)for(const[y,b]of Object.entries(g))u.style.setProperty(y,b);const m=Z._svgFactory.create(1,1,!0);m.setAttribute("aria-hidden","true"),m.setAttribute("width","100%"),m.setAttribute("height","100%");const v=Z._svgFactory.createElement("clipPath");v.setAttribute("id",p),v.setAttribute("clipPathUnits","objectBoundingBox"),f=Z._svgFactory.createElement("path"),v.append(f),m.append(v),u.append(m),o.path=f,o.selectionDiv=u}d.#t&&u.parentNode!==d.#t&&(d.#t.append(u),this.#u.add(u)),f.setAttribute("d",c.join(" "))}}static get _svgFactory(){return Y(this,"_svgFactory",new Pn)}static#y(t,[e,s,n,i]){const{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*n}%`,r.height=`${100*i}%`}#b(){const t=Z._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#x(t,e){const s=Z._svgFactory.createElement("clipPath");t.append(s);const n=`clip_${e}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const i=Z._svgFactory.createElement("use");return s.append(i),i.setAttribute("href",`#${e}`),i.classList.add("clip"),n}#S(t,e){for(const[s,n]of Object.entries(e))n===null?t.removeAttribute(s):t.setAttribute(s,n)}draw(t,e=!1,s=!1){const n=Z.#o++,i=this.#b(),r=Z._svgFactory.createElement("defs");i.append(r);const a=Z._svgFactory.createElement("path");r.append(a);const o=`path_${n}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#r.set(n,a);const l=s?this.#x(r,o):null,c=Z._svgFactory.createElement("use");return i.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(i,t),this.#e.set(n,i),{id:n,clipPathId:`url(#${l})`}}drawOutline(t,e){const s=Z.#o++,n=this.#b(),i=Z._svgFactory.createElement("defs");n.append(i);const r=Z._svgFactory.createElement("path");i.append(r);const a=`path_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const d=Z._svgFactory.createElement("mask");i.append(d),o=`mask_${s}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=Z._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=Z._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=Z._svgFactory.createElement("use");n.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return n.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(n,t),this.#e.set(s,n),s}finalizeDraw(t,e){this.#r.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:s,bbox:n,rootClass:i,path:r}=e,a=typeof t=="number"?this.#e.get(t):t;if(a){if(s&&this.#S(a,s),n&&Z.#y(a,n),i){const{classList:o}=a;for(const[l,c]of Object.entries(i))o.toggle(l,c)}if(r){const l=a.firstElementChild.firstElementChild;this.#S(l,r)}}}updateParent(t,e){if(e===this)return;const s=this.#e.get(t);s&&(e.#t.append(s),this.#e.delete(t),e.#e.set(t,s))}remove(t){this.#r.delete(t),this.#t!==null&&(this.#e.get(t).remove(),this.#e.delete(t))}destroy(){this.#t=null;for(const t of this.#e.values())t.remove();this.#e.clear(),this.#r.clear(),this.#a?.disconnect(),this.#a=null,this.#s&&(Z.#g.get(this.#s)?.drawLayer===this&&(Z.#m(this.#s),Z.#g.delete(this.#s),Z.#f.delete(this.#s),Z.#f.size===0&&(Z.#c?.abort(),Z.#c=null,Z.#d=!1)),this.#s=null)}}function yn(h){return`${(h*100).toFixed(2)}%`}class In{#t=[];#e=new Map;#s=null;#n=0;#i=0;#a=0;static#r=null;constructor(t,e,s,n){this.#n=t,this.#t=e,this.#i=s.rawDims.pageWidth,this.#a=s.rawDims.pageHeight,this.#s=n}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){const s=this.#o(this.#t.subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,n=this.#e.get(s);if(!n)return;const i=In.#r?.deref();if(i===s)return;i&&(i.width=0,i.height=0),In.#r=new WeakRef(s);const{inverseTransform:r,x1:a,y1:o,width:l,height:c}=n,d=this.#s(),u=Math.ceil(a*d.width),f=Math.ceil(o*d.height),p=Math.floor((a+l/this.#i)*d.width),g=Math.floor((o+c/this.#a)*d.height);s.width=p-u,s.height=g-f;const m=s.getContext("2d");m.setTransform(...r),m.translate(-u,-f),m.drawImage(d,0,0)}),t}#o([t,e,s,n,i,r]){const a=Math.hypot((i-t)*this.#i,(r-e)*this.#a),o=Math.hypot((s-t)*this.#i,(n-e)*this.#a);if(a<this.#n||o<this.#n)return null;const l=[(i-t)*this.#i/a,(r-e)*this.#a/a,(s-t)*this.#i/o,(n-e)*this.#a/o,0,0],c=L.inverseTransform(l),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:yn(t),top:yn(e),width:yn(a/this.#i),height:yn(o/this.#a),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(d,{inverseTransform:c,width:a,height:o,x1:t,y1:e}),d}}globalThis._pdfjsTestingUtils={HighlightOutliner:wi};globalThis.pdfjsLib={AbortException:$e,AnnotationEditorLayer:Ne,AnnotationEditorParamsType:lt,AnnotationEditorType:q,AnnotationEditorUIManager:He,AnnotationLayer:ji,AnnotationMode:_e,AnnotationType:It,applyOpacity:Uo,build:oc,ColorPicker:ce,createValidAbsoluteUrl:na,CSSConstants:_o,DOMSVGFactory:Pn,DrawLayer:Z,FeatureTest:mt,fetchData:Ci,findContrastColor:$o,getDocument:Ea,getFilenameFromUrl:Fo,getPdfFilenameFromUrl:Lo,getRGB:Qs,getRGBA:Ks,getUuid:ra,GlobalWorkerOptions:ws,ImageKind:xn,InvalidPDFException:ui,isDataScheme:Fn,isPdfFile:Ii,isValidExplicitDest:hl,makeArr:Cs,makeMap:Ti,makeObj:fi,makeSet:No,MathClamp:xt,noContextMenu:pe,normalizeUnicode:Mo,OPS:Te,OutputScale:ge,PasswordException:di,PasswordResponses:So,PDFDataRangeTransport:Ta,PDFDateString:pi,PDFWorker:Vs,PermissionFlag:wo,PixelsPerInch:Ts,RenderingCancelledException:Pi,renderRichText:oa,ResponseException:En,setLayerDimensions:ns,shadow:Y,SignatureExtractor:ys,stopEvent:Lt,SupportedImageMimeTypes:gi,TextLayer:ee,TextLayerImages:In,TouchManager:ha,updateUrlHash:ia,Util:L,VerbosityLevel:Rn,version:ac,XfaLayer:aa};const Dc="/assets/pdf.worker.min-BmVo14Nb.mjs";ws.workerSrc=Dc;const bn="/pdfjs-assets/";function Fc({url:h,authToken:t}){const e=U.useRef(null),[s,n]=U.useState(0),[i,r]=U.useState(!0),[a,o]=U.useState(null),[l,c]=U.useState(1),d=U.useRef([]),u=U.useRef([]),[f,p]=U.useState(null);U.useEffect(()=>{if(!h)return;let y=!1;async function b(){r(!0),o(null),n(0),p(null),d.current=[];for(const S of u.current)try{S.cancel()}catch{}u.current=[];try{const S={url:h,withCredentials:!1,wasmUrl:`${bn}wasm/`,iccUrl:`${bn}iccs/`,cMapUrl:`${bn}cmaps/`,cMapPacked:!0,standardFontDataUrl:`${bn}standard_fonts/`};t&&(S.httpHeaders={Authorization:`Bearer ${t}`});const x=Ea(S),w=await x.promise;if(y){x.destroy();return}p(w),n(w.numPages),r(!1),c(1)}catch(S){if(y)return;console.error("[PdfViewer] load error:",S),o("Failed to load PDF. Please try again."),r(!1)}}return b(),()=>{y=!0;for(const S of u.current)try{S.cancel()}catch{}u.current=[]}},[h,t]),U.useEffect(()=>{if(!f||s===0)return;let y=!1;async function b(){for(let S=1;S<=s&&!y;S++)await g(f,S)}return b(),()=>{y=!0}},[f,s]);async function g(y,b){const S=d.current[b-1];if(!S)return;const x=await y.getPage(b),w=window.devicePixelRatio||1,E=e.current?.clientWidth||700,C=x.getViewport({scale:1}),T=E/C.width*w,O=x.getViewport({scale:T});S.width=O.width,S.height=O.height,S.style.width=`${E}
57px`,S.style.height=`${O.height/w}px`;const I=S.getContext("2d");if(!I)return;const M=x.render({canvasContext:I,viewport:O,canvas:S});u.current.push(M);try{await M.promise}catch(N){if(N&&typeof N=="object"&&"name"in N&&N.name==="RenderingCancelledException")return;console.warn(`[PdfViewer] page ${b} render error:`,N)}}function m(){if(!e.current||s===0)return;const y=e.current.scrollTop,b=e.current.clientHeight;for(let S=0;S<d.current.length;S++){const x=d.current[S];if(!x)continue;const w=x.offsetTop,E=w+x.offsetHeight;if(w<y+b*.6&&E>y){c(S+1);break}}}function v(y){y.preventDefault(),y.stopPropagation()}return A.jsxs("div",{className:"flex flex-col h-full bg-gray-800",children:[A.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-gray-900 text-white text-xs select-none shrink-0",children:[A.jsx("span",{className:"font-medium text-gray-300",children:"Study Materials"}),s>0&&A.jsxs("span",{className:"text-gray-500",children:["Page ",l," of ",s]})]}),A.jsxs("div",{ref:e,onScroll:m,onContextMenu:v,onMouseDown:v,onDragStart:v,className:"flex-1 overflow-y-auto overflow-x-hidden",style:{userSelect:"none",WebkitUserSelect:"none"},children:[i&&A.jsxs("div",{className:"flex items-center justify-center h-40 text-gray-300 text-sm gap-2",children:[A.jsxs("svg",{className:"animate-spin h-5 w-5",viewBox:"0 0 24 24",fill:"none",children:[A.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),A.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}),"Loading document…"]}),a&&A.jsx("div",{className:"flex items-center justify-center h-40 text-red-400 text-sm",children:a}),!i&&!a&&A.jsx("div",{className:"flex flex-col items-center gap-3 py-3 px-3",children:Array.from({length:s},(y,b)=>A.jsx("div",{className:"shadow-lg rounded overflow-hidden w-full",children:A.jsx("canvas",{ref:S=>{d.current[b]=S},className:"block w-full",style:{display:"block",maxWidth:"100%"}})},b))})]})]})}function Lc(h){const t=h.replace(/^https?:\/\/[^/]+\/api\/storage\/objects\//i,"").replace(/^\/api\/storage\/objects\//,"");return`${sa}/storage/pdf-view?path=${encodeURIComponent(t)}`}function Jr(h){return h?h.stepType==="quiz"||h.title==="Quiz"||/\s*[–-]\s*quiz\s*$/i.test(h.title):!1}const Bc="msa-keep-awake",jc=2e4;let On=!1,Zr=!1,qr=0,As=null,ta=!1;function _c(){const h=window.ReactNativeWebView;return h&&typeof h.postMessage=="function"?h:null}async function La(){if(!(As||!("wakeLock"in navigator)||document.visibilityState!=="visible"))try{const h=await navigator.wakeLock.request("screen");h.addEventListener("release",()=>{As===h&&(As=null)}),As=h,On||Ba()}catch{}}function Ba(){const h=As;As=null,h?.release().catch(()=>{})}function Uc(){ta||(ta=!0,document.addEventListener("visibilitychange",()=>{On&&La()}))}function ea(h){const t=_c();if(t){const e=Date.now();if(h!==Zr||h&&e-qr>=jc){Zr=h,qr=e;try{t.postMessage(JSON.stringify({type:Bc,on:h}))}catch{}}}h!==On&&(On=h,h?(Uc(),La()):Ba())}function $c(h){return h>=100?"Course complete — outstanding!":h>=75?"Almost there — finish strong!":h>=50?"More than halfway. Excellent consistency!":h>=25?"You're building real progress!":h>0?"Great start! Keep the momentum going.":"Begin your journey — one lesson at a time!"}function Hc({percent:h}){const e=2*Math.PI*24,s=Math.max(0,Math.min(100,h))/100*e;return A.jsxs("div",{className:"relative w-16 h-16 shrink-0",children:[A.jsxs("svg",{viewBox:"0 0 60 60",className:"w-full h-full -rotate-90",children:[A.jsx("circle",{cx:"30",cy:"30",r:24,fill:"none",stroke:"#e9d5ff",strokeWidth:"5.5"}),A.jsx("circle",{cx:"30",cy:"30",r:24,fill:"none",stroke:"#7c3aed",strokeWidth:"5.5",strokeLinecap:"round",strokeDasharray:`${s} ${e-s}`})]}),A.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:A.jsxs("span",{className:"text-xs font-bold text-violet-700",children:[h,"%"]})})]})}function zc({assignment:h,onOpen:t}){const e=!!h.isLocked,s=!!h.submission,n=!!h.viewed,i=e?"Locked":s?"Submitted":n?"Opened — submit anytime":"Required — open to continue";return A.jsxs("button",{onClick:()=>{e||t()},disabled:e,className:`w-full text-left px-3 py-2.5 rounded-xl text-sm transition-all flex items-center gap-2.5 border ${e?"bg-gray-50 text-gray-900 border-gray-100 cursor-not-allowed":n||s?"bg-white text-violet-800 border-violet-100 hover:bg-violet-50":"bg-gradient-to-r from-violet-50 to-fuchsia-50 text-violet-900 border-violet-200 hover:border-violet-300 shadow-sm"}`,children:[A.jsx("span",{className:`w-6 h-6 rounded-lg flex items-center justify-center shrink-0 ${e?"bg-gray-200 text-gray-900":"bg-violet-500 text-white"}`,children:A.jsx(Ls,{size:12})}),A.jsxs("span",{className:"min-w-0 flex-1",children:[A.jsx("span",{className:"block truncate leading-snug font-medium",children:h.title}),A.jsx("span",{className:`block text-[10px] font-medium ${e?"text-gray-900":s?"text-emerald-500":n?"text-violet-400":"text-fuchsia-500"}`,children:i})]}),e&&A.jsx(gs,{size:12,className:"shrink-0 text-gray-600"})]})}function nh(){const[,h]=Xa("/courses/:courseId/lessons/:lessonId"),[,t]=Ya(),e=parseInt(h?.courseId??"0",10),s=parseInt(h?.lessonId??"0",10),{toast:n}=Ka(),[i,r]=U.useState(null),[a,o]=U.useState(null),[l,c]=U.useState(null),[d,u]=U.useState(""),[f,p]=U.useState([]);U.useEffect(()=>{if(!e)return;let P=!1;return zt.get("/assignments").then(_=>{if(P)return;const z=(_.data??[]).filter(et=>et.courseId===e).sort((et,St)=>(et.afterStep??0)-(St.afterStep??0)||et.id-St.id);p(z)}
57).catch(()=>{}),()=>{P=!0}},[e,s]);const[g,m]=U.useState(null),[v]=to(),[y,b]=U.useState([]),[S,x]=U.useState(!1),[w,E]=U.useState({}),[C,T]=U.useState(null),[O,I]=U.useState(!1),[M,N]=U.useState(!1),[D,$]=U.useState(!1),[k,F]=U.useState(""),[W,G]=U.useState(!1),[at,bt]=U.useState(!1),[J,tt]=U.useState(null),dt=U.useRef(null),[_t,B]=U.useState(!1),[R,j]=U.useState([]),[K,ct]=U.useState(""),[X,nt]=U.useState(!1),[ut,kt]=U.useState(!1),[ft,At]=U.useState(0),[Wt,Pe]=U.useState(!1),Ie=U.useRef(null),Zs=U.useRef(null),qs=U.useRef(null),[ze,it]=U.useState(null),rt=U.useRef(null),gt=U.useRef(null),wt=U.useRef(null),Dt=U.useRef(!1),Pt=U.useRef(""),$t=U.useRef(0),os=U.useRef(!1),[me,Ps]=U.useState(null),[ls,Ge]=U.useState(!1),{user:Fe}=Qa(),[re,Ve]=U.useState({top:10,left:8});U.useEffect(()=>{const P=setInterval(()=>Ve({top:8+Math.random()*64,left:5+Math.random()*50}),9e3);return()=>clearInterval(P)},[]);const tn=U.useRef(80),ve=U.useRef(0),cs=U.useRef(!1),hs=U.useRef(0),he=U.useRef(()=>Promise.resolve());function Oe(P,_,z){const et=ur();return!et||!s||!e?Promise.resolve():fetch(`${sa}/progress/playback`,{method:"POST",keepalive:z,headers:{"Content-Type":"application/json",Authorization:`Bearer ${et}`},body:JSON.stringify({lessonId:s,courseId:e,positionSeconds:P,durationSeconds:_})}).then(()=>{}).catch(()=>{})}he.current=Oe,U.useEffect(()=>{const P=()=>{Zt.current>15&&vt.current>0&&Oe(Math.floor(Zt.current),Math.floor(vt.current),!0)},_=()=>{document.visibilityState==="hidden"&&P()};return window.addEventListener("pagehide",P),document.addEventListener("visibilitychange",_),()=>{window.removeEventListener("pagehide",P),document.removeEventListener("visibilitychange",_)}},[s,e]);const vt=U.useRef(0),Zt=U.useRef(0),Le=U.useRef(null);U.useEffect(()=>(Ua(),()=>Yi()),[e,s]),U.useEffect(()=>{s&&Vn()},[s]),U.useEffect(()=>{At(0),Pe(!1),Dt.current=!1,vt.current=0,Zt.current=0,Pt.current=`lms-pos-${s}`,Ge(!1),$t.current=0,os.current=!1,Ps(null),ve.current=0,cs.current=!1,hs.current=0,zt.get(`/progress/playback/${s}`).then(P=>{ve.current=Number(P.data?.positionSeconds??0)}).catch(()=>{}).finally(()=>{cs.current=!0}),Le.current&&(clearInterval(Le.current),Le.current=null),it(null),rt.current&&(clearInterval(rt.current),rt.current=null),s&&(F(""),tt(null),zt.get(`/notes/${s}`).then(P=>{F(P.data?.content??""),tt(P.data?.updatedAt?new Date(P.data.updatedAt):null)}).catch(()=>{const P=localStorage.getItem(`lms-notes-${s}`);P&&F(P)}))},[s]),U.useEffect(()=>{!i||!a||!l||!e||!s||oo(window.localStorage,{courseId:e,lessonId:s,courseTitle:i.title,lessonTitle:a.title,timestamp:Date.now()})},[i?.id,a?.id,l?.courseId]);const ds=U.useCallback(P=>{const _=vt.current,z=Zt.current+P,et=Math.max(0,_>0?Math.min(z,_-1):z);Zt.current=et,ye.current("setCurrentTime",et),ye.current("getCurrentTime"),vt.current>0&&et>15&&he.current(Math.floor(et),Math.floor(vt.current),!1)},[]);U.useEffect(()=>{function P(_){const z=_.target?.tagName;if(!(z==="INPUT"||z==="TEXTAREA"||z==="SELECT")&&!(_.ctrlKey||_.metaKey||_.altKey)&&(_.key==="ArrowLeft"||_.key==="ArrowRight")){_.preventDefault();const et=_.shiftKey?30:10;ds(_.key==="ArrowLeft"?-et:et);return}}return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[ds]);const ye=U.useRef(()=>{}),Wi=U.useRef(()=>{}),us=U.useRef(null);U.useEffect(()=>{function P(Ht,qt){try{Ie.current?.contentWindow?.postMessage(JSON.stringify({context:"player.js",version:"0.0.19",method:Ht,value:qt??null}),"*")}catch{}}ye.current=P,Wi.current=z;function _(){P("addEventListener","ready"),P("addEventListener","play"),P("addEventListener","pause"),P("addEventListener","ended"),P("addEventListener","timeupdate"),P("addEventListener","progress"),P("getDuration")}function z(){Le.current||(Le.current=setInterval(()=>{P("getCurrentTime"),vt.current||P("getDuration")},2e3))}function et(){Le.current&&(clearInterval(Le.current),Le.current=null)}function St(){ea(!0),us.current&&clearTimeout(us.current),us.current=setTimeout(Et,1e4)}function Et(){us.current&&clearTimeout(us.current),us.current=null,ea(!1)}function Rt(Ht){let qt=null;
57try{qt=typeof Ht.data=="string"?JSON.parse(Ht.data):Ht.data}catch{return}if(!qt||typeof qt!="object")return;const Ut=String(qt.event??qt.type??qt.method??"");if(!Ut)return;const Be=qt.value,je=Be&&typeof Be=="object"?Be:qt,on=typeof Be=="number"?Be:void 0,be=on??Number(je.seconds??je.currentTime??je.time??0),nr=Ut==="getDuration"&&on!==void 0?on:Number(je.duration??0);if(nr>0&&(vt.current=nr),Ut==="ready"&&(_(),z()),(Ut==="play"||Ut==="playing")&&(z(),St(),Ge(!1)),Ut==="pause"&&(et(),Et(),Zt.current>15&&vt.current>0&&he.current(Math.floor(Zt.current),Math.floor(vt.current),!1)),Ut==="duration"||Ut==="getDuration"){const Yt=Number(je.duration??je.seconds??on??be);Yt>0&&(vt.current=Yt)}if(Ut==="timeupdate"||Ut==="currentTime"||Ut==="getCurrentTime"||Ut==="progress"){const Yt=vt.current;be>Zt.current&&St(),be>0&&(Zt.current=be);const ir=Yt>0&&be>0?Math.round(be/Yt*100):-1;if(ir>=0&&At(Jn=>Math.max(Jn,Math.min(ir,100))),!os.current&&Yt>0&&cs.current){os.current=!0;const Jn=Number(localStorage.getItem(Pt.current)??"0"),Ns=Math.max(Jn,ve.current),Wa=Yt*tn.current/100;Ns>15&&Ns<Math.min(Yt-20,Wa)&&(P("setCurrentTime",Ns),Zt.current=Ns,Ps(Ns),Ge(!0))}const ln=Date.now();if(be>15&&Yt>0&&ln-$t.current>5e3){$t.current=ln;try{localStorage.setItem(Pt.current,String(Math.floor(be)))}catch{}}be>15&&Yt>0&&ln-hs.current>15e3&&(hs.current=ln,he.current(Math.floor(be),Math.floor(Yt),!1))}Ut==="ended"&&(et(),Et(),At(100),vt.current>0&&he.current(Math.floor(vt.current),Math.floor(vt.current),!1),r(Yt=>(Yt?.autoplayNext&&Xi(),Yt)))}return window.addEventListener("message",Rt),()=>{window.removeEventListener("message",Rt),et(),Et()}},[]),U.useEffect(()=>{Me&&a?.videoUrl&&!fs&&!Dt.current&&ft>=Re&&(Dt.current=!0,(async()=>(await Qi(),i?.autoplayNext&&Os&&Xi()))())},[ft]);function Xi(){it(5),rt.current&&clearInterval(rt.current),rt.current=setInterval(()=>{it(P=>P===null?null:P<=1?(clearInterval(rt.current),rt.current=null,0):P-1)},1e3)}function ja(){rt.current&&(clearInterval(rt.current),rt.current=null),it(null)}U.useEffect(()=>{if(ze!==0||!i?.lessons)return;const P=i.lessons.filter(et=>et.stepType==="video"),_=P.findIndex(et=>et.id===s),z=_>=0?P[_+1]:void 0;z&&t(`/courses/${e}/lessons/${z.id}`)},[ze]);async function Vn(){if(s)try{const P=await zt.get(`/lessons/${s}/questions`);j(P.data??[])}catch{}}async function _a(){if(K.trim()){nt(!0);try{await zt.post(`/lessons/${s}/questions`,{question:K.trim()}),ct(""),n({title:"Question submitted!",description:"You'll be notified when it's answered."}),await Vn()}catch{n({title:"Failed to submit question",variant:"destructive"})}finally{nt(!1)}}}U.useEffect(()=>{const P=z=>z.preventDefault(),_=z=>{const et=z.ctrlKey||z.metaKey;(et&&z.key==="s"||et&&z.key==="u"||et&&z.key==="p"||et&&z.shiftKey&&(z.key==="i"||z.key==="I"||z.key==="j"||z.key==="J")||z.key==="F12"||et&&z.key==="a"&&z.target?.tagName!=="INPUT"&&z.target?.tagName!=="TEXTAREA")&&(z.preventDefault(),z.stopPropagation())};return document.addEventListener("contextmenu",P),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("contextmenu",P),document.removeEventListener("keydown",_,!0)}},[]);function Yi(){gt.current&&(clearTimeout(gt.current),gt.current=null),wt.current=null}async function Ua(){Yi();try{const[P,_]=await Promise.all([zt.get(`/courses/${e}`),zt.get(`/progress/course/${e}`)]),z=P.data;if(z){r(z);const et=z.lessons?.find(St=>St.id===s);if(et){const St=et;if(o(St),St.sectionId){const Rt=z.lessons?.find(Ht=>Ht.sectionId===St.sectionId&&Ht.stepType==="pdf");u(Rt?.pdfUrl??"")}let Et=null;if(Jr(St))Et=St.id;else if(St.sectionId){const Rt=z.lessons?.find(Ht=>Ht.sectionId===St.sectionId&&(Ht.stepType==="quiz"||Ht.title==="Quiz"||/\s*[–-]\s*quiz\s*$/i.test(Ht.title)));Rt&&(Et=Rt.id)}Et&&(m(Et),Ki(Et))}}_.data&&c(_.data)}catch{n({title:"Failed to load lesson",variant:"destructive"})}}async function Ki(P){x(!0),b([]),E({}),T(null),wt.current=P;try{const _=await zt.post(`/quiz/generate/${P}`,{});if(_.data?.questions&&_.data.questions.length>0){b(_.data.questions),x(!1);return}wt.current===P&&en(P,0)}catch(_){if(_ instanceof or&&(_.status===401||_.status===403)){x(!1);return}wt.current===P&&en(P,0)}}function en(P,_){if(wt.current!==P)return;if(_>80){x(!1);return}const z=_===0?3e3:5e3;gt.current=setTimeout(()=>$a(P,_),z)}async function $a(P,_){if(wt.current===P)try{const z=await zt.get(`/quiz/questions/${P}`);if(wt.current!==P)return;if(z.data?.questions&&z.data.questions.length>0){b(z.data.questions),x(!1);return}z.data?.pending?en(P,_+1):x(!1)}catch(z){if(z instanceof or&&(z.status===401||z.status===403)){x(!1);return}wt.current===P&&en(P,_+1)}}async function Ha(){g&&Ki(g)}async function Qi(){I(!0);try{await zt.post("/progress/lesson",{lessonId:s,courseId:e});try{localStorage.removeItem(Pt.current)}catch{}Oe(0,Math.floor(vt.current)||0,!1);const P=await zt.get(`/progress/course/${e}`);P.data?(c(P.data),P.data.progressPercent===100?B(!0):n({title:"Lesson completed!",description:`${P.data.progressPercent}% of the course done.`})):n({title:"Lesson completed!",description:"Your progress has been saved."})}catch{n({title:"Failed to save progress",variant:"destructive"})}finally{I(!1)}}async function za(){if(!y.length||!g)return;const P=y.map(_=>({quizId:_.id,answer:w[_.id]??""}));N(!0);try{const _=await zt.post("/progress/quiz",{lessonId:g,answers:P});if(_.data){T(_.data),n({title:_.data.passed?"Quiz Passed! 🎉":"Quiz Complete",description:`You scored ${_.data.score}/${_.data.total} (${_.data.percent}%)`});const z=await zt.get(`/progress/course/${e}`);z.data&&c(z.data)}}catch(_){n({title:"Failed to submit quiz",description:_.message,variant:"destructive"})}finally{N(!1)}}const Is=l?.lessons.find(P=>P.lessonId===s),sn=g?l?.lessons.find(P=>P.lessonId===g):null,fs=Is?.completed??!1,Ji=y.length>0&&y.every(P=>w[P.id]),ae=i?.lessons?.filter(P=>P.stepType==="video")??[],Xt=ae.findIndex(P=>P.id===s),Os=Xt>=0?ae[Xt+1]:void 0,nn=Xt>0?ae[Xt-1]:void 0,Me=i?.lessonCompletionOrder==="sequential",Wn=i?.videoWatchRequired??!1,Re=i?.videoWatchPercent??80;tn.current=Re;const rn=!!a?.videoUrl&&ft>=Re,Zi=fs||Me&&rn,Xn=eo(l?.lessons),Yn=rn?s:null;function Ga(P){return io(ae,Xn,P,Yn)}function qi(P){return ro(f,P)}function tr(P){return ao(Me,ae,Xn,f,P,Yn)}const We=Me&&Xt>0&&Ga(Xt)?qi(Xt):void 0,er=!fs&&Wn&&!!a?.videoUrl&&ft<Re,an=Jr(a),sr=lo(a,i?.lessons),Ms=sr.pdfUrl||d,Kn=sr.hasQuiz||!!g,Xe=co(l,ae.length),Va=Xt===-1||tr(Xt),Qn=a?.stepType==="video"&&!a?.videoUrl&&!fs,Rs=!Qn;return U.useEffect(()=>{D&&Zs.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,D]),Me&&!Va&&i?A.jsxs(lr,{backHref:`/courses/${e}`,backLabel:i.title,children:[A.jsxs("div",{className:"mb-5 bg-white rounded-2xl border border-gray-100 shadow-sm p-4",children:[A.jsxs("div",{className:"flex items-center justify-between mb-2",children:[A.jsxs("div",{children:[A.jsx("p",{className:"text-xs text-gray-900",children:"Course"}),A.jsx("p",{className:"text-sm font-semibold text-gray-900",children:i.title})]}),A.jsxs("div",{className:"text-right",children:[A.jsx("p",{className:"text-xs text-gray-900",children:"Progress"}),A.jsxs("p",{className:"text-sm font-bold text-blue-600",children:[l?.progressPercent??0,"%"]})]})]}),A.jsx(gr,{value:l?.progressPercent??0,className:"h-1.5"})]}),A.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-10 flex flex-col items-center text-center gap-4",children:[A.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center ${We?"bg-violet-50":"bg-gray-100"}`,children:We?A.jsx(Ls,{size:28,className:"text-violet-500"}):A.jsx(gs,{size:28,className:"text-gray-600"})}),A.jsxs("div",{children:[A.jsx("h2",{className:"text-lg font-bold text-gray-900 mb-1",children:We?"Assignment Checkpoint":"Lesson Locked"}),A.jsx("p",{className:"text-sm text-gray-900 max-w-xs",children:We?A.jsxs(A.Fragment,{children:["Open and go through ",A.jsx("span",{className:"font-semibold text-gray-900",children:We.title})," to continue to this lesson."]}):"Complete the previous lesson to unlock this content."})]}),We?A.jsxs("button",{onClick:()=>t(`/assignments/${We.id}`),className:"flex items-center gap-2 text-sm font-medium px-5 py-2.5 rounded-xl bg-violet-600 hover:bg-violet-700 text-white transition-colors",children:[A.jsx(Ls,{size:15})," Open Assignment"]}):nn&&A.jsxs("button",{onClick:()=>t(`/courses/${e}/lessons/${nn.id}`),className:"flex items-center gap-2 text-sm font-medium px-5 py-2.5 rounded-xl bg-blue-600 hover:bg-blue-700 text-white transition-colors",children:[A.jsx(mr,{size:15})," Go to Previous Lesson"]}),A.jsx("button",{onClick:()=>t(`/courses/${e}`),className:"text-xs text-gray-900 hover:text-gray-600 transition-colors",children:"Back to course overview"})]})]}):A.jsxs(lr,{backHref:`/courses/${e}`,backLabel:i?.title??"Course",children:[_t&&A.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",onClick:()=>B(!1),children:A.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl p-8 max-w-md w-full text-center relative overflow-hidden",onClick:P=>P.stopPropagation(),children:[A.jsx("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:["⭐","🌟","✨","🎉","🎊","⭐","🌟","✨"].map((P,_)=>A.jsx("span",{className:"absolute text-2xl animate-bounce",style:{left:`${10+_*12}%`,top:`${Math.random()>.5?5:15}%`,animationDelay:`${_*.15}s`,animationDuration:"1.2s"},children:P},_))}),A.jsx("div",{className:"text-6xl mb-4",children:"🏆"}),A.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Course Complete!"}),A.jsx("p",{className:"text-gray-900 mb-1 text-sm",children:"You've completed"}),A.jsx("p",{className:"font-semibold text-blue-600 text-lg mb-5",children:i?.title}),A.jsx("p",{className:"text-gray-900 text-sm mb-6",children:"Excellent work. Review your course requirements and certificate status when you are ready."}),A.jsxs("div",{className:"flex flex-col gap-3",children:[A.jsx("button",{onClick:()=>t("/certificates"),className:"w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 rounded-xl transition-colors text-sm",children:"Check Certificate Status"}),A.jsx("button",{onClick:()=>t("/courses"),className:"w-full bg-emerald-50 hover:bg-emerald-100 text-emerald-700 font-semibold py-3 rounded-xl transition-colors text-sm",children:"Explore More Courses"}),A.jsx("button",{onClick:()=>{B(!1),t("/my-courses")},className:"w-full bg-gray-100 hover:bg-gray-200 text-gray-900 font-medium py-3 rounded-xl transition-colors text-sm",children:"Back to My Courses"}),A.jsx("button",{onClick:()=>B(!1),className:"text-xs text-gray-900 hover:text-gray-500 transition-colors mt-1",children:"Continue exploring this course"})]})]})}),i&&A.jsx("div",{className:"mb-5 rounded-2xl border border-indigo-100 bg-gradient-to-r from-indigo-50/80 via-white to-violet-50/80 shadow-sm p-4",children:A.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center",children:[A.jsxs("div",{className:"min-w-0 flex-1",children:[A.jsx("p",{className:"text-xs font-medium text-indigo-400",children:"Course"}),A.jsx("p",{className:"text-base font-bold text-gray-900 truncate",children:i.title}),A.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[A.jsx(gr,{value:Xe.progressPercent,className:"h-2.5 flex-1 bg-gray-100 [&>div]:bg-gradient-to-r [&>div]:from-indigo-500 [&>div]:to-emerald-500"}),A.jsxs("span",{className:"text-sm font-bold text-indigo-600 shrink-0",children:[Xe.progressPercent,"%"]})]})]}),A.jsxs("div",{className:"grid grid-cols-3 gap-2 sm:min-w-[280px] shrink-0",children:[A.jsxs("div",{className:"rounded-xl border border-emerald-100 bg-emerald-50 px-3 py-2 text-center",children:[A.jsx("p",{className:"text-[10px] uppercase tracking-wide text-emerald-700",children:"Done"}),A.jsx("p",{className:"text-lg font-bold text-emerald-700 leading-tight",children:Xe.completedLessons})]}),A.jsxs("div",{className:"rounded-xl border border-slate-100 bg-slate-50 px-3 py-2 text-center",children:[A.jsx("p",{className:"text-[10px] uppercase tracking-wide text-slate-600",children:"Total"}),A.jsx("p",{className:"text-lg font-bold text-slate-700 leading-tight",children:Xe.totalLessons})]}),A.jsxs("div",{className:"rounded-xl border border-orange-100 bg-orange-50 px-3 py-2 text-center",children:[A.jsx("p",{className:"text-[10px] uppercase tracking-wide text-orange-700",children:"Left"}),A.jsx("p",{className:"text-lg font-bold text-orange-600 leading-tight",children:Xe.remainingLessons})]})]}),A.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-violet-100 bg-white/80 px-4 py-2.5 shrink-0",children:[A.jsx(Hc,{percent:Xe.progressPercent}),A.jsxs("div",{className:"min-w-0",children:[A.jsx("p",{className:"text-xs font-bold text-violet-800 leading-snug max-w-[160px]",children:$c(Xe.progressPercent)}),A.jsx("p",{className:"text-[10px] font-semibold text-violet-600 mt-0.5",children:"Keep Going!"})]})]})]})}),ae.length>0&&A.jsxs("div",{className:"md:hidden mb-4",children:[A.jsxs("button",{onClick:()=>$(P=>!P),className:"w-full flex items-center justify-between bg-white border border-gray-100 shadow-sm rounded-2xl px-4 py-3",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wide",children:"All Lessons"}),Xt>=0&&A.jsxs("span",{className:"text-xs text-gray-900",children:["(",Xt+1," of ",ae.length,")"]})]}),A.jsx(cr,{size:16,className:`text-gray-900 transition-transform duration-200 ${D?"rotate-180":""}`})]}),D&&A.jsx("div",{className:"mt-2 bg-white border border-gray-100 shadow-sm rounded-2xl p-3 space-y-1.5",children:ae.map((P,_)=>{const z=l?.lessons.find(Rt=>Rt.lessonId===P.id),et=tr(_),St=P.id===s,Et=f.filter(Rt=>(Rt.afterStep??0)===_+1);return A.jsxs("div",{className:"space-y-1.5",children:[A.jsxs("button",{ref:St?Zs:void 0,onClick:()=>{et&&(t(`/courses/${e}/lessons/${P.id}`),$(!1))},disabled:!et,className:`w-full text-left px-3 py-3 rounded-xl text-sm transition-colors flex items-center gap-2.5 ${St?"bg-blue-600 text-white font-medium":et?z?.completed?"bg-green-50 text-green-700 border border-green-100":"bg-white text-gray-900 border border-gray-100":"bg-gray-50 text-gray-900 border border-gray-100 cursor-not-allowed"}`,children:[A.jsx("span",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${!et&&!St?"bg-gray-200 text-gray-900":z?.completed?"bg-green-500 text-white":St?"bg-white/30 text-white":"bg-gray-100 text-gray-900"}`,children:!et&&!St?A.jsx(gs,{size:9}):z?.completed?"✓":_+1}),A.jsx("span",{className:"truncate flex-1",children:P.title}),St&&A.jsx("span",{className:"text-[10px] text-white/70 shrink-0",children:"Current"})]}),Et.map(Rt=>A.jsx(zc,{assignment:Rt,onOpen:()=>{t(`/assignments/${Rt.id}`),$(!1)}},`assignment-${Rt.id}`))]},P.id)})})]}
57),A.jsxs("div",{className:"grid md:grid-cols-4 gap-5",children:[A.jsxs("div",{className:"md:col-span-3 space-y-4 md:order-2",children:[!an&&A.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-5",children:[A.jsxs("div",{className:"flex items-start justify-between mb-4",children:[A.jsxs("div",{children:[A.jsx("h1",{className:"text-xl font-bold text-gray-900",children:a?.title??"Lesson"}),A.jsxs("p",{className:"text-sm text-gray-900 mt-0.5",children:["Lesson ",Xt>=0?Xt+1:"",ae.length?` of ${ae.length}`:""]})]}),A.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[fs&&A.jsx(ti,{className:"bg-green-100 text-green-700 border-green-200",children:"✓ Done"}),(sn?.quizPercent??Is?.quizPercent)!=null&&A.jsxs(ti,{className:"bg-amber-100 text-amber-700 border-amber-200",children:["Quiz: ",sn?.quizPercent??Is?.quizPercent,"%"]})]})]}),A.jsxs("div",{className:"mb-4 grid gap-2 sm:grid-cols-3",children:[A.jsxs("button",{type:"button",onClick:()=>qs.current?.scrollIntoView({behavior:"smooth",block:"start"}),disabled:!Ms||!Rs,className:`flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-xs font-semibold transition-colors ${Ms&&Rs?"border-orange-200 bg-orange-50 text-orange-700 hover:bg-orange-100":"border-gray-100 bg-gray-50 text-gray-900 cursor-not-allowed"}`,children:[A.jsx(Ja,{size:14}),Ms?"PDF Available":"No PDF"]}),A.jsxs("button",{type:"button",onClick:()=>document.getElementById("lesson-quiz-section")?.scrollIntoView({behavior:"smooth",block:"start"}),disabled:!Kn,className:`flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-xs font-semibold transition-colors ${Kn?"border-blue-200 bg-blue-50 text-blue-700 hover:bg-blue-100":"border-gray-100 bg-gray-50 text-gray-900 cursor-not-allowed"}`,children:[A.jsx(cn,{size:14}),Kn?"Quiz Available":"No Quiz"]}),A.jsxs(hr,{href:"/assignments",className:"flex items-center justify-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs font-semibold text-emerald-700 transition-colors hover:bg-emerald-100",children:[A.jsx(Ls,{size:14}),"Assignments Hub"]})]}),a?.videoUrl&&!Wt?A.jsxs("div",{className:"mb-4",children:[A.jsxs("div",{className:"aspect-video rounded-xl overflow-hidden bg-black relative",onContextMenu:P=>P.preventDefault(),onDragStart:P=>P.preventDefault(),children:[Fe&&A.jsx("div",{className:"pointer-events-none absolute z-[5] select-none transition-all duration-[3000ms] ease-linear",style:{top:`${re.top}%`,left:`${re.left}%`},"aria-hidden":"true",children:A.jsxs("p",{className:"whitespace-nowrap text-xs font-medium text-white/30",style:{textShadow:"0 0 3px rgba(0,0,0,0.6)"},children:[Fe.name||Fe.email," · ",Fe.phone||Fe.email]})}),ls&&me!==null&&A.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-10 flex justify-center p-3",children:A.jsxs("div",{className:"flex items-center gap-2.5 rounded-xl bg-emerald-600/95 text-white shadow-lg px-4 py-2.5 max-w-full",children:[A.jsx(ho,{size:22,className:"shrink-0 animate-pulse"}),A.jsxs("div",{className:"min-w-0 text-left",children:[A.jsxs("p",{className:"text-sm font-semibold leading-snug",children:["Resumed from ",Math.floor(me/60),":",String(Math.floor(me%60)).padStart(2,"0")," — press play to continue"]}),A.jsx("p",{className:"text-xs text-emerald-100 leading-snug",children:"మీరు ఆపిన చోటు నుండే కొనసాగుతుంది — ప్లే నొక్కండి"})]})]})}),A.jsx("iframe",{ref:Ie,src:(()=>{try{const P=new URL(a.videoUrl);return P.searchParams.set("download","false"),P.toString()}catch{return a.videoUrl}})(),onError:()=>Pe(!0),onLoad:()=>{setTimeout(()=>{ye.current("addEventListener","ready"),ye.current("addEventListener","play"),ye.current("addEventListener","pause"),ye.current("addEventListener","ended"),ye.current("addEventListener","timeupdate"),ye.current("addEventListener","progress"),ye.current("getDuration"),Wi.current()},500)},className:"w-full h-full",allow:"accelerometer; gyroscope; autoplay; encrypted-media; fullscreen",allowFullScreen:!0,style:{pointerEvents:"auto"}},a.videoUrl),ze!==null&&ze>0&&Os&&A.jsxs("div",{className:"absolute bottom-0 left-0 right-0 bg-black/80 text-white flex items-center justify-between px-4 py-3",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx(uo,{size:15,className:"text-blue-400"}),A.jsxs("span",{className:"text-sm",children:["Next: ",A.jsx("span",{className:"font-medium",children:Os.title})]})]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsxs("span",{className:"text-sm text-gray-300",children:["Starting in ",ze,"s"]}),A.jsx("button",{onClick:ja,className:"text-xs bg-white/20 hover:bg-white/30 px-3 py-1 rounded-lg transition-colors",children:"Cancel"})]})]})]}),(Wn||Me)&&!Zi&&A.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[A.jsx("div",{className:"flex-1 bg-gray-100 rounded-full h-1.5",children:A.jsx("div",{className:`h-1.5 rounded-full transition-all duration-300 ${rn?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(ft,100)}%`}})}),A.jsx("span",{className:"text-xs text-gray-900 whitespace-nowrap",children:rn?`✓ ${ft}% watched — next step unlocked`:`${ft}% watched · ${Re}% required`})]}),A.jsxs("div",{className:"mt-3 flex items-center gap-1.5 flex-wrap",children:[A.jsx(ei,{size:13,className:"text-gray-900 shrink-0"}),A.jsx("span",{className:"text-xs text-gray-900 font-medium mr-1",children:"Skip:"}),A.jsxs("button",{onClick:()=>ds(-10),title:"Back 10 seconds (←)","aria-label":"Rewind 10 seconds",className:"text-xs px-2.5 py-1 rounded-lg font-medium bg-gray-100 text-gray-900 hover:bg-gray-200 transition-colors flex items-center gap-1",children:[A.jsx(ei,{size:12})," 10s"]}),A.jsxs("button",{onClick:()=>ds(10),title:"Forward 10 seconds (→)","aria-label":"Forward 10 seconds",className:"text-xs px-2.5 py-1 rounded-lg font-medium bg-gray-100 text-gray-900 hover:bg-gray-200 transition-colors flex items-center gap-1",children:["10s ",A.jsx(yr,{size:12})]}),A.jsxs("button",{onClick:()=>ds(-30),title:"Back 30 seconds","aria-label":"Rewind 30 seconds",className:"text-xs px-2.5 py-1 rounded-lg font-medium bg-gray-100 text-gray-900 hover:bg-gray-200 transition-colors flex items-center gap-1",children:[A.jsx(ei,{size:12})," 30s"]}),A.jsxs("button",{onClick:()=>ds(30),title:"Forward 30 seconds","aria-label":"Forward 30 seconds",className:"text-xs px-2.5 py-1 rounded-lg font-medium bg-gray-100 text-gray-900 hover:bg-gray-200 transition-colors flex items-center gap-1",children:["30s ",A.jsx(yr,{size:12})]}),A.jsx("span",{className:"text-[10px] text-gray-900 ml-1 hidden sm:inline",children:"Keys ← →"})]}),A.jsxs("p",{className:"mt-3 text-xs text-gray-900 flex items-center gap-1.5",children:[A.jsx(vo,{size:13,className:"shrink-0"}),"Playback speed: use the gear icon in the player."]}),me!==null&&A.jsxs("p",{className:"mt-1.5 text-xs text-emerald-800 flex items-center gap-1.5",children:[A.jsx(dr,{size:13,className:"shrink-0"}),"Resumed from ",Math.floor(me/60),":",String(Math.floor(me%60)).padStart(2,"0")," — where you left off."]})]}):a?.videoUrl&&Wt?A.jsxs("div",{className:"aspect-video rounded-xl bg-gradient-to-br from-amber-50 to-orange-50 border border-amber-100 flex flex-col items-center justify-center mb-4 px-4 text-center",children:[A.jsx("p",{className:"text-sm text-amber-900 font-medium mb-1",children:"Video could not be loaded in the player"}),A.jsx("p",{className:"text-xs text-amber-800/80 mb-3",children:"Network or embed restrictions can block playback. Please try the protected player again."}),A.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:A.jsx("button",{type:"button",onClick:()=>Pe(!1),className:"text-xs px-3 py-1.5 rounded-lg bg-amber-600 text-white hover:bg-amber-700",children:"Retry player"})})]}):A.jsx("div",{className:"aspect-video rounded-xl bg-gradient-to-br from-gray-100 to-gray-200 flex items-center justify-center mb-4",children:A.jsxs("div",{className:"text-center text-gray-900",children:[A.jsx("div",{className:"text-5xl mb-2",children:"🎬"}),A.jsx("p",{className:"text-sm",children:"Video content coming soon"})]})}),Ms&&(Rs?A.jsx("div",{ref:qs,className:"mb-4 rounded-xl overflow-hidden border border-gray-700",style:{height:"580px"},onContextMenu:P=>P.preventDefault(),children:A.jsx(Fc,{url:Lc(Ms),authToken:ur()??void 0})}):Qn?null:A.jsxs("div",{className:"mb-4 rounded-xl border border-gray-200 bg-gray-50 flex flex-col items-center justify-center py-10 gap-2.5",children:[A.jsx("div",{className:"w-10 h-10 rounded-full bg-gray-100 flex items-center justify-center",children:A.jsx(gs,{size:18,className:"text-gray-600"})}),A.jsx("p",{className:"text-sm font-semibold text-gray-900",children:"Study Materials Locked"}),A.jsxs("p",{className:"text-xs text-gray-900",children:["Watch ",Math.max(0,Re-ft),"% more of the video to unlock"]}),A.jsx("div",{className:"w-40 bg-gray-200 rounded-full h-1.5 mt-1",children:A.jsx("div",{className:"bg-blue-400 h-1.5 rounded-full transition-all duration-300",style:{width:`${Math.min(ft,100)}%`}})}),A.jsxs("p",{className:"text-[11px] text-gray-900",children:[ft,"% / ",Re,"% watched"]})]})),!fs&&A.jsxs("div",{className:"space-y-1.5",children:[A.jsxs("button",{onClick:Qi,disabled:O||er,className:"flex items-center gap-2 bg-green-600 hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium px-4 py-2 rounded-xl transition-colors",children:[A.jsx(dr,{size:16}),O?"Saving...":"Mark as Complete"]}),er&&A.jsx("p",{className:"text-xs text-amber-700 flex items-center gap-1",children:A.jsxs("span",{children:["Watch ",Re-ft,"% more — it will auto-complete"]})})]}),A.jsxs("div",{className:"mt-5 border-t border-gray-100 pt-4",children:[A.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[A.jsxs(hr,{href:`/study-assistant?courseId=${e}&lessonId=${s}`,className:"inline-flex items-center gap-1.5 text-xs font-semibold px-3 py-1.5 rounded-full bg-gradient-to-r from-violet-600 to-indigo-600 text-white shadow-sm hover:opacity-95 transition-opacity",children:[A.jsx(Za,{size:13}),"Take your teacher's help (lesson)"]}),A.jsx("span",{className:"text-[11px] text-gray-900",children:"Telugu + English · revision & practice"})]}),A.jsxs("button",{onClick:()=>G(P=>!P),className:"flex items-center gap-2 text-sm font-medium text-gray-900 hover:text-gray-800 transition-colors group",children:[A.jsx(xo,{size:15,className:"text-amber-500 group-hover:text-amber-600"}),"My Notes",A.jsx(cr,{size:14,className:`text-gray-900 transition-transform duration-200 ${W?"rotate-180":""}`}),k&&!W&&A.jsx("span",{className:"text-[10px] text-amber-700 bg-amber-50 border border-amber-200 px-1.5 py-0.5 rounded-full font-medium",children:"saved"})]}),W&&A.jsxs("div",{className:"mt-3",children:[A.jsx("textarea",{value:k,onChange:P=>{const _=P.target.value;F(_),dt.current&&clearTimeout(dt.current),bt(!0),dt.current=setTimeout(()=>{zt.put(`/notes/${s}`,{content:_}).then(()=>{tt(new Date),bt(!1)}).catch(()=>{localStorage.setItem(`lms-notes-${s}`,_),bt(!1)})},800)},placeholder:"Jot down key points, interpretations, or questions as you learn… (cloud-saved)",rows:6,className:"w-full text-sm border border-gray-200 rounded-xl p-3 text-gray-900 placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-amber-400/30 focus:border-amber-400 resize-none leading-relaxed"}),A.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[A.jsx("span",{className:"text-[11px] text-gray-800",children:at?"Saving…":J?`Saved ${J.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:k.length>0?`${k.length} characters`:"Start typing to take notes"}),k&&A.jsx("button",{onClick:()=>{F(""),zt.put(`/notes/${s}`,{content:""}).catch(()=>{})},className:"text-[11px] text-red-400 hover:text-red-500 transition-colors",children:"Clear"})]})]})]})]}),an&&A.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-5",children:[A.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[A.jsx(cn,{size:22,className:"text-blue-600 shrink-0"}),A.jsx("h1",{className:"text-xl font-bold text-gray-900",children:a?.title?.replace(/\s*[–-]\s*quiz\s*$/i,"").trim()||"Knowledge Check"})]}),A.jsx("p",{className:"text-sm text-gray-900 ml-9",children:"Test your understanding with 10 multiple-choice questions."}),(sn?.quizPercent??Is?.quizPercent)!=null&&A.jsx("div",{className:"mt-3 ml-9",children:A.jsxs(ti,{className:"bg-amber-100 text-amber-700 border-amber-200",children:["Last score: ",sn?.quizPercent??Is?.quizPercent,"%"]})})]}),g&&!Rs&&!Qn&&A.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-6 flex flex-col items-center text-center gap-2.5",children:[A.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-50 flex items-center justify-center",children:A.jsx(gs,{size:18,className:"text-amber-400"})}),A.jsx("p",{className:"text-sm font-semibold text-gray-900",children:"Qu
57iz Locked"}),A.jsx("p",{className:"text-xs text-gray-900 max-w-xs",children:Wn?`Watch at least ${Re}% of the video to unlock the quiz (${ft}% watched)`:"Complete this lesson to unlock the quiz"}),A.jsx("div",{className:"w-40 bg-gray-200 rounded-full h-1.5 mt-1",children:A.jsx("div",{className:"bg-amber-400 h-1.5 rounded-full transition-all duration-300",style:{width:`${Math.min(ft,100)}%`}})})]}),g&&Rs&&A.jsxs("div",{id:"lesson-quiz-section",className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-5 scroll-mt-4",children:[A.jsxs("div",{className:"flex items-center justify-between mb-4",children:[A.jsxs("h2",{className:"font-bold text-gray-900 flex items-center gap-2",children:[A.jsx(cn,{size:18,className:"text-blue-600"}),"Knowledge Check",y.length>0&&A.jsxs("span",{className:"text-xs font-normal text-gray-900 ml-1",children:["(",y.length," questions)"]})]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx(so,{}),C&&A.jsxs("button",{onClick:()=>{T(null),E({})},className:"flex items-center gap-1.5 text-xs text-blue-600 hover:text-blue-700 font-medium",children:[A.jsx(fr,{size:13})," Retake"]})]})]}),S&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3 text-gray-900",children:[A.jsx(qn,{size:28,className:"animate-spin text-blue-500"}),A.jsx("p",{className:"text-sm font-medium",children:"Generating your quiz questions…"}),A.jsx("p",{className:"text-xs text-gray-900",children:"This may take up to a minute for new topics"})]}),!S&&y.length>0&&A.jsxs("div",{className:"space-y-7",children:[y.map((P,_)=>{const z=C?.results.find(Et=>Et.quizId===P.id),et=v==="te"&&!!P.questionTe?.trim(),St=et&&P.optionsTe&&P.optionsTe.length===P.options.length?P.optionsTe:P.options;return A.jsxs("div",{className:"space-y-3",children:[A.jsxs("p",{className:`text-sm font-semibold text-gray-900 ${et?"font-telugu":""}`,children:[_+1,". ",et?P.questionTe:P.question]}),A.jsx("div",{className:"space-y-2",children:P.options.map((Et,Rt)=>{const Ht=St[Rt]??Et,qt=w[P.id]===Et,Ut=z&&Et===z.correctAnswer,Be=z&&qt&&!z.correct;return A.jsx("button",{onClick:()=>!C&&E(je=>({...je,[P.id]:Et})),disabled:!!C,className:`w-full text-left p-3 rounded-xl border text-sm transition-colors ${Ut?"border-green-300 bg-green-50 text-green-800 font-medium":Be?"border-red-300 bg-red-50 text-red-800":qt?"border-blue-400 bg-blue-50 text-blue-800":"border-gray-200 bg-gray-50 text-gray-900 hover:border-blue-300 hover:bg-blue-50/30 disabled:cursor-default"}`,children:A.jsxs("span",{className:`flex items-center gap-2 ${et?"font-telugu":""}`,children:[Ut&&A.jsx("span",{className:"text-green-600",children:"✓"}),Be&&A.jsx("span",{className:"text-red-500",children:"✗"}),Ht]})},Et)})}),C&&z&&(()=>{const Et=v==="te"&&z.explanationTe?.trim()?z.explanationTe:P.explanation;if(!Et)return null;const Rt=Et!==P.explanation;return A.jsxs("div",{className:`px-4 py-2.5 rounded-xl text-xs border ${Rt?"font-telugu":""} ${z.correct?"bg-green-50 border-green-200 text-green-800":"bg-blue-50 border-blue-200 text-blue-800"}`,children:[A.jsx("span",{className:"font-semibold",children:Rt?"వివరణ: ":"Explanation: "}),Et]})})()]},P.id)}),C?A.jsxs("div",{className:`p-4 rounded-xl text-center border ${C.passed?"bg-green-50 border-green-200":"bg-amber-50 border-amber-200"}`,children:[A.jsx("p",{className:`text-xl font-bold ${C.passed?"text-green-700":"text-amber-700"}`,children:C.passed?"🎉 Passed!":"📚 Keep Learning"}),A.jsxs("p",{className:`text-sm mt-1 ${C.passed?"text-green-600":"text-amber-600"}`,children:[C.score,"/",C.total," correct (",C.percent,"%)"]}),!C.passed&&A.jsx("p",{className:"text-xs text-amber-700 mt-1",children:"You need 60% to pass. Review the explanations above and try again."})]}):A.jsx("button",{onClick:za,disabled:!Ji||M,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:opacity-40 text-white font-medium text-sm py-3 rounded-xl transition-colors flex items-center justify-center gap-2",children:M?A.jsxs(A.Fragment,{children:[A.jsx(qn,{size:16,className:"animate-spin"})," Submitting…"]}):`Submit Quiz ${Ji?"":`(${Object.keys(w).length}/${y.length} answered)`}`})]}),!S&&y.length===0&&A.jsxs("div",{className:"flex flex-col items-center py-8 gap-3 text-gray-900",children:[A.jsx(cn,{size:32,className:"opacity-30"}
57),A.jsx("p",{className:"text-sm",children:"Quiz questions not available"}),A.jsxs("button",{onClick:Ha,className:"text-xs text-blue-600 hover:text-blue-700 font-medium flex items-center gap-1.5",children:[A.jsx(fr,{size:12})," Try again"]})]})]}),!an&&A.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[A.jsxs("button",{onClick:()=>{kt(P=>!P),ut||Vn()},className:"w-full flex items-center justify-between p-5 hover:bg-gray-50 transition-colors",children:[A.jsxs("h2",{className:"font-bold text-gray-900 flex items-center gap-2",children:[A.jsx(pr,{size:18,className:"text-indigo-600"}),"Ask a Question",R.length>0&&A.jsxs("span",{className:"text-xs font-normal text-gray-900",children:["(",R.length,")"]})]}),A.jsx("span",{className:"text-gray-900 text-sm",children:ut?"▲":"▼"})]}),ut&&A.jsxs("div",{className:"px-5 pb-5 border-t border-gray-50 space-y-4",children:[A.jsxs("div",{className:"pt-4",children:[A.jsx("textarea",{value:K,onChange:P=>ct(P.target.value),placeholder:"Type your question about this lesson…",rows:3,className:"w-full text-sm border border-gray-200 rounded-xl p-3 focus:outline-none focus:ring-2 focus:ring-indigo-200 resize-none"}),A.jsx("div",{className:"flex justify-end mt-2",children:A.jsxs("button",{onClick:_a,disabled:!K.trim()||X,className:"flex items-center gap-1.5 text-sm font-medium px-4 py-2 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white disabled:opacity-40 transition-colors",children:[X?A.jsx(qn,{size:14,className:"animate-spin"}):A.jsx(fo,{size:14}),"Submit Question"]})})]}),R.length>0&&A.jsx("div",{className:"space-y-3",children:R.map(P=>A.jsxs("div",{className:"rounded-xl border border-gray-100 overflow-hidden",children:[A.jsxs("div",{className:"flex items-start gap-2.5 p-3 bg-gray-50",children:[A.jsx("div",{className:"w-7 h-7 rounded-full bg-indigo-100 flex items-center justify-center shrink-0",children:A.jsx(qa,{size:13,className:"text-indigo-600"})}),A.jsxs("div",{className:"flex-1",children:[A.jsxs("p",{className:"text-xs font-semibold text-gray-900 mb-0.5",children:[P.userName??"You",A.jsx("span",{className:"font-normal text-gray-800 ml-2",children:new Date(P.createdAt).toLocaleDateString("en-IN",{day:"numeric",month:"short"})})]}),A.jsx("p",{className:"text-sm text-gray-900",children:P.question})]})]}),P.answer?A.jsxs("div",{className:"flex items-start gap-2.5 p-3 bg-indigo-50 border-t border-indigo-100",children:[A.jsx("div",{className:"w-7 h-7 rounded-full bg-indigo-600 flex items-center justify-center shrink-0 text-white text-[10px] font-bold",children:"T"}),A.jsxs("div",{className:"flex-1",children:[A.jsxs("p",{className:"text-xs font-semibold text-indigo-700 mb-0.5",children:[P.answeredByName??"Instructor",A.jsx("span",{className:"font-normal text-indigo-400 ml-2",children:P.answeredAt?new Date(P.answeredAt).toLocaleDateString("en-IN",{day:"numeric",month:"short"}):""})]}),A.jsx("p",{className:"text-sm text-indigo-900",children:P.answer})]})]}):A.jsx("div",{className:"px-3 py-2 bg-amber-50 border-t border-amber-100",children:A.jsx("p",{className:"text-xs text-amber-600",children:"Awaiting instructor response…"})})]},P.id))}),R.length===0&&A.jsxs("div",{className:"text-center py-6 text-gray-900",children:[A.jsx(pr,{size:28,className:"mx-auto mb-2 opacity-30"}),A.jsx("p",{className:"text-sm",children:"No questions yet. Be the first to ask!"})]})]})]}),!an&&A.jsxs("div",{className:"flex justify-between pt-1",children:[nn?A.jsxs("button",{onClick:()=>t(`/courses/${e}/lessons/${nn.id}`),className:"flex items-center gap-2 text-sm font-medium px-4 py-2 rounded-xl border border-gray-200 text-gray-900 hover:bg-gray-50 transition-colors",children:[A.jsx(mr,{size:16})," Previous"]}):A.jsx("div",{}),Os&&(()=>{const P=Me&&!Zi,_=!P&&Me?qi(Xt+1):void 0;return _?A.jsxs("button",{onClick:()=>t(`/assignments/${_.id}`),title:"Open the assignment checkpoint to continue to the next lesson",className:"flex items-center gap-2 text-sm font-medium px-4 py-2 rounded-xl bg-violet-600 hover:bg-violet-700 text-white transition-colors",children:[A.jsx(Ls,{size:14})," Open Assignment ",A.jsx(vr,{size:16})]}):A.jsxs("button",{onClick:()=>{P||t(`/courses/${e}/lessons/${Os.id}`)},disabled:P,title:P?"Complete this lesson first to continue":void 0,className:`flex items-center gap-2 text-sm font-medium px-4 py-2 rounded-xl transition-colors ${P?"bg-gray-100 text-gray-900 border border-gray-200 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 text-white"}`,children:["Next ",A.jsx(vr,{size:16}),P&&A.jsx(gs,{size:12})]})})()]})]}),A.jsx(no,{courseId:e,videoLessons:ae,completedIds:Xn,sequential:Me,assignments:f,activeLessonId:s,boostLessonId:Yn,onNavigate:t})]})]})}export{nh as default};

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