6 lines
73 KiB
JavaScript
6 lines
73 KiB
JavaScript
|
|
import{D as e,M as t}from"./package-Bop5TfAT.js";import{t as n}from"./jszip.min-CoyCHGS6.js";var r=e=>{let t=e.split(` `),n=[],r=0;for(;r<t.length;){if(t[r]===`M`||t[r]===`S`){let e={type:`M`,x:parseFloat(t[r+1]),y:parseFloat(t[r+2])};r+=3,n.push(e)}if(t[r]===`L`){let e={type:`L`,x:parseFloat(t[r+1]),y:parseFloat(t[r+2])};r+=3,n.push(e)}else if(t[r]===`C`)n.push({type:`C`,x:0,y:0}),r++;else if(t[r]===`B`){let e={type:`B`,x1:parseFloat(t[r+1]),y1:parseFloat(t[r+2]),x2:parseFloat(t[r+3]),y2:parseFloat(t[r+4]),x3:parseFloat(t[r+5]),y3:parseFloat(t[r+6])};r+=7,n.push(e)}else r++}return n},i=function(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.type===`M`||r.type===`L`||r.type===`C`){let e=0,n=0;e=r.x,n=r.y,r.x=d(e),r.y=d(n),t.push(r)}else if(r.type===`B`){let e=r.x1,n=r.y1,i=r.x2,a=r.y2,o=r.x3,s=r.y3,c={type:`B`,x1:d(e),y1:d(n),x2:d(i),y2:d(a),x3:d(o),y3:d(s)};t.push(c)}}return t},a=function(e,t){return e*t/25.4},o=10,s=o,c=function(e){o=e>5?5:e},l=function(e){s=e>1?e:1,s=s>o?o:s},u=function(){return s},d=function(e){return a(e,s*25.4)},f=function(e){if(e.indexOf(`g`)===-1){let t=[];for(let n of e.split(` `))t.push(parseFloat(n));return t}else{let t=e.split(` `),n=!1,r=!1,i=0,a=[];for(let e of t)if(e===`g`)n=!0;else{if(!e||e.trim().length==0)continue;if(n)i=parseInt(e),r=!0,n=!1;else if(r){for(let t=0;t<i;t++)a.push(parseFloat(e));r=!1}else a.push(parseFloat(e))}return a}},p=function(e){let t=0,n=0,r=[];if(!e)return r;for(let i of e){if(!i)continue;t=parseFloat(i[`@_X`]),n=parseFloat(i[`@_Y`]),isNaN(t)&&(t=0),isNaN(n)&&(n=0);let e=[],a=[];i[`@_DeltaX`]&&i[`@_DeltaX`].length>0&&(e=f(i[`@_DeltaX`])),i[`@_DeltaY`]&&i[`@_DeltaY`].length>0&&(a=f(i[`@_DeltaY`]));let o=i[`#text`];if(o){o+=``,o=v(o),o=o.replace(/ /g,` `);for(let i=0;i<o.length;i++){i>0&&e.length>0&&(t+=e[i-1]),i>0&&a.length>0&&(n+=a[i-1]);let s=o.substring(i,i+1),c=r.filter(e=>e.y==d(n));if(c&&c.length)c[0].text+=s;else{let e={x:d(t),y:d(n),text:s};r.push(e)}}}}return r},m=function(e){return e&&e.indexOf(`/`)===0&&(e=e.replace(`/`,``)),e},h=function(e){return!e&&typeof e!=`string`?``:e.substring(e.lastIndexOf(`.`)+1)},g=/&\w+;|&#(\d+);/g,_={"<":`<`,">":`>`,"&":`&`," ":` `,""":`"`,"©":``,"'":`'`},v=function(e){return e??=this.toString(),typeof e==`string`?e.replace(g,function(e,t){var n=_[e];return n??=isNaN(t)?e:String.fromCharCode(t==160?32:t),n}):e},y={楷体:`楷体, KaiTi, Kai, simkai`,kaiti:`楷体, KaiTi, Kai, simkai`,Kai:`楷体, KaiTi, Kai`,simsun:`SimSun, simsun, Songti SC`,宋体:`SimSun, simsun, Songti SC`,黑体:`SimHei, STHeiti, simhei`,仿宋:`FangSong, STFangsong, simfang`,小标宋体:`sSun`,方正小标宋_gbk:`sSun`,仿宋_gb2312:`FangSong, STFangsong, simfang`,楷体_gb2312:`楷体, KaiTi, Kai, simkai`,couriernew:`Courier New`,"courier new":`Courier New`},b=function(e){y[e.toLowerCase()]&&(e=y[e.toLowerCase()]);for(let t of Object.keys(y))if(e.toLowerCase().indexOf(t.toLowerCase())!=-1)return y[t];return e},x=function(e){if(e){let t=e.split(` `);return{x:parseFloat(t[0]),y:parseFloat(t[1]),w:parseFloat(t[2]),h:parseFloat(t[3])}}else return null},S=function(e){return e.split(` `)},C=function(e){if(e){if(e.indexOf(`#`)!==-1)return e=e.replace(/#/g,``),e=e.replace(/ /g,``),e=`#`+e.toString(),e;let t=e.split(` `);return`rgb(${t[0]}, ${t[1]}, ${t[2]})`}else return`rgb(0, 0, 0)`},w=function(e){return{x:d(e.x),y:d(e.y),w:d(e.w),h:d(e.h)}},T=function(e,t,n){let r=n[Object.keys(n)[0]].json[`ofd:Area`],i;if(r){let e=r[`ofd:PhysicalBox`];if(e)i=e;else{let e=r[`ofd:ApplicationBox`];if(e)i=e;else{let e=r[`ofd:ContentBox`];e&&(i=e)}}}else{let e=t[`ofd:CommonData`][`ofd:PageArea`],n=e[`ofd:PhysicalBox`];if(n)i=n;else{let t=e[`ofd:ApplicationBox`];if(t)i=t;else{let t=e[`ofd:ContentBox`];t&&(i=t)}}}let a=i.split(` `),o=((e-10)/parseFloat(a[2])).toFixed(1);return c(o),l(o),i=x(i),i=w(i),i},E=function(e,t){let n=t[Object.keys(t)[0]].json[`ofd:Area`],r;if(n){let e=n[`ofd:PhysicalBox`];if(e)r=e;else{let e=n[`ofd:ApplicationBox`];if(e)r=e;else{let e=n[`ofd:ContentBox`];e&&(r=e)}}}else{let t=e[`ofd:CommonData`][`ofd:PageAre
|
|||
|
|
`),s=n(s,i,a);let c=new r(`!xml`),l=c,d=``;for(let n=0;n<e.length;n++)if(e[n]===`<`)if(e[n+1]===`/`){let r=p(e,`>`,n,`Closing Tag is not closed.`),i=e.substring(n+2,r).trim();if(s.ignoreNameSpace){let e=i.indexOf(`:`);e!==-1&&(i=i.substr(e+1))}l&&(l.val?l.val=t.getValue(l.val)+``+o(i,d,s):l.val=o(i,d,s)),s.stopNodes.length&&s.stopNodes.includes(l.tagname)&&(l.child=[],l.attrsMap??={},l.val=e.substr(l.startIndex+1,n-l.startIndex-1)),l=l.parent,d=``,n=r}else if(e[n+1]===`?`)n=p(e,`?>`,n,`Pi Tag is not closed.`);else if(e.substr(n+1,3)===`!--`)n=p(e,`-->`,n,`Comment is not closed.`);else if(e.substr(n+1,2)===`!D`){let t=p(e,`>`,n,`DOCTYPE is not closed.`);n=e.substring(n,t).indexOf(`[`)>=0?e.indexOf(`]>`,n)+1:t}else if(e.substr(n+1,2)===`![`){let i=p(e,`]]>`,n,`CDATA is not closed.`)-2,a=e.substring(n+9,i);if(d&&=(l.val=t.getValue(l.val)+``+o(l.tagname,d,s),``),s.cdataTagName){let e=new r(s.cdataTagName,l,a);l.addChild(e),l.val=t.getValue(l.val)+s.cdataPositionChar,a&&(e.val=a)}else l.val=(l.val||``)+(a||``);n=i+2}else{let i=f(e,n+1),a=i.data,c=i.index,p=a.indexOf(` `),m=a;if(p!==-1&&(m=a.substr(0,p).replace(/\s\s*$/,``),a=a.substr(p+1)),s.ignoreNameSpace){let e=m.indexOf(`:`);e!==-1&&(m=m.substr(e+1))}if(l&&d&&l.tagname!==`!xml`&&(l.val=t.getValue(l.val)+``+o(l.tagname,d,s)),a.length>0&&a.lastIndexOf(`/`)===a.length-1){m[m.length-1]===`/`?(m=m.substr(0,m.length-1),a=m):a=a.substr(0,a.length-1);let e=new r(m,l,``);m!==a&&(e.attrsMap=u(a,s)),l.addChild(e)}else{let e=new r(m,l);s.stopNodes.length&&s.stopNodes.includes(e.tagname)&&(e.startIndex=c),m!==a&&(e.attrsMap=u(a,s)),l.addChild(e),l=e}d=``,n=c}else d+=e[n];return c};function f(e,t){let n,r=``;for(let i=t;i<e.length;i++){let t=e[i];if(n)t===n&&(n=``);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return{data:r,index:i};else t===` `&&(t=` `);r+=t}}function p(e,t,n,r){let i=e.indexOf(t,n);if(i===-1)throw Error(r);return i+t.length-1}e.getTraversalObj=d})),H=e((e=>{var t=R(),n={allowBooleanAttributes:!1},r=[`allowBooleanAttributes`];e.validate=function(e,o){o=t.buildOptions(o,n,r);let s=[],l=!1,d=!1;e[0]===``&&(e=e.substr(1));for(let t=0;t<e.length;t++)if(e[t]===`<`)if(t++,e[t]===`?`){if(t=i(e,++t),t.err)return t}else if(e[t]===`!`){t=a(e,t);continue}else{let n=!1;e[t]===`/`&&(n=!0,t++);let r=``;for(;t<e.length&&e[t]!==`>`&&e[t]!==` `&&e[t]!==` `&&e[t]!==`
|
|||
|
|
`&&e[t]!==`\r`;t++)r+=e[t];if(r=r.trim(),r[r.length-1]===`/`&&(r=r.substring(0,r.length-1),t--),!h(r)){let n;return n=r.trim().length===0?`There is an unnecessary space between tag name and backward slash '</ ..'.`:`Tag '`+r+`' is an invalid name.`,p(`InvalidTag`,n,g(e,t))}let i=c(e,t);if(i===!1)return p(`InvalidAttr`,`Attributes for '`+r+`' have open quote.`,g(e,t));let m=i.value;if(t=i.index,m[m.length-1]===`/`){m=m.substring(0,m.length-1);let n=u(m,o);if(n===!0)l=!0;else return p(n.err.code,n.err.msg,g(e,t-m.length+n.err.line))}else if(n){if(!i.tagClosed)return p(`InvalidTag`,`Closing tag '`+r+`' doesn't have proper closing.`,g(e,t));if(m.trim().length>0)return p(`InvalidTag`,`Closing tag '`+r+`' can't have attributes or invalid starting.`,g(e,t));{let n=s.pop();if(r!==n)return p(`InvalidTag`,`Closing tag '`+n+`' is expected inplace of '`+r+`'.`,g(e,t));s.length==0&&(d=!0)}}else{let n=u(m,o);if(n!==!0)return p(n.err.code,n.err.msg,g(e,t-m.length+n.err.line));if(d===!0)return p(`InvalidXml`,`Multiple possible root nodes found.`,g(e,t));s.push(r),l=!0}for(t++;t<e.length;t++)if(e[t]===`<`)if(e[t+1]===`!`){t++,t=a(e,t);continue}else break;else if(e[t]===`&`){let n=f(e,t);if(n==-1)return p(`InvalidChar`,`char '&' is not expected.`,g(e,t));t=n}e[t]===`<`&&t--}else{if(e[t]===` `||e[t]===` `||e[t]===`
|
|||
|
|
`||e[t]===`\r`)continue;return p(`InvalidChar`,`char '`+e[t]+`' is not expected.`,g(e,t))}return l?s.length>0?p(`InvalidXml`,`Invalid '`+JSON.stringify(s,null,4).replace(/\r?\n/g,``)+`' found.`,1):!0:p(`InvalidXml`,`Start tag expected.`,1)};function i(e,t){for(var n=t;t<e.length;t++)if(e[t]==`?`||e[t]==` `){var r=e.substr(n,t-n);if(t>5&&r===`xml`)return p(`InvalidXml`,`XML declaration allowed only at the start of the document.`,g(e,t));if(e[t]==`?`&&e[t+1]==`>`){t++;break}else continue}return t}function a(e,t){if(e.length>t+5&&e[t+1]===`-`&&e[t+2]===`-`){for(t+=3;t<e.length;t++)if(e[t]===`-`&&e[t+1]===`-`&&e[t+2]===`>`){t+=2;break}}else if(e.length>t+8&&e[t+1]===`D`&&e[t+2]===`O`&&e[t+3]===`C`&&e[t+4]===`T`&&e[t+5]===`Y`&&e[t+6]===`P`&&e[t+7]===`E`){let n=1;for(t+=8;t<e.length;t++)if(e[t]===`<`)n++;else if(e[t]===`>`&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]===`[`&&e[t+2]===`C`&&e[t+3]===`D`&&e[t+4]===`A`&&e[t+5]===`T`&&e[t+6]===`A`&&e[t+7]===`[`){for(t+=8;t<e.length;t++)if(e[t]===`]`&&e[t+1]===`]`&&e[t+2]===`>`){t+=2;break}}return t}var o=`"`,s=`'`;function c(e,t){let n=``,r=``,i=!1;for(;t<e.length;t++){if(e[t]===o||e[t]===s)if(r===``)r=e[t];else if(r!==e[t])continue;else r=``;else if(e[t]===`>`&&r===``){i=!0;break}n+=e[t]}return r===``?{value:n,index:t,tagClosed:i}:!1}var l=RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,`g`);function u(e,n){let r=t.getAllMatches(e,l),i={};for(let t=0;t<r.length;t++){if(r[t][1].length===0)return p(`InvalidAttr`,`Attribute '`+r[t][2]+`' has no space in starting.`,_(e,r[t][0]));if(r[t][3]===void 0&&!n.allowBooleanAttributes)return p(`InvalidAttr`,`boolean attribute '`+r[t][2]+`' is not allowed.`,_(e,r[t][0]));let a=r[t][2];if(!m(a))return p(`InvalidAttr`,`Attribute '`+a+`' is an invalid name.`,_(e,r[t][0]));if(!i.hasOwnProperty(a))i[a]=1;else return p(`InvalidAttr`,`Attribute '`+a+`' is repeated.`,_(e,r[t][0]))}return!0}function d(e,t){let n=/\d/;for(e[t]===`x`&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===`;`)return t;if(!e[t].match(n))break}return-1}function f(e,t){if(t++,e[t]===`;`)return-1;if(e[t]===`#`)return t++,d(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===`;`)break;return-1}return t}function p(e,t,n){return{err:{code:e,msg:t,line:n}}}function m(e){return t.isName(e)}function h(e){return t.isName(e)}function g(e,t){return e.substring(0,t).split(/\r?\n/).length}function _(e,t){return e.indexOf(t)+t.length}})),U=e((e=>{var t=function(e){return String.fromCharCode(e)},n={nilChar:t(176),missingChar:t(201),nilPremitive:t(175),missingPremitive:t(200),emptyChar:t(178),emptyValue:t(177),boundryChar:t(179),objStart:t(198),arrStart:t(204),arrayEnd:t(185)},r=[n.nilChar,n.nilPremitive,n.missingChar,n.missingPremitive,n.boundryChar,n.emptyChar,n.emptyValue,n.arrayEnd,n.objStart,n.arrStart],i=function(e,t,r){if(typeof t==`string`)return e&&e[0]&&e[0].val!==void 0?a(e[0].val,t):a(e,t);{let s=c(e);if(s===!0){let s=``;if(Array.isArray(t)){s+=n.arrStart;let c=t[0],l=e.length;if(typeof c==`string`)for(let t=0;t<l;t++){let n=a(e[t].val,c);s=o(s,n)}else for(let t=0;t<l;t++){let n=i(e[t],c,r);s=o(s,n)}s+=n.arrayEnd}else{s+=n.objStart;let a=Object.keys(t);Array.isArray(e)&&(e=e[0]);for(let n in a){let c=a[n],l;l=!r.ignoreAttributes&&e.attrsMap&&e.attrsMap[c]?i(e.attrsMap[c],t[c],r):c===r.textNodeName?i(e.val,t[c],r):i(e.child[c],t[c],r),s=o(s,l)}}return s}else return s}},a=function(e){switch(e){case void 0:return n.missingPremitive;case null:return n.nilPremitive;case``:return n.emptyValue;default:return e}},o=function(e,t){return!s(t[0])&&!s(e[e.length-1])&&(e+=n.boundryChar),e+t},s=function(e){return r.indexOf(e)!==-1};function c(e){return e===void 0?n.missingChar:e===null?n.nilChar:e.child&&Object.keys(e.child).length===0&&(!e.attrsMap||Object.keys(e.attrsMap).length===0)?n.emptyChar:!0}var l=V(),u=R().buildOptions;e.convert2nimn=function(e,t,n){return n=u(n,l.defaultOptions,l.props),i(e,t,n)}})),W=e((e=>{var t=R(),n=R().buildOptions,r=V(),i=function(e,t){return t=n(t,r.defaultOptions,r.props),t.indentBy=t.indentBy||``,a(e,t,0)},a=function(e,n
|
|||
|
|
`,this.newLine=`
|
|||
|
|
`):(this.indentate=function(){return``},this.tagEndChar=`>`,this.newLine=``),this.options.supressEmptyNode?(this.buildTextNode=d,this.buildObjNode=l):(this.buildTextNode=u,this.buildObjNode=c),this.buildTextValNode=u,this.buildObjectNode=c}a.prototype.parse=function(e){return this.j2x(e,0).val},a.prototype.j2x=function(e,t){let n=``,r=``,i=Object.keys(e),a=i.length;for(let o=0;o<a;o++){let a=i[o];if(e[a]!==void 0)if(e[a]===null)r+=this.indentate(t)+`<`+a+`/`+this.tagEndChar;else if(e[a]instanceof Date)r+=this.buildTextNode(e[a],a,``,t);else if(typeof e[a]!=`object`){let i=this.isAttribute(a);i?n+=` `+i+`="`+this.options.attrValueProcessor(``+e[a])+`"`:this.isCDATA(a)?e[this.options.textNodeName]?r+=this.replaceCDATAstr(e[this.options.textNodeName],e[a]):r+=this.replaceCDATAstr(``,e[a]):a===this.options.textNodeName?e[this.options.cdataTagName]||(r+=this.options.tagValueProcessor(``+e[a])):r+=this.buildTextNode(e[a],a,``,t)}else if(Array.isArray(e[a]))if(this.isCDATA(a))r+=this.indentate(t),e[this.options.textNodeName]?r+=this.replaceCDATAarr(e[this.options.textNodeName],e[a]):r+=this.replaceCDATAarr(``,e[a]);else{let n=e[a].length;for(let i=0;i<n;i++){let n=e[a][i];if(n!==void 0)if(n===null)r+=this.indentate(t)+`<`+a+`/`+this.tagEndChar;else if(typeof n==`object`){let e=this.j2x(n,t+1);r+=this.buildObjNode(e.val,a,e.attrStr,t)}else r+=this.buildTextNode(n,a,``,t)}}else if(this.options.attrNodeName&&a===this.options.attrNodeName){let t=Object.keys(e[a]),r=t.length;for(let i=0;i<r;i++)n+=` `+t[i]+`="`+this.options.attrValueProcessor(``+e[a][t[i]])+`"`}else{let n=this.j2x(e[a],t+1);r+=this.buildObjNode(n.val,a,n.attrStr,t)}}return{attrStr:n,val:r}};function o(e,t){return e=this.options.tagValueProcessor(``+e),this.options.cdataPositionChar===``||e===``?e+`<![CDATA[`+t+`]]`+this.tagEndChar:e.replace(this.options.cdataPositionChar,`<![CDATA[`+t+`]]`+this.tagEndChar)}function s(e,t){if(e=this.options.tagValueProcessor(``+e),this.options.cdataPositionChar===``||e===``)return e+`<![CDATA[`+t.join(`]]><![CDATA[`)+`]]`+this.tagEndChar;for(let n in t)e=e.replace(this.options.cdataPositionChar,`<![CDATA[`+t[n]+`]]>`);return e+this.newLine}function c(e,t,n,r){return n&&!e.includes(`<`)?this.indentate(r)+`<`+t+n+`>`+e+`</`+t+this.tagEndChar:this.indentate(r)+`<`+t+n+this.tagEndChar+e+this.indentate(r)+`</`+t+this.tagEndChar}function l(e,t,n,r){return e===``?this.indentate(r)+`<`+t+n+`/`+this.tagEndChar:this.buildObjectNode(e,t,n,r)}function u(e,t,n,r){return this.indentate(r)+`<`+t+n+`>`+this.options.tagValueProcessor(e)+`</`+t+this.tagEndChar}function d(e,t,n,r){return e===``?this.indentate(r)+`<`+t+n+`/`+this.tagEndChar:this.buildTextValNode(e,t,n,r)}function f(e){return this.options.indentBy.repeat(e)}function p(e){return e.startsWith(this.options.attributeNamePrefix)?e.substr(this.attrPrefixLen):!1}function m(e){return e===this.options.cdataTagName}t.exports=a})),K=e((e=>{var t=z(),n=V(),r=V(),i=R().buildOptions,a=H();e.parse=function(e,o,s){if(s){s===!0&&(s={});let t=a.validate(e,s);if(t!==!0)throw Error(t.err.msg)}o=i(o,r.defaultOptions,r.props);let c=n.getTraversalObj(e,o);return t.convertToJson(c,o)},e.convertTonimn=U().convert2nimn,e.getTraversalObj=n.getTraversalObj,e.convertToJson=t.convertToJson,e.convertToJsonString=W().convertToJsonString,e.validate=a.validate,e.j2xParser=G(),e.parseToNimn=function(t,n,r){return e.convertTonimn(e.getTraversalObj(t,r),n,r)}})),q=t(n(),1),ee=t(K(),1);globalThis._pdfjsCompatibilityChecked||(globalThis._pdfjsCompatibilityChecked=!0);var te={ERRORS:0,WARNINGS:1,INFOS:5},ne=te.WARNINGS;function J(e){ne>=te.INFOS&&console.log(`Info: ${e}`)}function re(e){throw Error(e)}function ie(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}var ae=(function(){function e(t){this.constructor===e&&re(`Cannot initialize BaseException.`),this.message=t,this.name=this.constructor.name}return e.prototype=Error(),e.constructor=e,e})();(function(){let e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`;return function(t,n,r=!1){if(!r&&URL.createObject
|