2025-02-18 05:37:27 -03:00
/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
2025-03-07 06:22:58 -03:00
var S1 = Object . create ; var La = Object . defineProperty ; var E1 = Object . getOwnPropertyDescriptor ; var T1 = Object . getOwnPropertyNames ; var A1 = Object . getPrototypeOf , I1 = Object . prototype . hasOwnProperty ; var bm = n => { throw TypeError ( n ) } ; var B1 = ( n , e , t ) => e in n ? La ( n , e , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : t } ) : n [ e ] = t ; var J = ( n , e ) => ( ) => ( e || n ( ( e = { exports : { } } ) . exports , e ) , e . exports ) , b0 = ( n , e ) => { for ( var t in e ) La ( n , t , { get : e [ t ] , enumerable : ! 0 } ) } , ym = ( n , e , t , i ) => { if ( e && typeof e == "object" || typeof e == "function" ) for ( let r of T1 ( e ) ) ! I1 . call ( n , r ) && r !== t && La ( n , r , { get : ( ) => e [ r ] , enumerable : ! ( i = E1 ( e , r ) ) || i . enumerable } ) ; return n } ; var Ki = ( n , e , t ) => ( t = n != null ? S1 ( A1 ( n ) ) : { } , ym ( e || ! n || ! n . _ _esModule ? La ( t , "default" , { value : n , enumerable : ! 0 } ) : t , n ) ) , L1 = n => ym ( La ( { } , "__esModule" , { value : ! 0 } ) , n ) ; var y0 = ( n , e , t ) => B1 ( n , typeof e != "symbol" ? e + "" : e , t ) , vm = ( n , e , t ) => e . has ( n ) || bm ( "Cannot " + t ) ; var Ge = ( n , e , t ) => ( vm ( n , e , "read from private field" ) , t ? t . call ( n ) : e . get ( n ) ) , mn = ( n , e , t ) => e . has ( n ) ? bm ( "Cannot add the same private member more than once" ) : e instanceof WeakSet ? e . add ( n ) : e . set ( n , t ) , Ot = ( n , e , t , i ) => ( vm ( n , e , "write to private field" ) , i ? i . call ( n , t ) : e . set ( n , t ) , t ) ; var v0 = ( n , e , t , i ) => ( { set _ ( r ) { Ot ( n , e , r , t ) } , get _ ( ) { return Ge ( n , e , i ) } } ) ; var bn = J ( St => { "use strict" ; var q1 = typeof Uint8Array != "undefined" && typeof Uint16Array != "undefined" && typeof Int32Array != "undefined" ; function W1 ( n , e ) { return Object . prototype . hasOwnProperty . call ( n , e ) } St . assign = function ( n ) { for ( var e = Array . prototype . slice . call ( arguments , 1 ) ; e . length ; ) { var t = e . shift ( ) ; if ( t ) { if ( typeof t != "object" ) throw new TypeError ( t + "must be non-object" ) ; for ( var i in t ) W1 ( t , i ) && ( n [ i ] = t [ i ] ) } } return n } ; St . shrinkBuf = function ( n , e ) { return n . length === e ? n : n . subarray ? n . subarray ( 0 , e ) : ( n . length = e , n ) } ; var j1 = { arraySet : function ( n , e , t , i , r ) { if ( e . subarray && n . subarray ) { n . set ( e . subarray ( t , t + i ) , r ) ; return } for ( var o = 0 ; o < i ; o ++ ) n [ r + o ] = e [ t + o ] } , flattenChunks : function ( n ) { var e , t , i , r , o , s ; for ( i = 0 , e = 0 , t = n . length ; e < t ; e ++ ) i += n [ e ] . length ; for ( s = new Uint8Array ( i ) , r = 0 , e = 0 , t = n . length ; e < t ; e ++ ) o = n [ e ] , s . set ( o , r ) , r += o . length ; return s } } , K1 = { arraySet : function ( n , e , t , i , r ) { for ( var o = 0 ; o < i ; o ++ ) n [ r + o ] = e [ t + o ] } , flattenChunks : function ( n ) { return [ ] . concat . apply ( [ ] , n ) } } ; St . setTyped = function ( n ) { n ? ( St . Buf8 = Uint8Array , St . Buf16 = Uint16Array , St . Buf32 = Int32Array , St . assign ( St , j1 ) ) : ( St . Buf8 = Array , St . Buf16 = Array , St . Buf32 = Array , St . assign ( St , K1 ) ) } ; St . setTyped ( q1 ) } ) ; var Jm = J ( fs => { "use strict" ; var G1 = bn ( ) , X1 = 4 , Em = 0 , Tm = 1 , Z1 = 2 ; function us ( n ) { for ( var e = n . length ; -- e >= 0 ; ) n [ e ] = 0 } var Y1 = 0 , Mm = 1 , J1 = 2 , _1 = 3 , Q1 = 258 , X0 = 29 , Ga = 256 , qa = Ga + 1 + X0 , hs = 30 , Z0 = 19 , Nm = 2 * qa + 1 , Qr = 15 , U0 = 16 , $1 = 7 , Y0 = 256 , Rm = 16 , Vm = 17 , Hm = 18 , K0 = [ 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 ] , fd = [ 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 ] , eF = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 3 , 7 ] , zm = [ 16 , 17 , 18 , 0 , 8 , 7 , 9 , 6 , 10 , 5 , 11 , 4 , 12 , 3 , 13 , 2 , 14 , 1 , 15 ] , tF = 512 , yn = new Array ( ( qa + 2 ) * 2 ) ; us ( yn ) ; var Ua = new Array ( hs * 2 ) ; us ( Ua ) ; var Wa = new Array ( tF ) ; us ( Wa ) ; var ja = new Array ( Q1 - _1 + 1 ) ; us ( ja ) ; var J0 = new Array ( X0 ) ; us ( J0 ) ; var pd = new Array ( hs ) ; us ( pd ) ; function q0 ( n , e , t , i , r ) { this . static _tree = n , this . extra _bits = e , this . extra _base = t , this . elems = i , this . max _length = r , this . has _stree = n && n . length } var Um , qm , Wm ; function W0 ( n , e ) { this . dyn _tree = n , this . max _code = 0 , this . stat _desc = e } function jm ( n ) { return n < 256 ? Wa [ n ] : Wa [ 256 + ( n >>> 7 ) ] } function Ka ( n , e ) { n . pending _buf [ n . pending ++ ] = e & 255 , n . pending _buf [ n . pending ++ ] = e >>> 8 & 255 } function Rt ( n , e , t ) { n . bi _valid > U0 - t ? ( n . bi _buf |= e << n . bi _valid & 65535 , Ka ( n , n . bi _buf ) , n . bi _buf = e >> U0 - n . bi _valid , n . bi _valid += t - U0 ) : ( n . bi _buf |= e << n . bi _valid & 65535 , n . bi _valid += t ) } function Zi ( n , e , t ) { Rt ( n , t [ e * 2 ] , t [ e * 2 + 1 ] ) } function Km ( n , e ) { var t = 0 ; do t |= n & 1 , n >>>= 1 , t <<= 1 ; while ( -- e > 0 ) ; return t >>> 1 } function iF ( n ) { n . bi _valid === 16 ? ( Ka ( n , n . bi _buf ) , n . bi _buf = 0 , n . bi _valid = 0 ) : n . bi _valid >= 8 && ( n . pending _buf [ n . pending ++ ] = n . bi _buf & 255 , n . bi _buf >>= 8 , n . bi _valid -= 8 ) } function nF ( n , e ) { var t = e . dyn _tree , i = e . max _code , r = e . stat _desc . static _tree , o = e . stat _desc . has _stree , s = e . stat _desc . extra _bits , a = e . stat _desc . extra _base , c = e . stat _desc . max _length , l , d , h , u , p , f , m = 0 ; for ( u = 0 ; u <= Qr ; u ++ ) n . bl _count [ u ] = 0 ; for ( t [ n . heap [ n . heap _max ] * 2 + 1 ] = 0 , l = n . heap _max + 1 ; l < Nm ; l ++ ) d = n . heap [ l ] , u = t [ t [ d * 2 + 1 ] * 2 + 1 ] + 1 , u > c && ( u = c , m ++ ) , t [ d * 2 + 1 ] = u , ! ( d > i ) && ( n .
` ,"𝔑":" \u {1D511}","⁠":" \u 2060"," ":" \x A0","ℕ":" \u 2115","⫬":" \u 2AEC","≢":" \u 2262","≭":" \u 226D","∦":" \u 2226","∉":" \u 2209","≠":" \u 2260","≂̸":" \u 2242 \u 0338","∄":" \u 2204","≯":" \u 226F","≱":" \u 2271","≧̸":" \u 2267 \u 0338","≫̸":" \u 226B \u 0338","≹":" \u 2279","⩾̸":" \u 2A7E \u 0338","≵":" \u 2275","≎̸":" \u 224E \u 0338","≏̸":" \u 224F \u 0338","⋪":" \u 22EA","⧏̸":" \u 29CF \u 0338","⋬":" \u 22EC","≮":" \u 226E","≰":" \u 2270","≸":" \u 2278","≪̸":" \u 226A \u 0338","⩽̸":" \u 2A7D \u 0338","≴":" \u 2274","⪢̸":" \u 2AA2 \u 0338","⪡̸":" \u 2AA1 \u 0338","⊀":" \u 2280","⪯̸":" \u 2AAF \u 0338","⋠":" \u 22E0","∌":" \u 220C","⋫":" \u 22EB","⧐̸":" \u 29D0 \u 0338","⋭":" \u 22ED","⊏̸":" \u 228F \u 0338","⋢":" \u 22E2","⊐̸":" \u 2290 \u 0338","⋣":" \u 22E3","⊂⃒":" \u 2282 \u 20D2","⊈":" \u 2288","⊁":" \u 2281","⪰̸":" \u 2AB0 \u 0338","⋡":" \u 22E1","≿̸":" \u 227F \u 0338","⊃⃒":" \u 2283 \u 20D2","⊉":" \u 2289","≁":" \u 2241","≄":" \u 2244","≇":" \u 2247","≉":" \u 2249","∤":" \u 2224","𝒩":" \u {1D4A9}","Ñ":" \x D1","Ñ":" \x D1","Ν":" \u 039D","Œ":" \u 0152","Ó":" \x D3","Ó":" \x D3","Ô":" \x D4","Ô":" \x D4","О":" \u 041E","Ő":" \u 0150","𝔒":" \u {1D512}","Ò":" \x D2","Ò":" \x D2","Ō":" \u 014C","Ω":" \u 03A9","Ο":" \u 039F","𝕆":" \u {1D546}","“":" \u 201C","‘":" \u 2018","⩔":" \u 2A54","𝒪":" \u {1D4AA}","Ø":" \x D8","Ø":" \x D8","Õ":" \x D5","Õ":" \x D5","⨷":" \u 2A37","Ö":" \x D6","Ö":" \x D6","‾":" \u 203E","⏞":" \u 23DE","⎴":" \u 23B4","⏜":" \u 23DC","∂":" \u 2202","П":" \u 041F","𝔓":" \u {1D513}","Φ":" \u 03A6","Π":" \u 03A0","±":" \x B1","ℌ":" \u 210C","ℙ":" \u 2119","⪻":" \u 2ABB","≺":" \u 227A","⪯":" \u 2AAF","≼":" \u 227C","≾":" \u 227E","″":" \u 2033","∏":" \u 220F","∷":" \u 2237","∝":" \u 221D","𝒫":" \u {1D4AB}","Ψ":" \u 03A8",""":'"',""":'"',"𝔔":" \u {1D514}","ℚ":" \u 211A","𝒬":" \u {1D4AC}","⤐":" \u 2910","®":" \x AE","®":" \x AE","Ŕ":" \u 0154","⟫":" \u 27EB","↠":" \u 21A0","⤖":" \u 2916","Ř":" \u 0158","Ŗ":" \u 0156","Р":" \u 0420","ℜ":" \u 211C","∋":" \u 220B","⇋":" \u 21CB","⥯":" \u 296F","ℜ":" \u 211C","Ρ":" \u 03A1","⟩":" \u 27E9","→":" \u 2192","⇥":" \u 21E5","⇄":" \u 21C4","⌉":" \u 2309","⟧":" \u 27E7","⥝":" \u 295D","⇂":" \u 21C2","⥕":" \u 2955","⌋":" \u 230B","⊢":" \u 22A2","↦":" \u 21A6","⥛":" \u 295B","⊳":" \u 22B3","⧐":" \u 29D0","⊵":" \u 22B5","⥏":" \u 294F","⥜":" \u 295C","↾":" \u 21BE","⥔":" \u 2954","⇀":" \u 21C0","⥓":" \u 2953","⇒":" \u 21D2","ℝ":" \u 211D","⥰":" \u 2970","⇛":" \u 21DB","ℛ":" \u 211B","↱":" \u 21B1","⧴":" \u 29F4","Щ":" \u 0429","Ш":" \u 0428","Ь":" \u 042C","Ś":" \u 015A","⪼":" \u 2ABC","Š":" \u 0160","Ş":" \u 015E","Ŝ":" \u 015C","&
` ).replace(/ \s + $ /,"")}get children(){return this.childNodes.filter(e=>e instanceof n)}toString(){let e=this.tagName;if(e){let t=/^(img|br|hr|area|base|input|doctype|link|meta) $ /i.test(e),i=this.rawAttrs?" "+this.rawAttrs:"";return t? ` < $ { e } $ { i } / > ` : ` < $ { e } $ { i } > $ { this . innerHTML } < / $ { e } > ` } e l s e r e t u r n t h i s . i n n e r H T M L } g e t i n n e r H T M L ( ) { r e t u r n t h i s . c h i l d N o d e s . m a p ( e = > e . t o S t r i n g ( ) ) . j o i n ( " " ) } s e t i n n e r H T M L ( e ) { l e t t = T p ( e ) ; t h i s . c h i l d N o d e s . f o r E a c h ( i = > i . r e m o v e ( ) ) , t . c h i l d N o d e s . f o r E a c h ( i = > t h i s . a p p e n d C h i l d ( i ) ) } s e t _ c o n t e n t ( e ) { i f ( e i n s t a n c e o f W o ) e = [ e ] ; e l s e i f ( t y p e o f e = = " s t r i n g " ) { l e t t = T p ( e ) ; e = t . c h i l d N o d e s . l e n g t h ? t . c h i l d N o d e s : [ n e w q o ( e ) ] } t h i s . c h i l d N o d e s = e } g e t o u t e r H T M L ( ) { r e t u r n t h i s . t o S t r i n g ( ) } t r i m R i g h t ( e ) { f o r ( l e t t = 0 ; t < t h i s . c h i l d N o d e s . l e n g t h ; t + + ) { l e t i = t h i s . c h i l d N o d e s [ t ] ; i f ( i . n o d e T y p e = = = A t . E L E M E N T _ N O D E ) i . t r i m R i g h t ( e ) ; e l s e { l e t r = i . r a w T e x t . s e a r c h ( e ) ; r > - 1 & & ( i . v a l u e = i . r a w T e x t . s u b s t r ( 0 , r ) , t h i s . c h i l d N o d e s . l e n g t h = t + 1 ) } } r e t u r n t h i s } g e t s t r u c t u r e ( ) { l e t e = [ ] , t = 0 ; f u n c t i o n i ( o ) { e . p u s h ( " " . r e p e a t ( t ) + o ) } f u n c t i o n r ( o ) { l e t s = o . i d ? " # " + o . i d : " " , a = o . c l a s s N a m e s . l e n g t h ? " . " + o . c l a s s N a m e s . j o i n ( " . " ) : " " ; i ( o . t a g N a m e + s + a ) , t + + ; f o r ( l e t c = 0 ; c < o . c h i l d N o d e s . l e n g t h ; c + + ) { l e t l = o . c h i l d N o d e s [ c ] ; l . n o d e T y p e = = = A t . E L E M E N T _ N O D E ? r ( l ) : l . n o d e T y p e = = = A t . T E X T _ N O D E & & ( l . i s W h i t e s p a c e | | i ( " # t e x t " ) ) } t - - } r e t u r n r ( t h i s ) , e . j o i n ( `
` )}removeWhitespace(){let e=0;for(let t=0;t<this.childNodes.length;t++){let i=this.childNodes[t];if(i.nodeType===At.TEXT_NODE){if(i.isWhitespace)continue;i.value=i.rawText.trim()}else i.nodeType===At.ELEMENT_NODE&&i.removeWhitespace();this.childNodes[e++]=i}return this.childNodes.length=e,this}querySelectorAll(e){if(!(e instanceof Uo))if(e.includes(",")){let o=e.split(","),s=new Set(o.map(a=>this.querySelectorAll(a.trim())).flat());return Array.from(s)}else return this.querySelectorAll(new Uo(e));let t=e,i=new Set,r=[];for(this.childNodes.forEach(o=>r.push(o));r.length>0;){let o=r.shift();o.nodeType===At.ELEMENT_NODE&&(t.advance(o)&&t.matched&&(i.add(o),t.rewind()),o.childNodes.forEach(s=>{r.push(s)}))}return Array.from(i)}querySelector(e){let t;e instanceof Uo?(t=e,t.reset()):t=new Uo(e);let i=[];for(let r=0;r<this.childNodes.length;r++)for(i.push([this.childNodes[r],0,!1]);i.length;){let o=ia(i),s=o[0];if(o[1]===0){if(s.nodeType!==At.ELEMENT_NODE){i.pop();continue}if((o[2]=t.advance(s))&&t.matched)return s}o[1]<s.childNodes.length?i.push([s.childNodes[o[1]++],0,!1]):(o[2]&&t.rewind(),i.pop())}return null}appendChild(e){return this.childNodes.push(e),e instanceof n&&(e.parentNode=this),e}prependChild(e){return this.childNodes.unshift(e),e instanceof n&&(e.parentNode=this),e}get firstChild(){return this.childNodes[0]}get lastChild(){return ia(this.childNodes)}get attributes(){if(this._attrs)return this._attrs;this._attrs={};let e=this.rawAttributes;for(let t in e)this._attrs[t]=(0,ta.decode)(e[t]);return this._attrs}get rawAttributes(){if(this._rawAttrs)return this._rawAttrs;let e={};if(this.rawAttrs){let t;for(;t=Dk.exec(this.rawAttrs);)e[t[1]]=t[4]||t[5]||t[6]||""}return this._rawAttrs=e,e}setAttribute(e,t){e==="id"?this.id=t:e==="class"&&(this.classNames=t.split(/ \s +/));let i=this.attributes;t===void 0?delete i[e]:i[e]=t+"",this._rawAttrs&&(t===void 0?delete this._rawAttrs[e]:this._rawAttrs[e]=(0,ta.encode)(t+"")),this.rawAttrs=Object.keys(i).map(r=>r+(i[r]===""?"":'="'+(0,ta.encode)(i[r])+'"')).join(" ")}removeAttribute(e){this.setAttribute(e,void 0)}setAttributes(e){e.id?this.id=e.id:e.class&&(this.classNames=e.class.split(/ \s +/)),this.attributes&&(Object.keys(this.attributes).forEach(t=>delete this.attributes[t]),Object.keys(e).forEach(t=>this.attributes[t]=e[t]+"")),this.rawAttributes&&(Object.keys(this.rawAttributes).forEach(t=>delete this.rawAttributes[t]),Object.keys(e).forEach(t=>this.rawAttributes[t]=(0,ta.encode)(e[t]+""))),this.rawAttrs=Object.keys(e).map(t=>t+(e[t]===""?"":'="'+(0,ta.encode)(e[t]+"")+'"')).join(" ")}};ft.HTMLElement=na;var Yh={},Ep={f145:function(n,e,t,i,r){"use strict";if(e=e||"",t=t||[],i=i||"",r=r||"",n.id!=e.substr(1))return!1;for(let o=t,s=0;s<o.length;s++)if(n.classNames.indexOf(o[s])===-1)return!1;return!0},f45:function(n,e,t,i,r){"use strict";e=e||"",t=t||[],i=i||"",r=r||"";for(let o=t,s=0;s<o.length;s++)if(n.classNames.indexOf(o[s])===-1)return!1;return!0},f15:function(n,e,t,i,r){"use strict";return e=e||"",t=t||[],i=i||"",r=r||"",n.id==e.substr(1)},f1:function(n,e,t,i,r){"use strict";if(e=e||"",t=t||[],i=i||"",r=r||"",n.id!=e.substr(1))return!1},f5:function(n,e,t,i,r){"use strict";return n=n||{},e=e||"",t=t||[],i=i||"",r=r||"",!0},f245:function(n,e,t,i,r){"use strict";e=e||"",t=t||[],i=i||"",r=r||"";let o=n.attributes;for(let s in o){let a=o[s];if(s==i&&a==r)return!0}return!1},f25:function(n,e,t,i,r){"use strict";e=e||"",t=t||[],i=i||"",r=r||"";let o=n.attributes;for(let s in o){let a=o[s];if(s==i&&a==r)return!0}return!1},f2:function(n,e,t,i,r){"use strict";e=e||"",t=t||[],i=i||"",r=r||"";let o=n.attributes;for(let s in o){let a=o[s];if(s==i&&a==r)return!0}return!1},f345:function(n,e,t,i,r){"use strict";if(e=e||"",t=t||[],i=i||"",r=r||"",n.tagName!=e)return!1;for(let o=t,s=0;s<o.length;s++)if(n.classNames.indexOf(o[s])===-1)return!1;return!0},f35:function(n,e,t,i,r){"use strict";return e=e||"",t=t||[],i=i||"",r=r||"",n.tagName==e},f3:function(n,e,t,i,r){"use strict";if(e=e||"",t=t||[],i=i||"",r=r||"",n.tagName!=e)return!1}},Uo=class{constructor(e){this.nextMatch=0,Ep.f5=Ep.f5,th
` ," \f "," \r "," \v "],k0=n=>/^[ \n \f \r \u 000B] $ /.test(n),Ma=n=>n.split(/[ \n \f \r \u 000B]/),cd=n=>n.replace(/[ \n \f \r \u 000B]/g," "),dd=(n,e)=>{let t=n.charCodeAt(e),i,r=e+1,o=1;return t>=55296&&t<=56319&&n.length>r&&(i=n.charCodeAt(r),i>=56320&&i<=57343&&(o=2)),[n.slice(e,e+o),o]},C0=n=>{let e=[];for(let t=0,i=n.length;t<i;){let[r,o]=dd(n,t);e.push(r),t+=o}return e},R1=n=>{let e=Fm.join("|"),t=[" $ "];for(let r=0,o=n.length;r<o;r++){let s=n[r];if(k0(s))throw new TypeError( ` \ ` wordBreak \` must not include ${ e } ` ) ; t . push ( s === "" ? "." : wm ( s ) ) } let i = t . join ( "|" ) ; return new RegExp ( ` ( ${ e } )|((.*?)( ${ i } )) ` , "gm" ) } , S0 = ( n , e , t , i ) => { let r = R1 ( e ) , o = nr ( n ) . match ( r ) , s = "" , a = 0 , c = [ ] , l = ( ) => { s !== "" && c . push ( s ) , s = "" , a = 0 } ; for ( let d = 0 , h = o . length ; d < h ; d ++ ) { let u = o [ d ] ; if ( k0 ( u ) ) l ( ) ; else { let p = i ( u ) ; a + p > t && l ( ) , s += u , a += p } } return l ( ) , c } , V1 = /^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/ , Na = n => { let e = n . match ( V1 ) ; if ( ! e ) return ; let [ , t , i = "01" , r = "01" , o = "00" , s = "00" , a = "00" , c = "Z" , l = "00" , d = "00" ] = e , h = c === "Z" ? "Z" : ` ${ c } ${ l } : ${ d } ` ; return new Date ( ` ${ t } - ${ i } - ${ r } T ${ o } : ${ s } : ${ a } ${ h } ` ) } , ls = ( n , e ) => { var t ; let i = 0 , r ; for ( ; i < n . length ; ) { let o = n . substring ( i ) . match ( e ) ; if ( ! o ) return { match : r , pos : i } ; r = o , i += ( ( t = o . index ) !== null && t !== void 0 ? t : 0 ) + o [ 0 ] . length } return { match : r , pos : i } } ; var Jr = n => n [ n . length - 1 ] , Ra = n => { if ( n instanceof Uint8Array ) return n ; let e = n . length , t = new Uint8Array ( e ) ; for ( let i = 0 ; i < e ; i ++ ) t [ i ] = n . charCodeAt ( i ) ; return t } , E0 = ( ... n ) => { let e = n . length , t = [ ] ; for ( let s = 0 ; s < e ; s ++ ) { let a = n [ s ] ; t [ s ] = a instanceof Uint8Array ? a : Ra ( a ) } let i = 0 ; for ( let s = 0 ; s < e ; s ++ ) i += n [ s ] . length ; let r = new Uint8Array ( i ) , o = 0 ; for ( let s = 0 ; s < e ; s ++ ) { let a = t [ s ] ; for ( let c = 0 , l = a . length ; c < l ; c ++ ) r [ o ++ ] = a [ c ] } return r } , T0 = n => { let e = 0 ; for ( let r = 0 , o = n . length ; r < o ; r ++ ) e += n [ r ] . length ; let t = new Uint8Array ( e ) , i = 0 ; for ( let r = 0 , o = n . length ; r < o ; r ++ ) { let s = n [ r ] ; t . set ( s , i ) , i += s . length } return t } , xn = n => { let e = "" ; for ( let t = 0 , i = n . length ; t < i ; t ++ ) e += Mt ( n [ t ] ) ; return e } , A0 = ( n , e ) => n . id - e . id , I0 = ( n , e ) => { let t = [ ] ; for ( let i = 0 , r = n . length ; i < r ; i ++ ) { let o = n [ i ] , s = n [ i - 1 ] ; ( i === 0 || e ( o ) !== e ( s ) ) && t . push ( o ) } return t } , cs = ( n , e ) => { if ( n . length !== e . length ) return ! 1 ; for ( let t = 0 , i = n . length ; t < i ; t ++ ) if ( n [ t ] !== e [ t ] ) return ! 1 ; return ! 0 } , rr = n => { let e = n . length ; for ( let t = 0 , i = Math . floor ( e / 2 ) ; t < i ; t ++ ) { let r = t , o = e - t - 1 , s = n [ t ] ; n [ r ] = n [ o ] , n [ o ] = s } return n } , B0 = n => { let e = 0 ; for ( let t = 0 , i = n . length ; t < i ; t ++ ) e += n [ t ] ; return e } , L0 = ( n , e ) => { let t = new Array ( e - n ) ; for ( let i = 0 , r = t . length ; i < r ; i ++ ) t [ i ] = n + i ; return t } , O0 = ( n , e ) => { let t = new Array ( e . length ) ; for ( let i = 0 , r = e . length ; i < r ; i ++ ) t [ i ] = n [ e [ i ] ] ; return t } , M0 = n => n instanceof Uint8Array || n instanceof ArrayBuffer || typeof n == "string" , _r = n => { if ( typeof n == "string" ) return D0 ( n ) ; if ( n instanceof ArrayBuffer ) return new Uint8Array ( n ) ; if ( n instanceof Uint8Array ) return n ; throw new TypeError ( "`input` must be one of `string | ArrayBuffer | Uint8Array`" ) } , Dm = [ ] ; for ( let n = 0 ; n <= 255 ; ++ n ) Dm [ n ] = n . toString ( 16 ) . padStart ( 2 , "0" ) ; var N0 = n => { let e = new Array ( n . length ) ; for ( let t = 0 ; t < n . length ; ++ t ) e [ t ] = Dm [ n [ t ] ] ; return e . join ( "" ) } ; var Ti = ( ) => new Promise ( n => { setTimeout ( ( ) => n ( ) , 0 ) } ) ; var H1 = ( n , e = ! 0 ) => { let t = [ ] ; e && t . push ( 239 , 187 , 191 ) ; for ( let i = 0 , r = n . length ; i < r ; ) { let o = n . codePointAt ( i ) ; if ( o < 128 ) { let s = o & 127 ; t . push ( s ) , i += 1 } else if ( o < 2048 ) { let s = o >> 6 & 31 | 192 , a = o & 63 | 128 ; t . push ( s , a ) , i += 1 } else if ( o < 65536 ) { let s = o >> 12 & 15 | 224 , a = o >> 6 & 63 | 128 , c = o & 63 | 128 ; t . push ( s , a , c ) , i += 1 } else if ( o < 1114112 ) { let s = o >> 18 & 7 | 240 , a = o >> 12 & 63 | 128 , c = o >> 6 & 63 | 128 , l = o >> 0 & 63 | 128 ; t . push ( s , a , c , l ) , i += 2 } else throw new Error ( ` Invalid code point: 0x ${ Xi ( o ) } ` ) } return new Uint8Array ( t ) } , R0 = ( n , e = ! 0 ) => { let t = [ ] ; e && t . push ( 65279 ) ; for ( let i = 0 , r = n . length ; i < r ; ) { let o = n . codePointAt ( i ) ; if ( o < 65536 ) t . push ( o ) , i += 1 ; else if ( o < 1114112 ) t . push ( hd ( o ) , ud ( o ) ) , i += 2 ; else throw new Error ( ` Invalid code point: 0x ${ Xi ( o ) } ` ) } return new Uint16Array ( t ) } , V0 = n => n >= 0 && n <= 65535 , H0 = n => n >= 65536 && n <= 1114111 , hd = n => Math . floor ( ( n - 65536 ) / 1024 ) + 55296 , ud = n => ( n - 65536 ) % 1024 + 56320 , or ; ( function ( n ) { n . BigEndian = "BigEndian" , n . LittleEndian = "LittleEndian" } ) ( or || ( or = { } ) ) ; var Va = "\uFFFD" . codePointAt ( 0 ) , Ha = ( n , e = ! 0 ) => { if ( n . length <= 1 ) return String . fromCodePoint ( Va ) ; let t = e ? U1 ( n ) : or . BigEndian , i = e ? 2 : 0 , r = [ ] ; for ( ; n . length - i >= 2 ; ) { let o = km ( n [ i ++ ] , n [ i ++ ] , t ) ; if ( z1 ( o ) ) if ( n . length - i < 2 ) r
% $ { e } $ { e } $ { e } $ { e } ` }sizeInBytes(){return 12+this.major.length+this.minor.length}copyBytesInto(e,t){let i=t;return e[t++]=P.Percent,e[t++]=P.P,e[t++]=P.D,e[t++]=P.F,e[t++]=P.Dash,t+=Se(this.major,e,t),e[t++]=P.Period,t+=Se(this.minor,e,t),e[t++]=P.Newline,e[t++]=P.Percent,e[t++]=129,e[t++]=129,e[t++]=129,e[t++]=129,t-i}};Sl.forVersion=(n,e)=>new Sl(n,e);var en=Sl;var Ef=class{clone(e){throw new Ze(this.constructor.name,"clone")}toString(){throw new Ze(this.constructor.name,"toString")}sizeInBytes(){throw new Ze(this.constructor.name,"sizeInBytes")}copyBytesInto(e,t){throw new Ze(this.constructor.name,"copyBytesInto")}},Pe=Ef;var El=class n extends Pe{constructor(e){super(),this.numberValue=e,this.stringValue=z0(e)}asNumber(){return this.numberValue}value(){return this.numberValue}clone(){return n.of(this.numberValue)}toString(){return this.stringValue}sizeInBytes(){return this.stringValue.length}copyBytesInto(e,t){return t+=Se(this.stringValue,e,t),this.stringValue.length}};El.of=n=>new El(n);var K=El;var Tl=class n extends Pe{constructor(e){super(),this.array=[],this.context=e}size(){return this.array.length}push(e){this.array.push(e)}insert(e,t){this.array.splice(e,0,t)}indexOf(e){let t=this.array.indexOf(e);return t===-1?void 0:t}remove(e){this.array.splice(e,1)}set(e,t){this.array[e]=t}get(e){return this.array[e]}lookupMaybe(e,...t){return this.context.lookupMaybe(this.get(e),...t)}lookup(e,...t){return this.context.lookup(this.get(e),...t)}asRectangle(){if(this.size()!==4)throw new gl(this.size());let e=this.lookup(0,K).asNumber(),t=this.lookup(1,K).asNumber(),i=this.lookup(2,K).asNumber(),r=this.lookup(3,K).asNumber(),o=Math.min(e,i),s=Math.min(t,r),a=Math.abs(e-i),c=Math.abs(t-r);return{x:o,y:s,width:a,height:c}}asArray(){return this.array.slice()}clone(e){let t=n.withContext(e||this.context);for(let i=0,r=this.size();i<r;i++)t.push(this.array[i]);return t}toString(){let e="[ ";for(let t=0,i=this.size();t<i;t++)e+=this.get(t).toString(),e+=" ";return e+="]",e}sizeInBytes(){let e=3;for(let t=0,i=this.size();t<i;t++)e+=this.get(t).sizeInBytes()+1;return e}copyBytesInto(e,t){let i=t;e[t++]=P.LeftSquareBracket,e[t++]=P.Space;for(let r=0,o=this.size();r<o;r++)t+=this.get(r).copyBytesInto(e,t),e[t++]=P.Space;return e[t++]=P.RightSquareBracket,t-i}scalePDFNumbers(e,t){for(let i=0,r=this.size();i<r;i++){let o=this.lookup(i);if(o instanceof K){let s=i%2===0?e:t;this.set(i,K.of(o.asNumber()*s))}}}};Tl.withContext=n=>new Tl(n);var X=Tl;var Tf={},lo=class extends Pe{constructor(e,t){if(e!==Tf)throw new Dn("PDFBool");super(),this.value=t}asBoolean(){return this.value}clone(){return this}toString(){return String(this.value)}sizeInBytes(){return this.value?4:5}copyBytesInto(e,t){return this.value?(e[t++]=P.t,e[t++]=P.r,e[t++]=P.u,e[t++]=P.e,4):(e[t++]=P.f,e[t++]=P.a,e[t++]=P.l,e[t++]=P.s,e[t++]=P.e,5)}};lo.True=new lo(Tf,!0);lo.False=new lo(Tf,!1);var Li=lo;var Ht=new Uint8Array(256);Ht[P.LeftParen]=1;Ht[P.RightParen]=1;Ht[P.LessThan]=1;Ht[P.GreaterThan]=1;Ht[P.LeftSquareBracket]=1;Ht[P.RightSquareBracket]=1;Ht[P.LeftCurly]=1;Ht[P.RightCurly]=1;Ht[P.ForwardSlash]=1;Ht[P.Percent]=1;var ai=new Uint8Array(256);ai[P.Null]=1;ai[P.Tab]=1;ai[P.Newline]=1;ai[P.FormFeed]=1;ai[P.CarriageReturn]=1;ai[P.Space]=1;var Id=new Uint8Array(256);for(let n=0,e=256;n<e;n++)Id[n]=ai[n]||Ht[n]?1:0;Id[P.Hash]=1;var $ D=n=>n.replace(/#([ \d ABCDEF]{2})/g,(e,t)=>P0(t)),eP=n=>n>=P.ExclamationPoint&&n<=P.Tilde&&!Id[n],qb={},Ub=new Map,re=class extends Pe{constructor(e,t){if(e!==qb)throw new Dn("PDFName");super();let i="/";for(let r=0,o=t.length;r<o;r++){let s=t[r],a=se(s);i+=eP(a)?s: ` # $ { Xi ( a ) } ` }this.encodedName=i}asBytes(){let e=[],t="",i=!1,r=o=>{o!==void 0&&e.push(o),i=!1};for(let o=1,s=this.encodedName.length;o<s;o++){let a=this.encodedName[o],c=se(a),l=this.encodedName[o+1];i?c>=P.Zero&&c<=P.Nine||c>=P.a&&c<=P.f||c>=P.A&&c<=P.F?(t+=a,(t.length===2||!(l>="0"&&l<="9"||l>="a"&&l<="f"||l>="A"&&l<="F"))&&(r(parseInt(t,16)),t="")):r(c):c===P.Hash?i=!0:r(c)}return new Uint8Array(e)}decodeText(){let e=this.asBytes();return String.fromCharCode(...Array.from(e))}asS
2025-02-18 05:37:27 -03:00
` ,t=this.entries();for(let i=0,r=t.length;i<r;i++){let[o,s]=t[i];e+=o.toString()+" "+s.toString()+ `
2025-03-07 06:22:58 -03:00
` }return e+=">>",e}sizeInBytes(){let e=5,t=this.entries();for(let i=0,r=t.length;i<r;i++){let[o,s]=t[i];e+=o.sizeInBytes()+s.sizeInBytes()+2}return e}copyBytesInto(e,t){let i=t;e[t++]=P.LessThan,e[t++]=P.LessThan,e[t++]=P.Newline;let r=this.entries();for(let o=0,s=r.length;o<s;o++){let[a,c]=r[o];t+=a.copyBytesInto(e,t),e[t++]=P.Space,t+=c.copyBytesInto(e,t),e[t++]=P.Newline}return e[t++]=P.GreaterThan,e[t++]=P.GreaterThan,t-i}};co.withContext=n=>new co(new Map,n);co.fromMapWithContext=(n,e)=>new co(n,e);var G=co;var Sn=class n extends Pe{constructor(e){super(),this.value=e}asBytes(){let e=this.value+(this.value.length%2===1?"0":""),t=e.length,i=new Uint8Array(e.length/2),r=0,o=0;for(;r<t;){let s=parseInt(e.substring(r,r+2),16);i[o]=s,r+=2,o+=1}return i}decodeText(){let e=this.asBytes();return za(e)?Ha(e):cl(e)}decodeDate(){let e=this.decodeText(),t=Na(e);if(!t)throw new ao(e);return t}asString(){return this.value}clone(){return n.of(this.value)}toString(){return ` < $ { this . value } > ` }sizeInBytes(){return this.value.length+2}copyBytesInto(e,t){return e[t++]=P.LessThan,t+=Se(this.value,e,t),e[t++]=P.GreaterThan,this.value.length+2}};Sn.of=n=>new Sn(n);Sn.fromText=n=>{let e=R0(n),t="";for(let i=0,r=e.length;i<r;i++)t+=Gi(e[i],4);return new Sn(t)};Sn.fromBytes=n=>Sn.of(N0(n));var j=Sn;var If=class extends Pe{constructor(e){super(),this.dict=e}clone(e){throw new Ze(this.constructor.name,"clone")}getContentsString(){throw new Ze(this.constructor.name,"getContentsString")}getContents(){throw new Ze(this.constructor.name,"getContents")}getContentsSize(){throw new Ze(this.constructor.name,"getContentsSize")}updateContents(e){throw new Ze(this.constructor.name,"updateContents")}updateDict(){let e=this.getContentsSize();this.dict.set(w.Length,K.of(e))}sizeInBytes(){return this.updateDict(),this.dict.sizeInBytes()+this.getContentsSize()+18}toString(){this.updateDict();let e=this.dict.toString();return e+= `
2025-02-18 05:37:27 -03:00
stream
` ,e+=this.getContentsString(),e+= `
2025-03-07 06:22:58 -03:00
endstream ` ,e}copyBytesInto(e,t){this.updateDict();let i=t;t+=this.dict.copyBytesInto(e,t),e[t++]=P.Newline,e[t++]=P.s,e[t++]=P.t,e[t++]=P.r,e[t++]=P.e,e[t++]=P.a,e[t++]=P.m,e[t++]=P.Newline;let r=this.getContents();for(let o=0,s=r.length;o<s;o++)e[t++]=r[o];return e[t++]=P.Newline,e[t++]=P.e,e[t++]=P.n,e[t++]=P.d,e[t++]=P.s,e[t++]=P.t,e[t++]=P.r,e[t++]=P.e,e[t++]=P.a,e[t++]=P.m,t-i}},Ee=If;var Al=class n extends Ee{constructor(e,t,i){super(e),this.contents=t,this.transform=i}asUint8Array(){return this.contents.slice()}clone(e){return n.of(this.dict.clone(e),this.contents.slice())}getContentsString(){return xn(this.contents)}getContents(){return this.contents}getContentsSize(){return this.contents.length}updateContents(e){this.contents=e}};Al.of=(n,e,t)=>new Al(n,e,t);var Oi=Al;var jb={},Wb=new Map,Il=class extends Pe{constructor(e,t,i){if(e!==jb)throw new Dn("PDFRef");super(),this.objectNumber=t,this.generationNumber=i,this.tag= ` $ { t } $ { i } R ` }clone(){return this}toString(){return this.tag}sizeInBytes(){return this.tag.length}copyBytesInto(e,t){return t+=Se(this.tag,e,t),this.tag.length}};Il.of=(n,e=0)=>{let t= ` $ { n } $ { e } R ` ,i=Wb.get(t);return i||(i=new Il(jb,n,e),Wb.set(t,i)),i};var Y=Il;var ho=class n extends Pe{constructor(e){super(),this.value=e}asBytes(){let e=[],t="",i=!1,r=o=>{o!==void 0&&e.push(o),i=!1};for(let o=0,s=this.value.length;o<s;o++){let a=this.value[o],c=se(a),l=this.value[o+1];i?c===P.Newline||c===P.CarriageReturn?r():c===P.n?r(P.Newline):c===P.r?r(P.CarriageReturn):c===P.t?r(P.Tab):c===P.b?r(P.Backspace):c===P.f?r(P.FormFeed):c===P.LeftParen?r(P.LeftParen):c===P.RightParen?r(P.RightParen):c===P.Backspace?r(P.BackSlash):c>=P.Zero&&c<=P.Seven?(t+=a,(t.length===3||!(l>="0"&&l<="7"))&&(r(parseInt(t,8)),t="")):r(c):c===P.BackSlash?i=!0:r(c)}return new Uint8Array(e)}decodeText(){let e=this.asBytes();return za(e)?Ha(e):cl(e)}decodeDate(){let e=this.decodeText(),t=Na(e);if(!t)throw new ao(e);return t}asString(){return this.value}clone(){return n.of(this.value)}toString(){return ` ( $ { this . value } ) ` }sizeInBytes(){return this.value.length+2}copyBytesInto(e,t){return e[t++]=P.LeftParen,t+=Se(this.value,e,t),e[t++]=P.RightParen,this.value.length+2}};ho.of=n=>new ho(n);ho.fromDate=n=>{let e=Nt(String(n.getUTCFullYear()),4,"0"),t=Nt(String(n.getUTCMonth()+1),2,"0"),i=Nt(String(n.getUTCDate()),2,"0"),r=Nt(String(n.getUTCHours()),2,"0"),o=Nt(String(n.getUTCMinutes()),2,"0"),s=Nt(String(n.getUTCSeconds()),2,"0");return new ho( ` D : $ { e } $ { t } $ { i } $ { r } $ { o } $ { s } Z ` )};var ee=ho;var Bl=class n{constructor(e,t){this.name=e,this.args=t||[]}clone(e){let t=new Array(this.args.length);for(let i=0,r=t.length;i<r;i++){let o=this.args[i];t[i]=o instanceof Pe?o.clone(e):o}return n.of(this.name,t)}toString(){let e="";for(let t=0,i=this.args.length;t<i;t++)e+=String(this.args[t])+" ";return e+=this.name,e}sizeInBytes(){let e=0;for(let t=0,i=this.args.length;t<i;t++){let r=this.args[t];e+=(r instanceof Pe?r.sizeInBytes():r.length)+1}return e+=this.name.length,e}copyBytesInto(e,t){let i=t;for(let r=0,o=this.args.length;r<o;r++){let s=this.args[r];s instanceof Pe?t+=s.copyBytesInto(e,t):t+=Se(s,e,t),e[t++]=P.Space}return t+=Se(this.name,e,t),t-i}};Bl.of=(n,e)=>new Bl(n,e);var ae=Bl;var Bf;(function(n){n.NonStrokingColor="sc",n.NonStrokingColorN="scn",n.NonStrokingColorRgb="rg",n.NonStrokingColorGray="g",n.NonStrokingColorCmyk="k",n.NonStrokingColorspace="cs",n.StrokingColor="SC",n.StrokingColorN="SCN",n.StrokingColorRgb="RG",n.StrokingColorGray="G",n.StrokingColorCmyk="K",n.StrokingColorspace="CS",n.BeginMarkedContentSequence="BDC",n.BeginMarkedContent="BMC",n.EndMarkedContent="EMC",n.MarkedContentPointWithProps="DP",n.MarkedContentPoint="MP",n.DrawObject="Do",n.ConcatTransformationMatrix="cm",n.PopGraphicsState="Q",n.PushGraphicsState="q",n.SetFlatness="i",n.SetGraphicsStateParams="gs",n.SetLineCapStyle="J",n.SetLineDashPattern="d",n.SetLineJoinStyle="j",n.SetLineMiterLimit="M",n.SetLineWidth="w",n.SetTextMatrix="Tm",n.SetRenderingIntent="ri",n.AppendRectangle="re",n.BeginInlineImage="BI",n.BeginInlineImageData="ID",n.EndInlineImage="EI",n.ClipEve
` ;return e}getUnencodedContents(){let e=new Uint8Array(this.getUnencodedContentsSize()),t=0;for(let i=0,r=this.operators.length;i<r;i++)t+=this.operators[i].copyBytesInto(e,t),e[t++]=P.Newline;return e}getUnencodedContentsSize(){let e=0;for(let t=0,i=this.operators.length;t<i;t++)e+=this.operators[t].sizeInBytes()+1;return e}};Ll.of=(n,e,t=!0)=>new Ll(n,e,t);var tn=Ll;var Cs=class{constructor(e){this.seed=e}nextInt(){let e=Math.sin(this.seed++)*1e4;return e-Math.floor(e)}};Cs.withSeed=n=>new Cs(n);var tP=([n],[e])=>n.objectNumber-e.objectNumber,Ol=class{constructor(){this.isDecrypted=!0,this.largestObjectNumber=0,this.header=en.forVersion(1,7),this.trailerInfo={},this.indirectObjects=new Map,this.rng=Cs.withSeed(1)}assign(e,t){this.indirectObjects.set(e,t),e.objectNumber>this.largestObjectNumber&&(this.largestObjectNumber=e.objectNumber)}nextRef(){return this.largestObjectNumber+=1,Y.of(this.largestObjectNumber)}register(e){let t=this.nextRef();return this.assign(t,e),t}delete(e){return this.indirectObjects.delete(e)}lookupMaybe(e,...t){let i=t.includes(Ve),r=e instanceof Y?this.indirectObjects.get(e):e;if(!(!r||r===Ve&&!i)){for(let o=0,s=t.length;o<s;o++){let a=t[o];if(a===Ve){if(r===Ve)return r}else if(r instanceof a)return r}throw new $ i(t,r)}}lookup(e,...t){let i=e instanceof Y?this.indirectObjects.get(e):e;if(t.length===0)return i;for(let r=0,o=t.length;r<o;r++){let s=t[r];if(s===Ve){if(i===Ve)return i}else if(i instanceof s)return i}throw new $ i(t,i)}getObjectRef(e){let t=Array.from(this.indirectObjects.entries());for(let i=0,r=t.length;i<r;i++){let[o,s]=t[i];if(s===e)return o}}enumerateIndirectObjects(){return Array.from(this.indirectObjects.entries()).sort(tP)}obj(e){if(e instanceof Pe)return e;if(e==null)return Ve;if(typeof e=="string")return w.of(e);if(typeof e=="number")return K.of(e);if(typeof e=="boolean")return e?Li.True:Li.False;if(e instanceof Uint8Array)return j.fromBytes(e);if(Array.isArray(e)){let t=X.withContext(this);for(let i=0,r=e.length;i<r;i++)t.push(this.obj(e[i]));return t}else{let t=G.withContext(this),i=Object.keys(e);for(let r=0,o=i.length;r<o;r++){let s=i[r],a=e[s];a!==void 0&&t.set(w.of(s),this.obj(a))}return t}}getLiteral(e,{deep:t=!0,literalRef:i=!1,literalStreamDict:r=!1,literalString:o=!1}={}){let s={deep:t,literalRef:i,literalStreamDict:r,literalString:o};if(e instanceof X){let a=e.asArray();return t?a.map(c=>this.getLiteral(c,s)):a}else{if(e instanceof Li)return e.asBoolean();if(e instanceof G){let a={},c=e.entries();for(let l=0,d=c.length;l<d;l++){let[h,u]=c[l];a[this.getLiteral(h)]=t?this.getLiteral(u,s):u}return a}else{if(e instanceof w)return e.decodeText();if(e===Ve)return null;if(e instanceof K)return e.asNumber();if(e instanceof Y&&i)return e.objectNumber;if(e instanceof Ee&&r)return this.getLiteral(e.dict,s);if((e instanceof ee||e instanceof j)&&o)return e.asString()}}return e}stream(e,t={}){return Oi.of(this.obj(t),Ra(e))}flateStream(e,t={}){return this.stream(Gb.default.deflate(Ra(e)),{...t,Filter:"FlateDecode"})}contentStream(e,t={}){return tn.of(this.obj(t),e)}formXObject(e,t={}){return this.contentStream(e,{BBox:this.obj([0,0,0,0]),Matrix:this.obj([1,0,0,1,0,0]),...t,Type:"XObject",Subtype:"Form"})}getPushGraphicsStateContentStream(){if(this.pushGraphicsStateContentStreamRef)return this.pushGraphicsStateContentStreamRef;let e=this.obj({}),t=ae.of(ce.PushGraphicsState),i=tn.of(e,[t]);return this.pushGraphicsStateContentStreamRef=this.register(i),this.pushGraphicsStateContentStreamRef}getPopGraphicsStateContentStream(){if(this.popGraphicsStateContentStreamRef)return this.popGraphicsStateContentStreamRef;let e=this.obj({}),t=ae.of(ce.PopGraphicsState),i=tn.of(e,[t]);return this.popGraphicsStateContentStreamRef=this.register(i),this.popGraphicsStateContentStreamRef}addRandomSuffix(e,t=4){return ` $ { e } - $ { Math . floor ( this . rng . nextInt ( ) * 10 * * t ) } ` }};Ol.create=()=>new Ol;var uo=Ol;var gr=class n extends G{constructor(e,t,i=!0){super(e,t),this.normalized=!1,this.autoNormalizeCTM=i}clone(e){let t=n.fromMapWithContext(new Map,e||this.context,this.autoNormalizeCTM),i=this.entries();for(
2025-02-18 05:37:27 -03:00
` ;for(let t=0,i=this.subsections.length;t<i;t++){let r=this.subsections[t];e+= ` $ { r [ 0 ] . ref . objectNumber } $ { r . length }
2025-03-07 06:22:58 -03:00
` ;for(let o=0,s=r.length;o<s;o++){let a=r[o];e+=Nt(String(a.offset),10,"0"),e+=" ",e+=Nt(String(a.ref.generationNumber),5,"0"),e+=" ",e+=a.deleted?"f":"n",e+= `
` }}return e}sizeInBytes(){let e=5;for(let t=0,i=this.subsections.length;t<i;t++){let r=this.subsections[t],o=r.length,[s]=r;e+=2,e+=String(s.ref.objectNumber).length,e+=String(o).length,e+=20*o}return e}copyBytesInto(e,t){let i=t;return e[t++]=P.x,e[t++]=P.r,e[t++]=P.e,e[t++]=P.f,e[t++]=P.Newline,t+=this.copySubsectionsIntoBuffer(this.subsections,e,t),t-i}copySubsectionsIntoBuffer(e,t,i){let r=i,o=e.length;for(let s=0;s<o;s++){let a=this.subsections[s],c=String(a[0].ref.objectNumber);i+=Se(c,t,i),t[i++]=P.Space;let l=String(a.length);i+=Se(l,t,i),t[i++]=P.Newline,i+=this.copyEntriesIntoBuffer(a,t,i)}return i-r}copyEntriesIntoBuffer(e,t,i){let r=e.length;for(let o=0;o<r;o++){let s=e[o],a=Nt(String(s.offset),10,"0");i+=Se(a,t,i),t[i++]=P.Space;let c=Nt(String(s.ref.generationNumber),5,"0");i+=Se(c,t,i),t[i++]=P.Space,t[i++]=s.deleted?P.f:P.n,t[i++]=P.Space,t[i++]=P.Newline}return 20*r}append(e){if(this.chunkLength===0){this.subsections.push([e]),this.chunkIdx=0,this.chunkLength=1;return}let t=this.subsections[this.chunkIdx],i=t[this.chunkLength-1];e.ref.objectNumber-i.ref.objectNumber>1?(this.subsections.push([e]),this.chunkIdx+=1,this.chunkLength=1):(t.push(e),this.chunkLength+=1)}};fo.create=()=>new fo({ref:Y.of(0,65535),offset:0,deleted:!0});fo.createEmpty=()=>new fo;var po=fo;var Rl=class{constructor(e){this.lastXRefOffset=String(e)}toString(){return ` startxref
2025-02-18 05:37:27 -03:00
$ { this . lastXRefOffset }
2025-03-07 06:22:58 -03:00
% % EOF ` }sizeInBytes(){return 16+this.lastXRefOffset.length}copyBytesInto(e,t){let i=t;return e[t++]=P.s,e[t++]=P.t,e[t++]=P.a,e[t++]=P.r,e[t++]=P.t,e[t++]=P.x,e[t++]=P.r,e[t++]=P.e,e[t++]=P.f,e[t++]=P.Newline,t+=Se(this.lastXRefOffset,e,t),e[t++]=P.Newline,e[t++]=P.Percent,e[t++]=P.Percent,e[t++]=P.E,e[t++]=P.O,e[t++]=P.F,t-i}};Rl.forLastCrossRefSectionOffset=n=>new Rl(n);var mr=Rl;var Vl=class{constructor(e){this.dict=e}toString(){return ` trailer
$ { this . dict . toString ( ) } ` }sizeInBytes(){return 8+this.dict.sizeInBytes()}copyBytesInto(e,t){let i=t;return e[t++]=P.t,e[t++]=P.r,e[t++]=P.a,e[t++]=P.i,e[t++]=P.l,e[t++]=P.e,e[t++]=P.r,e[t++]=P.Newline,t+=this.dict.copyBytesInto(e,t),t-i}};Vl.of=n=>new Vl(n);var Bd=Vl;var Hl=class n extends pr{constructor(e,t,i=!0){super(e.obj({}),i),this.objects=t,this.offsets=this.computeObjectOffsets(),this.offsetsString=this.computeOffsetsString(),this.dict.set(w.of("Type"),w.of("ObjStm")),this.dict.set(w.of("N"),K.of(this.objects.length)),this.dict.set(w.of("First"),K.of(this.offsetsString.length))}getObjectsCount(){return this.objects.length}clone(e){return n.withContextAndObjects(e||this.dict.context,this.objects.slice(),this.encode)}getContentsString(){let e=this.offsetsString;for(let t=0,i=this.objects.length;t<i;t++){let[,r]=this.objects[t];e+= ` $ { r }
` }return e}getUnencodedContents(){let e=new Uint8Array(this.getUnencodedContentsSize()),t=Se(this.offsetsString,e,0);for(let i=0,r=this.objects.length;i<r;i++){let[,o]=this.objects[i];t+=o.copyBytesInto(e,t),e[t++]=P.Newline}return e}getUnencodedContentsSize(){return this.offsetsString.length+Jr(this.offsets)[1]+Jr(this.objects)[1].sizeInBytes()+1}computeOffsetsString(){let e="";for(let t=0,i=this.offsets.length;t<i;t++){let[r,o]=this.offsets[t];e+= ` $ { r } $ { o } ` }return e}computeObjectOffsets(){let e=0,t=new Array(this.objects.length);for(let i=0,r=this.objects.length;i<r;i++){let[o,s]=this.objects[i];t[i]=[o.objectNumber,e],e+=s.sizeInBytes()+1}return t}};Hl.withContextAndObjects=(n,e,t=!0)=>new Hl(n,e,t);var Ss=Hl;var zl=class{constructor(e,t){this.parsedObjects=0,this.shouldWaitForTick=i=>(this.parsedObjects+=i,this.parsedObjects%this.objectsPerTick===0),this.context=e,this.objectsPerTick=t}async serializeToBuffer(){let{size:e,header:t,indirectObjects:i,xref:r,trailerDict:o,trailer:s}=await this.computeBufferSize(),a=0,c=new Uint8Array(e);a+=t.copyBytesInto(c,a),c[a++]=P.Newline,c[a++]=P.Newline;for(let l=0,d=i.length;l<d;l++){let[h,u]=i[l],p=String(h.objectNumber);a+=Se(p,c,a),c[a++]=P.Space;let f=String(h.generationNumber);a+=Se(f,c,a),c[a++]=P.Space,c[a++]=P.o,c[a++]=P.b,c[a++]=P.j,c[a++]=P.Newline,a+=u.copyBytesInto(c,a),c[a++]=P.Newline,c[a++]=P.e,c[a++]=P.n,c[a++]=P.d,c[a++]=P.o,c[a++]=P.b,c[a++]=P.j,c[a++]=P.Newline,c[a++]=P.Newline;let m=u instanceof Ss?u.getObjectsCount():1;this.shouldWaitForTick(m)&&await Ti()}return r&&(a+=r.copyBytesInto(c,a),c[a++]=P.Newline),o&&(a+=o.copyBytesInto(c,a),c[a++]=P.Newline,c[a++]=P.Newline),a+=s.copyBytesInto(c,a),c}computeIndirectObjectSize([e,t]){let i=e.sizeInBytes()+3,r=t.sizeInBytes()+9;return i+r}createTrailerDict(){return this.context.obj({Size:this.context.largestObjectNumber+1,Root:this.context.trailerInfo.Root,Encrypt:this.context.trailerInfo.Encrypt,Info:this.context.trailerInfo.Info,ID:this.context.trailerInfo.ID})}async computeBufferSize(){let e=en.forVersion(1,7),t=e.sizeInBytes()+2,i=po.create(),r=this.context.security,o=this.context.enumerateIndirectObjects();for(let l=0,d=o.length;l<d;l++){let h=o[l],[u,p]=h;r&&this.encrypt(u,p,r),i.addEntry(u,t),t+=this.computeIndirectObjectSize(h),this.shouldWaitForTick(1)&&await Ti()}let s=t;t+=i.sizeInBytes()+1;let a=Bd.of(this.createTrailerDict());t+=a.sizeInBytes()+2;let c=mr.forLastCrossRefSectionOffset(s);return t+=c.sizeInBytes(),{size:t,header:e,indirectObjects:o,xref:i,trailerDict:a,trailer:c}}encrypt(e,t,i){if(t instanceof Ee){let r=i.getEncryptFn(e.objectNumber,e.generationNumber),o=t.getContents(),s=r(o);t.updateContents(s)}}};zl.forContext=(n,e)=>new zl(n,e);var Es=zl;var Ul=class n extends Pe{constructor(e){super(),this.data=e}clone(){return n.of(this.data.slice())}toString(){return ` PDFInvalidObject ( $ { this . data . length } bytes ) ` }sizeInBytes(){return this.data.length}copyBytesInto(e,t){let i=this.data.length;for(let r=0;r<i;r++)e[t++]=this.data[r];return i}};Ul.of=n=>new Ul(n);var Ts=Ul;var iP=/ \/ ([^ \0 \t \n \f \r \ ]+)[ \0 \t \n \f \r \ ]*( \d * \. \d +| \d +)?[ \0 \t \n \f \r \ ]+Tf/,Of=class n{constructor(e,t){this.dict=e,this.ref=t}T(){return this.dict.lookupMaybe(w.of("T"),ee,j)}Ff(){let e=this.getInheritableAttribute(w.of("Ff"));return this.dict.context.lookupMaybe(e,K)}V(){let e=this.getInheritableAttribute(w.of("V"));return this.dict.context.lookup(e)}Kids(){return this.dict.lookupMaybe(w.of("Kids"),X)}DA(){let e=this.dict.lookup(w.of("DA"));if(e instanceof ee||e instanceof j)return e}setKids(e){this.dict.set(w.of("Kids"),this.dict.context.obj(e))}getParent(){let e=this.dict.get(w.of("Parent"));if(e instanceof Y){let t=this.dict.lookup(w.of("Parent"),G);return new n(t,e)}}setParent(e){e?this.dict.set(w.of("Parent"),e):this.dict.delete(w.of("Parent"))}getFullyQualifiedName(){let e=this.getParent();return e? ` $ { e . getFullyQualifiedName ( ) } . $ { this . getPartialName ( ) } ` :this.getPartialName()}getPartialName(){var e;return(e=this.T())===null||e===void 0?void 0:e.decodeText()}setPartialName(e){e?this.dict.set(w.of("T"),j.fromText(e)):this.di
2025-02-18 05:37:27 -03:00
12 dict begin
begincmap
/ C I D S y s t e m I n f o < <
/ R e g i s t r y ( A d o b e )
/ O r d e r i n g ( U C S )
/ S u p p l e m e n t 0
>> def
/ C M a p N a m e / A d o b e - I d e n t i t y - U C S d e f
/ C M a p T y p e 2 d e f
1 begincodespacerange
< 0000 > < ffff >
endcodespacerange
$ { n . length } beginbfchar
$ { n . map ( ( [ e , t ] ) => ` ${ e } ${ t } ` ) . join ( `
` )}
endbfchar
endcmap
CMapName currentdict / CMap defineresource pop
end
2025-03-07 06:22:58 -03:00
end ` ,Zb=(...n)=> ` < $ { n . join ( "" ) } > ` ,Hd=n=>Gi(n,4),lP=n=>{if(V0(n))return Hd(n);if(H0(n)){let i=hd(n),r=ud(n);return ` $ { Hd ( i ) } $ { Hd ( r ) } ` }let t= ` 0 x$ { Xi ( n ) } is not a valid UTF - 8 or UTF - 16 codepoint . ` ;throw new Error(t)};var cP=n=>{let e=0,t=i=>{e|=1<<i-1};return n.fixedPitch&&t(1),n.serif&&t(2),n.symbolic&&t(3),n.script&&t(4),n.nonsymbolic&&t(6),n.italic&&t(7),n.allCap&&t(17),n.smallCap&&t(18),n.forceBold&&t(19),e},Jb=n=>{let e=n["OS/2"]?n["OS/2"].sFamilyClass:0;return cP({fixedPitch:n.post.isFixedPitch,serif:1<=e&&e<=7,symbolic:!0,script:e===10,italic:n.head.macStyle.italic})};var Hf=class n{static async for(e,t,i,r){let o=await e.create(t);return new n(o,t,i,r)}constructor(e,t,i,r){this.allGlyphsInFontSortedById=()=>{let o=new Array(this.font.characterSet.length);for(let s=0,a=o.length;s<a;s++){let c=this.font.characterSet[s];o[s]=this.font.glyphForCodePoint(c)}return I0(o.sort(A0),s=>s.id)},this.font=e,this.scale=1e3/this.font.unitsPerEm,this.fontData=t,this.fontName=this.font.postscriptName||"Font",this.customName=i,this.fontFeatures=r,this.baseFontName="",this.glyphCache=ht.populatedBy(this.allGlyphsInFontSortedById)}encodeText(e){let{glyphs:t}=this.font.layout(e,this.fontFeatures),i=new Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=Gi(t[r].id,4);return j.of(i.join(""))}widthOfTextAtSize(e,t){let{glyphs:i}=this.font.layout(e,this.fontFeatures),r=0;for(let s=0,a=i.length;s<a;s++)r+=i[s].advanceWidth*this.scale;let o=t/1e3;return r*o}heightOfFontAtSize(e,t={}){let{descender:i=!0}=t,{ascent:r,descent:o,bbox:s}=this.font,a=(r||s.maxY)*this.scale,c=(o||s.minY)*this.scale,l=a-c;return i||(l-=Math.abs(o)||0),l/1e3*e}sizeOfFontAtHeight(e){let{ascent:t,descent:i,bbox:r}=this.font,o=(t||r.maxY)*this.scale,s=(i||r.minY)*this.scale;return 1e3*e/(o-s)}embedIntoContext(e,t){return this.baseFontName=this.customName||e.addRandomSuffix(this.fontName),this.embedFontDict(e,t)}async embedFontDict(e,t){let i=await this.embedCIDFontDict(e),r=this.embedUnicodeCmap(e),o=e.obj({Type:"Font",Subtype:"Type0",BaseFont:this.baseFontName,Encoding:"Identity-H",DescendantFonts:[i],ToUnicode:r});return t?(e.assign(t,o),t):e.register(o)}isCFF(){return this.font.cff}async embedCIDFontDict(e){let t=await this.embedFontDescriptor(e),i=e.obj({Type:"Font",Subtype:this.isCFF()?"CIDFontType0":"CIDFontType2",CIDToGIDMap:"Identity",BaseFont:this.baseFontName,CIDSystemInfo:{Registry:ee.of("Adobe"),Ordering:ee.of("Identity"),Supplement:0},FontDescriptor:t,W:this.computeWidths()});return e.register(i)}async embedFontDescriptor(e){let t=await this.embedFontStream(e),{scale:i}=this,{italicAngle:r,ascent:o,descent:s,capHeight:a,xHeight:c}=this.font,{minX:l,minY:d,maxX:h,maxY:u}=this.font.bbox,p=e.obj({Type:"FontDescriptor",FontName:this.baseFontName,Flags:Jb(this.font),FontBBox:[l*i,d*i,h*i,u*i],ItalicAngle:r,Ascent:o*i,Descent:s*i,CapHeight:(a||o)*i,XHeight:(c||0)*i,StemV:0,[this.isCFF()?"FontFile3":"FontFile2"]:t});return e.register(p)}async serializeFont(){return this.fontData}async embedFontStream(e){let t=e.flateStream(await this.serializeFont(),{Subtype:this.isCFF()?"CIDFontType0C":void 0});return e.register(t)}embedUnicodeCmap(e){let t=Yb(this.glyphCache.access(),this.glyphId.bind(this)),i=e.flateStream(t);return e.register(i)}glyphId(e){return e?e.id:-1}computeWidths(){let e=this.glyphCache.access(),t=[],i=[];for(let r=0,o=e.length;r<o;r++){let s=e[r],a=e[r-1],c=this.glyphId(s),l=this.glyphId(a);r===0?t.push(c):c-l!==1&&(t.push(i),t.push(c),i=[]),i.push(s.advanceWidth*this.scale)}return t.push(i),t}},Pr=Hf;var zf=class n extends Pr{static async for(e,t,i,r){let o=await e.create(t);return new n(o,t,i,r)}constructor(e,t,i,r){super(e,t,i,r),this.subset=this.font.createSubset(),this.glyphs=[],this.glyphCache=ht.populatedBy(()=>this.glyphs),this.glyphIdMap=new Map}encodeText(e){let{glyphs:t}=this.font.layout(e,this.fontFeatures),i=new Array(t.length);for(let r=0,o=t.length;r<o;r++){let s=t[r],a=this.subset.includeGlyph(s);this.glyphs[a-1]=s,this.glyphIdMap.set(s.id,a),i[r]=Gi(a,4)}return this.glyphCache.invalidate(),j.of(i.join(""))}isCFF(){return this.subset.cf
` );n.setDefaultAppearance(o)},Up=(n,e)=>{var t,i,r;let o=gi(e),s=gi(n.acroField),a=e.getRectangle(),c=e.getAppearanceCharacteristics(),l=e.getBorderStyle(),d=(t=l==null?void 0:l.getWidth())!==null&&t!==void 0?t:0,h=di(c==null?void 0:c.getRotation()),{width:u,height:p}=on(a,h),f=pi({...a,rotation:h}),m=fe(0,0,0),x=(i=yt(c==null?void 0:c.getBorderColor()))!==null&&i!==void 0?i:m,g=yt(c==null?void 0:c.getBackgroundColor()),b=yt(c==null?void 0:c.getBackgroundColor(),.8),v=(r=o!=null?o:s)!==null&&r!==void 0?r:m;mi(o?e:n.acroField,v);let y={x:0+d/2,y:0+d/2,width:u-d,height:p-d,thickness:1.5,borderWidth:d,borderColor:x,markColor:v};return{normal:{on:[...f,...oa({...y,color:g,filled:!0})],off:[...f,...oa({...y,color:g,filled:!1})]},down:{on:[...f,...oa({...y,color:b,filled:!0})],off:[...f,...oa({...y,color:b,filled:!1})]}}},qp=(n,e)=>{var t,i,r;let o=gi(e),s=gi(n.acroField),a=e.getRectangle(),c=e.getAppearanceCharacteristics(),l=e.getBorderStyle(),d=(t=l==null?void 0:l.getWidth())!==null&&t!==void 0?t:0,h=di(c==null?void 0:c.getRotation()),{width:u,height:p}=on(a,h),f=pi({...a,rotation:h}),m=fe(0,0,0),x=(i=yt(c==null?void 0:c.getBorderColor()))!==null&&i!==void 0?i:m,g=yt(c==null?void 0:c.getBackgroundColor()),b=yt(c==null?void 0:c.getBackgroundColor(),.8),v=(r=o!=null?o:s)!==null&&r!==void 0?r:m;mi(o?e:n.acroField,v);let y={x:u/2,y:p/2,width:u-d,height:p-d,borderWidth:d,borderColor:x,dotColor:v};return{normal:{on:[...f,...sa({...y,color:g,filled:!0})],off:[...f,...sa({...y,color:g,filled:!1})]},down:{on:[...f,...sa({...y,color:b,filled:!0})],off:[...f,...sa({...y,color:b,filled:!1})]}}},Wp=(n,e,t)=>{var i,r,o,s,a;let c=gi(e),l=gi(n.acroField),d=Lr(e),h=Lr(n.acroField),u=e.getRectangle(),p=e.getAppearanceCharacteristics(),f=e.getBorderStyle(),m=p==null?void 0:p.getCaptions(),x=(i=m==null?void 0:m.normal)!==null&&i!==void 0?i:"",g=(o=(r=m==null?void 0:m.down)!==null&&r!==void 0?r:x)!==null&&o!==void 0?o:"",b=(s=f==null?void 0:f.getWidth())!==null&&s!==void 0?s:0,v=di(p==null?void 0:p.getRotation()),{width:y,height:F}=on(u,v),D=pi({...u,rotation:v}),C=fe(0,0,0),k=yt(p==null?void 0:p.getBorderColor()),E=yt(p==null?void 0:p.getBackgroundColor()),B=yt(p==null?void 0:p.getBackgroundColor(),.8),S={x:b,y:b,width:y-b*2,height:F-b*2},I=la(x,{alignment:qe.Center,fontSize:d!=null?d:h,font:t,bounds:S}),L=la(g,{alignment:qe.Center,fontSize:d!=null?d:h,font:t,bounds:S}),A=Math.min(I.fontSize,L.fontSize),N=(a=c!=null?c:l)!==null&&a!==void 0?a:C;mi(c||d!==void 0?e:n.acroField,N,t,A);let q={x:0+b/2,y:0+b/2,width:y-b,height:F-b,borderWidth:b,borderColor:k,textColor:N,font:t.name,fontSize:A};return{normal:[...D,...tu({...q,color:E,textLines:[I.line]})],down:[...D,...tu({...q,color:B,textLines:[L.line]})]}},jp=(n,e,t)=>{var i,r,o,s;let a=gi(e),c=gi(n.acroField),l=Lr(e),d=Lr(n.acroField),h=e.getRectangle(),u=e.getAppearanceCharacteristics(),p=e.getBorderStyle(),f=(i=n.getText())!==null&&i!==void 0?i:"",m=(r=p==null?void 0:p.getWidth())!==null&&r!==void 0?r:0,x=di(u==null?void 0:u.getRotation()),{width:g,height:b}=on(h,x),v=pi({...h,rotation:x}),y=fe(0,0,0),F=yt(u==null?void 0:u.getBorderColor()),D=yt(u==null?void 0:u.getBackgroundColor()),C,k,E=n.isCombed()?0:1,B={x:m+E,y:m+E,width:g-(m+E)*2,height:b-(m+E)*2};if(n.isMultiline()){let L=ru(f,{alignment:n.getAlignment(),fontSize:l!=null?l:d,font:t,bounds:B});C=L.lines,k=L.fontSize}else if(n.isCombed()){let L=zp(f,{fontSize:l!=null?l:d,font:t,bounds:B,cellCount:(o=n.getMaxLength())!==null&&o!==void 0?o:0});C=L.cells,k=L.fontSize}else{let L=la(f,{alignment:n.getAlignment(),fontSize:l!=null?l:d,font:t,bounds:B});C=[L.line],k=L.fontSize}let S=(s=a!=null?a:c)!==null&&s!==void 0?s:y;mi(a||l!==void 0?e:n.acroField,S,t,k);let I={x:0+m/2,y:0+m/2,width:g-m,height:b-m,borderWidth:m!=null?m:0,borderColor:F,textColor:S,font:t.name,fontSize:k,color:D,textLines:C,padding:E};return[...v,...nu(I)]},Kp=(n,e,t)=>{var i,r,o;let s=gi(e),a=gi(n.acroField),c=Lr(e),l=Lr(n.acroField),d=e.getRectangle(),h=e.getAppearanceCharacteristics(),u=e.getBorderStyle(),p=(i=n.getSelected()[0])!==null&&i!==void 0?i:"",f=(r=u==null?void 0:u
` );let C=1,k={x:u+C,y:u+C,width:f-(u+C)*2,height:m-(u+C)*2},{lines:E,fontSize:B,lineHeight:S}=ru(D,{alignment:qe.Left,fontSize:a!=null?a:c,font:t,bounds:k}),I=[];for(let N=0,q=E.length;N<q;N++){let U=E[N];F.includes(U.text)&&I.push(N)}let L=fe(153/255,193/255,218/255),A=(r=o!=null?o:s)!==null&&r!==void 0?r:g;return mi(o||a!==void 0?e:n.acroField,A,t,B),[...x,...Rp({x:0+u/2,y:0+u/2,width:f-u,height:m-u,borderWidth:u!=null?u:0,borderColor:b,textColor:A,font:t.name,fontSize:B,color:v,textLines:E,lineHeight:S,selectedColor:L,selectedLines:I,padding:C})]};var lu=Ki(Ap(),1);var zi=class{constructor(e,t,i){this.alreadyEmbedded=!1,T(e,"ref",[[Y,"PDFRef"]]),T(t,"doc",[[je,"PDFDocument"]]),T(i,"embedder",[[Us,"PDFPageEmbedder"]]),this.ref=e,this.doc=t,this.width=i.width,this.height=i.height,this.embedder=i}scale(e){return T(e,"factor",["number"]),{width:this.width*e,height:this.height*e}}size(){return this.scale(1)}async embed(){this.alreadyEmbedded||(await this.embedder.embedIntoContext(this.doc.context,this.ref),this.alreadyEmbedded=!0)}};zi.of=(n,e,t)=>new zi(n,e,t);var Oe=class{constructor(e,t,i){this.modified=!0,T(e,"ref",[[Y,"PDFRef"]]),T(t,"doc",[[je,"PDFDocument"]]),T(i,"embedder",[[Pr,"CustomFontEmbedder"],[Dr,"StandardFontEmbedder"]]),this.ref=e,this.doc=t,this.name=i.fontName,this.embedder=i}encodeText(e){return T(e,"text",["string"]),this.modified=!0,this.embedder.encodeText(e)}widthOfTextAtSize(e,t){return T(e,"text",["string"]),T(t,"size",["number"]),this.embedder.widthOfTextAtSize(e,t)}heightAtSize(e,t){var i;return T(e,"size",["number"]),V(t==null?void 0:t.descender,"options.descender",["boolean"]),this.embedder.heightOfFontAtSize(e,{descender:(i=t==null?void 0:t.descender)!==null&&i!==void 0?i:!0})}sizeAtHeight(e){return T(e,"height",["number"]),this.embedder.sizeOfFontAtHeight(e)}getCharacterSet(){return this.embedder instanceof Dr?this.embedder.encoding.supportedCodePoints:this.embedder.font.characterSet}async embed(){this.modified&&(await this.embedder.embedIntoContext(this.doc.context,this.ref),this.modified=!1)}};Oe.of=(n,e,t)=>new Oe(n,e,t);var xi=class{constructor(e,t,i){T(e,"ref",[[Y,"PDFRef"]]),T(t,"doc",[[je,"PDFDocument"]]),T(i,"embedder",[[Rs,"JpegEmbedder"],[Hs,"PngEmbedder"]]),this.ref=e,this.doc=t,this.width=i.width,this.height=i.height,this.embedder=i}scale(e){return T(e,"factor",["number"]),{width:this.width*e,height:this.height*e}}scaleToFit(e,t){T(e,"width",["number"]),T(t,"height",["number"]);let i=e/this.width,r=t/this.height,o=Math.min(i,r);return this.scale(o)}size(){return this.scale(1)}async embed(){if(this.embedder){if(!this.embedTask){let{doc:e,ref:t}=this;this.embedTask=this.embedder.embedIntoContext(e.context,t)}await this.embedTask,this.embedder=void 0}}};xi.of=(n,e,t)=>new xi(n,e,t);var bi;(function(n){n[n.Left=0]="Left",n[n.Center=1]="Center",n[n.Right=2]="Right"})(bi||(bi={}));var yi=n=>{V(n==null?void 0:n.x,"options.x",["number"]),V(n==null?void 0:n.y,"options.y",["number"]),V(n==null?void 0:n.width,"options.width",["number"]),V(n==null?void 0:n.height,"options.height",["number"]),V(n==null?void 0:n.textColor,"options.textColor",[[Object,"Color"]]),V(n==null?void 0:n.backgroundColor,"options.backgroundColor",[[Object,"Color"]]),V(n==null?void 0:n.borderColor,"options.borderColor",[[Object,"Color"]]),V(n==null?void 0:n.borderWidth,"options.borderWidth",["number"]),V(n==null?void 0:n.rotate,"options.rotate",[[Object,"Rotation"]])},at=class{constructor(e,t,i){T(e,"acroField",[[zt,"PDFAcroTerminal"]]),T(t,"ref",[[Y,"PDFRef"]]),T(i,"doc",[[je,"PDFDocument"]]),this.acroField=e,this.ref=t,this.doc=i}getName(){var e;return(e=this.acroField.getFullyQualifiedName())!==null&&e!==void 0?e:""}isReadOnly(){return this.acroField.hasFlag(jt.ReadOnly)}enableReadOnly(){this.acroField.setFlagTo(jt.ReadOnly,!0)}disableReadOnly(){this.acroField.setFlagTo(jt.ReadOnly,!1)}isRequired(){return this.acroField.hasFlag(jt.Required)}enableRequired(){this.acroField.setFlagTo(jt.Required,!0)}disableRequired(){this.acroField.setFlagTo(jt.Required,!1)}isExported(){return!this.acroField.hasFlag(jt.NoExport)}enabl
` +Ni(i).toString();this.acroField.setDefaultAppearance(y)}return m}updateWidgetAppearanceWithFont(e,t,{normal:i,rollover:r,down:o}){this.updateWidgetAppearances(e,{normal:this.createAppearanceStream(e,i,t),rollover:r&&this.createAppearanceStream(e,r,t),down:o&&this.createAppearanceStream(e,o,t)})}updateOnOffWidgetAppearance(e,t,{normal:i,rollover:r,down:o}){this.updateWidgetAppearances(e,{normal:this.createAppearanceDict(e,i,t),rollover:r&&this.createAppearanceDict(e,r,t),down:o&&this.createAppearanceDict(e,o,t)})}updateWidgetAppearances(e,{normal:t,rollover:i,down:r}){e.setNormalAppearance(t),i?e.setRolloverAppearance(i):e.removeRolloverAppearance(),r?e.setDownAppearance(r):e.removeDownAppearance()}createAppearanceStream(e,t,i){let{context:r}=this.acroField.dict,{width:o,height:s}=e.getRectangle(),a=i&&{Font:{[i.name]:i.ref}},c=r.formXObject(t,{Resources:a,BBox:r.obj([0,0,o,s]),Matrix:r.obj([1,0,0,1,0,0])});return r.register(c)}createImageAppearanceStream(e,t,i){var r;let{context:o}=this.acroField.dict,s=e.getRectangle(),a=e.getAppearanceCharacteristics(),c=e.getBorderStyle(),l=(r=c==null?void 0:c.getWidth())!==null&&r!==void 0?r:0,d=di(a==null?void 0:a.getRotation()),h=pi({...s,rotation:d}),u=on(s,d),p=t.scaleToFit(u.width-l*2,u.height-l*2),f={x:l,y:l,width:p.width,height:p.height,rotate: $ (0),xSkew: $ (0),ySkew: $ (0)};i===bi.Center?(f.x+=(u.width-l*2)/2-p.width/2,f.y+=(u.height-l*2)/2-p.height/2):i===bi.Right&&(f.x=u.width-l-p.width,f.y=u.height-l-p.height);let m=this.doc.context.addRandomSuffix("Image",10),x=[...h,...wc(m,f)],g={XObject:{[m]:t.ref}},b=o.formXObject(x,{Resources:g,BBox:o.obj([0,0,s.width,s.height]),Matrix:o.obj([1,0,0,1,0,0])});return o.register(b)}createAppearanceDict(e,t,i){let{context:r}=this.acroField.dict,o=this.createAppearanceStream(e,t.on),s=this.createAppearanceStream(e,t.off),a=r.obj({});return a.set(i,o),a.set(w.of("Off"),s),a}};var Yt=class extends at{constructor(e,t,i){super(e,t,i),T(e,"acroCheckBox",[[En,"PDFAcroCheckBox"]]),this.acroField=e}check(){var e;let t=(e=this.acroField.getOnValue())!==null&&e!==void 0?e:w.of("Yes");this.markAsDirty(),this.acroField.setValue(t)}uncheck(){this.markAsDirty(),this.acroField.setValue(w.of("Off"))}isChecked(){let e=this.acroField.getOnValue();return!!e&&e===this.acroField.getValue()}addToPage(e,t){var i,r,o,s,a,c;T(e,"page",[[Ie,"PDFPage"]]),yi(t),t||(t={}),"textColor"in t||(t.textColor=fe(0,0,0)),"backgroundColor"in t||(t.backgroundColor=fe(1,1,1)),"borderColor"in t||(t.borderColor=fe(0,0,0)),"borderWidth"in t||(t.borderWidth=1);let l=this.createWidget({x:(i=t.x)!==null&&i!==void 0?i:0,y:(r=t.y)!==null&&r!==void 0?r:0,width:(o=t.width)!==null&&o!==void 0?o:50,height:(s=t.height)!==null&&s!==void 0?s:50,textColor:t.textColor,backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:(a=t.borderWidth)!==null&&a!==void 0?a:0,rotate:(c=t.rotate)!==null&&c!==void 0?c: $ (0),hidden:t.hidden,page:e.ref}),d=this.doc.context.register(l.dict);this.acroField.addWidget(d),l.setAppearanceState(w.of("Off")),this.updateWidgetAppearance(l,w.of("Yes")),e.node.addAnnot(d)}needsAppearancesUpdate(){var e;let t=this.acroField.getWidgets();for(let i=0,r=t.length;i<r;i++){let o=t[i],s=o.getAppearanceState(),a=(e=o.getAppearances())===null||e===void 0?void 0:e.normal;if(!(a instanceof G)||s&&!a.has(s))return!0}return!1}defaultUpdateAppearances(){this.updateAppearances()}updateAppearances(e){var t;V(e,"provider",[Function]);let i=this.acroField.getWidgets();for(let r=0,o=i.length;r<o;r++){let s=i[r],a=(t=s.getOnValue())!==null&&t!==void 0?t:w.of("Yes");a&&this.updateWidgetAppearance(s,a,e)}this.markAsClean()}updateWidgetAppearance(e,t,i){let r=i!=null?i:Up,o=Zt(r(this,e));this.updateOnOffWidgetAppearance(e,t,o)}};Yt.of=(n,e,t)=>new Yt(n,e,t);var vi=class extends at{constructor(e,t,i){super(e,t,i),T(e,"acroComboBox",[[Tn,"PDFAcroComboBox"]]),this.acroField=e}getOptions(){let e=this.acroField.getOptions(),t=new Array(e.length);for(let i=0,r=t.length;i<r;i++){let{display:o,value:s}=e[i];t[i]=(o!=null?o:s).decodeText()}return t}getSelected(){let e=this.acroField.getValu
` )}}),e}async findPDFjsOutlineTreeNode(e){let t=null;return await this.iterAsync({enter:async i=>{if(!(t||i.isRoot())&&e.item.title===i.title){let r=e.item.dest,o=i.getNormalizedDestination();if(typeof r=="string")typeof o=="string"&&r===o&&(t=i);else{let s=await e.getPageNumber();JSON.stringify(this.lib.normalizePDFJsDestArray(r,s))===JSON.stringify(o)&&(t=i)}}}}),t}static async processOutlineRoot(e,t,i){let{app:r}=i,o=await n.fromFile(t,i);e(o.ensureRoot());let s=await o.doc.save();await r.vault.modifyBinary(t,s)}static async findAndProcessOutlineItem(e,t,i,r){let{app:o}=r,s=await n.fromFile(i,r),a=await s.findPDFjsOutlineTreeNode(e);if(!a){new kw.Notice( ` $ { r . manifest . name } : Failed to process the outline item . ` );return}t(a);let c=await s.doc.save();await o.vault.modifyBinary(i,c)}},Cu=class n{constructor(e,t){this.outlines=e,this.dict=t}get doc(){return this.outlines.doc}get lib(){return this.outlines.plugin.lib}is(e){return e!==null&&this.dict===e.dict}_get(e){let t=lt(this.dict,e);return t instanceof G?new n(this.outlines,t):null}_setOrDelete(e,t){if(t){let i=this.doc.context.getObjectRef(t.dict);i||(i=this.doc.context.register(t.dict)),this.dict.set(w.of(e),i);return}this.dict.delete(w.of(e))}get firstChild(){return this._get("First")}set firstChild(e){if(e&&!this.is(e.parent))throw new Error( ` Item "${e.name}" is not a child of this item "${this.name}" ` );this._setOrDelete("First",e)}get lastChild(){return this._get("Last")}set lastChild(e){if(e&&!this.is(e.parent))throw new Error( ` Item "${e.name}" is not a child of this item "${this.name}" ` );this._setOrDelete("Last",e)}get nextSibling(){return this._get("Next")}set nextSibling(e){if(e&&!(e.parent&&e.parent.is(this.parent)))throw new Error( ` Item "${e.name}" is not a sibling of this item "${this.name}" ` );this._setOrDelete("Next",e)}get prevSibling(){return this._get("Prev")}set prevSibling(e){if(e&&!(e.parent&&e.parent.is(this.parent)))throw new Error( ` Item "${e.name}" is not a sibling of this item "${this.name}" ` );this._setOrDelete("Prev",e)}get parent(){return this._get("Parent")}set parent(e){if(e&&this.isRoot())throw new Error("Cannot set parent of the root of outline");this._setOrDelete("Parent",e)}get count(){let e=lt(this.dict,"Count");return e instanceof K?e.asNumber():null}set count(e){if(e===null){this.dict.delete(w.of("Count"));return}this.dict.set(w.of("Count"),K.of(e))}get title(){if(this.isRoot())throw new Error("Root of outline does not have a title");let e=lt(this.dict,"Title");if(e instanceof ee||e instanceof j)return e.decodeText();throw new Error("Title is not a string")}set title(e){if(this.isRoot())throw new Error("Cannot set title of the root of outline");this.dict.set(w.of("Title"),j.fromText(e))}get name(){if(this.isRoot())return"(Root)";let e=this.title;return this.iterAncestors(t=>{t.isRoot()||(e= ` $ { t . title } / $ { e } ` )}),e}get depth(){let e=0;return this.iterAncestors(()=>e++),e}isLeaf(){return!this.firstChild}isRoot(){return this.parent===null}createChild(e,t){let i;if(typeof t=="string")i=j.fromText(t);else{i=X.withContext(this.doc.context),i.push(this.doc.getPage(t[0]).ref),i.push(w.of(t[1]));for(let s of t.slice(2))i.push(typeof s=="number"?K.of(s):Ve)}let r=this.doc.context.getObjectRef(this.dict);if(!r)throw new Error("Could not get ref for parent");let o={Title:j.fromText(e),Dest:i,Parent:r};if(this.lastChild){Object.assign(o,{Prev:this.doc.context.getObjectRef(this.lastChild.dict)});let s=new n(this.outlines,this.doc.context.obj(o));this.lastChild.nextSibling=s,this.lastChild=s}else{let s=new n(this.outlines,this.doc.context.obj(o));this.firstChild=s,this.lastChild=s}return this.lastChild}appendChild(e){if(e.isAncestorOf(this,!0))throw new Error("Cannot append an ancestor as a child");e.remove(),e.updateCountForAllAncestors(),e.parent=this,this.lastChild?(this.lastChild.nextSibling=e,e.prevSibling=this.lastChild,this.lastChild=e):(this.firstChild=e,this.lastChild=e,e.prevSibling=null),e.nextSibling=null,e.updateCountForAllAncestors()}remove(){return this.prevSibling&&(this.prevSibling.nextSibling=this.nextSibling),this.nextSibling&&(this
` ),t=await this.parseBibliographyText(e);if(t){let i=Array.from(this.destIdToBibText.keys());for(let r=0;r<t.length;r++)this.destIdToParsedBib.set(i[r],t[r]),this.events.trigger("parsed",i[r],t[r])}}spawnBibPopoverOnModKeyDown(e,t,i,r){let o=()=>{let s=new Ft.HoverPopover(t,r,200);s.hoverEl.addClass("pdf-plus-bib-popover");let a=s.hoverEl.createDiv();s.addChild(new Vg(this,e,a))};this.plugin.requireModKeyForLinkHover(Su.HOVER_LINK_SOURCE_ID)?og(i,r,o):o()}getGoogleScholarSearchUrlFromDest(e){var r;let t="",i=this.destIdToParsedBib.get(e);if(i){let{author:o,title:s,year:a,"container-title":c}=i;s&&(t+= ` $ { s [ 0 ] } ` ),o&&(t+=" "+o.map(l=>l.family).join(" ")),a&&(t+= ` $ { a } ` ),c&&(t+= ` $ { c [ 0 ] } ` )}else t=(r=this.destIdToBibText.get(e))!=null?r:"";return t? ` https : //scholar.google.com/scholar?hl=en&as_sdt=0%2C5&q=${encodeURIComponent(t)}`:null}async parseBibliographyText(e){let{app:t,plugin:i,settings:r}=this,o=r.anystylePath;if(!o)return null;let s=i.getAnyStyleInputDir();if(Ft.Platform.isDesktopApp&&t.vault.adapter instanceof Ft.FileSystemAdapter&&s){let a=t.vault.adapter.getFullPath(s);await Ft.FileSystemAdapter.mkdir(a);let c=s+`/${dg()}.txt`,l=t.vault.adapter.getFullPath(c);await t.vault.adapter.write(c,e),this.register(()=>t.vault.adapter.remove(c));let{spawn:d}=require("child_process");return new Promise(h=>{let u=d(o,["parse",l]),p="";u.stdout.on("data",f=>{if(f){p+=f.toString();return}h(null)}),u.on("error",f=>{if("code"in f&&f.code==="ENOENT"){let m=`${i.manifest.name}: AnyStyle not found at the path "${o}".`;if(i.settings.anystylePath){let x=new Ft.Notice(m,8e3);x.noticeEl.appendText(" Click "),x.noticeEl.createEl("a",{text:"here"},g=>{g.addEventListener("click",()=>{i.openSettingTab().scrollTo("anystylePath")})}),x.noticeEl.appendText(" to update the path."),console.error(m)}else console.warn(m);return h(null)}}),u.on("close",f=>{var x;if(f)return h(null);let m=JSON.parse(p);if(Array.isArray(m)){for(let g of m)for(let b of(x=g.date)!=null?x:[]){let v=b.match(/\d{4}/);if(v){g.year=v[0];break}}h(m)}h(null)})})}return null}on(e,t,i){return this.events.on(e,t,i)}};Su.HOVER_LINK_SOURCE_ID="pdf-plus-citation-link";var pn=Su,Rg=class{constructor(e,t){this.plugin=e,this.doc=t,this.pageRefToTextContentItemsPromise={}}onExtracted(e){return this.onExtractedCallback=e,this}async extract(){let e=await this.doc.getDestinations(),t=[];for(let i in e)if(this.plugin.lib.isCitationId(i)){let r=e[i];t.push(this.extractBibTextForDest(r).then(o=>{var s;if(o){let a=o.text;(s=this.onExtractedCallback)==null||s.call(this,i,a)}}))}await Promise.all(t)}async getTextContentItemsFromPageRef(e){var i;let t=JSON.stringify(e);return(i=this.pageRefToTextContentItemsPromise[t])!=null?i:this.pageRefToTextContentItemsPromise[t]=(async()=>{let r=await this.doc.getPageIndex(e)+1;return(await(await this.doc.getPage(r)).getTextContent()).items})()}async extractBibTextForDest(e){let t=e[0],i=await this.getTextContentItemsFromPageRef(t),r=-1;if(e[1].name==="XYZ"){let d=e[2],h=e[3];if(d===null||h===null)return null;r=i.findIndex(u=>{if(!u.str)return!1;let p=u.transform[4],f=u.transform[5]+(u.height||u.transform[0])*.8;return d<=p&&f<=h})}else if(e[1].name==="FitBH"){let d=e[2];if(d===null)return null;r=i.findIndex(h=>h.str?h.transform[5]+(h.height||h.transform[0])*.8<=d:!1)}if(r===-1)return null;let o=i[r],s=o.transform[4],a=i[r].str,c=r+1,l=[o];for(;;){let d=i[c];if(!d||d.transform[4]<=s+Math.max(d.height,8)*.1)break;d.str.trimStart().startsWith(".")||d.str.trimStart().startsWith(",")?a=a.trimEnd()+d.str.trimStart():a+=`
` +d.str,l.push(d),c++}return a=a.trimStart().replace(/^ \[ \d + \] /,""),a=a.trimStart().replace(/^ \( \d + \) /,""),a=a.trimStart().replace(/^ \d + \. /,""),{text:Kc(a),items:l}}},Vg=class extends Fe{constructor(e,t,i){super(e.plugin),this.bib=e,this.destId=t,this.containerEl=i,this.containerEl.addClass("pdf-plus-bib")}get child(){return this.bib.child}renderParsedBib(e){let{author:t,title:i,year:r,"container-title":o}=e;return t?(this.containerEl.createDiv("",s=>{s.createDiv("bib-title",a=>{var c;a.setText((c=i==null?void 0:i[0])!=null?c:"No title")}),s.createDiv("bib-author-year",a=>{let c=t.map(l=>{let d="";return l.given&&(d+=l.given),l.family&&(d+=" "+l.family),d}).filter(l=>l).join(", ");a.appendText(c),r&&a.appendText( ` ( $ { r } ) ` )}),o&&s.createDiv("bib-container-title",a=>{a.setText(o[0])})}),!0):!1}async onload(){await this.render()}async render(){this.containerEl.empty();let e=!1,t=this.bib.destIdToParsedBib.get(this.destId);if(t&&(e=this.renderParsedBib(t)),!e){let i=this.bib.destIdToBibText.get(this.destId);i?(this.containerEl.createDiv({text:i}),Ft.Platform.isDesktopApp&&this.settings.anystylePath&&this.registerRenderOn("parsed")):this.bib.initialized?this.containerEl.createDiv({text:"No bibliography found"}):(this.containerEl.createDiv({text:"Loading..."}),this.registerRenderOn("extracted"))}this.containerEl.createDiv("button-container",i=>{new Ft.ButtonComponent(i).setButtonText("Google Scholar").onClick(()=>{let r=this.bib.getGoogleScholarSearchUrlFromDest(this.destId);if(!r){new Ft.Notice( ` $ { this . plugin . manifest . name } : $ { this . bib . initialized ? "No bibliography found" : "Still loading the bibliography information. Please try again later." } ` );return}window.open(r)}),new Ft.ExtraButtonComponent(i).setIcon("lucide-settings").setTooltip("Customize...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("citation")})})}registerRenderOn(e){let t=this.bib.on(e,i=>{i===this.destId&&(this.render(),this.bib.events.offref(t))});this.registerEvent(t)}onunload(){this.containerEl.empty()}};var Eu=class{get hoverPopover(){return this.child.hoverPopover}set hoverPopover(e){this.child.hoverPopover=e,e&&(e.hoverEl.addClass("pdf-plus-pdf-link-like-popover"),this.onHoverPopoverSet(e))}onHoverPopoverSet(e){}constructor(e,t,i){this.plugin=e,this.app=e.app,this.lib=e.lib,this.child=t,this.targetEl=i,this.useModifierKey()&&this.registerClickToOpenInNewLeaf(),this.shouldShowHoverPopover()&&this.registerHover(),this.shouldRecordHistory()&&this.registerClickToRecordHistory()}get hoverLinkSourceId(){return this.constructor.HOVER_LINK_SOURCE_ID}get file(){return this.child.file}get sourcePath(){var e,t;return(t=(e=this.file)==null?void 0:e.path)!=null?t:""}registerClickToOpenInNewLeaf(){let{app:e,plugin:t,targetEl:i}=this;t.registerDomEvent(i,"click",async r=>{if(r.defaultPrevented)return;let o=Tw.Keymap.isModEvent(r);if(!o)return;r.preventDefault(),r.stopPropagation();let s=await this.getLinkText(r);s!==null&&e.workspace.openLinkText(s,this.sourcePath,o)},{capture:!0})}async customHover(e){return!1}registerHover(){let{app:e,plugin:t,targetEl:i}=this;t.registerDomEvent(i,"mouseover",async r=>{if(await this.customHover(r))return;let o=null;try{o=await this.getLinkText(r)}catch(s){if(s.name==="UnknownErrorException")return console.warn( ` $ { this . plugin . manifest . name } : The destination was not found in this document . ` );throw s}o!==null&&e.workspace.trigger("hover-link",{event:r,source:this.hoverLinkSourceId,hoverParent:this,targetEl:i,linktext:o,sourcePath:this.sourcePath})})}registerClickToRecordHistory(){let{plugin:e,targetEl:t}=this;e.registerDomEvent(t,"click",i=>{this.recordLeafHistory()},{capture:!0})}recordLeafHistory(){this.lib.workspace.iteratePDFViews(e=>{if(e.containerEl.contains(this.targetEl)){let t=e.leaf;t.recordHistory(t.getHistoryState())}})}},Tu=class extends Eu{async getLinkText(e){var c,l,d;let{lib:t,child:i,targetEl:r}=this;if(!Pi(e,r))return null;let o=(c=i.pdfViewer.pdfViewer)==null?void 0:c.pdfDocument;if(!o)return null;let s=this.getDest(),a=null;return typeof s=="string"?a=await t.destIdToSubpath(s,o):a=await t.pdfJsDestArray
2025-02-18 05:37:27 -03:00
> { { selection } }
` },{name:"Link",template:"{{linkWithDisplay}}"},{name:"Embed",template:"!{{link}}"},{name:"Callout",template: ` > [ ! { { calloutType } } | { { color } } ] { { linkWithDisplay } }
> { { text } }
` },{name:"Quote in callout",template: ` > [ ! { { calloutType } } | { { color } } ] { { linkWithDisplay } }
> > { { text } }
>
> ` }],useAnotherCopyTemplateWhenNoSelection:!1,copyTemplateWhenNoSelection:"{{linkToPageWithDisplay}}",trimSelectionEmbed:!1,embedMargin:50,noSidebarInEmbed:!0,noSpreadModeInEmbed:!0,embedUnscrollable:!1,singleTabForSinglePDF:!0,highlightExistingTab:!1,existingTabHighlightOpacity:.5,existingTabHighlightDuration:.75,paneTypeForFirstPDFLeaf:"left",openLinkNextToExistingPDFTab:!0,openPDFWithDefaultApp:!1,openPDFWithDefaultAppAndObsidian:!0,focusObsidianAfterOpenPDFWithDefaultApp:!0,syncWithDefaultApp:!1,dontActivateAfterOpenPDF:!0,dontActivateAfterOpenMD:!0,highlightDuration:.75,noTextHighlightsInEmbed:!1,noAnnotationHighlightsInEmbed:!0,persistentTextHighlightsInEmbed:!0,persistentAnnotationHighlightsInEmbed:!1,highlightBacklinks:!0,selectionBacklinkVisualizeStyle:"highlight",dblclickEmbedToOpenLink:!0,highlightBacklinksPane:!0,highlightOnHoverBacklinkPane:!0,backlinkHoverColor:"",colors:{Yellow:"#ffd000",Red:"#ea5252",Note:"#086ddd",Important:"#bb61e5"},defaultColor:"",defaultColorPaletteItemIndex:0,syncColorPaletteItem:!0,syncDefaultColorPaletteItem:!1,colorPaletteInToolbar:!0,noColorButtonInColorPalette:!0,colorPaletteInEmbedToolbar:!1,quietColorPaletteTooltip:!1,showStatusInToolbar:!0,highlightColorSpecifiedOnly:!1,doubleClickHighlightToOpenBacklink:!0,hoverHighlightAction:"preview",paneTypeForFirstMDLeaf:"right",singleMDLeafInSidebar:!0,alwaysUseSidebar:!0,ignoreExistingMarkdownTabIn:[],defaultColorPaletteActionIndex:4,syncColorPaletteAction:!0,syncDefaultColorPaletteAction:!1,proxyMDProperty:"PDF",hoverPDFLinkToOpen:!1,ignoreHeightParamInPopoverPreview:!0,filterBacklinksByPageDefault:!0,showBacklinkToPage:!0,enableHoverPDFInternalLink:!0,recordPDFInternalLinkHistory:!0,alwaysRecordHistory:!0,renderMarkdownInStickyNote:!1,enablePDFEdit:!1,author:"",writeHighlightToFileOpacity:.2,defaultWriteFileToggle:!1,syncWriteFileToggle:!0,syncDefaultWriteFileToggle:!1,enableAnnotationDeletion:!0,warnEveryAnnotationDelete:!1,warnBacklinkedAnnotationDelete:!0,enableAnnotationContentEdit:!0,enableEditEncryptedPDF:!1,pdfLinkColor:"#04a802",pdfLinkBorder:!1,replaceContextMenu:!0,showContextMenuOnMouseUpIf:"Mod",contextMenuConfig:[{id:"action",visible:!0},{id:"selection",visible:!0},{id:"write-file",visible:!0},{id:"annotation",visible:!0},{id:"modify-annotation",visible:!0},{id:"link",visible:!0},{id:"text",visible:!0},{id:"search",visible:!0},{id:"speech",visible:!0},{id:"page",visible:!0},{id:"settings",visible:!0}],selectionProductMenuConfig:["color","copy-format","display"],writeFileProductMenuConfig:["color","copy-format","display"],annotationProductMenuConfig:["copy-format","display"],updateColorPaletteStateFromContextMenu:!0,mobileCopyAction:"pdf-plus",showContextMenuOnTablet:!1,executeBuiltinCommandForOutline:!0,executeBuiltinCommandForZoom:!0,executeFontSizeAdjusterCommand:!0,closeSidebarWithShowCommandIfExist:!0,autoHidePDFSidebar:!1,defaultSidebarView:1,outlineDrag:!0,outlineContextMenu:!0,outlineLinkDisplayTextFormat:"{{file.basename}}, {{text}}",outlineLinkCopyFormat:"{{linkWithDisplay}}",recordHistoryOnOutlineClick:!0,popoverPreviewOnOutlineHover:!0,thumbnailDrag:!0,thumbnailContextMenu:!0,thumbnailLinkDisplayTextFormat:"{{file.basename}}, p.{{pageLabel}}",thumbnailLinkCopyFormat:"{{linkWithDisplay}}",recordHistoryOnThumbnailClick:!0,popoverPreviewOnThumbnailHover:!0,annotationPopupDrag:!0,showAnnotationPopupOnHover:!0,useCallout:!0,calloutType:"PDF",calloutIcon:"highlighter",highlightBacklinksInEmbed:!1,highlightBacklinksInHoverPopover:!1,highlightBacklinksInCanvas:!0,clickPDFInternalLinkWithModifierKey:!0,clickOutlineItemWithModifierKey:!0,clickThumbnailWithModifierKey:!0,focusEditorAfterAutoPaste:!0,clearSelectionAfterAutoPaste:!0,respectCursorPositionWhenAutoPaste:!0,blankLineAboveAppendedContent:!0,autoCopy:!1,autoFocus:!1,autoPaste:!1,autoFocusTarget:"last-active-and-open-then-last-paste",autoPasteTarget:"last-active-and-open-then-last-paste",openAutoFocusTargetIfNotOpened:!0,howToOpenAutoFocusTargetIfNotOpened:"right",closeHoverEditorWhenLostFocus:!0,closeSidebarWhenLostFocus:!1,openAutoFocusTargetInEditingView:!
2025-03-07 06:22:58 -03:00
{ { linkWithDisplay } } ` ,copyOutlineAsHeadingsDisplayTextFormat:"p.{{pageLabel}}",copyOutlineAsHeadingsMinLevel:2,newFileNameFormat:"",newFileTemplatePath:"",newPDFLocation:"current",newPDFFolderPath:"",rectEmbedStaticImage:!1,rectImageFormat:"file",rectImageExtension:"webp",zoomToFitRect:!1,rectFollowAdaptToTheme:!0,rectEmbedResolution:100,includeColorWhenCopyingRectLink:!0,backlinkIconSize:50,showBacklinkIconForSelection:!1,showBacklinkIconForAnnotation:!1,showBacklinkIconForOffset:!0,showBacklinkIconForRect:!1,showBoundingRectForBacklinkedAnnot:!1,hideReplyAnnotation:!1,hideStampAnnotation:!1,searchLinkHighlightAll:"true",searchLinkCaseSensitive:"true",searchLinkMatchDiacritics:"default",searchLinkEntireWord:"false",dontFitWidthWhenOpenPDFLink:!0,preserveCurrentLeftOffsetWhenOpenPDFLink:!1,defaultZoomValue:"page-width",scrollModeOnLoad:0,spreadModeOnLoad:0,usePageUpAndPageDown:!0,hoverableDropdownMenuInToolbar:!0,zoomLevelInputBoxInToolbar:!0,popoverPreviewOnExternalLinkHover:!0,actionOnCitationHover:"pdf-plus-bib-popover",anystylePath:"",enableBibInEmbed:!1,enableBibInHoverPopover:!1,enableBibInCanvas:!0,citationIdPatterns: ` ^ cite .
^ bib \ \ d + $ ` ,copyAsSingleLine:!0,removeWhitespaceBetweenCJChars:!0,dummyFileFolderPath:"",externalURIPatterns:[".* \\ .pdf $ ","https://arxiv.org/pdf/.*"],modifierToDropExternalPDFToCreateDummy:["Shift"],vim:!1,vimrcPath:"",vimVisualMotion:!0,vimScrollSize:40,vimLargerScrollSizeWhenZoomIn:!0,vimContinuousScrollSpeed:1.2,vimSmoothScroll:!0,vimHlsearch:!0,vimIncsearch:!0,enableVimInContextMenu:!0,enableVimOutlineMode:!0,vimSmoothOutlineMode:!0,vimHintChars:"hjklasdfgyuiopqwertnmzxcvb",vimHintArgs:"all",PATH:""};function dC(n){return Qn.hasOwnProperty(n)}var _n=Bt("Mod").toLowerCase(),Lu=class extends pe.PluginSettingTab{constructor(t){super(t.app,t);this.plugin=t;this.events=new pe.Events;this.component=new pe.Component,this.items={},this.headings=new Map,this.iconHeadings=new Map,this.headerEls=new Map,this.promises=[],this.containerEl.addClass("pdf-plus-settings"),this.headerContainerEl=this.containerEl.createDiv("header-container"),this.contentEl=this.containerEl.createDiv("content")}addSetting(t){let i=new pe.Setting(this.contentEl);return t&&(this.items[t]=i,this.component.registerDomEvent(i.settingEl,"contextmenu",r=>{r.preventDefault(),new zg.Menu().addItem(o=>{o.setTitle("Restore default value of this setting").setIcon("lucide-undo-2").onClick(async()=>{this.plugin.settings[t]=this.plugin.getDefaultSettings()[t],await this.plugin.saveSettings(),this.redisplay(),new pe.Notice( ` $ { this . plugin . manifest . name } : Default setting restored . Note that some options require a restart to take effect . ` ,6e3)})}).addItem(o=>{o.setTitle("Copy link to this setting").setIcon("lucide-link").onClick(()=>{navigator.clipboard.writeText( ` obsidian : //pdf-plus?setting=${t}`)})}).showAtMouseEvent(r)})),i}addHeading(t,i,r,o){let s=this.addSetting().setName(t).setHeading().then(a=>{if(r){let c=a.settingEl.parentElement;c&&c.insertBefore(createDiv("spacer"),a.settingEl);let l=createDiv();a.settingEl.prepend(l),(0,pe.setIcon)(l,r),a.settingEl.addClass("pdf-plus-setting-heading")}});return this.headings.set(i,s),this.component.registerDomEvent(s.settingEl,"contextmenu",a=>{a.preventDefault(),new zg.Menu().addItem(c=>{c.setTitle("Copy link to this heading").setIcon("lucide-link").onClick(()=>{navigator.clipboard.writeText(`obsidian://pdf-plus?setting=heading:${i}`)})}).showAtMouseEvent(a)}),r&&this.headerContainerEl.createDiv("clickable-icon header",a=>{let c=a.createDiv();(0,pe.setIcon)(c,r);let l=a.createDiv("header-title");l.setText(t),(0,pe.setTooltip)(a,t),this.component.registerDomEvent(a,"click",d=>{var h;((h=s.settingEl.previousElementSibling)!=null?h:s.settingEl).scrollIntoView({behavior:"smooth"}),this.updateHeaderElClassOnScroll(d)}),o==null||o({headerEl:a,iconEl:c,titleEl:l}),this.iconHeadings.set(i,s),this.headerEls.set(i,a)}),s}updateHeaderElClass(){var r,o,s;let t=this.containerEl.getBoundingClientRect().height,i=Array.from(this.iconHeadings.entries());for(let a=0;a<i.length;a++){let c=i[a][1].settingEl.getBoundingClientRect().top,l=(o=(r=i[a+1])==null?void 0:r[1].settingEl.getBoundingClientRect().top)!=null?o:this.contentEl.getBoundingClientRect().bottom,d=c<=t*.85&&l>=t*.2+this.headerContainerEl.clientHeight,h=i[a][0];(s=this.headerEls.get(h))==null||s.toggleClass("is-active",d)}}updateHeaderElClassOnScroll(t){var o;let i=(o=t==null?void 0:t.win)!=null?o:activeWindow,r=i.setInterval(()=>this.updateHeaderElClass(),50);i.setTimeout(()=>i.clearInterval(r),1500)}scrollTo(t,i){let r=this.items[t];r&&this.scrollToSetting(r,i)}scrollToHeading(t,i){let r=this.headings.get(t);r&&this.scrollToSetting(r,i)}scrollToSetting(t,i){let r=t.settingEl;r&&this.containerEl.scrollTo({top:r.offsetTop-this.headerContainerEl.offsetHeight,...i})}openFromObsidianUrl(t){let i=t.setting;i.startsWith("heading:")?this.plugin.openSettingTab().scrollToHeading(i.slice(8)):dC(i)&&this.plugin.openSettingTab().scrollTo(i)}getVisibilityToggler(t,i){let r=()=>{i()?t.settingEl.show():t.settingEl.hide()};return r(),r}showConditionally(t,i){let r=Array.isArray(t)?t:[t],o=r.map(s=>this.getVisibilityToggler(s,i));return this.events.on("update",()=>o.forEach(s=>s())),r}addTextSett
2025-02-18 05:37:27 -03:00
If you prefer PayPal , please make donations via Ko - fi . Thank you ! ` ).then(i=>{let r=i.infoEl,o=i.settingEl.firstElementChild;if(!o)return;let s=i.settingEl.createDiv();s.appendChild(o),s.appendChild(r),i.settingEl.prepend(s),i.settingEl.id="pdf-plus-funding",s.id="pdf-plus-funding-icon-info-container",o.id="pdf-plus-funding-icon",t(o)}).addButton(i=>{i.setButtonText("GitHub Sponsors").onClick(()=>{open("https://github.com/sponsors/RyotaUshio")})}).addButton(i=>{i.setButtonText("Buy Me a Coffee").onClick(()=>{open("https://www.buymeacoffee.com/ryotaushio")})}).addButton(i=>{i.setButtonText("Ko-fi").onClick(()=>{open("https://ko-fi.com/ryotaushio")})})}async renderMarkdown(t,i){this.promises.push(this._renderMarkdown(t,i)),i.addClass("markdown-rendered")}async _renderMarkdown(t,i){await pe.MarkdownRenderer.render(this.app,Array.isArray(t)?t.join( `
2025-03-07 06:22:58 -03:00
` ):t,i,"",this.component),i.childNodes.length===1&&i.firstChild instanceof HTMLParagraphElement&&i.replaceChildren(...i.firstChild.childNodes)}addColorSetting(t){let i=this.plugin.settings.colors,[r,o]=Object.entries(i)[t],s=this.plugin.settings.defaultColor===r,a=o;return this.addSetting().addText(c=>{c.setPlaceholder("Color name (case-insensitive)").then(l=>{l.inputEl.size=l.inputEl.placeholder.length,(0,pe.setTooltip)(l.inputEl,"Color name (case-insensitive)")}).setValue(r).onChange(async l=>{if(l in i){new pe.Notice("This color name is already used."),c.inputEl.addClass("error");return}c.inputEl.removeClass("error"),delete i[r];for(let d of["defaultColor","backlinkHoverColor"]){let h=this.items[d];if(h){let u=h.components[0].selectEl.querySelector( ` : scope > option : nth - child ( $ { t + 2 } ) ` );u&&(u.value=l,u.textContent=l)}}r=l,i[r]=o,s&&(this.plugin.settings.defaultColor=r),await this.plugin.saveSettings(),this.plugin.loadStyle()})}).addColorPicker(c=>{c.setValue(o),c.onChange(async l=>{a=o,o=l,i[r]=o,await this.plugin.saveSettings(),this.plugin.loadStyle()})}).addExtraButton(c=>{c.setIcon("rotate-ccw").setTooltip("Return to previous color").onClick(async()=>{o=a,i[r]=o,await this.plugin.saveSettings(),this.plugin.loadStyle(),this.redisplay()})}).addExtraButton(c=>{c.setIcon("trash").setTooltip("Delete").onClick(async()=>{this.plugin.settings.defaultColor===r&&(this.plugin.settings.defaultColor=""),delete i[r],await this.plugin.saveSettings(),this.plugin.loadStyle(),this.redisplay()})})}addNameValuePairListSetting(t,i,r,o,s){let{getName:a,setName:c,getValue:l,setValue:d}=o,h=t[i],u=a(h),p=l(h);return this.addSetting().addText(f=>{f.setPlaceholder(s.name.placeholder).then(m=>{m.inputEl.size=s.name.formSize,(0,pe.setTooltip)(m.inputEl,s.name.placeholder)}).setValue(u).onChange(async m=>{if(t.some(g=>a(g)===m)){new pe.Notice(s.name.duplicateMessage),f.inputEl.addClass("error");return}f.inputEl.removeClass("error"),c(h,m);let x=this.items[r];if(x){let g=x.components[0].selectEl.querySelector( ` : scope > option : nth - child ( $ { i + 1 } ) ` );g&&(g.value=m,g.textContent=m)}await this.plugin.saveSettings()})}).then(f=>{s.value.hasOwnProperty("formRows")?f.addTextArea(m=>{m.setPlaceholder(s.value.placeholder).then(x=>{x.inputEl.rows=s.value.formRows,x.inputEl.cols=s.value.formSize,(0,pe.setTooltip)(x.inputEl,s.value.placeholder)}).setValue(p).onChange(async x=>{d(h,x),await this.plugin.saveSettings()})}):f.addText(m=>{m.setPlaceholder(s.value.placeholder).then(x=>{x.inputEl.size=s.value.formSize,(0,pe.setTooltip)(x.inputEl,s.value.placeholder)}).setValue(p).onChange(async x=>{d(h,x),await this.plugin.saveSettings()})})}).addExtraButton(f=>{f.setIcon("trash").setTooltip("Delete").onClick(async()=>{if(t.length===1){new pe.Notice(s.delete.deleteLastMessage);return}t.splice(i,1),this.plugin.settings[r]>i?this.plugin.settings[r]--:this.plugin.settings[r]===i&&(this.plugin.settings[r]=0),await this.plugin.saveSettings(),this.redisplay()})}).setClass("no-border")}addNamedTemplatesSetting(t,i,r,o){return this.addNameValuePairListSetting(t,i,r,{getName:s=>s.name,setName:(s,a)=>{s.name=a},getValue:s=>s.template,setValue:(s,a)=>{s.template=a}},o)}addDisplayTextSetting(t){return this.addNamedTemplatesSetting(this.plugin.settings.displayTextFormats,t,"defaultDisplayTextFormatIndex",{name:{placeholder:"Format name",formSize:30,duplicateMessage:"This format name is already used."},value:{placeholder:"Display text format",formSize:50},delete:{deleteLastMessage:"You cannot delete the last display text format."}})}addCopyCommandSetting(t){return this.addNamedTemplatesSetting(this.plugin.settings.copyCommands,t,"defaultColorPaletteActionIndex",{name:{placeholder:"Format name",formSize:30,duplicateMessage:"This format name is already used."},value:{placeholder:"Copied text format",formSize:50,formRows:3},delete:{deleteLastMessage:"You cannot delete the last copy format."}})}addHotkeySettingButton(t,i){t.addButton(r=>{r.setButtonText("Open hotkeys settings").onClick(()=>{this.plugin.openHotkeySettingTab(i)})})}addPagePreviewSettingButton(t){return t.addButton(i=>{i
2025-02-18 05:37:27 -03:00
` )),this.component.registerDomEvent(d.inputEl,"focusout",async()=>{let h=d.inputEl.value;this.plugin.settings.externalURIPatterns=h.split( `
2025-03-07 06:22:58 -03:00
` ).map(u=>u.trim()).filter(u=>u),await this.plugin.saveSettings()})}),this.addHeading("Vim keybindings","vim","vim").then(d=>this.renderMarkdown("Tracked at [this GitHub issue](https://github.com/RyotaUshio/obsidian-pdf-plus/issues/119).",d.descEl)),this.addSetting().then(d=>{this.renderMarkdown(['The default keybindings are as follows. You can customize them be creating a "vimrc" file and providing its path in the setting below.',"","- ` j ` / ` k ` / ` h ` / ` l ` : Scroll down/up/left/right","- ` J ` : Go to next page","- ` K ` : Go to previous page","- ` gg ` : Go to first page","- ` G ` : Go to last page","- ` 0 ` / ` ^ ` / ` H ` : Go to top of current page","- ` $ ` / ` L ` : Go to bottom of current page","- ` < C - f > ` / ` < C - b > ` : Scroll down/up as much as the viewer height ( ` C ` = ` Ctrl ` )","- ` < C - d > ` / ` < C - u > ` : Scroll down/up half as much as the viewer height","- ` / ` / ` ? ` : Search forward/backward","- ` n ` / ` N ` : Go to next/previous match","- ` gn ` / ` gN ` : Select search result","- ` + ` / ` zi ` : Zoom in","- ` - ` / ` zo ` : Zoom out","- ` = ` / ` z0 ` : Reset zoom","- ` r ` : Rotate pages clockwise","- ` R ` : Rotate pages counterclockwise","- ` y ` : Yank (copy) selected text", ` - \ ` c \` : Run the " ${ this . plugin . lib . commands . stripCommandNamePrefix ( this . plugin . lib . commands . getCommand ( "copy-link-to-selection" ) . name ) } " command ` , "- `C`: Show context menu at text selection" , "- `o`: Swap the start and end of the selection" , "- `:`: Enter command-line mode (experimental)" , "- `<Tab>`: Toggle outline (table of contents)" , "- `<S-Tab>`: Toggle thumbnails (`S`=`Shift`)" , "- `f`: Enter hint mode by running `:hint` (experimental)" , "- `<Esc>`: Go back to normal mode, abort search, etc" , "" , "Many of the commands above can be combined with counts. For example:" , "- `2j` scrolls down the page twice as much as `j`." , "- `2J` advances two pages." , "- `10G` takes you to page 10." , "- `150=` sets the zoom level to 150%." ] , d . descEl ) } ) , this . addToggleSetting ( "vim" , ( ) => this . events . trigger ( "update" ) ) . setName ( "Enable" ) . setDesc ( "Reopen the PDF viewers after changing this option." ) , this . showConditionally ( [ this . addTextSetting ( "vimrcPath" , void 0 , ( ) => this . plugin . vimrc = null ) . setName ( "Vimrc file path (optional)" ) . then ( async d => { await this . renderMarkdown ( [ "Only the [Ex commands supported by PDF++](https://github.com/RyotaUshio/obsidian-pdf-plus/blob/main/src/vim/ex-commands.ts) are allowed." , "" , "Example (not necessarily recommendations):" , "```" , '" Use j/k, instead of J/K, to go to the next page' , "map j J" , "map k K" , "" , '" JavaScript commands' , '" - Hit Ctrl-h in Normal mode to show a message' , 'nmap <C-h> :js alert("Hello, world!")' , '" - Hit Ctrl-h in Visual mode to run a .js file' , "vmap <C-h> :jsfile filename.js" , "" , '" Obsidian commands' , '" - Open the current PDF in the OS-default app by hitting d, e, and then f' , "map def :obcommand open-with-default-app:open" , '" - Go back and forth the history with Ctrl-o and Ctrl-i' , "map <C-o> :obcommand app:go-back" , "map <C-i> :obcommand app:go-forward" , "```" , "" , "After changing the path or the file content, you need to reopen the PDF viewer. If the vimrc file is a hidden file or is under a hidden folder, you need to reload PDF++ or the app." ] , d . descEl ) ; let h = d . components [ 0 ] . inputEl ; new Oc ( this . app , h ) . onSelect ( ( { item : u } ) => { this . plugin . settings . vimrcPath = u . path , this . plugin . saveSettings ( ) } ) } ) , this . addHeading ( "Visual mode" , "vim-visual" ) , this . addToggleSetting ( "vimVisualMotion" ) . setName ( "Enter visual mode on text selection" ) . then ( d => { this . renderMarkdown ( [ "When some text is selected, you can modify the range of selection using the `j,` `k`, `h`, `l`, `w`, `e`, `b`, `0`, `^`, `$`, `H`, and `L` keys, similarly to Vim's visual mode (`H`/`L` are mapped to `^`/`$` by default). If disabled, you can use `j`/`k`/`h`/`l`/`0`/`^`/`$`/`H`/`L` keys to scroll the page regardless of text selection. Reload the viewer or the app after changing this option." , "" , "Tips:" , "- You can use `o` to swap the start and end of the selection." , "- As you know, `/` and `?` keys initiate search. Pressing `gn`/`gN` after the search will select the search result. You can also use search to extend the current selection to the search result." , "" , " Note : On
2025-02-18 05:37:27 -03:00
: hint [ < target1 > < target2 > ... ] - Enter hint mode and show hint marks for the specified targets in the current page . Inspired by [ Tridactyl ] ( https : //github.com/tridactyl/tridactyl)'s hint mode.
If no target is specified , the default targets ( configured in PDF ++ settings ) will be used .
The accepted targets are :
- \ ` all \` : all of the followings
- \ ` link \` : internal & external links
- \ ` annot \` : (non-link) annotations written in the file
- \ ` backlink \` : backlink highlighting, i.e., highlights that is not written in the file itself
2025-03-07 06:22:58 -03:00
` ,func:(...e)=>{e.length===0&&(e=n.settings.vimHintArgs.trim().split(/ \s +/)),e.includes("all")&&(e=["link","annot","backlink"]),n.hintMode.setTarget(...e.map(t=>{switch(t){case"link":return 0;case"annot":return 1;case"backlink":return 2;default:throw Error( ` Unknown hint target : $ { t } ` )}})),setTimeout(()=>n.enterHintMode())}}],xC=(n,e=12,t=!0)=>(n=n.replace(new RegExp( ` ^ { $ { e } } ` ,"gm"),"").replace(/^ \s */,""),t?n.replace(/([<>])/g," \\ $ 1"):n),Zr=(n,e,t=!1)=> ` : $ { n } < from > < to > - Map < from > to < to > $ { t ? "non-recusively " : "" } in $ { e . length > 1 ? e . slice ( 0 , - 1 ) . join ( ", " ) + " and " + e . at ( - 1 ) + " modes" : e [ 0 ] + " mode" } . If < to > is an ex - command , it must be start with ":" . ` ;var Xu=class extends gn{constructor(t){super(t);this.history=[];this.historyIndex=0;this.isActive=!1;this.dom=this.vim.viewer.containerEl.createDiv("pdf-plus-vim-command",i=>{this.register(()=>i.remove()),i.appendText(":"),this.inputEl=i.createEl("input",{cls:"pdf-plus-vim-command-input"},r=>{r.placeholder="type a command or page number...",r.addEventListener("focusout",()=>{setTimeout(()=>{this.isActive&&this.vim.enterNormalMode()})}),r.addEventListener("keydown",o=>{if(!o.isComposing&&o.key==="Enter"){this.submitCommand();return}if(o.key==="Escape"||o.key==="Backspace"&&!r.value){this.vim.enterNormalMode(),o.preventDefault();return}if(o.key==="ArrowUp"||o.key==="ArrowDown"){o.preventDefault(),this.navigateHistory(o.key==="ArrowDown");return}})}),i.hide()}),this.vimScope.registerKeymaps(["command"],{"<C-u>":()=>this.inputEl.value="","<C-w>":()=>this.inputEl.value=this.inputEl.value.replace(/ \S + \s * $ /,"")}),this.excmds=Jw(this.vim),this.suggest=new Jg(this).onSelect(({item:{minNargs:i}})=>setTimeout(()=>{if(!i){this.submitCommand();return}this.inputEl.value+=" "})),this.settings.vimrcPath&&this.viewer.then(i=>{let r=i.pdfViewer.eventBus;r&&r.on("pagesloaded",()=>setTimeout(()=>{if(this.plugin.vimrc===null){let o=(0,es.normalizePath)(this.settings.vimrcPath);this.app.vault.adapter.read(o).then(s=>this.runScript(this.plugin.vimrc=s))}else this.runScript(this.plugin.vimrc)},{once:!0}))})}async executeCommand(t,i={error:["notice","console.error"],history:!0}){if(i={error:[],history:!0,...i},i.history&&(this.history.push(t),this.history.length>100&&this.history.shift(),this.historyIndex=this.history.length),t.startsWith("!")){if(!es.Platform.isDesktopApp){this.reportError( ` $ { this . plugin . manifest . name } ( Vim mode ) : Shell command is not supported on mobile ` ,i.error);return}let{exec:a}=require("child_process"),c=process.env;return this.settings.PATH&&(c.PATH=this.settings.PATH),new Promise((l,d)=>a(t.slice(1),{env:c},(h,u,p)=>{h&&d(h),u&&(alert(u),l(u)),p&&console.warn(p)}))}if(/^[1-9] \d * $ /.test(t)){let a=+t;this.pdfViewer&&(this.pdfViewer.currentPageNumber=a);return}let[r,...o]=t.split(/ \s +/),s=this.findCommand(r);if(s){if(s.minNargs&&o.length<s.minNargs){this.reportError( ` $ { this . plugin . manifest . name } ( Vim mode ) : Expected $ { s . minNargs } or more arguments for command "${s.id}" but got $ { o . length } ` ,i.error);return}return s.func(...o)}this.reportError( ` $ { this . plugin . manifest . name } ( Vim mode ) : Unknown command "${t}" ` ,i.error)}findCommand(t){return this.excmds.find(i=>i.pattern&&i.pattern.test(t)||i.id===t)}submitCommand(){let t=this.inputEl.value.trim();if(t){this.history[this.historyIndex]===t&&this.history.splice(this.historyIndex,1);try{this.executeCommand(t)}catch(r){new es.Notice( ` $ { this . plugin . manifest . name } ( Vim mode ) : Error occurred while executing the command : $ { r } ` ),console.error(r)}}this.vim.enterNormalMode()}runScript(t){this.parseScript(t).forEach(r=>this.executeCommand(r,{error:["console.warn"],history:!1}))}parseScript(t){return t.split(/ \r ? \n /).filter(i=>i.trim()&&!i.trimStart().startsWith('"')).join( `
2025-02-18 05:37:27 -03:00
` ).replace(/ \\ \n /g,"").split( `
2025-03-07 06:22:58 -03:00
` )}enter(){this.inputEl.value="",this.dom.show(),this.inputEl.focus(),this.isActive=!0}exit(){this.isActive=!1,this.inputEl.value="",this.dom.hide()}navigateHistory(t){let i=this.inputEl;if(this.historyIndex<this.history.length||!i.value){let r=this.historyIndex+(t?1:-1);if(r<0)return;r<=this.history.length&&(this.historyIndex=r);let o=this.history[r]||"";i.value=o,i.setSelectionRange(o.length,o.length)}}reportError(t,i){for(let r of i)r==="notice"?new es.Notice(t):r==="console.error"?console.error(t):r==="console.warn"&&console.warn(t)}},Jg=class extends Mr{constructor(e){super(e.app,e.inputEl,{blurOnSelect:!1}),this.commandLineMode=e;let t=this.scope.keys.find(o=>o.key==="Escape"&&o.modifiers==="");t&&this.scope.unregister(t);let i=this.scope.keys.find(o=>o.key==="ArrowDown"&&o.modifiers===""),r=this.scope.keys.find(o=>o.key==="ArrowUp"&&o.modifiers==="");i&&(this.scope.unregister(i),this.scope.register([],"Tab",i.func)),r&&(this.scope.unregister(r),this.scope.register(["Shift"],"Tab",r.func))}getItems(){return this.commandLineMode.excmds}getItemText(e){return e.id}};var Zu=class extends Fe{constructor(t,i,r){super(t);this.pages=new Map;this.pdfViewer=i,this.file=r}onload(){this.registerEvent(this.app.vault.on("modify",t=>{t===this.file&&this.pages.clear()}))}getPageParser(t){let i=this.pages.get(t);if(!i){let r=this.pdfViewer.getPageView(t-1);if(r){let o=r.textLayer,s=o&&wt(o);if(s){let{textContentItems:a,textDivs:c}=s;i=new _g(r,a,c),this.pages.set(t,i)}}}return i}},_g=class{constructor(e,t,i){this.lineStartIndices=null;this.pageView=e,this.items=t,this.divs=i}getBoundIndicesOfLine(e,t){var a;let i=this._getIndexWithinLineStartIndicesForLineContainingItem(e),r=(a=this.lineStartIndices[i+t])!=null?a:null;if(r===null)return null;let o=this.lineStartIndices[i+1+t],s=o===void 0?this.items.length-1:o-1;for(;s>r&&!this.items[s].str.length;)s--;return{start:r,end:s}}getLineShiftPosition(e,t){let i=this.getBoundIndicesOfLine(e.index,t);if(!i)return null;let r=this._getHorizontalRangeOfChar(e);if(!r)return null;let{start:o,end:s}=i,a=o;for(;a<=s;a++){let d=this.items[a],h=this._getHorizontalRangeOfItem(d);if(Pg(r,h))break}for(a>s&&(a=s);a>o&&!this.items[a].str.length;)a--;let c=this.items[a],l=0;for(;;){let d=this._getHorizontalRangeOfChar({index:a,offset:l});if(!d)return null;if(d.from>=r.from||d.to>=r.to)return{index:a,offset:l};if(l+1<c.str.length)l++;else return{index:a,offset:c.str.length-1}}}_getIndexWithinLineStartIndicesForLineContainingItem(e){this.lineStartIndices||this.parse();let{found:t,index:i}=hn(this.lineStartIndices,r=>e-r);return t?i:i-1}parse(){let e=this._findIndexOfFirstNonEmptyItem();if(e===-1){this.lineStartIndices=[0];return}this.lineStartIndices=[e];let t=[this.items[e]];for(let i=e+1;i<this.items.length;i++){let r=this.items[i];if(this.isItemNonEmpty(r)){let o=this._getVerticalRangeOfItem(r),s=this._getMergedRangeOfItems(t.slice(-10));t.push(r),s&&!kg(o,s)&&this.lineStartIndices.push(i)}}}_findIndexOfFirstNonEmptyItem(){return this.items.findIndex(e=>this.isItemNonEmpty(e))}isItemNonEmpty(e){let t=this._getVerticalRangeOfItem(e);return t.from<t.to}_getVerticalRangeOfItem(e){return{from:e.transform[5],to:e.transform[5]+e.height}}_getMergedRangeOfItems(e,t="vertical"){if(e.length===0)return null;let i=e.map(t==="vertical"?this._getVerticalRangeOfItem.bind(this):this._getHorizontalRangeOfItem.bind(this)),r=Math.min(...i.map(s=>s.from)),o=Math.max(...i.map(s=>s.to));return{from:r,to:o}}_getHorizontalRangeOfItem(e){return{from:e.transform[4],to:e.transform[4]+e.width}}_getHorizontalRangeOfChar(e){let t=e.index,i=e.offset,r=this.items[t];if(r.chars&&r.chars.length>=r.str.length){let p=r.chars[i];return{from:p.r[0],to:p.r[2]}}let o=this.divs[t],s=Kn(o,i);if(!s)return null;let{node:a,offset:c}=s,l=o.doc.createRange();l.setStart(a,c),l.setEnd(a,c+1);let d=l.getBoundingClientRect(),[[h],[u]]=[...mu(this.pageView,[{x:d.left,y:d.bottom},{x:d.right,y:d.top}])];return{from:h,to:u}}};var Yu=class n extends Fe{constructor(t,i){super(t);this._structureParser=null;this.viewer=i,this.vimScope=new Hu(this.viewer.scope)
2025-02-18 05:37:27 -03:00
$ { i . map ( l => "- " + l . path ) . join ( `
` )}
2025-03-07 06:22:58 -03:00
Aborting . ` ;throw Error(c)}return(a=i.first())!=null?a:null}findLinkedFile(e){let t=null,i=this.lib.workspace.getActiveGroupLeaves();if(i){for(let r of i)if(r.view instanceof ts.FileView&&r.view.file&&r.view.file!==e){t=r.view.file;break}}return t}};var _u=class extends Ae{constructor(){super(...arguments);this.statusDurationMs=2e3}getPageAndTextRangeFromSelection(t){if(t=t!=null?t:activeWindow.getSelection(),!t)return null;let i=this.lib.getPageElFromSelection(t);if(!i||i.dataset.pageNumber===void 0)return null;let r=+i.dataset.pageNumber,o=t.rangeCount>0?t.getRangeAt(0):null;if(o){let s=this.getTextSelectionRange(i,o);if(s)return{page:r,selection:s}}return{page:r}}getTextSelectionRange(t,i){if(i&&!i.collapsed){let r=pu(t,i.startContainer),o=pu(t,i.endContainer);if(r&&o){let s=r.dataset.idx,a=o.dataset.idx,c=gu(r,i.startContainer,i.startOffset),l=gu(o,i.endContainer,i.endOffset);if(s!==void 0&&a!==void 0&&c!==null&&l!==null)return{beginIndex:+s-this.plugin.textDivFirstIdx,beginOffset:c,endIndex:+a-this.plugin.textDivFirstIdx,endOffset:l}}}return null}getTemplateVariables(t){var d,h,u;let i=activeWindow.getSelection();if(!i)return null;let r=this.lib.getPageElFromSelection(i);if(!r||r.dataset.pageNumber===void 0)return null;let o=this.lib.getPDFViewerChildAssociatedWithNode(r),s=o==null?void 0:o.file;if(!s)return null;let a=+r.dataset.pageNumber;i.toString()||(a=(h=(d=o.pdfViewer.pdfViewer)==null?void 0:d.currentPageNumber)!=null?h:a);let c=o.getTextSelectionRangeStr(r);if(!c)return null;let l=qc({page:a,selection:c,...t});return{child:o,file:s,subpath:l,page:a,pageCount:o.pdfViewer.pagesCount,pageLabel:(u=o.getPage(a).pageLabel)!=null?u:""+a,text:this.lib.toSingleLine(i.toString())}}getLinkTemplateVariables(t,i,r,o,s,a,c,l){l=l!=null?l:"";let d=this.app.fileManager.generateMarkdownLink(r,l,o).slice(1),h=this.app.metadataCache.fileToLinktext(r,l)+o;this.app.vault.getConfig("useMarkdownLinks")&&(h=Rr(h));let u=this.getDisplayText(t,i,r,s,a,c),p=this.lib.generateMarkdownLink(r,l,o,u||void 0).slice(1),f=this.app.fileManager.generateMarkdownLink(r,l, ` # page = $ { s } ` ).slice(1),m=this.lib.generateMarkdownLink(r,l, ` # page = $ { s } ` ,u||void 0).slice(1);return{link:d,linktext:h,display:u,linkWithDisplay:p,linkToPage:f,linkToPageWithDisplay:m}}getDisplayText(t,i,r,o,s,a){var c;if(!i){let l=this.lib.getColorPaletteFromChild(t);l?i=this.settings.displayTextFormats[l.displayTextFormatIndex].template:i=this.settings.displayTextFormats[this.settings.defaultDisplayTextFormatIndex].template}try{return new nd(this.plugin,{file:r,page:o,pageCount:t.pdfViewer.pagesCount,pageLabel:(c=t.getPage(o).pageLabel)!=null?c:""+o,text:s,comment:a!=null?a:""}).evalTemplate(i).trim()}catch(l){console.error(l),new Wi.Notice( ` $ { this . plugin . manifest . name } : Display text format is invalid . Error : $ { l . message } ` ,3e3)}}getTextToCopy(t,i,r,o,s,a,c,l,d,h){var m,x,g,b,v,y;let u=t.getPage(s);if(typeof h!="string"){let F=fa(a).get("annotation");h=typeof F=="string"&&((v=(b=(g=(x=(m=u==null?void 0:u.annotationLayer)==null?void 0:m.annotationLayer)==null?void 0:x.getAnnotation(F))==null?void 0:g.data)==null?void 0:b.contentsObj)==null?void 0:v.str),h=this.lib.toSingleLine(h||"")}return new nd(this.plugin,{file:o,page:s,pageLabel:(y=u.pageLabel)!=null?y:""+s,pageCount:t.pdfViewer.pagesCount,text:c,comment:h,colorName:l,calloutType:this.settings.calloutType,...this.lib.copyLink.getLinkTemplateVariables(t,r,o,a,s,c,h,d)}).evalTemplate(i)}async getTextToCopyForOutlineItem(t,i,r,o){return(await this.getTextToCopyForOutlineItemDynamic(t,i,r))(o)}async getTextToCopyForOutlineItemDynamic(t,i,r){let o=await r.getExplicitDestination(),s=await r.getPageNumber(),a=this.lib.normalizePDFJsDestArray(o,s),c=this.lib.destArrayToSubpath(a);return l=>this.getTextToCopy(t,this.settings.outlineLinkCopyFormat,this.settings.outlineLinkDisplayTextFormat,i,s,c,r.item.title,"",l)}getSelectionLinkInfo(){var s;let t=this.lib.getColorPaletteAssociatedWithSelection();if(!t)return null;let i=this.settings.copyCommands[t.actionIndex].template,r=(s=t.selectedColorName)!=null?s:void 0,o=t.writeFile;return{temp
2025-02-18 05:37:27 -03:00
2025-03-07 06:22:58 -03:00
` +p.slice(1),await navigator.clipboard.writeText(f);let y=async()=>{(i.containerEl.win!==window||m.destroyed)&&(m=await(await this.lib.loadPDFDocument(l)).getPage(r));let F=await this.lib.pdfPageToImageArrayBuffer(m,{type: ` image / $ { x } ` ,cropRect:o,renderParams:this.lib.getOptionalRenderParameters()});return await this.app.vault.createBinary(g,F)};a?(await y(),this.onCopyFinish(f)):this.onCopyFinish(f,y)}else f= ` ! [ ] ( $ { await this . lib . pdfPageToImageDataUrl ( m , { type : ` image/ ${ x } ` , cropRect : o } ) } ) ` + `
2025-02-18 05:37:27 -03:00
2025-03-07 06:22:58 -03:00
` +p.slice(1),await navigator.clipboard.writeText(f),this.onCopyFinish(f);this.plugin.lastCopiedDestInfo={file:l,destArray:[r-1,"FitR",...o]},d==null||d.setStatus("Link copied",this.statusDurationMs),await this.autoFocusOrAutoPaste(f,a,d!=null?d:void 0)})()}return!0}copyLinkToSearch(t,i,r,o,s,a){if(!i.file)return!1;let c=i.file,l=this.lib.getColorPaletteFromChild(i);if(!t){let d=this.lib.copyLink.getDisplayText(i,void 0,c,r,o),h=this.lib.generateMarkdownLink(c,"", ` # search = $ { o } ` ,d).slice(1);(async()=>(await navigator.clipboard.writeText(h),this.onCopyFinish(h),l==null||l.setStatus("Link copied",this.statusDurationMs),await this.autoFocusOrAutoPaste(h,s,l!=null?l:void 0)))()}return!0}makeCanvasTextNodeFromSelection(t,i,r,o){var a;let s=this.getTemplateVariables(o?{color:o.toLowerCase()}:{});if(s){let{child:c,file:l,subpath:d,page:h,text:u}=s;if(!u)return!1;if(!t){let p=this.getTextToCopy(c,r,void 0,l,h,d,u,(a=o==null?void 0:o.toLowerCase())!=null?a:"");i.createTextNode({pos:i.posCenter(),position:"center",text:p})}return!0}return!1}makeCanvasTextNodeFromAnnotation(t,i,r,o,s,a){let c=r.file;if(!c)return!1;if(!t){let l=r.getPage(s);r.getAnnotatedText(l,a).then(d=>{let h=this.getTextToCopy(r,o,void 0,c,s, ` # page = $ { s } & annotation = $ { a } ` ,d!=null?d:"","");i.createTextNode({pos:i.posCenter(),position:"center",text:h})})}return!0}async autoPaste(t){let i=this.getAutoFocusOrAutoPasteTarget(this.settings.autoPasteTarget);if(i)return await this.pasteTextToFile(t,i),!0;if(!this.settings.executeCommandWhenTargetNotIdentified)return!1;let r=this.app.commands.findCommand(this.settings.commandToExecuteWhenTargetNotIdentified);if(!r)return new Wi.Notice( ` $ { this . plugin . manifest . name } : Command "${this.settings.commandToExecuteWhenTargetNotIdentified}" was not found . Please update the "Command to execute when pasting a link for the first time with auto-focus or auto-paste" setting . ` ),!1;let o=!1;return new Promise(s=>{let a=this.app.workspace.on("file-open",async l=>{l&&l.extension==="md"&&(this.app.workspace.offref(a),await this.pasteTextToFile(t,l,!0),this.plugin.lastPasteFile=l,s(!0))}),c=this.lib.workspace.hoverEditor;this.plugin.registerOneTimeEvent(this.app.workspace,"active-leaf-change",l=>{l&&c.isHoverEditorLeaf(l)&&c.postProcessHoverEditorLeaf(l)}),this.app.commands.executeCommandById(r.id),activeWindow.setTimeout(()=>{if(!o){let{noticeEl:l}=new Wi.Notice( ` $ { this . plugin . manifest . name } : Could not find the auto - paste target markdown file within $ { this . settings . autoPasteTargetDialogTimeoutSec } seconds . ` );l.appendText(" Click "),l.createEl("a",{text:"here"},d=>{d.addEventListener("click",()=>{this.plugin.openSettingTab().scrollTo("autoPasteTargetDialogTimeoutSec")})}),l.appendText(" to change the timeout duration."),this.app.workspace.offref(a),s(!1)}},this.settings.autoPasteTargetDialogTimeoutSec*1e3)}).then(s=>(o=!0,s))}async autoFocus(){let t=this.getAutoFocusOrAutoPasteTarget(this.settings.autoFocusTarget);if(t){let{leaf:o,isExistingLeaf:s}=await this.prepareMarkdownLeafForPaste(t);return o&&o.view instanceof Wi.MarkdownView&&await this.updateAndRevealCursorInEditor(o.view,{focus:!0,goEnd:!s}),!0}if(!this.settings.executeCommandWhenTargetNotIdentified)return!1;let i=this.app.commands.findCommand(this.settings.commandToExecuteWhenTargetNotIdentified);if(!i)return new Wi.Notice( ` $ { this . plugin . manifest . name } : Command "${this.settings.commandToExecuteWhenTargetNotIdentified}" was not found . Please update the "Command to execute when pasting a link for the first time with auto-focus or auto-paste" setting . ` ),!1;let r=this.lib.workspace.hoverEditor;return this.plugin.registerOneTimeEvent(this.app.workspace,"active-leaf-change",o=>{o&&r.isHoverEditorLeaf(o)&&r.postProcessHoverEditorLeaf(o)}),this.app.commands.executeCommandById(i.id)}getAutoFocusOrAutoPasteTarget(t){let i=this.plugin.lastActiveMarkdownFile,r=this.plugin.lastPasteFile,o=!!(i&&this.lib.workspace.isMarkdownFileOpened(i)),s=null;return t==="last-paste"?s=r:t==="last-active"?s=i:t==="last-active-and-open"?o&&(s=i):t==="last-paste-then-last-active"?s=r!=null?r:i:t==="last-paste-then
2025-02-18 05:37:27 -03:00
` : `
` ),l+=t,c.setValue(l)}a.save(),await this.updateAndRevealCursorInEditor(o.view,{focus:this.settings.focusEditorAfterAutoPaste,goEnd:!this.settings.respectCursorPositionWhenAutoPaste})}else await this.app.vault.process(i,a=>(a=a.trimEnd(),a&&(a+=this.settings.blankLineAboveAppendedContent? `
` : `
2025-03-07 06:22:58 -03:00
` ),a+=t,a)),o&&activeWindow.setTimeout(async()=>{o.view instanceof Wi.MarkdownView&&await this.updateAndRevealCursorInEditor(o.view,{focus:this.settings.focusEditorAfterAutoPaste,goEnd:!0})})}async updateAndRevealCursorInEditor(t,i){let{focus:r,goEnd:o}=i,s=t.editor;r&&(o&&s.exec("goEnd"),await this.lib.workspace.revealLeaf(t.leaf),this.app.workspace.setActiveLeaf(t.leaf),s.focus());let a=s.coordsAtPos(s.getCursor(),!0);if(a){let c=s.getScrollInfo();if(a.top<c.top||a.top>c.top+c.clientHeight){let l={from:s.getCursor("from"),to:s.getCursor("to")};s.scrollIntoView(l,!0)}}}watchPaste(t,i){this.plugin.registerOneTimeEvent(this.app.workspace,"editor-paste",(r,o,s)=>{var d;if(((d=s.file)==null?void 0:d.extension)!=="md"||!r.clipboardData)return;let c=r.clipboardData.getData("text/plain").replace(/ \r \n /g, `
2025-02-18 05:37:27 -03:00
` ),l=t.replace(/ \r \n /g, `
2025-03-07 06:22:58 -03:00
` );c===l&&(this.plugin.lastPasteFile=s.file,i==null||i()),s instanceof Wi.MarkdownView&&setTimeout(()=>s.save())})}onCopyFinish(t,i){this.watchPaste(t,i),this.plugin.lastCopiedDestInfo=null}async autoFocusOrAutoPaste(t,i,r){if(i||this.settings.autoPaste)if(await this.autoPaste(t)){if(r==null||r.setStatus("Link copied & pasted",this.statusDurationMs),!this.settings.focusEditorAfterAutoPaste&&this.settings.clearSelectionAfterAutoPaste){let s=activeWindow.getSelection();s&&this.lib.copyLink.getPageAndTextRangeFromSelection(s)&&s.empty()}}else r==null||r.setStatus("Link copied but paste target not identified",this.statusDurationMs);else this.settings.autoFocus&&(await this.autoFocus()||r==null||r.setStatus("Link copied but paste target not identified",this.statusDurationMs))}};var Qu=class extends Ae{computeMergedHighlightRects(e,t,i,r,o){let{textContentItems:s,textDivs:a}=e,c=[],l=null,d=[];o===0&&(r--,o=s[r].str.length);for(let h=t;h<=r;h++){let u=s[h],p=a[h];if(!u.str)continue;let f=this.computeHighlightRectForItem(u,p,h,t,i,r,o);f&&(l?this.areRectanglesMergeable(l,f)?(l=this.mergeRectangles(l,f),d.push(h)):(c.push({rect:l,indices:d}),l=f,d=[h]):(l=f,d=[h]))}return l&&c.push({rect:l,indices:d}),c}computeHighlightRectForItem(e,t,i,r,o,s,a){return e.chars&&e.chars.length>=e.str.length?this.computeHighlightRectForItemFromChars(e,i,r,o,s,a):this.computeHighlightRectForItemFromTextLayer(e,t,i,r,o,s,a)}computeHighlightRectForItemFromChars(e,t,i,r,o,s){let a=e.chars.slice(e.chars.findIndex(u=>u.c===e.str.charAt(0)),e.chars.findLastIndex(u=>u.c===e.str.charAt(e.str.length-1))+1),c=t===i?r:0,l=(t===o?Math.min(s,a.length):a.length)-1;if(c>a.length-1||l<0)return null;let d=a[c],h=a[l];return[Math.min(d.r[0],h.r[0]),Math.min(d.r[1],h.r[1]),Math.max(d.r[2],h.r[2]),Math.max(d.r[3],h.r[3])]}computeHighlightRectForItemFromTextLayer(e,t,i,r,o,s,a){let c=e.transform[4],l=e.transform[5],d=e.transform[4]+e.width,h=e.transform[5]+e.height,u=t.doc.createRange();if(i===r){let m=Kn(t,o);m?u.setStart(m.node,m.offset):u.setStartBefore(t)}else u.setStartBefore(t);if(i===s){let m=Kn(t,a);m?u.setEnd(m.node,m.offset):u.setEndAfter(t)}else u.setEndAfter(t);let p=u.getBoundingClientRect(),f=t.getBoundingClientRect();return[c+(p.left-f.left)/f.width*e.width,l+(p.bottom-f.bottom)/f.height*e.height,d-(f.right-p.right)/f.width*e.width,h-(f.top-p.top)/f.height*e.height]}areRectanglesMergeable(e,t){return this.areRectanglesMergeableHorizontally(e,t)||this.areRectanglesMergeableVertically(e,t)}areRectanglesMergeableHorizontally(e,t){let[i,r,o,s]=e,[a,c,l,d]=t,h=(r+s)/2,u=(c+d)/2,p=Math.abs(s-r),f=Math.abs(d-c),m=Math.max(p,f)*.5;return Math.abs(h-u)<m}areRectanglesMergeableVertically(e,t){let[i,r,o,s]=e,[a,c,l,d]=t,h=Math.abs(o-i),u=Math.abs(l-a),p=Math.abs(s-r),f=Math.abs(d-c),m=Math.max(h,u)*.1;return Math.abs(i-a)<m&&Math.abs(o-l)<m&&p/h>.85&&f/u>.85}mergeRectangles(...e){let t=e.map(s=>s[0]),i=e.map(s=>s[1]),r=e.map(s=>s[2]),o=e.map(s=>s[3]);return[Math.min(...t),Math.min(...i),Math.max(...r),Math.max(...o)]}rectsToQuadPoints(e){return e.flatMap(([t,i,r,o])=>[t,o,r,o,t,i,r,i])}};var $ u=require("obsidian");var e0=class extends Ae{getPDFPlusBacklinkHighlightLayer(e){var i;let t=e.div;return(i=t.querySelector("div.pdf-plus-backlink-highlight-layer"))!=null?i:t.createDiv("pdf-plus-backlink-highlight-layer",r=>{window.pdfjsLib.setLayerDimensions(r,e.viewport)})}placeRectInPage(e,t){let i=t.pdfPage.view,r=i[0],o=i[1],s=i[2]-i[0],a=i[3]-i[1],c=window.pdfjsLib.Util.normalizeRect([e[0],i[3]-e[1]+i[1],e[2],i[3]-e[3]+i[1]]),d=this.getPDFPlusBacklinkHighlightLayer(t).createDiv("pdf-plus-backlink");return d.setCssStyles({left: ` $ { 100 * ( c [ 0 ] - r ) / s } % ` ,top: ` $ { 100 * ( c [ 1 ] - o ) / a } % ` ,width: ` $ { 100 * ( c [ 2 ] - c [ 0 ] ) / s } % ` ,height: ` $ { 100 * ( c [ 3 ] - c [ 1 ] ) / a } % ` }),d}highlightSubpath(e,t){var i,r,o;if(((i=e.subpathHighlight)==null?void 0:i.type)==="text"){let s=new $ u.Component;s.load(),this.lib.onTextLayerReady(e.pdfViewer,s,a=>{var d;if(((d=e.subpathHighlight)==null?void 0:d.type)!=="text")return;let{page:c,range:l}=e.subpathHighlight;c===a&&(e.highlightText(c,l),t>0&&setTimeout(()=>{e.clearTextHig
` );return a=this.lib.toSingleLine(a),[s.id,{text:a,rgb:s.rgb,comment:s.comment}]}))}getTextByRect(e,t){let[i,r,o,s]=t,a="",c={index:-1,offset:-1},l={index:-1,offset:-1};for(let d=0;d<e.length;d++){let h=e[d];if(h.chars&&h.chars.length)for(let u=0;u<h.chars.length;u++){let p=h.chars[u],f=(p.r[0]+p.r[2])/2,m=(p.r[1]+p.r[3])/2;i<=f&&f<=o&&r<=m&&m<=s&&(a+=p.u,c.index===-1&&c.offset===-1&&(c={index:d,offset:u}),l={index:d,offset:u+1})}}return{text:a,from:c,to:l}}};var r0=class extends Ae{constructor(t){super(t);this.plugin=t;this.geometry=new Qu(t),this.viewer=new e0(t),this.writeFile=new i0(t),this.extract=new n0(t)}};var Je=require("obsidian");function CC(n){return["tab","split","window"].contains(n)}function SC(n){return["right","left","down","up"].contains(n)}function d1(n){return["right-sidebar","left-sidebar"].contains(n)}var o0=class extends Ae{constructor(...e){super(...e),this.hoverEditor=new $ g(...e)}iteratePDFViews(e){this.app.workspace.iterateAllLeaves(t=>{let i=t.view;this.lib.isPDFView(i)&&e(i)})}iterateBacklinkViews(e){this.app.workspace.getLeavesOfType("backlink").forEach(t=>e(t.view))}iterateCanvasViews(e){this.app.workspace.iterateAllLeaves(t=>{let i=t.view;this.lib.isCanvasView(i)&&e(i)})}iteratePDFEmbeds(e){this.app.workspace.iterateAllLeaves(t=>{let i=t.view;i instanceof Je.MarkdownView?this.lib.getAllPDFEmbedsInMarkdownView(i).forEach(e):this.lib.isCanvasView(i)&&this.lib.getAllPDFEmbedsInCanvasView(i).forEach(e)})}iteratePDFViewerComponents(e){this.app.workspace.iterateAllLeaves(t=>{let i=t.view;this.lib.isPDFView(i)?e(i.viewer,i.file):i instanceof Je.MarkdownView?this.lib.getAllPDFEmbedsInMarkdownView(i).forEach(r=>e(r.viewer,r.file)):this.lib.isCanvasView(i)&&this.lib.getAllPDFEmbedsInCanvasView(i).forEach(r=>e(r.viewer,r.file))})}iteratePDFViewerChild(e){this.iteratePDFViewerComponents(t=>{t.then(i=>e(i))})}getActivePDFView(){var t;if(this.plugin.classes.PDFView)return this.app.workspace.getActiveViewOfType(this.plugin.classes.PDFView);let e=(t=this.app.workspace.activeLeaf)==null?void 0:t.view;return e&&this.lib.isPDFView(e)?e:null}getActiveCanvasView(){var t;let e=(t=this.app.workspace.activeLeaf)==null?void 0:t.view;return e&&this.lib.isCanvasView(e)?e:null}getExistingLeafForPDFFile(e){return this.getExistingLeafForFile(e)}getActiveGroupLeaves(){var t;let e=(t=this.app.workspace.activeLeaf)==null?void 0:t.group;return e?this.app.workspace.getGroupLeaves(e):null}async openMarkdownLinkFromPDF(e,t,i,r){var a;let o;i?o=this.app.workspace.getLeaf(i):d1(this.settings.paneTypeForFirstMDLeaf)&&this.settings.alwaysUseSidebar?o=this.getMarkdownLeafInSidebar(this.settings.paneTypeForFirstMDLeaf):o=this.getMarkdownLeafForLinkFromPDF(e,t);let s={};if(r){if("pos"in r){let{pos:c}=r;s.eState={line:c.start.line,startLoc:c.start,endLoc:c.end}}else{let{line:c}=r;s.eState={line:c}}s.eState.scroll=s.eState.line,s.eState.focus=!this.settings.dontActivateAfterOpenMD}o.parentSplit instanceof Je.WorkspaceTabs&&o.parentSplit===((a=this.app.workspace.activeLeaf)==null?void 0:a.parentSplit)||(s.active=!this.plugin.settings.dontActivateAfterOpenMD),await o.openLinkText(e,t,s),await this.revealLeaf(o)}getMarkdownLeafInSidebar(e){var t;return this.settings.singleMDLeafInSidebar?(t=this.lib.workspace.getExistingMarkdownLeafInSidebar(e))!=null?t:this.lib.workspace.getNewLeafInSidebar(e):this.lib.workspace.getNewLeafInSidebar(e)}getMarkdownLeafForLinkFromPDF(e,t){var a;let{path:i}=(0,Je.parseLinktext)(e),r=this.app.metadataCache.getFirstLinkpathDest(i,t),o,s;return this.app.workspace.iterateAllLeaves(c=>{if(o)return;let l=!0;if(c.view.getViewType()==="markdown"){let d=c.getRoot();for(let h of this.settings.ignoreExistingMarkdownTabIn)if(d===this.app.workspace[h])return;c.parentSplit instanceof Je.WorkspaceTabs&&c.parentSplit.children.some(u=>{if(u instanceof Je.WorkspaceLeaf&&u.view.getViewType()==="pdf")return this.getFilePathFromView(u.view)===t})&&(l=!1),l&&(s=c.parentSplit),r&&this.getFilePathFromView(c.view)===r.path&&(o=c)}}),o||(d1(this.settings.paneTypeForFirstMDLeaf)&&this.settings.singleMDLeafInSidebar&&s&&this.isInSide
2025-02-18 05:37:27 -03:00
` :t==="heading"&&(d+="#".repeat(f.depth+c-1)+ ` $ { v }
2025-03-07 06:22:58 -03:00
` )}}}),navigator.clipboard.writeText(d),new ct.Notice( ` $ { this . plugin . manifest . name } : Outline copied to clipboard . ` )})()}return!0}addOutlineItem(e){let t=this.lib.workspace.getActivePDFView(),i=t==null?void 0:t.file,r=t==null?void 0:t.viewer.child;if(!t||!i||!r||!this.lib.isEditable(r))return!1;let o=t.getState(),s=this.lib.viewStateToDestArray(o,!0);return s?(e||new qr(this.plugin,"Add to outline").ask().then(async({title:a})=>{let c=await Ke.fromFile(i,this.plugin),l=c.doc;c.ensureRoot().createChild(a,s).updateCountForAllAncestors(),c.ensureRoot().sortChildren(),await this.app.vault.modifyBinary(i,await l.save())}),!0):!1}async createNewNote(){var d;let e=this.app.workspace.getActiveFile(),t=(d=e==null?void 0:e.path)!=null?d:"",i=this.app.fileManager.getNewFileParent(t),r="",o="";if(e&&e.extension==="pdf"){let h=new id(this.plugin,{file:e,folder:e.parent,app:this.app}),u=this.settings.newFileNameFormat;u&&(r=h.evalTemplate(u));let p=this.settings.newFileTemplatePath;if(p){let f=this.app.vault.getAbstractFileByPath(p);f instanceof ct.TFile&&(o=await this.app.vault.read(f),o=h.evalTemplate(o))}}let s=await this.app.fileManager.createNewMarkdownFile(i,r,o||void 0),a=async()=>{let{leaf:h,isExistingLeaf:u}=await this.lib.copyLink.prepareMarkdownLeafForPaste(s);if(h){await this.lib.workspace.revealLeaf(h),this.app.workspace.setActiveLeaf(h);let p=h.view;if(p instanceof ct.MarkdownView){let f=p.editor;f.focus(),u||f.exec("goEnd")}}};if(this.settings.howToOpenAutoFocusTargetIfNotOpened!=="hover-editor"){await a();return}let l=this.app.metadataCache.on("resolve",async h=>{h===s&&(this.app.metadataCache.offref(l),setTimeout(()=>a(),100))})}extractHighlightedText(e){let t=this.lib.getPDFViewerChild();if(!t)return!1;let i=t.file;if(!i)return!1;if(!e){let r=this.lib.getColorPaletteFromChild(t),o=r?this.settings.copyCommands[r.actionIndex].template:this.settings.copyCommands[this.settings.defaultColorPaletteActionIndex].template,s="";(async()=>{var l;let a=(l=this.lib.getPDFDocument(!0))!=null?l:await this.lib.loadPDFDocument(i);(await this.lib.highlight.extract.getAnnotatedTextsInDocument(a)).forEach((d,h)=>{d.forEach(({text:u,rgb:p,comment:f},m)=>{s&&(s=s.trimEnd()+ `
2025-02-18 05:37:27 -03:00
2025-03-07 06:22:58 -03:00
` );let x=p? ` $ { p . r } , $ { p . g } , $ { p . b } ` :"";s+=this.lib.copyLink.getTextToCopy(t,o,void 0,i,h, ` # page = $ { h } & annotation = $ { m } ` ,u,x,void 0,f)})}),s?(await navigator.clipboard.writeText(s),new ct.Notice( ` $ { this . plugin . manifest . name } : Highlighted text copied to clipboard . ` )):new ct.Notice( ` $ { this . plugin . manifest . name } : No highlighted text found . ` )})()}return!0}async copyDebugInfo(){let e=await xg(this.app),t=Object.assign({},this.settings,{author:"*".repeat(this.settings.author.length)}),i=bg(this.app),r=this.plugin.domManager.styleEl.textContent,o= ` # # # # Obsidian debug info
2025-02-18 05:37:27 -03:00
` ;for(let[s,a]of Object.entries(e)){if(Array.isArray(a)){o+= ` - $ { s } : $ { a . length }
` ,a.forEach(c=>{o+= ` - $ { c }
` });continue}o+= ` - $ { s } : $ { a }
` }o+= `
# # # # PDF ++ debug info
2025-03-07 06:22:58 -03:00
` ,o+=" ` ` ` \ n "+JSON.stringify({settings:t,styleSettings:i,styleSheet:r})+" \ n ` ` ` \n ",await navigator.clipboard.writeText(o),new ct.Notice( ` $ { this . plugin . manifest . name } : Debug info copied to clipboard . ` )}loadDebugInfo(e){return this.plugin.isDebugMode?(e||(async()=>{try{let{settings:t,styleSettings:i,styleSheet:r}=JSON.parse(await navigator.clipboard.readText());new ct.Notice( ` $ { this . plugin . manifest . name } : Debug info loaded from clipboard . ` ),console.debug("Loaded debug info:"),console.debug("- settings:",t),console.debug("- styleSettings:",i),console.debug("- styleSheet:",r),window.pdfPlusDebugInfo={settings:t,styleSettings:i,styleSheet:r},this.plugin.settings=t;let o=this.app.setting.pluginTabs.find(s=>s.id===this.plugin.manifest.id);o&&await o.hide()}catch(t){new ct.Notice( ` $ { this . plugin . manifest . name } : Debug info not found in clipboard . ` )}})(),!0):!1}importExternalFileIntoVault(e){let t=this.lib.getPDFViewerChild(!0);return!t||!t.isFileExternal||!t.palette?!1:(e||t.palette.importFile(),!0)}openExternalSource(e){let t=this.lib.getPDFViewerChild(!0),i=t==null?void 0:t.file;return!t||!t.isFileExternal||!i?!1:(e||(async()=>{let r=(await this.app.vault.read(i)).trim();window.open(r,"_blank")})(),!0)}createDummyForExternalPDF(){new va(this.plugin).open()}showContextMenu(e){let t=this.lib.getPDFViewerChild(!0);if(!t)return!1;let r=t.containerEl.doc.getSelection();return!r||!r.focusNode||r.isCollapsed?!1:(e||Nu(this.plugin,t,r),!0)}};var ti=require("obsidian");var l0=class extends Ae{constructor(...e){super(...e),this.fileOperator=new em(this.plugin),this.linkUpdater=new tm(this.plugin)}isEnabled(){return this.settings.enablePDFEdit}async addPage(e){return await this.linkUpdater.updateLinks(()=>this.fileOperator.addPage(e),[e],(t,i)=>({}))}async insertPage(e,t,i,r){return await this.linkUpdater.updateLinks(()=>this.fileOperator.insertPage(e,t,i,r),[e],(o,s)=>({pageNumber:typeof s=="number"&&s>=t?s+1:s}))}async removePage(e,t,i){return await this.linkUpdater.updateLinks(()=>this.fileOperator.removePage(e,t,i),[e],(r,o)=>({pageNumber:typeof o=="number"&&o>t?o-1:o}))}async mergeFiles(e,t,i){let r=(await this.fileOperator.read(e)).getPageCount();return await this.linkUpdater.updateLinks(()=>this.fileOperator.mergeFiles(e,t,i),[e,t],(o,s)=>o===e?{}:{file:e,pageNumber:typeof s=="number"?s+r:s})}async extractPages(e,t,i,r,o,s){let a;return Array.isArray(t)?a=t:(t.from===void 0&&(t.from=1),t.to===void 0&&(t.to=(await this.fileOperator.read(e)).getPageCount()),a=hg(t.from,t.to+1)),await this.linkUpdater.updateLinks(()=>this.fileOperator.extractPages(e,a,i,r,o,s),[e],(c,l)=>{if(l===void 0)return{};if(a.includes(l))return{file:i,pageNumber:a.filter(d=>d<=l).length};if(s){let d=a.filter(h=>h<l).length;return d>0?{pageNumber:l-d}:{}}return{}})}},em=class extends Ae{constructor(...e){super(...e),this.pageLabelUpdater=new im(this.plugin)}async read(e){return await this.lib.loadPdfLibDocument(e)}async write(e,t,i){let r=await t.save(),o=this.app.vault.getAbstractFileByPath(e);if(o instanceof ti.TFile)return i||new ti.Notice( ` $ { this . plugin . manifest . name } : File already exists : $ { e } ` ),await this.app.vault.modifyBinary(o,r),o;if(o===null){let s=(0,ti.normalizePath)(e.split("/").slice(0,-1).join("/"));return s&&(this.app.vault.getAbstractFileByPath(s)||await this.app.vault.createFolder(s)),await this.app.vault.createBinary(e,r)}return null}async addPage(e){let t=await this.read(e),i=t.getPage(t.getPageCount()-1),{width:r,height:o}=i.getSize();return t.addPage([r,o]),await this.write(e.path,t,!0)}async insertPage(e,t,i,r){let o=await this.read(e);this.pageLabelUpdater.insertPage(o,t,r);let s=o.getPage(i-1),{width:a,height:c}=s.getSize();return o.insertPage(t-1,[a,c]),await this.write(e.path,o,!0)}async removePage(e,t,i){let r=await this.read(e);return this.pageLabelUpdater.removePage(r,t,i),r.removePage(t-1),await(await Ke.fromDocument(r,this.plugin)).prune(),await this.write(e.path,r,!0)}async mergeFiles(e,t,i){let[r,o]=await Promise.all([this.read(e),this.read(t)]);this.pageLabelUpdater.mergeFiles(r,o,i);let s=await r.copyPages(o,o.getPageIndices())
` )}}return f})}else{let p=e.key;await this.app.fileManager.processFrontMatter(o,f=>{f[p]=u})}}},im=class extends Ae{addPage(e){}insertPage(e,t,i){qi.processDocument(e,r=>{if(i){r.divideRangeAtPage(t,!0).shiftRangesAfterPage(t,1).divideRangeAtPage(t,!1,o=>{delete o.prefix,delete o.style});return}r.shiftRangesAfterPage(t,1)})}removePage(e,t,i){this.removePages(e,[t],i)}removePages(e,t,i){qi.processDocument(e,r=>{t.sort((o,s)=>s-o).forEach(o=>{this.removePageFromLabels(r,o,i)})})}removePageFromLabels(e,t,i){if(i){e.divideRangeAtPage(t+1,!0).shiftRangesAfterPage(t+1,-1);return}e.shiftRangesAfterPage(t+1,-1)}mergeFiles(e,t,i){}};var d0=require("obsidian");var nm=class{constructor(e){y0(this,"value");y0(this,"next");this.value=e}},Si,is,ns,od=class{constructor(){mn(this,Si);mn(this,is);mn(this,ns);this.clear()}enqueue(e){let t=new nm(e);Ge(this,Si)?(Ge(this,is).next=t,Ot(this,is,t)):(Ot(this,Si,t),Ot(this,is,t)),v0(this,ns)._++}dequeue(){let e=Ge(this,Si);if(e)return Ot(this,Si,Ge(this,Si).next),v0(this,ns)._--,e.value}peek(){if(Ge(this,Si))return Ge(this,Si).value}clear(){Ot(this,Si,void 0),Ot(this,is,void 0),Ot(this,ns,0)}get size(){return Ge(this,ns)}*[Symbol.iterator](){let e=Ge(this,Si);for(;e;)yield e.value,e=e.next}};Si=new WeakMap,is=new WeakMap,ns=new WeakMap;function rm(n){h1(n);let e=new od,t=0,i=()=>{t<n&&e.size>0&&(e.dequeue()(),t++)},r=()=>{t--,i()},o=async(c,l,d)=>{let h=(async()=>c(...d))();l(h);try{await h}catch(u){}r()},s=(c,l,d)=>{new Promise(h=>{e.enqueue(h)}).then(o.bind(void 0,c,l,d)),(async()=>(await Promise.resolve(),t<n&&i()))()},a=(c,...l)=>new Promise(d=>{s(c,d,l)});return Object.defineProperties(a,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value(){e.clear()}},concurrency:{get:()=>n,set(c){h1(c),n=c,queueMicrotask(()=>{for(;t<n&&e.size>0;)i()})}}}),a}function h1(n){if(!((Number.isInteger(n)||n===Number.POSITIVE_INFINITY)&&n>0))throw new TypeError("Expected ` concurrency ` to be a number from 1 and up")}var c0=class c0 extends d0.Component{constructor(t,i,r,o,s,a,c,l){super();this.plugin=t;this.ctx=i;this.file=r;this.subpath=o;this.pageNumber=s;this.rect=a;this.width=c;this.annotationId=l;this.app=i.app,this.containerEl=i.containerEl,this.rect=window.pdfjsLib.Util.normalizeRect(a),this.containerEl.addClass("pdf-cropped-embed"),c&&this.containerEl.setAttribute("width",""+c)}get lib(){return this.plugin.lib}onload(){super.onload(),this.shouldUpdateOnModify()&&this.registerEvent(this.app.vault.on("modify",t=>{t===this.file&&this.loadFile()})),this.plugin.settings.rectFollowAdaptToTheme&&(this.registerEvent(this.app.workspace.on("css-change",()=>{this.loadFile()})),this.registerEvent(this.plugin.on("adapt-to-theme-change",()=>{this.loadFile()})))}shouldUpdateOnModify(){return typeof this.annotationId=="string"}async loadFile(){let t=await c0.limit(this.computeDataUrl.bind(this));await new Promise((i,r)=>{this.containerEl.empty(),this.containerEl.createEl("img",{attr:{src:t}},o=>{o.addEventListener("load",()=>i()),o.addEventListener("error",c=>r(c));let s=this.containerEl.getAttribute("width"),a=this.containerEl.getAttribute("height");s&&o.setAttribute("width",s),a&&o.setAttribute("height",a)}),activeWindow.setTimeout(()=>r(),5e3)})}async computeDataUrl(){let t=await this.lib.loadPDFDocument(this.file),i=await t.getPage(this.pageNumber);if(this.annotationId){let s=(await i.getAnnotations()).find(a=>a.id===this.annotationId);s&&Array.isArray(s.rect)&&(this.rect=window.pdfjsLib.Util.normalizeRect(s.rect))}let r=await this.lib.pdfPageToImageDataUrl(i,{type:"image/png",cropRect:this.rect,renderParams:this.lib.getOptionalRenderParameters()});return await t.destroy(),r}};c0.limit=rm(d0.Platform.isMobile?3:10);var Yr=c0;var h0=class extends Ae{get ttsPlugin(){var e;return(e=this.app.plugins.plugins["obsidian-tts"])!=null?e:null}isEnabled(){return!!this.ttsPlugin}async speak(e){var t;await((t=this.ttsPlugin)==null?void 0:t.say(e))}};var $ n=require("obsidian");var u0=class extends Ae{async createDummyFilesInFolder(e,t){if(!!!this.app.vault.getFolderByPath(e))try{await this.app.vault.createFol
2025-02-18 05:37:27 -03:00
` ),t.replaceSelection(l)})}}getUrisFromDataTransfer(e){if(window.electron){let i=Array.from(e.files);if(i.length&&i.every(r=>r.type==="application/pdf"))return i.map(r=>{let o=window.electron.webUtils.getPathForFile(r);return this.absolutePathToFileUri(o)})}let t=e.getData("text/uri-list").split( ` \ r
2025-03-07 06:22:58 -03:00
` ).filter(i=>!i.startsWith("#"));return t.length&&t.every(i=>this.isUriPdf(i))?t:[]}getFolderPathForDummyFiles(e){var i;let t=this.settings.dummyFileFolderPath||this.app.vault.getConfig("attachmentFolderPath");return t==="."||t.startsWith("./")?(0, $ n.normalizePath)(((i=e==null?void 0:e.parent)!=null?i:this.app.vault.getRoot()).path+"/"+t.slice(1)):(0, $ n.normalizePath)(t)}absolutePathToFileUri(e){return e=e.replace(/ \\ /g,"/").replace(/ /g,"%20"),"file://"+(e.startsWith("/")?"":"/")+e}isUriPdf(e){return this.settings.externalURIPatterns.map(t=>new RegExp(t)).some(t=>t.test(e))}};var f0=class{constructor(e){this.utils=Sg;this.PDFCroppedEmbed=Yr;this.PDFOutlines=Ke;this.NameTree=ya;this.NumberTree=Wr;this.PDFNamedDestinations=Fa;this.PDFPageLabels=qi;this.app=e.app,this.plugin=e,this.commands=new a0(e),this.copyLink=new _u(e),this.highlight=new r0(e),this.workspace=new o0(e),this.composer=new l0(e),this.dummyFileManager=new u0(e),this.speech=new h0(e)}registerPDFEvent(e,t,i,r){let o=async s=>{await r(s),i||t.off(e,o)};i==null||i.register(()=>t.off(e,o)),t.on(e,o)}onPageReady(e,t,i){var r;(r=e.pdfViewer)==null||r._pages.forEach((o,s)=>{i(s+1,o,!1)}),this.registerPDFEvent("pagerendered",e.eventBus,t,o=>{i(o.pageNumber,o.source,!0)})}onTextLayerReady(e,t,i){var r;(r=e.pdfViewer)==null||r._pages.forEach((o,s)=>{o.textLayer&&i(s+1,o,!1)}),this.registerPDFEvent("textlayerrendered",e.eventBus,t,o=>{i(o.pageNumber,o.source,!0)})}onAnnotationLayerReady(e,t,i){var r;(r=e.pdfViewer)==null||r._pages.forEach((o,s)=>{o.annotationLayer&&i(s+1,o,!1)}),this.registerPDFEvent("annotationlayerrendered",e.eventBus,t,o=>{i(o.pageNumber,o.source,!0)})}applyPDFViewStateToViewer(e,t){let i=()=>{typeof t.left=="number"&&typeof t.top=="number"&&typeof t.zoom=="number"?e.scrollPageIntoView({pageNumber:t.page,destArray:[t.page,{name:"XYZ"},t.left,t.top,t.zoom]}):e.currentPageNumber=t.page};e.pagesCount?i():this.registerPDFEvent("pagesloaded",e.eventBus,null,()=>i())}getPageElAssociatedWithNode(e){let t=e.instanceOf(HTMLElement)?e:e.parentElement;if(!t)return null;let i=t.closest(".page");return!i||!i.instanceOf(HTMLElement)?null:i}getPageElFromSelection(e){let t=e.rangeCount>0?e.getRangeAt(0):null;return t?this.getPageElAssociatedWithNode(t.startContainer):null}getPageElFromEvent(e){return uu(e,e.target)?this.getPageElAssociatedWithNode(e.target):null}getPageNumberFromEvent(e){let t=this.getPageElFromEvent(e),i=t==null?void 0:t.dataset.pageNumber;return i===void 0?null:+i}getToolbarAssociatedWithNode(e){let t=e.instanceOf(HTMLElement)?e:e.parentElement;if(!t)return null;let i=t.closest(".pdf-container"),r=i==null?void 0:i.previousElementSibling;return r&&r.hasClass("pdf-toolbar")?r:null}getToolbarAssociatedWithSelection(){let e=activeWindow.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0);return this.getToolbarAssociatedWithNode(t.startContainer)}return null}getColorPalette(){var t;let e=(t=this.getPDFViewerChild(!0))!=null?t:this.plugin.lastAnnotationPopupChild;return e?this.getColorPaletteFromChild(e):this.getColorPaletteAssociatedWithSelection()}getColorPaletteOptions(){let e=this.getColorPalette();if(e)return e.getState();let t=this.plugin.settings;return{selectedColorName:[null,...Object.keys(t.colors)][t.defaultColorPaletteItemIndex],actionIndex:t.defaultColorPaletteActionIndex,displayTextFormatIndex:t.defaultDisplayTextFormatIndex,writeFile:t.defaultWriteFileToggle}}getColorPaletteAssociatedWithNode(e){var r;let t=this.getToolbarAssociatedWithNode(e);if(!t)return null;let i=t.querySelector("."+ei.CLS);return i&&(r=ei.elInstanceMap.get(i))!=null?r:null}getColorPaletteAssociatedWithSelection(){let e=activeWindow.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0);return this.getColorPaletteAssociatedWithNode(t.startContainer)}return null}getColorPaletteFromChild(e){var i;let t=(i=e.pdfViewer.dom)==null?void 0:i.viewerEl;return t?this.getColorPaletteAssociatedWithNode(t):null}getColorPaletteContainedIn(e){for(let[t,i]of ei.elInstanceMap)if(e.contains(t))return i;return null}getPDFViewerChildAssociatedWithNode(e){let t,i=e.instanceO
` ))}isEditable(e){return this.plugin.settings.enablePDFEdit&&!e.isFileExternal}requirePluginVersion(e,t){let i=this.app.plugins.plugins[e];if(!i)return!1;let r=i.manifest.version;return r===t||Uc(r,t)}requirePluginNewerThan(e,t){let i=this.app.plugins.plugins[e];if(!i)return!1;let r=i.manifest.version;return Uc(r,t)}onDocumentReady(e,t){if(e.pdfLoadingTask){e.pdfLoadingTask.promise.then(i=>t(i));return}e.pdfPlusCallbacksOnDocumentLoaded||(e.pdfPlusCallbacksOnDocumentLoaded=[]),e.pdfPlusCallbacksOnDocumentLoaded.push(t)}toSingleLine(e){return Kc(e,this.plugin.settings.removeWhitespaceBetweenCJChars)}async write(e,t,i){let r=this.app.vault.getAbstractFileByPath(e);if(r instanceof ke.TFile)return i||new ke.Notice( ` $ { this . plugin . manifest . name } : File already exists : $ { e } ` ),typeof t=="string"?await this.app.vault.modify(r,t):await this.app.vault.modifyBinary(r,t),r;if(r===null){let o=(0,ke.normalizePath)(e.split("/").slice(0,-1).join("/"));return o&&(this.app.vault.getAbstractFileByPath(o)||await this.app.vault.createFolder(o)),typeof t=="string"?await this.app.vault.create(e,t):await this.app.vault.createBinary(e,t)}return null}isCitationId(e){return typeof e=="string"&&this.plugin.citationIdRegex.test(e)}};var u1=require("obsidian");var p0=class extends Fe{constructor(e){if(super(e),this.settings.autoCopyToggleRibbonIcon){let t=!1;this.iconEl=e.settings.autoCopyToggleRibbonIcon?e.addRibbonIcon(this.settings.autoCopyIconName, ` $ { e . manifest . name } : Toggle auto - copy ` ,()=>{t||this.toggle()}):null,this.iconEl&&this.registerDomEvent(this.iconEl,"contextmenu",i=>{if(t)return;let r=new u1.Menu;r.addItem(o=>{o.setIcon("lucide-settings").setTitle("Customize...").onClick(()=>{this.plugin.openSettingTab().scrollToHeading("auto-copy")})}),r.onHide(()=>{t=!1}),r.showAtMouseEvent(i),t=!0})}}toggle(e){e=e!=null?e:!this.settings.autoCopy,e?this.enable():this.disable()}enable(){this.settings.autoCopy=!0,this.plugin.saveSettings(),this.load()}disable(){this.settings.autoCopy=!1,this.plugin.saveSettings(),this.unload()}onload(){var e;(e=this.iconEl)==null||e.addClass("is-active")}onunload(){var e;(e=this.iconEl)==null||e.removeClass("is-active")}};var f1=require("obsidian");var g0=class extends Fe{constructor(e){super(e),this.styleEl=e.registerEl(createEl("style",{attr:{id:"pdf-plus-style"}})),document.head.append(this.styleEl)}update(){this.unload(),this.plugin.removeChild(this),this.plugin.addChild(this)}registerEl(e){return this.register(()=>e.remove()),e}onload(){this.plugin.trigger("update-dom"),this.updateStyleEl(),this.updateClass("pdf-plus-click-embed-to-open-link",this.settings.dblclickEmbedToOpenLink),this.updateClass("pdf-plus-backlink-selection-highlight",this.settings.selectionBacklinkVisualizeStyle==="highlight"),this.updateClass("pdf-plus-backlink-selection-underline",this.settings.selectionBacklinkVisualizeStyle==="underline"),this.app.workspace.trigger("css-change")}updateClass(e,t){document.body.toggleClass(e,t),this.register(()=>document.body.removeClass(e))}updateStyleEl(){let e=this.plugin.settings;this.styleEl.textContent=Object.entries(e.colors).map(([r,o])=>cn(o)?[ ` . pdf - plus - backlink - highlight - layer . pdf - plus - backlink : not ( . hovered - highlight ) [ data - highlight - color = "${r.toLowerCase()}" ] , ` , ` . pdf - embed [ data - highlight - color = "${r.toLowerCase()}" ] . textLayer . mod - focused { ` , ` -- pdf - plus - color : $ { o } ; ` , ` -- pdf - plus - backlink - icon - color : $ { o } ; ` , ` -- pdf - plus - rect - color : $ { o } ; ` ,"}"].join( `
2025-02-18 05:37:27 -03:00
` ):"").join( `
2025-03-07 06:22:58 -03:00
` );let t=e.colors[e.defaultColor];(!t||!cn(t))&&(t="rgb(var(--text-highlight-bg-rgb))"),this.styleEl.textContent+=[ `
2025-02-18 05:37:27 -03:00
. pdf - plus - backlink - highlight - layer . pdf - plus - backlink : not ( . hovered - highlight ) { ` , ` -- pdf - plus - color : $ { t } ; ` , ` -- pdf - plus - backlink - icon - color : $ { t } ; ` , ` -- pdf - plus - rect - color : $ { t } ; ` ,"}"].join( `
2025-03-07 06:22:58 -03:00
` );let i=e.colors[e.backlinkHoverColor];(!i||!cn(i))&&(i=Lw),this.styleEl.textContent+=[ `
2025-02-18 05:37:27 -03:00
. pdf - plus - backlink - highlight - layer . pdf - plus - backlink . hovered - highlight { ` , ` -- pdf - plus - color : $ { i } ; ` , ` -- pdf - plus - backlink - icon - color : $ { i } ; ` , ` -- pdf - plus - rect - color : $ { i } ; ` ,"}"].join( `
2025-03-07 06:22:58 -03:00
` );for(let[r,o]of Object.entries(e.colors))cn(o)&&(this.styleEl.textContent+=[ `
. $ { ei . CLS } - item [ data - highlight - color = "${r.toLowerCase()}" ] > . $ { ei . CLS } - item - inner { ` , ` background - color : $ { o } ; ` ,"}"].join( `
2025-02-18 05:37:27 -03:00
` ));this.styleEl.textContent+=[ `
2025-03-07 06:22:58 -03:00
. $ { ei . CLS } - item : not ( [ data - highlight - color ] ) > . $ { ei . CLS } - item - inner { ` ," background-color: transparent;","}"].join( `
2025-02-18 05:37:27 -03:00
` ),this.styleEl.textContent+=[ `
. workspace - leaf . pdf - plus - link - opened . is - highlighted : : before { ` , ` opacity : $ { e . existingTabHighlightOpacity } ; ` ,"}"].join( `
` ),this.setCSSColorVariables(),this.updateCalloutStyle()}updateCalloutStyle(){var i;if(!this.plugin.settings.useCallout)return;let e=this.plugin.settings.calloutType.toLowerCase();for(let r of Object.keys(this.plugin.settings.colors)){let o=(i=this.toCSSVariableName(r))!=null?i:"--pdf-plus-default-color-rgb";this.styleEl.textContent+=[ `
. callout [ data - callout = "${e}" ] [ data - callout - metadata = "${r.toLowerCase()}" ] { ` , ` -- callout - color : var ( $ { o } ) ; ` ," background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))","}"].join( `
` )}this.styleEl.textContent+=[ `
. callout [ data - callout = "${e}" ] { ` ," --callout-color: var(--pdf-plus-default-color-rgb);"," background-color: rgba(var(--callout-color), var(--pdf-plus-highlight-opacity, 0.2))","}"].join( `
` );let t=this.plugin.settings.calloutIcon;t?this.styleEl.textContent+=[ `
. callout [ data - callout = "${e}" ] { ` , ` -- callout - icon : lucide - $ { t } ; ` ,"}"].join( `
` ):this.styleEl.textContent+=[ `
. callout [ data - callout = "${e}" ] . callout - icon { ` ," display: none;","}"].join( `
2025-03-07 06:22:58 -03:00
` )}registerCalloutRenderer(){let e=this.plugin.settings.calloutType.toLowerCase();this.plugin.registerMarkdownPostProcessor((t,i)=>{for(let r of t.querySelectorAll( ` . callout [ data - callout = "${e}" ] [ data - callout - metadata *= "," ] ` ))i.addChild(new om(r))})}setCSSColorVariables(){let e=this.plugin.settings;for(let[i,r]of Object.entries(e.colors)){let o=this.toCSSVariableName(i),s=Or(r);if(o!==null&&s!==null){let{r:a,g:c,b:l}=s;this.styleEl.textContent+=[ `
2025-02-18 05:37:27 -03:00
body { ` , ` $ { o } : $ { a } , $ { c } , $ { l } ` ,"}"].join( `
` )}}let t=!1;if(e.defaultColor in e.colors){let i=this.toCSSVariableName(e.defaultColor);i!==null&&(this.styleEl.textContent+=[ `
body { ` , ` -- pdf - plus - default - color - rgb : var ( $ { i } ) ` ,"}"].join( `
` ),t=!0)}t||(this.styleEl.textContent+=[ `
body { ` ," --pdf-plus-default-color-rgb: var(--text-highlight-bg-rgb)","}"].join( `
2025-03-07 06:22:58 -03:00
` ))}toCSSVariableName(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-");return t=t.replace(/^-+|-+ $ /g,""),t?"--pdf-plus-"+t+"-rgb":null}getRgb(e){let t="--pdf-plus-default-color-rgb";if(e){let o=this.toCSSVariableName(e);o&&(t=o)}let i=getComputedStyle(document.body).getPropertyValue(t);return eg(i)}},om=class extends f1.MarkdownRenderChild{onload(){let e=this.containerEl.dataset.calloutMetadata;if(e){let t=e.split(",").map(r=>parseInt(r));t.length===3&&t.every(r=>0<=r&&r<=255)&&this.containerEl.style.setProperty("--callout-color",t.join(", "))}}};var m0=class extends Le.Plugin{constructor(){super(...arguments);this.lib=new f0(this);this.events=new Le.Events;this.autoFocusToggleIconEl=null;this.autoPasteToggleIconEl=null;this.patchStatus={workspace:!1,pagePreview:!1,pdfView:!1,pdfInternals:!1,pdfOutlineViewer:!1,backlink:!1};this.classes={};this.lastPasteFile=null;this.lastActiveMarkdownFile=null;this.lastAnnotationPopupChild=null;this.lastCopiedDestInfo=null;this.vimrc=null;this.pdfViewerChildren=new Map;this.shownMenus=new Set;this.isDebugMode=!1}async onload(){this.checkVersion(),this.addIcons(),await(0,Le.loadPdfJs)(),await this.loadSettings(),await this.saveSettings(),this.domManager=this.addChild(new g0(this)),this.domManager.registerCalloutRenderer(),this.registerRibbonIcons(),this.patchObsidian(),this.registerPDFEmbedCreator(),this.registerHoverLinkSources(),this.registerCommands(),this.registerGlobalVariables(),this.registerEvents(),this.startTrackingActiveMarkdownFile(),this.registerObsidianProtocolHandler("pdf-plus",this.obsidianProtocolHandler.bind(this)),this.addSettingTab(this.settingTab=new Lu(this)),this.registerStyleSettings()}async onunload(){await this.cleanUpResources()}async cleanUpResources(){await this.cleanUpAnystyleFiles()}async cleanUpAnystyleFiles(){let t=this.app.vault.adapter;if(Le.Platform.isDesktopApp&&t instanceof Le.FileSystemAdapter){let i=this.getAnyStyleInputDir();if(i)try{await t.rmdir(i,!0)}catch(r){if(r.code!=="ENOENT")throw r}}}checkVersion(){this.textDivFirstIdx=Le.apiVersion==="1.8.0"?1:0,wa.openIfNecessary(this)}addIcons(){(0,Le.addIcon)("vim",'<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="Arial" font-size="48" fill="currentColor" style="letter-spacing:2; font-weight:bold;">VIM</text>')}getDefaultSettings(){return structuredClone(Qn)}async restoreDefaultSettings(){this.settings=this.getDefaultSettings(),await this.saveSettings()}async loadSettings(){if(this.settings=Object.assign(this.getDefaultSettings(),await this.loadData()),this.setCitationIdRegex(),!this.settings.anystylePath){let t=this.loadLocalStorage("anystylePath");typeof t=="string"&&(this.settings.anystylePath=t)}(this.settings.defaultDisplayTextFormatIndex<0||this.settings.defaultDisplayTextFormatIndex>=this.settings.displayTextFormats.length)&&(this.settings.defaultDisplayTextFormatIndex=0),(this.settings.defaultColorPaletteActionIndex<0||this.settings.defaultColorPaletteActionIndex>=this.settings.copyCommands.length)&&(this.settings.defaultColorPaletteActionIndex=0),this.validateAutoFocusAndAutoPasteSettings();for(let[t,i]of Object.entries(this.settings.colors))this.settings.colors[t]=i.toLowerCase();this.settings.paneTypeForFirstMDLeaf==="split"&&(this.settings.paneTypeForFirstMDLeaf="right");for(let t of this.settings.copyCommands)t.hasOwnProperty("format")&&(t.template=t.format,delete t.format);if(this.settings.hasOwnProperty("aliasFormat")&&(this.settings.displayTextFormats.push({name:"Custom",template:this.settings.aliasFormat}),delete this.settings.aliasFormat),this.settings.hasOwnProperty("showCopyLinkToSearchInContextMenu")){let t=this.settings.contextMenuConfig.find(({id:i})=>i==="search");t&&t.visible&&(t.visible=this.settings.showCopyLinkToSearchInContextMenu),delete this.settings.showCopyLinkToSearchInContextMenu}this.settings.showContextMenuOnMouseUpIf==="mod"&&(this.settings.showContextMenuOnMouseUpIf="Mod"),this.settings.enableEditEncryptedPDF=!1,this.renameSetting("enalbeWriteHighlightToFile","enablePDFEdit"),this.renameSetting("selectToCopyToggleRibbonIcon",
2025-02-18 05:37:27 -03:00
/ * ! B u n d l e d l i c e n s e i n f o r m a t i o n :
crypto - js / ripemd160 . js :
( * * @ preserve
( c ) 2012 by Cédric Mesnil . All rights reserved .
Redistribution and use in source and binary forms , with or without modification , are permitted provided that the following conditions are met :
- Redistributions of source code must retain the above copyright notice , this list of conditions and the following disclaimer .
- Redistributions in binary form must reproduce the above copyright notice , this list of conditions and the following disclaimer in the documentation and / or other materials provided with the distribution .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* )
crypto - js / mode - ctr - gladman . js :
( * * @ preserve
* Counter block mode compatible with Dr Brian Gladman fileenc . c
* derived from CryptoJS . mode . CTR
* Jan Hruby jhruby . web @ gmail . com
* )
* /
/* nosourcemap */