From d2ec60b383f131907baa3717996f847d8ae162dc Mon Sep 17 00:00:00 2001 From: Walid Date: Thu, 2 Jul 2026 16:22:18 +0600 Subject: [PATCH] fix: latex math symbol missing --- main.js | 60 ++++++++++++----------- main.ts | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 171 insertions(+), 35 deletions(-) diff --git a/main.js b/main.js index 7daa1b7..375fe6c 100644 --- a/main.js +++ b/main.js @@ -1,18 +1,18 @@ -var $u=Object.create;var Go=Object.defineProperty;var ed=Object.getOwnPropertyDescriptor;var td=Object.getOwnPropertyNames;var rd=Object.getPrototypeOf,nd=Object.prototype.hasOwnProperty;var He=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),od=(t,e)=>{for(var r in e)Go(t,r,{get:e[r],enumerable:!0})},Cs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of td(e))!nd.call(t,o)&&o!==r&&Go(t,o,{get:()=>e[o],enumerable:!(n=ed(e,o))||n.enumerable});return t};var Ko=(t,e,r)=>(r=t!=null?$u(rd(t)):{},Cs(e||!t||!t.__esModule?Go(r,"default",{value:t,enumerable:!0}):r,t)),id=t=>Cs(Go({},"__esModule",{value:!0}),t);var It=He(Ke=>{"use strict";var hd=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function pd(t,e){return Object.prototype.hasOwnProperty.call(t,e)}Ke.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(var n in r)pd(r,n)&&(t[n]=r[n])}}return t};Ke.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var vd={arraySet:function(t,e,r,n,o){if(e.subarray&&t.subarray){t.set(e.subarray(r,r+n),o);return}for(var i=0;i{"use strict";var gd=It(),yd=4,_s=0,$s=1,bd=2;function Kr(t){for(var e=t.length;--e>=0;)t[e]=0}var xd=0,il=1,Fd=2,wd=3,Sd=258,na=29,Hn=256,In=Hn+1+na,Gr=30,oa=19,al=2*In+1,yr=15,Qi=16,Pd=7,ia=256,sl=16,ll=17,fl=18,ta=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],$o=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Dd=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cl=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Cd=512,zt=new Array((In+2)*2);Kr(zt);var Mn=new Array(Gr*2);Kr(Mn);var zn=new Array(Cd);Kr(zn);var jn=new Array(Sd-wd+1);Kr(jn);var aa=new Array(na);Kr(aa);var ei=new Array(Gr);Kr(ei);function _i(t,e,r,n,o){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=o,this.has_stree=t&&t.length}var ul,dl,hl;function $i(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function pl(t){return t<256?zn[t]:zn[256+(t>>>7)]}function Ln(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function _e(t,e,r){t.bi_valid>Qi-r?(t.bi_buf|=e<>Qi-t.bi_valid,t.bi_valid+=r-Qi):(t.bi_buf|=e<>>=1,r<<=1;while(--e>0);return r>>>1}function kd(t){t.bi_valid===16?(Ln(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)}function Td(t,e){var r=e.dyn_tree,n=e.max_code,o=e.stat_desc.static_tree,i=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,f=e.stat_desc.max_length,l,c,u,d,p,h,b=0;for(d=0;d<=yr;d++)t.bl_count[d]=0;for(r[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;lf&&(d=f,b++),r[c*2+1]=d,!(c>n)&&(t.bl_count[d]++,p=0,c>=s&&(p=a[c-s]),h=r[c*2],t.opt_len+=h*(d+p),i&&(t.static_len+=h*(o[c*2+1]+p)));if(b!==0){do{for(d=f-1;t.bl_count[d]===0;)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[f]--,b-=2}while(b>0);for(d=f;d!==0;d--)for(c=t.bl_count[d];c!==0;)u=t.heap[--l],!(u>n)&&(r[u*2+1]!==d&&(t.opt_len+=(d-r[u*2+1])*r[u*2],r[u*2+1]=d),c--)}}function ml(t,e,r){var n=new Array(yr+1),o=0,i,a;for(i=1;i<=yr;i++)n[i]=o=o+r[i-1]<<1;for(a=0;a<=e;a++){var s=t[a*2+1];s!==0&&(t[a*2]=vl(n[s]++,s))}}function Ed(){var t,e,r,n,o,i=new Array(yr+1);for(r=0,n=0;n>=7;n8?Ln(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function Ad(t,e,r,n){yl(t),n&&(Ln(t,r),Ln(t,~r)),gd.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}function el(t,e,r,n){var o=e*2,i=r*2;return t[o]>1;a>=1;a--)ea(t,r,a);l=i;do a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],ea(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=s,r[l*2]=r[a*2]+r[s*2],t.depth[l]=(t.depth[a]>=t.depth[s]?t.depth[a]:t.depth[s])+1,r[a*2+1]=r[s*2+1]=l,t.heap[1]=l++,ea(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],Td(t,e),ml(r,f,t.bl_count)}function rl(t,e,r){var n,o=-1,i,a=e[0*2+1],s=0,f=7,l=4;for(a===0&&(f=138,l=3),e[(r+1)*2+1]=65535,n=0;n<=r;n++)i=a,a=e[(n+1)*2+1],!(++s=3&&t.bl_tree[cl[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function Od(t,e,r,n){var o;for(_e(t,e-257,5),_e(t,r-1,5),_e(t,n-4,4),o=0;o>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return _s;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return $s;for(r=32;r0?(t.strm.data_type===bd&&(t.strm.data_type=Bd(t)),ra(t,t.l_desc),ra(t,t.d_desc),a=Rd(t),o=t.opt_len+3+7>>>3,i=t.static_len+3+7>>>3,i<=o&&(o=i)):o=i=r+5,r+4<=o&&e!==-1?bl(t,e,r,n):t.strategy===yd||i===o?(_e(t,(il<<1)+(n?1:0),3),tl(t,zt,Mn)):(_e(t,(Fd<<1)+(n?1:0),3),Od(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),tl(t,t.dyn_ltree,t.dyn_dtree)),gl(t),n&&yl(t)}function zd(t,e,r){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=r&255,t.last_lit++,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(jn[r]+Hn+1)*2]++,t.dyn_dtree[pl(e)*2]++),t.last_lit===t.lit_bufsize-1}Xr._tr_init=Nd;Xr._tr_stored_block=bl;Xr._tr_flush_block=Id;Xr._tr_tally=zd;Xr._tr_align=Md});var sa=He((Ym,Fl)=>{"use strict";function jd(t,e,r,n){for(var o=t&65535|0,i=t>>>16&65535|0,a=0;r!==0;){a=r>2e3?2e3:r,r-=a;do o=o+e[n++]|0,i=i+o|0;while(--a);o%=65521,i%=65521}return o|i<<16|0}Fl.exports=jd});var la=He((Jm,wl)=>{"use strict";function Ld(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e}var Hd=Ld();function Ud(t,e,r,n){var o=Hd,i=n+r;t^=-1;for(var a=n;a>>8^o[(t^e[a])&255];return t^-1}wl.exports=Ud});var ti=He((Qm,Sl)=>{"use strict";Sl.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var Ol=He(kt=>{"use strict";var Xe=It(),at=xl(),kl=sa(),Kt=la(),Vd=ti(),wr=0,qd=1,Wd=3,Qt=4,Pl=5,Ct=0,Dl=1,st=-2,Gd=-3,fa=-5,Kd=-1,Xd=1,ri=2,Zd=3,Yd=4,Jd=0,Qd=2,ai=8,_d=9,$d=15,eh=8,th=29,rh=256,ua=rh+1+th,nh=30,oh=19,ih=2*ua+1,ah=15,de=3,Yt=258,mt=Yt+de+1,sh=32,si=42,da=69,ni=73,oi=91,ii=103,br=113,Vn=666,Ne=1,qn=2,xr=3,Jr=4,lh=3;function Jt(t,e){return t.msg=Vd[e],e}function Cl(t){return(t<<1)-(t>4?9:0)}function Zt(t){for(var e=t.length;--e>=0;)t[e]=0}function Xt(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(Xe.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0))}function je(t,e){at._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Xt(t.strm)}function he(t,e){t.pending_buf[t.pending++]=e}function Un(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function fh(t,e,r,n){var o=t.avail_in;return o>n&&(o=n),o===0?0:(t.avail_in-=o,Xe.arraySet(e,t.input,t.next_in,o,r),t.state.wrap===1?t.adler=kl(t.adler,e,o,r):t.state.wrap===2&&(t.adler=Kt(t.adler,e,o,r)),t.next_in+=o,t.total_in+=o,o)}function Tl(t,e){var r=t.max_chain_length,n=t.strstart,o,i,a=t.prev_length,s=t.nice_match,f=t.strstart>t.w_size-mt?t.strstart-(t.w_size-mt):0,l=t.window,c=t.w_mask,u=t.prev,d=t.strstart+Yt,p=l[n+a-1],h=l[n+a];t.prev_length>=t.good_match&&(r>>=2),s>t.lookahead&&(s=t.lookahead);do if(o=e,!(l[o+a]!==h||l[o+a-1]!==p||l[o]!==l[n]||l[++o]!==l[n+1])){n+=2,o++;do;while(l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&na){if(t.match_start=e,a=i,i>=s)break;p=l[n+a-1],h=l[n+a]}}while((e=u[e&c])>f&&--r!==0);return a<=t.lookahead?a:t.lookahead}function Fr(t){var e=t.w_size,r,n,o,i,a;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-mt)){Xe.arraySet(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do o=t.head[--r],t.head[r]=o>=e?o-e:0;while(--n);n=e,r=n;do o=t.prev[--r],t.prev[r]=o>=e?o-e:0;while(--n);i+=e}if(t.strm.avail_in===0)break;if(n=fh(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=de)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=(t.ins_h<t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Fr(t),t.lookahead===0&&e===wr)return Ne;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((t.strstart===0||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,je(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-mt&&(je(t,!1),t.strm.avail_out===0))return Ne}return t.insert=0,e===Qt?(je(t,!0),t.strm.avail_out===0?xr:Jr):(t.strstart>t.block_start&&(je(t,!1),t.strm.avail_out===0),Ne)}function ca(t,e){for(var r,n;;){if(t.lookahead=de&&(t.ins_h=(t.ins_h<=de)if(n=at._tr_tally(t,t.strstart-t.match_start,t.match_length-de),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=de){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<=de&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=de-1)),t.prev_length>=de&&t.match_length<=t.prev_length){o=t.strstart+t.lookahead-de,n=at._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-de),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=o&&(t.ins_h=(t.ins_h<=de&&t.strstart>0&&(o=t.strstart-1,n=a[o],n===a[++o]&&n===a[++o]&&n===a[++o])){i=t.strstart+Yt;do;while(n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&ot.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=de?(r=at._tr_tally(t,1,t.match_length-de),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=at._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(je(t,!1),t.strm.avail_out===0))return Ne}return t.insert=0,e===Qt?(je(t,!0),t.strm.avail_out===0?xr:Jr):t.last_lit&&(je(t,!1),t.strm.avail_out===0)?Ne:qn}function dh(t,e){for(var r;;){if(t.lookahead===0&&(Fr(t),t.lookahead===0)){if(e===wr)return Ne;break}if(t.match_length=0,r=at._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(je(t,!1),t.strm.avail_out===0))return Ne}return t.insert=0,e===Qt?(je(t,!0),t.strm.avail_out===0?xr:Jr):t.last_lit&&(je(t,!1),t.strm.avail_out===0)?Ne:qn}function Dt(t,e,r,n,o){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=o}var Yr;Yr=[new Dt(0,0,0,0,ch),new Dt(4,4,8,4,ca),new Dt(4,5,16,8,ca),new Dt(4,6,32,32,ca),new Dt(4,4,16,16,Zr),new Dt(8,16,32,32,Zr),new Dt(8,16,128,128,Zr),new Dt(8,32,128,256,Zr),new Dt(32,128,258,1024,Zr),new Dt(32,258,258,4096,Zr)];function hh(t){t.window_size=2*t.w_size,Zt(t.head),t.max_lazy_match=Yr[t.level].max_lazy,t.good_match=Yr[t.level].good_length,t.nice_match=Yr[t.level].nice_length,t.max_chain_length=Yr[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=de-1,t.match_available=0,t.ins_h=0}function ph(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ai,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Xe.Buf16(ih*2),this.dyn_dtree=new Xe.Buf16((2*nh+1)*2),this.bl_tree=new Xe.Buf16((2*oh+1)*2),Zt(this.dyn_ltree),Zt(this.dyn_dtree),Zt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Xe.Buf16(ah+1),this.heap=new Xe.Buf16(2*ua+1),Zt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Xe.Buf16(2*ua+1),Zt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function El(t){var e;return!t||!t.state?Jt(t,st):(t.total_in=t.total_out=0,t.data_type=Qd,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?si:br,t.adler=e.wrap===2?0:1,e.last_flush=wr,at._tr_init(e),Ct)}function Al(t){var e=El(t);return e===Ct&&hh(t.state),e}function vh(t,e){return!t||!t.state||t.state.wrap!==2?st:(t.state.gzhead=e,Ct)}function Rl(t,e,r,n,o,i){if(!t)return st;var a=1;if(e===Kd&&(e=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),o<1||o>_d||r!==ai||n<8||n>15||e<0||e>9||i<0||i>Yd)return Jt(t,st);n===8&&(n=9);var s=new ph;return t.state=s,s.strm=t,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<Pl||e<0)return t?Jt(t,st):st;if(n=t.state,!t.output||!t.input&&t.avail_in!==0||n.status===Vn&&e!==Qt)return Jt(t,t.avail_out===0?fa:st);if(n.strm=t,r=n.last_flush,n.last_flush=e,n.status===si)if(n.wrap===2)t.adler=0,he(n,31),he(n,139),he(n,8),n.gzhead?(he(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),he(n,n.gzhead.time&255),he(n,n.gzhead.time>>8&255),he(n,n.gzhead.time>>16&255),he(n,n.gzhead.time>>24&255),he(n,n.level===9?2:n.strategy>=ri||n.level<2?4:0),he(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(he(n,n.gzhead.extra.length&255),he(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=Kt(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=da):(he(n,0),he(n,0),he(n,0),he(n,0),he(n,0),he(n,n.level===9?2:n.strategy>=ri||n.level<2?4:0),he(n,lh),n.status=br);else{var a=ai+(n.w_bits-8<<4)<<8,s=-1;n.strategy>=ri||n.level<2?s=0:n.level<6?s=1:n.level===6?s=2:s=3,a|=s<<6,n.strstart!==0&&(a|=sh),a+=31-a%31,n.status=br,Un(n,a),n.strstart!==0&&(Un(n,t.adler>>>16),Un(n,t.adler&65535)),t.adler=1}if(n.status===da)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),Xt(t),o=n.pending,n.pending===n.pending_buf_size));)he(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=ni)}else n.status=ni;if(n.status===ni)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),Xt(t),o=n.pending,n.pending===n.pending_buf_size)){i=1;break}n.gzindexo&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),i===0&&(n.gzindex=0,n.status=oi)}else n.status=oi;if(n.status===oi)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),Xt(t),o=n.pending,n.pending===n.pending_buf_size)){i=1;break}n.gzindexo&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),i===0&&(n.status=ii)}else n.status=ii;if(n.status===ii&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Xt(t),n.pending+2<=n.pending_buf_size&&(he(n,t.adler&255),he(n,t.adler>>8&255),t.adler=0,n.status=br)):n.status=br),n.pending!==0){if(Xt(t),t.avail_out===0)return n.last_flush=-1,Ct}else if(t.avail_in===0&&Cl(e)<=Cl(r)&&e!==Qt)return Jt(t,fa);if(n.status===Vn&&t.avail_in!==0)return Jt(t,fa);if(t.avail_in!==0||n.lookahead!==0||e!==wr&&n.status!==Vn){var f=n.strategy===ri?dh(n,e):n.strategy===Zd?uh(n,e):Yr[n.level].func(n,e);if((f===xr||f===Jr)&&(n.status=Vn),f===Ne||f===xr)return t.avail_out===0&&(n.last_flush=-1),Ct;if(f===qn&&(e===qd?at._tr_align(n):e!==Pl&&(at._tr_stored_block(n,0,0,!1),e===Wd&&(Zt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Xt(t),t.avail_out===0))return n.last_flush=-1,Ct}return e!==Qt?Ct:n.wrap<=0?Dl:(n.wrap===2?(he(n,t.adler&255),he(n,t.adler>>8&255),he(n,t.adler>>16&255),he(n,t.adler>>24&255),he(n,t.total_in&255),he(n,t.total_in>>8&255),he(n,t.total_in>>16&255),he(n,t.total_in>>24&255)):(Un(n,t.adler>>>16),Un(n,t.adler&65535)),Xt(t),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Ct:Dl)}function yh(t){var e;return!t||!t.state?st:(e=t.state.status,e!==si&&e!==da&&e!==ni&&e!==oi&&e!==ii&&e!==br&&e!==Vn?Jt(t,st):(t.state=null,e===br?Jt(t,Gd):Ct))}function bh(t,e){var r=e.length,n,o,i,a,s,f,l,c;if(!t||!t.state||(n=t.state,a=n.wrap,a===2||a===1&&n.status!==si||n.lookahead))return st;for(a===1&&(t.adler=kl(t.adler,e,r,0)),n.wrap=0,r>=n.w_size&&(a===0&&(Zt(n.head),n.strstart=0,n.block_start=0,n.insert=0),c=new Xe.Buf8(n.w_size),Xe.arraySet(c,e,r-n.w_size,n.w_size,0),e=c,r=n.w_size),s=t.avail_in,f=t.next_in,l=t.input,t.avail_in=r,t.next_in=0,t.input=e,Fr(n);n.lookahead>=de;){o=n.strstart,i=n.lookahead-(de-1);do n.ins_h=(n.ins_h<{"use strict";var li=It(),Bl=!0,Nl=!0;try{String.fromCharCode.apply(null,[0])}catch{Bl=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Nl=!1}var Wn=new li.Buf8(256);for(jt=0;jt<256;jt++)Wn[jt]=jt>=252?6:jt>=248?5:jt>=240?4:jt>=224?3:jt>=192?2:1;var jt;Wn[254]=Wn[254]=1;Qr.string2buf=function(t){var e,r,n,o,i,a=t.length,s=0;for(o=0;o>>6,e[i++]=128|r&63):r<65536?(e[i++]=224|r>>>12,e[i++]=128|r>>>6&63,e[i++]=128|r&63):(e[i++]=240|r>>>18,e[i++]=128|r>>>12&63,e[i++]=128|r>>>6&63,e[i++]=128|r&63);return e};function Ml(t,e){if(e<65534&&(t.subarray&&Nl||!t.subarray&&Bl))return String.fromCharCode.apply(null,li.shrinkBuf(t,e));for(var r="",n=0;n4){s[n++]=65533,r+=i-1;continue}for(o&=i===2?31:i===3?15:7;i>1&&r1){s[n++]=65533;continue}o<65536?s[n++]=o:(o-=65536,s[n++]=55296|o>>10&1023,s[n++]=56320|o&1023)}return Ml(s,n)};Qr.utf8border=function(t,e){var r;for(e=e||t.length,e>t.length&&(e=t.length),r=e-1;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+Wn[t[r]]>e?r:e}});var pa=He((eg,Il)=>{"use strict";function xh(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}Il.exports=xh});var Hl=He(Xn=>{"use strict";var Gn=Ol(),Kn=It(),ma=ha(),ga=ti(),Fh=pa(),Ll=Object.prototype.toString,wh=0,va=4,_r=0,zl=1,jl=2,Sh=-1,Ph=0,Dh=8;function Sr(t){if(!(this instanceof Sr))return new Sr(t);this.options=Kn.assign({level:Sh,method:Dh,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ph,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fh,this.strm.avail_out=0;var r=Gn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==_r)throw new Error(ga[r]);if(e.header&&Gn.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(typeof e.dictionary=="string"?n=ma.string2buf(e.dictionary):Ll.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,r=Gn.deflateSetDictionary(this.strm,n),r!==_r)throw new Error(ga[r]);this._dict_set=!0}}Sr.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,o,i;if(this.ended)return!1;i=e===~~e?e:e===!0?va:wh,typeof t=="string"?r.input=ma.string2buf(t):Ll.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new Kn.Buf8(n),r.next_out=0,r.avail_out=n),o=Gn.deflate(r,i),o!==zl&&o!==_r)return this.onEnd(o),this.ended=!0,!1;(r.avail_out===0||r.avail_in===0&&(i===va||i===jl))&&(this.options.to==="string"?this.onData(ma.buf2binstring(Kn.shrinkBuf(r.output,r.next_out))):this.onData(Kn.shrinkBuf(r.output,r.next_out)))}while((r.avail_in>0||r.avail_out===0)&&o!==zl);return i===va?(o=Gn.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===_r):(i===jl&&(this.onEnd(_r),r.avail_out=0),!0)};Sr.prototype.onData=function(t){this.chunks.push(t)};Sr.prototype.onEnd=function(t){t===_r&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Kn.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function ya(t,e){var r=new Sr(e);if(r.push(t,!0),r.err)throw r.msg||ga[r.err];return r.result}function Ch(t,e){return e=e||{},e.raw=!0,ya(t,e)}function kh(t,e){return e=e||{},e.gzip=!0,ya(t,e)}Xn.Deflate=Sr;Xn.deflate=ya;Xn.deflateRaw=Ch;Xn.gzip=kh});var Vl=He((rg,Ul)=>{"use strict";var fi=30,Th=12;Ul.exports=function(e,r){var n,o,i,a,s,f,l,c,u,d,p,h,b,F,x,m,y,w,S,D,T,C,E,I,A;n=e.state,o=e.next_in,I=e.input,i=o+(e.avail_in-5),a=e.next_out,A=e.output,s=a-(r-e.avail_out),f=a+(e.avail_out-257),l=n.dmax,c=n.wsize,u=n.whave,d=n.wnext,p=n.window,h=n.hold,b=n.bits,F=n.lencode,x=n.distcode,m=(1<>>24,h>>>=S,b-=S,S=w>>>16&255,S===0)A[a++]=w&65535;else if(S&16){D=w&65535,S&=15,S&&(b>>=S,b-=S),b<15&&(h+=I[o++]<>>24,h>>>=S,b-=S,S=w>>>16&255,S&16){if(T=w&65535,S&=15,bl){e.msg="invalid distance too far back",n.mode=fi;break e}if(h>>>=S,b-=S,S=a-s,T>S){if(S=T-S,S>u&&n.sane){e.msg="invalid distance too far back",n.mode=fi;break e}if(C=0,E=p,d===0){if(C+=c-S,S2;)A[a++]=E[C++],A[a++]=E[C++],A[a++]=E[C++],D-=3;D&&(A[a++]=E[C++],D>1&&(A[a++]=E[C++]))}else{C=a-T;do A[a++]=A[C++],A[a++]=A[C++],A[a++]=A[C++],D-=3;while(D>2);D&&(A[a++]=A[C++],D>1&&(A[a++]=A[C++]))}}else if((S&64)===0){w=x[(w&65535)+(h&(1<>3,o-=D,b-=D<<3,h&=(1<{"use strict";var ql=It(),$r=15,Wl=852,Gl=592,Kl=0,ba=1,Xl=2,Eh=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Ah=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Rh=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Oh=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];Zl.exports=function(e,r,n,o,i,a,s,f){var l=f.bits,c=0,u=0,d=0,p=0,h=0,b=0,F=0,x=0,m=0,y=0,w,S,D,T,C,E=null,I=0,A,R=new ql.Buf16($r+1),z=new ql.Buf16($r+1),M=null,X=0,te,L,ue;for(c=0;c<=$r;c++)R[c]=0;for(u=0;u=1&&R[p]===0;p--);if(h>p&&(h=p),p===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,f.bits=1,0;for(d=1;d0&&(e===Kl||p!==1))return-1;for(z[1]=0,c=1;c<$r;c++)z[c+1]=z[c]+R[c];for(u=0;uWl||e===Xl&&m>Gl)return 1;for(;;){te=c-F,s[u]A?(L=M[X+s[u]],ue=E[I+s[u]]):(L=96,ue=0),w=1<>F)+S]=te<<24|L<<16|ue|0;while(S!==0);for(w=1<>=1;if(w!==0?(y&=w-1,y+=w):y=0,u++,--R[c]===0){if(c===p)break;c=r[n+s[u]]}if(c>h&&(y&T)!==D){for(F===0&&(F=h),C+=d,b=c-F,x=1<Wl||e===Xl&&m>Gl)return 1;D=y&T,i[D]=h<<24|b<<16|C-a|0}}return y!==0&&(i[C+y]=c-F<<24|64<<16|0),f.bits=h,0}});var Rf=He(gt=>{"use strict";var nt=It(),Da=sa(),Tt=la(),Bh=Vl(),Zn=Yl(),Nh=0,wf=1,Sf=2,Jl=4,Mh=5,ci=6,Pr=0,Ih=1,zh=2,lt=-2,Pf=-3,Ca=-4,jh=-5,Ql=8,Df=1,_l=2,$l=3,ef=4,tf=5,rf=6,nf=7,of=8,af=9,sf=10,hi=11,Lt=12,xa=13,lf=14,Fa=15,ff=16,cf=17,uf=18,df=19,ui=20,di=21,hf=22,pf=23,vf=24,mf=25,gf=26,wa=27,yf=28,bf=29,be=30,ka=31,Lh=32,Hh=852,Uh=592,Vh=15,qh=Vh;function xf(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function Wh(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new nt.Buf16(320),this.work=new nt.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Cf(t){var e;return!t||!t.state?lt:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=Df,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new nt.Buf32(Hh),e.distcode=e.distdyn=new nt.Buf32(Uh),e.sane=1,e.back=-1,Pr)}function kf(t){var e;return!t||!t.state?lt:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,Cf(t))}function Tf(t,e){var r,n;return!t||!t.state||(n=t.state,e<0?(r=0,e=-e):(r=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?lt:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,kf(t))}function Ef(t,e){var r,n;return t?(n=new Wh,t.state=n,n.window=null,r=Tf(t,e),r!==Pr&&(t.state=null),r):lt}function Gh(t){return Ef(t,qh)}var Ff=!0,Sa,Pa;function Kh(t){if(Ff){var e;for(Sa=new nt.Buf32(512),Pa=new nt.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Zn(wf,t.lens,0,288,Sa,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Zn(Sf,t.lens,0,32,Pa,0,t.work,{bits:5}),Ff=!1}t.lencode=Sa,t.lenbits=9,t.distcode=Pa,t.distbits=5}function Af(t,e,r,n){var o,i=t.state;return i.window===null&&(i.wsize=1<=i.wsize?(nt.arraySet(i.window,e,r-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):(o=i.wsize-i.wnext,o>n&&(o=n),nt.arraySet(i.window,e,r-n,o,i.wnext),n-=o,n?(nt.arraySet(i.window,e,r-n,n,0),i.wnext=n,i.whave=i.wsize):(i.wnext+=o,i.wnext===i.wsize&&(i.wnext=0),i.whave>>8&255,r.check=Tt(r.check,E,2,0),l=0,c=0,r.mode=_l;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=be;break}if((l&15)!==Ql){t.msg="unknown compression method",r.mode=be;break}if(l>>>=4,c-=4,T=(l&15)+8,r.wbits===0)r.wbits=T;else if(T>r.wbits){t.msg="invalid window size",r.mode=be;break}r.dmax=1<>8&1),r.flags&512&&(E[0]=l&255,E[1]=l>>>8&255,r.check=Tt(r.check,E,2,0)),l=0,c=0,r.mode=$l;case $l:for(;c<32;){if(s===0)break e;s--,l+=n[i++]<>>8&255,E[2]=l>>>16&255,E[3]=l>>>24&255,r.check=Tt(r.check,E,4,0)),l=0,c=0,r.mode=ef;case ef:for(;c<16;){if(s===0)break e;s--,l+=n[i++]<>8),r.flags&512&&(E[0]=l&255,E[1]=l>>>8&255,r.check=Tt(r.check,E,2,0)),l=0,c=0,r.mode=tf;case tf:if(r.flags&1024){for(;c<16;){if(s===0)break e;s--,l+=n[i++]<>>8&255,r.check=Tt(r.check,E,2,0)),l=0,c=0}else r.head&&(r.head.extra=null);r.mode=rf;case rf:if(r.flags&1024&&(p=r.length,p>s&&(p=s),p&&(r.head&&(T=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),nt.arraySet(r.head.extra,n,i,p,T)),r.flags&512&&(r.check=Tt(r.check,n,p,i)),s-=p,i+=p,r.length-=p),r.length))break e;r.length=0,r.mode=nf;case nf:if(r.flags&2048){if(s===0)break e;p=0;do T=n[i+p++],r.head&&T&&r.length<65536&&(r.head.name+=String.fromCharCode(T));while(T&&p>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Lt;break;case sf:for(;c<32;){if(s===0)break e;s--,l+=n[i++]<>>=c&7,c-=c&7,r.mode=wa;break}for(;c<3;){if(s===0)break e;s--,l+=n[i++]<>>=1,c-=1,l&3){case 0:r.mode=lf;break;case 1:if(Kh(r),r.mode=ui,e===ci){l>>>=2,c-=2;break e}break;case 2:r.mode=cf;break;case 3:t.msg="invalid block type",r.mode=be}l>>>=2,c-=2;break;case lf:for(l>>>=c&7,c-=c&7;c<32;){if(s===0)break e;s--,l+=n[i++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=be;break}if(r.length=l&65535,l=0,c=0,r.mode=Fa,e===ci)break e;case Fa:r.mode=ff;case ff:if(p=r.length,p){if(p>s&&(p=s),p>f&&(p=f),p===0)break e;nt.arraySet(o,n,i,p,a),s-=p,i+=p,f-=p,a+=p,r.length-=p;break}r.mode=Lt;break;case cf:for(;c<14;){if(s===0)break e;s--,l+=n[i++]<>>=5,c-=5,r.ndist=(l&31)+1,l>>>=5,c-=5,r.ncode=(l&15)+4,l>>>=4,c-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=be;break}r.have=0,r.mode=uf;case uf:for(;r.have>>=3,c-=3}for(;r.have<19;)r.lens[R[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,I={bits:r.lenbits},C=Zn(Nh,r.lens,0,19,r.lencode,0,r.work,I),r.lenbits=I.bits,C){t.msg="invalid code lengths set",r.mode=be;break}r.have=0,r.mode=df;case df:for(;r.have>>24,m=F>>>16&255,y=F&65535,!(x<=c);){if(s===0)break e;s--,l+=n[i++]<>>=x,c-=x,r.lens[r.have++]=y;else{if(y===16){for(A=x+2;c>>=x,c-=x,r.have===0){t.msg="invalid bit length repeat",r.mode=be;break}T=r.lens[r.have-1],p=3+(l&3),l>>>=2,c-=2}else if(y===17){for(A=x+3;c>>=x,c-=x,T=0,p=3+(l&7),l>>>=3,c-=3}else{for(A=x+7;c>>=x,c-=x,T=0,p=11+(l&127),l>>>=7,c-=7}if(r.have+p>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=be;break}for(;p--;)r.lens[r.have++]=T}}if(r.mode===be)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=be;break}if(r.lenbits=9,I={bits:r.lenbits},C=Zn(wf,r.lens,0,r.nlen,r.lencode,0,r.work,I),r.lenbits=I.bits,C){t.msg="invalid literal/lengths set",r.mode=be;break}if(r.distbits=6,r.distcode=r.distdyn,I={bits:r.distbits},C=Zn(Sf,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,I),r.distbits=I.bits,C){t.msg="invalid distances set",r.mode=be;break}if(r.mode=ui,e===ci)break e;case ui:r.mode=di;case di:if(s>=6&&f>=258){t.next_out=a,t.avail_out=f,t.next_in=i,t.avail_in=s,r.hold=l,r.bits=c,Bh(t,d),a=t.next_out,o=t.output,f=t.avail_out,i=t.next_in,n=t.input,s=t.avail_in,l=r.hold,c=r.bits,r.mode===Lt&&(r.back=-1);break}for(r.back=0;F=r.lencode[l&(1<>>24,m=F>>>16&255,y=F&65535,!(x<=c);){if(s===0)break e;s--,l+=n[i++]<>w)],x=F>>>24,m=F>>>16&255,y=F&65535,!(w+x<=c);){if(s===0)break e;s--,l+=n[i++]<>>=w,c-=w,r.back+=w}if(l>>>=x,c-=x,r.back+=x,r.length=y,m===0){r.mode=gf;break}if(m&32){r.back=-1,r.mode=Lt;break}if(m&64){t.msg="invalid literal/length code",r.mode=be;break}r.extra=m&15,r.mode=hf;case hf:if(r.extra){for(A=r.extra;c>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=pf;case pf:for(;F=r.distcode[l&(1<>>24,m=F>>>16&255,y=F&65535,!(x<=c);){if(s===0)break e;s--,l+=n[i++]<>w)],x=F>>>24,m=F>>>16&255,y=F&65535,!(w+x<=c);){if(s===0)break e;s--,l+=n[i++]<>>=w,c-=w,r.back+=w}if(l>>>=x,c-=x,r.back+=x,m&64){t.msg="invalid distance code",r.mode=be;break}r.offset=y,r.extra=m&15,r.mode=vf;case vf:if(r.extra){for(A=r.extra;c>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=be;break}r.mode=mf;case mf:if(f===0)break e;if(p=d-f,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=be;break}p>r.wnext?(p-=r.wnext,h=r.wsize-p):h=r.wnext-p,p>r.length&&(p=r.length),b=r.window}else b=o,h=a-r.offset,p=r.length;p>f&&(p=f),f-=p,r.length-=p;do o[a++]=b[h++];while(--p);r.length===0&&(r.mode=di);break;case gf:if(f===0)break e;o[a++]=r.length,f--,r.mode=di;break;case wa:if(r.wrap){for(;c<32;){if(s===0)break e;s--,l|=n[i++]<{"use strict";Of.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var Nf=He((ag,Bf)=>{"use strict";function Qh(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}Bf.exports=Qh});var If=He(Jn=>{"use strict";var en=Rf(),Yn=It(),pi=ha(),ke=Ta(),Ea=ti(),_h=pa(),$h=Nf(),Mf=Object.prototype.toString;function Dr(t){if(!(this instanceof Dr))return new Dr(t);this.options=Yn.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new _h,this.strm.avail_out=0;var r=en.inflateInit2(this.strm,e.windowBits);if(r!==ke.Z_OK)throw new Error(Ea[r]);if(this.header=new $h,en.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=pi.string2buf(e.dictionary):Mf.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=en.inflateSetDictionary(this.strm,e.dictionary),r!==ke.Z_OK)))throw new Error(Ea[r])}Dr.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,o=this.options.dictionary,i,a,s,f,l,c=!1;if(this.ended)return!1;a=e===~~e?e:e===!0?ke.Z_FINISH:ke.Z_NO_FLUSH,typeof t=="string"?r.input=pi.binstring2buf(t):Mf.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new Yn.Buf8(n),r.next_out=0,r.avail_out=n),i=en.inflate(r,ke.Z_NO_FLUSH),i===ke.Z_NEED_DICT&&o&&(i=en.inflateSetDictionary(this.strm,o)),i===ke.Z_BUF_ERROR&&c===!0&&(i=ke.Z_OK,c=!1),i!==ke.Z_STREAM_END&&i!==ke.Z_OK)return this.onEnd(i),this.ended=!0,!1;r.next_out&&(r.avail_out===0||i===ke.Z_STREAM_END||r.avail_in===0&&(a===ke.Z_FINISH||a===ke.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=pi.utf8border(r.output,r.next_out),f=r.next_out-s,l=pi.buf2string(r.output,s),r.next_out=f,r.avail_out=n-f,f&&Yn.arraySet(r.output,r.output,s,f,0),this.onData(l)):this.onData(Yn.shrinkBuf(r.output,r.next_out))),r.avail_in===0&&r.avail_out===0&&(c=!0)}while((r.avail_in>0||r.avail_out===0)&&i!==ke.Z_STREAM_END);return i===ke.Z_STREAM_END&&(a=ke.Z_FINISH),a===ke.Z_FINISH?(i=en.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===ke.Z_OK):(a===ke.Z_SYNC_FLUSH&&(this.onEnd(ke.Z_OK),r.avail_out=0),!0)};Dr.prototype.onData=function(t){this.chunks.push(t)};Dr.prototype.onEnd=function(t){t===ke.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Yn.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Aa(t,e){var r=new Dr(e);if(r.push(t,!0),r.err)throw r.msg||Ea[r.err];return r.result}function ep(t,e){return e=e||{},e.raw=!0,Aa(t,e)}Jn.Inflate=Dr;Jn.inflate=Aa;Jn.inflateRaw=ep;Jn.ungzip=Aa});var Qn=He((lg,jf)=>{"use strict";var tp=It().assign,rp=Hl(),np=If(),op=Ta(),zf={};tp(zf,rp,np,op);jf.exports=zf});var Bm={};od(Bm,{default:()=>qi});module.exports=id(Bm);var N=require("obsidian");var Ki=function(t,e){return Ki=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)n.hasOwnProperty(o)&&(r[o]=n[o])},Ki(t,e)};function k(t,e){Ki(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Y=function(){return Y=Object.assign||function(e){for(var r,n=1,o=arguments.length;n0&&i[i.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]>2],e+=Vr[(t[n]&3)<<4|t[n+1]>>4],e+=Vr[(t[n+1]&15)<<2|t[n+2]>>6],e+=Vr[t[n+2]&63];return r%3===2?e=e.substring(0,e.length-1)+"=":r%3===1&&(e=e.substring(0,e.length-2)+"=="),e},Ts=function(t){var e=t.length*.75,r=t.length,n,o=0,i,a,s,f;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);var l=new Uint8Array(e);for(n=0;n>4,l[o++]=(a&15)<<4|s>>2,l[o++]=(s&3)<<6|f&63;return l},ad=/^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i,As=function(t){var e=t.trim(),r=e.substring(0,100),n=r.match(ad);if(!n)return Ts(e);var o=n[0],i=e.substring(o.length);return Ts(i)};var Q=function(t){return t.charCodeAt(0)},Rs=function(t){return t.codePointAt(0)},Mt=function(t,e){return rt(t.toString(16),e,"0").toUpperCase()},Wt=function(t){return Mt(t,2)},tt=function(t){return String.fromCharCode(t)},Os=function(t){return tt(parseInt(t,16))},rt=function(t,e,r){for(var n="",o=0,i=e-t.length;o=55296&&r<=56319&&t.length>o&&(n=t.charCodeAt(o),n>=56320&&n<=57343&&(i=2)),[t.slice(e,e+i),i]},Ns=function(t){for(var e=[],r=0,n=t.length;rr&&l(),a+=d,s+=p}}return l(),f},cd=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,Zo=function(t){var e=t.match(cd);if(e){var r=e[1],n=e[2],o=n===void 0?"01":n,i=e[3],a=i===void 0?"01":i,s=e[4],f=s===void 0?"00":s,l=e[5],c=l===void 0?"00":l,u=e[6],d=u===void 0?"00":u,p=e[7],h=p===void 0?"Z":p,b=e[8],F=b===void 0?"00":b,x=e[9],m=x===void 0?"00":x,y=h==="Z"?"Z":""+h+F+":"+m,w=new Date(r+"-"+o+"-"+a+"T"+f+":"+c+":"+d+y);return w}},On=function(t,e){for(var r,n=0,o;n=0&&t<=65535},Zs=function(t){return t>=65536&&t<=1114111},Yi=function(t){return Math.floor((t-65536)/1024)+55296},Ji=function(t){return(t-65536)%1024+56320},Gt;(function(t){t.BigEndian="BigEndian",t.LittleEndian="LittleEndian"})(Gt||(Gt={}));var Bn="\uFFFD".codePointAt(0),Qo=function(t,e){if(e===void 0&&(e=!0),t.length<=1)return String.fromCodePoint(Bn);for(var r=e?dd(t):Gt.BigEndian,n=e?2:0,o=[];t.length-n>=2;){var i=Gs(t[n++],t[n++],r);if(ud(i))if(t.length-n<2)o.push(Bn);else{var a=Gs(t[n++],t[n++],r);Ws(a)?o.push(i,a):o.push(Bn)}else Ws(i)?(n+=2,o.push(Bn)):o.push(i)}return n=55296&&t<=56319},Ws=function(t){return t>=56320&&t<=57343},Gs=function(t,e,r){if(r===Gt.LittleEndian)return e<<8|t;if(r===Gt.BigEndian)return t<<8|e;throw new Error("Invalid byteOrder: "+r)},dd=function(t){return Ys(t)?Gt.BigEndian:Js(t)?Gt.LittleEndian:Gt.BigEndian},Ys=function(t){return t[0]===254&&t[1]===255},Js=function(t){return t[0]===255&&t[1]===254},_o=function(t){return Ys(t)||Js(t)};var Qs=function(t){var e=String(t);if(Math.abs(t)<1){var r=parseInt(t.toString().split("e-")[1]);if(r){var n=t<0;n&&(t*=-1),t*=Math.pow(10,r-1),e="0."+new Array(r).join("0")+t.toString().substring(2),n&&(e="-"+e)}}else{var r=parseInt(t.toString().split("+")[1]);r>20&&(r-=20,t/=Math.pow(10,r),e=t.toString()+new Array(r+1).join("0"))}return e},Nn=function(t){return Math.ceil(t.toString(2).length/8)},mr=function(t){for(var e=new Uint8Array(Nn(t)),r=1;r<=e.length;r++)e[r-1]=t>>(e.length-r)*8;return e};var gr=function(t){throw new Error(t)};var Hf=Ko(Qn()),Lf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$n=new Uint8Array(256);for(_n=0;_n>4,l[o++]=(a&15)<<4|s>>2,l[o++]=(s&3)<<6|f&63;return l},ap=function(t){for(var e="",r=0;rn)throw new Error(Me(e)+" must be at least "+r+" and at most "+n+", but was actually "+t)},ot=function(t,e,r,n){P(t,e,["number","undefined"]),typeof t=="number"&&Ue(t,e,r,n)},gi=function(t,e,r){if(P(t,e,["number"]),t%r!==0)throw new Error(Me(e)+" must be a multiple of "+r+", but was actually "+t)},sc=function(t,e){if(!Number.isInteger(t))throw new Error(Me(e)+" must be an integer, but was actually "+t)},_t=function(t,e){if(![1,0].includes(Math.sign(t)))throw new Error(Me(e)+" must be a positive number or 0, but was actually "+t)};var $=new Uint16Array(256);for(no=0;no<256;no++)$[no]=no;var no;$[22]=Q("");$[24]=Q("\u02D8");$[25]=Q("\u02C7");$[26]=Q("\u02C6");$[27]=Q("\u02D9");$[28]=Q("\u02DD");$[29]=Q("\u02DB");$[30]=Q("\u02DA");$[31]=Q("\u02DC");$[127]=Q("\uFFFD");$[128]=Q("\u2022");$[129]=Q("\u2020");$[130]=Q("\u2021");$[131]=Q("\u2026");$[132]=Q("\u2014");$[133]=Q("\u2013");$[134]=Q("\u0192");$[135]=Q("\u2044");$[136]=Q("\u2039");$[137]=Q("\u203A");$[138]=Q("\u2212");$[139]=Q("\u2030");$[140]=Q("\u201E");$[141]=Q("\u201C");$[142]=Q("\u201D");$[143]=Q("\u2018");$[144]=Q("\u2019");$[145]=Q("\u201A");$[146]=Q("\u2122");$[147]=Q("\uFB01");$[148]=Q("\uFB02");$[149]=Q("\u0141");$[150]=Q("\u0152");$[151]=Q("\u0160");$[152]=Q("\u0178");$[153]=Q("\u017D");$[154]=Q("\u0131");$[155]=Q("\u0142");$[156]=Q("\u0153");$[157]=Q("\u0161");$[158]=Q("\u017E");$[159]=Q("\uFFFD");$[160]=Q("\u20AC");$[173]=Q("\uFFFD");var yi=function(t){for(var e=new Array(t.length),r=0,n=t.length;r=g.ExclamationPoint&&t<=g.Tilde&&!xi[t]},Dc={},Cc=new Map,jp=function(t){k(e,t);function e(r,n){var o=this;if(r!==Dc)throw new tn("PDFName");o=t.call(this)||this;for(var i="/",a=0,s=n.length;a=g.Zero&&l<=g.Nine||l>=g.a&&l<=g.f||l>=g.A&&l<=g.F?(n+=f,(n.length===2||!(c>="0"&&c<="9"||c>="a"&&c<="f"||c>="A"&&c<="F"))&&(i(parseInt(n,16)),n="")):i(l):l===g.Hash?o=!0:i(l)}return new Uint8Array(r)},e.prototype.decodeText=function(){var r=this.asBytes();return String.fromCharCode.apply(String,Array.from(r))},e.prototype.asString=function(){return this.encodedName},e.prototype.value=function(){return this.encodedName},e.prototype.clone=function(){return this},e.prototype.toString=function(){return this.encodedName},e.prototype.sizeInBytes=function(){return this.encodedName.length},e.prototype.copyBytesInto=function(r,n){return n+=me(this.encodedName,r,n),this.encodedName.length},e.of=function(r){var n=Ip(r),o=Cc.get(n);return o||(o=new e(Dc,n),Cc.set(n,o)),o},e.Length=e.of("Length"),e.FlateDecode=e.of("FlateDecode"),e.Resources=e.of("Resources"),e.Font=e.of("Font"),e.XObject=e.of("XObject"),e.ExtGState=e.of("ExtGState"),e.Contents=e.of("Contents"),e.Type=e.of("Type"),e.Parent=e.of("Parent"),e.MediaBox=e.of("MediaBox"),e.Page=e.of("Page"),e.Annots=e.of("Annots"),e.TrimBox=e.of("TrimBox"),e.ArtBox=e.of("ArtBox"),e.BleedBox=e.of("BleedBox"),e.CropBox=e.of("CropBox"),e.Rotate=e.of("Rotate"),e.Title=e.of("Title"),e.Author=e.of("Author"),e.Subject=e.of("Subject"),e.Creator=e.of("Creator"),e.Keywords=e.of("Keywords"),e.Producer=e.of("Producer"),e.CreationDate=e.of("CreationDate"),e.ModDate=e.of("ModDate"),e}(ve),v=jp;var Lp=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.asNull=function(){return null},e.prototype.clone=function(){return this},e.prototype.toString=function(){return"null"},e.prototype.sizeInBytes=function(){return 4},e.prototype.copyBytesInto=function(r,n){return r[n++]=g.n,r[n++]=g.u,r[n++]=g.l,r[n++]=g.l,4},e}(ve),Te=new Lp;var Hp=function(t){k(e,t);function e(r,n){var o=t.call(this)||this;return o.dict=r,o.context=n,o}return e.prototype.keys=function(){return Array.from(this.dict.keys())},e.prototype.values=function(){return Array.from(this.dict.values())},e.prototype.entries=function(){return Array.from(this.dict.entries())},e.prototype.set=function(r,n){this.dict.set(r,n)},e.prototype.get=function(r,n){n===void 0&&(n=!1);var o=this.dict.get(r);if(!(o===Te&&!n))return o},e.prototype.has=function(r){var n=this.dict.get(r);return n!==void 0&&n!==Te},e.prototype.lookupMaybe=function(r){for(var n,o=[],i=1;i()=>(e||t((e={exports:{}}).exports,e),e.exports),id=(t,e)=>{for(var r in e)Go(t,r,{get:e[r],enumerable:!0})},Ts=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of rd(e))!od.call(t,o)&&o!==r&&Go(t,o,{get:()=>e[o],enumerable:!(n=td(e,o))||n.enumerable});return t};var Ko=(t,e,r)=>(r=t!=null?ed(nd(t)):{},Ts(e||!t||!t.__esModule?Go(r,"default",{value:t,enumerable:!0}):r,t)),ad=t=>Ts(Go({},"__esModule",{value:!0}),t);var It=He(Ke=>{"use strict";var pd=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function vd(t,e){return Object.prototype.hasOwnProperty.call(t,e)}Ke.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(var n in r)vd(r,n)&&(t[n]=r[n])}}return t};Ke.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var md={arraySet:function(t,e,r,n,o){if(e.subarray&&t.subarray){t.set(e.subarray(r,r+n),o);return}for(var i=0;i{"use strict";var yd=It(),bd=4,el=0,tl=1,xd=2;function Kr(t){for(var e=t.length;--e>=0;)t[e]=0}var Fd=0,sl=1,wd=2,Sd=3,Pd=258,oa=29,Hn=256,In=Hn+1+oa,Gr=30,ia=19,ll=2*In+1,yr=15,_i=16,Dd=7,aa=256,fl=16,cl=17,ul=18,ra=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],$o=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Cd=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],dl=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],kd=512,zt=new Array((In+2)*2);Kr(zt);var Mn=new Array(Gr*2);Kr(Mn);var zn=new Array(kd);Kr(zn);var jn=new Array(Pd-Sd+1);Kr(jn);var sa=new Array(oa);Kr(sa);var ei=new Array(Gr);Kr(ei);function $i(t,e,r,n,o){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=o,this.has_stree=t&&t.length}var hl,pl,vl;function ea(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function ml(t){return t<256?zn[t]:zn[256+(t>>>7)]}function Ln(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function _e(t,e,r){t.bi_valid>_i-r?(t.bi_buf|=e<>_i-t.bi_valid,t.bi_valid+=r-_i):(t.bi_buf|=e<>>=1,r<<=1;while(--e>0);return r>>>1}function Td(t){t.bi_valid===16?(Ln(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)}function Ed(t,e){var r=e.dyn_tree,n=e.max_code,o=e.stat_desc.static_tree,i=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,f=e.stat_desc.max_length,l,c,u,d,p,h,b=0;for(d=0;d<=yr;d++)t.bl_count[d]=0;for(r[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;lf&&(d=f,b++),r[c*2+1]=d,!(c>n)&&(t.bl_count[d]++,p=0,c>=s&&(p=a[c-s]),h=r[c*2],t.opt_len+=h*(d+p),i&&(t.static_len+=h*(o[c*2+1]+p)));if(b!==0){do{for(d=f-1;t.bl_count[d]===0;)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[f]--,b-=2}while(b>0);for(d=f;d!==0;d--)for(c=t.bl_count[d];c!==0;)u=t.heap[--l],!(u>n)&&(r[u*2+1]!==d&&(t.opt_len+=(d-r[u*2+1])*r[u*2],r[u*2+1]=d),c--)}}function yl(t,e,r){var n=new Array(yr+1),o=0,i,a;for(i=1;i<=yr;i++)n[i]=o=o+r[i-1]<<1;for(a=0;a<=e;a++){var s=t[a*2+1];s!==0&&(t[a*2]=gl(n[s]++,s))}}function Ad(){var t,e,r,n,o,i=new Array(yr+1);for(r=0,n=0;n>=7;n8?Ln(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function Rd(t,e,r,n){xl(t),n&&(Ln(t,r),Ln(t,~r)),yd.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}function rl(t,e,r,n){var o=e*2,i=r*2;return t[o]>1;a>=1;a--)ta(t,r,a);l=i;do a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],ta(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=s,r[l*2]=r[a*2]+r[s*2],t.depth[l]=(t.depth[a]>=t.depth[s]?t.depth[a]:t.depth[s])+1,r[a*2+1]=r[s*2+1]=l,t.heap[1]=l++,ta(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],Ed(t,e),yl(r,f,t.bl_count)}function ol(t,e,r){var n,o=-1,i,a=e[0*2+1],s=0,f=7,l=4;for(a===0&&(f=138,l=3),e[(r+1)*2+1]=65535,n=0;n<=r;n++)i=a,a=e[(n+1)*2+1],!(++s=3&&t.bl_tree[dl[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function Bd(t,e,r,n){var o;for(_e(t,e-257,5),_e(t,r-1,5),_e(t,n-4,4),o=0;o>>=1)if(e&1&&t.dyn_ltree[r*2]!==0)return el;if(t.dyn_ltree[9*2]!==0||t.dyn_ltree[10*2]!==0||t.dyn_ltree[13*2]!==0)return tl;for(r=32;r0?(t.strm.data_type===xd&&(t.strm.data_type=Nd(t)),na(t,t.l_desc),na(t,t.d_desc),a=Od(t),o=t.opt_len+3+7>>>3,i=t.static_len+3+7>>>3,i<=o&&(o=i)):o=i=r+5,r+4<=o&&e!==-1?Fl(t,e,r,n):t.strategy===bd||i===o?(_e(t,(sl<<1)+(n?1:0),3),nl(t,zt,Mn)):(_e(t,(wd<<1)+(n?1:0),3),Bd(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),nl(t,t.dyn_ltree,t.dyn_dtree)),bl(t),n&&xl(t)}function jd(t,e,r){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=r&255,t.last_lit++,e===0?t.dyn_ltree[r*2]++:(t.matches++,e--,t.dyn_ltree[(jn[r]+Hn+1)*2]++,t.dyn_dtree[ml(e)*2]++),t.last_lit===t.lit_bufsize-1}Xr._tr_init=Md;Xr._tr_stored_block=Fl;Xr._tr_flush_block=zd;Xr._tr_tally=jd;Xr._tr_align=Id});var la=He((Jm,Sl)=>{"use strict";function Ld(t,e,r,n){for(var o=t&65535|0,i=t>>>16&65535|0,a=0;r!==0;){a=r>2e3?2e3:r,r-=a;do o=o+e[n++]|0,i=i+o|0;while(--a);o%=65521,i%=65521}return o|i<<16|0}Sl.exports=Ld});var fa=He((Qm,Pl)=>{"use strict";function Hd(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[r]=t}return e}var Ud=Hd();function Vd(t,e,r,n){var o=Ud,i=n+r;t^=-1;for(var a=n;a>>8^o[(t^e[a])&255];return t^-1}Pl.exports=Vd});var ti=He((_m,Dl)=>{"use strict";Dl.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var Nl=He(kt=>{"use strict";var Xe=It(),at=wl(),El=la(),Kt=fa(),qd=ti(),wr=0,Wd=1,Gd=3,Qt=4,Cl=5,Ct=0,kl=1,st=-2,Kd=-3,ca=-5,Xd=-1,Zd=1,ri=2,Yd=3,Jd=4,Qd=0,_d=2,ai=8,$d=9,eh=15,th=8,rh=29,nh=256,da=nh+1+rh,oh=30,ih=19,ah=2*da+1,sh=15,de=3,Yt=258,mt=Yt+de+1,lh=32,si=42,ha=69,ni=73,oi=91,ii=103,br=113,Vn=666,Ne=1,qn=2,xr=3,Jr=4,fh=3;function Jt(t,e){return t.msg=qd[e],e}function Tl(t){return(t<<1)-(t>4?9:0)}function Zt(t){for(var e=t.length;--e>=0;)t[e]=0}function Xt(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(Xe.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,e.pending===0&&(e.pending_out=0))}function je(t,e){at._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Xt(t.strm)}function he(t,e){t.pending_buf[t.pending++]=e}function Un(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function ch(t,e,r,n){var o=t.avail_in;return o>n&&(o=n),o===0?0:(t.avail_in-=o,Xe.arraySet(e,t.input,t.next_in,o,r),t.state.wrap===1?t.adler=El(t.adler,e,o,r):t.state.wrap===2&&(t.adler=Kt(t.adler,e,o,r)),t.next_in+=o,t.total_in+=o,o)}function Al(t,e){var r=t.max_chain_length,n=t.strstart,o,i,a=t.prev_length,s=t.nice_match,f=t.strstart>t.w_size-mt?t.strstart-(t.w_size-mt):0,l=t.window,c=t.w_mask,u=t.prev,d=t.strstart+Yt,p=l[n+a-1],h=l[n+a];t.prev_length>=t.good_match&&(r>>=2),s>t.lookahead&&(s=t.lookahead);do if(o=e,!(l[o+a]!==h||l[o+a-1]!==p||l[o]!==l[n]||l[++o]!==l[n+1])){n+=2,o++;do;while(l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&l[++n]===l[++o]&&na){if(t.match_start=e,a=i,i>=s)break;p=l[n+a-1],h=l[n+a]}}while((e=u[e&c])>f&&--r!==0);return a<=t.lookahead?a:t.lookahead}function Fr(t){var e=t.w_size,r,n,o,i,a;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-mt)){Xe.arraySet(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do o=t.head[--r],t.head[r]=o>=e?o-e:0;while(--n);n=e,r=n;do o=t.prev[--r],t.prev[r]=o>=e?o-e:0;while(--n);i+=e}if(t.strm.avail_in===0)break;if(n=ch(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=de)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=(t.ins_h<t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Fr(t),t.lookahead===0&&e===wr)return Ne;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((t.strstart===0||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,je(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-mt&&(je(t,!1),t.strm.avail_out===0))return Ne}return t.insert=0,e===Qt?(je(t,!0),t.strm.avail_out===0?xr:Jr):(t.strstart>t.block_start&&(je(t,!1),t.strm.avail_out===0),Ne)}function ua(t,e){for(var r,n;;){if(t.lookahead=de&&(t.ins_h=(t.ins_h<=de)if(n=at._tr_tally(t,t.strstart-t.match_start,t.match_length-de),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=de){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<=de&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=de-1)),t.prev_length>=de&&t.match_length<=t.prev_length){o=t.strstart+t.lookahead-de,n=at._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-de),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=o&&(t.ins_h=(t.ins_h<=de&&t.strstart>0&&(o=t.strstart-1,n=a[o],n===a[++o]&&n===a[++o]&&n===a[++o])){i=t.strstart+Yt;do;while(n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&n===a[++o]&&ot.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=de?(r=at._tr_tally(t,1,t.match_length-de),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=at._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(je(t,!1),t.strm.avail_out===0))return Ne}return t.insert=0,e===Qt?(je(t,!0),t.strm.avail_out===0?xr:Jr):t.last_lit&&(je(t,!1),t.strm.avail_out===0)?Ne:qn}function hh(t,e){for(var r;;){if(t.lookahead===0&&(Fr(t),t.lookahead===0)){if(e===wr)return Ne;break}if(t.match_length=0,r=at._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(je(t,!1),t.strm.avail_out===0))return Ne}return t.insert=0,e===Qt?(je(t,!0),t.strm.avail_out===0?xr:Jr):t.last_lit&&(je(t,!1),t.strm.avail_out===0)?Ne:qn}function Dt(t,e,r,n,o){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=o}var Yr;Yr=[new Dt(0,0,0,0,uh),new Dt(4,4,8,4,ua),new Dt(4,5,16,8,ua),new Dt(4,6,32,32,ua),new Dt(4,4,16,16,Zr),new Dt(8,16,32,32,Zr),new Dt(8,16,128,128,Zr),new Dt(8,32,128,256,Zr),new Dt(32,128,258,1024,Zr),new Dt(32,258,258,4096,Zr)];function ph(t){t.window_size=2*t.w_size,Zt(t.head),t.max_lazy_match=Yr[t.level].max_lazy,t.good_match=Yr[t.level].good_length,t.nice_match=Yr[t.level].nice_length,t.max_chain_length=Yr[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=de-1,t.match_available=0,t.ins_h=0}function vh(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ai,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Xe.Buf16(ah*2),this.dyn_dtree=new Xe.Buf16((2*oh+1)*2),this.bl_tree=new Xe.Buf16((2*ih+1)*2),Zt(this.dyn_ltree),Zt(this.dyn_dtree),Zt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Xe.Buf16(sh+1),this.heap=new Xe.Buf16(2*da+1),Zt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Xe.Buf16(2*da+1),Zt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Rl(t){var e;return!t||!t.state?Jt(t,st):(t.total_in=t.total_out=0,t.data_type=_d,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?si:br,t.adler=e.wrap===2?0:1,e.last_flush=wr,at._tr_init(e),Ct)}function Ol(t){var e=Rl(t);return e===Ct&&ph(t.state),e}function mh(t,e){return!t||!t.state||t.state.wrap!==2?st:(t.state.gzhead=e,Ct)}function Bl(t,e,r,n,o,i){if(!t)return st;var a=1;if(e===Xd&&(e=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),o<1||o>$d||r!==ai||n<8||n>15||e<0||e>9||i<0||i>Jd)return Jt(t,st);n===8&&(n=9);var s=new vh;return t.state=s,s.strm=t,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<Cl||e<0)return t?Jt(t,st):st;if(n=t.state,!t.output||!t.input&&t.avail_in!==0||n.status===Vn&&e!==Qt)return Jt(t,t.avail_out===0?ca:st);if(n.strm=t,r=n.last_flush,n.last_flush=e,n.status===si)if(n.wrap===2)t.adler=0,he(n,31),he(n,139),he(n,8),n.gzhead?(he(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),he(n,n.gzhead.time&255),he(n,n.gzhead.time>>8&255),he(n,n.gzhead.time>>16&255),he(n,n.gzhead.time>>24&255),he(n,n.level===9?2:n.strategy>=ri||n.level<2?4:0),he(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(he(n,n.gzhead.extra.length&255),he(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=Kt(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=ha):(he(n,0),he(n,0),he(n,0),he(n,0),he(n,0),he(n,n.level===9?2:n.strategy>=ri||n.level<2?4:0),he(n,fh),n.status=br);else{var a=ai+(n.w_bits-8<<4)<<8,s=-1;n.strategy>=ri||n.level<2?s=0:n.level<6?s=1:n.level===6?s=2:s=3,a|=s<<6,n.strstart!==0&&(a|=lh),a+=31-a%31,n.status=br,Un(n,a),n.strstart!==0&&(Un(n,t.adler>>>16),Un(n,t.adler&65535)),t.adler=1}if(n.status===ha)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),Xt(t),o=n.pending,n.pending===n.pending_buf_size));)he(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=ni)}else n.status=ni;if(n.status===ni)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),Xt(t),o=n.pending,n.pending===n.pending_buf_size)){i=1;break}n.gzindexo&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),i===0&&(n.gzindex=0,n.status=oi)}else n.status=oi;if(n.status===oi)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),Xt(t),o=n.pending,n.pending===n.pending_buf_size)){i=1;break}n.gzindexo&&(t.adler=Kt(t.adler,n.pending_buf,n.pending-o,o)),i===0&&(n.status=ii)}else n.status=ii;if(n.status===ii&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Xt(t),n.pending+2<=n.pending_buf_size&&(he(n,t.adler&255),he(n,t.adler>>8&255),t.adler=0,n.status=br)):n.status=br),n.pending!==0){if(Xt(t),t.avail_out===0)return n.last_flush=-1,Ct}else if(t.avail_in===0&&Tl(e)<=Tl(r)&&e!==Qt)return Jt(t,ca);if(n.status===Vn&&t.avail_in!==0)return Jt(t,ca);if(t.avail_in!==0||n.lookahead!==0||e!==wr&&n.status!==Vn){var f=n.strategy===ri?hh(n,e):n.strategy===Yd?dh(n,e):Yr[n.level].func(n,e);if((f===xr||f===Jr)&&(n.status=Vn),f===Ne||f===xr)return t.avail_out===0&&(n.last_flush=-1),Ct;if(f===qn&&(e===Wd?at._tr_align(n):e!==Cl&&(at._tr_stored_block(n,0,0,!1),e===Gd&&(Zt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Xt(t),t.avail_out===0))return n.last_flush=-1,Ct}return e!==Qt?Ct:n.wrap<=0?kl:(n.wrap===2?(he(n,t.adler&255),he(n,t.adler>>8&255),he(n,t.adler>>16&255),he(n,t.adler>>24&255),he(n,t.total_in&255),he(n,t.total_in>>8&255),he(n,t.total_in>>16&255),he(n,t.total_in>>24&255)):(Un(n,t.adler>>>16),Un(n,t.adler&65535)),Xt(t),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Ct:kl)}function bh(t){var e;return!t||!t.state?st:(e=t.state.status,e!==si&&e!==ha&&e!==ni&&e!==oi&&e!==ii&&e!==br&&e!==Vn?Jt(t,st):(t.state=null,e===br?Jt(t,Kd):Ct))}function xh(t,e){var r=e.length,n,o,i,a,s,f,l,c;if(!t||!t.state||(n=t.state,a=n.wrap,a===2||a===1&&n.status!==si||n.lookahead))return st;for(a===1&&(t.adler=El(t.adler,e,r,0)),n.wrap=0,r>=n.w_size&&(a===0&&(Zt(n.head),n.strstart=0,n.block_start=0,n.insert=0),c=new Xe.Buf8(n.w_size),Xe.arraySet(c,e,r-n.w_size,n.w_size,0),e=c,r=n.w_size),s=t.avail_in,f=t.next_in,l=t.input,t.avail_in=r,t.next_in=0,t.input=e,Fr(n);n.lookahead>=de;){o=n.strstart,i=n.lookahead-(de-1);do n.ins_h=(n.ins_h<{"use strict";var li=It(),Ml=!0,Il=!0;try{String.fromCharCode.apply(null,[0])}catch{Ml=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Il=!1}var Wn=new li.Buf8(256);for(jt=0;jt<256;jt++)Wn[jt]=jt>=252?6:jt>=248?5:jt>=240?4:jt>=224?3:jt>=192?2:1;var jt;Wn[254]=Wn[254]=1;Qr.string2buf=function(t){var e,r,n,o,i,a=t.length,s=0;for(o=0;o>>6,e[i++]=128|r&63):r<65536?(e[i++]=224|r>>>12,e[i++]=128|r>>>6&63,e[i++]=128|r&63):(e[i++]=240|r>>>18,e[i++]=128|r>>>12&63,e[i++]=128|r>>>6&63,e[i++]=128|r&63);return e};function zl(t,e){if(e<65534&&(t.subarray&&Il||!t.subarray&&Ml))return String.fromCharCode.apply(null,li.shrinkBuf(t,e));for(var r="",n=0;n4){s[n++]=65533,r+=i-1;continue}for(o&=i===2?31:i===3?15:7;i>1&&r1){s[n++]=65533;continue}o<65536?s[n++]=o:(o-=65536,s[n++]=55296|o>>10&1023,s[n++]=56320|o&1023)}return zl(s,n)};Qr.utf8border=function(t,e){var r;for(e=e||t.length,e>t.length&&(e=t.length),r=e-1;r>=0&&(t[r]&192)===128;)r--;return r<0||r===0?e:r+Wn[t[r]]>e?r:e}});var va=He((tg,jl)=>{"use strict";function Fh(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}jl.exports=Fh});var Vl=He(Xn=>{"use strict";var Gn=Nl(),Kn=It(),ga=pa(),ya=ti(),wh=va(),Ul=Object.prototype.toString,Sh=0,ma=4,_r=0,Ll=1,Hl=2,Ph=-1,Dh=0,Ch=8;function Sr(t){if(!(this instanceof Sr))return new Sr(t);this.options=Kn.assign({level:Ph,method:Ch,chunkSize:16384,windowBits:15,memLevel:8,strategy:Dh,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new wh,this.strm.avail_out=0;var r=Gn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==_r)throw new Error(ya[r]);if(e.header&&Gn.deflateSetHeader(this.strm,e.header),e.dictionary){var n;if(typeof e.dictionary=="string"?n=ga.string2buf(e.dictionary):Ul.call(e.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(e.dictionary):n=e.dictionary,r=Gn.deflateSetDictionary(this.strm,n),r!==_r)throw new Error(ya[r]);this._dict_set=!0}}Sr.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,o,i;if(this.ended)return!1;i=e===~~e?e:e===!0?ma:Sh,typeof t=="string"?r.input=ga.string2buf(t):Ul.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new Kn.Buf8(n),r.next_out=0,r.avail_out=n),o=Gn.deflate(r,i),o!==Ll&&o!==_r)return this.onEnd(o),this.ended=!0,!1;(r.avail_out===0||r.avail_in===0&&(i===ma||i===Hl))&&(this.options.to==="string"?this.onData(ga.buf2binstring(Kn.shrinkBuf(r.output,r.next_out))):this.onData(Kn.shrinkBuf(r.output,r.next_out)))}while((r.avail_in>0||r.avail_out===0)&&o!==Ll);return i===ma?(o=Gn.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===_r):(i===Hl&&(this.onEnd(_r),r.avail_out=0),!0)};Sr.prototype.onData=function(t){this.chunks.push(t)};Sr.prototype.onEnd=function(t){t===_r&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Kn.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function ba(t,e){var r=new Sr(e);if(r.push(t,!0),r.err)throw r.msg||ya[r.err];return r.result}function kh(t,e){return e=e||{},e.raw=!0,ba(t,e)}function Th(t,e){return e=e||{},e.gzip=!0,ba(t,e)}Xn.Deflate=Sr;Xn.deflate=ba;Xn.deflateRaw=kh;Xn.gzip=Th});var Wl=He((ng,ql)=>{"use strict";var fi=30,Eh=12;ql.exports=function(e,r){var n,o,i,a,s,f,l,c,u,d,p,h,b,F,x,m,y,w,S,D,T,C,E,I,A;n=e.state,o=e.next_in,I=e.input,i=o+(e.avail_in-5),a=e.next_out,A=e.output,s=a-(r-e.avail_out),f=a+(e.avail_out-257),l=n.dmax,c=n.wsize,u=n.whave,d=n.wnext,p=n.window,h=n.hold,b=n.bits,F=n.lencode,x=n.distcode,m=(1<>>24,h>>>=S,b-=S,S=w>>>16&255,S===0)A[a++]=w&65535;else if(S&16){D=w&65535,S&=15,S&&(b>>=S,b-=S),b<15&&(h+=I[o++]<>>24,h>>>=S,b-=S,S=w>>>16&255,S&16){if(T=w&65535,S&=15,bl){e.msg="invalid distance too far back",n.mode=fi;break e}if(h>>>=S,b-=S,S=a-s,T>S){if(S=T-S,S>u&&n.sane){e.msg="invalid distance too far back",n.mode=fi;break e}if(C=0,E=p,d===0){if(C+=c-S,S2;)A[a++]=E[C++],A[a++]=E[C++],A[a++]=E[C++],D-=3;D&&(A[a++]=E[C++],D>1&&(A[a++]=E[C++]))}else{C=a-T;do A[a++]=A[C++],A[a++]=A[C++],A[a++]=A[C++],D-=3;while(D>2);D&&(A[a++]=A[C++],D>1&&(A[a++]=A[C++]))}}else if((S&64)===0){w=x[(w&65535)+(h&(1<>3,o-=D,b-=D<<3,h&=(1<{"use strict";var Gl=It(),$r=15,Kl=852,Xl=592,Zl=0,xa=1,Yl=2,Ah=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Rh=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Oh=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Bh=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];Jl.exports=function(e,r,n,o,i,a,s,f){var l=f.bits,c=0,u=0,d=0,p=0,h=0,b=0,F=0,x=0,m=0,y=0,w,S,D,T,C,E=null,I=0,A,R=new Gl.Buf16($r+1),z=new Gl.Buf16($r+1),M=null,X=0,te,L,ue;for(c=0;c<=$r;c++)R[c]=0;for(u=0;u=1&&R[p]===0;p--);if(h>p&&(h=p),p===0)return i[a++]=1<<24|64<<16|0,i[a++]=1<<24|64<<16|0,f.bits=1,0;for(d=1;d0&&(e===Zl||p!==1))return-1;for(z[1]=0,c=1;c<$r;c++)z[c+1]=z[c]+R[c];for(u=0;uKl||e===Yl&&m>Xl)return 1;for(;;){te=c-F,s[u]A?(L=M[X+s[u]],ue=E[I+s[u]]):(L=96,ue=0),w=1<>F)+S]=te<<24|L<<16|ue|0;while(S!==0);for(w=1<>=1;if(w!==0?(y&=w-1,y+=w):y=0,u++,--R[c]===0){if(c===p)break;c=r[n+s[u]]}if(c>h&&(y&T)!==D){for(F===0&&(F=h),C+=d,b=c-F,x=1<Kl||e===Yl&&m>Xl)return 1;D=y&T,i[D]=h<<24|b<<16|C-a|0}}return y!==0&&(i[C+y]=c-F<<24|64<<16|0),f.bits=h,0}});var Bf=He(gt=>{"use strict";var nt=It(),Ca=la(),Tt=fa(),Nh=Wl(),Zn=Ql(),Mh=0,Pf=1,Df=2,_l=4,Ih=5,ci=6,Pr=0,zh=1,jh=2,lt=-2,Cf=-3,ka=-4,Lh=-5,$l=8,kf=1,ef=2,tf=3,rf=4,nf=5,of=6,af=7,sf=8,lf=9,ff=10,hi=11,Lt=12,Fa=13,cf=14,wa=15,uf=16,df=17,hf=18,pf=19,ui=20,di=21,vf=22,mf=23,gf=24,yf=25,bf=26,Sa=27,xf=28,Ff=29,be=30,Ta=31,Hh=32,Uh=852,Vh=592,qh=15,Wh=qh;function wf(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function Gh(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new nt.Buf16(320),this.work=new nt.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Tf(t){var e;return!t||!t.state?lt:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=kf,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new nt.Buf32(Uh),e.distcode=e.distdyn=new nt.Buf32(Vh),e.sane=1,e.back=-1,Pr)}function Ef(t){var e;return!t||!t.state?lt:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,Tf(t))}function Af(t,e){var r,n;return!t||!t.state||(n=t.state,e<0?(r=0,e=-e):(r=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?lt:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Ef(t))}function Rf(t,e){var r,n;return t?(n=new Gh,t.state=n,n.window=null,r=Af(t,e),r!==Pr&&(t.state=null),r):lt}function Kh(t){return Rf(t,Wh)}var Sf=!0,Pa,Da;function Xh(t){if(Sf){var e;for(Pa=new nt.Buf32(512),Da=new nt.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Zn(Pf,t.lens,0,288,Pa,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Zn(Df,t.lens,0,32,Da,0,t.work,{bits:5}),Sf=!1}t.lencode=Pa,t.lenbits=9,t.distcode=Da,t.distbits=5}function Of(t,e,r,n){var o,i=t.state;return i.window===null&&(i.wsize=1<=i.wsize?(nt.arraySet(i.window,e,r-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):(o=i.wsize-i.wnext,o>n&&(o=n),nt.arraySet(i.window,e,r-n,o,i.wnext),n-=o,n?(nt.arraySet(i.window,e,r-n,n,0),i.wnext=n,i.whave=i.wsize):(i.wnext+=o,i.wnext===i.wsize&&(i.wnext=0),i.whave>>8&255,r.check=Tt(r.check,E,2,0),l=0,c=0,r.mode=ef;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",r.mode=be;break}if((l&15)!==$l){t.msg="unknown compression method",r.mode=be;break}if(l>>>=4,c-=4,T=(l&15)+8,r.wbits===0)r.wbits=T;else if(T>r.wbits){t.msg="invalid window size",r.mode=be;break}r.dmax=1<>8&1),r.flags&512&&(E[0]=l&255,E[1]=l>>>8&255,r.check=Tt(r.check,E,2,0)),l=0,c=0,r.mode=tf;case tf:for(;c<32;){if(s===0)break e;s--,l+=n[i++]<>>8&255,E[2]=l>>>16&255,E[3]=l>>>24&255,r.check=Tt(r.check,E,4,0)),l=0,c=0,r.mode=rf;case rf:for(;c<16;){if(s===0)break e;s--,l+=n[i++]<>8),r.flags&512&&(E[0]=l&255,E[1]=l>>>8&255,r.check=Tt(r.check,E,2,0)),l=0,c=0,r.mode=nf;case nf:if(r.flags&1024){for(;c<16;){if(s===0)break e;s--,l+=n[i++]<>>8&255,r.check=Tt(r.check,E,2,0)),l=0,c=0}else r.head&&(r.head.extra=null);r.mode=of;case of:if(r.flags&1024&&(p=r.length,p>s&&(p=s),p&&(r.head&&(T=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),nt.arraySet(r.head.extra,n,i,p,T)),r.flags&512&&(r.check=Tt(r.check,n,p,i)),s-=p,i+=p,r.length-=p),r.length))break e;r.length=0,r.mode=af;case af:if(r.flags&2048){if(s===0)break e;p=0;do T=n[i+p++],r.head&&T&&r.length<65536&&(r.head.name+=String.fromCharCode(T));while(T&&p>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Lt;break;case ff:for(;c<32;){if(s===0)break e;s--,l+=n[i++]<>>=c&7,c-=c&7,r.mode=Sa;break}for(;c<3;){if(s===0)break e;s--,l+=n[i++]<>>=1,c-=1,l&3){case 0:r.mode=cf;break;case 1:if(Xh(r),r.mode=ui,e===ci){l>>>=2,c-=2;break e}break;case 2:r.mode=df;break;case 3:t.msg="invalid block type",r.mode=be}l>>>=2,c-=2;break;case cf:for(l>>>=c&7,c-=c&7;c<32;){if(s===0)break e;s--,l+=n[i++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=be;break}if(r.length=l&65535,l=0,c=0,r.mode=wa,e===ci)break e;case wa:r.mode=uf;case uf:if(p=r.length,p){if(p>s&&(p=s),p>f&&(p=f),p===0)break e;nt.arraySet(o,n,i,p,a),s-=p,i+=p,f-=p,a+=p,r.length-=p;break}r.mode=Lt;break;case df:for(;c<14;){if(s===0)break e;s--,l+=n[i++]<>>=5,c-=5,r.ndist=(l&31)+1,l>>>=5,c-=5,r.ncode=(l&15)+4,l>>>=4,c-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=be;break}r.have=0,r.mode=hf;case hf:for(;r.have>>=3,c-=3}for(;r.have<19;)r.lens[R[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,I={bits:r.lenbits},C=Zn(Mh,r.lens,0,19,r.lencode,0,r.work,I),r.lenbits=I.bits,C){t.msg="invalid code lengths set",r.mode=be;break}r.have=0,r.mode=pf;case pf:for(;r.have>>24,m=F>>>16&255,y=F&65535,!(x<=c);){if(s===0)break e;s--,l+=n[i++]<>>=x,c-=x,r.lens[r.have++]=y;else{if(y===16){for(A=x+2;c>>=x,c-=x,r.have===0){t.msg="invalid bit length repeat",r.mode=be;break}T=r.lens[r.have-1],p=3+(l&3),l>>>=2,c-=2}else if(y===17){for(A=x+3;c>>=x,c-=x,T=0,p=3+(l&7),l>>>=3,c-=3}else{for(A=x+7;c>>=x,c-=x,T=0,p=11+(l&127),l>>>=7,c-=7}if(r.have+p>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=be;break}for(;p--;)r.lens[r.have++]=T}}if(r.mode===be)break;if(r.lens[256]===0){t.msg="invalid code -- missing end-of-block",r.mode=be;break}if(r.lenbits=9,I={bits:r.lenbits},C=Zn(Pf,r.lens,0,r.nlen,r.lencode,0,r.work,I),r.lenbits=I.bits,C){t.msg="invalid literal/lengths set",r.mode=be;break}if(r.distbits=6,r.distcode=r.distdyn,I={bits:r.distbits},C=Zn(Df,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,I),r.distbits=I.bits,C){t.msg="invalid distances set",r.mode=be;break}if(r.mode=ui,e===ci)break e;case ui:r.mode=di;case di:if(s>=6&&f>=258){t.next_out=a,t.avail_out=f,t.next_in=i,t.avail_in=s,r.hold=l,r.bits=c,Nh(t,d),a=t.next_out,o=t.output,f=t.avail_out,i=t.next_in,n=t.input,s=t.avail_in,l=r.hold,c=r.bits,r.mode===Lt&&(r.back=-1);break}for(r.back=0;F=r.lencode[l&(1<>>24,m=F>>>16&255,y=F&65535,!(x<=c);){if(s===0)break e;s--,l+=n[i++]<>w)],x=F>>>24,m=F>>>16&255,y=F&65535,!(w+x<=c);){if(s===0)break e;s--,l+=n[i++]<>>=w,c-=w,r.back+=w}if(l>>>=x,c-=x,r.back+=x,r.length=y,m===0){r.mode=bf;break}if(m&32){r.back=-1,r.mode=Lt;break}if(m&64){t.msg="invalid literal/length code",r.mode=be;break}r.extra=m&15,r.mode=vf;case vf:if(r.extra){for(A=r.extra;c>>=r.extra,c-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=mf;case mf:for(;F=r.distcode[l&(1<>>24,m=F>>>16&255,y=F&65535,!(x<=c);){if(s===0)break e;s--,l+=n[i++]<>w)],x=F>>>24,m=F>>>16&255,y=F&65535,!(w+x<=c);){if(s===0)break e;s--,l+=n[i++]<>>=w,c-=w,r.back+=w}if(l>>>=x,c-=x,r.back+=x,m&64){t.msg="invalid distance code",r.mode=be;break}r.offset=y,r.extra=m&15,r.mode=gf;case gf:if(r.extra){for(A=r.extra;c>>=r.extra,c-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=be;break}r.mode=yf;case yf:if(f===0)break e;if(p=d-f,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=be;break}p>r.wnext?(p-=r.wnext,h=r.wsize-p):h=r.wnext-p,p>r.length&&(p=r.length),b=r.window}else b=o,h=a-r.offset,p=r.length;p>f&&(p=f),f-=p,r.length-=p;do o[a++]=b[h++];while(--p);r.length===0&&(r.mode=di);break;case bf:if(f===0)break e;o[a++]=r.length,f--,r.mode=di;break;case Sa:if(r.wrap){for(;c<32;){if(s===0)break e;s--,l|=n[i++]<{"use strict";Nf.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var If=He((sg,Mf)=>{"use strict";function _h(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}Mf.exports=_h});var jf=He(Jn=>{"use strict";var en=Bf(),Yn=It(),pi=pa(),ke=Ea(),Aa=ti(),$h=va(),ep=If(),zf=Object.prototype.toString;function Dr(t){if(!(this instanceof Dr))return new Dr(t);this.options=Yn.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(t&&t.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $h,this.strm.avail_out=0;var r=en.inflateInit2(this.strm,e.windowBits);if(r!==ke.Z_OK)throw new Error(Aa[r]);if(this.header=new ep,en.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=pi.string2buf(e.dictionary):zf.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=en.inflateSetDictionary(this.strm,e.dictionary),r!==ke.Z_OK)))throw new Error(Aa[r])}Dr.prototype.push=function(t,e){var r=this.strm,n=this.options.chunkSize,o=this.options.dictionary,i,a,s,f,l,c=!1;if(this.ended)return!1;a=e===~~e?e:e===!0?ke.Z_FINISH:ke.Z_NO_FLUSH,typeof t=="string"?r.input=pi.binstring2buf(t):zf.call(t)==="[object ArrayBuffer]"?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new Yn.Buf8(n),r.next_out=0,r.avail_out=n),i=en.inflate(r,ke.Z_NO_FLUSH),i===ke.Z_NEED_DICT&&o&&(i=en.inflateSetDictionary(this.strm,o)),i===ke.Z_BUF_ERROR&&c===!0&&(i=ke.Z_OK,c=!1),i!==ke.Z_STREAM_END&&i!==ke.Z_OK)return this.onEnd(i),this.ended=!0,!1;r.next_out&&(r.avail_out===0||i===ke.Z_STREAM_END||r.avail_in===0&&(a===ke.Z_FINISH||a===ke.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=pi.utf8border(r.output,r.next_out),f=r.next_out-s,l=pi.buf2string(r.output,s),r.next_out=f,r.avail_out=n-f,f&&Yn.arraySet(r.output,r.output,s,f,0),this.onData(l)):this.onData(Yn.shrinkBuf(r.output,r.next_out))),r.avail_in===0&&r.avail_out===0&&(c=!0)}while((r.avail_in>0||r.avail_out===0)&&i!==ke.Z_STREAM_END);return i===ke.Z_STREAM_END&&(a=ke.Z_FINISH),a===ke.Z_FINISH?(i=en.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===ke.Z_OK):(a===ke.Z_SYNC_FLUSH&&(this.onEnd(ke.Z_OK),r.avail_out=0),!0)};Dr.prototype.onData=function(t){this.chunks.push(t)};Dr.prototype.onEnd=function(t){t===ke.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Yn.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function Ra(t,e){var r=new Dr(e);if(r.push(t,!0),r.err)throw r.msg||Aa[r.err];return r.result}function tp(t,e){return e=e||{},e.raw=!0,Ra(t,e)}Jn.Inflate=Dr;Jn.inflate=Ra;Jn.inflateRaw=tp;Jn.ungzip=Ra});var Qn=He((fg,Hf)=>{"use strict";var rp=It().assign,np=Vl(),op=jf(),ip=Ea(),Lf={};rp(Lf,np,op,ip);Hf.exports=Lf});var Nm={};id(Nm,{default:()=>Wi});module.exports=ad(Nm);var N=require("obsidian");var Xi=function(t,e){return Xi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)n.hasOwnProperty(o)&&(r[o]=n[o])},Xi(t,e)};function k(t,e){Xi(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Y=function(){return Y=Object.assign||function(e){for(var r,n=1,o=arguments.length;n0&&i[i.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!i||l[1]>i[0]&&l[1]>2],e+=Vr[(t[n]&3)<<4|t[n+1]>>4],e+=Vr[(t[n+1]&15)<<2|t[n+2]>>6],e+=Vr[t[n+2]&63];return r%3===2?e=e.substring(0,e.length-1)+"=":r%3===1&&(e=e.substring(0,e.length-2)+"=="),e},As=function(t){var e=t.length*.75,r=t.length,n,o=0,i,a,s,f;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);var l=new Uint8Array(e);for(n=0;n>4,l[o++]=(a&15)<<4|s>>2,l[o++]=(s&3)<<6|f&63;return l},sd=/^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i,Os=function(t){var e=t.trim(),r=e.substring(0,100),n=r.match(sd);if(!n)return As(e);var o=n[0],i=e.substring(o.length);return As(i)};var Q=function(t){return t.charCodeAt(0)},Bs=function(t){return t.codePointAt(0)},Mt=function(t,e){return rt(t.toString(16),e,"0").toUpperCase()},Wt=function(t){return Mt(t,2)},tt=function(t){return String.fromCharCode(t)},Ns=function(t){return tt(parseInt(t,16))},rt=function(t,e,r){for(var n="",o=0,i=e-t.length;o=55296&&r<=56319&&t.length>o&&(n=t.charCodeAt(o),n>=56320&&n<=57343&&(i=2)),[t.slice(e,e+i),i]},Is=function(t){for(var e=[],r=0,n=t.length;rr&&l(),a+=d,s+=p}}return l(),f},ud=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,Zo=function(t){var e=t.match(ud);if(e){var r=e[1],n=e[2],o=n===void 0?"01":n,i=e[3],a=i===void 0?"01":i,s=e[4],f=s===void 0?"00":s,l=e[5],c=l===void 0?"00":l,u=e[6],d=u===void 0?"00":u,p=e[7],h=p===void 0?"Z":p,b=e[8],F=b===void 0?"00":b,x=e[9],m=x===void 0?"00":x,y=h==="Z"?"Z":""+h+F+":"+m,w=new Date(r+"-"+o+"-"+a+"T"+f+":"+c+":"+d+y);return w}},On=function(t,e){for(var r,n=0,o;n=0&&t<=65535},Js=function(t){return t>=65536&&t<=1114111},Ji=function(t){return Math.floor((t-65536)/1024)+55296},Qi=function(t){return(t-65536)%1024+56320},Gt;(function(t){t.BigEndian="BigEndian",t.LittleEndian="LittleEndian"})(Gt||(Gt={}));var Bn="\uFFFD".codePointAt(0),Qo=function(t,e){if(e===void 0&&(e=!0),t.length<=1)return String.fromCodePoint(Bn);for(var r=e?hd(t):Gt.BigEndian,n=e?2:0,o=[];t.length-n>=2;){var i=Xs(t[n++],t[n++],r);if(dd(i))if(t.length-n<2)o.push(Bn);else{var a=Xs(t[n++],t[n++],r);Ks(a)?o.push(i,a):o.push(Bn)}else Ks(i)?(n+=2,o.push(Bn)):o.push(i)}return n=55296&&t<=56319},Ks=function(t){return t>=56320&&t<=57343},Xs=function(t,e,r){if(r===Gt.LittleEndian)return e<<8|t;if(r===Gt.BigEndian)return t<<8|e;throw new Error("Invalid byteOrder: "+r)},hd=function(t){return Qs(t)?Gt.BigEndian:_s(t)?Gt.LittleEndian:Gt.BigEndian},Qs=function(t){return t[0]===254&&t[1]===255},_s=function(t){return t[0]===255&&t[1]===254},_o=function(t){return Qs(t)||_s(t)};var $s=function(t){var e=String(t);if(Math.abs(t)<1){var r=parseInt(t.toString().split("e-")[1]);if(r){var n=t<0;n&&(t*=-1),t*=Math.pow(10,r-1),e="0."+new Array(r).join("0")+t.toString().substring(2),n&&(e="-"+e)}}else{var r=parseInt(t.toString().split("+")[1]);r>20&&(r-=20,t/=Math.pow(10,r),e=t.toString()+new Array(r+1).join("0"))}return e},Nn=function(t){return Math.ceil(t.toString(2).length/8)},mr=function(t){for(var e=new Uint8Array(Nn(t)),r=1;r<=e.length;r++)e[r-1]=t>>(e.length-r)*8;return e};var gr=function(t){throw new Error(t)};var Vf=Ko(Qn()),Uf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$n=new Uint8Array(256);for(_n=0;_n>4,l[o++]=(a&15)<<4|s>>2,l[o++]=(s&3)<<6|f&63;return l},sp=function(t){for(var e="",r=0;rn)throw new Error(Me(e)+" must be at least "+r+" and at most "+n+", but was actually "+t)},ot=function(t,e,r,n){P(t,e,["number","undefined"]),typeof t=="number"&&Ue(t,e,r,n)},gi=function(t,e,r){if(P(t,e,["number"]),t%r!==0)throw new Error(Me(e)+" must be a multiple of "+r+", but was actually "+t)},fc=function(t,e){if(!Number.isInteger(t))throw new Error(Me(e)+" must be an integer, but was actually "+t)},_t=function(t,e){if(![1,0].includes(Math.sign(t)))throw new Error(Me(e)+" must be a positive number or 0, but was actually "+t)};var $=new Uint16Array(256);for(no=0;no<256;no++)$[no]=no;var no;$[22]=Q("");$[24]=Q("\u02D8");$[25]=Q("\u02C7");$[26]=Q("\u02C6");$[27]=Q("\u02D9");$[28]=Q("\u02DD");$[29]=Q("\u02DB");$[30]=Q("\u02DA");$[31]=Q("\u02DC");$[127]=Q("\uFFFD");$[128]=Q("\u2022");$[129]=Q("\u2020");$[130]=Q("\u2021");$[131]=Q("\u2026");$[132]=Q("\u2014");$[133]=Q("\u2013");$[134]=Q("\u0192");$[135]=Q("\u2044");$[136]=Q("\u2039");$[137]=Q("\u203A");$[138]=Q("\u2212");$[139]=Q("\u2030");$[140]=Q("\u201E");$[141]=Q("\u201C");$[142]=Q("\u201D");$[143]=Q("\u2018");$[144]=Q("\u2019");$[145]=Q("\u201A");$[146]=Q("\u2122");$[147]=Q("\uFB01");$[148]=Q("\uFB02");$[149]=Q("\u0141");$[150]=Q("\u0152");$[151]=Q("\u0160");$[152]=Q("\u0178");$[153]=Q("\u017D");$[154]=Q("\u0131");$[155]=Q("\u0142");$[156]=Q("\u0153");$[157]=Q("\u0161");$[158]=Q("\u017E");$[159]=Q("\uFFFD");$[160]=Q("\u20AC");$[173]=Q("\uFFFD");var yi=function(t){for(var e=new Array(t.length),r=0,n=t.length;r=g.ExclamationPoint&&t<=g.Tilde&&!xi[t]},kc={},Tc=new Map,Lp=function(t){k(e,t);function e(r,n){var o=this;if(r!==kc)throw new tn("PDFName");o=t.call(this)||this;for(var i="/",a=0,s=n.length;a=g.Zero&&l<=g.Nine||l>=g.a&&l<=g.f||l>=g.A&&l<=g.F?(n+=f,(n.length===2||!(c>="0"&&c<="9"||c>="a"&&c<="f"||c>="A"&&c<="F"))&&(i(parseInt(n,16)),n="")):i(l):l===g.Hash?o=!0:i(l)}return new Uint8Array(r)},e.prototype.decodeText=function(){var r=this.asBytes();return String.fromCharCode.apply(String,Array.from(r))},e.prototype.asString=function(){return this.encodedName},e.prototype.value=function(){return this.encodedName},e.prototype.clone=function(){return this},e.prototype.toString=function(){return this.encodedName},e.prototype.sizeInBytes=function(){return this.encodedName.length},e.prototype.copyBytesInto=function(r,n){return n+=me(this.encodedName,r,n),this.encodedName.length},e.of=function(r){var n=zp(r),o=Tc.get(n);return o||(o=new e(kc,n),Tc.set(n,o)),o},e.Length=e.of("Length"),e.FlateDecode=e.of("FlateDecode"),e.Resources=e.of("Resources"),e.Font=e.of("Font"),e.XObject=e.of("XObject"),e.ExtGState=e.of("ExtGState"),e.Contents=e.of("Contents"),e.Type=e.of("Type"),e.Parent=e.of("Parent"),e.MediaBox=e.of("MediaBox"),e.Page=e.of("Page"),e.Annots=e.of("Annots"),e.TrimBox=e.of("TrimBox"),e.ArtBox=e.of("ArtBox"),e.BleedBox=e.of("BleedBox"),e.CropBox=e.of("CropBox"),e.Rotate=e.of("Rotate"),e.Title=e.of("Title"),e.Author=e.of("Author"),e.Subject=e.of("Subject"),e.Creator=e.of("Creator"),e.Keywords=e.of("Keywords"),e.Producer=e.of("Producer"),e.CreationDate=e.of("CreationDate"),e.ModDate=e.of("ModDate"),e}(ve),v=Lp;var Hp=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.asNull=function(){return null},e.prototype.clone=function(){return this},e.prototype.toString=function(){return"null"},e.prototype.sizeInBytes=function(){return 4},e.prototype.copyBytesInto=function(r,n){return r[n++]=g.n,r[n++]=g.u,r[n++]=g.l,r[n++]=g.l,4},e}(ve),Te=new Hp;var Up=function(t){k(e,t);function e(r,n){var o=t.call(this)||this;return o.dict=r,o.context=n,o}return e.prototype.keys=function(){return Array.from(this.dict.keys())},e.prototype.values=function(){return Array.from(this.dict.values())},e.prototype.entries=function(){return Array.from(this.dict.entries())},e.prototype.set=function(r,n){this.dict.set(r,n)},e.prototype.get=function(r,n){n===void 0&&(n=!1);var o=this.dict.get(r);if(!(o===Te&&!n))return o},e.prototype.has=function(r){var n=this.dict.get(r);return n!==void 0&&n!==Te},e.prototype.lookupMaybe=function(r){for(var n,o=[],i=1;ithis.largestObjectNumber&&(this.largestObjectNumber=e.objectNumber)},t.prototype.nextRef=function(){return this.largestObjectNumber+=1,J.of(this.largestObjectNumber)},t.prototype.register=function(e){var r=this.nextRef();return this.assign(r,e),r},t.prototype.delete=function(e){return this.indirectObjects.delete(e)},t.prototype.lookupMaybe=function(e){for(var r=[],n=1;nthis.largestObjectNumber&&(this.largestObjectNumber=e.objectNumber)},t.prototype.nextRef=function(){return this.largestObjectNumber+=1,J.of(this.largestObjectNumber)},t.prototype.register=function(e){var r=this.nextRef();return this.assign(r,e),r},t.prototype.delete=function(e){return this.indirectObjects.delete(e)},t.prototype.lookupMaybe=function(e){for(var r=[],n=1;n1?(this.subsections.push([e]),this.chunkIdx+=1,this.chunkLength=1):(r.push(e),this.chunkLength+=1)},t.create=function(){return new t({ref:J.of(0,65535),offset:0,deleted:!0})},t.createEmpty=function(){return new t},t}(),oo=Qp;var _p=function(){function t(e){this.lastXRefOffset=String(e)}return t.prototype.toString=function(){return`startxref +`}}return e},t.prototype.sizeInBytes=function(){for(var e=5,r=0,n=this.subsections.length;r1?(this.subsections.push([e]),this.chunkIdx+=1,this.chunkLength=1):(r.push(e),this.chunkLength+=1)},t.create=function(){return new t({ref:J.of(0,65535),offset:0,deleted:!0})},t.createEmpty=function(){return new t},t}(),oo=_p;var $p=function(){function t(e){this.lastXRefOffset=String(e)}return t.prototype.toString=function(){return`startxref `+this.lastXRefOffset+` -%%EOF`},t.prototype.sizeInBytes=function(){return 16+this.lastXRefOffset.length},t.prototype.copyBytesInto=function(e,r){var n=r;return e[r++]=g.s,e[r++]=g.t,e[r++]=g.a,e[r++]=g.r,e[r++]=g.t,e[r++]=g.x,e[r++]=g.r,e[r++]=g.e,e[r++]=g.f,e[r++]=g.Newline,r+=me(this.lastXRefOffset,e,r),e[r++]=g.Newline,e[r++]=g.Percent,e[r++]=g.Percent,e[r++]=g.E,e[r++]=g.O,e[r++]=g.F,r-n},t.forLastCrossRefSectionOffset=function(e){return new t(e)},t}(),Er=_p;var $p=function(){function t(e){this.dict=e}return t.prototype.toString=function(){return`trailer -`+this.dict.toString()},t.prototype.sizeInBytes=function(){return 8+this.dict.sizeInBytes()},t.prototype.copyBytesInto=function(e,r){var n=r;return e[r++]=g.t,e[r++]=g.r,e[r++]=g.a,e[r++]=g.i,e[r++]=g.l,e[r++]=g.e,e[r++]=g.r,e[r++]=g.Newline,r+=this.dict.copyBytesInto(e,r),r-n},t.of=function(e){return new t(e)},t}(),Ha=$p;var e0=function(t){k(e,t);function e(r,n,o){o===void 0&&(o=!0);var i=t.call(this,r.obj({}),o)||this;return i.objects=n,i.offsets=i.computeObjectOffsets(),i.offsetsString=i.computeOffsetsString(),i.dict.set(v.of("Type"),v.of("ObjStm")),i.dict.set(v.of("N"),j.of(i.objects.length)),i.dict.set(v.of("First"),j.of(i.offsetsString.length)),i}return e.prototype.getObjectsCount=function(){return this.objects.length},e.prototype.clone=function(r){return e.withContextAndObjects(r||this.dict.context,this.objects.slice(),this.encode)},e.prototype.getContentsString=function(){for(var r=this.offsetsString,n=0,o=this.objects.length;n1&&(a.push(s),a.push(c.ref.objectNumber),s=0),s+=1}return a.push(s),a},i.computeEntryTuples=function(){for(var a=new Array(i.entries.length),s=0,f=i.entries.length;ss[0]&&(s[0]=h),b>s[1]&&(s[1]=b),F>s[2]&&(s[2]=F)}return s},i.entries=n||[],i.entryTuplesCache=Ve.populatedBy(i.computeEntryTuples),i.maxByteWidthsCache=Ve.populatedBy(i.computeMaxEntryByteWidths),i.indexCache=Ve.populatedBy(i.computeIndex),r.set(v.of("Type"),v.of("XRef")),i}return e.prototype.addDeletedEntry=function(r,n){var o=er.Deleted;this.entries.push({type:o,ref:r,nextFreeObjectNumber:n}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},e.prototype.addUncompressedEntry=function(r,n){var o=er.Uncompressed;this.entries.push({type:o,ref:r,offset:n}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},e.prototype.addCompressedEntry=function(r,n,o){var i=er.Compressed;this.entries.push({type:i,ref:r,objectStreamRef:n,index:o}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},e.prototype.clone=function(r){var n=this,o=n.dict,i=n.entries,a=n.encode;return e.of(o.clone(r),i.slice(),a)},e.prototype.getContentsString=function(){for(var r=this.entryTuplesCache.access(),n=this.maxByteWidthsCache.access(),o="",i=0,a=r.length;i=0;h--)o+=(u[h]||0).toString(2);for(var h=n[1]-1;h>=0;h--)o+=(d[h]||0).toString(2);for(var h=n[2]-1;h>=0;h--)o+=(p[h]||0).toString(2)}return o},e.prototype.getUnencodedContents=function(){for(var r=this.entryTuplesCache.access(),n=this.maxByteWidthsCache.access(),o=new Uint8Array(this.getUnencodedContentsSize()),i=0,a=0,s=r.length;a=0;b--)o[i++]=d[b]||0;for(var b=n[1]-1;b>=0;b--)o[i++]=p[b]||0;for(var b=n[2]-1;b>=0;b--)o[i++]=h[b]||0}return o},e.prototype.getUnencodedContentsSize=function(){var r=this.maxByteWidthsCache.access(),n=Hs(r);return n*this.entries.length},e.prototype.updateDict=function(){t.prototype.updateDict.call(this);var r=this.maxByteWidthsCache.access(),n=this.indexCache.access(),o=this.dict.context;this.dict.set(v.of("W"),o.obj(r)),this.dict.set(v.of("Index"),o.obj(n))},e.create=function(r,n){n===void 0&&(n=!0);var o=new e(r,[],n);return o.addDeletedEntry(J.of(0,65535),0),o},e.of=function(r,n,o){return o===void 0&&(o=!0),new e(r,n,o)},e}(Tr),Ua=n0;var o0=function(t){k(e,t);function e(r,n,o,i){var a=t.call(this,r,n)||this;return a.encodeStreams=o,a.objectsPerStream=i,a}return e.prototype.computeBufferSize=function(){return V(this,void 0,void 0,function(){var r,n,o,i,a,s,f,l,h,b,c,x,u,d,F,p,h,b,F,x,m,y,w,S;return q(this,function(D){switch(D.label){case 0:r=this.context.largestObjectNumber+1,n=Ht.forVersion(1,7),o=n.sizeInBytes()+2,i=Ua.create(this.createTrailerDict(),this.encodeStreams),a=[],s=[],f=[],l=this.context.enumerateIndirectObjects(),h=0,b=l.length,D.label=1;case 1:return h"},e.prototype.sizeInBytes=function(){return this.value.length+2},e.prototype.copyBytesInto=function(r,n){return r[n++]=g.LessThan,n+=me(this.value,r,n),r[n++]=g.GreaterThan,this.value.length+2},e.of=function(r){return new e(r)},e.fromText=function(r){for(var n=Ks(r),o="",i=0,a=n.length;i1&&(a.push(s),a.push(c.ref.objectNumber),s=0),s+=1}return a.push(s),a},i.computeEntryTuples=function(){for(var a=new Array(i.entries.length),s=0,f=i.entries.length;ss[0]&&(s[0]=h),b>s[1]&&(s[1]=b),F>s[2]&&(s[2]=F)}return s},i.entries=n||[],i.entryTuplesCache=Ve.populatedBy(i.computeEntryTuples),i.maxByteWidthsCache=Ve.populatedBy(i.computeMaxEntryByteWidths),i.indexCache=Ve.populatedBy(i.computeIndex),r.set(v.of("Type"),v.of("XRef")),i}return e.prototype.addDeletedEntry=function(r,n){var o=er.Deleted;this.entries.push({type:o,ref:r,nextFreeObjectNumber:n}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},e.prototype.addUncompressedEntry=function(r,n){var o=er.Uncompressed;this.entries.push({type:o,ref:r,offset:n}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},e.prototype.addCompressedEntry=function(r,n,o){var i=er.Compressed;this.entries.push({type:i,ref:r,objectStreamRef:n,index:o}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},e.prototype.clone=function(r){var n=this,o=n.dict,i=n.entries,a=n.encode;return e.of(o.clone(r),i.slice(),a)},e.prototype.getContentsString=function(){for(var r=this.entryTuplesCache.access(),n=this.maxByteWidthsCache.access(),o="",i=0,a=r.length;i=0;h--)o+=(u[h]||0).toString(2);for(var h=n[1]-1;h>=0;h--)o+=(d[h]||0).toString(2);for(var h=n[2]-1;h>=0;h--)o+=(p[h]||0).toString(2)}return o},e.prototype.getUnencodedContents=function(){for(var r=this.entryTuplesCache.access(),n=this.maxByteWidthsCache.access(),o=new Uint8Array(this.getUnencodedContentsSize()),i=0,a=0,s=r.length;a=0;b--)o[i++]=d[b]||0;for(var b=n[1]-1;b>=0;b--)o[i++]=p[b]||0;for(var b=n[2]-1;b>=0;b--)o[i++]=h[b]||0}return o},e.prototype.getUnencodedContentsSize=function(){var r=this.maxByteWidthsCache.access(),n=Vs(r);return n*this.entries.length},e.prototype.updateDict=function(){t.prototype.updateDict.call(this);var r=this.maxByteWidthsCache.access(),n=this.indexCache.access(),o=this.dict.context;this.dict.set(v.of("W"),o.obj(r)),this.dict.set(v.of("Index"),o.obj(n))},e.create=function(r,n){n===void 0&&(n=!0);var o=new e(r,[],n);return o.addDeletedEntry(J.of(0,65535),0),o},e.of=function(r,n,o){return o===void 0&&(o=!0),new e(r,n,o)},e}(Tr),Va=o0;var i0=function(t){k(e,t);function e(r,n,o,i){var a=t.call(this,r,n)||this;return a.encodeStreams=o,a.objectsPerStream=i,a}return e.prototype.computeBufferSize=function(){return V(this,void 0,void 0,function(){var r,n,o,i,a,s,f,l,h,b,c,x,u,d,F,p,h,b,F,x,m,y,w,S;return q(this,function(D){switch(D.label){case 0:r=this.context.largestObjectNumber+1,n=Ht.forVersion(1,7),o=n.sizeInBytes()+2,i=Va.create(this.createTrailerDict(),this.encodeStreams),a=[],s=[],f=[],l=this.context.enumerateIndirectObjects(),h=0,b=l.length,D.label=1;case 1:return h"},e.prototype.sizeInBytes=function(){return this.value.length+2},e.prototype.copyBytesInto=function(r,n){return r[n++]=g.LessThan,n+=me(this.value,r,n),r[n++]=g.GreaterThan,this.value.length+2},e.of=function(r){return new e(r)},e.fromText=function(r){for(var n=Zs(r),o="",i=0,a=n.length;i"},wi=function(t){return Mt(t,4)},l0=function(t){if(Xs(t))return wi(t);if(Zs(t)){var e=Yi(t),r=Ji(t);return""+wi(e)+wi(r)}var n=Wt(t),o="0x"+n+" is not a valid UTF-8 or UTF-16 codepoint.";throw new Error(o)};var f0=function(t){var e=0,r=function(n){e|=1<=g.Zero&&l<=g.Seven?(n+=f,(n.length===3||!(c>="0"&&c<="7"))&&(i(parseInt(n,8)),n="")):i(l):l===g.BackSlash?o=!0:i(l)}return new Uint8Array(r)},e.prototype.decodeText=function(){var r=this.asBytes();return _o(r)?Qo(r):yi(r)},e.prototype.decodeDate=function(){var r=this.decodeText(),n=Zo(r);if(!n)throw new bi(r);return n},e.prototype.asString=function(){return this.value},e.prototype.clone=function(){return e.of(this.value)},e.prototype.toString=function(){return"("+this.value+")"},e.prototype.sizeInBytes=function(){return this.value.length+2},e.prototype.copyBytesInto=function(r,n){return r[n++]=g.LeftParen,n+=me(this.value,r,n),r[n++]=g.RightParen,this.value.length+2},e.of=function(r){return new e(r)},e.fromDate=function(r){var n=rt(String(r.getUTCFullYear()),4,"0"),o=rt(String(r.getUTCMonth()+1),2,"0"),i=rt(String(r.getUTCDate()),2,"0"),a=rt(String(r.getUTCHours()),2,"0"),s=rt(String(r.getUTCMinutes()),2,"0"),f=rt(String(r.getUTCSeconds()),2,"0");return new e("D:"+n+o+i+a+s+f+"Z")},e}(ve),ne=c0;var u0=function(){function t(e,r,n,o){var i=this;this.allGlyphsInFontSortedById=function(){for(var a=new Array(i.font.characterSet.length),s=0,f=a.length;s>3)]>>7-((h&7)<<0)&1,R=3*A;s[w]=S[R],s[w+1]=S[R+1],s[w+2]=S[R+2],s[w+3]=A>2)]>>6-((h&3)<<1)&3,R=3*A;s[w]=S[R],s[w+1]=S[R+1],s[w+2]=S[R+2],s[w+3]=A>1)]>>4-((h&1)<<2)&15,R=3*A;s[w]=S[R],s[w+1]=S[R+1],s[w+2]=S[R+2],s[w+3]=A>>3)]>>>7-(L&7)&1),ue=M==x*255?0:255;f[te+L]=ue<<24|M<<16|M<<8|M}else if(c==2)for(var L=0;L>>2)]>>>6-((L&3)<<1)&3),ue=M==x*85?0:255;f[te+L]=ue<<24|M<<16|M<<8|M}else if(c==4)for(var L=0;L>>1)]>>>4-((L&1)<<2)&15),ue=M==x*17?0:255;f[te+L]=ue<<24|M<<16|M<<8|M}else if(c==8)for(var L=0;L>>2<<3));o==0;){if(o=F(e,d,1),i=F(e,d+1,2),d+=3,i==0){(d&7)!=0&&(d+=8-(d&7));var C=(d>>>3)+4,E=e[C-4]|e[C-3]<<8;T&&(r=t.H.W(r,u+E)),r.set(new n(e.buffer,e.byteOffset+C,E),u),d=C+E<<3,u+=E;continue}if(T&&(r=t.H.W(r,u+(1<<17))),i==1&&(p=D.J,h=D.h,l=511,c=31),i==2){a=x(e,d,5)+257,s=x(e,d+5,5)+1,f=x(e,d+10,4)+4,d+=14;for(var I=d,A=1,R=0;R<38;R+=2)D.Q[R]=0,D.Q[R+1]=0;for(var R=0;RA&&(A=z)}d+=3*f,y(D.Q,A),w(D.Q,A,D.u),p=D.w,h=D.d,d=m(D.u,(1<>>4;if(!(L>>>8))r[u++]=L;else{if(L==256)break;var ue=u+L-254;if(L>264){var ye=D.q[L-257];ue=u+(ye>>>3)+x(e,d,ye&7),d+=ye&7}var oe=h[S(e,d)&c];d+=oe&15;var Fe=oe>>>4,Ce=D.c[Fe],Be=(Ce>>>4)+F(e,d,Ce&15);for(d+=Ce&15;u>>4;if(u<=15)a[l]=u,l++;else{var d=0,p=0;u==16?(p=3+s(o,i,2),i+=2,d=a[l-1]):u==17?(p=3+s(o,i,3),i+=3):u==18&&(p=11+s(o,i,7),i+=7);for(var h=l+p;l>>1;ai&&(i=f),a++}for(;a>1,l=e[s+1],c=f<<4|l,u=r-l,d=e[s]<>>15-r;n[h]=c,d++}},t.H.l=function(e,r){for(var n=t.H.m.r,o=15-r,i=0;i>>o}},t.H.M=function(e,r,n){n=n<<(r&7);var o=r>>>3;e[o]|=n,e[o+1]|=n>>>8},t.H.I=function(e,r,n){n=n<<(r&7);var o=r>>>3;e[o]|=n,e[o+1]|=n>>>8,e[o+2]|=n>>>16},t.H.e=function(e,r,n){return(e[r>>>3]|e[(r>>>3)+1]<<8)>>>(r&7)&(1<>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16)>>>(r&7)&(1<>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16)>>>(r&7)},t.H.i=function(e,r){return(e[r>>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16|e[(r>>>3)+3]<<24)>>>(r&7)},t.H.m=function(){var e=Uint16Array,r=Uint32Array;return{K:new e(16),j:new e(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new e(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new r(32),J:new e(512),_:[],h:new e(32),$:[],w:new e(32768),C:[],v:[],d:new e(32768),D:[],u:new e(512),Q:[],r:new e(32768),s:new r(286),Y:new r(30),a:new r(19),t:new r(15e3),k:new e(65536),g:new e(32768)}}(),function(){for(var e=t.H.m,r=32768,n=0;n>>1|(o&1431655765)<<1,o=(o&3435973836)>>>2|(o&858993459)<<2,o=(o&4042322160)>>>4|(o&252645135)<<4,o=(o&4278255360)>>>8|(o&16711935)<<8,e.r[n]=(o>>>16|o<<16)>>>17}function i(a,s,f){for(;s--!=0;)a.push(0,f)}for(var n=0;n<32;n++)e.q[n]=e.S[n]<<3|e.T[n],e.c[n]=e.p[n]<<4|e.z[n];i(e._,144,8),i(e._,112,9),i(e._,24,7),i(e._,8,8),t.H.n(e._,9),t.H.A(e._,9,e.J),t.H.l(e._,9),i(e.$,32,5),t.H.n(e.$,5),t.H.A(e.$,5,e.h),t.H.l(e.$,5),i(e.Q,19,0),i(e.C,286,0),i(e.D,30,0),i(e.v,320,0)}(),t.H.N}();B.decode._readInterlace=function(t,e){for(var r=e.width,n=e.height,o=B.decode._getBPP(e),i=o>>3,a=Math.ceil(r*o/8),s=new Uint8Array(n*a),f=0,l=[0,0,4,0,2,0,1],c=[0,4,0,2,0,1,0],u=[8,8,8,4,4,2,2],d=[8,8,4,4,2,2,1],p=0;p<7;){for(var h=u[p],b=d[p],F=0,x=0,m=l[p];m>3];E=E>>7-(C&7)&1,s[D*a+(T>>3)]|=E<<7-((T&7)<<0)}if(o==2){var E=t[C>>3];E=E>>6-(C&7)&3,s[D*a+(T>>2)]|=E<<6-((T&3)<<1)}if(o==4){var E=t[C>>3];E=E>>4-(C&7)&15,s[D*a+(T>>1)]|=E<<4-((T&1)<<2)}if(o>=8)for(var I=D*a+T*i,A=0;A>3)+A];C+=o,T+=b}S++,D+=h}F*x!=0&&(f+=x*(1+w)),p=p+1}return s};B.decode._getBPP=function(t){var e=[1,null,3,1,2,null,4][t.ctype];return e*t.depth};B.decode._filterZero=function(t,e,r,n,o){var i=B.decode._getBPP(e),a=Math.ceil(n*i/8),s=B.decode._paeth;i=Math.ceil(i/8);var f=0,l=1,c=t[r],u=0;if(c>1&&(t[r]=[0,0,1][c-2]),c==3)for(u=i;u>>1)&255;for(var d=0;d>>1);for(;u>>1)}else{for(;u>8&255,t[e+1]=r&255},readUint:function(t,e){return t[e]*(256*256*256)+(t[e+1]<<16|t[e+2]<<8|t[e+3])},writeUint:function(t,e,r){t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=r&255},readASCII:function(t,e,r){for(var n="",o=0;o=0&&s>=0?(u=p*e+h<<2,d=(s+p)*o+a+h<<2):(u=(-s+p)*e-a+h<<2,d=p*o+h<<2),f==0)n[d]=t[u],n[d+1]=t[u+1],n[d+2]=t[u+2],n[d+3]=t[u+3];else if(f==1){var b=t[u+3]*.00392156862745098,F=t[u]*b,x=t[u+1]*b,m=t[u+2]*b,y=n[d+3]*(1/255),w=n[d]*y,S=n[d+1]*y,D=n[d+2]*y,T=1-b,C=b+y*T,E=C==0?0:1/C;n[d+3]=255*C,n[d+0]=(F+w*T)*E,n[d+1]=(x+S*T)*E,n[d+2]=(m+D*T)*E}else if(f==2){var b=t[u+3],F=t[u],x=t[u+1],m=t[u+2],y=n[d+3],w=n[d],S=n[d+1],D=n[d+2];b==y&&F==w&&x==S&&m==D?(n[d]=0,n[d+1]=0,n[d+2]=0,n[d+3]=0):(n[d]=F,n[d+1]=x,n[d+2]=m,n[d+3]=b)}else if(f==3){var b=t[u+3],F=t[u],x=t[u+1],m=t[u+2],y=n[d+3],w=n[d],S=n[d+1],D=n[d+2];if(b==y&&F==w&&x==S&&m==D)continue;if(b<220&&y>20)return!1}return!0};B.encode=function(t,e,r,n,o,i,a){n==null&&(n=0),a==null&&(a=!1);var s=B.encode.compress(t,e,r,n,[!1,!1,!1,0,a]);return B.encode.compressPNG(s,-1),B.encode._main(s,e,r,o,i)};B.encodeLL=function(t,e,r,n,o,i,a,s){for(var f={ctype:0+(n==1?0:2)+(o==0?0:4),depth:i,frames:[]},l=Date.now(),c=(n+o)*i,u=c*e,d=0;d1,u=!1,d=33+(c?20:0);if(o.sRGB!=null&&(d+=13),o.pHYs!=null&&(d+=21),t.ctype==3){for(var p=t.plte.length,h=0;h>>24!=255&&(u=!0);d+=8+p*3+4+(u?8+p*1+4:0)}for(var b=0;b>>8&255,T=w>>>16&255;x[l+y+0]=S,x[l+y+1]=D,x[l+y+2]=T}if(l+=p*3,a(x,l,i(x,l-p*3-4,p*3+4)),l+=4,u){a(x,l,p),l+=4,f(x,l,"tRNS"),l+=4;for(var h=0;h>>24&255;l+=p,a(x,l,i(x,l-p-4,p+4)),l+=4}}for(var C=0,b=0;b>2,R>>2));for(var p=0;pX&&L==M[F-X])te[F]=te[F-X];else{var ue=y[L];if(ue==null&&(y[L]=ue=w.length,w.push(L),w.length>=300))break;te[F]=ue}}}var ye=w.length;ye<=256&&l==!1&&(ye<=2?u=1:ye<=4?u=2:ye<=16?u=4:u=8,u=Math.max(u,f));for(var p=0;p>1)]|=Vo[Wo+we]<<4-(we&1)*4;else if(u==2)for(var we=0;we>2)]|=Vo[Wo+we]<<6-(we&3)*2;else if(u==1)for(var we=0;we>3)]|=Vo[Wo+we]<<7-(we&7)*1}Be=wt,c=3,Wi=1}else if(x==!1&&m.length==1){for(var wt=new Uint8Array(X*Ce*3),_u=X*Ce,F=0;F<_u;F++){var A=F*3,Gi=F*4;wt[A]=Be[Gi],wt[A+1]=Be[Gi+1],wt[A+2]=Be[Gi+2]}Be=wt,c=2,Wi=3,En=3*X}z.img=Be,z.bpl=En,z.bpp=Wi}return{ctype:c,depth:u,plte:w,frames:m}};B.encode.framize=function(t,e,r,n,o,i){for(var a=[],s=0;sT&&(T=I),EC&&(C=E))}T==-1&&(S=D=T=C=0),o&&((S&1)==1&&S--,(D&1)==1&&D--);var R=(T-S+1)*(C-D+1);RF&&(F=w),Sx&&(x=S))}F==-1&&(h=b=F=x=0),a&&((h&1)==1&&h--,(b&1)==1&&b--),i={x:h,y:b,width:F-h+1,height:x-b+1};var C=n[o];C.rect=i,C.blend=1,C.img=new Uint8Array(i.width*i.height*4),n[o-1].dispose==0?(B._copyTile(l,e,r,C.img,i.width,i.height,-i.x,-i.y,0),B.encode._prepareDiff(d,e,r,C.img,i)):B._copyTile(d,e,r,C.img,i.width,i.height,-i.x,-i.y,0)};B.encode._prepareDiff=function(t,e,r,n,o){B._copyTile(t,e,r,n,o.width,o.height,-o.x,-o.y,2)};B.encode._filterZero=function(t,e,r,n,o,i,a){var s=[],f=[0,1,2,3,4];i!=-1?f=[i]:(e*n>5e5||r==1)&&(f=[0]);var l;a&&(l={level:0});for(var c=a&&UZIP!=null?UZIP:Ic.default,u=0;u>1)+256&255;if(i==4)for(var l=o;l>1)&255;for(var l=o;l>1)&255}if(i==4){for(var l=0;l>>1:r=r>>>1;t[e]=r}return t}(),update:function(t,e,r,n){for(var o=0;o>>8;return t},crc:function(t,e,r){return B.crc.update(4294967295,t,e,r)^4294967295}};B.quantize=function(t,e){for(var r=new Uint8Array(t),n=r.slice(0),o=new Uint32Array(n.buffer),i=B.quantize.getKDtree(n,e),a=i[0],s=i[1],f=B.quantize.planeDst,l=r,c=o,u=l.length,d=new Uint8Array(r.length>>2),p=0;p>2]=m.ind,c[p>>2]=m.est.rgba}return{abuf:n.buffer,inds:d,plte:s}};B.quantize.getKDtree=function(t,e,r){r==null&&(r=1e-4);var n=new Uint32Array(t.buffer),o={i0:0,i1:t.length,bst:null,est:null,tdst:0,left:null,right:null};o.bst=B.quantize.stats(t,o.i0,o.i1),o.est=B.quantize.estats(o.bst);for(var i=[o];i.lengtha&&(a=i[f].est.L,s=f);if(a=c||l.i1<=c;if(u){l.est.L=0;continue}var d={i0:l.i0,i1:c,bst:null,est:null,tdst:0,left:null,right:null};d.bst=B.quantize.stats(t,d.i0,d.i1),d.est=B.quantize.estats(d.bst);var p={i0:c,i1:l.i1,bst:null,est:null,tdst:0,left:null,right:null};p.bst={R:[],m:[],N:l.bst.N-d.bst.N};for(var f=0;f<16;f++)p.bst.R[f]=l.bst.R[f]-d.bst.R[f];for(var f=0;f<4;f++)p.bst.m[f]=l.bst.m[f]-d.bst.m[f];p.est=B.quantize.estats(p.bst),l.left=d,l.right=p,i[s]=d,i.push(p)}i.sort(function(h,b){return b.bst.N-h.bst.N});for(var f=0;f0&&(a=t.right,s=t.left);var f=B.quantize.getNearest(a,e,r,n,o);if(f.tdst<=i*i)return f;var l=B.quantize.getNearest(s,e,r,n,o);return l.tdsti;)n-=4;if(r>=n)break;var f=e[r>>2];e[r>>2]=e[n>>2],e[n>>2]=f,r+=4,n-=4}for(;a(t,r,o)>i;)r-=4;return r+4};B.quantize.vecDot=function(t,e,r){return t[e]*r[0]+t[e+1]*r[1]+t[e+2]*r[2]+t[e+3]*r[3]};B.quantize.stats=function(t,e,r){for(var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o=[0,0,0,0],i=r-e>>2,a=e;a>>0}};B.M4={multVec:function(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3],t[4]*e[0]+t[5]*e[1]+t[6]*e[2]+t[7]*e[3],t[8]*e[0]+t[9]*e[1]+t[10]*e[2]+t[11]*e[3],t[12]*e[0]+t[13]*e[1]+t[14]*e[2]+t[15]*e[3]]},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},sml:function(t,e){return[t*e[0],t*e[1],t*e[2],t*e[3]]}};B.encode.concatRGBA=function(t){for(var e=0,r=0;r1)throw new Error("Animated PNGs are not supported");var o=new Uint8Array(n[0]),i=g0(o),a=i.rgbChannel,s=i.alphaChannel;this.rgbChannel=a;var f=s.some(function(l){return l<255});f&&(this.alphaChannel=s),this.type=m0(r.ctype),this.width=r.width,this.height=r.height,this.bitsPerComponent=8}return t.load=function(e){return new t(e)},t}();var y0=function(){function t(e){this.image=e,this.bitsPerComponent=e.bitsPerComponent,this.width=e.width,this.height=e.height,this.colorSpace="DeviceRGB"}return t.for=function(e){return V(this,void 0,void 0,function(){var r;return q(this,function(n){return r=zc.load(e),[2,new t(r)]})})},t.prototype.embedIntoContext=function(e,r){return V(this,void 0,void 0,function(){var n,o;return q(this,function(i){return n=this.embedAlphaChannel(e),o=e.flateStream(this.image.rgbChannel,{Type:"XObject",Subtype:"Image",BitsPerComponent:this.image.bitsPerComponent,Width:this.image.width,Height:this.image.height,ColorSpace:this.colorSpace,SMask:n}),r?(e.assign(r,o),[2,r]):[2,e.register(o)]})})},t.prototype.embedAlphaChannel=function(e){if(this.image.alphaChannel){var r=e.flateStream(this.image.alphaChannel,{Type:"XObject",Subtype:"Image",Height:this.image.height,Width:this.image.width,BitsPerComponent:this.image.bitsPerComponent,ColorSpace:"DeviceGray",Decode:[0,1]});return e.register(r)}},t}(),co=y0;var b0=function(){function t(e,r,n){this.bytes=e,this.start=r||0,this.pos=this.start,this.end=r&&n?r+n:this.bytes.length}return Object.defineProperty(t.prototype,"length",{get:function(){return this.end-this.start},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.length===0},enumerable:!1,configurable:!0}),t.prototype.getByte=function(){return this.pos>=this.end?-1:this.bytes[this.pos++]},t.prototype.getUint16=function(){var e=this.getByte(),r=this.getByte();return e===-1||r===-1?-1:(e<<8)+r},t.prototype.getInt32=function(){var e=this.getByte(),r=this.getByte(),n=this.getByte(),o=this.getByte();return(e<<24)+(r<<16)+(n<<8)+o},t.prototype.getBytes=function(e,r){r===void 0&&(r=!1);var n=this.bytes,o=this.pos,i=this.end;if(e){var s=o+e;s>i&&(s=i),this.pos=s;var a=n.subarray(o,s);return r?new Uint8ClampedArray(a):a}else{var a=n.subarray(o,i);return r?new Uint8ClampedArray(a):a}},t.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},t.prototype.peekBytes=function(e,r){r===void 0&&(r=!1);var n=this.getBytes(e,r);return this.pos-=n.length,n},t.prototype.skip=function(e){e||(e=1),this.pos+=e},t.prototype.reset=function(){this.pos=this.start},t.prototype.moveStart=function(){this.start=this.pos},t.prototype.makeSubStream=function(e,r){return new t(this.bytes,e,r)},t.prototype.decode=function(){return this.bytes},t}(),Si=b0;var x0=new Uint8Array(0),F0=function(){function t(e){if(this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=x0,this.minBufferLength=512,e)for(;this.minBufferLengthi&&(n=i)}else{for(;!this.eof;)this.readBlock();n=this.bufferLength}this.pos=n;var a=this.buffer.subarray(o,n);return r&&!(a instanceof Uint8ClampedArray)?new Uint8ClampedArray(a):a},t.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},t.prototype.peekBytes=function(e,r){r===void 0&&(r=!1);var n=this.getBytes(e,r);return this.pos-=n.length,n},t.prototype.skip=function(e){e||(e=1),this.pos+=e},t.prototype.reset=function(){this.pos=0},t.prototype.makeSubStream=function(e,r){for(var n=e+r;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Si(this.buffer,e,r)},t.prototype.decode=function(){for(;!this.eof;)this.readBlock();return this.buffer.subarray(0,this.bufferLength)},t.prototype.readBlock=function(){throw new Le(this.constructor.name,"readBlock")},t.prototype.ensureBuffer=function(e){var r=this.buffer;if(e<=r.byteLength)return r;for(var n=this.minBufferLength;n=0;--l)f[s+l]=u&255,u>>=8}},e}(At),Lc=w0;var S0=function(t){k(e,t);function e(r,n){var o=t.call(this,n)||this;return o.stream=r,o.firstDigit=-1,n&&(n=.5*n),o}return e.prototype.readBlock=function(){var r=8e3,n=this.stream.getBytes(r);if(!n.length){this.eof=!0;return}for(var o=n.length+1>>1,i=this.ensureBuffer(this.bufferLength+o),a=this.bufferLength,s=this.firstDigit,f=0,l=n.length;f=48&&c<=57)u=c&15;else if(c>=65&&c<=70||c>=97&&c<=102)u=(c&15)+9;else if(c===62){this.eof=!0;break}else continue;s<0?s=u:(i[a++]=s<<4|u,s=-1)}s>=0&&this.eof&&(i[a++]=s<<4,s=-1),this.firstDigit=s,this.bufferLength=a},e}(At),Hc=S0;var Uc=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),P0=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),D0=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),C0=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],k0=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5],T0=function(t){k(e,t);function e(r,n){var o=t.call(this,n)||this;o.stream=r;var i=r.getByte(),a=r.getByte();if(i===-1||a===-1)throw new Error("Invalid header in flate stream: "+i+", "+a);if((i&15)!==8)throw new Error("Unknown compression method in flate stream: "+i+", "+a);if(((i<<8)+a)%31!==0)throw new Error("Bad FCHECK in flate stream: "+i+", "+a);if(a&32)throw new Error("FDICT bit set in flate stream: "+i+", "+a);return o.codeSize=0,o.codeBuf=0,o}return e.prototype.readBlock=function(){var r,n,o=this.stream,i=this.getBits(3);if(i&1&&(this.eof=!0),i>>=1,i===0){var a=void 0;if((a=o.getByte())===-1)throw new Error("Bad block header in flate stream");var s=a;if((a=o.getByte())===-1)throw new Error("Bad block header in flate stream");if(s|=a<<8,(a=o.getByte())===-1)throw new Error("Bad block header in flate stream");var f=a;if((a=o.getByte())===-1)throw new Error("Bad block header in flate stream");if(f|=a<<8,f!==(~s&65535)&&(s!==0||f!==0))throw new Error("Bad uncompressed block length in flate stream");this.codeBuf=0,this.codeSize=0;var l=this.bufferLength;r=this.ensureBuffer(l+s);var c=l+s;if(this.bufferLength=c,s===0)o.peekByte()===-1&&(this.eof=!0);else for(var u=l;u0;)S[m++]=C}d=this.generateHuffmanTable(S.subarray(0,h)),p=this.generateHuffmanTable(S.subarray(h,w))}else throw new Error("Unknown block type in flate stream");r=this.buffer;for(var A=r?r.length:0,R=this.bufferLength;;){var z=this.getCode(d);if(z<256){R+1>=A&&(r=this.ensureBuffer(R+1),A=r.length),r[R++]=z;continue}if(z===256){this.bufferLength=R;return}z-=257,z=P0[z];var M=z>>16;M>0&&(M=this.getBits(M)),n=(z&65535)+M,z=this.getCode(p),z=D0[z],M=z>>16,M>0&&(M=this.getBits(M));var X=(z&65535)+M;R+n>=A&&(r=this.ensureBuffer(R+n),A=r.length);for(var te=0;te>r,this.codeSize=o-=r,a},e.prototype.getCode=function(r){for(var n=this.stream,o=r[0],i=r[1],a=this.codeSize,s=this.codeBuf,f;a>16,u=l&65535;if(c<1||a>c,this.codeSize=a-c,u},e.prototype.generateHuffmanTable=function(r){var n=r.length,o=0,i;for(i=0;io&&(o=r[i]);for(var a=1<>=1;for(i=d;i0;if(!S||S<256)F[0]=S,x=1;else if(S>=258)if(S=0;a--)F[a]=u[s],s=p[s];else F[x++]=F[0];else if(S===256){h=9,c=258,x=0;continue}else{this.eof=!0,delete this.lzwState;break}if(D&&(p[c]=b,d[c]=d[b]+1,u[c]=F[0],c++,h=c+l&c+l-1?h:Math.min(Math.log(c+l)/.6931471805599453+1,12)|0),b=S,m+=x,n>>n&(1<0){var a=this.stream.getBytes(i);n.set(a,o),o+=i}}else{i=257-i;var s=r[1];n=this.ensureBuffer(o+i+1);for(var f=0;fn.size())throw new nn(r,0,n.size());n.remove(r)}else{if(r!==0)throw new nn(r,0,0);this.setKids([])}},e.prototype.normalizedEntries=function(){var r=this.Kids();return r||(r=this.dict.context.obj([this.ref]),this.dict.set(v.of("Kids"),r)),{Kids:r}},e.fromDict=function(r,n){return new e(r,n)},e}(vo),it=U0;var V0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.Opt=function(){return this.dict.lookupMaybe(v.of("Opt"),ne,H,Z)},e.prototype.setOpt=function(r){this.dict.set(v.of("Opt"),this.dict.context.obj(r))},e.prototype.getExportValues=function(){var r=this.Opt();if(r){if(r instanceof ne||r instanceof H)return[r];for(var n=[],o=0,i=r.size();on.size())throw new nn(r,0,n.size());n.remove(r)}},e.prototype.normalizeExportValues=function(){for(var r,n,o,i,a=(r=this.getExportValues())!==null&&r!==void 0?r:[],s=[],f=this.getWidgets(),l=0,c=f.length;l1){if(!this.hasFlag(le.MultiSelect))throw new hc;this.dict.set(v.of("V"),this.dict.context.obj(r))}this.updateSelectedIndices(r)},e.prototype.valuesAreValid=function(r){for(var n=this.getOptions(),o=function(f,l){var c=r[f].decodeText();if(!n.find(function(u){return c===(u.display||u.value).decodeText()}))return{value:!1}},i=0,a=r.length;i1){for(var n=new Array(r.length),o=this.getOptions(),i=function(f,l){var c=r[f].decodeText();n[f]=o.findIndex(function(u){return c===(u.display||u.value).decodeText()})},a=0,s=r.length;a0){var s=a.lookup(0,ne,H),f=a.lookupMaybe(1,ne,H);n.push({value:s,display:f||s})}}return n}return[]},e}(it),go=W0;var G0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Ch",Ff:le.Combo,Kids:[]}),o=r.register(n);return new e(n,o)},e}(go),rr=G0;var K0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.addField=function(r){var n=this.normalizedEntries().Kids;n?.push(r)},e.prototype.normalizedEntries=function(){var r=this.Kids();return r||(r=this.dict.context.obj([]),this.dict.set(v.of("Kids"),r)),{Kids:r}},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({}),o=r.register(n);return new e(n,o)},e}(vo),nr=K0;var X0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e}(it),Nr=X0;var Z0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.MaxLen=function(){var r=this.dict.lookup(v.of("MaxLen"));if(r instanceof j)return r},e.prototype.Q=function(){var r=this.dict.lookup(v.of("Q"));if(r instanceof j)return r},e.prototype.setMaxLength=function(r){this.dict.set(v.of("MaxLen"),j.of(r))},e.prototype.removeMaxLength=function(){this.dict.delete(v.of("MaxLen"))},e.prototype.getMaxLength=function(){var r;return(r=this.MaxLen())===null||r===void 0?void 0:r.asNumber()},e.prototype.setQuadding=function(r){this.dict.set(v.of("Q"),j.of(r))},e.prototype.getQuadding=function(){var r;return(r=this.Q())===null||r===void 0?void 0:r.asNumber()},e.prototype.setValue=function(r){this.dict.set(v.of("V"),r)},e.prototype.removeValue=function(){this.dict.delete(v.of("V"))},e.prototype.getValue=function(){var r=this.V();if(r instanceof ne||r instanceof H)return r},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Tx",Kids:[]}),o=r.register(n);return new e(n,o)},e}(it),or=Z0;var Y0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Btn",Ff:qe.PushButton,Kids:[]}),o=r.register(n);return new e(n,o)},e}(Br),ir=Y0;var J0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.setValue=function(r){var n=this.getOnValues();if(!n.includes(r)&&r!==v.of("Off"))throw new on;this.dict.set(v.of("V"),r);for(var o=this.getWidgets(),i=0,a=o.length;ii)throw new Na(n,i);for(var a=n,s=0,f=o.size();sa)return c.insertLeafNode(r,a)||l;a-=c.Count().asNumber()}c instanceof Ze&&(a-=1)}if(a===0){this.insertLeafKid(o.size(),r);return}throw new Ma(n,"insertLeafNode")},e.prototype.removeLeafNode=function(r,n){n===void 0&&(n=!0);var o=this.Kids(),i=this.Count().asNumber();if(r>=i)throw new Na(r,i);for(var a=r,s=0,f=o.size();sa){c.removeLeafNode(a,n),n&&c.Kids().size()===0&&o.remove(s);return}else a-=c.Count().asNumber();if(c instanceof Ze)if(a===0){this.removeKid(s);return}else a-=1}throw new Ma(r,"removeLeafNode")},e.prototype.ascend=function(r){r(this);var n=this.Parent();n&&n.ascend(r)},e.prototype.traverse=function(r){for(var n=this.Kids(),o=0,i=n.size();oNumber.MAX_SAFE_INTEGER)if(this.capNumbers){var o="Parsed number that is too large for some PDF readers: "+e+", using Number.MAX_SAFE_INTEGER instead.";return console.warn(o),Number.MAX_SAFE_INTEGER}else{var o="Parsed number that is too large for some PDF readers: "+e+", not capping.";console.warn(o)}return n},t.prototype.skipWhitespace=function(){for(;!this.bytes.done()&&ft[this.bytes.peek()];)this.bytes.next()},t.prototype.skipLine=function(){for(;!this.bytes.done();){var e=this.bytes.peek();if(e===Zc||e===Yc)return;this.bytes.next()}},t.prototype.skipComment=function(){if(this.bytes.peek()!==g.Percent)return!1;for(;!this.bytes.done();){var e=this.bytes.peek();if(e===Zc||e===Yc)return!0;this.bytes.next()}return!0},t.prototype.skipWhitespaceAndComments=function(){for(this.skipWhitespace();this.skipComment();)this.skipWhitespace()},t.prototype.matchKeyword=function(e){for(var r=this.bytes.offset(),n=0,o=e.length;n=this.length},t.prototype.offset=function(){return this.idx},t.prototype.slice=function(e,r){return this.bytes.slice(e,r)},t.prototype.position=function(){return{line:this.line,column:this.column,offset:this.idx}},t.of=function(e){return new t(e)},t.fromPDFRawStream=function(e){return t.of(uo(e).decode())},t}(),lr=av;var sv=g.Space,wo=g.CarriageReturn,So=g.Newline,Po=[g.s,g.t,g.r,g.e,g.a,g.m],Ti=[g.e,g.n,g.d,g.s,g.t,g.r,g.e,g.a,g.m],pe={header:[g.Percent,g.P,g.D,g.F,g.Dash],eof:[g.Percent,g.Percent,g.E,g.O,g.F],obj:[g.o,g.b,g.j],endobj:[g.e,g.n,g.d,g.o,g.b,g.j],xref:[g.x,g.r,g.e,g.f],trailer:[g.t,g.r,g.a,g.i,g.l,g.e,g.r],startxref:[g.s,g.t,g.a,g.r,g.t,g.x,g.r,g.e,g.f],true:[g.t,g.r,g.u,g.e],false:[g.f,g.a,g.l,g.s,g.e],null:[g.n,g.u,g.l,g.l],stream:Po,streamEOF1:re(Po,[sv,wo,So]),streamEOF2:re(Po,[wo,So]),streamEOF3:re(Po,[wo]),streamEOF4:re(Po,[So]),endstream:Ti,EOF1endstream:re([wo,So],Ti),EOF2endstream:re([wo],Ti),EOF3endstream:re([So],Ti)};var lv=function(t){k(e,t);function e(r,n,o){o===void 0&&(o=!1);var i=t.call(this,r,o)||this;return i.context=n,i}return e.prototype.parseObject=function(){if(this.skipWhitespaceAndComments(),this.matchKeyword(pe.true))return Ut.True;if(this.matchKeyword(pe.false))return Ut.False;if(this.matchKeyword(pe.null))return Te;var r=this.bytes.peek();if(r===g.LessThan&&this.bytes.peekAhead(1)===g.LessThan)return this.parseDictOrStream();if(r===g.LessThan)return this.parseHexString();if(r===g.LeftParen)return this.parseString();if(r===g.ForwardSlash)return this.parseName();if(r===g.LeftSquareBracket)return this.parseArray();if(Fo[r])return this.parseNumberOrRef();throw new gc(this.bytes.position(),r)},e.prototype.parseNumberOrRef=function(){var r=this.parseRawNumber();this.skipWhitespaceAndComments();var n=this.bytes.offset();if(Ie[this.bytes.peek()]){var o=this.parseRawNumber();if(this.skipWhitespaceAndComments(),this.bytes.peek()===g.R)return this.bytes.assertNext(g.R),J.of(r,o)}return this.bytes.moveTo(n),j.of(r)},e.prototype.parseHexString=function(){var r="";for(this.bytes.assertNext(g.LessThan);!this.bytes.done()&&this.bytes.peek()!==g.GreaterThan;)r+=tt(this.bytes.next());return this.bytes.assertNext(g.GreaterThan),H.of(r)},e.prototype.parseString=function(){for(var r=0,n=!1,o="";!this.bytes.done();){var i=this.bytes.next();if(o+=tt(i),n||(i===g.LeftParen&&(r+=1),i===g.RightParen&&(r-=1)),i===g.BackSlash?n=!n:n&&(n=!1),r===0)return ne.of(o.substring(1,o.length-1))}throw new xc(this.bytes.position())},e.prototype.parseName=function(){this.bytes.assertNext(g.ForwardSlash);for(var r="";!this.bytes.done();){var n=this.bytes.peek();if(ft[n]||et[n])break;r+=tt(n),this.bytes.next()}return v.of(r)},e.prototype.parseArray=function(){this.bytes.assertNext(g.LeftSquareBracket),this.skipWhitespaceAndComments();for(var r=Z.withContext(this.context);this.bytes.peek()!==g.RightSquareBracket;){var n=this.parseObject();r.push(n),this.skipWhitespaceAndComments()}return this.bytes.assertNext(g.RightSquareBracket),r},e.prototype.parseDict=function(){this.bytes.assertNext(g.LessThan),this.bytes.assertNext(g.LessThan),this.skipWhitespaceAndComments();for(var r=new Map;!this.bytes.done()&&this.bytes.peek()!==g.GreaterThan&&this.bytes.peekAhead(1)!==g.GreaterThan;){var n=this.parseName(),o=this.parseObject();r.set(n,o),this.skipWhitespaceAndComments()}this.skipWhitespaceAndComments(),this.bytes.assertNext(g.GreaterThan),this.bytes.assertNext(g.GreaterThan);var i=r.get(v.of("Type"));return i===v.of("Catalog")?bo.fromMapWithContext(r,this.context):i===v.of("Pages")?xo.fromMapWithContext(r,this.context):i===v.of("Page")?Ze.fromMapWithContext(r,this.context):U.fromMapWithContext(r,this.context)},e.prototype.parseDictOrStream=function(){var r=this.bytes.position(),n=this.parseDict();if(this.skipWhitespaceAndComments(),!this.matchKeyword(pe.streamEOF1)&&!this.matchKeyword(pe.streamEOF2)&&!this.matchKeyword(pe.streamEOF3)&&!this.matchKeyword(pe.streamEOF4)&&!this.matchKeyword(pe.stream))return n;var o=this.bytes.offset(),i,a=n.get(v.of("Length"));a instanceof j?(i=o+a.asNumber(),this.bytes.moveTo(i),this.skipWhitespaceAndComments(),this.matchKeyword(pe.endstream)||(this.bytes.moveTo(o),i=this.findEndOfStreamFallback(r))):i=this.findEndOfStreamFallback(r);var s=this.bytes.slice(o,i);return Et.of(n,s)},e.prototype.findEndOfStreamFallback=function(r){for(var n=1,o=this.bytes.offset();!this.bytes.done()&&(o=this.bytes.offset(),this.matchKeyword(pe.stream)?n+=1:this.matchKeyword(pe.EOF1endstream)||this.matchKeyword(pe.EOF2endstream)||this.matchKeyword(pe.EOF3endstream)||this.matchKeyword(pe.endstream)?n-=1:this.bytes.next(),n!==0););if(n!==0)throw new bc(r);return o},e.forBytes=function(r,n,o){return new e(lr.of(r),n,o)},e.forByteStream=function(r,n,o){return o===void 0&&(o=!1),new e(r,n,o)},e}(Jc),Do=lv;var fv=function(t){k(e,t);function e(r,n){var o=t.call(this,lr.fromPDFRawStream(r),r.dict.context)||this,i=r.dict;return o.alreadyParsed=!1,o.shouldWaitForTick=n||function(){return!1},o.firstOffset=i.lookup(v.of("First"),j).asNumber(),o.objectCount=i.lookup(v.of("N"),j).asNumber(),o}return e.prototype.parseIntoContext=function(){return V(this,void 0,void 0,function(){var r,n,o,i,a,s,f,l;return q(this,function(c){switch(c.label){case 0:if(this.alreadyParsed)throw new rn("PDFObjectStreamParser","parseIntoContext");this.alreadyParsed=!0,r=this.parseOffsetsAndObjectNumbers(),n=0,o=r.length,c.label=1;case 1:return n=g.Space&&n<=g.Tilde;if(o&&(this.matchKeyword(pe.xref)||this.matchKeyword(pe.trailer)||this.matchKeyword(pe.startxref)||this.matchIndirectObjectHeader())){this.bytes.moveTo(r);break}this.bytes.next()}},e.prototype.skipBinaryHeaderComment=function(){this.skipWhitespaceAndComments();try{var r=this.bytes.offset();this.parseIndirectObjectHeader(),this.bytes.moveTo(r)}catch{this.bytes.next(),this.skipWhitespaceAndComments()}},e.forBytesWithOptions=function(r,n,o,i){return new e(r,n,o,i)},e}(Do),_a=uv;var Rt=function(t){return 1<0&&(n[n.length]=+o),r[r.length]={cmd:e,args:n},n=[],o="",i=!1),e=l;else if([" ",","].includes(l)||l==="-"&&o.length>0&&o[o.length-1]!=="e"||l==="."&&i){if(o.length===0)continue;n.length===a?(r[r.length]={cmd:e,args:n},n=[+o],e==="M"&&(e="L"),e==="m"&&(e="l")):n[n.length]=+o,i=l===".",o=["-","."].includes(l)?l:""}else o+=l,l==="."&&(i=!0)}return o.length>0&&(n.length===a?(r[r.length]={cmd:e,args:n},n=[+o],e==="M"&&(e="L"),e==="m"&&(e="l")):n[n.length]=+o),r[r.length]={cmd:e,args:n},r},vv=function(t){G=K=fe=ce=No=Mo=0;for(var e=[],r=0;r1&&(d=Math.sqrt(d),r*=d,n*=d);var p=u/r,h=c/r,b=-c/n,F=u/n,x=p*s+h*f,m=b*s+F*f,y=p*t+h*e,w=b*t+F*e,S=(y-x)*(y-x)+(w-m)*(w-m),D=1/S-.25;D<0&&(D=0);var T=Math.sqrt(D);i===o&&(T=-T);var C=.5*(x+y)-T*(w-m),E=.5*(m+w)+T*(y-x),I=Math.atan2(m-E,x-C),A=Math.atan2(w-E,y-C),R=A-I;R<0&&i===1?R+=2*Math.PI:R>0&&i===0&&(R-=2*Math.PI);for(var z=Math.ceil(Math.abs(R/(Math.PI*.5+.001))),M=[],X=0;Xt.length)return o-1;var F=e.heightAtSize(o),x=F+F*.2,m=x*i;if(m>Math.abs(r.height))return o-1;o+=1}return o},Fv=function(t,e,r,n){for(var o=r.width/n,i=r.height,a=Eu,s=Ns(t);ao*.75;if(u)return a-1}var d=e.heightAtSize(a,{descender:!1});if(d>i)return a-1;a+=1}return a},wv=function(t){for(var e=t.length;e>0;e--)if(/\s/.test(t[e]))return e},Sv=function(t,e,r,n){for(var o,i=t.length;i>0;){var a=t.substring(0,i),s=r.encodeText(a),f=r.widthOfTextAtSize(a,n);if(fd&&(d=T+S),h+s>p&&(p=h+s),l.push({text:y,encoded:w,width:S,height:s,x:T,y:h}),x=D?.trim()}return{fontSize:n,lineHeight:f,lines:l,bounds:{x:c,y:u,width:d-c,height:p-u}}},Ou=function(t,e){var r=e.fontSize,n=e.font,o=e.bounds,i=e.cellCount,a=Xi(pr(t));if(a.length>i)throw new Cu(a.length,i);(r===void 0||r===0)&&(r=Fv(a,n,o,i));for(var s=o.width/i,f=n.heightAtSize(r,{descender:!1}),l=o.y+(o.height/2-f/2),c=[],u=o.x,d=o.y,p=o.x+o.width,h=o.y+o.height,b=0,F=0;bp&&(p=T+S),l+f>h&&(h=l+f),c.push({text:a,encoded:w,width:S,height:f,x:T,y:l}),b+=1,F+=y}return{fontSize:r,cells:c,bounds:{x:u,y:d,width:p-u,height:h-d}}},jo=function(t,e){var r=e.alignment,n=e.fontSize,o=e.font,i=e.bounds,a=Xi(pr(t));(n===void 0||n===0)&&(n=Ru([a],o,i));var s=o.encodeText(a),f=o.widthOfTextAtSize(a,n),l=o.heightAtSize(n,{descender:!1}),c=r===De.Left?i.x:r===De.Center?i.x+i.width/2-f/2:r===De.Right?i.x+i.width-f:i.x,u=i.y+(i.height/2-l/2);return{fontSize:n,line:{text:a,encoded:s,width:f,height:l,x:c,y:u},bounds:{x:c,y:u,width:f,height:l}}};var pt=function(t){return"normal"in t?t:{normal:t}},Pv=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]+(\d*\.\d+|\d+)[\0\t\n\f\r\ ]+Tf/,dr=function(t){var e,r,n=(e=t.getDefaultAppearance())!==null&&e!==void 0?e:"",o=(r=On(n,Pv).match)!==null&&r!==void 0?r:[],i=Number(o[2]);return isFinite(i)?i:void 0},Dv=/(\d*\.\d+|\d+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+(g|rg|k)/,dt=function(t){var e,r=(e=t.getDefaultAppearance())!==null&&e!==void 0?e:"",n=On(r,Dv).match,o=n??[],i=o[1],a=o[2],s=o[3],f=o[4],l=o[5];if(l==="g"&&i)return ls(Number(i));if(l==="rg"&&i&&a&&s)return ae(Number(i),Number(a),Number(s));if(l==="k"&&i&&a&&s&&f)return fs(Number(i),Number(a),Number(s),Number(f))},ht=function(t,e,r,n){var o;n===void 0&&(n=0);var i=[Bt(e).toString(),Oo((o=r?.name)!==null&&o!==void 0?o:"dummy__noop",n).toString()].join(` -`);t.setDefaultAppearance(i)},Bu=function(t,e){var r,n,o,i=dt(e),a=dt(t.acroField),s=e.getRectangle(),f=e.getAppearanceCharacteristics(),l=e.getBorderStyle(),c=(r=l?.getWidth())!==null&&r!==void 0?r:0,u=bt(f?.getRotation()),d=qt(s,u),p=d.width,h=d.height,b=xt(Y(Y({},s),{rotation:u})),F=ae(0,0,0),x=(n=We(f?.getBorderColor()))!==null&&n!==void 0?n:F,m=We(f?.getBackgroundColor()),y=We(f?.getBackgroundColor(),.8),w=(o=i??a)!==null&&o!==void 0?o:F;ht(i?e:t.acroField,w);var S={x:0+c/2,y:0+c/2,width:p-c,height:h-c,thickness:1.5,borderWidth:c,borderColor:x,markColor:w};return{normal:{on:re(b,Io(Y(Y({},S),{color:m,filled:!0}))),off:re(b,Io(Y(Y({},S),{color:m,filled:!1})))},down:{on:re(b,Io(Y(Y({},S),{color:y,filled:!0}))),off:re(b,Io(Y(Y({},S),{color:y,filled:!1})))}}},Nu=function(t,e){var r,n,o,i=dt(e),a=dt(t.acroField),s=e.getRectangle(),f=e.getAppearanceCharacteristics(),l=e.getBorderStyle(),c=(r=l?.getWidth())!==null&&r!==void 0?r:0,u=bt(f?.getRotation()),d=qt(s,u),p=d.width,h=d.height,b=xt(Y(Y({},s),{rotation:u})),F=ae(0,0,0),x=(n=We(f?.getBorderColor()))!==null&&n!==void 0?n:F,m=We(f?.getBackgroundColor()),y=We(f?.getBackgroundColor(),.8),w=(o=i??a)!==null&&o!==void 0?o:F;ht(i?e:t.acroField,w);var S={x:p/2,y:h/2,width:p-c,height:h-c,borderWidth:c,borderColor:x,dotColor:w};return{normal:{on:re(b,zo(Y(Y({},S),{color:m,filled:!0}))),off:re(b,zo(Y(Y({},S),{color:m,filled:!1})))},down:{on:re(b,zo(Y(Y({},S),{color:y,filled:!0}))),off:re(b,zo(Y(Y({},S),{color:y,filled:!1})))}}},Mu=function(t,e,r){var n,o,i,a,s,f=dt(e),l=dt(t.acroField),c=dr(e),u=dr(t.acroField),d=e.getRectangle(),p=e.getAppearanceCharacteristics(),h=e.getBorderStyle(),b=p?.getCaptions(),F=(n=b?.normal)!==null&&n!==void 0?n:"",x=(i=(o=b?.down)!==null&&o!==void 0?o:F)!==null&&i!==void 0?i:"",m=(a=h?.getWidth())!==null&&a!==void 0?a:0,y=bt(p?.getRotation()),w=qt(d,y),S=w.width,D=w.height,T=xt(Y(Y({},d),{rotation:y})),C=ae(0,0,0),E=We(p?.getBorderColor()),I=We(p?.getBackgroundColor()),A=We(p?.getBackgroundColor(),.8),R={x:m,y:m,width:S-m*2,height:D-m*2},z=jo(F,{alignment:De.Center,fontSize:c??u,font:r,bounds:R}),M=jo(x,{alignment:De.Center,fontSize:c??u,font:r,bounds:R}),X=Math.min(z.fontSize,M.fontSize),te=(s=f??l)!==null&&s!==void 0?s:C;ht(f||c!==void 0?e:t.acroField,te,r,X);var L={x:0+m/2,y:0+m/2,width:S-m,height:D-m,borderWidth:m,borderColor:E,textColor:te,font:r.name,fontSize:X};return{normal:re(T,ps(Y(Y({},L),{color:I,textLines:[z.line]}))),down:re(T,ps(Y(Y({},L),{color:A,textLines:[M.line]})))}},Iu=function(t,e,r){var n,o,i,a,s=dt(e),f=dt(t.acroField),l=dr(e),c=dr(t.acroField),u=e.getRectangle(),d=e.getAppearanceCharacteristics(),p=e.getBorderStyle(),h=(n=t.getText())!==null&&n!==void 0?n:"",b=(o=p?.getWidth())!==null&&o!==void 0?o:0,F=bt(d?.getRotation()),x=qt(u,F),m=x.width,y=x.height,w=xt(Y(Y({},u),{rotation:F})),S=ae(0,0,0),D=We(d?.getBorderColor()),T=We(d?.getBackgroundColor()),C,E,I=t.isCombed()?0:1,A={x:b+I,y:b+I,width:m-(b+I)*2,height:y-(b+I)*2};if(t.isMultiline()){var R=ys(h,{alignment:t.getAlignment(),fontSize:l??c,font:r,bounds:A});C=R.lines,E=R.fontSize}else if(t.isCombed()){var R=Ou(h,{fontSize:l??c,font:r,bounds:A,cellCount:(i=t.getMaxLength())!==null&&i!==void 0?i:0});C=R.cells,E=R.fontSize}else{var R=jo(h,{alignment:t.getAlignment(),fontSize:l??c,font:r,bounds:A});C=[R.line],E=R.fontSize}var z=(a=s??f)!==null&&a!==void 0?a:S;ht(s||l!==void 0?e:t.acroField,z,r,E);var M={x:0+b/2,y:0+b/2,width:m-b,height:y-b,borderWidth:b??0,borderColor:D,textColor:z,font:r.name,fontSize:E,color:T,textLines:C,padding:I};return re(w,ms(M))},zu=function(t,e,r){var n,o,i,a=dt(e),s=dt(t.acroField),f=dr(e),l=dr(t.acroField),c=e.getRectangle(),u=e.getAppearanceCharacteristics(),d=e.getBorderStyle(),p=(n=t.getSelected()[0])!==null&&n!==void 0?n:"",h=(o=d?.getWidth())!==null&&o!==void 0?o:0,b=bt(u?.getRotation()),F=qt(c,b),x=F.width,m=F.height,y=xt(Y(Y({},c),{rotation:b})),w=ae(0,0,0),S=We(u?.getBorderColor()),D=We(u?.getBackgroundColor()),T=1,C={x:h+T,y:h+T,width:x-(h+T)*2,height:m-(h+T)*2},E=jo(p,{alignment:De.Left,fontSize:f??l,font:r,bounds:C}),I=E.line,A=E.fontSize,R=(i=a??s)!==null&&i!==void 0?i:w;ht(a||f!==void 0?e:t.acroField,R,r,A);var z={x:0+h/2,y:0+h/2,width:x-h,height:m-h,borderWidth:h??0,borderColor:S,textColor:R,font:r.name,fontSize:A,color:D,textLines:[I],padding:T};return re(y,ms(z))},ju=function(t,e,r){var n,o,i=dt(e),a=dt(t.acroField),s=dr(e),f=dr(t.acroField),l=e.getRectangle(),c=e.getAppearanceCharacteristics(),u=e.getBorderStyle(),d=(n=u?.getWidth())!==null&&n!==void 0?n:0,p=bt(c?.getRotation()),h=qt(l,p),b=h.width,F=h.height,x=xt(Y(Y({},l),{rotation:p})),m=ae(0,0,0),y=We(c?.getBorderColor()),w=We(c?.getBackgroundColor()),S=t.getOptions(),D=t.getSelected();t.isSorted()&&S.sort();for(var T="",C=0,E=S.length;C1||o.length===1&&n)&&this.enableMultiselect();for(var s=new Array(o.length),f=0,l=o.length;f1||o.length===1&&n)&&this.enableMultiselect();for(var a=new Array(o.length),s=0,f=o.length;sn)throw new ku(r.length,n,this.getName());this.markAsDirty(),this.disableRichFormatting(),r?this.acroField.setValue(H.fromText(r)):this.acroField.removeValue()},e.prototype.getAlignment=function(){var r=this.acroField.getQuadding();return r===0?De.Left:r===1?De.Center:r===2?De.Right:De.Left},e.prototype.setAlignment=function(r){yt(r,"alignment",De),this.markAsDirty(),this.acroField.setQuadding(r)},e.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},e.prototype.setMaxLength=function(r){if(ot(r,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),r===void 0)this.acroField.removeMaxLength();else{var n=this.getText();if(n&&n.length>r)throw new Tu(n.length,r,this.getName());this.acroField.setMaxLength(r)}},e.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},e.prototype.setImage=function(r){for(var n=this.getAlignment(),o=n===De.Center?Ft.Center:n===De.Right?Ft.Right:Ft.Left,i=this.acroField.getWidgets(),a=0,s=i.length;at/25.4*96;function Wv(t){return t.pageSize==="Custom"?{w:Math.max(1,Math.round(kn(t.customPageWidth))),h:Math.max(1,Math.round(kn(t.customPageHeight)))}:Vi[t.pageSize]??Vi.A4}function Ui(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function qu(t){return t.replace(/<\/style/gi,"<\\/style")}function Cn(t,e){let r=e.trim();if(!r)return"";if(/^(https?:|data:)/i.test(r))return r;let n=t.vault.getAbstractFileByPath(r);if(n instanceof N.TFile)return t.vault.getResourcePath(n);let o=t.metadataCache.getFirstLinkpathDest(r,"");return o instanceof N.TFile?t.vault.getResourcePath(o):(console.warn("[advanced-pdf-export] Could not resolve image path:",r),r)}function Wu(t){return{size:t==="fill"?"100% 100%":t==="tile"?"auto":t,repeat:t==="tile"?"repeat":"no-repeat"}}var Gv=/[\u0590-\u08FF\uFB1D-\uFDFD\uFE70-\uFEFC]/g,Kv=/[A-Za-z\u0590-\u08FF\uFB1D-\uFDFD\uFE70-\uFEFC]/g;function Xv(t){let e=(t.match(Gv)??[]).length,r=(t.match(Kv)??[]).length;return r>0&&e/r>.1}function Zv(t){return t.replace(/\r\n|\r/g,` -`)}function Yv(t){return t.replace(/^---[ \t]*\n[\s\S]*?\n---[ \t]*(\n|$)/,"")}function Jv(t){return t.split(/^\/\/\/\s*$/m).map(e=>e.trim()).filter(Boolean)}async function Qv(t,e,r,n){let o=activeDocument.createElement("div");o.setCssStyles({position:"fixed",top:"0",left:"-99999px",visibility:"hidden",pointerEvents:"none"}),activeDocument.body.appendChild(o);try{await N.MarkdownRenderer.render(t,e,o,r,n),await rm(o),await nm(o);let i=activeDocument.fonts;if(i)try{await i.ready}catch{}}finally{activeDocument.body.removeChild(o)}return tm(o),o}var _v=/[^\p{L}\p{N}\s-]/gu,$v=/\s+/g,em=/-+/g;function Gu(t){return t.toLowerCase().replace(_v,"").trim().replace($v,"-").replace(em,"-")}function tm(t){let e=new Map;t.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(r=>{let n=r.textContent||"",o=Gu(n);if(!o)return;let i=e.get(o)??0;e.set(o,i+1),r.id=i===0?o:`${o}-${i}`}),t.querySelectorAll("a").forEach(r=>{r.classList.remove("external-link");let n=r.getAttribute("data-href")??r.getAttribute("href");n?.startsWith("#")&&r.setAttribute("href","#"+Gu(n.slice(1)))}),t.querySelectorAll(".copy-code-button").forEach(r=>r.remove()),t.querySelectorAll(".callout").forEach(r=>{r.removeAttribute("data-callout-fold"),r.classList.remove("is-collapsed"),r.querySelectorAll(".callout-fold").forEach(n=>n.remove())}),t.querySelectorAll("style, script").forEach(r=>{r.closest("svg")||r.remove()})}async function rm(t){let e=Array.from(t.querySelectorAll(".mermaid"));if(e.length===0)return;let r=5e3;await Promise.all(e.map(n=>new Promise(o=>{if(n.querySelector("svg")){o();return}let i=window.setTimeout(()=>{a.disconnect(),o()},r),a=new MutationObserver(()=>{n.querySelector("svg")&&(window.clearTimeout(i),a.disconnect(),o())});a.observe(n,{childList:!0,subtree:!0})})))}async function nm(t){let e=Array.from(t.querySelectorAll(".math"));if(e.length===0)return;let r=window.MathJax;if(r?.startup?.promise)try{await r.startup.promise}catch{}let n=8e3;await Promise.all(e.filter(o=>!o.querySelector("mjx-container")).map(o=>new Promise(i=>{let a=window.setTimeout(()=>{s.disconnect(),i()},n),s=new MutationObserver(()=>{o.querySelector("mjx-container")&&(window.clearTimeout(a),s.disconnect(),i())});s.observe(o,{childList:!0,subtree:!0})})))}var om={comment:["comment","prolog","doctype","cdata"],punctuation:["punctuation"],property:["property","tag","boolean","number","constant","symbol","deleted","attr-name"],selector:["selector","string","char","builtin","inserted","attr-value"],operator:["operator","entity","url"],keyword:["atrule","keyword","important"],function:["function","class-name"],regex:["regex","variable"]},Ss={none:{name:"None (plain)"},"github-light":{name:"GitHub Light",background:"#f6f8fa",text:"#24292e",tokens:{comment:"#6a737d",punctuation:"#24292e",property:"#005cc5",selector:"#032f62",operator:"#d73a49",keyword:"#d73a49",function:"#6f42c1",regex:"#032f62"}},"github-dark":{name:"GitHub Dark",background:"#0d1117",text:"#c9d1d9",tokens:{comment:"#8b949e",punctuation:"#c9d1d9",property:"#79c0ff",selector:"#a5d6ff",operator:"#ff7b72",keyword:"#ff7b72",function:"#d2a8ff",regex:"#a5d6ff"}},"atom-one-light":{name:"Atom One Light",background:"#fafafa",text:"#383a42",tokens:{comment:"#a0a1a7",punctuation:"#383a42",property:"#986801",selector:"#50a14f",operator:"#0184bc",keyword:"#a626a4",function:"#4078f2",regex:"#50a14f"}},"atom-one-dark":{name:"Atom One Dark",background:"#282c34",text:"#abb2bf",tokens:{comment:"#5c6370",punctuation:"#abb2bf",property:"#d19a66",selector:"#98c379",operator:"#56b6c2",keyword:"#c678dd",function:"#61afef",regex:"#98c379"}},monokai:{name:"Monokai",background:"#272822",text:"#f8f8f2",tokens:{comment:"#75715e",punctuation:"#f8f8f2",property:"#ae81ff",selector:"#e6db74",operator:"#f92672",keyword:"#f92672",function:"#a6e22e",regex:"#e6db74"}},dracula:{name:"Dracula",background:"#282a36",text:"#f8f8f2",tokens:{comment:"#6272a4",punctuation:"#f8f8f2",property:"#bd93f9",selector:"#f1fa8c",operator:"#ff79c6",keyword:"#ff79c6",function:"#50fa7b",regex:"#ff79c6"}},"tokyo-night":{name:"Tokyo Night",background:"#1a1b26",text:"#a9b1d6",tokens:{comment:"#565f89",punctuation:"#89ddff",property:"#ff9e64",selector:"#9ece6a",operator:"#89ddff",keyword:"#bb9af7",function:"#7aa2f7",regex:"#b4f9f8"}},"solarized-light":{name:"Solarized Light",background:"#fdf6e3",text:"#586e75",tokens:{comment:"#93a1a1",punctuation:"#586e75",property:"#cb4b16",selector:"#2aa198",operator:"#859900",keyword:"#859900",function:"#268bd2",regex:"#2aa198"}},"catppuccin-macchiato":{name:"Catppuccin Macchiato",background:"#24273a",text:"#cad3f5",tokens:{comment:"#939ab7",punctuation:"#b8c0e0",property:"#f5a97f",selector:"#a6da95",operator:"#91d7e3",keyword:"#c6a0f6",function:"#8aadf4",regex:"#f5bde6"}},"catppuccin-mocha":{name:"Catppuccin Mocha",background:"#1e1e2e",text:"#cdd6f4",tokens:{comment:"#9399b2",punctuation:"#bac2de",property:"#fab387",selector:"#a6e3a1",operator:"#89dceb",keyword:"#cba6f7",function:"#89b4fa",regex:"#f5c2e7"}}};function im(t){let e=Ss[t.codeTheme]??Ss.none,r=e.background??t.codeBackground,n=e.text??t.bodyColor,o=Object.entries(e.tokens??{}).map(([i,a])=>`${om[i].map(l=>`.mpdf-doc pre code .token.${l}`).join(", ")} { color: ${a};${i==="comment"?" font-style: italic;":""} }`).join(` +end`},Nc=function(){for(var t=[],e=0;e"},wi=function(t){return Mt(t,4)},f0=function(t){if(Ys(t))return wi(t);if(Js(t)){var e=Ji(t),r=Qi(t);return""+wi(e)+wi(r)}var n=Wt(t),o="0x"+n+" is not a valid UTF-8 or UTF-16 codepoint.";throw new Error(o)};var c0=function(t){var e=0,r=function(n){e|=1<=g.Zero&&l<=g.Seven?(n+=f,(n.length===3||!(c>="0"&&c<="7"))&&(i(parseInt(n,8)),n="")):i(l):l===g.BackSlash?o=!0:i(l)}return new Uint8Array(r)},e.prototype.decodeText=function(){var r=this.asBytes();return _o(r)?Qo(r):yi(r)},e.prototype.decodeDate=function(){var r=this.decodeText(),n=Zo(r);if(!n)throw new bi(r);return n},e.prototype.asString=function(){return this.value},e.prototype.clone=function(){return e.of(this.value)},e.prototype.toString=function(){return"("+this.value+")"},e.prototype.sizeInBytes=function(){return this.value.length+2},e.prototype.copyBytesInto=function(r,n){return r[n++]=g.LeftParen,n+=me(this.value,r,n),r[n++]=g.RightParen,this.value.length+2},e.of=function(r){return new e(r)},e.fromDate=function(r){var n=rt(String(r.getUTCFullYear()),4,"0"),o=rt(String(r.getUTCMonth()+1),2,"0"),i=rt(String(r.getUTCDate()),2,"0"),a=rt(String(r.getUTCHours()),2,"0"),s=rt(String(r.getUTCMinutes()),2,"0"),f=rt(String(r.getUTCSeconds()),2,"0");return new e("D:"+n+o+i+a+s+f+"Z")},e}(ve),ne=u0;var d0=function(){function t(e,r,n,o){var i=this;this.allGlyphsInFontSortedById=function(){for(var a=new Array(i.font.characterSet.length),s=0,f=a.length;s>3)]>>7-((h&7)<<0)&1,R=3*A;s[w]=S[R],s[w+1]=S[R+1],s[w+2]=S[R+2],s[w+3]=A>2)]>>6-((h&3)<<1)&3,R=3*A;s[w]=S[R],s[w+1]=S[R+1],s[w+2]=S[R+2],s[w+3]=A>1)]>>4-((h&1)<<2)&15,R=3*A;s[w]=S[R],s[w+1]=S[R+1],s[w+2]=S[R+2],s[w+3]=A>>3)]>>>7-(L&7)&1),ue=M==x*255?0:255;f[te+L]=ue<<24|M<<16|M<<8|M}else if(c==2)for(var L=0;L>>2)]>>>6-((L&3)<<1)&3),ue=M==x*85?0:255;f[te+L]=ue<<24|M<<16|M<<8|M}else if(c==4)for(var L=0;L>>1)]>>>4-((L&1)<<2)&15),ue=M==x*17?0:255;f[te+L]=ue<<24|M<<16|M<<8|M}else if(c==8)for(var L=0;L>>2<<3));o==0;){if(o=F(e,d,1),i=F(e,d+1,2),d+=3,i==0){(d&7)!=0&&(d+=8-(d&7));var C=(d>>>3)+4,E=e[C-4]|e[C-3]<<8;T&&(r=t.H.W(r,u+E)),r.set(new n(e.buffer,e.byteOffset+C,E),u),d=C+E<<3,u+=E;continue}if(T&&(r=t.H.W(r,u+(1<<17))),i==1&&(p=D.J,h=D.h,l=511,c=31),i==2){a=x(e,d,5)+257,s=x(e,d+5,5)+1,f=x(e,d+10,4)+4,d+=14;for(var I=d,A=1,R=0;R<38;R+=2)D.Q[R]=0,D.Q[R+1]=0;for(var R=0;RA&&(A=z)}d+=3*f,y(D.Q,A),w(D.Q,A,D.u),p=D.w,h=D.d,d=m(D.u,(1<>>4;if(!(L>>>8))r[u++]=L;else{if(L==256)break;var ue=u+L-254;if(L>264){var ye=D.q[L-257];ue=u+(ye>>>3)+x(e,d,ye&7),d+=ye&7}var oe=h[S(e,d)&c];d+=oe&15;var Fe=oe>>>4,Ce=D.c[Fe],Be=(Ce>>>4)+F(e,d,Ce&15);for(d+=Ce&15;u>>4;if(u<=15)a[l]=u,l++;else{var d=0,p=0;u==16?(p=3+s(o,i,2),i+=2,d=a[l-1]):u==17?(p=3+s(o,i,3),i+=3):u==18&&(p=11+s(o,i,7),i+=7);for(var h=l+p;l>>1;ai&&(i=f),a++}for(;a>1,l=e[s+1],c=f<<4|l,u=r-l,d=e[s]<>>15-r;n[h]=c,d++}},t.H.l=function(e,r){for(var n=t.H.m.r,o=15-r,i=0;i>>o}},t.H.M=function(e,r,n){n=n<<(r&7);var o=r>>>3;e[o]|=n,e[o+1]|=n>>>8},t.H.I=function(e,r,n){n=n<<(r&7);var o=r>>>3;e[o]|=n,e[o+1]|=n>>>8,e[o+2]|=n>>>16},t.H.e=function(e,r,n){return(e[r>>>3]|e[(r>>>3)+1]<<8)>>>(r&7)&(1<>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16)>>>(r&7)&(1<>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16)>>>(r&7)},t.H.i=function(e,r){return(e[r>>>3]|e[(r>>>3)+1]<<8|e[(r>>>3)+2]<<16|e[(r>>>3)+3]<<24)>>>(r&7)},t.H.m=function(){var e=Uint16Array,r=Uint32Array;return{K:new e(16),j:new e(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new e(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new r(32),J:new e(512),_:[],h:new e(32),$:[],w:new e(32768),C:[],v:[],d:new e(32768),D:[],u:new e(512),Q:[],r:new e(32768),s:new r(286),Y:new r(30),a:new r(19),t:new r(15e3),k:new e(65536),g:new e(32768)}}(),function(){for(var e=t.H.m,r=32768,n=0;n>>1|(o&1431655765)<<1,o=(o&3435973836)>>>2|(o&858993459)<<2,o=(o&4042322160)>>>4|(o&252645135)<<4,o=(o&4278255360)>>>8|(o&16711935)<<8,e.r[n]=(o>>>16|o<<16)>>>17}function i(a,s,f){for(;s--!=0;)a.push(0,f)}for(var n=0;n<32;n++)e.q[n]=e.S[n]<<3|e.T[n],e.c[n]=e.p[n]<<4|e.z[n];i(e._,144,8),i(e._,112,9),i(e._,24,7),i(e._,8,8),t.H.n(e._,9),t.H.A(e._,9,e.J),t.H.l(e._,9),i(e.$,32,5),t.H.n(e.$,5),t.H.A(e.$,5,e.h),t.H.l(e.$,5),i(e.Q,19,0),i(e.C,286,0),i(e.D,30,0),i(e.v,320,0)}(),t.H.N}();B.decode._readInterlace=function(t,e){for(var r=e.width,n=e.height,o=B.decode._getBPP(e),i=o>>3,a=Math.ceil(r*o/8),s=new Uint8Array(n*a),f=0,l=[0,0,4,0,2,0,1],c=[0,4,0,2,0,1,0],u=[8,8,8,4,4,2,2],d=[8,8,4,4,2,2,1],p=0;p<7;){for(var h=u[p],b=d[p],F=0,x=0,m=l[p];m>3];E=E>>7-(C&7)&1,s[D*a+(T>>3)]|=E<<7-((T&7)<<0)}if(o==2){var E=t[C>>3];E=E>>6-(C&7)&3,s[D*a+(T>>2)]|=E<<6-((T&3)<<1)}if(o==4){var E=t[C>>3];E=E>>4-(C&7)&15,s[D*a+(T>>1)]|=E<<4-((T&1)<<2)}if(o>=8)for(var I=D*a+T*i,A=0;A>3)+A];C+=o,T+=b}S++,D+=h}F*x!=0&&(f+=x*(1+w)),p=p+1}return s};B.decode._getBPP=function(t){var e=[1,null,3,1,2,null,4][t.ctype];return e*t.depth};B.decode._filterZero=function(t,e,r,n,o){var i=B.decode._getBPP(e),a=Math.ceil(n*i/8),s=B.decode._paeth;i=Math.ceil(i/8);var f=0,l=1,c=t[r],u=0;if(c>1&&(t[r]=[0,0,1][c-2]),c==3)for(u=i;u>>1)&255;for(var d=0;d>>1);for(;u>>1)}else{for(;u>8&255,t[e+1]=r&255},readUint:function(t,e){return t[e]*(256*256*256)+(t[e+1]<<16|t[e+2]<<8|t[e+3])},writeUint:function(t,e,r){t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=r&255},readASCII:function(t,e,r){for(var n="",o=0;o=0&&s>=0?(u=p*e+h<<2,d=(s+p)*o+a+h<<2):(u=(-s+p)*e-a+h<<2,d=p*o+h<<2),f==0)n[d]=t[u],n[d+1]=t[u+1],n[d+2]=t[u+2],n[d+3]=t[u+3];else if(f==1){var b=t[u+3]*.00392156862745098,F=t[u]*b,x=t[u+1]*b,m=t[u+2]*b,y=n[d+3]*(1/255),w=n[d]*y,S=n[d+1]*y,D=n[d+2]*y,T=1-b,C=b+y*T,E=C==0?0:1/C;n[d+3]=255*C,n[d+0]=(F+w*T)*E,n[d+1]=(x+S*T)*E,n[d+2]=(m+D*T)*E}else if(f==2){var b=t[u+3],F=t[u],x=t[u+1],m=t[u+2],y=n[d+3],w=n[d],S=n[d+1],D=n[d+2];b==y&&F==w&&x==S&&m==D?(n[d]=0,n[d+1]=0,n[d+2]=0,n[d+3]=0):(n[d]=F,n[d+1]=x,n[d+2]=m,n[d+3]=b)}else if(f==3){var b=t[u+3],F=t[u],x=t[u+1],m=t[u+2],y=n[d+3],w=n[d],S=n[d+1],D=n[d+2];if(b==y&&F==w&&x==S&&m==D)continue;if(b<220&&y>20)return!1}return!0};B.encode=function(t,e,r,n,o,i,a){n==null&&(n=0),a==null&&(a=!1);var s=B.encode.compress(t,e,r,n,[!1,!1,!1,0,a]);return B.encode.compressPNG(s,-1),B.encode._main(s,e,r,o,i)};B.encodeLL=function(t,e,r,n,o,i,a,s){for(var f={ctype:0+(n==1?0:2)+(o==0?0:4),depth:i,frames:[]},l=Date.now(),c=(n+o)*i,u=c*e,d=0;d1,u=!1,d=33+(c?20:0);if(o.sRGB!=null&&(d+=13),o.pHYs!=null&&(d+=21),t.ctype==3){for(var p=t.plte.length,h=0;h>>24!=255&&(u=!0);d+=8+p*3+4+(u?8+p*1+4:0)}for(var b=0;b>>8&255,T=w>>>16&255;x[l+y+0]=S,x[l+y+1]=D,x[l+y+2]=T}if(l+=p*3,a(x,l,i(x,l-p*3-4,p*3+4)),l+=4,u){a(x,l,p),l+=4,f(x,l,"tRNS"),l+=4;for(var h=0;h>>24&255;l+=p,a(x,l,i(x,l-p-4,p+4)),l+=4}}for(var C=0,b=0;b>2,R>>2));for(var p=0;pX&&L==M[F-X])te[F]=te[F-X];else{var ue=y[L];if(ue==null&&(y[L]=ue=w.length,w.push(L),w.length>=300))break;te[F]=ue}}}var ye=w.length;ye<=256&&l==!1&&(ye<=2?u=1:ye<=4?u=2:ye<=16?u=4:u=8,u=Math.max(u,f));for(var p=0;p>1)]|=Vo[Wo+we]<<4-(we&1)*4;else if(u==2)for(var we=0;we>2)]|=Vo[Wo+we]<<6-(we&3)*2;else if(u==1)for(var we=0;we>3)]|=Vo[Wo+we]<<7-(we&7)*1}Be=wt,c=3,Gi=1}else if(x==!1&&m.length==1){for(var wt=new Uint8Array(X*Ce*3),$u=X*Ce,F=0;F<$u;F++){var A=F*3,Ki=F*4;wt[A]=Be[Ki],wt[A+1]=Be[Ki+1],wt[A+2]=Be[Ki+2]}Be=wt,c=2,Gi=3,En=3*X}z.img=Be,z.bpl=En,z.bpp=Gi}return{ctype:c,depth:u,plte:w,frames:m}};B.encode.framize=function(t,e,r,n,o,i){for(var a=[],s=0;sT&&(T=I),EC&&(C=E))}T==-1&&(S=D=T=C=0),o&&((S&1)==1&&S--,(D&1)==1&&D--);var R=(T-S+1)*(C-D+1);RF&&(F=w),Sx&&(x=S))}F==-1&&(h=b=F=x=0),a&&((h&1)==1&&h--,(b&1)==1&&b--),i={x:h,y:b,width:F-h+1,height:x-b+1};var C=n[o];C.rect=i,C.blend=1,C.img=new Uint8Array(i.width*i.height*4),n[o-1].dispose==0?(B._copyTile(l,e,r,C.img,i.width,i.height,-i.x,-i.y,0),B.encode._prepareDiff(d,e,r,C.img,i)):B._copyTile(d,e,r,C.img,i.width,i.height,-i.x,-i.y,0)};B.encode._prepareDiff=function(t,e,r,n,o){B._copyTile(t,e,r,n,o.width,o.height,-o.x,-o.y,2)};B.encode._filterZero=function(t,e,r,n,o,i,a){var s=[],f=[0,1,2,3,4];i!=-1?f=[i]:(e*n>5e5||r==1)&&(f=[0]);var l;a&&(l={level:0});for(var c=a&&UZIP!=null?UZIP:jc.default,u=0;u>1)+256&255;if(i==4)for(var l=o;l>1)&255;for(var l=o;l>1)&255}if(i==4){for(var l=0;l>>1:r=r>>>1;t[e]=r}return t}(),update:function(t,e,r,n){for(var o=0;o>>8;return t},crc:function(t,e,r){return B.crc.update(4294967295,t,e,r)^4294967295}};B.quantize=function(t,e){for(var r=new Uint8Array(t),n=r.slice(0),o=new Uint32Array(n.buffer),i=B.quantize.getKDtree(n,e),a=i[0],s=i[1],f=B.quantize.planeDst,l=r,c=o,u=l.length,d=new Uint8Array(r.length>>2),p=0;p>2]=m.ind,c[p>>2]=m.est.rgba}return{abuf:n.buffer,inds:d,plte:s}};B.quantize.getKDtree=function(t,e,r){r==null&&(r=1e-4);var n=new Uint32Array(t.buffer),o={i0:0,i1:t.length,bst:null,est:null,tdst:0,left:null,right:null};o.bst=B.quantize.stats(t,o.i0,o.i1),o.est=B.quantize.estats(o.bst);for(var i=[o];i.lengtha&&(a=i[f].est.L,s=f);if(a=c||l.i1<=c;if(u){l.est.L=0;continue}var d={i0:l.i0,i1:c,bst:null,est:null,tdst:0,left:null,right:null};d.bst=B.quantize.stats(t,d.i0,d.i1),d.est=B.quantize.estats(d.bst);var p={i0:c,i1:l.i1,bst:null,est:null,tdst:0,left:null,right:null};p.bst={R:[],m:[],N:l.bst.N-d.bst.N};for(var f=0;f<16;f++)p.bst.R[f]=l.bst.R[f]-d.bst.R[f];for(var f=0;f<4;f++)p.bst.m[f]=l.bst.m[f]-d.bst.m[f];p.est=B.quantize.estats(p.bst),l.left=d,l.right=p,i[s]=d,i.push(p)}i.sort(function(h,b){return b.bst.N-h.bst.N});for(var f=0;f0&&(a=t.right,s=t.left);var f=B.quantize.getNearest(a,e,r,n,o);if(f.tdst<=i*i)return f;var l=B.quantize.getNearest(s,e,r,n,o);return l.tdsti;)n-=4;if(r>=n)break;var f=e[r>>2];e[r>>2]=e[n>>2],e[n>>2]=f,r+=4,n-=4}for(;a(t,r,o)>i;)r-=4;return r+4};B.quantize.vecDot=function(t,e,r){return t[e]*r[0]+t[e+1]*r[1]+t[e+2]*r[2]+t[e+3]*r[3]};B.quantize.stats=function(t,e,r){for(var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o=[0,0,0,0],i=r-e>>2,a=e;a>>0}};B.M4={multVec:function(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3],t[4]*e[0]+t[5]*e[1]+t[6]*e[2]+t[7]*e[3],t[8]*e[0]+t[9]*e[1]+t[10]*e[2]+t[11]*e[3],t[12]*e[0]+t[13]*e[1]+t[14]*e[2]+t[15]*e[3]]},dot:function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},sml:function(t,e){return[t*e[0],t*e[1],t*e[2],t*e[3]]}};B.encode.concatRGBA=function(t){for(var e=0,r=0;r1)throw new Error("Animated PNGs are not supported");var o=new Uint8Array(n[0]),i=y0(o),a=i.rgbChannel,s=i.alphaChannel;this.rgbChannel=a;var f=s.some(function(l){return l<255});f&&(this.alphaChannel=s),this.type=g0(r.ctype),this.width=r.width,this.height=r.height,this.bitsPerComponent=8}return t.load=function(e){return new t(e)},t}();var b0=function(){function t(e){this.image=e,this.bitsPerComponent=e.bitsPerComponent,this.width=e.width,this.height=e.height,this.colorSpace="DeviceRGB"}return t.for=function(e){return V(this,void 0,void 0,function(){var r;return q(this,function(n){return r=Lc.load(e),[2,new t(r)]})})},t.prototype.embedIntoContext=function(e,r){return V(this,void 0,void 0,function(){var n,o;return q(this,function(i){return n=this.embedAlphaChannel(e),o=e.flateStream(this.image.rgbChannel,{Type:"XObject",Subtype:"Image",BitsPerComponent:this.image.bitsPerComponent,Width:this.image.width,Height:this.image.height,ColorSpace:this.colorSpace,SMask:n}),r?(e.assign(r,o),[2,r]):[2,e.register(o)]})})},t.prototype.embedAlphaChannel=function(e){if(this.image.alphaChannel){var r=e.flateStream(this.image.alphaChannel,{Type:"XObject",Subtype:"Image",Height:this.image.height,Width:this.image.width,BitsPerComponent:this.image.bitsPerComponent,ColorSpace:"DeviceGray",Decode:[0,1]});return e.register(r)}},t}(),co=b0;var x0=function(){function t(e,r,n){this.bytes=e,this.start=r||0,this.pos=this.start,this.end=r&&n?r+n:this.bytes.length}return Object.defineProperty(t.prototype,"length",{get:function(){return this.end-this.start},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEmpty",{get:function(){return this.length===0},enumerable:!1,configurable:!0}),t.prototype.getByte=function(){return this.pos>=this.end?-1:this.bytes[this.pos++]},t.prototype.getUint16=function(){var e=this.getByte(),r=this.getByte();return e===-1||r===-1?-1:(e<<8)+r},t.prototype.getInt32=function(){var e=this.getByte(),r=this.getByte(),n=this.getByte(),o=this.getByte();return(e<<24)+(r<<16)+(n<<8)+o},t.prototype.getBytes=function(e,r){r===void 0&&(r=!1);var n=this.bytes,o=this.pos,i=this.end;if(e){var s=o+e;s>i&&(s=i),this.pos=s;var a=n.subarray(o,s);return r?new Uint8ClampedArray(a):a}else{var a=n.subarray(o,i);return r?new Uint8ClampedArray(a):a}},t.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},t.prototype.peekBytes=function(e,r){r===void 0&&(r=!1);var n=this.getBytes(e,r);return this.pos-=n.length,n},t.prototype.skip=function(e){e||(e=1),this.pos+=e},t.prototype.reset=function(){this.pos=this.start},t.prototype.moveStart=function(){this.start=this.pos},t.prototype.makeSubStream=function(e,r){return new t(this.bytes,e,r)},t.prototype.decode=function(){return this.bytes},t}(),Si=x0;var F0=new Uint8Array(0),w0=function(){function t(e){if(this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=F0,this.minBufferLength=512,e)for(;this.minBufferLengthi&&(n=i)}else{for(;!this.eof;)this.readBlock();n=this.bufferLength}this.pos=n;var a=this.buffer.subarray(o,n);return r&&!(a instanceof Uint8ClampedArray)?new Uint8ClampedArray(a):a},t.prototype.peekByte=function(){var e=this.getByte();return this.pos--,e},t.prototype.peekBytes=function(e,r){r===void 0&&(r=!1);var n=this.getBytes(e,r);return this.pos-=n.length,n},t.prototype.skip=function(e){e||(e=1),this.pos+=e},t.prototype.reset=function(){this.pos=0},t.prototype.makeSubStream=function(e,r){for(var n=e+r;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Si(this.buffer,e,r)},t.prototype.decode=function(){for(;!this.eof;)this.readBlock();return this.buffer.subarray(0,this.bufferLength)},t.prototype.readBlock=function(){throw new Le(this.constructor.name,"readBlock")},t.prototype.ensureBuffer=function(e){var r=this.buffer;if(e<=r.byteLength)return r;for(var n=this.minBufferLength;n=0;--l)f[s+l]=u&255,u>>=8}},e}(At),Uc=S0;var P0=function(t){k(e,t);function e(r,n){var o=t.call(this,n)||this;return o.stream=r,o.firstDigit=-1,n&&(n=.5*n),o}return e.prototype.readBlock=function(){var r=8e3,n=this.stream.getBytes(r);if(!n.length){this.eof=!0;return}for(var o=n.length+1>>1,i=this.ensureBuffer(this.bufferLength+o),a=this.bufferLength,s=this.firstDigit,f=0,l=n.length;f=48&&c<=57)u=c&15;else if(c>=65&&c<=70||c>=97&&c<=102)u=(c&15)+9;else if(c===62){this.eof=!0;break}else continue;s<0?s=u:(i[a++]=s<<4|u,s=-1)}s>=0&&this.eof&&(i[a++]=s<<4,s=-1),this.firstDigit=s,this.bufferLength=a},e}(At),Vc=P0;var qc=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),D0=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),C0=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),k0=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],T0=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5],E0=function(t){k(e,t);function e(r,n){var o=t.call(this,n)||this;o.stream=r;var i=r.getByte(),a=r.getByte();if(i===-1||a===-1)throw new Error("Invalid header in flate stream: "+i+", "+a);if((i&15)!==8)throw new Error("Unknown compression method in flate stream: "+i+", "+a);if(((i<<8)+a)%31!==0)throw new Error("Bad FCHECK in flate stream: "+i+", "+a);if(a&32)throw new Error("FDICT bit set in flate stream: "+i+", "+a);return o.codeSize=0,o.codeBuf=0,o}return e.prototype.readBlock=function(){var r,n,o=this.stream,i=this.getBits(3);if(i&1&&(this.eof=!0),i>>=1,i===0){var a=void 0;if((a=o.getByte())===-1)throw new Error("Bad block header in flate stream");var s=a;if((a=o.getByte())===-1)throw new Error("Bad block header in flate stream");if(s|=a<<8,(a=o.getByte())===-1)throw new Error("Bad block header in flate stream");var f=a;if((a=o.getByte())===-1)throw new Error("Bad block header in flate stream");if(f|=a<<8,f!==(~s&65535)&&(s!==0||f!==0))throw new Error("Bad uncompressed block length in flate stream");this.codeBuf=0,this.codeSize=0;var l=this.bufferLength;r=this.ensureBuffer(l+s);var c=l+s;if(this.bufferLength=c,s===0)o.peekByte()===-1&&(this.eof=!0);else for(var u=l;u0;)S[m++]=C}d=this.generateHuffmanTable(S.subarray(0,h)),p=this.generateHuffmanTable(S.subarray(h,w))}else throw new Error("Unknown block type in flate stream");r=this.buffer;for(var A=r?r.length:0,R=this.bufferLength;;){var z=this.getCode(d);if(z<256){R+1>=A&&(r=this.ensureBuffer(R+1),A=r.length),r[R++]=z;continue}if(z===256){this.bufferLength=R;return}z-=257,z=D0[z];var M=z>>16;M>0&&(M=this.getBits(M)),n=(z&65535)+M,z=this.getCode(p),z=C0[z],M=z>>16,M>0&&(M=this.getBits(M));var X=(z&65535)+M;R+n>=A&&(r=this.ensureBuffer(R+n),A=r.length);for(var te=0;te>r,this.codeSize=o-=r,a},e.prototype.getCode=function(r){for(var n=this.stream,o=r[0],i=r[1],a=this.codeSize,s=this.codeBuf,f;a>16,u=l&65535;if(c<1||a>c,this.codeSize=a-c,u},e.prototype.generateHuffmanTable=function(r){var n=r.length,o=0,i;for(i=0;io&&(o=r[i]);for(var a=1<>=1;for(i=d;i0;if(!S||S<256)F[0]=S,x=1;else if(S>=258)if(S=0;a--)F[a]=u[s],s=p[s];else F[x++]=F[0];else if(S===256){h=9,c=258,x=0;continue}else{this.eof=!0,delete this.lzwState;break}if(D&&(p[c]=b,d[c]=d[b]+1,u[c]=F[0],c++,h=c+l&c+l-1?h:Math.min(Math.log(c+l)/.6931471805599453+1,12)|0),b=S,m+=x,n>>n&(1<0){var a=this.stream.getBytes(i);n.set(a,o),o+=i}}else{i=257-i;var s=r[1];n=this.ensureBuffer(o+i+1);for(var f=0;fn.size())throw new nn(r,0,n.size());n.remove(r)}else{if(r!==0)throw new nn(r,0,0);this.setKids([])}},e.prototype.normalizedEntries=function(){var r=this.Kids();return r||(r=this.dict.context.obj([this.ref]),this.dict.set(v.of("Kids"),r)),{Kids:r}},e.fromDict=function(r,n){return new e(r,n)},e}(vo),it=V0;var q0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.Opt=function(){return this.dict.lookupMaybe(v.of("Opt"),ne,H,Z)},e.prototype.setOpt=function(r){this.dict.set(v.of("Opt"),this.dict.context.obj(r))},e.prototype.getExportValues=function(){var r=this.Opt();if(r){if(r instanceof ne||r instanceof H)return[r];for(var n=[],o=0,i=r.size();on.size())throw new nn(r,0,n.size());n.remove(r)}},e.prototype.normalizeExportValues=function(){for(var r,n,o,i,a=(r=this.getExportValues())!==null&&r!==void 0?r:[],s=[],f=this.getWidgets(),l=0,c=f.length;l1){if(!this.hasFlag(le.MultiSelect))throw new vc;this.dict.set(v.of("V"),this.dict.context.obj(r))}this.updateSelectedIndices(r)},e.prototype.valuesAreValid=function(r){for(var n=this.getOptions(),o=function(f,l){var c=r[f].decodeText();if(!n.find(function(u){return c===(u.display||u.value).decodeText()}))return{value:!1}},i=0,a=r.length;i1){for(var n=new Array(r.length),o=this.getOptions(),i=function(f,l){var c=r[f].decodeText();n[f]=o.findIndex(function(u){return c===(u.display||u.value).decodeText()})},a=0,s=r.length;a0){var s=a.lookup(0,ne,H),f=a.lookupMaybe(1,ne,H);n.push({value:s,display:f||s})}}return n}return[]},e}(it),go=G0;var K0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Ch",Ff:le.Combo,Kids:[]}),o=r.register(n);return new e(n,o)},e}(go),rr=K0;var X0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.addField=function(r){var n=this.normalizedEntries().Kids;n?.push(r)},e.prototype.normalizedEntries=function(){var r=this.Kids();return r||(r=this.dict.context.obj([]),this.dict.set(v.of("Kids"),r)),{Kids:r}},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({}),o=r.register(n);return new e(n,o)},e}(vo),nr=X0;var Z0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e}(it),Nr=Z0;var Y0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.MaxLen=function(){var r=this.dict.lookup(v.of("MaxLen"));if(r instanceof j)return r},e.prototype.Q=function(){var r=this.dict.lookup(v.of("Q"));if(r instanceof j)return r},e.prototype.setMaxLength=function(r){this.dict.set(v.of("MaxLen"),j.of(r))},e.prototype.removeMaxLength=function(){this.dict.delete(v.of("MaxLen"))},e.prototype.getMaxLength=function(){var r;return(r=this.MaxLen())===null||r===void 0?void 0:r.asNumber()},e.prototype.setQuadding=function(r){this.dict.set(v.of("Q"),j.of(r))},e.prototype.getQuadding=function(){var r;return(r=this.Q())===null||r===void 0?void 0:r.asNumber()},e.prototype.setValue=function(r){this.dict.set(v.of("V"),r)},e.prototype.removeValue=function(){this.dict.delete(v.of("V"))},e.prototype.getValue=function(){var r=this.V();if(r instanceof ne||r instanceof H)return r},e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Tx",Kids:[]}),o=r.register(n);return new e(n,o)},e}(it),or=Y0;var J0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.fromDict=function(r,n){return new e(r,n)},e.create=function(r){var n=r.obj({FT:"Btn",Ff:qe.PushButton,Kids:[]}),o=r.register(n);return new e(n,o)},e}(Br),ir=J0;var Q0=function(t){k(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.setValue=function(r){var n=this.getOnValues();if(!n.includes(r)&&r!==v.of("Off"))throw new on;this.dict.set(v.of("V"),r);for(var o=this.getWidgets(),i=0,a=o.length;ii)throw new Ma(n,i);for(var a=n,s=0,f=o.size();sa)return c.insertLeafNode(r,a)||l;a-=c.Count().asNumber()}c instanceof Ze&&(a-=1)}if(a===0){this.insertLeafKid(o.size(),r);return}throw new Ia(n,"insertLeafNode")},e.prototype.removeLeafNode=function(r,n){n===void 0&&(n=!0);var o=this.Kids(),i=this.Count().asNumber();if(r>=i)throw new Ma(r,i);for(var a=r,s=0,f=o.size();sa){c.removeLeafNode(a,n),n&&c.Kids().size()===0&&o.remove(s);return}else a-=c.Count().asNumber();if(c instanceof Ze)if(a===0){this.removeKid(s);return}else a-=1}throw new Ia(r,"removeLeafNode")},e.prototype.ascend=function(r){r(this);var n=this.Parent();n&&n.ascend(r)},e.prototype.traverse=function(r){for(var n=this.Kids(),o=0,i=n.size();oNumber.MAX_SAFE_INTEGER)if(this.capNumbers){var o="Parsed number that is too large for some PDF readers: "+e+", using Number.MAX_SAFE_INTEGER instead.";return console.warn(o),Number.MAX_SAFE_INTEGER}else{var o="Parsed number that is too large for some PDF readers: "+e+", not capping.";console.warn(o)}return n},t.prototype.skipWhitespace=function(){for(;!this.bytes.done()&&ft[this.bytes.peek()];)this.bytes.next()},t.prototype.skipLine=function(){for(;!this.bytes.done();){var e=this.bytes.peek();if(e===Jc||e===Qc)return;this.bytes.next()}},t.prototype.skipComment=function(){if(this.bytes.peek()!==g.Percent)return!1;for(;!this.bytes.done();){var e=this.bytes.peek();if(e===Jc||e===Qc)return!0;this.bytes.next()}return!0},t.prototype.skipWhitespaceAndComments=function(){for(this.skipWhitespace();this.skipComment();)this.skipWhitespace()},t.prototype.matchKeyword=function(e){for(var r=this.bytes.offset(),n=0,o=e.length;n=this.length},t.prototype.offset=function(){return this.idx},t.prototype.slice=function(e,r){return this.bytes.slice(e,r)},t.prototype.position=function(){return{line:this.line,column:this.column,offset:this.idx}},t.of=function(e){return new t(e)},t.fromPDFRawStream=function(e){return t.of(uo(e).decode())},t}(),lr=sv;var lv=g.Space,wo=g.CarriageReturn,So=g.Newline,Po=[g.s,g.t,g.r,g.e,g.a,g.m],Ti=[g.e,g.n,g.d,g.s,g.t,g.r,g.e,g.a,g.m],pe={header:[g.Percent,g.P,g.D,g.F,g.Dash],eof:[g.Percent,g.Percent,g.E,g.O,g.F],obj:[g.o,g.b,g.j],endobj:[g.e,g.n,g.d,g.o,g.b,g.j],xref:[g.x,g.r,g.e,g.f],trailer:[g.t,g.r,g.a,g.i,g.l,g.e,g.r],startxref:[g.s,g.t,g.a,g.r,g.t,g.x,g.r,g.e,g.f],true:[g.t,g.r,g.u,g.e],false:[g.f,g.a,g.l,g.s,g.e],null:[g.n,g.u,g.l,g.l],stream:Po,streamEOF1:re(Po,[lv,wo,So]),streamEOF2:re(Po,[wo,So]),streamEOF3:re(Po,[wo]),streamEOF4:re(Po,[So]),endstream:Ti,EOF1endstream:re([wo,So],Ti),EOF2endstream:re([wo],Ti),EOF3endstream:re([So],Ti)};var fv=function(t){k(e,t);function e(r,n,o){o===void 0&&(o=!1);var i=t.call(this,r,o)||this;return i.context=n,i}return e.prototype.parseObject=function(){if(this.skipWhitespaceAndComments(),this.matchKeyword(pe.true))return Ut.True;if(this.matchKeyword(pe.false))return Ut.False;if(this.matchKeyword(pe.null))return Te;var r=this.bytes.peek();if(r===g.LessThan&&this.bytes.peekAhead(1)===g.LessThan)return this.parseDictOrStream();if(r===g.LessThan)return this.parseHexString();if(r===g.LeftParen)return this.parseString();if(r===g.ForwardSlash)return this.parseName();if(r===g.LeftSquareBracket)return this.parseArray();if(Fo[r])return this.parseNumberOrRef();throw new bc(this.bytes.position(),r)},e.prototype.parseNumberOrRef=function(){var r=this.parseRawNumber();this.skipWhitespaceAndComments();var n=this.bytes.offset();if(Ie[this.bytes.peek()]){var o=this.parseRawNumber();if(this.skipWhitespaceAndComments(),this.bytes.peek()===g.R)return this.bytes.assertNext(g.R),J.of(r,o)}return this.bytes.moveTo(n),j.of(r)},e.prototype.parseHexString=function(){var r="";for(this.bytes.assertNext(g.LessThan);!this.bytes.done()&&this.bytes.peek()!==g.GreaterThan;)r+=tt(this.bytes.next());return this.bytes.assertNext(g.GreaterThan),H.of(r)},e.prototype.parseString=function(){for(var r=0,n=!1,o="";!this.bytes.done();){var i=this.bytes.next();if(o+=tt(i),n||(i===g.LeftParen&&(r+=1),i===g.RightParen&&(r-=1)),i===g.BackSlash?n=!n:n&&(n=!1),r===0)return ne.of(o.substring(1,o.length-1))}throw new wc(this.bytes.position())},e.prototype.parseName=function(){this.bytes.assertNext(g.ForwardSlash);for(var r="";!this.bytes.done();){var n=this.bytes.peek();if(ft[n]||et[n])break;r+=tt(n),this.bytes.next()}return v.of(r)},e.prototype.parseArray=function(){this.bytes.assertNext(g.LeftSquareBracket),this.skipWhitespaceAndComments();for(var r=Z.withContext(this.context);this.bytes.peek()!==g.RightSquareBracket;){var n=this.parseObject();r.push(n),this.skipWhitespaceAndComments()}return this.bytes.assertNext(g.RightSquareBracket),r},e.prototype.parseDict=function(){this.bytes.assertNext(g.LessThan),this.bytes.assertNext(g.LessThan),this.skipWhitespaceAndComments();for(var r=new Map;!this.bytes.done()&&this.bytes.peek()!==g.GreaterThan&&this.bytes.peekAhead(1)!==g.GreaterThan;){var n=this.parseName(),o=this.parseObject();r.set(n,o),this.skipWhitespaceAndComments()}this.skipWhitespaceAndComments(),this.bytes.assertNext(g.GreaterThan),this.bytes.assertNext(g.GreaterThan);var i=r.get(v.of("Type"));return i===v.of("Catalog")?bo.fromMapWithContext(r,this.context):i===v.of("Pages")?xo.fromMapWithContext(r,this.context):i===v.of("Page")?Ze.fromMapWithContext(r,this.context):U.fromMapWithContext(r,this.context)},e.prototype.parseDictOrStream=function(){var r=this.bytes.position(),n=this.parseDict();if(this.skipWhitespaceAndComments(),!this.matchKeyword(pe.streamEOF1)&&!this.matchKeyword(pe.streamEOF2)&&!this.matchKeyword(pe.streamEOF3)&&!this.matchKeyword(pe.streamEOF4)&&!this.matchKeyword(pe.stream))return n;var o=this.bytes.offset(),i,a=n.get(v.of("Length"));a instanceof j?(i=o+a.asNumber(),this.bytes.moveTo(i),this.skipWhitespaceAndComments(),this.matchKeyword(pe.endstream)||(this.bytes.moveTo(o),i=this.findEndOfStreamFallback(r))):i=this.findEndOfStreamFallback(r);var s=this.bytes.slice(o,i);return Et.of(n,s)},e.prototype.findEndOfStreamFallback=function(r){for(var n=1,o=this.bytes.offset();!this.bytes.done()&&(o=this.bytes.offset(),this.matchKeyword(pe.stream)?n+=1:this.matchKeyword(pe.EOF1endstream)||this.matchKeyword(pe.EOF2endstream)||this.matchKeyword(pe.EOF3endstream)||this.matchKeyword(pe.endstream)?n-=1:this.bytes.next(),n!==0););if(n!==0)throw new Fc(r);return o},e.forBytes=function(r,n,o){return new e(lr.of(r),n,o)},e.forByteStream=function(r,n,o){return o===void 0&&(o=!1),new e(r,n,o)},e}(_c),Do=fv;var cv=function(t){k(e,t);function e(r,n){var o=t.call(this,lr.fromPDFRawStream(r),r.dict.context)||this,i=r.dict;return o.alreadyParsed=!1,o.shouldWaitForTick=n||function(){return!1},o.firstOffset=i.lookup(v.of("First"),j).asNumber(),o.objectCount=i.lookup(v.of("N"),j).asNumber(),o}return e.prototype.parseIntoContext=function(){return V(this,void 0,void 0,function(){var r,n,o,i,a,s,f,l;return q(this,function(c){switch(c.label){case 0:if(this.alreadyParsed)throw new rn("PDFObjectStreamParser","parseIntoContext");this.alreadyParsed=!0,r=this.parseOffsetsAndObjectNumbers(),n=0,o=r.length,c.label=1;case 1:return n=g.Space&&n<=g.Tilde;if(o&&(this.matchKeyword(pe.xref)||this.matchKeyword(pe.trailer)||this.matchKeyword(pe.startxref)||this.matchIndirectObjectHeader())){this.bytes.moveTo(r);break}this.bytes.next()}},e.prototype.skipBinaryHeaderComment=function(){this.skipWhitespaceAndComments();try{var r=this.bytes.offset();this.parseIndirectObjectHeader(),this.bytes.moveTo(r)}catch{this.bytes.next(),this.skipWhitespaceAndComments()}},e.forBytesWithOptions=function(r,n,o,i){return new e(r,n,o,i)},e}(Do),$a=dv;var Rt=function(t){return 1<0&&(n[n.length]=+o),r[r.length]={cmd:e,args:n},n=[],o="",i=!1),e=l;else if([" ",","].includes(l)||l==="-"&&o.length>0&&o[o.length-1]!=="e"||l==="."&&i){if(o.length===0)continue;n.length===a?(r[r.length]={cmd:e,args:n},n=[+o],e==="M"&&(e="L"),e==="m"&&(e="l")):n[n.length]=+o,i=l===".",o=["-","."].includes(l)?l:""}else o+=l,l==="."&&(i=!0)}return o.length>0&&(n.length===a?(r[r.length]={cmd:e,args:n},n=[+o],e==="M"&&(e="L"),e==="m"&&(e="l")):n[n.length]=+o),r[r.length]={cmd:e,args:n},r},mv=function(t){G=K=fe=ce=No=Mo=0;for(var e=[],r=0;r1&&(d=Math.sqrt(d),r*=d,n*=d);var p=u/r,h=c/r,b=-c/n,F=u/n,x=p*s+h*f,m=b*s+F*f,y=p*t+h*e,w=b*t+F*e,S=(y-x)*(y-x)+(w-m)*(w-m),D=1/S-.25;D<0&&(D=0);var T=Math.sqrt(D);i===o&&(T=-T);var C=.5*(x+y)-T*(w-m),E=.5*(m+w)+T*(y-x),I=Math.atan2(m-E,x-C),A=Math.atan2(w-E,y-C),R=A-I;R<0&&i===1?R+=2*Math.PI:R>0&&i===0&&(R-=2*Math.PI);for(var z=Math.ceil(Math.abs(R/(Math.PI*.5+.001))),M=[],X=0;Xt.length)return o-1;var F=e.heightAtSize(o),x=F+F*.2,m=x*i;if(m>Math.abs(r.height))return o-1;o+=1}return o},wv=function(t,e,r,n){for(var o=r.width/n,i=r.height,a=Ru,s=Is(t);ao*.75;if(u)return a-1}var d=e.heightAtSize(a,{descender:!1});if(d>i)return a-1;a+=1}return a},Sv=function(t){for(var e=t.length;e>0;e--)if(/\s/.test(t[e]))return e},Pv=function(t,e,r,n){for(var o,i=t.length;i>0;){var a=t.substring(0,i),s=r.encodeText(a),f=r.widthOfTextAtSize(a,n);if(fd&&(d=T+S),h+s>p&&(p=h+s),l.push({text:y,encoded:w,width:S,height:s,x:T,y:h}),x=D?.trim()}return{fontSize:n,lineHeight:f,lines:l,bounds:{x:c,y:u,width:d-c,height:p-u}}},Nu=function(t,e){var r=e.fontSize,n=e.font,o=e.bounds,i=e.cellCount,a=Zi(pr(t));if(a.length>i)throw new Tu(a.length,i);(r===void 0||r===0)&&(r=wv(a,n,o,i));for(var s=o.width/i,f=n.heightAtSize(r,{descender:!1}),l=o.y+(o.height/2-f/2),c=[],u=o.x,d=o.y,p=o.x+o.width,h=o.y+o.height,b=0,F=0;bp&&(p=T+S),l+f>h&&(h=l+f),c.push({text:a,encoded:w,width:S,height:f,x:T,y:l}),b+=1,F+=y}return{fontSize:r,cells:c,bounds:{x:u,y:d,width:p-u,height:h-d}}},jo=function(t,e){var r=e.alignment,n=e.fontSize,o=e.font,i=e.bounds,a=Zi(pr(t));(n===void 0||n===0)&&(n=Bu([a],o,i));var s=o.encodeText(a),f=o.widthOfTextAtSize(a,n),l=o.heightAtSize(n,{descender:!1}),c=r===De.Left?i.x:r===De.Center?i.x+i.width/2-f/2:r===De.Right?i.x+i.width-f:i.x,u=i.y+(i.height/2-l/2);return{fontSize:n,line:{text:a,encoded:s,width:f,height:l,x:c,y:u},bounds:{x:c,y:u,width:f,height:l}}};var pt=function(t){return"normal"in t?t:{normal:t}},Dv=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]+(\d*\.\d+|\d+)[\0\t\n\f\r\ ]+Tf/,dr=function(t){var e,r,n=(e=t.getDefaultAppearance())!==null&&e!==void 0?e:"",o=(r=On(n,Dv).match)!==null&&r!==void 0?r:[],i=Number(o[2]);return isFinite(i)?i:void 0},Cv=/(\d*\.\d+|\d+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+(g|rg|k)/,dt=function(t){var e,r=(e=t.getDefaultAppearance())!==null&&e!==void 0?e:"",n=On(r,Cv).match,o=n??[],i=o[1],a=o[2],s=o[3],f=o[4],l=o[5];if(l==="g"&&i)return fs(Number(i));if(l==="rg"&&i&&a&&s)return ae(Number(i),Number(a),Number(s));if(l==="k"&&i&&a&&s&&f)return cs(Number(i),Number(a),Number(s),Number(f))},ht=function(t,e,r,n){var o;n===void 0&&(n=0);var i=[Bt(e).toString(),Oo((o=r?.name)!==null&&o!==void 0?o:"dummy__noop",n).toString()].join(` +`);t.setDefaultAppearance(i)},Mu=function(t,e){var r,n,o,i=dt(e),a=dt(t.acroField),s=e.getRectangle(),f=e.getAppearanceCharacteristics(),l=e.getBorderStyle(),c=(r=l?.getWidth())!==null&&r!==void 0?r:0,u=bt(f?.getRotation()),d=qt(s,u),p=d.width,h=d.height,b=xt(Y(Y({},s),{rotation:u})),F=ae(0,0,0),x=(n=We(f?.getBorderColor()))!==null&&n!==void 0?n:F,m=We(f?.getBackgroundColor()),y=We(f?.getBackgroundColor(),.8),w=(o=i??a)!==null&&o!==void 0?o:F;ht(i?e:t.acroField,w);var S={x:0+c/2,y:0+c/2,width:p-c,height:h-c,thickness:1.5,borderWidth:c,borderColor:x,markColor:w};return{normal:{on:re(b,Io(Y(Y({},S),{color:m,filled:!0}))),off:re(b,Io(Y(Y({},S),{color:m,filled:!1})))},down:{on:re(b,Io(Y(Y({},S),{color:y,filled:!0}))),off:re(b,Io(Y(Y({},S),{color:y,filled:!1})))}}},Iu=function(t,e){var r,n,o,i=dt(e),a=dt(t.acroField),s=e.getRectangle(),f=e.getAppearanceCharacteristics(),l=e.getBorderStyle(),c=(r=l?.getWidth())!==null&&r!==void 0?r:0,u=bt(f?.getRotation()),d=qt(s,u),p=d.width,h=d.height,b=xt(Y(Y({},s),{rotation:u})),F=ae(0,0,0),x=(n=We(f?.getBorderColor()))!==null&&n!==void 0?n:F,m=We(f?.getBackgroundColor()),y=We(f?.getBackgroundColor(),.8),w=(o=i??a)!==null&&o!==void 0?o:F;ht(i?e:t.acroField,w);var S={x:p/2,y:h/2,width:p-c,height:h-c,borderWidth:c,borderColor:x,dotColor:w};return{normal:{on:re(b,zo(Y(Y({},S),{color:m,filled:!0}))),off:re(b,zo(Y(Y({},S),{color:m,filled:!1})))},down:{on:re(b,zo(Y(Y({},S),{color:y,filled:!0}))),off:re(b,zo(Y(Y({},S),{color:y,filled:!1})))}}},zu=function(t,e,r){var n,o,i,a,s,f=dt(e),l=dt(t.acroField),c=dr(e),u=dr(t.acroField),d=e.getRectangle(),p=e.getAppearanceCharacteristics(),h=e.getBorderStyle(),b=p?.getCaptions(),F=(n=b?.normal)!==null&&n!==void 0?n:"",x=(i=(o=b?.down)!==null&&o!==void 0?o:F)!==null&&i!==void 0?i:"",m=(a=h?.getWidth())!==null&&a!==void 0?a:0,y=bt(p?.getRotation()),w=qt(d,y),S=w.width,D=w.height,T=xt(Y(Y({},d),{rotation:y})),C=ae(0,0,0),E=We(p?.getBorderColor()),I=We(p?.getBackgroundColor()),A=We(p?.getBackgroundColor(),.8),R={x:m,y:m,width:S-m*2,height:D-m*2},z=jo(F,{alignment:De.Center,fontSize:c??u,font:r,bounds:R}),M=jo(x,{alignment:De.Center,fontSize:c??u,font:r,bounds:R}),X=Math.min(z.fontSize,M.fontSize),te=(s=f??l)!==null&&s!==void 0?s:C;ht(f||c!==void 0?e:t.acroField,te,r,X);var L={x:0+m/2,y:0+m/2,width:S-m,height:D-m,borderWidth:m,borderColor:E,textColor:te,font:r.name,fontSize:X};return{normal:re(T,vs(Y(Y({},L),{color:I,textLines:[z.line]}))),down:re(T,vs(Y(Y({},L),{color:A,textLines:[M.line]})))}},ju=function(t,e,r){var n,o,i,a,s=dt(e),f=dt(t.acroField),l=dr(e),c=dr(t.acroField),u=e.getRectangle(),d=e.getAppearanceCharacteristics(),p=e.getBorderStyle(),h=(n=t.getText())!==null&&n!==void 0?n:"",b=(o=p?.getWidth())!==null&&o!==void 0?o:0,F=bt(d?.getRotation()),x=qt(u,F),m=x.width,y=x.height,w=xt(Y(Y({},u),{rotation:F})),S=ae(0,0,0),D=We(d?.getBorderColor()),T=We(d?.getBackgroundColor()),C,E,I=t.isCombed()?0:1,A={x:b+I,y:b+I,width:m-(b+I)*2,height:y-(b+I)*2};if(t.isMultiline()){var R=bs(h,{alignment:t.getAlignment(),fontSize:l??c,font:r,bounds:A});C=R.lines,E=R.fontSize}else if(t.isCombed()){var R=Nu(h,{fontSize:l??c,font:r,bounds:A,cellCount:(i=t.getMaxLength())!==null&&i!==void 0?i:0});C=R.cells,E=R.fontSize}else{var R=jo(h,{alignment:t.getAlignment(),fontSize:l??c,font:r,bounds:A});C=[R.line],E=R.fontSize}var z=(a=s??f)!==null&&a!==void 0?a:S;ht(s||l!==void 0?e:t.acroField,z,r,E);var M={x:0+b/2,y:0+b/2,width:m-b,height:y-b,borderWidth:b??0,borderColor:D,textColor:z,font:r.name,fontSize:E,color:T,textLines:C,padding:I};return re(w,gs(M))},Lu=function(t,e,r){var n,o,i,a=dt(e),s=dt(t.acroField),f=dr(e),l=dr(t.acroField),c=e.getRectangle(),u=e.getAppearanceCharacteristics(),d=e.getBorderStyle(),p=(n=t.getSelected()[0])!==null&&n!==void 0?n:"",h=(o=d?.getWidth())!==null&&o!==void 0?o:0,b=bt(u?.getRotation()),F=qt(c,b),x=F.width,m=F.height,y=xt(Y(Y({},c),{rotation:b})),w=ae(0,0,0),S=We(u?.getBorderColor()),D=We(u?.getBackgroundColor()),T=1,C={x:h+T,y:h+T,width:x-(h+T)*2,height:m-(h+T)*2},E=jo(p,{alignment:De.Left,fontSize:f??l,font:r,bounds:C}),I=E.line,A=E.fontSize,R=(i=a??s)!==null&&i!==void 0?i:w;ht(a||f!==void 0?e:t.acroField,R,r,A);var z={x:0+h/2,y:0+h/2,width:x-h,height:m-h,borderWidth:h??0,borderColor:S,textColor:R,font:r.name,fontSize:A,color:D,textLines:[I],padding:T};return re(y,gs(z))},Hu=function(t,e,r){var n,o,i=dt(e),a=dt(t.acroField),s=dr(e),f=dr(t.acroField),l=e.getRectangle(),c=e.getAppearanceCharacteristics(),u=e.getBorderStyle(),d=(n=u?.getWidth())!==null&&n!==void 0?n:0,p=bt(c?.getRotation()),h=qt(l,p),b=h.width,F=h.height,x=xt(Y(Y({},l),{rotation:p})),m=ae(0,0,0),y=We(c?.getBorderColor()),w=We(c?.getBackgroundColor()),S=t.getOptions(),D=t.getSelected();t.isSorted()&&S.sort();for(var T="",C=0,E=S.length;C1||o.length===1&&n)&&this.enableMultiselect();for(var s=new Array(o.length),f=0,l=o.length;f1||o.length===1&&n)&&this.enableMultiselect();for(var a=new Array(o.length),s=0,f=o.length;sn)throw new Eu(r.length,n,this.getName());this.markAsDirty(),this.disableRichFormatting(),r?this.acroField.setValue(H.fromText(r)):this.acroField.removeValue()},e.prototype.getAlignment=function(){var r=this.acroField.getQuadding();return r===0?De.Left:r===1?De.Center:r===2?De.Right:De.Left},e.prototype.setAlignment=function(r){yt(r,"alignment",De),this.markAsDirty(),this.acroField.setQuadding(r)},e.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},e.prototype.setMaxLength=function(r){if(ot(r,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),r===void 0)this.acroField.removeMaxLength();else{var n=this.getText();if(n&&n.length>r)throw new Au(n.length,r,this.getName());this.acroField.setMaxLength(r)}},e.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},e.prototype.setImage=function(r){for(var n=this.getAlignment(),o=n===De.Center?Ft.Center:n===De.Right?Ft.Right:Ft.Left,i=this.acroField.getWidgets(),a=0,s=i.length;at/25.4*96;function Gv(t){return t.pageSize==="Custom"?{w:Math.max(1,Math.round(kn(t.customPageWidth))),h:Math.max(1,Math.round(kn(t.customPageHeight)))}:Vi[t.pageSize]??Vi.A4}function Ui(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function Gu(t){return t.replace(/<\/style/gi,"<\\/style")}function Cn(t,e){let r=e.trim();if(!r)return"";if(/^(https?:|data:)/i.test(r))return r;let n=t.vault.getAbstractFileByPath(r);if(n instanceof N.TFile)return t.vault.getResourcePath(n);let o=t.metadataCache.getFirstLinkpathDest(r,"");return o instanceof N.TFile?t.vault.getResourcePath(o):(console.warn("[advanced-pdf-export] Could not resolve image path:",r),r)}function Ku(t){return{size:t==="fill"?"100% 100%":t==="tile"?"auto":t,repeat:t==="tile"?"repeat":"no-repeat"}}var Kv=/[\u0590-\u08FF\uFB1D-\uFDFD\uFE70-\uFEFC]/g,Xv=/[A-Za-z\u0590-\u08FF\uFB1D-\uFDFD\uFE70-\uFEFC]/g;function Zv(t){let e=(t.match(Kv)??[]).length,r=(t.match(Xv)??[]).length;return r>0&&e/r>.1}function Yv(t){return t.replace(/\r\n|\r/g,` +`)}function Jv(t){return t.replace(/^---[ \t]*\n[\s\S]*?\n---[ \t]*(\n|$)/,"")}function Qv(t){return t.split(/^\/\/\/\s*$/m).map(e=>e.trim()).filter(Boolean)}async function _v(t,e,r,n){let o=activeDocument.createElement("div");o.setCssStyles({position:"fixed",top:"0",left:"-99999px",visibility:"hidden",pointerEvents:"none"}),activeDocument.body.appendChild(o);try{await N.MarkdownRenderer.render(t,e,o,r,n);try{await(0,N.finishRenderMath)()}catch{}await nm(o),await om(o);let i=activeDocument.fonts;if(i)try{await i.ready}catch{}}finally{activeDocument.body.removeChild(o)}return rm(o),o}var $v=/[^\p{L}\p{N}\s-]/gu,em=/\s+/g,tm=/-+/g;function Xu(t){return t.toLowerCase().replace($v,"").trim().replace(em,"-").replace(tm,"-")}function rm(t){let e=new Map;t.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(r=>{let n=r.textContent||"",o=Xu(n);if(!o)return;let i=e.get(o)??0;e.set(o,i+1),r.id=i===0?o:`${o}-${i}`}),t.querySelectorAll("a").forEach(r=>{r.classList.remove("external-link");let n=r.getAttribute("data-href")??r.getAttribute("href");n?.startsWith("#")&&r.setAttribute("href","#"+Xu(n.slice(1)))}),t.querySelectorAll(".copy-code-button").forEach(r=>r.remove()),t.querySelectorAll(".callout").forEach(r=>{r.removeAttribute("data-callout-fold"),r.classList.remove("is-collapsed"),r.querySelectorAll(".callout-fold").forEach(n=>n.remove())}),t.querySelectorAll("style, script").forEach(r=>{r.closest("svg")||r.remove()})}async function nm(t){let e=Array.from(t.querySelectorAll(".mermaid"));if(e.length===0)return;let r=5e3;await Promise.all(e.map(n=>new Promise(o=>{if(n.querySelector("svg")){o();return}let i=window.setTimeout(()=>{a.disconnect(),o()},r),a=new MutationObserver(()=>{n.querySelector("svg")&&(window.clearTimeout(i),a.disconnect(),o())});a.observe(n,{childList:!0,subtree:!0})})))}async function om(t){let e=Array.from(t.querySelectorAll(".math"));if(e.length===0)return;let r=window.MathJax;if(r?.startup?.promise)try{await r.startup.promise}catch{}let n=8e3;await Promise.all(e.filter(o=>!o.querySelector("mjx-container")).map(o=>new Promise(i=>{let a=window.setTimeout(()=>{s.disconnect(),i()},n),s=new MutationObserver(()=>{o.querySelector("mjx-container")&&(window.clearTimeout(a),s.disconnect(),i())});s.observe(o,{childList:!0,subtree:!0})}))),await Ps()}async function Ps(){let n=Date.now(),o=qi().length,i=0;for(;i<2&&Date.now()-n<2500;){await new Promise(s=>window.setTimeout(s,60));let a=qi().length;a===o?i++:(i=0,o=a)}}var im={comment:["comment","prolog","doctype","cdata"],punctuation:["punctuation"],property:["property","tag","boolean","number","constant","symbol","deleted","attr-name"],selector:["selector","string","char","builtin","inserted","attr-value"],operator:["operator","entity","url"],keyword:["atrule","keyword","important"],function:["function","class-name"],regex:["regex","variable"]},Ds={none:{name:"None (plain)"},"github-light":{name:"GitHub Light",background:"#f6f8fa",text:"#24292e",tokens:{comment:"#6a737d",punctuation:"#24292e",property:"#005cc5",selector:"#032f62",operator:"#d73a49",keyword:"#d73a49",function:"#6f42c1",regex:"#032f62"}},"github-dark":{name:"GitHub Dark",background:"#0d1117",text:"#c9d1d9",tokens:{comment:"#8b949e",punctuation:"#c9d1d9",property:"#79c0ff",selector:"#a5d6ff",operator:"#ff7b72",keyword:"#ff7b72",function:"#d2a8ff",regex:"#a5d6ff"}},"atom-one-light":{name:"Atom One Light",background:"#fafafa",text:"#383a42",tokens:{comment:"#a0a1a7",punctuation:"#383a42",property:"#986801",selector:"#50a14f",operator:"#0184bc",keyword:"#a626a4",function:"#4078f2",regex:"#50a14f"}},"atom-one-dark":{name:"Atom One Dark",background:"#282c34",text:"#abb2bf",tokens:{comment:"#5c6370",punctuation:"#abb2bf",property:"#d19a66",selector:"#98c379",operator:"#56b6c2",keyword:"#c678dd",function:"#61afef",regex:"#98c379"}},monokai:{name:"Monokai",background:"#272822",text:"#f8f8f2",tokens:{comment:"#75715e",punctuation:"#f8f8f2",property:"#ae81ff",selector:"#e6db74",operator:"#f92672",keyword:"#f92672",function:"#a6e22e",regex:"#e6db74"}},dracula:{name:"Dracula",background:"#282a36",text:"#f8f8f2",tokens:{comment:"#6272a4",punctuation:"#f8f8f2",property:"#bd93f9",selector:"#f1fa8c",operator:"#ff79c6",keyword:"#ff79c6",function:"#50fa7b",regex:"#ff79c6"}},"tokyo-night":{name:"Tokyo Night",background:"#1a1b26",text:"#a9b1d6",tokens:{comment:"#565f89",punctuation:"#89ddff",property:"#ff9e64",selector:"#9ece6a",operator:"#89ddff",keyword:"#bb9af7",function:"#7aa2f7",regex:"#b4f9f8"}},"solarized-light":{name:"Solarized Light",background:"#fdf6e3",text:"#586e75",tokens:{comment:"#93a1a1",punctuation:"#586e75",property:"#cb4b16",selector:"#2aa198",operator:"#859900",keyword:"#859900",function:"#268bd2",regex:"#2aa198"}},"catppuccin-macchiato":{name:"Catppuccin Macchiato",background:"#24273a",text:"#cad3f5",tokens:{comment:"#939ab7",punctuation:"#b8c0e0",property:"#f5a97f",selector:"#a6da95",operator:"#91d7e3",keyword:"#c6a0f6",function:"#8aadf4",regex:"#f5bde6"}},"catppuccin-mocha":{name:"Catppuccin Mocha",background:"#1e1e2e",text:"#cdd6f4",tokens:{comment:"#9399b2",punctuation:"#bac2de",property:"#fab387",selector:"#a6e3a1",operator:"#89dceb",keyword:"#cba6f7",function:"#89b4fa",regex:"#f5c2e7"}}};function am(t){let e=Ds[t.codeTheme]??Ds.none,r=e.background??t.codeBackground,n=e.text??t.bodyColor,o=Object.entries(e.tokens??{}).map(([i,a])=>`${im[i].map(l=>`.mpdf-doc pre code .token.${l}`).join(", ")} { color: ${a};${i==="comment"?" font-style: italic;":""} }`).join(` `);return` .mpdf-doc pre { background: ${r}; @@ -54,7 +54,7 @@ end`},Oc=function(){for(var t=[],e=0;e`#${s}${s}${f}${f}${l}${l}`);if(!/^#[\da-f]{6}$/i.test(e))return 1;let r=a=>a<=.04045?a/12.92:((a+.055)/1.055)**2.4,n=r(parseInt(e.slice(1,3),16)/255),o=r(parseInt(e.slice(3,5),16)/255),i=r(parseInt(e.slice(5,7),16)/255);return .2126*n+.7152*o+.0722*i}function Yu(t){return t.fontFamily==="__custom__"?t.customFontName.trim()||"inherit":t.fontFamily}function sm(t,e=!1){let r=t.headingScale,n=Yu(t),o=am(t.tableHeaderBg)<.35?"#fff":t.headingColor;return` + ${o}`}function sm(t){let e=t.replace(/^#([\da-f])([\da-f])([\da-f])$/i,(a,s,f,l)=>`#${s}${s}${f}${f}${l}${l}`);if(!/^#[\da-f]{6}$/i.test(e))return 1;let r=a=>a<=.04045?a/12.92:((a+.055)/1.055)**2.4,n=r(parseInt(e.slice(1,3),16)/255),o=r(parseInt(e.slice(3,5),16)/255),i=r(parseInt(e.slice(5,7),16)/255);return .2126*n+.7152*o+.0722*i}function Qu(t){return t.fontFamily==="__custom__"?t.customFontName.trim()||"inherit":t.fontFamily}function lm(t,e=!1){let r=t.headingScale,n=Qu(t),o=sm(t.tableHeaderBg)<.35?"#fff":t.headingColor;return` .mpdf-doc { font-family: ${n}; font-size: ${t.fontSize}px; @@ -114,7 +114,7 @@ end`},Oc=function(){for(var t=[],e=0;et.textContent??"").join(` -`)}function fm(t){return t.replace(/@font-face\s*\{[^{}]*(?:\{[^{}]*\}[^{}]*)?\}/g,"")}async function cm(){let t=Ju();if(!t)return"";let e=new Set;for(let[,i]of t.matchAll(Ku)){let a=i.trim();a.startsWith("data:")||e.add(a)}if(!e.size)return t;let r=async i=>{try{let a=await(0,N.requestUrl)(i);if(a.status!==200)return i;let s=new Uint8Array(a.arrayBuffer),f="";for(let d=0;d[i,await r(i)])),o=new Map(n);return t.replace(Ku,(i,a)=>{let s=o.get(a.trim());return s&&s!==a.trim()?`url('${s}')`:i})}var Ku=/url\(\s*["']?([^"')]+)["']?\s*\)/g,um=new Set(["P","LI","BLOCKQUOTE","TD","TH"]),dm=new Set(["P","DIV","SECTION","ARTICLE","ASIDE","NAV","HEADER","FOOTER","UL","OL","LI","TABLE","THEAD","TBODY","TFOOT","TR","TD","TH","PRE","BLOCKQUOTE","HR","IMG","H1","H2","H3","H4","H5","H6"]),hm=new Set(["CODE","IMG","HR","H1","H2","H3","H4","H5","H6"]),pm=2;function vm(t,e){e.empty();for(let r of t)e.appendChild(r.cloneNode(!0));return e.getBoundingClientRect().height}function mm(t,e,r){return n=>vm([...t,n],e)<=r-pm}function gm(t){let e=activeDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;e.nextNode();){let r=e.currentNode,n=(r.textContent??"").replace(/^\s+/,"");if(n!==r.textContent&&(r.textContent=n),n.length>0)break}}function Uo(t,e,r=!0){let n=activeDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT),o=0,i=null,a=0;for(;n.nextNode();){let u=n.currentNode,d=u.textContent?.length??0;if(o+d>=e){i=u,a=e-o;break}o+=d}if(!i)return null;let s=activeDocument.createRange();s.selectNodeContents(t),s.setEnd(i,a);let f=activeDocument.createRange();f.selectNodeContents(t),f.setStart(i,a);let l=t.cloneNode(!1);l.appendChild(s.cloneContents());let c=t.cloneNode(!1);return c.appendChild(f.cloneContents()),r&&gm(c),[l,c]}function ym(t){let e=[],r=/\s+/g,n;for(;n=r.exec(t);)n.index>0&&n.index0){let f=0,l=o.length-1,c=-1;for(;f<=l;){let u=Math.floor((f+l)/2),d=Uo(t,o[u]);if(!d){l=u-1;continue}e(d[0])?(c=u,f=u+1):l=u-1}if(c>=0)return Uo(t,o[c]);if(!r)return null}let i=1,a=n.length-1,s=0;for(;i<=a;){let f=Math.floor((i+a)/2),l=Uo(t,f);if(!l){a=f-1;continue}e(l[0])?(s=f,i=f+1):a=f-1}return s>0?Uo(t,s):null}function Fs(t,e,r){let n=t.cloneNode(!1);t.tagName==="OL"&&r!==void 0&&r>1&&(n.start=r);for(let o of e)n.appendChild(o.cloneNode(!0));return n}function xm(t,e,r){let n=Array.from(t.children).filter(a=>a.tagName==="LI");if(n.length===0)return null;let o=t.tagName==="OL"?t.start??1:1,i=0;for(let a=0;a=n.length?null:[Fs(t,n.slice(0,i),o),Fs(t,n.slice(i),o+i)]}function ws(t,e){let r=t.cloneNode(!1),n=t.querySelector("caption");n&&r.appendChild(n.cloneNode(!0));let o=t.querySelector("colgroup");o&&r.appendChild(o.cloneNode(!0)),t.tHead&&r.appendChild(t.tHead.cloneNode(!0));let i=activeDocument.createElement("tbody");for(let a of e)i.appendChild(a.cloneNode(!0));return r.appendChild(i),r}function Fm(t,e,r){let n=t.tBodies[0],o=n?Array.from(n.rows):Array.from(t.rows).filter(a=>a.parentElement?.tagName!=="THEAD");if(o.length===0)return null;let i=0;for(let a=0;a=o.length?null:[ws(t,o.slice(0,i)),ws(t,o.slice(i))]}function wm(t){let e=[],r=0;for(let n of t)r+=n.length+1,e.push(r);return e}function Sm(t,e,r){let n=t.querySelector("code"),o=(n??t).textContent?.split(` -`)??[];if(o.length>1&&o[o.length-1]===""&&o.pop(),o.length<2)return null;let i=wm(o),a=l=>{if(!n){let p=h=>{let b=t.cloneNode(!1);return b.textContent=h,b};return[p(o.slice(0,l).join(` + `.trim()}function fm(t){return{name:t.name,fontFamily:t.fontFamily,fontSize:t.fontSize,lineHeight:t.lineHeight,paragraphSpacing:t.paragraphSpacing,headingScale:t.headingScale,accentColor:t.accentColor,bodyColor:t.bodyColor,headingColor:t.headingColor,h1BorderBottom:t.h1BorderBottom,h2BorderBottom:t.h2BorderBottom,centerH1:t.centerH1,blockquoteBg:t.blockquoteBg,blockquoteBorderColor:t.blockquoteBorderColor,codeBackground:t.codeBackground,codeFontSize:t.codeFontSize,codeTheme:t.codeTheme,tableHeaderBg:t.tableHeaderBg,tableStriped:t.tableStriped,pageBackground:t.pageBackground,marginTop:t.marginTop,marginBottom:t.marginBottom,marginLeft:t.marginLeft,marginRight:t.marginRight}}function qi(){let e=Array.from(activeDocument.head.querySelectorAll("style[id^='MJX-']")).map(n=>{try{if(n.sheet?.cssRules)return Array.from(n.sheet.cssRules).map(o=>o.cssText).join(` +`)}catch{}return n.textContent??""}).join(` +`),r="";try{r=(activeDocument.adoptedStyleSheets??[]).map(o=>{try{return Array.from(o.cssRules).map(i=>i.cssText).join(` +`)}catch{return""}}).filter(Boolean).join(` +`)}catch{}return r?`${e} +${r}`:e}function cm(t){return t.replace(/@font-face\s*\{[^{}]*(?:\{[^{}]*\}[^{}]*)?\}/g,"")}async function um(){let t=qi();if(!t)return"";let e=new Set;for(let[,i]of t.matchAll(Zu)){let a=i.trim();a.startsWith("data:")||e.add(a)}if(!e.size)return t;let r=async i=>{try{let a=await(0,N.requestUrl)(i);if(a.status!==200)return i;let s=new Uint8Array(a.arrayBuffer),f="";for(let d=0;d[i,await r(i)])),o=new Map(n);return t.replace(Zu,(i,a)=>{let s=o.get(a.trim());return s&&s!==a.trim()?`url('${s}')`:i})}var Zu=/url\(\s*["']?([^"')]+)["']?\s*\)/g,dm=new Set(["P","LI","BLOCKQUOTE","TD","TH"]),hm=new Set(["P","DIV","SECTION","ARTICLE","ASIDE","NAV","HEADER","FOOTER","UL","OL","LI","TABLE","THEAD","TBODY","TFOOT","TR","TD","TH","PRE","BLOCKQUOTE","HR","IMG","H1","H2","H3","H4","H5","H6"]),pm=new Set(["CODE","IMG","HR","H1","H2","H3","H4","H5","H6"]),vm=2;function mm(t,e){e.empty();for(let r of t)e.appendChild(r.cloneNode(!0));return e.getBoundingClientRect().height}function gm(t,e,r){return n=>mm([...t,n],e)<=r-vm}function ym(t){let e=activeDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(;e.nextNode();){let r=e.currentNode,n=(r.textContent??"").replace(/^\s+/,"");if(n!==r.textContent&&(r.textContent=n),n.length>0)break}}function Uo(t,e,r=!0){let n=activeDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT),o=0,i=null,a=0;for(;n.nextNode();){let u=n.currentNode,d=u.textContent?.length??0;if(o+d>=e){i=u,a=e-o;break}o+=d}if(!i)return null;let s=activeDocument.createRange();s.selectNodeContents(t),s.setEnd(i,a);let f=activeDocument.createRange();f.selectNodeContents(t),f.setStart(i,a);let l=t.cloneNode(!1);l.appendChild(s.cloneContents());let c=t.cloneNode(!1);return c.appendChild(f.cloneContents()),r&&ym(c),[l,c]}function bm(t){let e=[],r=/\s+/g,n;for(;n=r.exec(t);)n.index>0&&n.index0){let f=0,l=o.length-1,c=-1;for(;f<=l;){let u=Math.floor((f+l)/2),d=Uo(t,o[u]);if(!d){l=u-1;continue}e(d[0])?(c=u,f=u+1):l=u-1}if(c>=0)return Uo(t,o[c]);if(!r)return null}let i=1,a=n.length-1,s=0;for(;i<=a;){let f=Math.floor((i+a)/2),l=Uo(t,f);if(!l){a=f-1;continue}e(l[0])?(s=f,i=f+1):a=f-1}return s>0?Uo(t,s):null}function ws(t,e,r){let n=t.cloneNode(!1);t.tagName==="OL"&&r!==void 0&&r>1&&(n.start=r);for(let o of e)n.appendChild(o.cloneNode(!0));return n}function Fm(t,e,r){let n=Array.from(t.children).filter(a=>a.tagName==="LI");if(n.length===0)return null;let o=t.tagName==="OL"?t.start??1:1,i=0;for(let a=0;a=n.length?null:[ws(t,n.slice(0,i),o),ws(t,n.slice(i),o+i)]}function Ss(t,e){let r=t.cloneNode(!1),n=t.querySelector("caption");n&&r.appendChild(n.cloneNode(!0));let o=t.querySelector("colgroup");o&&r.appendChild(o.cloneNode(!0)),t.tHead&&r.appendChild(t.tHead.cloneNode(!0));let i=activeDocument.createElement("tbody");for(let a of e)i.appendChild(a.cloneNode(!0));return r.appendChild(i),r}function wm(t,e,r){let n=t.tBodies[0],o=n?Array.from(n.rows):Array.from(t.rows).filter(a=>a.parentElement?.tagName!=="THEAD");if(o.length===0)return null;let i=0;for(let a=0;a=o.length?null:[Ss(t,o.slice(0,i)),Ss(t,o.slice(i))]}function Sm(t){let e=[],r=0;for(let n of t)r+=n.length+1,e.push(r);return e}function Pm(t,e,r){let n=t.querySelector("code"),o=(n??t).textContent?.split(` +`)??[];if(o.length>1&&o[o.length-1]===""&&o.pop(),o.length<2)return null;let i=Sm(o),a=l=>{if(!n){let p=h=>{let b=t.cloneNode(!1);return b.textContent=h,b};return[p(o.slice(0,l).join(` `)),p(o.slice(l).join(` -`))]}let c=Uo(n,i[l-1],!1);if(!c)return null;let u=t.cloneNode(!1);u.appendChild(c[0]);let d=t.cloneNode(!1);return d.appendChild(c[1]),[u,d]},s=null,f=0;for(let l=1;l<=o.length;l++){let c=a(l);if(!c||!e(c[0]))break;s=c,f=l}if(f<=0){if(!r)return null;s=a(1),f=1}return f>=o.length||!s?null:s}function Pm(t){if(!um.has(t.tagName))return!1;for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE&&dm.has(e.tagName))return!1;return!0}function Dm(t,e,r){return hm.has(t.tagName)?null:t.tagName==="PRE"?Sm(t,e,r):t.tagName==="TABLE"?Fm(t,e,r):t.tagName==="UL"||t.tagName==="OL"?xm(t,e,r):Pm(t)?bm(t,e,r):null}function Cm(t,e,r,n){let o=activeDocument.createElement("div");o.setCssStyles({position:"fixed",top:"0",left:"-99999px",width:`${e}px`,visibility:"hidden",pointerEvents:"none",zIndex:"-1"});let i=o.attachShadow({mode:"open"}),a=new CSSStyleSheet;a.replaceSync(n),i.adoptedStyleSheets=[a];let s=activeDocument.createElement("div");s.className="mpdf-doc";for(let c of Array.from(t.children))s.appendChild(c.cloneNode(!0));i.appendChild(s);let f=activeDocument.createElement("div");f.className="mpdf-doc",f.setCssStyles({position:"absolute",top:"0",left:"0",width:`${e}px`,visibility:"hidden"}),i.appendChild(f),activeDocument.body.appendChild(o);let l=[];try{let c=[],u=Array.from(s.children),d=0;for(;d0?u[d]=x:d++;continue}if(c.length>0){l.push(c),c=[];continue}c.push(p.cloneNode(!0)),l.push(c),c=[],d++}c.length>0&&l.push(c)}finally{activeDocument.body.removeChild(o)}return l.length>0?l:[[]]}function km(t,e){let r=t.length;return t.map((n,o)=>{let i=o+1,a=e.showHeaderOnFirstPage||o>0,s=e.showFooterOnFirstPage||o>0,f=e.showFooterOnFirstPage?e.pageNumberStart+o:e.pageNumberStart+(o-1),l=e.showFooterOnFirstPage?e.pageNumberStart+r-1:e.pageNumberStart+r-2,c=`${f} / ${l}`,u="",d="",p="",h="",b="",F="";if(s&&(e.footerText&&(e.footerTextAlignment==="center"?p=e.footerText:e.footerTextAlignment==="left"?u=e.footerText:d=e.footerText),e.showPageNumbers)){let y=w=>w?w+" \u2014 "+c:c;e.pageNumberPosition==="center"?p=y(p):e.pageNumberPosition==="left"?u=y(u):d=y(d)}a&&e.headerText&&(e.headerAlignment==="center"?b=e.headerText:e.headerAlignment==="left"?h=e.headerText:F=e.headerText);let x=e.showHeader&&a&&!!(h||b||F||e.showHeaderBorder),m=e.showFooter&&s&&!!(u||d||p||e.showFooterBorder);return{pageNodes:n,pageNum:i,totalPages:r,pageShowsHeader:a,pageShowsFooter:s,hasHeader:x,hasFooter:m,headerLeft:h,headerCenter:b,headerRight:F,footerLeft:u,footerRight:d,footerCenter:p}})}function Tm(t){let e=[];for(let r of t)for(let n of r.pageNodes){let o=/^H[1-6]$/.test(n.tagName)?[n]:[],i=Array.from(n.querySelectorAll("h1,h2,h3,h4,h5,h6"));for(let a of[...o,...i]){let s=parseInt(a.tagName[1],10),f=(a.textContent??"").trim();f&&e.push({title:f,level:s,page:r.pageNum})}}return e}async function Em(t,e){if(!e.length)return t;let r=await Ge.load(t),n=r.getPages(),o=r.context,i=e.length,a=new Array(i).fill(-1);for(let m=1;m=0;y--)if(e[y].level=0;y--)if(a[y]===a[m]){s[m]=y;break}for(let y=m+1;y=0&&(l[y]<0&&(l[y]=m),c[y]=m,u[y]++)}let d=o.nextRef(),p=e.map(()=>o.nextRef());for(let m=0;m=0?p[a[m]]:d),S.set(v.of("Dest"),w),s[m]>=0&&S.set(v.of("Prev"),p[s[m]]),f[m]>=0&&S.set(v.of("Next"),p[f[m]]),l[m]>=0&&(S.set(v.of("First"),p[l[m]]),S.set(v.of("Last"),p[c[m]]),S.set(v.of("Count"),j.of(-u[m]))),o.assign(p[m],S)}let h=-1,b=-1,F=0;for(let m=0;m`}function Xu(t,e,r,n){if(!(!e&&!r&&!n))if(e){let o=activeDocument.createElement("span");o.className="mpdf-hf-center",o.textContent=e,t.appendChild(o)}else{let o=activeDocument.createElement("span");o.textContent=r,t.appendChild(o);let i=activeDocument.createElement("span");i.className="mpdf-hf-right",i.textContent=n,t.appendChild(i)}}function Zu(t,e,r){return!t&&!e&&!r?"":t?`${Ui(t)}`:`${Ui(e)}${Ui(r)}`}var qi=class extends N.Plugin{activeModal=null;presetSnapshots={};async onload(){await this.loadSettings(),this.addCommand({id:"open-panel",name:"Open Panel",callback:()=>this.openModal()}),this.registerEvent(this.app.workspace.on("file-menu",(e,r)=>{!(r instanceof N.TFile)||r.extension!=="md"||e.addItem(n=>n.setTitle("Advanced PDF Export: Open Panel").setIcon("file-output").onClick(()=>this.openModal(r)))})),this.addSettingTab(new Ds(this.app,this))}onunload(){this.activeModal?.close()}openModal(e){this.activeModal&&this.activeModal.close(),new Ps(this.app,this,e).open()}async loadSettings(){let e=await this.loadData()??{};this.settings=Object.assign({},Vu,e),e.codeTheme===void 0&&(this.settings.codeTheme=Tn[this.settings.preset]?.codeTheme??Vu.codeTheme),this.presetSnapshots=e.presetSnapshots??{},this.validateSettings()}validateSettings(){let e=this.settings;e.preset in Tn||(console.warn(`[advanced-pdf-export] Unknown preset "${e.preset}", resetting to "default".`),e.preset="default"),e.fontSize=Math.max(1,e.fontSize),e.headerFontSize=Math.max(1,e.headerFontSize),e.footerFontSize=Math.max(1,e.footerFontSize),e.marginTop=Math.max(0,e.marginTop),e.marginBottom=Math.max(0,e.marginBottom),e.marginLeft=Math.max(0,e.marginLeft),e.marginRight=Math.max(0,e.marginRight),e.customPageWidth=Math.max(10,e.customPageWidth),e.customPageHeight=Math.max(10,e.customPageHeight),e.previewScale=Math.max(.1,Math.min(3,e.previewScale)),e.pageNumberStart=Math.max(1,e.pageNumberStart)}async saveSettings(){await this.saveData({...this.settings,presetSnapshots:this.presetSnapshots})}async saveSettingsAndRender(){await this.saveSettings(),this.activeModal?.render()}applyPreset(e,r=!1){let n=Tn[e];n&&(r?delete this.presetSnapshots[e]:this.presetSnapshots[this.settings.preset]=lm(this.settings),this.settings.preset=e,Object.assign(this.settings,n,r?{}:this.presetSnapshots[e]??{}))}};function Om(t,e){if(e)return e;let r=t.workspace.getActiveFile();if(r?.extension==="md")return r;let n=t.workspace.getMostRecentLeaf();return n?.view instanceof N.MarkdownView?n.view.file??null:null}var Ps=class t extends N.Modal{plugin;editorEl;previewEl;pageCountEl;noteTitleEl;renderBtn;exportBtn;loadingOverlayEl;renderComponent=new N.Component;initialFile;currentFile=null;renderToken=0;layoutCache=null;renderDebounceTimer=null;constructor(e,r,n){super(e),this.plugin=r,this.initialFile=n??null}async onOpen(){this.plugin.activeModal=this,this.renderComponent.load(),this.modalEl.addClass("mpdf-modal"),this.buildUI(this.contentEl);let e=Om(this.app,this.initialFile);if(e){let r;try{r=await this.app.vault.read(e)}catch(n){let o=n instanceof Error?n.message:String(n);new N.Notice(`Failed to read file "${e.basename}": ${o}`);return}if(!this.plugin.activeModal)return;this.currentFile=e,this.editorEl.value=r,this.noteTitleEl.textContent=e.basename,this.noteTitleEl.title=e.path,this.render(!0)}}onClose(){this.renderDebounceTimer!==null&&(window.clearTimeout(this.renderDebounceTimer),this.renderDebounceTimer=null),this.renderComponent.unload(),this.plugin.activeModal=null,this.currentFile=null,this.layoutCache=null}buildUI(e){let r=this.plugin.settings;this.buildTopbar(e.createEl("div",{cls:"mpdf-topbar"}),r);let n=e.createEl("div",{cls:"mpdf-main"}),o=n.createEl("div",{cls:"mpdf-editor-panel"});this.editorEl=o.createEl("textarea",{cls:"mpdf-editor"}),this.editorEl.placeholder=`Type or paste markdown here to preview and export as PDF. +`))]}let c=Uo(n,i[l-1],!1);if(!c)return null;let u=t.cloneNode(!1);u.appendChild(c[0]);let d=t.cloneNode(!1);return d.appendChild(c[1]),[u,d]},s=null,f=0;for(let l=1;l<=o.length;l++){let c=a(l);if(!c||!e(c[0]))break;s=c,f=l}if(f<=0){if(!r)return null;s=a(1),f=1}return f>=o.length||!s?null:s}function Dm(t){if(!dm.has(t.tagName))return!1;for(let e of Array.from(t.childNodes))if(e.nodeType===Node.ELEMENT_NODE&&hm.has(e.tagName))return!1;return!0}function Cm(t,e,r){return pm.has(t.tagName)?null:t.tagName==="PRE"?Pm(t,e,r):t.tagName==="TABLE"?wm(t,e,r):t.tagName==="UL"||t.tagName==="OL"?Fm(t,e,r):Dm(t)?xm(t,e,r):null}function km(t,e,r,n){let o=activeDocument.createElement("div");o.setCssStyles({position:"fixed",top:"0",left:"-99999px",width:`${e}px`,visibility:"hidden",pointerEvents:"none",zIndex:"-1"});let i=o.attachShadow({mode:"open"}),a=new CSSStyleSheet;a.replaceSync(n),i.adoptedStyleSheets=[a];let s=activeDocument.createElement("div");s.className="mpdf-doc";for(let c of Array.from(t.children))s.appendChild(c.cloneNode(!0));i.appendChild(s);let f=activeDocument.createElement("div");f.className="mpdf-doc",f.setCssStyles({position:"absolute",top:"0",left:"0",width:`${e}px`,visibility:"hidden"}),i.appendChild(f),activeDocument.body.appendChild(o);let l=[];try{let c=[],u=Array.from(s.children),d=0;for(;d0?u[d]=x:d++;continue}if(c.length>0){l.push(c),c=[];continue}c.push(p.cloneNode(!0)),l.push(c),c=[],d++}c.length>0&&l.push(c)}finally{activeDocument.body.removeChild(o)}return l.length>0?l:[[]]}function Tm(t,e){let r=t.length;return t.map((n,o)=>{let i=o+1,a=e.showHeaderOnFirstPage||o>0,s=e.showFooterOnFirstPage||o>0,f=e.showFooterOnFirstPage?e.pageNumberStart+o:e.pageNumberStart+(o-1),l=e.showFooterOnFirstPage?e.pageNumberStart+r-1:e.pageNumberStart+r-2,c=`${f} / ${l}`,u="",d="",p="",h="",b="",F="";if(s&&(e.footerText&&(e.footerTextAlignment==="center"?p=e.footerText:e.footerTextAlignment==="left"?u=e.footerText:d=e.footerText),e.showPageNumbers)){let y=w=>w?w+" \u2014 "+c:c;e.pageNumberPosition==="center"?p=y(p):e.pageNumberPosition==="left"?u=y(u):d=y(d)}a&&e.headerText&&(e.headerAlignment==="center"?b=e.headerText:e.headerAlignment==="left"?h=e.headerText:F=e.headerText);let x=e.showHeader&&a&&!!(h||b||F||e.showHeaderBorder),m=e.showFooter&&s&&!!(u||d||p||e.showFooterBorder);return{pageNodes:n,pageNum:i,totalPages:r,pageShowsHeader:a,pageShowsFooter:s,hasHeader:x,hasFooter:m,headerLeft:h,headerCenter:b,headerRight:F,footerLeft:u,footerRight:d,footerCenter:p}})}function Em(t){let e=[];for(let r of t)for(let n of r.pageNodes){let o=/^H[1-6]$/.test(n.tagName)?[n]:[],i=Array.from(n.querySelectorAll("h1,h2,h3,h4,h5,h6"));for(let a of[...o,...i]){let s=parseInt(a.tagName[1],10),f=(a.textContent??"").trim();f&&e.push({title:f,level:s,page:r.pageNum})}}return e}async function Am(t,e){if(!e.length)return t;let r=await Ge.load(t),n=r.getPages(),o=r.context,i=e.length,a=new Array(i).fill(-1);for(let m=1;m=0;y--)if(e[y].level=0;y--)if(a[y]===a[m]){s[m]=y;break}for(let y=m+1;y=0&&(l[y]<0&&(l[y]=m),c[y]=m,u[y]++)}let d=o.nextRef(),p=e.map(()=>o.nextRef());for(let m=0;m=0?p[a[m]]:d),S.set(v.of("Dest"),w),s[m]>=0&&S.set(v.of("Prev"),p[s[m]]),f[m]>=0&&S.set(v.of("Next"),p[f[m]]),l[m]>=0&&(S.set(v.of("First"),p[l[m]]),S.set(v.of("Last"),p[c[m]]),S.set(v.of("Count"),j.of(-u[m]))),o.assign(p[m],S)}let h=-1,b=-1,F=0;for(let m=0;m`}function Yu(t,e,r,n){if(!(!e&&!r&&!n))if(e){let o=activeDocument.createElement("span");o.className="mpdf-hf-center",o.textContent=e,t.appendChild(o)}else{let o=activeDocument.createElement("span");o.textContent=r,t.appendChild(o);let i=activeDocument.createElement("span");i.className="mpdf-hf-right",i.textContent=n,t.appendChild(i)}}function Ju(t,e,r){return!t&&!e&&!r?"":t?`${Ui(t)}`:`${Ui(e)}${Ui(r)}`}var Wi=class extends N.Plugin{activeModal=null;presetSnapshots={};async onload(){await this.loadSettings(),this.addCommand({id:"open-panel",name:"Open Panel",callback:()=>this.openModal()}),this.registerEvent(this.app.workspace.on("file-menu",(e,r)=>{!(r instanceof N.TFile)||r.extension!=="md"||e.addItem(n=>n.setTitle("Advanced PDF Export: Open Panel").setIcon("file-output").onClick(()=>this.openModal(r)))})),this.addSettingTab(new ks(this.app,this))}onunload(){this.activeModal?.close()}openModal(e){this.activeModal&&this.activeModal.close(),new Cs(this.app,this,e).open()}async loadSettings(){let e=await this.loadData()??{};this.settings=Object.assign({},Wu,e),e.codeTheme===void 0&&(this.settings.codeTheme=Tn[this.settings.preset]?.codeTheme??Wu.codeTheme),this.presetSnapshots=e.presetSnapshots??{},this.validateSettings()}validateSettings(){let e=this.settings;e.preset in Tn||(console.warn(`[advanced-pdf-export] Unknown preset "${e.preset}", resetting to "default".`),e.preset="default"),e.fontSize=Math.max(1,e.fontSize),e.headerFontSize=Math.max(1,e.headerFontSize),e.footerFontSize=Math.max(1,e.footerFontSize),e.marginTop=Math.max(0,e.marginTop),e.marginBottom=Math.max(0,e.marginBottom),e.marginLeft=Math.max(0,e.marginLeft),e.marginRight=Math.max(0,e.marginRight),e.customPageWidth=Math.max(10,e.customPageWidth),e.customPageHeight=Math.max(10,e.customPageHeight),e.previewScale=Math.max(.1,Math.min(3,e.previewScale)),e.pageNumberStart=Math.max(1,e.pageNumberStart)}async saveSettings(){await this.saveData({...this.settings,presetSnapshots:this.presetSnapshots})}async saveSettingsAndRender(){await this.saveSettings(),this.activeModal?.render()}applyPreset(e,r=!1){let n=Tn[e];n&&(r?delete this.presetSnapshots[e]:this.presetSnapshots[this.settings.preset]=fm(this.settings),this.settings.preset=e,Object.assign(this.settings,n,r?{}:this.presetSnapshots[e]??{}))}};function Bm(t,e){if(e)return e;let r=t.workspace.getActiveFile();if(r?.extension==="md")return r;let n=t.workspace.getMostRecentLeaf();return n?.view instanceof N.MarkdownView?n.view.file??null:null}var Cs=class t extends N.Modal{plugin;editorEl;previewEl;pageCountEl;noteTitleEl;renderBtn;exportBtn;loadingOverlayEl;renderComponent=new N.Component;initialFile;currentFile=null;renderToken=0;layoutCache=null;renderDebounceTimer=null;constructor(e,r,n){super(e),this.plugin=r,this.initialFile=n??null}async onOpen(){this.plugin.activeModal=this,this.renderComponent.load(),this.modalEl.addClass("mpdf-modal"),this.buildUI(this.contentEl);let e=Bm(this.app,this.initialFile);if(e){let r;try{r=await this.app.vault.read(e)}catch(n){let o=n instanceof Error?n.message:String(n);new N.Notice(`Failed to read file "${e.basename}": ${o}`);return}if(!this.plugin.activeModal)return;this.currentFile=e,this.editorEl.value=r,this.noteTitleEl.textContent=e.basename,this.noteTitleEl.title=e.path,this.render(!0)}}onClose(){this.renderDebounceTimer!==null&&(window.clearTimeout(this.renderDebounceTimer),this.renderDebounceTimer=null),this.renderComponent.unload(),this.plugin.activeModal=null,this.currentFile=null,this.layoutCache=null}buildUI(e){let r=this.plugin.settings;this.buildTopbar(e.createEl("div",{cls:"mpdf-topbar"}),r);let n=e.createEl("div",{cls:"mpdf-main"}),o=n.createEl("div",{cls:"mpdf-editor-panel"});this.editorEl=o.createEl("textarea",{cls:"mpdf-editor"}),this.editorEl.placeholder=`Type or paste markdown here to preview and export as PDF. Tip: open this panel from a note's right-click menu, command palette, or keyboard shortcut to auto-load the active note. @@ -244,10 +248,10 @@ Markdown tables: /// `)),this.noteTitleEl=n.createEl("div",{cls:"mpdf-topbar-title",text:"\u2014"}),this.pageCountEl=o.createEl("span",{cls:"mpdf-page-count",text:"\u2014 pages"});let y=o.createEl("button",{cls:"mpdf-btn mpdf-btn-icon"});y.setAttr("aria-label","Open Advanced PDF Export settings"),(0,N.setIcon)(y,"settings"),y.addEventListener("click",()=>{let w=this.app.setting;w?.open?.(),w?.openTabById?.("advanced-pdf-export")}),this.renderBtn=o.createEl("button",{cls:"mpdf-btn",text:"\u27F3 Render PDF"}),this.renderBtn.title="Render preview (Ctrl+Enter)",this.renderBtn.addEventListener("click",()=>this.render(!0)),this.exportBtn=o.createEl("button",{cls:"mpdf-btn mpdf-btn-primary",text:"\u2B07 Export PDF"}),this.exportBtn.addEventListener("click",()=>void this.exportPDF())}insertAtCursor(e){let r=this.editorEl,n=r.selectionStart,o=r.selectionEnd;r.value=r.value.slice(0,n)+e+r.value.slice(o),r.selectionStart=r.selectionEnd=n+e.length,r.focus()}render(e=!1){let r=++this.renderToken;this.renderDebounceTimer!==null&&(window.clearTimeout(this.renderDebounceTimer),this.renderDebounceTimer=null),this.showLoading();let n=()=>this.doRender(r).catch(o=>{let i=o instanceof Error?o.message:String(o);console.error("[advanced-pdf-export] render error:",o),this.hideLoading(),new N.Notice("Advanced PDF Export \u2014 render failed: "+i)});e?window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>void n())):this.renderDebounceTimer=window.setTimeout(()=>{this.renderDebounceTimer=null,window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>void n()))},150)}static insertAutoBreaks(e,r,n){if(!r&&!n)return e;let o=e.split(` `),i=[],a=!1,s="";for(let f of o){if(a){let l=f.match(/^(`{3,}|~{3,})\s*$/);l&&l[1][0]===s[0]&&l[1].length>=s.length&&(a=!1,s="")}else{let l=f.match(/^(`{3,}|~{3,})/);l?(a=!0,s=l[1]):i.length>0&&(r&&/^# /.test(f)||n&&/^## /.test(f))&&i.push("///")}i.push(f)}return i.join(` -`)}async doRender(e){let r=this.plugin.settings,n=Zv(this.editorEl.value);r.hideFrontmatter&&(n=Yv(n)),r.includeFilenameAsTitle&&this.currentFile&&(n=`# ${this.currentFile.basename} +`)}async doRender(e){let r=this.plugin.settings,n=Yv(this.editorEl.value);r.hideFrontmatter&&(n=Jv(n)),r.includeFilenameAsTitle&&this.currentFile&&(n=`# ${this.currentFile.basename} -${n}`),n=t.insertAutoBreaks(n,r.autoBreakH1,r.autoBreakH2);let o=Jv(n),i=Wv(r),a=r.orientation==="landscape"?i.h:i.w,s=r.orientation==="landscape"?i.w:i.h,f=kn(r.marginTop),l=kn(r.marginBottom),c=kn(r.marginLeft),u=kn(r.marginRight),d=r.showFooter&&(r.showPageNumbers||r.footerText||r.showFooterBorder||r.footerImagePath)?r.footerHeight>0?r.footerHeight:Math.max(28,r.footerFontSize+14):0,p=r.showHeader&&(r.headerText||r.showHeaderBorder||r.headerImagePath)?r.headerHeight>0?r.headerHeight:Math.max(20,r.headerFontSize+10):0,h=Math.max(1,a-c-u),b=Math.max(1,s-f-l-d-p),F=Xv(this.editorEl.value),x=sm(r,F),m=this.currentFile?.path??"pdf-export",y=await Promise.all(o.map(E=>Qv(this.app,E,m,this.renderComponent)));if(e!==this.renderToken)return;let w=Ju(),S=w?fm(w):"",D=S?`${S} -${x}`:x,T=[];for(let E of y)T.push(...Cm(E,h,b,D));let C=km(T,r);this.layoutCache={layouts:C,pw:a,ph:s,mTop:f,mLeft:c,mRight:u,footerH:d,headerH:p,contentW:h,contentH:b,docCSS:D,fontFamily:Yu(r),accentColor:r.accentColor,pageBackground:r.pageBackground,isRTL:F},this.drawPreview(this.layoutCache,r.previewScale),this.pageCountEl.textContent=`${C.length} page${C.length!==1?"s":""}`,this.hideLoading()}renderPreviewOnly(){this.layoutCache&&this.drawPreview(this.layoutCache,this.plugin.settings.previewScale)}showLoading(){this.loadingOverlayEl.addClass("mpdf-is-active"),this.renderBtn.disabled=!0,this.renderBtn.textContent="Rendering\u2026"}hideLoading(){this.loadingOverlayEl.removeClass("mpdf-is-active"),this.renderBtn.disabled=!1,this.renderBtn.textContent="\u27F3 Render PDF"}drawPreview(e,r){let{layouts:n,pw:o,ph:i,mTop:a,mLeft:s,mRight:f,footerH:l,headerH:c,contentW:u,contentH:d,docCSS:p,fontFamily:h,accentColor:b,pageBackground:F,isRTL:x}=e,m=this.plugin.settings;this.previewEl.empty();let y=new Map;n.forEach((T,C)=>{for(let E of T.pageNodes)E.querySelectorAll("[id]").forEach(I=>{y.has(I.id)||y.set(I.id,C)}),E.id&&!y.has(E.id)&&y.set(E.id,C)});let w=[],S=` +${n}`),n=t.insertAutoBreaks(n,r.autoBreakH1,r.autoBreakH2);let o=Qv(n),i=Gv(r),a=r.orientation==="landscape"?i.h:i.w,s=r.orientation==="landscape"?i.w:i.h,f=kn(r.marginTop),l=kn(r.marginBottom),c=kn(r.marginLeft),u=kn(r.marginRight),d=r.showFooter&&(r.showPageNumbers||r.footerText||r.showFooterBorder||r.footerImagePath)?r.footerHeight>0?r.footerHeight:Math.max(28,r.footerFontSize+14):0,p=r.showHeader&&(r.headerText||r.showHeaderBorder||r.headerImagePath)?r.headerHeight>0?r.headerHeight:Math.max(20,r.headerFontSize+10):0,h=Math.max(1,a-c-u),b=Math.max(1,s-f-l-d-p),F=Zv(this.editorEl.value),x=lm(r,F),m=this.currentFile?.path??"pdf-export",y=await Promise.all(o.map(E=>_v(this.app,E,m,this.renderComponent)));if(e!==this.renderToken)return;await Ps();let w=qi(),S=w?cm(w):"",D=S?`${S} +${x}`:x,T=[];for(let E of y)T.push(...km(E,h,b,D));let C=Tm(T,r);this.layoutCache={layouts:C,pw:a,ph:s,mTop:f,mLeft:c,mRight:u,footerH:d,headerH:p,contentW:h,contentH:b,docCSS:D,fontFamily:Qu(r),accentColor:r.accentColor,pageBackground:r.pageBackground,isRTL:F},this.drawPreview(this.layoutCache,r.previewScale),this.pageCountEl.textContent=`${C.length} page${C.length!==1?"s":""}`,this.hideLoading()}renderPreviewOnly(){this.layoutCache&&this.drawPreview(this.layoutCache,this.plugin.settings.previewScale)}showLoading(){this.loadingOverlayEl.addClass("mpdf-is-active"),this.renderBtn.disabled=!0,this.renderBtn.textContent="Rendering\u2026"}hideLoading(){this.loadingOverlayEl.removeClass("mpdf-is-active"),this.renderBtn.disabled=!1,this.renderBtn.textContent="\u27F3 Render PDF"}drawPreview(e,r){let{layouts:n,pw:o,ph:i,mTop:a,mLeft:s,mRight:f,footerH:l,headerH:c,contentW:u,contentH:d,docCSS:p,fontFamily:h,accentColor:b,pageBackground:F,isRTL:x}=e,m=this.plugin.settings;this.previewEl.empty();let y=new Map;n.forEach((T,C)=>{for(let E of T.pageNodes)E.querySelectorAll("[id]").forEach(I=>{y.has(I.id)||y.set(I.id,C)}),E.id&&!y.has(E.id)&&y.set(E.id,C)});let w=[],S=` :host { display: block; width: ${o}px; @@ -262,8 +266,8 @@ ${x}`:x,T=[];for(let E of y)T.push(...Cm(E,h,b,D));let C=km(T,r);this.layoutCach .mpdf-hf-center { flex: 1; text-align: center; } .mpdf-hf-right { margin-left: auto; } ${p} - `,D=new CSSStyleSheet;D.replaceSync(S);for(let T of n){let C=Math.round(o*r),E=Math.round(i*r),I=this.previewEl.createEl("div",{cls:"mpdf-page-wrap"});I.setCssStyles({width:`${C}px`,height:`${E}px`}),I.createEl("div",{cls:"mpdf-page-label",text:`Page ${T.pageNum} of ${T.totalPages}`}),w.push(I);let A=I.createEl("div",{cls:"mpdf-page-scale"});A.setCssStyles({width:`${C}px`,height:`${E}px`});let R=activeDocument.createElement("div");R.addClass("mpdf-shadow-host"),R.setCssStyles({width:`${o}px`,height:`${i}px`,transform:`scale(${r})`}),A.appendChild(R);let z=R.attachShadow({mode:"open"});if(z.adoptedStyleSheets=[D],m.backgroundImageEnabled&&m.backgroundImagePath){let oe=Cn(this.app,m.backgroundImagePath);if(oe){let Fe=m.backgroundImageScope==="content-only",Ce=activeDocument.createElement("div"),Be=Wu(m.backgroundImageSize);Ce.setCssStyles({position:"absolute",...Fe?{top:`${a+c}px`,left:`${s}px`,width:`${u}px`,height:`${d}px`}:{inset:"0"},backgroundImage:`url('${oe}')`,backgroundRepeat:Be.repeat,backgroundSize:Be.size,backgroundPosition:"center",opacity:String(m.backgroundImageOpacity),pointerEvents:"none"}),z.appendChild(Ce)}}let M=T.pageShowsHeader,X=T.pageShowsFooter;if(M&&m.showHeader&&m.headerImagePath){let oe=Cn(this.app,m.headerImagePath);if(oe){let Fe=activeDocument.createElement("div");Fe.setCssStyles({position:"absolute",top:`${a*.4}px`,left:`${m.headerImageMargin}px`,right:`${m.headerImageMargin}px`,height:`${c}px`,backgroundImage:`url('${oe}')`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",pointerEvents:"none"}),z.appendChild(Fe)}}if(T.hasHeader){let oe=activeDocument.createElement("div");oe.setCssStyles({position:"absolute",top:`${a*.4}px`,left:`${s}px`,right:`${f}px`,height:`${c}px`,display:"flex",alignItems:"center",fontSize:`${m.headerFontSize}px`,color:m.headerFontColor,fontFamily:h,whiteSpace:"nowrap",...m.showHeaderBorder?{borderBottom:`0.5px solid ${b}33`}:{}}),Xu(oe,T.headerCenter,T.headerLeft,T.headerRight),z.appendChild(oe)}let L=activeDocument.createElement("div");L.className="mpdf-doc",x&&L.setAttribute("dir","rtl"),L.setCssStyles({position:"absolute",top:`${a+c}px`,left:`${s}px`,width:`${u}px`});for(let oe of T.pageNodes)L.appendChild(oe.cloneNode(!0));if(z.appendChild(L),L.querySelectorAll("a[href^='#']").forEach(oe=>{let Fe=decodeURIComponent((oe.getAttribute("href")??"").slice(1)),Ce=y.get(Fe);Ce!==void 0&&(oe.title=`Go to page ${Ce+1}`,oe.addEventListener("click",Be=>{Be.preventDefault(),w[Ce]?.scrollIntoView({behavior:"smooth",block:"start"})}))}),X&&m.showFooter&&m.footerImagePath){let oe=Cn(this.app,m.footerImagePath);if(oe){let Fe=activeDocument.createElement("div");Fe.setCssStyles({position:"absolute",bottom:"0",left:`${m.footerImageMargin}px`,right:`${m.footerImageMargin}px`,height:`${l}px`,backgroundImage:`url('${oe}')`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",pointerEvents:"none"}),z.appendChild(Fe)}}if(T.hasFooter){let oe=activeDocument.createElement("div");oe.setCssStyles({position:"absolute",bottom:"0",left:"0",right:"0",height:`${l}px`,display:"flex",alignItems:"center",...m.showFooterBorder?{borderTop:`0.5px solid ${b}33`}:{},padding:`0 ${f}px 0 ${s}px`,fontSize:`${m.footerFontSize}px`,color:m.footerFontColor,fontFamily:h}),Xu(oe,T.footerCenter,T.footerLeft,T.footerRight),z.appendChild(oe)}let ye=Am(m);ye&&z.appendChild(ye)}}async exportPDF(){let e=this.plugin.settings;this.exportBtn.disabled=!0,this.exportBtn.textContent="\u2B07 Exporting\u2026";let r=()=>{this.exportBtn.disabled=!1,this.exportBtn.textContent="\u2B07 Export PDF"};if(!this.layoutCache){this.renderDebounceTimer!==null&&(window.clearTimeout(this.renderDebounceTimer),this.renderDebounceTimer=null);let R=++this.renderToken;this.showLoading();try{await this.doRender(R)}catch(z){let M=z instanceof Error?z.message:String(z);new N.Notice("Advanced PDF Export \u2014 render failed: "+M),this.hideLoading(),r();return}}let n=this.layoutCache;if(!n||n.layouts.length===0){new N.Notice("Nothing to export."),r();return}let{layouts:o,pw:i,ph:a,mTop:s,mLeft:f,mRight:l,footerH:c,headerH:u,contentW:d,contentH:p,docCSS:h,fontFamily:b,accentColor:F,pageBackground:x,isRTL:m}=n,y=Rm(e),w=e.showHeader&&e.headerImagePath?Cn(this.app,e.headerImagePath):"",S=e.showFooter&&e.footerImagePath?Cn(this.app,e.footerImagePath):"",D=e.backgroundImageEnabled&&e.backgroundImagePath?Cn(this.app,e.backgroundImagePath):"",T=D?(()=>{let R=Wu(e.backgroundImageSize),z=e.backgroundImageScope==="content-only"?`top:${s+u}px;left:${f}px;width:${d}px;height:${p}px;`:"inset:0;",M=`background-image:url('${D}');background-size:${R.size};background-repeat:${R.repeat};background-position:center;opacity:${e.backgroundImageOpacity};pointer-events:none;`;return`
`})():"",C=o.map(R=>{let z=R.pageNodes.map(Be=>Be.outerHTML).join(` -`),M=R.hasHeader,X=e.showHeaderBorder?`border-bottom:0.5px solid ${F}33;`:"",te=M?`
${Zu(R.headerCenter,R.headerLeft,R.headerRight)}
`:"",L=R.hasFooter,ue=e.showFooterBorder?`border-top:0.5px solid ${F}33;`:"",ye=L?`
${Zu(R.footerCenter,R.footerLeft,R.footerRight)}
`:"",oe=`
${z}
`,Fe=R.pageShowsHeader&&w?`
`:"",Ce=R.pageShowsFooter&&S?`
`:"";return`
${T}${Fe}${te}${oe}${Ce}${ye}${y}
`}),E=await cm(),I=` + `,D=new CSSStyleSheet;D.replaceSync(S);for(let T of n){let C=Math.round(o*r),E=Math.round(i*r),I=this.previewEl.createEl("div",{cls:"mpdf-page-wrap"});I.setCssStyles({width:`${C}px`,height:`${E}px`}),I.createEl("div",{cls:"mpdf-page-label",text:`Page ${T.pageNum} of ${T.totalPages}`}),w.push(I);let A=I.createEl("div",{cls:"mpdf-page-scale"});A.setCssStyles({width:`${C}px`,height:`${E}px`});let R=activeDocument.createElement("div");R.addClass("mpdf-shadow-host"),R.setCssStyles({width:`${o}px`,height:`${i}px`,transform:`scale(${r})`}),A.appendChild(R);let z=R.attachShadow({mode:"open"});if(z.adoptedStyleSheets=[D],m.backgroundImageEnabled&&m.backgroundImagePath){let oe=Cn(this.app,m.backgroundImagePath);if(oe){let Fe=m.backgroundImageScope==="content-only",Ce=activeDocument.createElement("div"),Be=Ku(m.backgroundImageSize);Ce.setCssStyles({position:"absolute",...Fe?{top:`${a+c}px`,left:`${s}px`,width:`${u}px`,height:`${d}px`}:{inset:"0"},backgroundImage:`url('${oe}')`,backgroundRepeat:Be.repeat,backgroundSize:Be.size,backgroundPosition:"center",opacity:String(m.backgroundImageOpacity),pointerEvents:"none"}),z.appendChild(Ce)}}let M=T.pageShowsHeader,X=T.pageShowsFooter;if(M&&m.showHeader&&m.headerImagePath){let oe=Cn(this.app,m.headerImagePath);if(oe){let Fe=activeDocument.createElement("div");Fe.setCssStyles({position:"absolute",top:`${a*.4}px`,left:`${m.headerImageMargin}px`,right:`${m.headerImageMargin}px`,height:`${c}px`,backgroundImage:`url('${oe}')`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",pointerEvents:"none"}),z.appendChild(Fe)}}if(T.hasHeader){let oe=activeDocument.createElement("div");oe.setCssStyles({position:"absolute",top:`${a*.4}px`,left:`${s}px`,right:`${f}px`,height:`${c}px`,display:"flex",alignItems:"center",fontSize:`${m.headerFontSize}px`,color:m.headerFontColor,fontFamily:h,whiteSpace:"nowrap",...m.showHeaderBorder?{borderBottom:`0.5px solid ${b}33`}:{}}),Yu(oe,T.headerCenter,T.headerLeft,T.headerRight),z.appendChild(oe)}let L=activeDocument.createElement("div");L.className="mpdf-doc",x&&L.setAttribute("dir","rtl"),L.setCssStyles({position:"absolute",top:`${a+c}px`,left:`${s}px`,width:`${u}px`});for(let oe of T.pageNodes)L.appendChild(oe.cloneNode(!0));if(z.appendChild(L),L.querySelectorAll("a[href^='#']").forEach(oe=>{let Fe=decodeURIComponent((oe.getAttribute("href")??"").slice(1)),Ce=y.get(Fe);Ce!==void 0&&(oe.title=`Go to page ${Ce+1}`,oe.addEventListener("click",Be=>{Be.preventDefault(),w[Ce]?.scrollIntoView({behavior:"smooth",block:"start"})}))}),X&&m.showFooter&&m.footerImagePath){let oe=Cn(this.app,m.footerImagePath);if(oe){let Fe=activeDocument.createElement("div");Fe.setCssStyles({position:"absolute",bottom:"0",left:`${m.footerImageMargin}px`,right:`${m.footerImageMargin}px`,height:`${l}px`,backgroundImage:`url('${oe}')`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",pointerEvents:"none"}),z.appendChild(Fe)}}if(T.hasFooter){let oe=activeDocument.createElement("div");oe.setCssStyles({position:"absolute",bottom:"0",left:"0",right:"0",height:`${l}px`,display:"flex",alignItems:"center",...m.showFooterBorder?{borderTop:`0.5px solid ${b}33`}:{},padding:`0 ${f}px 0 ${s}px`,fontSize:`${m.footerFontSize}px`,color:m.footerFontColor,fontFamily:h}),Yu(oe,T.footerCenter,T.footerLeft,T.footerRight),z.appendChild(oe)}let ye=Rm(m);ye&&z.appendChild(ye)}}async exportPDF(){let e=this.plugin.settings;this.exportBtn.disabled=!0,this.exportBtn.textContent="\u2B07 Exporting\u2026";let r=()=>{this.exportBtn.disabled=!1,this.exportBtn.textContent="\u2B07 Export PDF"};if(!this.layoutCache){this.renderDebounceTimer!==null&&(window.clearTimeout(this.renderDebounceTimer),this.renderDebounceTimer=null);let R=++this.renderToken;this.showLoading();try{await this.doRender(R)}catch(z){let M=z instanceof Error?z.message:String(z);new N.Notice("Advanced PDF Export \u2014 render failed: "+M),this.hideLoading(),r();return}}let n=this.layoutCache;if(!n||n.layouts.length===0){new N.Notice("Nothing to export."),r();return}let{layouts:o,pw:i,ph:a,mTop:s,mLeft:f,mRight:l,footerH:c,headerH:u,contentW:d,contentH:p,docCSS:h,fontFamily:b,accentColor:F,pageBackground:x,isRTL:m}=n,y=Om(e),w=e.showHeader&&e.headerImagePath?Cn(this.app,e.headerImagePath):"",S=e.showFooter&&e.footerImagePath?Cn(this.app,e.footerImagePath):"",D=e.backgroundImageEnabled&&e.backgroundImagePath?Cn(this.app,e.backgroundImagePath):"",T=D?(()=>{let R=Ku(e.backgroundImageSize),z=e.backgroundImageScope==="content-only"?`top:${s+u}px;left:${f}px;width:${d}px;height:${p}px;`:"inset:0;",M=`background-image:url('${D}');background-size:${R.size};background-repeat:${R.repeat};background-position:center;opacity:${e.backgroundImageOpacity};pointer-events:none;`;return`
`})():"",C=o.map(R=>{let z=R.pageNodes.map(Be=>Be.outerHTML).join(` +`),M=R.hasHeader,X=e.showHeaderBorder?`border-bottom:0.5px solid ${F}33;`:"",te=M?`
${Ju(R.headerCenter,R.headerLeft,R.headerRight)}
`:"",L=R.hasFooter,ue=e.showFooterBorder?`border-top:0.5px solid ${F}33;`:"",ye=L?`
${Ju(R.footerCenter,R.footerLeft,R.footerRight)}
`:"",oe=`
${z}
`,Fe=R.pageShowsHeader&&w?`
`:"",Ce=R.pageShowsFooter&&S?`
`:"";return`
${T}${Fe}${te}${oe}${Ce}${ye}${y}
`});await Ps();let E=await um(),I=` *, *::before, *::after { box-sizing: border-box; } @page { size: ${i}px ${a}px; margin: 0; } html, body { margin: 0; padding: 0; background: ${x}; } @@ -281,14 +285,14 @@ ${x}`:x,T=[];for(let E of y)T.push(...Cm(E,h,b,D));let C=km(T,r);this.layoutCach ${Ui(this.currentFile?.basename??"Export")} -${E?``:""} - +${E?``:""} + ${C.join(` `)} -`;try{let R=window,z=R.require("@electron/remote");if(!z?.dialog)throw new Error("no remote");let M=await z.dialog.showSaveDialog({title:"Save PDF",defaultPath:(this.currentFile?.basename??"export")+".pdf",filters:[{name:"PDF",extensions:["pdf"]}]});if(M.canceled||!M.filePath){r();return}new N.Notice("Advanced PDF Export \u2014 generating PDF\u2026");let X=new Blob([A],{type:"text/html"}),te=URL.createObjectURL(X),L=new z.BrowserWindow({show:!1,webPreferences:{nodeIntegration:!1}});L.loadURL(te);let ue=!1,ye=()=>{URL.revokeObjectURL(te),L.close(),r()};L.webContents.once("did-fail-load",(oe,Fe,Ce)=>{ue||(ue=!0,new N.Notice("Advanced PDF Export \u2014 failed to load page: "+Ce),ye())}),L.webContents.once("did-finish-load",()=>{ue||(ue=!0,L.webContents.executeJavaScript("document.fonts.ready.then(() => true)").catch(()=>!0).then(()=>{let oe=e.pageSize==="Custom";return L.webContents.printToPDF({pageSize:oe?"A4":e.pageSize,landscape:!oe&&e.orientation==="landscape",preferCSSPageSize:oe,printBackground:!0,margins:{marginType:"none"}})}).then(async oe=>{if(e.includeOutline)try{oe=await Em(oe,Tm(o))}catch(Fe){console.warn("[advanced-pdf-export] outline injection failed:",Fe)}R.require("fs").writeFile(M.filePath,oe,Fe=>{Fe?new N.Notice("Advanced PDF Export \u2014 failed to save: "+Fe.message):new N.Notice("\u2713 PDF saved \u2014 "+M.filePath),ye()})}).catch(oe=>{new N.Notice("Advanced PDF Export \u2014 failed to render: "+oe.message),ye()}))})}catch{new N.Notice("Advanced PDF Export requires the Obsidian desktop app."),r()}}},Ds=class extends N.PluginSettingTab{plugin;dirty=!1;constructor(e,r){super(e,r),this.plugin=r}display(){this.dirty=!1,this.buildSettings()}hide(){this.dirty&&(this.dirty=!1,this.plugin.activeModal?.render(!0))}async markDirty(){this.dirty=!0,await this.plugin.saveSettings()}buildSettings(){let{containerEl:e}=this;e.empty();let r=this.plugin.settings,n=(m,y,w,S)=>{let D=new N.Setting(e).setName(m);return S&&D.setDesc(S),D.addText(T=>T.setValue(String(r[y])).onChange(C=>{let E=parseInt(C,10)||0;r[y]=w!==void 0?Math.max(w,E):E,this.markDirty()}))},o=(m,y)=>new N.Setting(e).setName(m).addColorPicker(w=>w.setValue(r[y]).onChange(S=>{r[y]=S,this.markDirty()}));new N.Setting(e).setName("Style Preset").setHeading(),new N.Setting(e).setName("Preset").setDesc("Pick a preset to configure the overall document style. Fine-tune any setting below.").addDropdown(m=>{Object.entries(Tn).forEach(([y,w])=>{m.addOption(y,w.name)}),m.setValue(r.preset).onChange(y=>{this.plugin.applyPreset(y),this.markDirty().then(()=>{this.buildSettings()})})}).addButton(m=>m.setButtonText("Reset Preset").setTooltip("Reset current preset to its default values").onClick(()=>{this.plugin.applyPreset(r.preset,!0),this.markDirty().then(()=>{this.buildSettings()})})),new N.Setting(e).setName("Page").setHeading();let i;new N.Setting(e).setName("Page size").addDropdown(m=>{Object.keys(Vi).forEach(y=>{m.addOption(y,y)}),m.addOption("Custom","Custom\u2026"),m.setValue(r.pageSize).onChange(y=>{r.pageSize=y,i.settingEl.toggleClass("mpdf-is-hidden",y!=="Custom"),this.markDirty()})}),i=new N.Setting(e).setName("Custom page size (mm)").setDesc("Width \xD7 Height in millimetres.").addText(m=>m.setPlaceholder("Width").setValue(String(r.customPageWidth)).onChange(y=>{r.customPageWidth=Math.max(10,parseFloat(y)||210),this.markDirty()})).addText(m=>m.setPlaceholder("Height").setValue(String(r.customPageHeight)).onChange(y=>{r.customPageHeight=Math.max(10,parseFloat(y)||297),this.markDirty()})),i.settingEl.toggleClass("mpdf-is-hidden",r.pageSize!=="Custom"),new N.Setting(e).setName("Orientation").addDropdown(m=>m.addOptions({portrait:"Portrait",landscape:"Landscape"}).setValue(r.orientation).onChange(y=>{r.orientation=y,this.markDirty()})),new N.Setting(e).setName("Margin & Frame").setHeading(),new N.Setting(e).setName("Margins").setDesc("Top \xB7 Bottom \xB7 Left \xB7 Right").addText(m=>m.setPlaceholder("Top").setValue(String(r.marginTop)).onChange(y=>{r.marginTop=parseInt(y,10)||0,this.markDirty()})).addText(m=>m.setPlaceholder("Bottom").setValue(String(r.marginBottom)).onChange(y=>{r.marginBottom=parseInt(y,10)||0,this.markDirty()})).addText(m=>m.setPlaceholder("Left").setValue(String(r.marginLeft)).onChange(y=>{r.marginLeft=parseInt(y,10)||0,this.markDirty()})).addText(m=>m.setPlaceholder("Right").setValue(String(r.marginRight)).onChange(y=>{r.marginRight=parseInt(y,10)||0,this.markDirty()}));let a,s,f,l,c=m=>{[a,s,f,l].forEach(y=>y.settingEl.toggleClass("mpdf-is-hidden",!m))};new N.Setting(e).setName("Enable frame").setDesc("Draws a border around the outer edge of every page.").addToggle(m=>m.setValue(r.frameEnabled).onChange(y=>{r.frameEnabled=y,c(y),this.markDirty()})),a=o("Frame color","frameColor"),s=n("Frame thickness (px)","frameThickness",1),f=n("Frame margin (px)","frameMargin",0,"Gap between the page edge and the frame, applied equally on all four sides."),l=new N.Setting(e).setName("Frame style").addDropdown(m=>m.addOptions({solid:"Solid",dashed:"Dashed",dotted:"Dotted",double:"Double",groove:"Groove",ridge:"Ridge"}).setValue(r.frameStyle).onChange(y=>{r.frameStyle=y,this.markDirty()})),c(r.frameEnabled),new N.Setting(e).setName("Typography").setHeading();let u;new N.Setting(e).setName("Font family").addDropdown(m=>m.addOptions({"Georgia, serif":"Georgia (Serif)","'Times New Roman', Times, serif":"Times New Roman","'Palatino Linotype', Palatino, serif":"Palatino","Arial, sans-serif":"Arial","'Helvetica Neue', Helvetica, sans-serif":"Helvetica","'Trebuchet MS', sans-serif":"Trebuchet","'Courier New', monospace":"Courier New",__custom__:"Custom\u2026"}).setValue(r.fontFamily).onChange(y=>{r.fontFamily=y,u.settingEl.toggleClass("mpdf-is-hidden",y!=="__custom__"),this.markDirty()})),u=new N.Setting(e).setName("Custom font name").setDesc('CSS font-family value \u2014 e.g. "Inter, sans-serif". The font must be installed on your system.').addText(m=>m.setPlaceholder("e.g. Inter, sans-serif").setValue(r.customFontName).onChange(y=>{r.customFontName=y,this.markDirty()})),u.settingEl.toggleClass("mpdf-is-hidden",r.fontFamily!=="__custom__"),new N.Setting(e).setName("Font size (px)").addDropdown(m=>{["10","11","12","13","14","15","16"].forEach(y=>{m.addOption(y,y+"px")}),m.setValue(String(r.fontSize)).onChange(y=>{r.fontSize=parseInt(y),this.markDirty()})}),new N.Setting(e).setName("Code font size").addDropdown(m=>m.addOptions({"0.75":"0.75em","0.80":"0.80em","0.82":"0.82em","0.85":"0.85em","0.88":"0.88em","0.90":"0.90em","1.0":"1.00em"}).setValue(String(r.codeFontSize)).onChange(y=>{r.codeFontSize=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Line height").addDropdown(m=>m.addOptions({"1.4":"Tight (1.4)","1.6":"Compact (1.6)","1.75":"Normal (1.75)","1.85":"Relaxed (1.85)","2.0":"Double (2.0)"}).setValue(String(r.lineHeight)).onChange(y=>{r.lineHeight=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Paragraph spacing").addDropdown(m=>m.addOptions({0:"None","0.3":"Tight (0.3em)","0.5":"Normal (0.5em)","0.65":"Relaxed (0.65em)","1.0":"Wide (1em)"}).setValue(String(r.paragraphSpacing)).onChange(y=>{r.paragraphSpacing=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Heading scale").setDesc("Multiplier applied to all heading sizes.").addDropdown(m=>m.addOptions({"0.8":"Small (0.8\xD7)","0.88":"0.88\xD7","0.9":"Compact (0.9\xD7)","0.95":"0.95\xD7","1.0":"Normal (1.0\xD7)","1.05":"1.05\xD7","1.1":"Large (1.1\xD7)","1.2":"XLarge (1.2\xD7)"}).setValue(String(r.headingScale)).onChange(y=>{r.headingScale=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Background").setHeading();let d,p,h,b,F,x=m=>{d.settingEl.toggleClass("mpdf-is-hidden",m),[p,h,b,F].forEach(y=>y.settingEl.toggleClass("mpdf-is-hidden",!m))};new N.Setting(e).setName("Use image background").setDesc("When on, a background image is used instead of the solid background color.").addToggle(m=>m.setValue(r.backgroundImageEnabled).onChange(y=>{r.backgroundImageEnabled=y,x(y),this.markDirty()})),d=new N.Setting(e).setName("Page background color").addColorPicker(m=>m.setValue(r.pageBackground).onChange(y=>{r.pageBackground=y,this.markDirty()})),p=new N.Setting(e).setName("Background image").setDesc("Vault-relative path or https:// URL.").addText(m=>m.setPlaceholder("assets/background.png").setValue(r.backgroundImagePath).onChange(y=>{r.backgroundImagePath=y,this.markDirty()})),h=new N.Setting(e).setName("Fit").addDropdown(m=>m.addOptions({cover:"Cover (fill, crop edges)",contain:"Contain (fit, show gaps)",fill:"Fill (stretch to exact size)",tile:"Tile (repeat)"}).setValue(r.backgroundImageSize).onChange(y=>{r.backgroundImageSize=y,this.markDirty()})),b=new N.Setting(e).setName("Scope").setDesc("Full page includes header and footer bands. Content area only restricts the background to the text zone between them.").addDropdown(m=>m.addOptions({"full-page":"Full page","content-only":"Content area only"}).setValue(r.backgroundImageScope).onChange(y=>{r.backgroundImageScope=y,this.markDirty()})),F=new N.Setting(e).setName("Opacity").addDropdown(m=>m.addOptions({"0.05":"5%","0.1":"10%","0.15":"15%","0.2":"20%","0.3":"30%","0.4":"40%","0.5":"50%","0.6":"60%","0.7":"70%","0.8":"80%","0.9":"90%",1:"100%"}).setValue(String(r.backgroundImageOpacity)).onChange(y=>{r.backgroundImageOpacity=parseFloat(y),this.markDirty()})),x(r.backgroundImageEnabled),new N.Setting(e).setName("Colors").setHeading(),o("Accent color","accentColor"),o("Body text color","bodyColor"),o("Heading color","headingColor"),o("Blockquote background","blockquoteBg"),o("Blockquote border","blockquoteBorderColor"),o("Table header background","tableHeaderBg"),o("Code background","codeBackground"),new N.Setting(e).setName("Code syntax theme").setDesc('Independent of your Obsidian theme. "None" uses the body text color and code background above with no highlighting.').addDropdown(m=>{let y={};for(let[w,S]of Object.entries(Ss))y[w]=S.name;m.addOptions(y).setValue(r.codeTheme).onChange(w=>{r.codeTheme=w,this.markDirty()})}),new N.Setting(e).setName("Header").setHeading(),new N.Setting(e).setName("Show header").addToggle(m=>m.setValue(r.showHeader).onChange(y=>{r.showHeader=y,this.markDirty()})),new N.Setting(e).setName("Show on first page").setDesc("When off, the header is hidden on page 1. Useful for title pages.").addToggle(m=>m.setValue(r.showHeaderOnFirstPage).onChange(y=>{r.showHeaderOnFirstPage=y,this.markDirty()})),new N.Setting(e).setName("Header text").addText(m=>m.setValue(r.headerText).onChange(y=>{r.headerText=y,this.markDirty()})),new N.Setting(e).setName("Alignment").addDropdown(m=>m.addOptions({left:"Left",center:"Center",right:"Right"}).setValue(r.headerAlignment).onChange(y=>{r.headerAlignment=y,this.markDirty()})),n("Font size (px)","headerFontSize",1),n("Height (px)","headerHeight",0,"Explicit band height (0 = auto)."),o("Font color","headerFontColor"),new N.Setting(e).setName("Border").setDesc("Separator line below the header.").addToggle(m=>m.setValue(r.showHeaderBorder).onChange(y=>{r.showHeaderBorder=y,this.markDirty()})),new N.Setting(e).setName("Image").setDesc("Vault-relative path or https:// URL. Fills the header band as a background banner.").addText(m=>m.setPlaceholder("assets/header-banner.png").setValue(r.headerImagePath).onChange(y=>{r.headerImagePath=y,this.markDirty()})),n("Image left/right margin (px)","headerImageMargin",0,"Insets the banner from the left and right page edges."),new N.Setting(e).setName("Footer").setHeading(),new N.Setting(e).setName("Show footer").addToggle(m=>m.setValue(r.showFooter).onChange(y=>{r.showFooter=y,this.markDirty()})),new N.Setting(e).setName("Show on first page").setDesc("When off, the footer and page numbers are hidden on page 1. Page numbering starts from page 2.").addToggle(m=>m.setValue(r.showFooterOnFirstPage).onChange(y=>{r.showFooterOnFirstPage=y,this.markDirty()})),new N.Setting(e).setName("Footer text").addText(m=>m.setValue(r.footerText).onChange(y=>{r.footerText=y,this.markDirty()})),new N.Setting(e).setName("Alignment").addDropdown(m=>m.addOptions({left:"Left",center:"Center",right:"Right"}).setValue(r.footerTextAlignment).onChange(y=>{r.footerTextAlignment=y,this.markDirty()})),n("Font size (px)","footerFontSize",1),n("Height (px)","footerHeight",0,"Explicit band height (0 = auto)."),o("Font color","footerFontColor"),new N.Setting(e).setName("Border").setDesc("Separator line above the footer.").addToggle(m=>m.setValue(r.showFooterBorder).onChange(y=>{r.showFooterBorder=y,this.markDirty()})),new N.Setting(e).setName("Image").setDesc("Vault-relative path or https:// URL. Fills the footer band as a background banner.").addText(m=>m.setPlaceholder("assets/footer-banner.png").setValue(r.footerImagePath).onChange(y=>{r.footerImagePath=y,this.markDirty()})),n("Image left/right margin (px)","footerImageMargin",0,"Insets the banner from the left and right page edges."),new N.Setting(e).setName("Show page numbers").addToggle(m=>m.setValue(r.showPageNumbers).onChange(y=>{r.showPageNumbers=y,this.markDirty()})),new N.Setting(e).setName("Page number position").addDropdown(m=>m.addOptions({left:"Left",center:"Center",right:"Right"}).setValue(r.pageNumberPosition).onChange(y=>{r.pageNumberPosition=y,this.markDirty()})),new N.Setting(e).setName("Page number start").setDesc("Number assigned to the first visible page number.").addText(m=>m.setValue(String(r.pageNumberStart)).onChange(y=>{r.pageNumberStart=parseInt(y,10)||1,this.markDirty()})),new N.Setting(e).setName("Behaviour").setHeading(),new N.Setting(e).setName("Hide frontmatter").setDesc("Strip the YAML frontmatter block (--- \u2026 ---) from the preview and exported PDF.").addToggle(m=>m.setValue(r.hideFrontmatter).onChange(y=>{r.hideFrontmatter=y,this.markDirty()})),new N.Setting(e).setName("Include file name as title").setDesc("Prepend the note's file name as an H1 heading at the top of the PDF.").addToggle(m=>m.setValue(r.includeFilenameAsTitle).onChange(y=>{r.includeFilenameAsTitle=y,this.markDirty()})),new N.Setting(e).setName("Underline links").setDesc("Applies to both internal and external links.").addToggle(m=>m.setValue(r.linkUnderline).onChange(y=>{r.linkUnderline=y,this.markDirty()})),new N.Setting(e).setName("Auto page break before H1").addToggle(m=>m.setValue(r.autoBreakH1).onChange(y=>{r.autoBreakH1=y,this.markDirty()})),new N.Setting(e).setName("Auto page break before H2").addToggle(m=>m.setValue(r.autoBreakH2).onChange(y=>{r.autoBreakH2=y,this.markDirty()})),new N.Setting(e).setName("H1 bottom border").addToggle(m=>m.setValue(r.h1BorderBottom).onChange(y=>{r.h1BorderBottom=y,this.markDirty()})),new N.Setting(e).setName("H2 bottom border").addToggle(m=>m.setValue(r.h2BorderBottom).onChange(y=>{r.h2BorderBottom=y,this.markDirty()})),new N.Setting(e).setName("Center H1").addToggle(m=>m.setValue(r.centerH1).onChange(y=>{r.centerH1=y,this.markDirty()})),new N.Setting(e).setName("Striped table rows").addToggle(m=>m.setValue(r.tableStriped).onChange(y=>{r.tableStriped=y,this.markDirty()})),new N.Setting(e).setName("Include PDF outline (bookmarks)").setDesc("Embeds a bookmark tree into the exported PDF. Most PDF readers display it in a side panel for quick navigation.").addToggle(m=>m.setValue(r.includeOutline).onChange(y=>{r.includeOutline=y,this.markDirty()}))}}; +`;try{let R=window,z=R.require("@electron/remote");if(!z?.dialog)throw new Error("no remote");let M=await z.dialog.showSaveDialog({title:"Save PDF",defaultPath:(this.currentFile?.basename??"export")+".pdf",filters:[{name:"PDF",extensions:["pdf"]}]});if(M.canceled||!M.filePath){r();return}new N.Notice("Advanced PDF Export \u2014 generating PDF\u2026");let X=new Blob([A],{type:"text/html"}),te=URL.createObjectURL(X),L=new z.BrowserWindow({show:!1,webPreferences:{nodeIntegration:!1}});L.loadURL(te);let ue=!1,ye=()=>{URL.revokeObjectURL(te),L.close(),r()};L.webContents.once("did-fail-load",(oe,Fe,Ce)=>{ue||(ue=!0,new N.Notice("Advanced PDF Export \u2014 failed to load page: "+Ce),ye())}),L.webContents.once("did-finish-load",()=>{ue||(ue=!0,L.webContents.executeJavaScript("document.fonts.ready.then(() => true)").catch(()=>!0).then(()=>{let oe=e.pageSize==="Custom";return L.webContents.printToPDF({pageSize:oe?"A4":e.pageSize,landscape:!oe&&e.orientation==="landscape",preferCSSPageSize:oe,printBackground:!0,margins:{marginType:"none"}})}).then(async oe=>{if(e.includeOutline)try{oe=await Am(oe,Em(o))}catch(Fe){console.warn("[advanced-pdf-export] outline injection failed:",Fe)}R.require("fs").writeFile(M.filePath,oe,Fe=>{Fe?new N.Notice("Advanced PDF Export \u2014 failed to save: "+Fe.message):new N.Notice("\u2713 PDF saved \u2014 "+M.filePath),ye()})}).catch(oe=>{new N.Notice("Advanced PDF Export \u2014 failed to render: "+oe.message),ye()}))})}catch{new N.Notice("Advanced PDF Export requires the Obsidian desktop app."),r()}}},ks=class extends N.PluginSettingTab{plugin;dirty=!1;constructor(e,r){super(e,r),this.plugin=r}display(){this.dirty=!1,this.buildSettings()}hide(){this.dirty&&(this.dirty=!1,this.plugin.activeModal?.render(!0))}async markDirty(){this.dirty=!0,await this.plugin.saveSettings()}buildSettings(){let{containerEl:e}=this;e.empty();let r=this.plugin.settings,n=(m,y,w,S)=>{let D=new N.Setting(e).setName(m);return S&&D.setDesc(S),D.addText(T=>T.setValue(String(r[y])).onChange(C=>{let E=parseInt(C,10)||0;r[y]=w!==void 0?Math.max(w,E):E,this.markDirty()}))},o=(m,y)=>new N.Setting(e).setName(m).addColorPicker(w=>w.setValue(r[y]).onChange(S=>{r[y]=S,this.markDirty()}));new N.Setting(e).setName("Style Preset").setHeading(),new N.Setting(e).setName("Preset").setDesc("Pick a preset to configure the overall document style. Fine-tune any setting below.").addDropdown(m=>{Object.entries(Tn).forEach(([y,w])=>{m.addOption(y,w.name)}),m.setValue(r.preset).onChange(y=>{this.plugin.applyPreset(y),this.markDirty().then(()=>{this.buildSettings()})})}).addButton(m=>m.setButtonText("Reset Preset").setTooltip("Reset current preset to its default values").onClick(()=>{this.plugin.applyPreset(r.preset,!0),this.markDirty().then(()=>{this.buildSettings()})})),new N.Setting(e).setName("Page").setHeading();let i;new N.Setting(e).setName("Page size").addDropdown(m=>{Object.keys(Vi).forEach(y=>{m.addOption(y,y)}),m.addOption("Custom","Custom\u2026"),m.setValue(r.pageSize).onChange(y=>{r.pageSize=y,i.settingEl.toggleClass("mpdf-is-hidden",y!=="Custom"),this.markDirty()})}),i=new N.Setting(e).setName("Custom page size (mm)").setDesc("Width \xD7 Height in millimetres.").addText(m=>m.setPlaceholder("Width").setValue(String(r.customPageWidth)).onChange(y=>{r.customPageWidth=Math.max(10,parseFloat(y)||210),this.markDirty()})).addText(m=>m.setPlaceholder("Height").setValue(String(r.customPageHeight)).onChange(y=>{r.customPageHeight=Math.max(10,parseFloat(y)||297),this.markDirty()})),i.settingEl.toggleClass("mpdf-is-hidden",r.pageSize!=="Custom"),new N.Setting(e).setName("Orientation").addDropdown(m=>m.addOptions({portrait:"Portrait",landscape:"Landscape"}).setValue(r.orientation).onChange(y=>{r.orientation=y,this.markDirty()})),new N.Setting(e).setName("Margin & Frame").setHeading(),new N.Setting(e).setName("Margins").setDesc("Top \xB7 Bottom \xB7 Left \xB7 Right").addText(m=>m.setPlaceholder("Top").setValue(String(r.marginTop)).onChange(y=>{r.marginTop=parseInt(y,10)||0,this.markDirty()})).addText(m=>m.setPlaceholder("Bottom").setValue(String(r.marginBottom)).onChange(y=>{r.marginBottom=parseInt(y,10)||0,this.markDirty()})).addText(m=>m.setPlaceholder("Left").setValue(String(r.marginLeft)).onChange(y=>{r.marginLeft=parseInt(y,10)||0,this.markDirty()})).addText(m=>m.setPlaceholder("Right").setValue(String(r.marginRight)).onChange(y=>{r.marginRight=parseInt(y,10)||0,this.markDirty()}));let a,s,f,l,c=m=>{[a,s,f,l].forEach(y=>y.settingEl.toggleClass("mpdf-is-hidden",!m))};new N.Setting(e).setName("Enable frame").setDesc("Draws a border around the outer edge of every page.").addToggle(m=>m.setValue(r.frameEnabled).onChange(y=>{r.frameEnabled=y,c(y),this.markDirty()})),a=o("Frame color","frameColor"),s=n("Frame thickness (px)","frameThickness",1),f=n("Frame margin (px)","frameMargin",0,"Gap between the page edge and the frame, applied equally on all four sides."),l=new N.Setting(e).setName("Frame style").addDropdown(m=>m.addOptions({solid:"Solid",dashed:"Dashed",dotted:"Dotted",double:"Double",groove:"Groove",ridge:"Ridge"}).setValue(r.frameStyle).onChange(y=>{r.frameStyle=y,this.markDirty()})),c(r.frameEnabled),new N.Setting(e).setName("Typography").setHeading();let u;new N.Setting(e).setName("Font family").addDropdown(m=>m.addOptions({"Georgia, serif":"Georgia (Serif)","'Times New Roman', Times, serif":"Times New Roman","'Palatino Linotype', Palatino, serif":"Palatino","Arial, sans-serif":"Arial","'Helvetica Neue', Helvetica, sans-serif":"Helvetica","'Trebuchet MS', sans-serif":"Trebuchet","'Courier New', monospace":"Courier New",__custom__:"Custom\u2026"}).setValue(r.fontFamily).onChange(y=>{r.fontFamily=y,u.settingEl.toggleClass("mpdf-is-hidden",y!=="__custom__"),this.markDirty()})),u=new N.Setting(e).setName("Custom font name").setDesc('CSS font-family value \u2014 e.g. "Inter, sans-serif". The font must be installed on your system.').addText(m=>m.setPlaceholder("e.g. Inter, sans-serif").setValue(r.customFontName).onChange(y=>{r.customFontName=y,this.markDirty()})),u.settingEl.toggleClass("mpdf-is-hidden",r.fontFamily!=="__custom__"),new N.Setting(e).setName("Font size (px)").addDropdown(m=>{["10","11","12","13","14","15","16"].forEach(y=>{m.addOption(y,y+"px")}),m.setValue(String(r.fontSize)).onChange(y=>{r.fontSize=parseInt(y),this.markDirty()})}),new N.Setting(e).setName("Code font size").addDropdown(m=>m.addOptions({"0.75":"0.75em","0.80":"0.80em","0.82":"0.82em","0.85":"0.85em","0.88":"0.88em","0.90":"0.90em","1.0":"1.00em"}).setValue(String(r.codeFontSize)).onChange(y=>{r.codeFontSize=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Line height").addDropdown(m=>m.addOptions({"1.4":"Tight (1.4)","1.6":"Compact (1.6)","1.75":"Normal (1.75)","1.85":"Relaxed (1.85)","2.0":"Double (2.0)"}).setValue(String(r.lineHeight)).onChange(y=>{r.lineHeight=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Paragraph spacing").addDropdown(m=>m.addOptions({0:"None","0.3":"Tight (0.3em)","0.5":"Normal (0.5em)","0.65":"Relaxed (0.65em)","1.0":"Wide (1em)"}).setValue(String(r.paragraphSpacing)).onChange(y=>{r.paragraphSpacing=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Heading scale").setDesc("Multiplier applied to all heading sizes.").addDropdown(m=>m.addOptions({"0.8":"Small (0.8\xD7)","0.88":"0.88\xD7","0.9":"Compact (0.9\xD7)","0.95":"0.95\xD7","1.0":"Normal (1.0\xD7)","1.05":"1.05\xD7","1.1":"Large (1.1\xD7)","1.2":"XLarge (1.2\xD7)"}).setValue(String(r.headingScale)).onChange(y=>{r.headingScale=parseFloat(y),this.markDirty()})),new N.Setting(e).setName("Background").setHeading();let d,p,h,b,F,x=m=>{d.settingEl.toggleClass("mpdf-is-hidden",m),[p,h,b,F].forEach(y=>y.settingEl.toggleClass("mpdf-is-hidden",!m))};new N.Setting(e).setName("Use image background").setDesc("When on, a background image is used instead of the solid background color.").addToggle(m=>m.setValue(r.backgroundImageEnabled).onChange(y=>{r.backgroundImageEnabled=y,x(y),this.markDirty()})),d=new N.Setting(e).setName("Page background color").addColorPicker(m=>m.setValue(r.pageBackground).onChange(y=>{r.pageBackground=y,this.markDirty()})),p=new N.Setting(e).setName("Background image").setDesc("Vault-relative path or https:// URL.").addText(m=>m.setPlaceholder("assets/background.png").setValue(r.backgroundImagePath).onChange(y=>{r.backgroundImagePath=y,this.markDirty()})),h=new N.Setting(e).setName("Fit").addDropdown(m=>m.addOptions({cover:"Cover (fill, crop edges)",contain:"Contain (fit, show gaps)",fill:"Fill (stretch to exact size)",tile:"Tile (repeat)"}).setValue(r.backgroundImageSize).onChange(y=>{r.backgroundImageSize=y,this.markDirty()})),b=new N.Setting(e).setName("Scope").setDesc("Full page includes header and footer bands. Content area only restricts the background to the text zone between them.").addDropdown(m=>m.addOptions({"full-page":"Full page","content-only":"Content area only"}).setValue(r.backgroundImageScope).onChange(y=>{r.backgroundImageScope=y,this.markDirty()})),F=new N.Setting(e).setName("Opacity").addDropdown(m=>m.addOptions({"0.05":"5%","0.1":"10%","0.15":"15%","0.2":"20%","0.3":"30%","0.4":"40%","0.5":"50%","0.6":"60%","0.7":"70%","0.8":"80%","0.9":"90%",1:"100%"}).setValue(String(r.backgroundImageOpacity)).onChange(y=>{r.backgroundImageOpacity=parseFloat(y),this.markDirty()})),x(r.backgroundImageEnabled),new N.Setting(e).setName("Colors").setHeading(),o("Accent color","accentColor"),o("Body text color","bodyColor"),o("Heading color","headingColor"),o("Blockquote background","blockquoteBg"),o("Blockquote border","blockquoteBorderColor"),o("Table header background","tableHeaderBg"),o("Code background","codeBackground"),new N.Setting(e).setName("Code syntax theme").setDesc('Independent of your Obsidian theme. "None" uses the body text color and code background above with no highlighting.').addDropdown(m=>{let y={};for(let[w,S]of Object.entries(Ds))y[w]=S.name;m.addOptions(y).setValue(r.codeTheme).onChange(w=>{r.codeTheme=w,this.markDirty()})}),new N.Setting(e).setName("Header").setHeading(),new N.Setting(e).setName("Show header").addToggle(m=>m.setValue(r.showHeader).onChange(y=>{r.showHeader=y,this.markDirty()})),new N.Setting(e).setName("Show on first page").setDesc("When off, the header is hidden on page 1. Useful for title pages.").addToggle(m=>m.setValue(r.showHeaderOnFirstPage).onChange(y=>{r.showHeaderOnFirstPage=y,this.markDirty()})),new N.Setting(e).setName("Header text").addText(m=>m.setValue(r.headerText).onChange(y=>{r.headerText=y,this.markDirty()})),new N.Setting(e).setName("Alignment").addDropdown(m=>m.addOptions({left:"Left",center:"Center",right:"Right"}).setValue(r.headerAlignment).onChange(y=>{r.headerAlignment=y,this.markDirty()})),n("Font size (px)","headerFontSize",1),n("Height (px)","headerHeight",0,"Explicit band height (0 = auto)."),o("Font color","headerFontColor"),new N.Setting(e).setName("Border").setDesc("Separator line below the header.").addToggle(m=>m.setValue(r.showHeaderBorder).onChange(y=>{r.showHeaderBorder=y,this.markDirty()})),new N.Setting(e).setName("Image").setDesc("Vault-relative path or https:// URL. Fills the header band as a background banner.").addText(m=>m.setPlaceholder("assets/header-banner.png").setValue(r.headerImagePath).onChange(y=>{r.headerImagePath=y,this.markDirty()})),n("Image left/right margin (px)","headerImageMargin",0,"Insets the banner from the left and right page edges."),new N.Setting(e).setName("Footer").setHeading(),new N.Setting(e).setName("Show footer").addToggle(m=>m.setValue(r.showFooter).onChange(y=>{r.showFooter=y,this.markDirty()})),new N.Setting(e).setName("Show on first page").setDesc("When off, the footer and page numbers are hidden on page 1. Page numbering starts from page 2.").addToggle(m=>m.setValue(r.showFooterOnFirstPage).onChange(y=>{r.showFooterOnFirstPage=y,this.markDirty()})),new N.Setting(e).setName("Footer text").addText(m=>m.setValue(r.footerText).onChange(y=>{r.footerText=y,this.markDirty()})),new N.Setting(e).setName("Alignment").addDropdown(m=>m.addOptions({left:"Left",center:"Center",right:"Right"}).setValue(r.footerTextAlignment).onChange(y=>{r.footerTextAlignment=y,this.markDirty()})),n("Font size (px)","footerFontSize",1),n("Height (px)","footerHeight",0,"Explicit band height (0 = auto)."),o("Font color","footerFontColor"),new N.Setting(e).setName("Border").setDesc("Separator line above the footer.").addToggle(m=>m.setValue(r.showFooterBorder).onChange(y=>{r.showFooterBorder=y,this.markDirty()})),new N.Setting(e).setName("Image").setDesc("Vault-relative path or https:// URL. Fills the footer band as a background banner.").addText(m=>m.setPlaceholder("assets/footer-banner.png").setValue(r.footerImagePath).onChange(y=>{r.footerImagePath=y,this.markDirty()})),n("Image left/right margin (px)","footerImageMargin",0,"Insets the banner from the left and right page edges."),new N.Setting(e).setName("Show page numbers").addToggle(m=>m.setValue(r.showPageNumbers).onChange(y=>{r.showPageNumbers=y,this.markDirty()})),new N.Setting(e).setName("Page number position").addDropdown(m=>m.addOptions({left:"Left",center:"Center",right:"Right"}).setValue(r.pageNumberPosition).onChange(y=>{r.pageNumberPosition=y,this.markDirty()})),new N.Setting(e).setName("Page number start").setDesc("Number assigned to the first visible page number.").addText(m=>m.setValue(String(r.pageNumberStart)).onChange(y=>{r.pageNumberStart=parseInt(y,10)||1,this.markDirty()})),new N.Setting(e).setName("Behaviour").setHeading(),new N.Setting(e).setName("Hide frontmatter").setDesc("Strip the YAML frontmatter block (--- \u2026 ---) from the preview and exported PDF.").addToggle(m=>m.setValue(r.hideFrontmatter).onChange(y=>{r.hideFrontmatter=y,this.markDirty()})),new N.Setting(e).setName("Include file name as title").setDesc("Prepend the note's file name as an H1 heading at the top of the PDF.").addToggle(m=>m.setValue(r.includeFilenameAsTitle).onChange(y=>{r.includeFilenameAsTitle=y,this.markDirty()})),new N.Setting(e).setName("Underline links").setDesc("Applies to both internal and external links.").addToggle(m=>m.setValue(r.linkUnderline).onChange(y=>{r.linkUnderline=y,this.markDirty()})),new N.Setting(e).setName("Auto page break before H1").addToggle(m=>m.setValue(r.autoBreakH1).onChange(y=>{r.autoBreakH1=y,this.markDirty()})),new N.Setting(e).setName("Auto page break before H2").addToggle(m=>m.setValue(r.autoBreakH2).onChange(y=>{r.autoBreakH2=y,this.markDirty()})),new N.Setting(e).setName("H1 bottom border").addToggle(m=>m.setValue(r.h1BorderBottom).onChange(y=>{r.h1BorderBottom=y,this.markDirty()})),new N.Setting(e).setName("H2 bottom border").addToggle(m=>m.setValue(r.h2BorderBottom).onChange(y=>{r.h2BorderBottom=y,this.markDirty()})),new N.Setting(e).setName("Center H1").addToggle(m=>m.setValue(r.centerH1).onChange(y=>{r.centerH1=y,this.markDirty()})),new N.Setting(e).setName("Striped table rows").addToggle(m=>m.setValue(r.tableStriped).onChange(y=>{r.tableStriped=y,this.markDirty()})),new N.Setting(e).setName("Include PDF outline (bookmarks)").setDesc("Embeds a bookmark tree into the exported PDF. Most PDF readers display it in a side panel for quick navigation.").addToggle(m=>m.setValue(r.includeOutline).onChange(y=>{r.includeOutline=y,this.markDirty()}))}}; /*! Bundled license information: tslib/tslib.es6.js: diff --git a/main.ts b/main.ts index cf66a5a..203623d 100644 --- a/main.ts +++ b/main.ts @@ -1,6 +1,7 @@ import { App, Component, MarkdownRenderer, MarkdownView, Menu, Modal, Notice, Plugin, PluginSettingTab, Setting, TFile, requestUrl, setIcon, + finishRenderMath, } from "obsidian"; import { PDFArray, PDFDict, PDFDocument, PDFHexString, PDFName, PDFNull, PDFNumber } from "pdf-lib"; @@ -524,6 +525,13 @@ async function renderMarkdownToEl( activeDocument.body.appendChild(temp); try { await MarkdownRenderer.render(app, markdown, temp, sourcePath, component); + // MarkdownRenderer.render()'s own promise can resolve before math queued by + // its internal post-processor (via renderMath()) has actually finished + // typesetting. finishRenderMath() is Obsidian's documented way to flush that + // shared queue — it's the fix for this specific race, not just another + // heuristic wait. Best-effort: if it's unavailable or throws, the + // mjx-container + stylesheet-stability waits below are the backstop. + try { await finishRenderMath(); } catch { /* non-critical — see waitForMathRendering */ } await waitForMermaidDiagrams(temp); await waitForMathRendering(temp); // Wait for MathJax's lazily-loaded @font-face files to arrive before we @@ -626,8 +634,31 @@ async function waitForMermaidDiagrams(el: HTMLElement): Promise { } /** Waits for MathJax to finish typesetting `.math` spans (native math and Latex - * Suite equations use the same renderer). Drains the shared `startup.promise` - * queue first, then falls back to a per-element observer, timing out at 8 s. */ + * Suite equations use the same renderer), AND for its CHTML stylesheet to stop + * mutating. + * + * `MathJax.startup.promise` is awaited first as a cheap early gate, but it is + * NOT a per-render "queue drained" signal — it resolves once, at MathJax's + * initial boot, and will already be resolved by the time this plugin runs. It + * proves nothing about whether *this* render pass is finished. + * + * The per-element `mjx-container` observer below is also insufficient on its + * own: it only proves the DOM shell for a piece of math has landed. MathJax's + * CHTML output uses `adaptiveCSS` — it generates the actual per-character CSS + * rules (the `.mjx-c…` class rules that map a glyph to `content` + a specific + * `font-family`) incrementally, into a shared, session-level stylesheet, as + * new characters are encountered. That stylesheet write is not guaranteed to + * have landed by the moment the container appears. In practice this meant + * common glyphs (plain digits/letters, from the Main/Math-Italic fonts) were + * always fine, while less-common ones — AMS symbols, blackboard-bold letters, + * bold text, Fraktur/Script/etc. — intermittently rendered as invisible + * characters in exported PDFs, because their CSS rules simply weren't in the + * stylesheet yet when it was captured for export. + * + * So after the DOM wait, we also poll the shared stylesheet + * (`waitForMathJaxStylesheetStable`) until it stops growing before declaring + * math "done". Total wait is bounded (8s for the DOM wait, +2.5s for the + * stylesheet wait) so a genuinely stuck render can't hang the export forever. */ async function waitForMathRendering(el: HTMLElement): Promise { const containers = Array.from(el.querySelectorAll(".math")); if (containers.length === 0) return; @@ -658,6 +689,36 @@ async function waitForMathRendering(el: HTMLElement): Promise { }), ), ); + + await waitForMathJaxStylesheetStable(); +} + +/** Polls MathJax's shared `style[id^='MJX-']` stylesheet (see `getMathJaxCSS`) + * until its total size stops changing for a couple of consecutive checks. + * This is the actual completion signal for `adaptiveCSS`-generated per-glyph + * rules — DOM insertion of `mjx-container` alone doesn't guarantee they've + * been flushed yet (see `waitForMathRendering`). Bounded by MAX_WAIT_MS so a + * stylesheet that's genuinely done (nothing left to add) can't stall forever; + * in the common case where nothing new is pending, this resolves in ~2 polls. */ +async function waitForMathJaxStylesheetStable(): Promise { + const POLL_MS = 60; + const STABLE_ROUNDS = 2; + const MAX_WAIT_MS = 2500; + + const start = Date.now(); + let lastLen = getMathJaxCSS().length; + let stableRounds = 0; + + while (stableRounds < STABLE_ROUNDS && Date.now() - start < MAX_WAIT_MS) { + await new Promise((resolve) => window.setTimeout(resolve, POLL_MS)); + const len = getMathJaxCSS().length; + if (len === lastLen) { + stableRounds++; + } else { + stableRounds = 0; + lastLen = len; + } + } } // ─── Code block syntax highlighting ──────────────────────────────────────── @@ -1036,13 +1097,73 @@ function extractDocStyle(s: PDFExportSettings): DocStyle { }; } -/** Collects MathJax's injected stylesheets for inclusion in shadow DOMs and - * the export HTML. Targets `MJX-` prefixed IDs to avoid capturing unrelated - * theme stylesheets that Obsidian injects into the document head. */ +/** Collects MathJax's CSS for inclusion in shadow DOMs and the export HTML. + * + * This has to check three sources, and missing any one causes specific + * glyphs to render as blank/invisible while everything else looks fine — + * confirmed directly: `mjx-c2135` (aleph) paints correctly in native reading + * view, yet is absent from every `