vault backup: 2026-10-07 22:56:17

This commit is contained in:
ben committed 2026-10-07 22:56:17 -07:00
1 parent 61f6cf0093
commit 793ae43e9f
6 files changed
+1198 -1

No files matched your search

+161
View File
@@ -0,0 +1,161 @@
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var T1=Object.create;var Na=Object.defineProperty;var A1=Object.getOwnPropertyDescriptor;var I1=Object.getOwnPropertyNames;var B1=Object.getPrototypeOf,O1=Object.prototype.hasOwnProperty;var wm=n=>{throw TypeError(n)};var L1=(n,e,t)=>e in n?Na(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),vf=(n,e)=>{for(var t in e)Na(n,t,{get:e[t],enumerable:!0})},Fm=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of I1(e))!O1.call(n,r)&&r!==t&&Na(n,r,{get:()=>e[r],enumerable:!(i=A1(e,r))||i.enumerable});return n};var Wi=(n,e,t)=>(t=n!=null?T1(B1(n)):{},Fm(e||!n||!n.__esModule?Na(t,"default",{value:n,enumerable:!0}):t,n)),M1=n=>Fm(Na({},"__esModule",{value:!0}),n);var wf=(n,e,t)=>L1(n,typeof e!="symbol"?e+"":e,t),Dm=(n,e,t)=>e.has(n)||wm("Cannot "+t);var qe=(n,e,t)=>(Dm(n,e,"read from private field"),t?t.call(n):e.get(n)),mn=(n,e,t)=>e.has(n)?wm("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),Lt=(n,e,t,i)=>(Dm(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);var Ff=(n,e,t,i)=>({set _(r){Lt(n,e,r,t)},get _(){return qe(n,e,i)}});var bn=_(St=>{"use strict";var W1=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function K1(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)K1(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 G1={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}},X1={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,G1)):(St.Buf8=Array,St.Buf16=Array,St.Buf32=Array,St.assign(St,X1))};St.setTyped(W1)});var $m=_(xs=>{"use strict";var Z1=bn(),Y1=4,Im=0,Bm=1,_1=2;function ms(n){for(var e=n.length;--e>=0;)n[e]=0}var J1=0,Vm=1,Q1=2,$1=3,eF=258,Yf=29,Ya=256,Ka=Ya+1+Yf,gs=30,_f=19,Hm=2*Ka+1,eo=15,jf=16,tF=7,Jf=256,zm=16,Um=17,qm=18,Xf=[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],xd=[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],iF=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],jm=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],nF=512,yn=new Array((Ka+2)*2);ms(yn);var Wa=new Array(gs*2);ms(Wa);var Ga=new Array(nF);ms(Ga);var Xa=new Array(eF-$1+1);ms(Xa);var Qf=new Array(Yf);ms(Qf);var bd=new Array(gs);ms(bd);function Wf(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 Wm,Km,Gm;function Kf(n,e){this.dyn_tree=n,this.max_code=0,this.stat_desc=e}function Xm(n){return n<256?Ga[n]:Ga[256+(n>>>7)]}function Za(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>jf-t?(n.bi_buf|=e<<n.bi_valid&65535,Za(n,n.bi_buf),n.bi_buf=e>>jf-n.bi_valid,n.bi_valid+=t-jf):(n.bi_buf|=e<<n.bi_valid&65535,n.bi_valid+=t)}function Xi(n,e,t){Rt(n,t[e*2],t[e*2+1])}function Zm(n,e){var t=0;do t|=n&1,n>>>=1,t<<=1;while(--e>0);return t>>>1}function rF(n){n.bi_valid===16?(Za(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 oF(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<=eo;u++)n.bl_count[u]=0;for(t[n.heap[n.heap_max]*2+1]=0,l=n.heap_max+1;l<Hm;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.bl_count[u]++,p=0,d>=a&&(p=s[d-a]),f=t[d*2],n.opt_len+=f*(u+p),o&&(n.static_len+=f*(r[d*2+1]+p)));if(m!==0){do{for(u=c-1;n.bl_count[u]===0;)u--;n.bl_count[u]--,n.bl_count[u+1]+=2,n.bl_count[c]--,m-=2}while(m>0);for(u=c;u!==0;u--)for(d=n.bl_count[u];d!==0;)h=n.heap[--l],!(h>i)&&(t[h*2+1]!==u&&(n.opt_len+=(u-t[h*2+1])*t[h*2],t[h*2+1]=u),d--)}}function Ym(n,e,t){var i=new Array(eo+1),r=0,o,s;for(o=1;o<=eo;o++)i[o]=r=r+t[o-1]<<1;for(s=0;s<=e;s++){var a=n[s*2+1];a!==0&&(n[s*2]=Zm(i[a]++,a))}}function sF(){var n,e,t,i,r,o=new Array(eo+1);for(t=0,i=0;i<Yf-1;i++)for(Qf[i]=t,n=0;n<1<<Xf[i];n++)Xa[t++]=i;for(Xa[t-1]=i,r=0,i=0;i<16;i++)for(bd[i]=r,n=0;n<1<<xd[i];n++)Ga[r++]=i;for(r>>=7;i<gs;i++)for(bd[i]=r<<7,n=0;n<1<<xd[i]-7;n++)Ga[256+r++]=i;for(e=0;e<=eo;e++)o[e]=0;for(n=0;n<=143;)yn[n*2+1]=8,n++,o[8]++;for(;n<=255;)yn[n*2+1]=9,n++,o[9]++;for(;n<=279;)yn[n*2+1]=7,n++,o[7]++;for(;n<=287;)yn[n*2+1]=8,Line truncated
`,"&Nfr;":"\u{1D511}","&NoBreak;":"\u2060","&NonBreakingSpace;":"\xA0","&Nopf;":"\u2115","&Not;":"\u2AEC","&NotCongruent;":"\u2262","&NotCupCap;":"\u226D","&NotDoubleVerticalBar;":"\u2226","&NotElement;":"\u2209","&NotEqual;":"\u2260","&NotEqualTilde;":"\u2242\u0338","&NotExists;":"\u2204","&NotGreater;":"\u226F","&NotGreaterEqual;":"\u2271","&NotGreaterFullEqual;":"\u2267\u0338","&NotGreaterGreater;":"\u226B\u0338","&NotGreaterLess;":"\u2279","&NotGreaterSlantEqual;":"\u2A7E\u0338","&NotGreaterTilde;":"\u2275","&NotHumpDownHump;":"\u224E\u0338","&NotHumpEqual;":"\u224F\u0338","&NotLeftTriangle;":"\u22EA","&NotLeftTriangleBar;":"\u29CF\u0338","&NotLeftTriangleEqual;":"\u22EC","&NotLess;":"\u226E","&NotLessEqual;":"\u2270","&NotLessGreater;":"\u2278","&NotLessLess;":"\u226A\u0338","&NotLessSlantEqual;":"\u2A7D\u0338","&NotLessTilde;":"\u2274","&NotNestedGreaterGreater;":"\u2AA2\u0338","&NotNestedLessLess;":"\u2AA1\u0338","&NotPrecedes;":"\u2280","&NotPrecedesEqual;":"\u2AAF\u0338","&NotPrecedesSlantEqual;":"\u22E0","&NotReverseElement;":"\u220C","&NotRightTriangle;":"\u22EB","&NotRightTriangleBar;":"\u29D0\u0338","&NotRightTriangleEqual;":"\u22ED","&NotSquareSubset;":"\u228F\u0338","&NotSquareSubsetEqual;":"\u22E2","&NotSquareSuperset;":"\u2290\u0338","&NotSquareSupersetEqual;":"\u22E3","&NotSubset;":"\u2282\u20D2","&NotSubsetEqual;":"\u2288","&NotSucceeds;":"\u2281","&NotSucceedsEqual;":"\u2AB0\u0338","&NotSucceedsSlantEqual;":"\u22E1","&NotSucceedsTilde;":"\u227F\u0338","&NotSuperset;":"\u2283\u20D2","&NotSupersetEqual;":"\u2289","&NotTilde;":"\u2241","&NotTildeEqual;":"\u2244","&NotTildeFullEqual;":"\u2247","&NotTildeTilde;":"\u2249","&NotVerticalBar;":"\u2224","&Nscr;":"\u{1D4A9}","&Ntilde":"\xD1","&Ntilde;":"\xD1","&Nu;":"\u039D","&OElig;":"\u0152","&Oacute":"\xD3","&Oacute;":"\xD3","&Ocirc":"\xD4","&Ocirc;":"\xD4","&Ocy;":"\u041E","&Odblac;":"\u0150","&Ofr;":"\u{1D512}","&Ograve":"\xD2","&Ograve;":"\xD2","&Omacr;":"\u014C","&Omega;":"\u03A9","&Omicron;":"\u039F","&Oopf;":"\u{1D546}","&OpenCurlyDoubleQuote;":"\u201C","&OpenCurlyQuote;":"\u2018","&Or;":"\u2A54","&Oscr;":"\u{1D4AA}","&Oslash":"\xD8","&Oslash;":"\xD8","&Otilde":"\xD5","&Otilde;":"\xD5","&Otimes;":"\u2A37","&Ouml":"\xD6","&Ouml;":"\xD6","&OverBar;":"\u203E","&OverBrace;":"\u23DE","&OverBracket;":"\u23B4","&OverParenthesis;":"\u23DC","&PartialD;":"\u2202","&Pcy;":"\u041F","&Pfr;":"\u{1D513}","&Phi;":"\u03A6","&Pi;":"\u03A0","&PlusMinus;":"\xB1","&Poincareplane;":"\u210C","&Popf;":"\u2119","&Pr;":"\u2ABB","&Precedes;":"\u227A","&PrecedesEqual;":"\u2AAF","&PrecedesSlantEqual;":"\u227C","&PrecedesTilde;":"\u227E","&Prime;":"\u2033","&Product;":"\u220F","&Proportion;":"\u2237","&Proportional;":"\u221D","&Pscr;":"\u{1D4AB}","&Psi;":"\u03A8","&QUOT":'"',"&QUOT;":'"',"&Qfr;":"\u{1D514}","&Qopf;":"\u211A","&Qscr;":"\u{1D4AC}","&RBarr;":"\u2910","&REG":"\xAE","&REG;":"\xAE","&Racute;":"\u0154","&Rang;":"\u27EB","&Rarr;":"\u21A0","&Rarrtl;":"\u2916","&Rcaron;":"\u0158","&Rcedil;":"\u0156","&Rcy;":"\u0420","&Re;":"\u211C","&ReverseElement;":"\u220B","&ReverseEquilibrium;":"\u21CB","&ReverseUpEquilibrium;":"\u296F","&Rfr;":"\u211C","&Rho;":"\u03A1","&RightAngleBracket;":"\u27E9","&RightArrow;":"\u2192","&RightArrowBar;":"\u21E5","&RightArrowLeftArrow;":"\u21C4","&RightCeiling;":"\u2309","&RightDoubleBracket;":"\u27E7","&RightDownTeeVector;":"\u295D","&RightDownVector;":"\u21C2","&RightDownVectorBar;":"\u2955","&RightFloor;":"\u230B","&RightTee;":"\u22A2","&RightTeeArrow;":"\u21A6","&RightTeeVector;":"\u295B","&RightTriangle;":"\u22B3","&RightTriangleBar;":"\u29D0","&RightTriangleEqual;":"\u22B5","&RightUpDownVector;":"\u294F","&RightUpTeeVector;":"\u295C","&RightUpVector;":"\u21BE","&RightUpVectorBar;":"\u2954","&RightVector;":"\u21C0","&RightVectorBar;":"\u2953","&Rightarrow;":"\u21D2","&Ropf;":"\u211D","&RoundImplies;":"\u2970","&Rrightarrow;":"\u21DB","&Rscr;":"\u211B","&Rsh;":"\u21B1","&RuleDelayed;":"\u29F4","&SHCHcy;":"\u0429","&SHcy;":"\u0428","&SOFTcy;":"\u042C","&Sacute;":"\u015A","&Sc;":"\u2ABC","&Scaron;":"\u0160","&Scedil;":"\u015E","&Scirc;":"\u015C","&Scy;":"\u0421","&Sfr;":"\u{1D516}","&ShortDownArrow;":"\u2193","&ShortLeftArrow;":"\u2190","&ShortRightArrow;":"\u2192","&ShortUpArrow;":"\u2191","&Sigma;":"\u03A3","&SmallCircle;":"\u2218","&Sopf;":"\u{1D54A}","&Sqrt;":"\u221A","&Square;":"\u25A1","&SquareIntersection;":"\u2293","&SquareSubset;":"\u228F","&SquareSubsetEqual;":"\u2291","&SquareSuperset;":"\u2290","&SquareSupersetEqual;":"\u2292","&SquareUnion;":"\u2294","&Sscr;":"\u{1D4AE}","&Star;":"\u22C6","&Sub;":"\u22D0","&Subset;":"\u22D0","&SubsetEqual;":"\u2286","&Succeeds;":"\u227B","&SucceedsEqual;":"\u2AB0","&SucceedsSlantEqual;":"\u227D","&SucceedsTilde;":"\u227F","&SuchThat;":"\u220B","&Sum;":"\u2211","&Sup;":"\u22D1","&Superset;":"\u2283","&SupersetEqual;":"\u2287","&Supset;":"\u22D1","&THORN":"\xDE","&THORN;":"\xDE","&TRADE;":"\u2122","&TSHcy;":"\u040B","&TScy;":"\u0426","&Tab;":" ","&Tau;":"\u03A4","&Tcaron;":"\u0164","&Tcedil Line truncated
`).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}>`}else return this.innerHTML}get innerHTML(){return this.childNodes.map(e=>e.toString()).join("")}set innerHTML(e){let t=Tp(e);this.childNodes.forEach(i=>i.remove()),t.childNodes.forEach(i=>this.appendChild(i))}set_content(e){if(e instanceof Go)e=[e];else if(typeof e=="string"){let t=Tp(e);e=t.childNodes.length?t.childNodes:[new Ko(e)]}this.childNodes=e}get outerHTML(){return this.toString()}trimRight(e){for(let t=0;t<this.childNodes.length;t++){let i=this.childNodes[t];if(i.nodeType===At.ELEMENT_NODE)i.trimRight(e);else{let r=i.rawText.search(e);r>-1&&(i.value=i.rawText.substr(0,r),this.childNodes.length=t+1)}}return this}get structure(){let e=[],t=0;function i(o){e.push(" ".repeat(t)+o)}function r(o){let s=o.id?"#"+o.id:"",a=o.classNames.length?"."+o.classNames.join("."):"";i(o.tagName+s+a),t++;for(let c=0;c<o.childNodes.length;c++){let l=o.childNodes[c];l.nodeType===At.ELEMENT_NODE?r(l):l.nodeType===At.TEXT_NODE&&(l.isWhitespace||i("#text"))}t--}return r(this),e.join(`
`)}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 Wo))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 Wo(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 Wo?(t=e,t.reset()):t=new Wo(e);let i=[];for(let r=0;r<this.childNodes.length;r++)for(i.push([this.childNodes[r],0,!1]);i.length;){let o=na(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 na(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,ia.decode)(e[t]);return this._attrs}get rawAttributes(){if(this._rawAttrs)return this._rawAttrs;let e={};if(this.rawAttrs){let t;for(;t=kk.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,ia.encode)(t+"")),this.rawAttrs=Object.keys(i).map(r=>r+(i[r]===""?"":'="'+(0,ia.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,ia.encode)(e[t]+""))),this.rawAttrs=Object.keys(e).map(t=>t+(e[t]===""?"":'="'+(0,ia.encode)(e[t]+"")+'"')).join(" ")}};pt.HTMLElement=ra;var Qh={},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}},Wo=class{constructor(e){this.nextMatch=0,Ep.f5=Ep.f5,this.matchers=e.split(" ").map(t=>{if(Qh[t])return Qh[t];let i=t.split("."),r=i[0],o=i.slice(1).sort(),s='"use strict";',a="f",c="",l="";if(r&&r!="*"){let h;if(r[0]=="#")s+="if (el.id != "+JSON.stringify(r.substr(1))+") return false;",a+="1";else if(h=r.match(/^\[\s*(\S+)\s*(=|!=)\s*((((["'])([^\6]*)\6))|(\S*?))\]\s*/)){c=h[1];let u=h[2];if(u!=="="&&u!=="!=")throw new Error("Selector not supported, Expect [key${op}value].op must be =,!=");u==="="&&(u="=="),l=h[7]||h[8],s+=`let attrs = el.attributes;for (let key in attrs){const val = attrs[key]; if (key == "${c}" && val == "${l}"){return true;}} return false;`,a+="2"}else s+="if (el.tagName != "+JSON.stringify(r)+") return false;",a+="3"}o.length>0&&(s+="for (let cls = "+JSON.stringify(o)+", i = 0; i < cls.length; i++) if (el.classNames.indexOf(cls[i]) === -1) return false;",a+="4"),s+="return true;",a+="5";let d={func:Ep[a],tagName:r||"",class Line truncated
`,"\f","\r","\v"],Sf=n=>/^[\n\f\r\u000B]$/.test(n),Va=n=>n.split(/[\n\f\r\u000B]/),fd=n=>n.replace(/[\n\f\r\u000B]/g," "),pd=(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]},Ef=n=>{let e=[];for(let t=0,i=n.length;t<i;){let[r,o]=pd(n,t);e.push(r),t+=o}return e},H1=n=>{let e=km.join("|"),t=["$"];for(let r=0,o=n.length;r<o;r++){let s=n[r];if(Sf(s))throw new TypeError(`\`wordBreak\` must not include ${e}`);t.push(s===""?".":Pm(s))}let i=t.join("|");return new RegExp(`(${e})|((.*?)(${i}))`,"gm")},Tf=(n,e,t,i)=>{let r=H1(e),o=ir(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(Sf(u))l();else{let p=i(u);a+p>t&&l(),s+=u,a+=p}}return l(),c},z1=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,Ha=n=>{let e=n.match(z1);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}`)},us=(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 Qr=n=>n[n.length-1],za=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},Af=(...n)=>{let e=n.length,t=[];for(let s=0;s<e;s++){let a=n[s];t[s]=a instanceof Uint8Array?a:za(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},If=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},Bf=(n,e)=>n.id-e.id,Of=(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},fs=(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},nr=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},Lf=n=>{let e=0;for(let t=0,i=n.length;t<i;t++)e+=n[t];return e},Mf=(n,e)=>{let t=new Array(e-n);for(let i=0,r=t.length;i<r;i++)t[i]=n+i;return t},Nf=(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},Rf=n=>n instanceof Uint8Array||n instanceof ArrayBuffer||typeof n=="string",$r=n=>{if(typeof n=="string")return kf(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`")},Cm=[];for(let n=0;n<=255;++n)Cm[n]=n.toString(16).padStart(2,"0");var Vf=n=>{let e=new Array(n.length);for(let t=0;t<n.length;++t)e[t]=Cm[n[t]];return e.join("")};var Ai=()=>new Promise(n=>{setTimeout(()=>n(),0)});var U1=(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${Gi(o)}`)}return new Uint8Array(t)},Hf=(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(gd(o),md(o)),i+=2;else throw new Error(`Invalid code point: 0x${Gi(o)}`)}return new Uint16Array(t)},zf=n=>n>=0&&n<=65535,Uf=n=>n>=65536&&n<=1114111,gd=n=>Math.floor((n-65536)/1024)+55296,md=n=>(n-65536)%1024+56320,rr;(function(n){n.BigEndian="BigEndian",n.LittleEndian="LittleEndian"})(rr||(rr={}));var Ua="\uFFFD".codePointAt(0),qa=(n,e=!0)=>{if(n.length<=1)return String.fromCodePoint(Ua);let t=e?j1(n):rr.BigEndian,i=e?2:0,r=[];for(;n.length-i>=2;){let o=Em(n[i++],n[i++],t);if(q1(o))if(n.length-i<2)r.push(Ua);else{let s=Em(n[i++],n[i++],t);Sm(s)?r.push(o,s):r.push(Ua)}else Sm(o)?(i+=2,r.push(Ua)):r.push(o)}return i<n.length&&r.push(Ua),String.fromCodePoint(...r)},q1=n=>n>=55296&&n<=56319,Sm=n=>n>=56320&&n<=57343,Em=(n,e,t)=>{if(t===rr.LittleEndian)return e<<8|n;if(t===rr.BigEndian)return n<<8|e;throw new Error(`Invalid byteOrder: ${t}`)},j1=n=>Tm(n)?rr.BigEndian:Am(n)?rr.LittleEndian:rr.BigEndian,Tm=n=>n[0]===254&&n[1]===255,Am=n=>n[0]===255&&n[1]===254,ja=n=>Tm(n)||Am(n);var qf=n=>{let e=String(n);if(Math.abs(n)<1){let t=parseInt(n.toString().split("e-")[1]);if(t){let i=n<0;i&&(n*=-1),n*=Math.pow(10,t-1),e="0."+new Array(t).join("0")+n.toString().substring(2),i&&(e="-"+e)}}else{let t=parseInt(n.toString().split("+")[1]);t>20&&(t-=20,n/=Math.pow(10,t),e=n.toString()+new Array(t+1).join("0"))}return e},ps=n=>Math.ceil(n.toString(2).length/8),or=n=>{let e=new Uint8Array(ps(n));for(let t=1Line truncated
%${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+=Ae(this.major,e,t),e[t++]=P.Period,t+=Ae(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}};Al.forVersion=(n,e)=>new Al(n,e);var $i=Al;var T0=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")}},Se=T0;var Il=class n extends Se{constructor(e){super(),this.numberValue=e,this.stringValue=qf(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 Ae(this.stringValue,e,t),this.stringValue.length}};Il.of=n=>new Il(n);var G=Il;var Bl=class n extends Se{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 bl(this.size());let e=this.lookup(0,G).asNumber(),t=this.lookup(1,G).asNumber(),i=this.lookup(2,G).asNumber(),r=this.lookup(3,G).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 G){let s=i%2===0?e:t;this.set(i,G.of(o.asNumber()*s))}}}};Bl.withContext=n=>new Bl(n);var Z=Bl;var A0={},ho=class extends Se{constructor(e,t){if(e!==A0)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)}};ho.True=new ho(A0,!0);ho.False=new ho(A0,!1);var Li=ho;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 ci=new Uint8Array(256);ci[P.Null]=1;ci[P.Tab]=1;ci[P.Newline]=1;ci[P.FormFeed]=1;ci[P.CarriageReturn]=1;ci[P.Space]=1;var Md=new Uint8Array(256);for(let n=0,e=256;n<e;n++)Md[n]=ci[n]||Ht[n]?1:0;Md[P.Hash]=1;var tP=n=>n.replace(/#([\dABCDEF]{2})/g,(e,t)=>Cf(t)),iP=n=>n>=P.ExclamationPoint&&n<=P.Tilde&&!Md[n],Kb={},Wb=new Map,oe=class extends Se{constructor(e,t){if(e!==Kb)throw new Dn("PDFName");super();let i="/";for(let r=0,o=t.length;r<o;r++){let s=t[r],a=ae(s);i+=iP(a)?s:`#${Gi(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=ae(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))}asString(){return this.encodedName}value(){return this.encodedName}clone(){return this}toString(){return this.encodedName}sizeInBytes(){return this.encodedName.length}copyBytesInto(e,t){return Ae(this.encodedName,e,t),this.encodedName.length}};oe.of=n=>{let e=tP(n),t=Wb.get(e);return t||(t=new oe(Kb,e),Wb.set(e,t)),t};oe.Length=oe.of("Length");oe.FlateDecode=oe.of("FlateDecode");oe.Resources=oe.of("Resources");oe.Font=oe.of("Font");oe.XObject=oe.of("XObject");oe.ExtGState=oe.of("ExtGState");oe.Contents=oe.of("Contents");oe.Type=oe.of("Type");oe.Parent=oe.of("Parent");oe.MediaBox=oe.of("MediaBox");oe.Page=oe.of("Page");oe.Annots=oe.of("Annots");oe.TrimBox=oe.of("TrimBox");oe.ArtBox=oe.of("ArtBox");oe.BleedBox=oe.of("BleedBox");oe.CropBox=oe.of("CropBox");oe.Rotate=oe.of("Rotate");oe.Title=oe.of("Title");oe.Author=oe.of("Author");oe.Subject=oe.of("Subject");oe.Creator=oe.of("Creator");oe.Keywords=oe Line truncated
`,t=this.entries();for(let i=0,r=t.length;i<r;i++){let[o,s]=t[i];e+=o.toString()+" "+s.toString()+`
`}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}};uo.withContext=n=>new uo(new Map,n);uo.fromMapWithContext=(n,e)=>new uo(n,e);var W=uo;var Sn=class n extends Se{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 ja(e)?qa(e):ul(e)}decodeDate(){let e=this.decodeText(),t=Ha(e);if(!t)throw new co(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+=Ae(this.value,e,t),e[t++]=P.GreaterThan,this.value.length+2}};Sn.of=n=>new Sn(n);Sn.fromText=n=>{let e=Hf(n),t="";for(let i=0,r=e.length;i<r;i++)t+=Ki(e[i],4);return new Sn(t)};Sn.fromBytes=n=>Sn.of(Vf(n));var K=Sn;var B0=class extends Se{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(v.Length,G.of(e))}sizeInBytes(){return this.updateDict(),this.dict.sizeInBytes()+this.getContentsSize()+18}toString(){this.updateDict();let e=this.dict.toString();return e+=`
stream
`,e+=this.getContentsString(),e+=`
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=B0;var Ol=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}};Ol.of=(n,e,t)=>new Ol(n,e,t);var Mi=Ol;var Xb={},Gb=new Map,Ll=class extends Se{constructor(e,t,i){if(e!==Xb)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 Ae(this.tag,e,t),this.tag.length}};Ll.of=(n,e=0)=>{let t=`${n} ${e} R`,i=Gb.get(t);return i||(i=new Ll(Xb,n,e),Gb.set(t,i)),i};var Y=Ll;var fo=class n extends Se{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=ae(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 ja(e)?qa(e):ul(e)}decodeDate(){let e=this.decodeText(),t=Ha(e);if(!t)throw new co(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+=Ae(this.value,e,t),e[t++]=P.RightParen,this.value.length+2}};fo.of=n=>new fo(n);fo.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 fo(`D:${e}${t}${i}${r}${o}${s}Z`)};var J=fo;var Ml=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 Se?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 Se?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 Se?t+=s.copyBytesInto(e,t):t+=Ae(s,e,t),e[t++]=P.Space}return t+=Ae(this.name,e,t),t-i}};Ml.of=(n,e)=>new Ml(n,e);var le=Ml;var O0;(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.ClipEvenOdd="W*",n.ClipNonZero="W",n.CloseAndStroke="s",n.CloseFillEvenOddAndStroke="b*",n.CloseFillNonZeroAndStroke="b",n.ClosePath="h",n.AppendBezierCurve="c",n.CurveToReplicateFinalPoint="y",n.CurveToReplicateInitialPoint="v",n.EndPath="n",n.FillEvenOddAndStroke="B*",n.FillEvenOdd="f*",n.FillNonZeroAndStroke="B",n.FillNonZero="f",n.LegacyFillNonZero="F",n.LineTo="l",n.MoveTo="m",n.ShadingFill="sh",n.StrokePath="S",n.BeginText="BT",n.EndText="ET",n.MoveText="Td",n.MoveTextSetLeading="TD",n.NextLine="T*",n.SetCharacterSpacing="Tc",n.SetFontAndSize="Tf",n.SetTextHorizontalScaling="Tz",n.SetTextLineHeight="TL",n.SetTextRenderingMode="Tr",n.SetTextRise="Ts",n.SetWordSpacing="Tw",n.ShowText="Tj",n.ShowTextAdjusted="TJ",n.ShowTextLine="'",n.ShowTextLineAndSpace='"',n.Type3D0="d0",n.Type3D1="d1",n.BeginCompatibilitySection="BX",n.EndCompatibilitySection="EX"})(O0||(O0={}));var ce=O0;var Zb=Wi(sl(),1);var L0 Line truncated
`;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}};Nl.of=(n,e,t=!0)=>new Nl(n,e,t);var en=Nl;var As=class{constructor(e){this.seed=e}nextInt(){let e=Math.sin(this.seed++)*1e4;return e-Math.floor(e)}};As.withSeed=n=>new As(n);var nP=([n],[e])=>n.objectNumber-e.objectNumber,Rl=class{constructor(){this.isDecrypted=!0,this.largestObjectNumber=0,this.header=$i.forVersion(1,7),this.trailerInfo={},this.indirectObjects=new Map,this.rng=As.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(He),r=e instanceof Y?this.indirectObjects.get(e):e;if(!(!r||r===He&&!i)){for(let o=0,s=t.length;o<s;o++){let a=t[o];if(a===He){if(r===He)return r}else if(r instanceof a)return r}throw new Qi(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===He){if(i===He)return i}else if(i instanceof s)return i}throw new Qi(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(nP)}obj(e){if(e instanceof Se)return e;if(e==null)return He;if(typeof e=="string")return v.of(e);if(typeof e=="number")return G.of(e);if(typeof e=="boolean")return e?Li.True:Li.False;if(e instanceof Uint8Array)return K.fromBytes(e);if(Array.isArray(e)){let t=Z.withContext(this);for(let i=0,r=e.length;i<r;i++)t.push(this.obj(e[i]));return t}else{let t=W.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(v.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 Z){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 W){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 v)return e.decodeText();if(e===He)return null;if(e instanceof G)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 J||e instanceof K)&&o)return e.asString()}}return e}stream(e,t={}){return Mi.of(this.obj(t),za(e))}flateStream(e,t={}){return this.stream(Yb.default.deflate(za(e)),Object.assign(Object.assign({},t),{Filter:"FlateDecode"}))}contentStream(e,t={}){return en.of(this.obj(t),e)}formXObject(e,t={}){return this.contentStream(e,Object.assign(Object.assign({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=le.of(ce.PushGraphicsState),i=en.of(e,[t]);return this.pushGraphicsStateContentStreamRef=this.register(i),this.pushGraphicsStateContentStreamRef}getPopGraphicsStateContentStream(){if(this.popGraphicsStateContentStreamRef)return this.popGraphicsStateContentStreamRef;let e=this.obj({}),t=le.of(ce.PopGraphicsState),i=en.of(e,[t]);return this.popGraphicsStateContentStreamRef=this.register(i),this.popGraphicsStateContentStreamRef}addRandomSuffix(e,t=4){return`${e}-${Math.floor(this.rng.nextInt()*Math.pow(10,t))}`}};Rl.create=()=>new Rl;var po=Rl;var pr=class n extends W{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(let r=0,o=i.length;r<o;r++){let[s,a]=i[r];t.set(s,a)}return t}Parent(){return this.lookupMaybe(v.Parent,W)}Contents(){return this.lookup(v.of("Contents"))}Annots(){return this.lookupMaybe(v.Annots,Z)}BleedBox(){return this.lookupMaybe(v.BleedBox,Z)}TrimBox(){return this.lookupMaybe(v.TrimBox,Z)}ArtBox(){return this.lookupMaybe(v.ArtBox,Z)}Resources(){let e=this.getInheritableAttribute(v.Resources);return this.context.lookupMaybe(e,W)}MediaBox(){let e=this.getInheritableAttribute(v.MediaBox);return this.context.lookup(e,Z)}CropBox(){let e=this.getInheritableAttribute(v.CropBox);return this.context.lookupMaybe(e,Z)}Rotate(){let e=this.getInheritableAttribute(v.Rotate);return this.context.lookupMaybe(e,G)}getInheritableAttribute(e){let t;return this.ascend(i=>{t||(t=i.get(e))}),t}setParent(e){this.set(v.Parent,e)}addContentStrea Line truncated
`;for(let t=0,i=this.subsections.length;t<i;t++){let r=this.subsections[t];e+=`${r[0].ref.objectNumber} ${r.length}
`;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+=Ae(c,t,i),t[i++]=P.Space;let l=String(a.length);i+=Ae(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+=Ae(a,t,i),t[i++]=P.Space;let c=Nt(String(s.ref.generationNumber),5,"0");i+=Ae(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)}};go.create=()=>new go({ref:Y.of(0,65535),offset:0,deleted:!0});go.createEmpty=()=>new go;var mo=go;var zl=class{constructor(e){this.lastXRefOffset=String(e)}toString(){return`startxref
${this.lastXRefOffset}
%%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+=Ae(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}};zl.forLastCrossRefSectionOffset=n=>new zl(n);var gr=zl;var Ul=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}};Ul.of=n=>new Ul(n);var Nd=Ul;var ql=class n extends fr{constructor(e,t,i=!0){super(e.obj({}),i),this.objects=t,this.offsets=this.computeObjectOffsets(),this.offsetsString=this.computeOffsetsString(),this.dict.set(v.of("Type"),v.of("ObjStm")),this.dict.set(v.of("N"),G.of(this.objects.length)),this.dict.set(v.of("First"),G.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=Ae(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+Qr(this.offsets)[1]+Qr(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}};ql.withContextAndObjects=(n,e,t=!0)=>new ql(n,e,t);var Is=ql;var jl=class{constructor(e,t){this.parsedObjects=0,this.shouldWaitForTick=i=>(this.parsedObjects+=i,this.parsedObjects%this.objectsPerTick===0),this.context=e,this.objectsPerTick=t}serializeToBuffer(){return Q(this,void 0,void 0,function*(){let{size:e,header:t,indirectObjects:i,xref:r,trailerDict:o,trailer:s}=yield 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+=Ae(p,c,a),c[a++]=P.Space;let f=String(h.generationNumber);a+=Ae(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 Is?u.getObjectsCount():1;this.shouldWaitForTick(m)&&(yield Ai())}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})}computeBufferSize(){return Q(this,void 0,void 0,function*(){let e=$i.forVersion(1,7),t=e.sizeInBytes()+2,i=mo.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)&&(yield Ai())}let s=t;t+=i.sizeInBytes()+1;let a=Nd.of(this.createTrailerDict());t+=a.sizeInBytes()+2;let c=gr.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)}}};jl.forContext=(n,e)=>new jl(n,e);var Bs=jl;var Wl=class n extends Se{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}};Wl.of=n=>new Wl(n);var Os=Wl;var rP=/\/([^\0\t\n\f\r ]+)[\0\t\n\f\r ]*(\d*\.\d+|\d+)?[\0\t\n\f\r ]+Tf/,M0=class n{constructor(e,t){this.dict=e,this.ref=t}T(){return this.dict.lookupMaybe(v.of("T"),J,K)}Ff(){let e=this.getInheritableAttribute(v.of("Ff"));return this.dict.context.lookupMaybe(e,G)}V(){let e=this.getInheritableAttribute(v.of("V"));return this.dict.context.lookup(e)}Kids(){return this.dict.lookupMaybe(v.of("Kids"),Z)}DA(){let e=this.dict.lookup(v.of("DA"));if(e instanceof J||e instanceof K)return e}setKids(e){this.dict.set(v.of("Kids"),this.dict.context.obj(e))}getParent(){let e=this.dict.get(v.of("Parent"));if(e instanceof Y){let t=this.dict.lookup(v.of("Parent"),W);return new n(t,e)}}setParent(e){e?this.dict.set(v.of("Parent"),e):this.dict.delete(v.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(v.of("T"),K.fromText(e)):this.dict.delete(v.of("T"))}setDefaultAppearance(e){this.dict.set(v.of("DA"),J.of(e))}getDefaultAppearance(){let e=this.DA();return e instanceof K?e.decodeText():e==null?void 0:e.asString()}setFontSize(e){var t;let i=(t=this.getFullyQualifiedName())!==null&&t!==void 0?t:"",r=this.getDefaultAppearance();if(!r)throw new vl(i);let o=us(r,rP);if(!o.match)throw new wl(i);let s=r.slice(0,o.pos-o.match[0].length),a=o.pos<=r.length?r.slice(o.pos):"",c=o.match[1],l=`${s} /${c} ${e} Tf ${a}`;this.setDefaultAppearance(l)}getFlags(){var e,t;return(t=(e=this.Ff())===null||e===void 0?void 0:e.asNumber())!==null&&t!==void 0?t:0}setFlags(e){this.dict.set(v.of("Ff"),G.of(e))}hasFlag(e){return(this.getFlags()&e)!==0}setFlag(e){let t=this.getFlags();this.setFlags(t|e)}clearFlag(e){let t=this.getFlags();this.setFlags(t&~e)}setFlagTo(e,t){t?this.set Line truncated
12 dict begin
begincmap
/CIDSystemInfo <<
/Registry (Adobe)
/Ordering (UCS)
/Supplement 0
>> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000><ffff>
endcodespacerange
${n.length} beginbfchar
${n.map(([e,t])=>`${e} ${t}`).join(`
`)}
endbfchar
endcmap
CMapName currentdict /CMap defineresource pop
end
end`,Qb=(...n)=>`<${n.join("")}>`,jd=n=>Ki(n,4),dP=n=>{if(zf(n))return jd(n);if(Uf(n)){let i=gd(n),r=md(n);return`${jd(i)}${jd(r)}`}let t=`0x${Gi(n)} is not a valid UTF-8 or UTF-16 codepoint.`;throw new Error(t)};var hP=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},ey=n=>{let e=n["OS/2"]?n["OS/2"].sFamilyClass:0;return hP({fixedPitch:n.post.isFixedPitch,serif:1<=e&&e<=7,symbolic:!0,script:e===10,italic:n.head.macStyle.italic})};var z0=class n{static for(e,t,i,r){return Q(this,void 0,void 0,function*(){let o=yield 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 Of(o.sort(Bf),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]=Ki(t[r].id,4);return K.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)}embedFontDict(e,t){return Q(this,void 0,void 0,function*(){let i=yield 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}embedCIDFontDict(e){return Q(this,void 0,void 0,function*(){let t=yield this.embedFontDescriptor(e),i=e.obj({Type:"Font",Subtype:this.isCFF()?"CIDFontType0":"CIDFontType2",CIDToGIDMap:"Identity",BaseFont:this.baseFontName,CIDSystemInfo:{Registry:J.of("Adobe"),Ordering:J.of("Identity"),Supplement:0},FontDescriptor:t,W:this.computeWidths()});return e.register(i)})}embedFontDescriptor(e){return Q(this,void 0,void 0,function*(){let t=yield 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:ey(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)})}serializeFont(){return Q(this,void 0,void 0,function*(){return this.fontData})}embedFontStream(e){return Q(this,void 0,void 0,function*(){let t=e.flateStream(yield this.serializeFont(),{Subtype:this.isCFF()?"CIDFontType0C":void 0});return e.register(t)})}embedUnicodeCmap(e){let t=$b(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}},Dr=z0;var U0=class n extends Dr{static for(e,t,i,r){return Q(this,void 0,void 0,function*(){let o=yield 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]=Ki(a,4)}return this.glyphCache.invalidate(),K.of(i.join(""))}isCFF(){return this.subset.cff}glyphId(e){return e?this.glyphIdMap.get(e.id):-1}serializeFont(){return new Promise((e,t)=>{let i=[];this.subset.encodeStream().on("data",r=>i.push(r)).on("end",()=>e(If(i))).on("error",r=>t(r))})}},Wd=U0;var Hs;(function(n){n.Source="Source",n.Data="Data",n.Alternative="Alternative",n.Supplement="Supplement",n.EncryptedPayload="EncryptedPayload",n.FormData="EncryptedPayload",n.Schema="Schema",n.Unspecified="Unspecified"})(Hs||(Hs={}));var q0=class n{static for(e,t,i={}){return new n(e,t,i)}constructor(e,t,i={}){this.fileData=e,this.fileName=t,this.options=i}embedIntoContext(e,t){return Q(this,void 0,void 0,function*(){let{mimeType:i,descriptio Line truncated
`);n.setDefaultAppearance(o)},Up=(n,e)=>{var t,i,r;let o=xi(e),s=xi(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=ui(c==null?void 0:c.getRotation()),{width:u,height:p}=on(a,h),f=mi(Object.assign(Object.assign({},a),{rotation:h})),m=pe(0,0,0),x=(i=vt(c==null?void 0:c.getBorderColor()))!==null&&i!==void 0?i:m,g=vt(c==null?void 0:c.getBackgroundColor()),b=vt(c==null?void 0:c.getBackgroundColor(),.8),w=(r=o!=null?o:s)!==null&&r!==void 0?r:m;bi(o?e:n.acroField,w);let y={x:0+d/2,y:0+d/2,width:u-d,height:p-d,thickness:1.5,borderWidth:d,borderColor:x,markColor:w};return{normal:{on:[...f,...sa(Object.assign(Object.assign({},y),{color:g,filled:!0}))],off:[...f,...sa(Object.assign(Object.assign({},y),{color:g,filled:!1}))]},down:{on:[...f,...sa(Object.assign(Object.assign({},y),{color:b,filled:!0}))],off:[...f,...sa(Object.assign(Object.assign({},y),{color:b,filled:!1}))]}}},qp=(n,e)=>{var t,i,r;let o=xi(e),s=xi(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=ui(c==null?void 0:c.getRotation()),{width:u,height:p}=on(a,h),f=mi(Object.assign(Object.assign({},a),{rotation:h})),m=pe(0,0,0),x=(i=vt(c==null?void 0:c.getBorderColor()))!==null&&i!==void 0?i:m,g=vt(c==null?void 0:c.getBackgroundColor()),b=vt(c==null?void 0:c.getBackgroundColor(),.8),w=(r=o!=null?o:s)!==null&&r!==void 0?r:m;bi(o?e:n.acroField,w);let y={x:u/2,y:p/2,width:u-d,height:p-d,borderWidth:d,borderColor:x,dotColor:w};return{normal:{on:[...f,...aa(Object.assign(Object.assign({},y),{color:g,filled:!0}))],off:[...f,...aa(Object.assign(Object.assign({},y),{color:g,filled:!1}))]},down:{on:[...f,...aa(Object.assign(Object.assign({},y),{color:b,filled:!0}))],off:[...f,...aa(Object.assign(Object.assign({},y),{color:b,filled:!1}))]}}},jp=(n,e,t)=>{var i,r,o,s,a;let c=xi(e),l=xi(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,w=ui(p==null?void 0:p.getRotation()),{width:y,height:F}=on(u,w),D=mi(Object.assign(Object.assign({},u),{rotation:w})),C=pe(0,0,0),k=vt(p==null?void 0:p.getBorderColor()),E=vt(p==null?void 0:p.getBackgroundColor()),B=vt(p==null?void 0:p.getBackgroundColor(),.8),S={x:b,y:b,width:y-b*2,height:F-b*2},I=ca(x,{alignment:Ue.Center,fontSize:d!=null?d:h,font:t,bounds:S}),O=ca(g,{alignment:Ue.Center,fontSize:d!=null?d:h,font:t,bounds:S}),A=Math.min(I.fontSize,O.fontSize),N=(a=c!=null?c:l)!==null&&a!==void 0?a:C;bi(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,...nu(Object.assign(Object.assign({},q),{color:E,textLines:[I.line]}))],down:[...D,...nu(Object.assign(Object.assign({},q),{color:B,textLines:[O.line]}))]}},Wp=(n,e,t)=>{var i,r,o,s;let a=xi(e),c=xi(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=ui(u==null?void 0:u.getRotation()),{width:g,height:b}=on(h,x),w=mi(Object.assign(Object.assign({},h),{rotation:x})),y=pe(0,0,0),F=vt(u==null?void 0:u.getBorderColor()),D=vt(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 O=su(f,{alignment:n.getAlignment(),fontSize:l!=null?l:d,font:t,bounds:B});C=O.lines,k=O.fontSize}else if(n.isCombed()){let O=zp(f,{fontSize:l!=null?l:d,font:t,bounds:B,cellCount:(o=n.getMaxLength())!==null&&o!==void 0?o:0});C=O.cells,k=O.fontSize}else{let O=ca(f,{alignment:n.getAlignment(),fontSize:l!=null?l:d,font:t,bounds:B});C=[O.line],k=O.fontSize}let S=(s=a!=null?a:c)!==null&&s!==void 0?s:y;bi(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[...w,...ou(I)]},Kp=(n,e,t)=>{var i,r,o;let s=xi(e),a=xi(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.getWidth())!==null&&r!==void 0?r:0,m=ui(h==null?void 0:h.getRotation()),{width:x,height:g}=on(d,m),b=mi(Object.assign(Object.assign({},d),{rotation:m})),w=pe(0,0,0),y=vt(h==null?void 0:h.getBorderColor()),F=vt(h==null?void 0:h.getBackgroundColor()),D=1,C={x:f+D,y:f+D,width:x-(f+D)*2,height:g-(f+D)*2},{line:k,fontSize:E}=ca(p,{alignment:Ue.Left,fontSize:c!=null?c:l,font:t,bounds:C}),B=(o=s!=null?s:a)!==null&&o!==void 0?o:w;bi(s||c!==void 0?e:n.acroField,B,t,E);let S={x:0+f/2,y:0+ Line truncated
`);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}=su(D,{alignment:Ue.Left,fontSize:a!=null?a:c,font:t,bounds:k}),I=[];for(let N=0,q=E.length;N<q;N++){let V=E[N];F.includes(V.text)&&I.push(N)}let O=pe(153/255,193/255,218/255),A=(r=o!=null?o:s)!==null&&r!==void 0?r:g;return bi(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:w,textLines:E,lineHeight:S,selectedColor:O,selectedLines:I,padding:C})]};var du=Wi(Ap(),1);var Hi=class{constructor(e,t,i){this.alreadyEmbedded=!1,T(e,"ref",[[Y,"PDFRef"]]),T(t,"doc",[[We,"PDFDocument"]]),T(i,"embedder",[[Ws,"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)}embed(){return Q(this,void 0,void 0,function*(){this.alreadyEmbedded||(yield this.embedder.embedIntoContext(this.doc.context,this.ref),this.alreadyEmbedded=!0)})}};Hi.of=(n,e,t)=>new Hi(n,e,t);var Me=class{constructor(e,t,i){this.modified=!0,T(e,"ref",[[Y,"PDFRef"]]),T(t,"doc",[[We,"PDFDocument"]]),T(i,"embedder",[[Dr,"CustomFontEmbedder"],[Fr,"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"]),H(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 Fr?this.embedder.encoding.supportedCodePoints:this.embedder.font.characterSet}embed(){return Q(this,void 0,void 0,function*(){this.modified&&(yield this.embedder.embedIntoContext(this.doc.context,this.ref),this.modified=!1)})}};Me.of=(n,e,t)=>new Me(n,e,t);var yi=class{constructor(e,t,i){T(e,"ref",[[Y,"PDFRef"]]),T(t,"doc",[[We,"PDFDocument"]]),T(i,"embedder",[[Us,"JpegEmbedder"],[js,"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)}embed(){return Q(this,void 0,void 0,function*(){if(this.embedder){if(!this.embedTask){let{doc:e,ref:t}=this;this.embedTask=this.embedder.embedIntoContext(e.context,t)}yield this.embedTask,this.embedder=void 0}})}};yi.of=(n,e,t)=>new yi(n,e,t);var vi;(function(n){n[n.Left=0]="Left",n[n.Center=1]="Center",n[n.Right=2]="Right"})(vi||(vi={}));var wi=n=>{H(n==null?void 0:n.x,"options.x",["number"]),H(n==null?void 0:n.y,"options.y",["number"]),H(n==null?void 0:n.width,"options.width",["number"]),H(n==null?void 0:n.height,"options.height",["number"]),H(n==null?void 0:n.textColor,"options.textColor",[[Object,"Color"]]),H(n==null?void 0:n.backgroundColor,"options.backgroundColor",[[Object,"Color"]]),H(n==null?void 0:n.borderColor,"options.borderColor",[[Object,"Color"]]),H(n==null?void 0:n.borderWidth,"options.borderWidth",["number"]),H(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",[[We,"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(Kt.ReadOnly)}enableReadOnly(){this.acroField.setFlagTo(Kt.ReadOnly,!0)}disableReadOnly(){this.acroField.setFlagTo(Kt.ReadOnly,!1)}isRequired(){return this.acroField.hasFlag(Kt.Required)}enableRequired(){this.acroField.setFlagTo(Kt.Required,!0)}disableRequired(){this.acroField.setFlagTo(Kt.Required,!1)}isExported(){return!this.acroField.hasFlag(Kt.NoExport)}enableExporting(){this.acroField.setFlagTo(Kt.NoExport,!1)}disableExporting(){this.acroField.setFlagTo(Kt.NoExport,!0)}needsAppearancesUpdate(){throw new Ze(this.constructor.name,"needsAppearancesUpdate")}defaultUpdateAppearances(e){throw new Ze(this.constructor.name,"defaultUpdateAppearances")}markAsDirty(){this.doc.getForm().markFieldAsDirty(this.ref)}markAsClean(){this.doc.getForm().markFieldAsClean(this.ref)}isDirty(){return this.doc.getForm().fieldIsDirty(this.ref)}createWidget(e){var t;let i=e.textColor,r=e.backgroundColor,o=e.borderColor,s=e.borderWidth,a=rn(e.rotate),c=e.caption,l=e.x,d=e.y,h=e.width+s,u=e.height+s,p=!!e.hidden,f=e.page;hl(a,"degreesAngle",90);let m=bo.create(this.doc.context,this.ref),x=op({x:l,y:d,width:h,height:u},s,a);m.setRectangle(x),f&&m.setP(f);let g=m.getOr Line truncated
`+ln(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=ui(a==null?void 0:a.getRotation()),h=mi(Object.assign(Object.assign({},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:te(0),xSkew:te(0),ySkew:te(0)};i===vi.Center?(f.x+=(u.width-l*2)/2-p.width/2,f.y+=(u.height-l*2)/2-p.height/2):i===vi.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,...kc(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(v.of("Off"),s),a}};var _t=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:v.of("Yes");this.markAsDirty(),this.acroField.setValue(t)}uncheck(){this.markAsDirty(),this.acroField.setValue(v.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",[[Oe,"PDFPage"]]),wi(t),t||(t={}),"textColor"in t||(t.textColor=pe(0,0,0)),"backgroundColor"in t||(t.backgroundColor=pe(1,1,1)),"borderColor"in t||(t.borderColor=pe(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:te(0),hidden:t.hidden,page:e.ref}),d=this.doc.context.register(l.dict);this.acroField.addWidget(d),l.setAppearanceState(v.of("Off")),this.updateWidgetAppearance(l,v.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 W)||s&&!a.has(s))return!0}return!1}defaultUpdateAppearances(){this.updateAppearances()}updateAppearances(e){var t;H(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:v.of("Yes");a&&this.updateWidgetAppearance(s,a,e)}this.markAsClean()}updateWidgetAppearance(e,t,i){let r=i!=null?i:Up,o=Yt(r(this,e));this.updateOnOffWidgetAppearance(e,t,o)}};_t.of=(n,e,t)=>new _t(n,e,t);var Fi=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.getValues(),t=new Array(e.length);for(let i=0,r=e.length;i<r;i++)t[i]=e[i].decodeText();return t}setOptions(e){T(e,"options",[Array]);let t=new Array(e.length);for(let i=0,r=e.length;i<r;i++)t[i]={value:K.fromText(e[i])};this.acroField.setOptions(t)}addOptions(e){T(e,"options",["string",Array]);let t=Array.isArray(e)?e:[e],i=this.acroField.getOptions(),r=new Array(t.length);for(let o=0,s=t.length;o<s;o++)r[o]={value:K.fromText(t[o])};this.acroField.setOptions(i.concat(r))}select(e,t=!1){T(e,"options",["string",Array]),T(t,"merge",["boolean"]);let i=Array.isArray(e)?e:[e],r=this.getOptions();i.find(a=>!r.includes(a))&&this.enableEditing(),this.markAsDirty(),(i.length>1||i.length===1&&t)&&this.enableMultiselect();let s=new Array(i.length);for(let a=0,c=i.length;a<c;a++)s[a]=K.fromText(i[a]);if(t){let a=this.acroField.getValues();this.acroField.setValues(a.concat(s))} Line truncated
`)}}),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 Sw.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)}},Su=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 W?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(v.of(e),i);return}this.dict.delete(v.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 G?e.asNumber():null}set count(e){if(e===null){this.dict.delete(v.of("Count"));return}this.dict.set(v.of("Count"),G.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 J||e instanceof K)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(v.of("Title"),K.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=K.fromText(t);else{i=Z.withContext(this.doc.context),i.push(this.doc.getPage(t[0]).ref),i.push(v.of(t[1]));for(let s of t.slice(2))i.push(typeof s=="number"?G.of(s):He)}let r=this.doc.context.getObjectRef(this.dict);if(!r)throw new Error("Could not get ref for parent");let o={Title:K.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.nextSibling.prevSibling=this.prevSibling),this.parent&&(this.is(this.parent.firstChild)&&(this.parent.firstChild=this.nextSibling),this.is(this.parent.lastChild)&&(this.parent.lastChild=this.prevSibling)),this}removeAndLiftUpChildren(){if(this.remove(),this.firstChild){if(!this.lastChild)throw new Error("Last child is not set despite having children");this.iterChildren(e=>{e.parent=this.parent}),this.prevSibling?(this.prevSibling.nextSibling=this.firstChild,this.firstChild.prevSibling=this.prevSibling):this.parent&&(this.parent.firstChild=this.firstChild,this.firstChild.prevSibling=null),this.nextSibling?(this.nextSibling.prevSibling=this.lastChild,this.lastChild.nextSibling=this.nextSibling):this.parent&&(this.parent.lastChild=this.lastChild,this.lastChild.nextSibling=null)}}iterChildren(e){let t=this.firstChild;for(;t;)e(t),t=t.nextSibling}async iterChildrenAsync(e){let t=this.firstChild;f Line truncated
`),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 Pt.HoverPopover(t,r,200);s.hoverEl.addClass("pdf-plus-bib-popover");let a=s.hoverEl.createDiv();s.addChild(new zg(this,e,a))};this.plugin.requireModKeyForLinkHover(Eu.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(Pt.Platform.isDesktopApp&&t.vault.adapter instanceof Pt.FileSystemAdapter&&s){let a=t.vault.adapter.getFullPath(s);await Pt.FileSystemAdapter.mkdir(a);let c=s+`/${ug()}.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 Pt.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 w=b.match(/\d{4}/);if(w){g.year=w[0];break}}h(m)}h(null)})})}return null}on(e,t,i){return this.events.on(e,t,i)}};Eu.HOVER_LINK_SOURCE_ID="pdf-plus-citation-link";var pn=Eu,Hg=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:Yc(a),items:l}}},zg=class extends ke{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}),Pt.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 Pt.ButtonComponent(i).setButtonText("Google Scholar").onClick(()=>{let r=this.bib.getGoogleScholarSearchUrlFromDest(this.destId);if(!r){new Pt.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 Pt.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 Tu=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=Iw.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())}})}},Au=class extends Tu{async getLinkText(e){var c,l,d;let{lib:t,child:i,targetEl:r}=this;if(!Ci(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.pdfJsDestArrayToSubpath(s,o),a===null?null:((d=(l=this.file)==null?void 0:l.path)!=null?d:"")+a}onHoverPopoverSet(e){let t=e.hoverEl,i=this.getDest();typeof i=="string"&&(t.dataset.dest=i)}},nd=class nd extends Au{constructor(e,t,i){super(e,t,i.container),this.linkAnnotationElement=i}static registerEvents(e,t,i){return i.data.subtype==="Link"?new nd(e,t,i):null}async getLinkText(e){var t,i;if(this.plugin.settings.actionOnCitationHover==="google-scholar-popover"&&this.lib.requirePluginNewerThan("surfing","0.9.5")){let r=this.getDest();if(this.lib.isCitationId(r)&&((t=this.child.pdfViewer.pdfViewer)==null?void 0:t.pdfDocument)){let s=(i=this.child.bib)==null?void 0:i.getGoogleScholarSearchUrlFromDest(r);if(s)return s}}return super.getLinkText(e)}getDest(){return this.linkAnnotationElement.data.dest}useModifierKey(){return this.plugin.settings.clickPDFInternalLinkWithModifierKey}shouldShowHoverPopover(){retu Line truncated
> {{text}}
`},{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:!0,executeCommandWhenTargetNotIdentified:!0,commandToExecuteWhenTargetNotIdentified:"switcher:open",autoPasteTargetDialogTimeoutSec:20,autoCopyToggleRibbonIcon:!0,autoCopyIconName:"highlighter",autoFocusToggleRibbonIcon:!0,autoFocusIconName:"zap",autoPasteToggleRibbonIcon:!0,autoPasteIconName:"clipboard-paste",viewSyncFollowPageNumber:!0,viewSyncPageDebounceInterval:.3,openAfterExtractPages:!0,howToOpenExtractedPDF:"tab",warnEveryPageDelete:!1,warnBacklinkedPageDelete:!0,extractPageInPlace:!1,askExtractPageInPlace:!0,pageLabelUpdateWhenInsertPage:"keep",pageLabelUpdateWhenDeletePage:"keep",pageLabelUpdateWhenExtractPage:"keep",askPageLabelUpdateWhenInsertPage:!0,askPageLabelUpdateWhenDeletePage:!0,askPageLabelUpdateWhenExtractPage:!0,copyOutlineAsListFormat:"{{linkWithDisplay}}",copyOutlineAsListDisplayTextFormat:"{{text}}",copyOutlineAsHeadingsFormat:`{{text}}
{{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:"",autoCheckForUpdates:!0,fixObsidianTextSelectionBug:!0};function uC(n){return Jn.hasOwnProperty(n)}var _n=Bt("Mod").toLowerCase(),Lu=class extends ge.PluginSettingTab{constructor(t){super(t.app,t);this.plugin=t;this.events=new ge.Events;this.component=new ge.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 ge.Setting(this.contentEl);return t&&(this.items[t]=i,this.component.registerDomEvent(i.settingEl,"contextmenu",r=>{r.preventDefault(),new qg.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 ge.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,ge.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 qg.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,ge.setIcon)(c,r);let l=a.createDiv("header-title");l.setText(t),(0,ge.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)):uC(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}addTextSetting(t,i,r){let o=this.addSetting(t).addText(s=>{s.setValue(this.plugin.settings[t]).setPlaceholder(i!=null?i:"").then(a=>{i&&(a.inputEl.size=Math.max(a.inputEl.size,a.inputEl.placeholder.length))}).onChange(async a=>{this.plugin.settings[t]=a,await this.plugin.saveSettings()}),r&&(this.component.registerDomEvent(s.inputEl,"blur",()=>{r(o)}),this.component.registerDomEvent(s.inputEl,"keypress",a=>{a.key==="Enter"&&r(o)}))});return o}addTextAreaSetting(t,i,r){return this.addSetting(t).addTextArea(o=>{o.setValue(this.plugin.settings[t]).setPlaceholder(i!=null?i:"").onChange(async s=>{this.plugin.settings[t]=s,await this.plugin.saveSettings()}),r&&this.component.registerDomEvent(o.inputEl,"blur",r)})}addNumberSetting(t){return this.addSetting(t).addText(i=>{i.setValue(""+this.plugin.settings[t]).setPlaceholder(""+Jn[t]).then(r=>r.inputEl.type Line truncated
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 ge.MarkdownRenderer.render(this.app,Array.isArray(t)?t.join(`
`):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=o;return this.addSetting().addText(a=>{a.setPlaceholder("Color name (case-insensitive)").then(c=>{c.inputEl.size=c.inputEl.placeholder.length,(0,ge.setTooltip)(c.inputEl,"Color name (case-insensitive)")}).setValue(r).onChange(async c=>{if(c in i){new ge.Notice("This color name is already used."),a.inputEl.addClass("error");return}a.inputEl.removeClass("error"),delete i[r];for(let l of["defaultColor","backlinkHoverColor"]){let d=this.items[l];if(d){let h=d.components[0].selectEl.querySelector(`:scope > option:nth-child(${t+2})`);h&&(h.value=c,h.textContent=c)}}this.plugin.settings.defaultColor===r&&(this.plugin.settings.defaultColor=c),r=c,i[r]=o,await this.plugin.saveSettings(),this.plugin.loadStyle()})}).addColorPicker(a=>{a.setValue(o),a.onChange(async c=>{s=o,o=c,i[r]=o,await this.plugin.saveSettings(),this.plugin.loadStyle()})}).addExtraButton(a=>{a.setIcon("rotate-ccw").setTooltip("Return to previous color").onClick(async()=>{o=s,i[r]=o,await this.plugin.saveSettings(),this.plugin.loadStyle(),this.redisplay()})}).addExtraButton(a=>{a.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,ge.setTooltip)(m.inputEl,s.name.placeholder)}).setValue(u).onChange(async m=>{if(t.some(g=>a(g)===m)){new ge.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,ge.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,ge.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 ge.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.setButtonText("Open page preview settings").onClick(()=>{this.app.setting.openTabById("page-preview")})})}addRequireModKeyOnHoverSetting(t){let i=this.app.workspace.hoverLinkSources[t].display,r=this.plugin.requireModKeyForLinkHover(t);return this.addSetting().setName(`Require ${_n} key while hovering`).setDesc(`Currently ${r?"required":"not required"}. You can toggle this on and off in the core Page Preview plugin settings > ${i}.`).then(o=>this.addPagePreviewSettingButton(o))}addIconSetting(t,i){let r=a=>a.startsWith("lucide-")?a.slice(7):a,o=a=>a.startsWith("lucide-")?a:"lucide-"+a,s=a=>{var d;let c=(d=a.controlEl.querySelector(":scope>.icon-preview"))!=null?d:a.controlEl.createDiv("icon-preview");(0,ge.setIcon)(c,o(this.plugin.settings[t]));let l=a.components[0];(!i||this.plugin.settings[t])&&!c.childElementCount?(l.inputEl.addClass("error"),(0,ge.setTooltip)(l.inputEl,"No icon found")):(l. Line truncated
`)),this.component.registerDomEvent(d.inputEl,"focusout",async()=>{let h=d.inputEl.value;this.plugin.settings.externalURIPatterns=h.split(`
`).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 Hc(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("Use motion keys to adjust 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 mobile, word-wise motions (`w`/`e`/`b`) might not work as expected around punctuations. Contributions to fix this are welcome!"],d.descEl)}),this.addHeading("Outline mode","vim-outline"),this.addToggleSetting("enableVimOutlineMode").setName("Enter outline mode when opening PDF outline view").then(d=>{this.renderMarkdown(["If enabled, you will enter the outline mode by opening the PDF outline view (from the icon in the toolbar or by `<Tab>`), and you can use the following keybindings, similarly to [Zathura](https://pwmt.org/projects/zathura/)'s index mode.","","- `j`: Move down","- `k`: Move up","- `h`: Collapse & move to parent entry","- `l`: Expand entry & move to child entry","- `H`: Collapse all entries","- `L`: Expand all entries","- `<CR>/<Space>`: Open the selected entry (`<CR>`=`Enter`)","- `<Esc>`: Close sidebar and go back to normal mode","","If disabled, you can use j/k/h/l/HLine truncated
: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
`,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())}}],yC=(n,e=12,t=!0)=>(n=n.replace(new RegExp(`^ {${e}}`,"gm"),"").replace(/^\s*/,""),t?n.replace(/([<>])/g,"\\$1"):n),Yr=(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 Zu=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=Qw(this.vim),this.suggest=new Qg(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,rs.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(!rs.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 rs.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(`
`).replace(/\\\n/g,"").split(`
`)}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 rs.Notice(t):r==="console.error"?console.error(t):r==="console.warn"&&console.warn(t)}},Qg=class extends Nr{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 Yu=class extends ke{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&&Dt(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(Cg(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&&!Sg(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=Wn(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]]=[...xu(this.pageView,[{x:d.left,y:d.bottom},{x:d.right,y:d.top}])];return{from:h,to:u}}};var _u=class n extends ke{constructor(t,i){super(t);this._structureParser=null;this.viewer=i,this.vimScope=new zu(this.viewer.scope),this.vimScope.registerKeymaps(["normal","visual","outline"],{":":()=>this.enterCommandMode(),"<Tab>":()=>{if(this.obsidianViewer){let r=this.obsidianViewer.pdfSidebar;r.isOpen&&r.active===2?r.close():r.switchView(2,!0)}},"<S-Tab>":()=>{if(this.obsidianViewer){let r=this.obsidianViewer.pdfSidebar;r.isOpen&&r.active===1?r.close():r.switchView(1,!0)}},f:()=>this.commandLineMode.executeCommand("hint")}),this.vimScope.registerKeymaps(["normal","visual","outline"],{j:r=>this.scroll.scrollTo("down",r),k:r=>this.scroll.scrollTo("up",r),h:r=>this.scroll.scrollTo("left",r),l:r=>this.scroll.scrollTo("right",r),J:ba(()=>{var r;return(r=this.pdfViewer)==null?void 0:r.nextPage()}),K:ba(()=>{var r;return(r=this.pdfViewer)==null?void 0:r.previousPage()}),gg:()=>this.pdfViewer&&(this.pdfViewer.currentPageNumber=1),G:r=>this.pdfViewer&&(this.pdfViewer.currentPageNumber=r!=null?r:this.pdfViewer.pagesCount),0: Line truncated
${i.map(l=>"- "+l.path).join(`
`)}
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 os.FileView&&r.view.file&&r.view.file!==e){t=r.view.file;break}}return t}};var Qu=class extends Be{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=gu(t,i.startContainer),o=gu(t,i.endContainer);if(r&&o){let s=r.dataset.idx,a=o.dataset.idx,c=mu(r,i.startContainer,i.startOffset),l=mu(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=Gc({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=Vr(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 ad(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 qi.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,w,y;let u=t.getPage(s);if(typeof h!="string"){let F=ga(a).get("annotation");h=typeof F=="string"&&((w=(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:w.str),h=this.lib.toSingleLine(h||"")}return new ad(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{template:i,colorName:r,writeFile:o}}getAnnotationLinkInfo(){let t=this.plugin.lastAnnotationPopupChild;if(!t)return null;let i=t.activeAnnotationPopupEl;if(!i)return null;let r=i.querySelector(".popupMeta div.clickable-icon:has(svg.lucide-copy)");if(!r)return null;let o=this.lib.getColorPaletteAssociatedWithNode(r),s;o?s=this.settings.copyCommands[o.actionIndex].template:s=this.settings.copyCommands[this.settings.defaultColorPaletteActionIndex].template;let a=this.lib.getAnnotationInfoFromPopupEl(i);if(!a)return null;let{page:c,id:l}=a;return{child:t,copyButtonEl:r,template:s,page:c,id:l}}copyLinkToSelection(t,i,r,o){let s=this.getTemplateVariables(r?{color:r.toLowerCase()}:{});if(s){let{child:a,file:c,subpath:l,page:d,text:h}=s;if(!h)if(this.settings.useAnotherCopyTemplateWhenNoSelection)i.copyFormat=this.settings.copyTemplateWhenNoSelection;else return!1;return t||(async()=>{var m;let u=this.g Line truncated
`+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})})`+`
`+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 qi.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 qi.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 qi.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 qi.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-last-active-and-open"?r?s=r:o&&(s=i):t==="last-active-and-open-then-last-paste"&&(o?s=i:r&&(s=r)),s&&s.extension==="md"?s:null}async prepareMarkdownLeafForPaste(t){let i=this.lib.workspace.getExistingLeafForMarkdownFile(t),r=!!i;if(!i&&this.settings.openAutoFocusTargetIfNotOpened){let o=this.settings.howToOpenAutoFocusTargetIfNotOpened;if(o==="hover-editor"){let s=await this.lib.workspace.hoverEditor.createNewHoverEditorLeaf({hoverPopover:null},null,t.path,"");s&&(i=s)}else i=this.lib.workspace.getLeaf(o),await i.openFile(t,{active:!1});if(i&&this.settings.openAutoFocusTargetInEditingView){await this.lib.workspace.ensureViewLoaded(i);let s=i.view;s instanceof qi.MarkdownView&&(await s.setState({mode:"source"},{history:!1}),s.setEphemeralState({focus:!1}))}}return i&&(await this.lib.workspace.ensureViewLoaded(i),this.lib.workspace.hoverEditor.postProcessHoverEditorLeaf(i),this.settings.close Line truncated
`:`
`),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?`
`:`
`),a+=t,a)),o&&activeWindow.setTimeout(async()=>{o.view instanceof qi.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,`
`),l=t.replace(/\r\n/g,`
`);c===l&&(this.plugin.lastPasteFile=s.file,i==null||i()),s instanceof qi.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 $u=class extends Be{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=Wn(t,o);m?u.setStart(m.node,m.offset):u.setStartBefore(t)}else u.setStartBefore(t);if(i===s){let m=Wn(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 ef=require("obsidian");var tf=class extends Be{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 ef.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.clearTextHighlight()},t*1e3),s.unload())})}else if(((r=e.subpathHighlight)==null?void 0:r.type)==="annotation"){let s=new ef.Component;s.load(),this.lib.onAnnotationLayerReady(e.pdfViewer,s,a=>{var d;if(((d=e.subpathHighlight)==null?void 0:d.type)!=="annotation")return;let{page:c,id:l}=e.subpathHighlight;c===a&&(e.highlightAnnotation(c,l),t>0&&setTimeout(()=>e.clearAnnotationHighlight(),t*1e3),s.unload())})}else if(((o=e.subpathHighlight)==null?void 0:o.type)==="rect"){let s=new ef.Component;s.load(),this.lib.onPageReady(e.pdfViewer,s,a=>{var d;if(((d=e.subpathHighlight)==null?void 0:d.type)!=="rect")return;let{page:c,rect:l}=e.subpathHighlight;c===a&&(this.highlightRect(e,c,l),t>0&&setTimeout(()=>{this.clearRectHighlight(e)},t*1e3),s.unload())})}}highlightRect(e,t,i){if(this.clearRectHighlight(e),1<=t&&t<=e.pdfViewer.pagesCount){let r=e.getPage(t);r!=null&&r.div.dataset.loaded&&(e.rectHighlight=this.pl Line truncated
`);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 sf=class extends Be{constructor(t){super(t);this.plugin=t;this.geometry=new $u(t),this.viewer=new tf(t),this.writeFile=new rf(t),this.extract=new of(t)}};var Qe=require("obsidian");function EC(n){return["tab","split","window"].contains(n)}function TC(n){return["right","left","down","up"].contains(n)}function u1(n){return["right-sidebar","left-sidebar"].contains(n)}var af=class extends Be{constructor(...e){super(...e),this.hoverEditor=new tm(...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 Qe.MarkdownView?this.lib.getAllPDFEmbedsInMarkdownView(i).forEach(e):this.lib.isCanvasView(i)?this.lib.getAllPDFEmbedsInCanvasView(i).forEach(e):this.lib.isExcalidrawView(i)&&this.lib.getAllPDFEmbedsInExcalidrawView(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 Qe.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)):this.lib.isExcalidrawView(i)&&this.lib.getAllPDFEmbedsInExcalidrawView(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}getActiveExcalidrawView(){var t;let e=(t=this.app.workspace.activeLeaf)==null?void 0:t.view;return e&&this.lib.isExcalidrawView(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):u1(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 Qe.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,Qe.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 Qe.WorkspaceTabs&&c.parentSplit.children.some(u=>{if(u instanceof Qe.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||(u1(this.settings.paneTypeForFirstMDLeaf)&&this.settings.singleMDLeafInSidebar&&s&&this.isInSidebar(s)?o=(a=this.getExistingMarkdownLeafInSidebar(this.settings.paneTypeForFirstMDLeaf))!=null?a:this.lib.workspace.getNewLeafInSidebar(this.settings.paneTypeForFirstMDLeaf):o=s?this.app.workspace.createLeafInParent(s,-1):this.getLeaf(this.plugin.settings.paneTypeForFirstMDLeaf)),o}isInSidebar(e){let t=e.getRoot();return t===this.app.workspace.rightSplit||t===this.app.workspace.leftSplit}getLeaf(e){return e===""&&(e=!1),typeof e=="boolean"||EC(e)?this.app.workspace.getLeaf(e):TC(e)?this.getLeafBySplit(e):this.getLeafInSidebar(e)}getLeafBySplit(e){let t=this.app.workspace. Line truncated
`):this.app.fileManager.generateMarkdownLink(e[0],"");await navigator.clipboard.writeText(i),new _r.Notice(`${this.plugin.manifest.name}: Copied!`)}),new _r.ButtonComponent(t).setButtonText("Close").onClick(()=>{this.close()})})}};var cf=class extends Be{constructor(...e){super(...e);let t=[{id:"copy-link-to-selection",name:"Copy link to selection or annotation",checkCallback:i=>this.copyLink(i,!1)},{id:"rectangular-selection",name:"Start rectangular selection",checkCallback:i=>this.copyEmbedLinkToRectangularSelection(i,!1)},{id:"context-menu",name:"Show context menu at selection",checkCallback:i=>this.showContextMenu(i)},{id:"extract-annotation-and-copy-links",name:"Extract & copy annotations in this PDF",checkCallback:i=>this.extractHighlightedText(i)},{id:"copy-link-to-page-view",name:"Copy link to current page view",checkCallback:i=>this.copyLinkToPageView(i)},{id:"outline",name:"Show outline",checkCallback:i=>this.showOutline(i)},{id:"thumbnail",name:"Show thumbnail",checkCallback:i=>this.showThumbnail(i)},{id:"close-sidebar",name:"Close PDF sidebar",checkCallback:i=>this.closeSidebar(i)},{id:"toggle-sidebar",name:"Toggle PDF sidebar",checkCallback:i=>this.toggleSidebar(i)},{id:"fit-width",name:"Fit width",checkCallback:i=>this.setScaleValue(i,"page-width")},{id:"fit-height",name:"Fit height",checkCallback:i=>this.setScaleValue(i,"page-height")},{id:"zoom-in",name:"Zoom in",checkCallback:i=>this.zoom(i,!0)},{id:"zoom-out",name:"Zoom out",checkCallback:i=>this.zoom(i,!1)},{id:"adapt-to-theme",name:"Adapt to theme",checkCallback:i=>this.toggleAdaptToTheme(i,!0)},{id:"not-adapt-to-theme",name:"Don't adapt to theme",checkCallback:i=>this.toggleAdaptToTheme(i,!1)},{id:"toggle-adapt-to-theme",name:'Toggle "adapt to theme"',checkCallback:i=>this.toggleAdaptToTheme(i)},{id:"go-to-page",name:"Go to page",checkCallback:i=>this.focusAndSelectPageNumberEl(i)},{id:"copy-format-menu",name:"Show copy format menu",checkCallback:i=>this.showCopyFormatMenu(i)},{id:"display-text-format-menu",name:"Show display text format menu",checkCallback:i=>this.showDisplayTextFormatMenu(i)},{id:"enable-pdf-edit",name:"Enable PDF edit",checkCallback:i=>this.setWriteFile(i,!0)},{id:"disable-pdf-edit",name:"Disable PDF edit",checkCallback:i=>this.setWriteFile(i,!1)},{id:"toggle-auto-focus",name:"Toggle auto-focus",callback:()=>this.toggleAutoFocus()},{id:"toggle-auto-paste",name:"Toggle auto-paste",callback:()=>this.toggleAutoPaste()},{id:"toggle-auto-copy",name:"Toggle auto-copy",callback:()=>this.plugin.autoCopyMode.toggle()},{id:"add-page",name:"Add new page at the end",checkCallback:i=>this.addPage(i)},{id:"insert-page-before",name:"Insert page before this page",checkCallback:i=>this.insertPage(i,!0)},{id:"insert-page-after",name:"Insert page after this page",checkCallback:i=>this.insertPage(i,!1)},{id:"delete-page",name:"Delete this page",checkCallback:i=>this.deletePage(i)},{id:"extract-this-page",name:"Extract this page to a new file",checkCallback:i=>this.extractThisPage(i)},{id:"divide",name:"Divide this PDF into two files at this page",checkCallback:i=>this.dividePDF(i)},{id:"edit-page-labels",name:"Edit page labels",checkCallback:i=>this.editPageLabels(i)},{id:"copy-outline-as-list",name:"Copy PDF outline as markdown list",checkCallback:i=>this.copyOutline(i,"list")},{id:"copy-outline-as-headings",name:"Copy PDF outline as markdown headings",checkCallback:i=>this.copyOutline(i,"heading")},{id:"add-outline-item",name:"Add to outline (bookmark)",checkCallback:i=>this.addOutlineItem(i)},{id:"create-new-note",name:"Create new note for auto-focus or auto-paste",callback:()=>this.createNewNote()},{id:"copy-debug-info",name:"Copy debug info",callback:()=>this.copyDebugInfo()},{id:"load-debug-info",name:"Load debug info",checkCallback:i=>this.loadDebugInfo(i)},{id:"create-pdf",name:"Create new PDF",callback:()=>this.createPDF()},{id:"import",name:"Import this PDF into vault",checkCallback:i=>this.importExternalFileIntoVault(i)},{id:"open-external",name:"Open this PDF in the original location",checkCallback:i=>this.openExternalSource(i)},{id:"create-dummy",name:"Create dummy file for external PDF",callback:()=>this.createDummyForExternalPDF()},{id:"restore-default",name:"Restore default settings",callback:()=>new lf(this.plugin).open()},{id:"open-dataview-inline-fields-modal",name:"Check Dataview inline fields",checkCallback:i=>this.plugin.requiresDataviewInlineFieldsMigration?(i||Aa.open(this.plugin),!0):!1}];this.commands={};for(let i of t)this.commands[i.id]=i}registerCommands(){Object.values(this.commands).forEach(e=>{this.plugin.addCommand(this.plugin.obsidianHasFocusBug?this.restorePDFLeafFocus(e):e)})}restorePDFLeafFocus(e){let t=e.checkCallback;if(!t)return e;let i=null;return{...e,checkCallback:r=>{var o,s;return r?(i=(s=(o=this.lib.workspace.getActivePDFView())==null?void 0:o.leaf)!=null?s:null,t(r)):(i&&i!==this.app.workspace.activeLeaf&&(this.app.workspace.setActiveLeaf(i,{focus:!0}),i=null),t(r))}}}getCommand(e){return Line truncated
`:t==="heading"&&(d+="#".repeat(f.depth+c-1)+` ${w}
`)}}}),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 jr(this.plugin,"Add to outline").ask().then(async({title:a})=>{let c=await Ge.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 sd(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()+`
`);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 yg(this.app),t=Object.assign({},this.settings,{author:"*".repeat(this.settings.author.length)}),i=vg(this.app),r=this.plugin.domManager.styleEl.textContent,o=`#### Obsidian debug info
`;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
`,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){console.error(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 Fa(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||Ru(this.plugin,t,r),!0)}};var ii=require("obsidian");var df=class extends Be{constructor(...e){super(...e),this.fileOperator=new nm(this.plugin),this.linkUpdater=new rm(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=fg(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{}})}},nm=class extends Be{constructor(...e){super(...e),this.pageLabelUpdater=new om(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 ii.TFile)return i||new ii.Notice(`${this.plugin.manifest.name}: File already exists: ${e}`),await this.app.vault.modifyBinary(o,r),o;if(o===null){let s=(0,ii.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 Ge.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());for(let c of s)r.addPage(c);let a=await this.write(e.path,r,!0);return a===null?null:(await this.app.fileManager.trashFile(t),a)}async extractPages(e,t,i,r,o,s){if(t.length===0)throw new Error("No pages to extract");return s?await this.extractPagesInPlace(e,t,i,r,o):await this.extractPagesAsNewFile(e,t,i,r,o)}async extractPagesInPlace(e,t,i,r,o){let[s,a]=await Promise.all([this.read(e),this.read(e)]),c=[];for(let h=1;h<=s.getPageCount();h++)t.includes(h)||c.push(h);this.pageLabelUpdater.removePages(s,t,o),this.pageLabelUpdater.removePages(a,c,o);for(let h=s.getPageCount();h>=1;h--)t.includes(h)?s.removePage(h-1):a.removePage(h-1);await Promise.all([s,a].map(async h=>{await(await Ge.fromDocument(h,this.plugin)).prune()}));let[l,d]=await Promise.all([this.write(e.path,s,!0),this.write(i,a,r)]);return d}async extractPagesAsNewFile(e,t,i,r,o){let s=await this.read(e),a=[];for(l Line truncated
`)}}return f})}else{let p=e.key;await this.app.fileManager.processFrontMatter(o,f=>{f[p]=u})}}},om=class extends Be{addPage(e){}insertPage(e,t,i){Ui.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){Ui.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 uf=require("obsidian");var sm=class{constructor(e){wf(this,"value");wf(this,"next");this.value=e}},ni,ss,as,cd=class{constructor(){mn(this,ni);mn(this,ss);mn(this,as);this.clear()}enqueue(e){let t=new sm(e);qe(this,ni)?(qe(this,ss).next=t,Lt(this,ss,t)):(Lt(this,ni,t),Lt(this,ss,t)),Ff(this,as)._++}dequeue(){let e=qe(this,ni);if(e)return Lt(this,ni,qe(this,ni).next),Ff(this,as)._--,e.value}peek(){if(qe(this,ni))return qe(this,ni).value}clear(){Lt(this,ni,void 0),Lt(this,ss,void 0),Lt(this,as,0)}get size(){return qe(this,as)}*[Symbol.iterator](){let e=qe(this,ni);for(;e;)yield e.value,e=e.next}*drain(){for(;qe(this,ni);)yield this.dequeue()}};ni=new WeakMap,ss=new WeakMap,as=new WeakMap;function am(n){f1(n);let e=new cd,t=0,i=()=>{t<n&&e.size>0&&(t++,e.dequeue()())},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)),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){f1(c),n=c,queueMicrotask(()=>{for(;t<n&&e.size>0;)i()})}},map:{async value(c,l){let d=c.map((h,u)=>this(l,h,u));return Promise.all(d)}}}),a}function f1(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 hf=class hf extends uf.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 hf.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}};hf.limit=am(uf.Platform.isMobile?3:10);var Jr=hf;var ff=class extends Be{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 Qn=require("obsidian");var pf=class extends Be{async createDummyFilesInFolder(e,t){if(!!!this.app.vault.getFolderByPath(e))try{await this.app.vault.createFolder(e)}catch(r){return console.error(`${this.plugin.manifest.name}: Failed to create folder "${e}" due to the following error: `,r),[]}return await Promise.all(t.map(async r=>{let o=r.split("/").pop().replace(/%20/g," ");Qn.Platform.isWin&&(o=o.replace(/\?/g," "));let s=(0,Qn.normalizePath)(e+"/"+o);s.endsWith(".pdf")&&(s=s.slice(0,-4));let a=this.app.vault.getAvailablePath(s,"pdf");try{return await this.app.vault.create(a,r)}catch(c){throw console.error(`${this.plugin.manifest.name}: Failed to create a dummy file "${a}" due to the following error: `,c),c}}))}async createDummyFilesFromObsidianUrl(e){let t=e["create-dummy"].replace(/^.*((https?)|(file):\/\/)/,"$1"),i=new Fa(this.plugin);if(i.source=t.startsWith("http")?"web":"file",i.uris=[t],"folder"in e){let r=e.folder;i.folderPath=(0,Qn.normalizePath)(r) Line truncated
`),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
`).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,Qn.normalizePath)(((i=e==null?void 0:e.parent)!=null?i:this.app.vault.getRoot()).path+"/"+t.slice(1)):(0,Qn.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 gf=class{constructor(e){this.utils=Tg;this.PDFCroppedEmbed=Jr;this.PDFOutlines=Ge;this.NameTree=wa;this.NumberTree=Wr;this.PDFNamedDestinations=Pa;this.PDFPageLabels=Ui;this.app=e.app,this.plugin=e,this.commands=new cf(e),this.copyLink=new Qu(e),this.highlight=new sf(e),this.workspace=new af(e),this.composer=new df(e),this.dummyFileManager=new pf(e),this.speech=new ff(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 qc(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("."+ti.CLS);return i&&(r=ti.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 ti.elInstanceMap)if(e.contains(t))return i;return null}getPDFViewerChildAssociatedWithNode(e){let t,i=e.instanceOf(HTMLElement)?e:e.parentElement;if(i){let r=i.closest(".pdf-container");r&&(t=this.plugin.pdfViewerChildren.get(r))}return t||this.workspace.iteratePDFViewerChild(r=>{!t&&r.containerEl.contains(e)&&(t=r)}),t!=null?t:null}getPDFViewerChildFromSelection(e){let t=e.rangeCount>0?e.getRangeAt(0):null;return t?this.getPDFViewerChildAssociatedWithNode(t.startContainer):null}async destIdToSubpath(e,t){let i=await t.getDestination(e);return i?this.pdfJsDestArrayToSubpath(i,t):null}async pdfJsDestArrayToSubpath(e,t){let i=await t.getPageIndex(e[0]);return this.destArrayToSubpath(this.normalizePDFJsDestArray(e,i+1))}normalizePDFJsDestArray(e,t){return[t-1,e[1].name,...e.slice(2)]}normalizePdfLibDestArray(e,t){let i=e.get(0);if(!(i instanceof Y))return null;let r=t.getPages().findIndex(s=>s.ref===i);if(r===-1)return null;let o=e.get(1);return o instanceof v?[r,o.decodeText(),...e.asArray().slice(2).map Line truncated
`))}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||pa(r,t)}requirePluginNewerThan(e,t){let i=this.app.plugins.plugins[e];if(!i)return!1;let r=i.manifest.version;return pa(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 Yc(e,this.plugin.settings.removeWhitespaceBetweenCJChars)}async write(e,t,i){let r=this.app.vault.getAbstractFileByPath(e);if(r instanceof ve.TFile)return i||new ve.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,ve.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)}async checkForUpdates(e){var u,p;let{result:t,error:i}=await OC((0,ve.requestUrl)({url:"https://api.github.com/repos/ryotaushio/obsidian-pdf-plus/releases?per_page=10&page=1",headers:{accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}));if(i||t.status!==200)return i&&console.error(i),{success:!1,shouldUpdate:!1,detail:"Failed to connect to GitHub to check for updates."};let{result:r,error:o}=BC(()=>t.json);if(o)return console.error(o),{success:!1,shouldUpdate:!1,detail:"Failed to parse JSON releases from GitHub."};if(!Array.isArray(r)||r.length===0)return{success:!1,shouldUpdate:!1,detail:"No releases found on GitHub."};r.sort((f,m)=>new Date(m.published_at).getTime()-new Date(f.published_at).getTime());let s=(u=e==null?void 0:e.currentVersion)!=null?u:this.plugin.manifest.version,a=r.filter(f=>!f.prerelease&&!f.draft&&pa(f.tag_name,s));if(a.length===0)return{success:!0,shouldUpdate:!1,detail:"Already up-to-date."};if(a.some(f=>{let m=f.body.split(`
`)[0];return/^\s*<!--\s*important\s*-->\s*$/.test(m)}))return{success:!0,shouldUpdate:!0,detail:"There is a newer version that should be updated to immediately."};let l=a.last(),d=(new Date().getTime()-new Date(l.published_at).getTime())/(1e3*60*60),h=(p=e==null?void 0:e.minHoursSinceRelease)!=null?p:24;return d<h?{success:!0,shouldUpdate:!1,detail:`There is a newer version, but it was released less than ${h} hours ago.`}:{success:!0,shouldUpdate:!0,detail:`There is a newer version released ${d.toFixed(1)} hours ago.`}}};function BC(n){try{return{result:n(),error:null}}catch(e){return{result:null,error:e}}}async function OC(n){try{return{result:await n,error:null}}catch(e){return{result:null,error:e}}}var p1=require("obsidian");var mf=class extends ke{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 p1.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 g1=require("obsidian");var xf=class extends ke{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(`
`):"").join(`
`);let t=e.colors[e.defaultColor];(!t||!cn(t))&&(t="rgb(var(--text-highlight-bg-rgb))"),this.styleEl.textContent+=[`
.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(`
`);let i=e.colors[e.backlinkHoverColor];(!i||!cn(i))&&(i=Mw),this.styleEl.textContent+=[`
.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(`
`);for(let[r,o]of Object.entries(e.colors))cn(o)&&(this.styleEl.textContent+=[`
.${ti.CLS}-item[data-highlight-color="${r.toLowerCase()}"] > .${ti.CLS}-item-inner {`,` background-color: ${o};`,"}"].join(`
`));this.styleEl.textContent+=[`
.${ti.CLS}-item:not([data-highlight-color]) > .${ti.CLS}-item-inner {`," background-color: transparent;","}"].join(`
`),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(`
`)}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 lm(r))})}setCSSColorVariables(){let e=this.plugin.settings;for(let[i,r]of Object.entries(e.colors)){let o=this.toCSSVariableName(i),s=Mr(r);if(o!==null&&s!==null){let{r:a,g:c,b:l}=s;this.styleEl.textContent+=[`
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(`
`))}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)}},lm=class extends g1.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 bf=class extends we.Plugin{constructor(){super(...arguments);this.lib=new gf(this);this.events=new we.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.requiresDataviewInlineFieldsMigration=!1;this.isDebugMode=!1}async onload(){this.checkVersion(),this.addIcons(),await(0,we.loadPdfJs)(),await this.loadSettings(),await this.saveSettings(),this.domManager=this.addChild(new xf(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(),this.checkDeprecatedSettings(),this.checkDataviewInlineFields(),this.registerAutoCheckForUpdates()}async onunload(){await this.cleanUpResources()}async cleanUpResources(){await this.cleanUpAnystyleFiles()}async cleanUpAnystyleFiles(){let t=this.app.vault.adapter;if(we.Platform.isDesktopApp&&t instanceof we.FileSystemAdapter){let i=this.getAnyStyleInputDir();if(i)try{await t.rmdir(i,!0)}catch(r){if(r.code!=="ENOENT")throw r}}}checkVersion(){this.textDivFirstIdx=we.apiVersion==="1.8.0"?1:0,this.obsidianHasFocusBug=!(0,we.requireApiVersion)("1.9.0"),this.obsidianHasTextSelectionBug=(0,we.requireApiVersion)("1.9.0"),Da.openIfNecessary(this)}addIcons(){(0,we.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(Jn)}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","autoCopyToggleRibbonIcon"),this.renameCommand("pdf-plus:toggle-select-to-copy",`${this.manifest.id}:toggle-auto-copy`),this.renameSetting("removeWhitespaceBetweenCJKChars","removeWhitespaceBetweenCJChars"),this.loadContextMenuConfig()}renameSetting(t,i){this.settings.hasOwnProperty(t)&&(this.settings[i]=this.settings[t],delete this.settings[t])}renameCommand(t,i){let{hotkeyManager:r}=this.app,o=r.getHotkeys(t);o&&(r.removeHotkeys(t),r.setHotkeys(i,o))}loadContextMenuConfig(){let t=this.getDefaultSettings().contextMenuConfig,i=[];for(let r of t){let o=this.settings.contextMenuConfig.find(({id:s})=>s===r.id);i.push(o!=null?o: Line truncated
/*! Bundled license information:
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 */