pdf2json
Version:
PDF file parser that converts PDF binaries to JSON and text, powered by porting a fork of PDF.JS to Node.js
1 lines • 931 kB
JavaScript
import e from"node:fs";import t from"node:util";import{readFile as a}from"node:fs/promises";import{EventEmitter as r}from"node:events";import{Buffer as i,Blob as n}from"node:buffer";import c from"node:process";import s from"node:console";import{Transform as o,Readable as f}from"node:stream";var l="pdf2json",h="3.1.7",u="PDF file parser that converts PDF binaries to JSON and text, powered by porting a fork of PDF.JS to Node.js",d=["pdf","pdf parser","pdf2json","convert pdf to json","convert pdf form to json","server side PDF parser","port pdf.js to node.js","PDF to text","PDF text extractor","PDF binary to text","PDF form extractor","command line utility to parse pdf to json","JSON","javascript","PDF canvas"],g={name:"Modesty Zhang",email:"modestyz@hotmail.com",url:"http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=62372"},m="https://github.com/modesty/pdf2json",p={type:"git",url:"git://github.com/modesty/pdf2json.git"},b="./dist/pdfparser.cjs",v="./dist/pdfparser.js",y="./dist/pdfparser.d.ts",k={pretest:"npm run build","test:jest":"jest --config ./jest.config.json --detectOpenHandles",test:"npm run test:jest && npm run parse-r && npm run parse-fd","test:forms":"cd ./test && sh p2j.forms.sh","test:misc":'cd ./test && sh p2j.one.sh misc . "Expected: 14 success, 6 fail exception with stack trace" ',parse:"./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form","parse-s":"./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s","parse-t":"./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s -t","parse-c":"./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s -t -c","parse-m":"./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s -t -c -m","parse-r":"./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -t -c -m -r","parse-fd":"./bin/pdf2json.js -f ./test/pdf/fd/form/ -o ./test/target/fd/form -t -c -m -r","parse-tb":"./bin/pdf2json.js -f ./test/pdf/misc/i242_testingWithTable.pdf -o ./test/target/misc","parse-tc":"./bin/pdf2json.js -f ./test/pdf/misc/i293_pdfpac.pdf -o ./test/target/misc","parse-rectFix":"./bin/pdf2json.js -f ./test/pdf/misc/pr298_rect_fix_from_upstream.pdf -o ./test/target/misc","parse-e":"./bin/pdf2json.js -f ./test/pdf/misc/i306_err_invalid.pdf -o ./test/target/misc","build:rollup":"rollup -c ./rollup.config.js","build:bundle-pdfjs-base":"node rollup/bundle-pdfjs-base.js",build:"npm run build:bundle-pdfjs-base && npm run build:rollup","build:clean":"rm -rf node_modules && rm -f package-lock.json && npm i && npm run build","test:deno":"deno --allow-read --allow-write --allow-net --allow-env --no-check ./bin/pdf2json.js -f ./test/pdf/fd/form/ -o ./test/target/fd/form -t -c -m -r","test:bun":"bun ./bin/pdf2json.js -f ./test/pdf/fd/form/ -o ./test/target/fd/form -t -c -m -r"},A={node:">=20.18.0"},w={packageManager:{name:"npm",version:">=10.8.2"}},x="module",S={pdf2json:"./bin/pdf2json.js"},C={},I=[],B={"@rollup/plugin-commonjs":"^28.0.6","@rollup/plugin-eslint":"^9.0.5","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^16.0.0","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^12.1.4","@types/node":"^24.0.7","@typescript-eslint/eslint-plugin":"^8.35.0","@typescript-eslint/parser":"^8.35.0",eslint:"^9.30.0",jest:"^30.0.3",rollup:"^4.44.1","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-sourcemaps":"^0.6.3",tslib:"^2.6.2"},T={typescript:"5.8.3"},L=[{name:"Modesty Zhang",email:"modestyz@hotmail.com",url:"http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=62372"}],F=[],P={url:"http://github.com/modesty/pdf2json/issues"},R="Apache-2.0",O="https://github.com/modesty/pdf2json/blob/master/readme.md",D={".":{types:"./dist/pdfparser.d.ts",import:"./dist/pdfparser.js",require:"./dist/pdfparser.cjs"}},M={registry:"https://registry.npmjs.com/",access:"public"},q=["bin/","dist/","package.json","readme.md","license.txt"],E={name:l,version:h,description:u,keywords:d,author:g,homepage:m,repository:p,main:b,module:v,typings:y,scripts:k,engines:A,devEngines:w,type:x,bin:S,dependencies:C,bundleDependencies:I,devDependencies:B,resolutions:T,maintainers:L,contributors:F,bugs:P,license:R,readme:O,exports:D,publishConfig:M,files:q},N=Object.freeze({__proto__:null,author:g,bin:S,bugs:P,bundleDependencies:I,contributors:F,default:E,dependencies:C,description:u,devDependencies:B,devEngines:w,engines:A,exports:D,files:q,homepage:m,keywords:d,license:R,main:b,maintainers:L,module:v,name:l,publishConfig:M,readme:O,repository:p,resolutions:T,scripts:k,type:x,typings:y,version:h});const j=`${l}@${h} [${m}]`,U=["#000000","#ffffff","#4c4c4c","#808080","#999999","#c0c0c0","#cccccc","#e5e5e5","#f2f2f2","#008000","#00ff00","#bfffa0","#ffd629","#ff99cc","#004080","#9fc0e1","#5580ff","#a9c9fa","#ff0080","#800080","#ffbfff","#e45b21","#ffbfaa","#008080","#ff0000","#fdc59f","#808000","#bfbf00","#824100","#007256","#008000","#000080","#008080","#800080","#ff0000","#0000ff","#008000"],z=["quicktype,arial,helvetica,sans-serif","quicktype condensed,arial narrow,arial,helvetica,sans-serif","quicktypepi,quicktypeiipi","quicktype mono,courier new,courier,monospace","ocr-a,courier new,courier,monospace","ocr b mt,courier new,courier,monospace"],H=[[0,6,0,0],[0,8,0,0],[0,10,0,0],[0,12,0,0],[0,14,0,0],[0,18,0,0],[0,6,1,0],[0,8,1,0],[0,10,1,0],[0,12,1,0],[0,14,1,0],[0,18,1,0],[0,6,0,1],[0,8,0,1],[0,10,0,1],[0,12,0,1],[0,14,0,1],[0,18,0,1],[0,6,1,1],[0,8,1,1],[0,10,1,1],[0,12,1,1],[0,14,1,1],[0,18,1,1],[1,6,0,0],[1,8,0,0],[1,10,0,0],[1,12,0,0],[1,14,0,0],[1,18,0,0],[1,6,1,0],[1,8,1,0],[1,10,1,0],[1,12,1,0],[1,14,1,0],[1,18,1,0],[1,6,0,1],[1,8,0,1],[1,10,0,1],[1,12,0,1],[1,14,0,1],[1,18,0,1],[2,8,0,0],[2,10,0,0],[2,12,0,0],[2,14,0,0],[2,18,0,0],[3,8,0,0],[3,10,0,0],[3,12,0,0],[4,12,0,0],[0,9,0,0],[0,9,1,0],[0,9,0,1],[0,9,1,1],[1,9,0,0],[1,9,1,0],[1,9,1,1],[4,10,0,0],[5,10,0,0],[5,12,0,0]],G=96/72;class _{static toFixedFloat(e){return parseFloat(e.toFixed(3))}static colorCount(){return U.length}static toPixelX(e){return Math.round(24*e)}static toPixelY(e){return Math.round(24*e)}static pointToPixel(e){return e*G}static getColorByIndex(e){return U[e]}static toFormPoint(e,t){return[e/24,t/24]}static toFormX(e){return _.toFixedFloat(e/24)}static toFormY(e){return _.toFixedFloat(e/24)}static findColorIndex(e){return 4===e.length&&(e+="000"),U.indexOf(e)}static dateToIso8601(e){"D:"===e.slice(0,2)&&(e=e.slice(2));let t="Z";const a=e.search(/[Z+-]/);a>=0&&(t=e.slice(a),"Z"!==t&&(t=`${t.slice(0,3)}:${t.slice(4,6)}`),e=e.slice(0,a));return`${e.slice(0,4)}-${e.slice(4,6)||"01"}-${e.slice(6,8)||"01"}T${e.slice(8,10)||"00"}:${e.slice(10,12)||"00"}:${e.slice(12,14)||"00"}${t}`}}const X=1024;class W{static tabIndex=0;static isWidgetSupported(e){let a=!1;switch(e.fieldType){case"Tx":case"Ch":case"Sig":a=!0;break;case"Btn":32768&e.fieldFlags?e.fieldType="Rd":65536&e.fieldFlags?e.fieldType="Btn":e.fieldType="Cb",a=!0;break;default:t.p2jwarn(`Unsupported: field.fieldType of ${e.fieldType}`)}return a}static isFormElement(e){let a=!1;if("Widget"===e.subtype)a=W.isWidgetSupported(e);else t.p2jwarn(`Unsupported: field.type of ${e.subtype}`);return a}constructor(e,t,a,r){this.field=e,this.viewport=t,this.Fields=a,this.Boxsets=r}static#e(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}#t(e){const t=this.viewport.convertToViewportRectangle(e.rect),a=W.#e(t);let r=a[3]-a[1];return"Tx"===e.fieldType?r>22&&(a[1]+=2,r-=2):"Ch"!==e.fieldType&&(a[1]-=3),r=r>=20?r:20,{x:_.toFormX(a[0]),y:_.toFormY(a[1]),w:_.toFormX(a[2]-a[0]),h:_.toFormY(r)}}#a(e){let t=0;1&e.fieldFlags&&(t|=X),2&e.fieldFlags&&(t|=16);const a={id:{Id:e.fullName,EN:0},TI:e.TI,AM:t};return e.alternativeText&&e.alternativeText.length>1&&(a.TU=e.alternativeText),e.alternativeID&&e.alternativeID.length>1&&(a.TM=e.alternativeID),Object.assign(a,this.#t(e))}#r(e){const t=Object.assign({style:48,T:{Name:e.TName||"alpha",TypeInfo:{}}},this.#a(e));e.MV&&(t.MV=e.MV),e.fieldValue&&(t.V=e.fieldValue),this.Fields.push(t)}#i(e){const t=Object.assign({style:48,T:{Name:"box",TypeInfo:{}}},this.#a(e));e.fieldValue&&(t.checked="Off"!==e.fieldValue),this.Boxsets.push({boxes:[t]})}#n(e){const t=Object.assign({style:48,T:{Name:"box",TypeInfo:{}}},this.#a(e));t.id.Id=e.value,"checked"in e&&(t.checked=e.checked);const a=this.Boxsets.filter((t=>"id"in t&&"Id"in t.id&&t.id.Id===e.fullName))[0];a&&"boxes"in a?a.boxes.push(t):this.Boxsets.push({boxes:[t],id:{Id:e.fullName,EN:0}})}#c(e){const t=Object.assign({style:48,T:{Name:"link"},FL:{form:{Id:e.FL}}},this.#a(e));this.Fields.push(t)}#s(e){const t=Object.assign({style:48,T:{Name:"alpha",TypeInfo:{}}},this.#a(e));t.w-=.5,t.PL={V:[],D:[]},e.value.forEach(((e,a)=>{Array.isArray(e)?(t.PL.D.push(e[0]),t.PL.V.push(e[1])):(t.PL.D.push(e),t.PL.V.push(e))})),e.fieldValue&&(t.V=e.fieldValue),this.Fields.push(t)}#o(e){const t=Object.assign({style:48,T:{Name:"signature",TypeInfo:{}}},this.#a(e));e.Sig&&(t.Sig={},e.Sig.Name&&(t.Sig.Name=e.Sig.Name),e.Sig.M&&(t.Sig.M=_.dateToIso8601(e.Sig.M)),e.Sig.Location&&(t.Sig.Location=e.Sig.Location),e.Sig.Reason&&(t.Sig.Reason=e.Sig.Reason),e.Sig.ContactInfo&&(t.Sig.ContactInfo=e.Sig.ContactInfo)),this.Fields.push(t)}processField(){switch(this.field.TI=W.tabIndex++,this.field.fieldType){case"Tx":this.#r(this.field);break;case"Cb":this.#i(this.field);break;case"Rd":this.#n(this.field);break;case"Btn":this.#c(this.field);break;case"Ch":this.#s(this.field);break;case"Sig":this.#o(this.field)}this.clean()}clean(){delete this.field,delete this.viewport,delete this.Fields,delete this.Boxsets}static getAllFieldsTypes(e){const t=e=>!!(e.AM&X),a=e=>({id:e.id.Id,type:e.T.Name,calc:t(e),value:e.V||""}),r=[];return e.Pages.forEach((e=>{e.Boxsets.forEach((e=>{e.boxes.length>1?e.boxes.forEach((a=>{r.push({id:e.id.Id,type:"radio",calc:t(a),value:a.id.Id})})):r.push(a(e.boxes[0]))})),e.Fields.forEach((e=>r.push(a(e))))})),r}static getAllFieldData(e){const t=e=>!!(e.AM&X);function a(e){return"box"===e.T.Name?void 0!==e.checked&&e.checked:e.V}const r=e=>({id:e.id.Id,type:e.T.Name,calc:t(e),value:a(e)}),i=[];return e.Pages.forEach((e=>{e.Boxsets.forEach((e=>{e.boxes.length>1?e.boxes.forEach((a=>{a.checked&&i.push({id:e.id.Id,type:"radio",calc:t(a),value:a.id.Id})})):i.push(r(e.boxes[0]))})),e.Fields.forEach((e=>i.push(r(e))))})),i}}const V=["bd","bold","demi","black","medi"],Y=["arial","helvetica","sans-serif ","courier ","monospace ","ocr "],J=.1;class K{#f(){let e=this.fontObj.name||this.fontObj.fallbackName;return e||(e=z[0]),e=e.toLowerCase(),e}#l(){let e=this.typeName,t=!1;const a=this.typeName.split("+");if(Array.isArray(a)&&a.length>1&&(e=a[1].split("-"),Array.isArray(e)&&e.length>1)){const a=e[1].toLowerCase();t=V.indexOf(a)>=0,e=e[0]}return{subType:e,bold:t}}#h(){const e=this.typeName.indexOf("symbol")>0||z[2].indexOf(this.subType)>=0;if(this.fontObj.isSymbolicFont){Y.filter((e=>this.typeName.indexOf(e)>=0)).length>0&&(this.fontObj.isSymbolicFont=!1,t.p2jinfo(`Reset: isSymbolicFont (false) for ${this.fontObj.name}`))}else e&&(this.fontObj.isSymbolicFont=!0,t.p2jinfo(`Reset: isSymbolicFont (true) for ${this.fontObj.name}`));return e}#u(){let{spaceWidth:e}=this.fontObj;if(!e){var t=Array.isArray(this.fontObj.toFontChar)?this.fontObj.toFontChar.indexOf(32):-1;e=t>=0&&Array.isArray(this.fontObj.widths)?this.fontObj.widths[t]:250}return e=_.toFormX(e)/32,e}constructor(e){this.fontObj=e,this.typeName=this.#f();const{subType:t,bold:a}=this.#l();this.subType=t,this.bold=a,this.isSymbol=this.#h(),this.spaceWidth=this.#u(),this.fontSize=1,this.faceIdx=0,this.italic=!1,this.fontStyleId=-1}static compareBlockPos(e,t){if(e.y<t.y-J)return-1;if(Math.abs(e.y-t.y)<=J){if(e.x<t.x-J)return-1;if(Math.abs(e.x-t.x)<=J)return 0}return 1}static haveSameStyle(e,t){let a=e.R[0].S===t.R[0].S;if(a&&e.R[0].S<0)for(let r=0;r<e.R[0].TS.length;r++)if(e.R[0].TS[r]!==t.R[0].TS[r]){a=!1;break}return a&&(a=void 0===e.R[0].RA&&void 0===t.R[0].RA),a}static getSpaceThreshHold(e){return K.getFontSize(e)/12*e.sw}static areAdjacentBlocks(e,t){const a=Math.abs(e.y-t.y)<=J,r=t.x-e.x-e.w<K.getSpaceThreshHold(e);return a&&r}static getFontSize(e){const t=e.R[0].S;return t<0?e.R[0].TS[1]:H[t][1]}static areDuplicateBlocks(e,t){return e.x===t.x&&e.y===t.y&&e.R[0].T===t.R[0].T&&K.haveSameStyle(e,t)}#d(){const{fontObj:e}=this;this.bold=e.bold,this.bold||(this.bold=this.typeName.indexOf("bold")>=0||this.typeName.indexOf("black")>=0),this.italic=e.italic,this.italic||(this.italic=this.typeName.indexOf("italic")>=0||this.typeName.indexOf("oblique")>=0),this.bold&&this.italic||!(this.typeName.indexOf("boldobl")>=0)||(this.bold=!0,this.italic=!0);const t=this.subType;e.isSerifFont?z[1].indexOf(t)>=0&&(this.faceIdx=1):z[2].indexOf(this.subType)>=0?this.faceIdx=2:e.isMonospace?(this.faceIdx=3,z[4].indexOf(t)>=0?this.faceIdx=4:z[5].indexOf(t)>=0&&(this.faceIdx=5)):e.isSymbolicFont&&(this.faceIdx=2),0===this.faceIdx&&this.typeName.indexOf("narrow")>0&&(this.faceIdx=1)}#g(e){this.#d(),this.fontSize=this.bold&&e>12?e+1:e;const t=[this.faceIdx,this.fontSize,this.bold?1:0,this.italic?1:0];let a=-1;return H.forEach(((e,r,i)=>{-1===a&&e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&(a=r)})),a}#m(e){let a=e;if(!e||1!==e.length)return a;if(!this.fontObj.isSymbolicFont||!this.isSymbol)return"C"!==a&&"G"!==a||(a=` ${a} `),a;switch(e.charCodeAt(0)){case 20:a="✓";break;case 70:a="CIDFontType0"===this.fontObj.type?"⚠":"}";break;case 71:case 97:a="▶";break;case 99:a=this.isSymbol?"•":"▲";break;case 100:a="▼";break;case 103:a="➨";break;case 106:a="";break;case 114:case 116:case 118:a="•";break;case 115:a="▲";break;default:t.p2jinfo(`${this.fontObj.type} - SymbolicFont - (${this.fontObj.name}) : ${e.charCodeAt(0)}::${e.charCodeAt(1)} => ${a}`)}return a}#p(e){let t=0;if(0===e[0][0]&&0===e[1][1])0!==e[0][1]&&0!==e[1][0]&&e[0][1]/e[1][0]+1<1e-4&&(t=90);else if(0!==e[0][0]&&0!==e[1][1]){const a=Math.atan(-e[0][1]/e[0][0]),r=Math.atan(e[1][0]/e[1][1]);Math.abs(a)>1e-4&&a-r<1e-4&&(t=180*a/Math.PI)}return t}processText(e,a,r,i,n,c,s){const o=this.#m(a);if(!o)return;this.fontStyleId=this.#g(n);const f=[this.faceIdx,this.fontSize,this.bold?1:0,this.italic?1:0],l=_.findColorIndex(i),h=l>=0&&l<_.colorCount()?{clr:l}:{oc:i};let u={T:this.flashEncode(o),S:this.fontStyleId,TS:f};const d=this.#p(s);0!==d&&(t.p2jinfo(`${a}: rotated ${d} degree.`),u={...u,RA:d});const g={x:_.toFormX(e.x)-.25,y:_.toFormY(e.y)-.75,w:_.toFixedFloat(r),...h,sw:this.spaceWidth,A:"left",R:[u]};c.Texts.push(g)}flashEncode(e){let t=encodeURIComponent(e);return t=t.replace("%C2%96","-"),t=t.replace("%C2%91","%27"),t=t.replace("%C2%92","%27"),t=t.replace("%C2%82","%27"),t=t.replace("%C2%93","%22"),t=t.replace("%C2%94","%22"),t=t.replace("%C2%84","%22"),t=t.replace("%C2%8B","%C2%AB"),t=t.replace("%C2%9B","%C2%BB"),t}clean(){this.fontObj=null,delete this.fontObj}}class Z{constructor(e){this.nodeName=e,this.childNodes=[],this.attributes={},this.textContent=""}getAttribute(e){return this.attributes[e]||null}getElementsByTagName(e){let t=[];this.nodeName===e&&t.push(this);for(const a of this.childNodes)if(a instanceof Z){"*"!==e&&a.nodeName!==e||t.push(a);const r=a.getElementsByTagName(e);t=t.concat(r)}return t}}class Q{constructor(){this.documentElement=null}}class ${parseFromString(e){const t=new Q;return e=e.replace(/<\?xml[^?]*\?>/,"").trim(),t.documentElement=this.parseElement(e),t}parseElement(e){const t=/<([^\s/>]+)([^>]*)>/,a=/([^\s=]+)=(?:"([^"]*)"|'([^']*)')/g,r=e.match(t);if(!r)return null;const i=r[1],n=r[2],c=new Z(i);let s;for(;null!==(s=a.exec(n));){const e=s[1],t=s[2]||s[3];c.attributes[e]=t}const o=r[0].length,f=new RegExp(`</${i}>`),l=e.slice(o).search(f);if(-1===l)return c;let h=e.slice(o,o+l).trim();for(;h.length>0;){if(h.startsWith("<")&&!h.startsWith("</")){const e=h.match(t);if(e){const t=e[1],a=new RegExp(`</${t}>`),r=h.search(a);if(-1!==r){const e=t.length+3,a=h.slice(0,r+e),i=this.parseElement(a);i&&c.childNodes.push(i),h=h.slice(a.length).trim();continue}}}const e=h.indexOf("<");if(-1===e){c.textContent+=h.trim();break}if(!(e>0))break;c.textContent+=h.slice(0,e).trim(),h=h.slice(e).trim()}return c}}class ee{xmlData=null;ptiPageArray=[];constructor(){this.xmlData=null,this.ptiPageArray=[]}parseXml(t,a){e.readFile(t,"utf8",((e,t)=>{if(e)a(e);else{this.xmlData=t;for(var r=(new $).parseFromString(this.xmlData).documentElement,i=r?r.getElementsByTagName("field"):[],n=[],c=0;c<i.length;c++){var s=i[c].getAttribute("id"),o=i[c].getAttribute("x"),f=i[c].getAttribute("y"),l=i[c].getAttribute("width"),h=i[c].getAttribute("height"),u=i[c].getAttribute("xsi:type"),d=i[c].getAttribute("page"),g=i[c].getAttribute("fontName"),m=i[c].getAttribute("fontSize"),p={},b=parseInt(o||"0")-21,v=parseInt(f||"0")-20,y=parseInt(String(b))+parseInt(l||"0")-4,k=parseInt(String(v))+parseInt(h||"0")-4;p.fieldType="Tx","Boolean"===u?p.fieldType="Btn":"SSN"!==u&&"Phone"!==u&&"zip"!==u||(p.TName=u?u.toLowerCase():""),p.alternativeText="",p.fullName=s||"",p.fontSize=m||"",p.fontName=g||"",p.subtype="Widget",p.rect=[b,v,y,k],n.push(p),d&&(this.ptiPageArray[parseInt(d)]=n)}}a()}))}getFields(e){return this.ptiPageArray[e]}}class te{constructor(e,t,a,r,i,n,c){this.x1=e,this.y1=t,this.x2=a,this.y2=r,this.lineWidth=i||1,this.color=n,this.dashed=c}#b(e,t,a){e.x=_.toFormX(t),e.y=_.toFormY(a)}processLine(e){const a=Math.abs(this.x2-this.x1),r=Math.abs(this.y2-this.y1),i=this.lineWidth;let n={x:0,y:0,w:_.toFixedFloat(this.lineWidth),l:0};const c=_.findColorIndex(this.color),s=c>0&&c<_.colorCount()?{clr:c}:{oc:this.color};if(n={...n,...s},this.dashed&&(n={...n,dsh:1}),r<this.lineWidth&&a>i){if(this.lineWidth<4&&a/this.lineWidth<4)return void t.p2jinfo(`Skipped: short thick HLine: lineWidth = ${this.lineWidth}, xDelta = ${a}`);n.l=_.toFormX(a),this.x1>this.x2?this.#b(n,this.x2,this.y2):this.#b(n,this.x1,this.y1),e.HLines.push(n)}else if(a<this.lineWidth&&r>i){if(this.lineWidth<4&&r/this.lineWidth<4)return void t.p2jinfo(`Skipped: short thick VLine: lineWidth = ${this.lineWidth}, yDelta = ${r}`);n.l=_.toFormY(r),this.y1>this.y2?this.#b(n,this.x2,this.y2):this.#b(n,this.x1,this.y1),e.VLines.push(n)}}}class ae{constructor(e,t,a,r,i){this.x=e,this.y=t,this.width=a,this.height=r,this.color=i}processFill(e){const a=_.findColorIndex(this.color),r=a>0&&a<_.colorCount()?{clr:a}:{oc:this.color},i={x:_.toFormX(this.x),y:_.toFormY(this.y),w:_.toFormX(this.width),h:_.toFormY(this.height),...r};i.w<2&&i.h<2?t.p2jinfo(`Skipped: tiny fill: ${i.w} x ${i.h}`):e.Fills.push(i)}}const{round:re,sin:ie,cos:ne,abs:ce,sqrt:se}=Math,oe=[];for(let e=0;e<16;e++)for(let t=0;t<16;t++)oe[16*e+t]=e.toString(16)+t.toString(16);function fe(e,t){const a=[[1,0,0],[0,1,0],[0,0,1]];for(let r=0;r<3;r++)for(let i=0;i<3;i++){let n=0;for(let a=0;a<3;a++)n+=e[r][a]*t[a][i];a[r][i]=n}return a}function le(e,t){t.fillStyle=e.fillStyle,t.lineCap=e.lineCap,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.miterLimit=e.miterLimit,t.shadowBlur=e.shadowBlur,t.shadowColor=e.shadowColor,t.shadowOffsetX=e.shadowOffsetX,t.shadowOffsetY=e.shadowOffsetY,t.strokeStyle=e.strokeStyle,t.globalAlpha=e.globalAlpha,t.arcScaleX_=e.arcScaleX_,t.arcScaleY_=e.arcScaleY_,t.lineScale_=e.lineScale_,t.dashArray=e.dashArray}function he(e){let t,a=1;if("rgb"===(e=String(e)).substring(0,3)){const r=e.indexOf("(",3),i=e.indexOf(")",r+1),n=e.substring(r+1,i).split(",");t="#";for(let e=0;e<3;e++)t+=oe[Number(n[e])];4===n.length&&"a"===e.substring(3,4)&&(a=n[3])}else t=e;return{color:t,alpha:a}}function ue(e,t,a,r){e.currentPath_.push({type:"bezierCurveTo",cp1x:t.x,cp1y:t.y,cp2x:a.x,cp2y:a.y,x:r.x,y:r.y}),e.currentX_=r.x,e.currentY_=r.y}function de(e,t,a){if(function(e){for(let t=0;t<3;t++)for(let a=0;a<2;a++)if(!isFinite(e[t][a])||isNaN(e[t][a]))return!1;return!0}(t)&&(e.m_=t,a)){const a=t[0][0]*t[1][1]-t[0][1]*t[1][0];e.lineScale_=se(ce(a))}}class ge{constructor(){}}class me{constructor(e){this.type_=e,this.x0_=0,this.y0_=0,this.r0_=0,this.x1_=0,this.y1_=0,this.r1_=0,this.colors_=[]}addColorStop(e,t){t=he(t),this.colors_.push({offset:e,color:t.color,alpha:t.alpha})}}class pe{constructor(e,t,a){this.m_=[[1,0,0],[0,1,0],[0,0,1]],this.mStack_=[],this.aStack_=[],this.currentPath_=[],this.strokeStyle="#000",this.fillStyle="#000",this.lineWidth=1,this.lineJoin="miter",this.lineCap="butt",this.dashArray=[],this.miterLimit=1,this.globalAlpha=1,"HLines"in e&&Array.isArray(e.HLines)||(e.HLines=[]),"VLines"in e&&Array.isArray(e.VLines)||(e.VLines=[]),"Fills"in e&&Array.isArray(e.Fills)||(e.Fills=[]),"Texts"in e&&Array.isArray(e.Texts)||(e.Texts=[]),this.canvas=e,this.width=t,this.height=a,this.arcScaleX_=1,this.arcScaleY_=1,this.lineScale_=1,this.currentFont=null}#v(e,t,a,r){const i=Array.isArray(this.dashArray)&&this.dashArray.length>1;new te(e.x,e.y,t.x,t.y,a,r,i).processLine(this.canvas)}#y(e,t,a,r){const i=a.x-t.x,n=a.y-t.y;new ae(e.x,e.y,i,n,r).processFill(this.canvas)}#k(e,a,r,i){const n=Math.abs(r-Math.abs(i))<1&&r<13;return n&&t.p2jinfo(`Skipped: tiny rect: w=${r}, h=${i}`),n}getContext(e){return"2d"===e?this:null}setLineDash(e){this.dashArray=e}getLineDash(){return this.dashArray}fillText(e,t,a,r,i){if(!e||1===!e.length&&e.trim().length<1)return;const n=this.getCoords_(t,a),c=he(this.fillStyle||this.strokeStyle),s=c?c.color:"#000000";this.currentFont.processText(n,e,r,s,i,this.canvas,this.m_)}strokeText(e,t,a,r){this.fillText(e,t,a,r)}measureText(e){t.p2jwarn("to be implemented: contextPrototype.measureText - ",e);return{width:(e.length||1)*(this.currentFont.spaceWidth||5)}}setFont(e){this.currentFont&&"function"==typeof this.currentFont.clean&&(this.currentFont.clean(),this.currentFont=null),this.currentFont=new K(e)}clearRect(){t.p2jwarn("to be implemented: contextPrototype.clearRect")}beginPath(){this.currentPath_=[]}moveTo(e,t){const a=this.getCoords_(e,t);this.currentPath_.push({type:"moveTo",x:a.x,y:a.y}),this.currentX_=a.x,this.currentY_=a.y}lineTo(e,t){const a=this.getCoords_(e,t);this.currentPath_.push({type:"lineTo",x:a.x,y:a.y}),this.currentX_=a.x,this.currentY_=a.y}bezierCurveTo(e,t,a,r,i,n){const c=this.getCoords_(i,n);ue(this,this.getCoords_(e,t),this.getCoords_(a,r),c)}quadraticCurveTo(e,t,a,r){const i=this.getCoords_(e,t),n=this.getCoords_(a,r),c={x:this.currentX_+2/3*(i.x-this.currentX_),y:this.currentY_+2/3*(i.y-this.currentY_)};ue(this,c,{x:c.x+(n.x-this.currentX_)/3,y:c.y+(n.y-this.currentY_)/3},n)}arc(e,t,a,r,i,n){const c=n?"at":"wa";let s=e+ne(r)*a;const o=t+ie(r)*a,f=e+ne(i)*a,l=t+ie(i)*a;s!==f||n||(s+=.125);const h=this.getCoords_(e,t),u=this.getCoords_(s,o),d=this.getCoords_(f,l);this.currentPath_.push({type:c,x:h.x,y:h.y,radius:a,xStart:u.x,yStart:u.y,xEnd:d.x,yEnd:d.y})}rect(e,t,a,r){this.#k(e,t,a,r)||(this.moveTo(e,t),this.lineTo(e+a,t),this.lineTo(e+a,t+r),this.lineTo(e,t+r),this.closePath())}strokeRect(e,t,a,r){if(this.#k(e,t,a,r))return;const i=this.currentPath_;this.beginPath(),this.moveTo(e,t),this.lineTo(e+a,t),this.lineTo(e+a,t+r),this.lineTo(e,t+r),this.closePath(),this.stroke(),this.currentPath_=i}fillRect(e,t,a,r){if(this.#k(e,t,a,r))return;const i=this.currentPath_;this.beginPath(),this.moveTo(e,t),this.lineTo(e+a,t),this.lineTo(e+a,t+r),this.lineTo(e,t+r),this.closePath(),this.fill(),this.currentPath_=i}createLinearGradient(e,t,a,r){const i=new me("gradient");return i.x0_=e,i.y0_=t,i.x1_=a,i.y1_=r,i}createRadialGradient(e,t,a,r,i,n){const c=new me("gradientradial");return c.x0_=e,c.y0_=t,c.r0_=a,c.x1_=r,c.y1_=i,c.r1_=n,c}drawImage(e,t){}getImageData(e,t,a,r){return{width:a,height:r,data:new Uint8Array(a*r*4)}}stroke(e){if(this.currentPath_.length<2)return;const t=he(e?this.fillStyle:this.strokeStyle),{color:a}=t,r=this.lineScale_*this.lineWidth,i={x:null,y:null},n={x:null,y:null};for(let t=0;t<this.currentPath_.length;t++){let c=this.currentPath_[t];switch(c.type){case"moveTo":case"bezierCurveTo":case"at":case"wa":break;case"lineTo":e||t>0&&this.#v(this.currentPath_[t-1],c,r,a);break;case"close":e||t>0&&this.#v(this.currentPath_[t-1],this.currentPath_[0],r,a),c=null}e&&c&&((null===i.x||c.x<i.x)&&(i.x=c.x),(null===n.x||c.x>n.x)&&(n.x=c.x),(null===i.y||c.y<i.y)&&(i.y=c.y),(null===n.y||c.y>n.y)&&(n.y=c.y))}e&&this.#y(i,i,n,a)}fill(){this.stroke(!0)}closePath(){this.currentPath_.push({type:"close"})}getCoords_(e,t){const a=this.m_;return{x:e*a[0][0]+t*a[1][0]+a[2][0],y:e*a[0][1]+t*a[1][1]+a[2][1]}}save(){const e={};le(this,e),this.aStack_.push(e),this.mStack_.push(this.m_),this.m_=fe([[1,0,0],[0,1,0],[0,0,1]],this.m_)}restore(){le(this.aStack_.pop(),this),this.m_=this.mStack_.pop()}translate(e,t){de(this,fe([[1,0,0],[0,1,0],[e,t,1]],this.m_),!1)}rotate(e){const t=ne(e),a=ie(e);de(this,fe([[t,a,0],[-a,t,0],[0,0,1]],this.m_),!1)}scale(e,t){this.arcScaleX_*=e,this.arcScaleY_*=t;de(this,fe([[e,0,0],[0,t,0],[0,0,1]],this.m_),!0)}transform(e,t,a,r,i,n){de(this,fe([[e,t,0],[a,r,0],[i,n,1]],this.m_),!0)}setTransform(e,t,a,r,i,n){de(this,[[e,t,0],[a,r,0],[i,n,1]],!0)}clip(){}arcTo(){}createPattern(){return new ge}}function be(e,t){return new pe({},e,t)}function ve(e,t){const a=e.get("AA");if(!a)return;let r=a.get("F");(r||(r=a.get("K"),r))&&r.forEach(((e,a)=>{"JS"===e&&function(e,t){if(Object.prototype.hasOwnProperty.call(t,"TName"))return;if(!e.split)return;const a=e.split("(");if(2!==a.length)return;const r=a[0],i=a[1].split(")")[0];switch(r){case"AFSpecial_Format":t.TName=ye[Number(i)];break;case"AFNumber_Format":t.TName="number";break;case"AFDate_FormatEx":t.TName="date",t.MV=i.replace(/^'+|^"+|'+$|"+$/g,"");break;case"AFSpecial_KeystrokeEx":{const e=i.replace(/^'+|^"+|'+$|"+$/g,"");e&&e.length>0&&e.length<64&&(t.TName="mask",t.MV=e)}break;case"AFPercent_Format":t.TName="percent"}}(a,t)}))}const ye=["zip","zip","phone","ssn",""];class ke{static processAnnotation(e,a){"Btn"===a.fieldType?32768&a.fieldFlags?function(e,t){const a=e.get("Parent");a&&a.forEach(((e,a)=>{"DV"===e||("TU"===e?t.alternativeText=a:"TM"===e&&(t.alternativeID=a))})),e.get("AP").get("N").forEach(((e,a)=>{"off"!==e.toLowerCase()&&(t.value=e,t.checked=t.fieldValue===t.value)})),t.value||(t.value="off")}(e,a):65536&a.fieldFlags?function(e,t){const a=e.get("MK");a&&(t.value=a.get("CA")||""),t.FL="";const r=e.get("A");if(r){const e=r.get("S");t.FL=r.get(e.name)}}(e,a):function(e,t){const a=e.get("AP").get("N");let r=0;a.forEach(((e,a)=>{r++,1===r&&(t.value=e)}))}(e,a):"Ch"===a.fieldType?function(e,t){t.value=e.get("Opt")||[]}(e,a):"Tx"===a.fieldType?ve(e,a):"Sig"===a.fieldType?function(e,t){const a=e.get("V");if(!a)return;t.Sig={};const r=a.get("Name");r&&(t.Sig.Name=r);const i=a.get("M");i&&(t.Sig.M=i);const n=a.get("Location");n&&(t.Sig.Location=n);const c=a.get("Reason");c&&(t.Sig.Reason=c);const s=a.get("ContactInfo");s&&(t.Sig.ContactInfo=s)}(e,a):t.p2jwarn("Unknown fieldType: ",a)}}let Ae=class{#A="";#w=null;set onload(e){this.#w="function"==typeof e?e:null}get onload(){return this.#w}set src(e){this.#A=e,this.#w&&this.#w()}get src(){return this.#A}btoa(e){return new i.from(e,"binary").toString("base64")}};const we={disableWorker:!0},xe={console:console,PDFJS:we};var Se="undefined"==typeof window,Ce=1,Ie=[.001,0,0,.001,0,0],Be=0,Te=1,Le=2,Fe=3,Pe=4;xe.PDFJS||(xe.PDFJS={}),xe.PDFJS.pdfBug=!1;var Re=we.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87},Oe=we.NO_OPS=[82,83,84,85,86,87],De=we.NO_OPS_RANGE=[78,79,80,81],Me=!Boolean(Number(process?.env?.PDF2JSON_DISABLE_LOGS??"0"))&&"console"in xe&&"log"in xe.console?xe.console.log.bind(xe.console):function(){};function qe(e){Ce>=5&&(Me("Info: "+e),we.LogManager.notify("info",e))}function Ee(e){Ce>=1&&(Me("Warning: "+e),we.LogManager.notify("warn",e))}function Ne(e){if(arguments.length>1){var t=["Error:"];t.push.apply(t,arguments),Me.apply(null,t),e=[].join.call(arguments," ")}throw we.LogManager.notify("error",e),new Error(e)}function je(e){Ee("TODO: "+e)}function Ue(e,t){e||Ne(t)}function ze(e,t){if(!t)return e;if(t.indexOf(":")>=0)return t;if("/"==t.charAt(0)){var a=e.indexOf("://");return a=e.indexOf("/",a+3),e.substring(0,a)+t}var r=e.length;r=(a=e.lastIndexOf("#"))>=0?a:r,r=(a=e.lastIndexOf("?",r))>=0?a:r;var i=e.lastIndexOf("/",r);return e.substring(0,i+1)+t}function He(e,t){if(!e)return!1;var a=e.indexOf(":");if(a<0)return t;switch(e.substring(0,a)){case"http":case"https":case"ftp":case"mailto":return!0;default:return!1}}function Ge(e,t){e||Ne(t)}we.isValidUrl=He;var _e;we.LogManager=(_e=[],{addLogger:function(e){_e.push(e)},notify:function(e,t){for(var a=0,r=_e.length;a<r;a++){var i=_e[a];i[e]&&i[e](t)}}});function Xe(e,t,a){return Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!1}),a}var We=we.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Ve=function(){function e(e,t){this.name="PasswordException",this.message=e,this.code=t}return e.prototype=new Error,e.constructor=e,e}(),Ye=function(){function e(e,t){this.name="UnknownErrorException",this.message=e,this.details=t}return e.prototype=new Error,e.constructor=e,e}(),Je=function(){function e(e){this.name="InvalidPDFException",this.message=e}return e.prototype=new Error,e.constructor=e,e}(),Ke=function(){function e(e){this.name="MissingPDFException",this.message=e}return e.prototype=new Error,e.constructor=e,e}(),Ze=function(){function e(e){this.message=e}return e.prototype=new Error,e.prototype.name="NotImplementedException",e.constructor=e,e}(),Qe=function(){function e(e,t){this.begin=e,this.end=t,this.message="Missing data ["+e+", "+t+")"}return e.prototype=new Error,e.prototype.name="MissingDataException",e.constructor=e,e}(),$e=function(){function e(e){this.message=e}return e.prototype=new Error,e.prototype.name="XRefParseException",e.constructor=e,e}();function et(e){for(var t="",a=e.length,r=0;r<a;++r)t+=String.fromCharCode(e[r]);return t}function tt(e){for(var t=e.length,a=new Uint8Array(t),r=0;r<t;++r)a[r]=255&e.charCodeAt(r);return a}var at=[1,0,0,1,0,0],rt=we.Util=function(){function e(){}return e.makeCssRgb=function(e){return"rgb("+e[0]+","+e[1]+","+e[2]+")"},e.makeCssCmyk=function(t){var a=wt.singletons.cmyk.getRgb(t,0);return e.makeCssRgb(a)},e.transform=function(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]},e.applyTransform=function(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]},e.applyInverseTransform=function(e,t){var a=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/a,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/a]},e.getAxialAlignedBoundingBox=function(t,a){var r=e.applyTransform(t,a),i=e.applyTransform(t.slice(2,4),a),n=e.applyTransform([t[0],t[3]],a),c=e.applyTransform([t[2],t[1]],a);return[Math.min(r[0],i[0],n[0],c[0]),Math.min(r[1],i[1],n[1],c[1]),Math.max(r[0],i[0],n[0],c[0]),Math.max(r[1],i[1],n[1],c[1])]},e.inverseTransform=function(e){var t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]},e.apply3dTransform=function(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]},e.singularValueDecompose2dScale=function(e){var t=[e[0],e[2],e[1],e[3]],a=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],i=e[2]*t[0]+e[3]*t[2],n=e[2]*t[1]+e[3]*t[3],c=(a+n)/2,s=Math.sqrt((a+n)*(a+n)-4*(a*n-i*r))/2,o=c+s||1,f=c-s||1;return[Math.sqrt(o),Math.sqrt(f)]},e.normalizeRect=function(e){var t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t},e.intersect=function(e,t){const a=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(a>r)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),n=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>n?null:[a,i,r,n]},e.sign=function(e){return e<0?-1:1},e.concatenateToArray=function(e,t){Array.prototype.push.apply(e,t)},e.prependToArray=function(e,t){Array.prototype.unshift.apply(e,t)},e.extendObj=function(e,t){for(var a in t)e[a]=t[a]},e.getInheritableProperty=function(e,t){for(;e&&!e.has(t);)e=e.get("Parent");return e?e.get(t):null},e.inherit=function(e,t,a){for(var r in e.prototype=Object.create(t.prototype),e.prototype.constructor=e,a)e.prototype[r]=a[r]},e.loadScript=function(e,t){var a=document.createElement("script"),r=!1;a.setAttribute("src",e),t&&(a.onload=function(){r||t(),r=!0}),document.getElementsByTagName("head")[0].appendChild(a)},e}(),it=(we.PageViewport=function(){function e(e,t,a,r,i,n){this.viewBox=e,this.scale=t,this.rotation=a,this.offsetX=r,this.offsetY=i;var c,s,o,f,l,h,u,d,g=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch(a=(a%=360)<0?a+360:a){case 180:c=-1,s=0,o=0,f=1;break;case 90:c=0,s=1,o=1,f=0;break;case 270:c=0,s=-1,o=-1,f=0;break;default:c=1,s=0,o=0,f=-1}n&&(o=-o,f=-f),0===c?(l=Math.abs(m-e[1])*t+r,h=Math.abs(g-e[0])*t+i,u=Math.abs(e[3]-e[1])*t,d=Math.abs(e[2]-e[0])*t):(l=Math.abs(g-e[0])*t+r,h=Math.abs(m-e[1])*t+i,u=Math.abs(e[2]-e[0])*t,d=Math.abs(e[3]-e[1])*t),this.transform=[c*t,s*t,o*t,f*t,l-c*t*g-o*t*m,h-s*t*g-f*t*m],this.width=u,this.height=d,this.fontScale=t}return e.prototype={clone:function(t){var a="scale"in(t=t||{})?t.scale:this.scale,r="rotation"in t?t.rotation:this.rotation;return new e(this.viewBox.slice(),a,r,this.offsetX,this.offsetY,t.dontFlip)},convertToViewportPoint:function(e,t){return rt.applyTransform([e,t],this.transform)},convertToViewportRectangle:function(e){var t=rt.applyTransform([e[0],e[1]],this.transform),a=rt.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],a[0],a[1]]},convertToPdfPoint:function(e,t){return rt.applyInverseTransform([e,t],this.transform)}},e}(),[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364]);function nt(e){var t,a=e.length,r="";if("þ"===e[0]&&"ÿ"===e[1])for(t=2;t<a;t+=2)r+=String.fromCharCode(e.charCodeAt(t)<<8|e.charCodeAt(t+1));else for(t=0;t<a;++t){var i=it[e.charCodeAt(t)];r+=i?String.fromCharCode(i):e.charAt(t)}return r}function ct(e){for(var t in e)return!1;return!0}function st(e){return"boolean"==typeof e}function ot(e){return"number"==typeof e&&(0|e)==e}function ft(e){return"number"==typeof e}function lt(e){return"string"==typeof e}function ht(e){return e instanceof ea}function ut(e,t){return e instanceof ta&&(!t||e.cmd==t)}function dt(e,t){if(!(e instanceof aa))return!1;if(!t)return!0;var a=e.get("Type");return ht(a)&&a.name==t}function gt(e){return e instanceof Array}function mt(e){return"object"==typeof e&&null!=e&&"getBytes"in e}function pt(e){return"object"==typeof e&&null!=e&&"byteLength"in e}function bt(e){return e instanceof ra}function vt(e){var t;if("object"!=typeof e)return!1;if(dt(e))t=e;else{if(!mt(e))return!1;t=e.dict}return t.has("FunctionType")}var yt=we.Promise=function(){var e={handlers:[],running:!1,unhandledRejections:[],pendingRejectionCheck:!1,scheduleHandlers:function(e){0!=e._status&&(this.handlers=this.handlers.concat(e._handlers),e._handlers=[],this.running||(this.running=!0,setTimeout(this.runHandlers.bind(this),0)))},runHandlers:function(){for(;this.handlers.length>0;){var e=this.handlers.shift(),t=e.thisPromise._status,a=e.thisPromise._value;try{1===t?"function"==typeof e.onResolve&&(a=e.onResolve(a)):"function"==typeof e.onReject&&(a=e.onReject(a),t=1,e.thisPromise._unhandledRejection&&this.removeUnhandeledRejection(e.thisPromise))}catch(e){t=2,a=e}e.nextPromise._updateStatus(t,a)}this.running=!1},addUnhandledRejection:function(e){this.unhandledRejections.push({promise:e,time:Date.now()}),this.scheduleRejectionCheck()},removeUnhandeledRejection:function(e){e._unhandledRejection=!1;for(var t=0;t<this.unhandledRejections.length;t++)this.unhandledRejections[t].promise===e&&(this.unhandledRejections.splice(t),t--)},scheduleRejectionCheck:function(){this.pendingRejectionCheck||(this.pendingRejectionCheck=!0,setTimeout(function(){this.pendingRejectionCheck=!1;for(var e=Date.now(),t=0;t<this.unhandledRejections.length;t++)if(e-this.unhandledRejections[t].time>500){var a=this.unhandledRejections[t].promise._value,r="Unhandled rejection: "+a;a.stack&&(r+="\n"+a.stack),Ee(r),this.unhandledRejections.splice(t),t--}this.unhandledRejections.length&&this.scheduleRejectionCheck()}.bind(this),500))}};function t(){this._status=0,this._handlers=[]}return t.all=function(e){var a=new t,r=e.length,i=[];if(0===r)return a.resolve(i),a;function n(e){2!==a._status&&(i=[],a.reject(e))}for(var c=0,s=e.length;c<s;++c){var o=e[c],f=function(e){return function(t){2!==a._status&&(i[e]=t,0===--r&&a.resolve(i))}}(c);t.isPromise(o)?o.then(f,n):f(o)}return a},t.isPromise=function(e){return e&&"function"==typeof e.then},t.prototype={_status:null,_value:null,_handlers:null,_unhandledRejection:null,_updateStatus:function(a,r){1!==this._status&&2!==this._status&&(1==a&&t.isPromise(r)?r.then(this._updateStatus.bind(this,1),this._updateStatus.bind(this,2)):(this._status=a,this._value=r,2===a&&0===this._handlers.length&&(this._unhandledRejection=!0,e.addUnhandledRejection(this)),e.scheduleHandlers(this)))},get isResolved(){return 1===this._status},get isRejected(){return 2===this._status},resolve:function(e){this._updateStatus(1,e)},reject:function(e){this._updateStatus(2,e)},then:function(a,r){var i=new t;return this._handlers.push({thisPromise:this,onResolve:a,onReject:r,nextPromise:i}),e.scheduleHandlers(this),i}},t}(),kt=function(){function e(e,t,a){for(;e.length<a;)e+=t;return e}function t(){this.started={},this.times=[],this.enabled=!0}return t.prototype={time:function(e){this.enabled&&(e in this.started&&Ee("Timer is already running for "+e),this.started[e]=Date.now())},timeEnd:function(e){this.enabled&&(e in this.started||Ee("Timer has not been started for "+e),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e])},toString:function(){for(var t=this.times,a="",r=0,i=0,n=t.length;i<n;++i){var c=t[i].name;c.length>r&&(r=c.length)}for(i=0,n=t.length;i<n;++i){var s=t[i],o=s.end-s.start;a+=e(s.name," ",r)+" "+o+"ms\n"}return a}},t}();function At(e,t){this.name=e,this.comObj=t,this.callbackIndex=1,this.postMessageTransfers=!0;var a=this.callbacks={},r=this.actionHandler={};r.console_log=[function(e){Me.apply(null,e)}],r.console_error="console"in xe?[function(e){xe.console.error.apply(null,e)}]:[function(e){Me.apply(null,e)}],r._warn=[function(e){Ee(e)}],"object"==typeof t&&(t.onmessage=function(e){var i=e.data;if(i.isReply){var n=i.callbackId;if(i.callbackId in a){var c=a[n];delete a[n],c(i.data)}else Ne("Cannot resolve callback "+n)}else if(i.action in r){var s=r[i.action];if(i.callbackId){var o=new yt;o.then((function(e){t.postMessage({isReply:!0,callbackId:i.callbackId,data:e})})),s[0].call(s[1],i.data,o)}else s[0].call(s[1],i.data)}else Ne("Unkown action from worker: "+i.action)})}we.createBlob=function(e,t){return new n([e],{type:t})},we.createObjectURL=function(){if("undefined"!=typeof URL&&URL.createObjectURL)return function(e,t){var a=we.createBlob(e,t);return URL.createObjectURL(a)};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function(t,a){for(var r="data:"+a+";base64,",i=0,n=t.length;i<n;i+=3){var c=255&t[i],s=255&t[i+1],o=255&t[i+2];r+=e[c>>2]+e[(3&c)<<4|s>>4]+e[i+1<n?(15&s)<<2|o>>6:64]+e[i+2<n?63&o:64]}return r}}(),At.prototype={on:function(e,t,a){var r=this.actionHandler;r[e]&&Ne('There is already an actionName called "'+e+'"'),r[e]=[t,a]},send:function(e,t,a,r){var i={action:e,data:t};if(a){var n=this.callbackIndex++;this.callbacks[n]=a,i.callbackId=n}r&&this.postMessageTransfers?this.comObj.postMessage(i,r):this.comObj.postMessage(i)}},t.p2jlog=Me,t.p2jinfo=qe,t.p2jwarn=Ee,t.p2jerror=Ne,t.verbosity=function(e){Ce=isNaN(e)?1:e<=0?0:e>=5?5:e},t.verbosity();var wt=function(){function e(){Ne("should not call ColorSpace constructor")}return e.prototype={getRgb:function(e,t){Ne("Should not call ColorSpace.getRgb")},getRgbItem:function(e,t,a,r){Ne("Should not call ColorSpace.getRgbItem")},getRgbBuffer:function(e,t,a,r,i,n){Ne("Should not call ColorSpace.getRgbBuffer")},getOutputLength:function(e){Ne("Should not call ColorSpace.getOutputLength")},isPassthrough:function(e){return!1},createRgbBuffer:function(e,t,a,r){if(this.isPassthrough(r))return e.subarray(t);var i=new Uint8Array(3*a),n=1<<r;if(1===this.numComps&&a>n&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){for(var c=r<=8?new Uint8Array(n):new Uint16Array(n),s=0;s<n;s++)c[s]=s;var o=new Uint8Array(3*n);this.getRgbBuffer(c,0,n,o,0,r);var f=0;for(s=0;s<a;++s){var l=3*e[t++];i[f++]=o[l],i[f++]=o[l+1],i[f++]=o[l+2]}return i}return this.getRgbBuffer(e,t,a,i,0,r),i},usesZeroToOneRange:!0},e.parse=function(t,a,r){var i=e.parseToIR(t,a,r);return i instanceof xt?i:e.fromIR(i)},e.fromIR=function(t){var a=gt(t)?t[0]:t;switch(a){case"DeviceGrayCS":return this.singletons.gray;case"DeviceRgbCS":return this.singletons.rgb;case"DeviceCmykCS":return this.singletons.cmyk;case"CalGrayCS":var r=t[1].WhitePoint,i=t[1].BlackPoint,n=t[1].Gamma;return new Lt(r,i,n);case"PatternCS":var c=t[1];return c&&(c=e.fromIR(c)),new St(c);case"IndexedCS":var s=t[1],o=t[2],f=t[3];return new Ct(e.fromIR(s),o,f);case"AlternateCS":var l=t[1],h=t[2],u=t[3];return new xt(l,e.fromIR(h),qt.fromIR(u));case"LabCS":r=t[1].WhitePoint,i=t[1].BlackPoint;var d=t[1].Range;return new Ft(r,i,d);default:Ne("Unkown name "+a)}return null},e.parseToIR=function(t,a,r){if(ht(t)){var i=r.get("ColorSpace");if(dt(i)){var n=i.get(t.name);n&&(t=n)}}var c;if(ht(t=a.fetchIfRef(t)))switch(c=t.name,this.mode=c,c){case"DeviceGray":case"G":return"DeviceGrayCS";case"DeviceRGB":case"RGB":return"DeviceRgbCS";case"DeviceCMYK":case"CMYK":return"DeviceCmykCS";case"Pattern":return["PatternCS",null];default:Ne("unrecognized colorspace "+c)}else if(gt(t))switch(c=t[0].name,this.mode=c,c){case"DeviceGray":case"G":return"DeviceGrayCS";case"DeviceRGB":case"RGB":case"CalRGB":return"DeviceRgbCS";case"DeviceCMYK":case"CMYK":return"DeviceCmykCS";case"CalGray":return["CalGrayCS",t[1].getAll()];case"ICCBased":if(1==(u=a.fetchIfRef(t[1]).dict.get("N")))return"DeviceGrayCS";if(3==u)return"DeviceRgbCS";if(4==u)return"DeviceCmykCS";break;case"Pattern":var s=t[1];return s&&(s=e.parseToIR(s,a,r)),["PatternCS",s];case"Indexed":case"I":var o=e.parseToIR(t[1],a,r),f=t[2]+1,l=a.fetchIfRef(t[3]);return mt(l)&&(l=l.getBytes()),["IndexedCS",o,f,l];case"Separation":case"DeviceN":var h=t[1],u=1;return ht(h)?u=1:gt(h)&&(u=h.length),["AlternateCS",u,e.parseToIR(t[2],a,r),qt.getIR(a,a.fetchIfRef(t[3]))];case"Lab":return["LabCS",t[1].getAll()];default:Ne('unimplemented color space object "'+c+'"')}else Ne('unrecognized color space object: "'+t+'"');return null},e.isDefaultDecode=function(e,t){if(!e)return!0;if(2*t!==e.length)return Ee("The decode map is not the correct length"),!0;for(var a=0,r=e.length;a<r;a+=2)if(0!==e[a]||1!=e[a+1])return!1;return!0},e.singletons={get gray(){return Xe(this,"gray",new It)},get rgb(){return Xe(this,"rgb",new Bt)},get cmyk(){return Xe(this,"cmyk",new Tt)}},e}(),xt=function(){function e(e,t,a){this.name="Alternate",this.numComps=e,this.defaultColor=new Float32Array(e);for(var r=0;r<e;++r)this.defaultColor[r]=1;this.base=t,this.tintFn=a}return e.prototype={getRgb:function(e,t){var a=new Uint8Array(3);return this.getRgbItem(e,t,a,0),a},getRgbItem:function(e,t,a,r){this.base.numComps;var i="subarray"in e?e.subarray(t,t+this.numComps):Array.prototype.slice.call(e,t,t+this.numComps),n=this.tintFn(i);this.base.getRgbItem(n,0,a,r)},getRgbBuffer:function(e,t,a,r,i,n){for(var c=this.tintFn,s=this.base,o=1/((1<<n)-1),f=s.numComps,l=s.usesZeroToOneRange,h=s.isPassthrough(8)||!l,u=h?i:0,d=h?r:new Uint8Array(f*a),g=this.numComps,m=new Float32Array(g),p=0;p<a;p++){for(var b=0;b<g;b++)m[b]=e[t++]*o;var v=c(m);if(l)for(b=0;b<f;b++)d[u++]=255*v[b];else s.getRgbItem(v,0,d,u),u+=f}h||s.getRgbBuffer(d,0,a,r,i,8)},getOutputLength:function(e){return this.base.getOutputLength(e*this.base.numComps/this.numComps)},isPassthrough:wt.prototype.isPassthrough,createRgbBuffer:wt.prototype.createRgbBuffer,isDefaultDecode:function(e){return wt.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0},e}(),St=function(){function e(e){this.name="Pattern",this.base=e}return e.prototype={},e}(),Ct=function(){function e(e,t,a){this.name="Indexed",this.numComps=1,this.defaultColor=new Uint8Array([0]),this.base=e,this.highVal=t;var r,i=e.numComps*t;if(mt(a)){r=new Uint8Array(i);var n=a.getBytes(i);r.set(n)}else if(lt(a)){r=new Uint8Array(i);for(var c=0;c<i;++c)r[c]=a.charCodeAt(c)}else a instanceof Uint8Array||a instanceof Array?r=a:Ne("Unrecognized lookup table: "+a);this.lookup=r}return e.prototype={getRgb:function(e,t){var a=this.base.numComps,r=e[t]*a;return this.base.getRgb(this.lookup,r)},getRgbItem:function(e,t,a,r){var i=this.base.numComps,n=e[t]*i;this.base.getRgbItem(this.lookup,n,a,r)},getRgbBuffer:function(e,t,a,r,i){for(var n=this.base,c=n.numComps,s=n.getOutputLength(c),o=this.lookup,f=0;f<a;++f){var l=e[t++]*c;n.getRgbBuffer(o,l,1,r,i,8),i+=s}},getOutputLength:function(e){return this.base.getOutputLength(e*this.base.numComps)},isPassthrough:wt.prototype.isPassthrough,createRgbBuffer:wt.prototype.createRgbBuffer,isDefaultDecode:function(e){return!0},usesZeroToOneRange:!0},e}(),It=function(){function e(){this.name="DeviceGray",this.numComps=1,this.defaultColor=new Float32Array([0])}return e.prototype={getRgb:function(e,t){var a=new Uint8Array(3);return this.getRgbItem(e,t,a,0),a},getRgbItem:function(e,t,a,r){var i=255*e[t]|0;i=i<0?0:i>255?255:i,a[r]=a[r+1]=a[r+2]=i},getRgbBuffer:function(e,t,a,r,i,n){for(var c=255/((1<<n)-1),s=t,o=i,f=0;f<a;++f){var l=c*e[s++]|0;r[o++]=l,r[o++]=l,r[o++]=l}},getOutputLength:function(e){return 3*e},isPassthrough:wt.prototype.isPassthrough,createRgbBuffer:wt.prototype.createRgbBuffer,isDefaultDecode:function(e){return wt.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0},e}(),Bt=function(){function e(){this.name="DeviceRGB",this.numComps=3,this.defaultColor=new Float32Array([0,0,0])}return e.prototype={getRgb:function(e,t){var a=new Uint8Array(3);return this.getRgbItem(e,t,a,0),a},getRgbItem:function(e,t,a,r){var i=255*e[t]|0,n=255*e[t+1]|0,c=255*e[t+2]|0;a[r]=i<0?0:i>255?255:i,a[r+1]=n<0?0:n>255?255:n,a[r+2]=c<0?0:c>255?255:c},getRgbBuffer:function(e,t,a,r,i,n){var c=3*a;if(8!=n)for(var s=255/((1<<n)-1),o=t,f=i,l=0;l<c;++l)r[f++]=s*e[o++]|0;else r.set(e.subarray(t,t+c),i)},getOutputLength:function(e){return e},isPassthrough:function(e){return 8==e},createRgbBuffer:wt.prototype.createRgbBuffer,isDefaultDecode:function(e){return wt.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0},e}(),Tt=function(){function e(e,t,a,r,i){var n=e[t+0]*a,c=e[t+1]*a,s=e[t+2]*a,o=e[t+3]*a,f=n*(-4.387332384609988*n+54.48615194189176*c+18.82290502165302*s+212.25662451639585*o-285.2331026137004)+c*(1.7149763477362134*c-5.6096736904047315*s+-17.873870861415444*o-5.497006427196366)+s*(-2.5217340131683033*s-21.248923337353073*o+17.5119270841813)+o*(-21.86122147463605*o-189.48180835922747)+255,l=n*(8.841041422036149*n+60.118027045597366*c+6.871425592049007*s+31.159100130055922*o-79.2970844816548)+c*(-15.310361306967817*c+17.575251261109482*s+131.35250912493976*o-190.9453302588951)+s*(4.444339102852739*s+9.8632861493405*o-24.86741582555878)+o*(-20.737325471181034*o-187.80453709719578)+255,h=n*(.8842522430003296*n+8.078677503112928*c+30.89978309703729*s-.23883238689178934*o-14.183576799673286)+c*(10.49593273432072*c+63.02378494754052*s+50.606957656360734*o-112.23884253719248)+s*(.03296041114873217*s+115.60384449646641*o-193.58209356861505)+o*(-22.33816807309886*o-180.12613974708367)+255;r[i]=f>255?255:f<0?0:f,r[i+1]=l>255?255:l<0?0:l,r[i+2]=h>255?255:h<0?0:h}function t(){this.name="DeviceCMYK",this.numComps=4,this.defaultColor=new Float32Array([0,0,0,1])}return t.prototype={getRgb:function(t,a){var r=new Uint8Array(3);return e(t,a,1,r,0),r},getRgbItem:function(t,a,r,i){e(t,a,1,r,i)},getRgbBuffer:function(t,a,r,i,n,c){for(var s=1/((1<<c)-1),o=0;o<r;o++)e(t,a,s,i,n),a+=4,n+=3},getOutputLength:function(e){return 3*(e>>2)},isPassthrough:wt.prototype.isPassthrough,createRgbBuffer:wt.prototype.createRgbBuffer,isDefaultDecode:function(e){return wt.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0},t}(),Lt=function(){function e(e,t,a){this.name="CalGray",this.numComps=3,this.defaultColor=new Float32Array([0,0,0]),e||Ne("WhitePoint missing - required for color space CalGray"),t=