@grapecity/gcpdfviewer
Version:
GcDocs PDF Viewer
2 lines • 6.55 MB
JavaScript
/*! For license information please see gcpdfviewer.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.gcpdfviewer=t():e.gcpdfviewer=t()}(self,(()=>(()=>{var __webpack_modules__={7186:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{(()=>{var __webpack_modules__={65298:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GcComponent:()=>g});var i=n(26786),o=n(96212),r=n(12875),a=n(46497),s=n(91586),c=n(11709);function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function d(e){var t="function"==typeof Map?new Map:void 0;return d=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(l())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,t);var o=new(e.bind.apply(e,i));return n&&(0,c.A)(o,n.prototype),o}(e,arguments,(0,a.A)(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),(0,c.A)(n,e)},d(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(u=function(){return!!e})()}var g=function(e){function t(){var e,n,o;return(0,i.A)(this,t),n=this,o=t,o=(0,a.A)(o),(e=(0,r.A)(n,u()?Reflect.construct(o,[],(0,a.A)(n).constructor):o.apply(n,undefined))).useNativeShadow=-1!==window.customElements.toString().indexOf("CustomElementRegistry"),e}return(0,s.A)(t,e),(0,o.A)(t,[{key:"connectedCallback",value:function(){this.id=this.id||function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return"c".concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e()).concat(e())}(),this.useNativeShadow?this.shadowSelector=":host":this.shadowSelector="#".concat(this.id)}},{key:"makeShadow",value:function(){this.useNativeShadow?this.attachShadow({mode:"open"}):this.shadowRoot=this}}])}(d(HTMLElement))},82488:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PDFJSDev:()=>i});var i={_h:{"!PRODUCTION || TESTING":!1,"!PRODUCTION || GENERIC":!1,MOZCENTRAL:!1,TESTING:!1,GENERIC:!0,"GENERIC || CHROME":!0,PRODUCTION:!0,SKIP_BABEL:!0,BUNDLE_VERSION:"2.10.377",BUNDLE_BUILD:"2.10.377"},eval:function(e){return this._h[e]},test:function(e){return e=e.toString(),this._h[e]}}},57302:(e,t,n)=>{"use strict";n.d(t,{EF:()=>Y,YO:()=>z});var i=n(18652),o=n(12875),r=n(46497),a=n(91586),s=n(47019),c=n(53575),l=n(44980),d=n(7272),u=n(26786),g=n(96212),p=n(72325),h=n.n(p),f=n(54533),m=n(61046),b=n(41363),v=n(31241),_=n(70497),y=n(17164),x=n(21504),w=n(36267),k=n(91384),A=n(5882),S=n(33439),C=n(7268),E=n(79259),M=n(53072),P=n(56408);function T(e,t,n,o){var a=(0,i.A)((0,r.A)(1&o?e.prototype:e),t,n);return 2&o&&"function"==typeof a?function(e){return a.apply(n,e)}:a}function I(e,t,n){return t=(0,r.A)(t),(0,o.A)(e,L()?Reflect.construct(t,n||[],(0,r.A)(e).constructor):t.apply(e,n))}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(L=function(){return!!e})()}function D(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return O(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,r=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw r}}}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var z=function(){return(0,g.A)((function e(){(0,u.A)(this,e)}),null,[{key:"create",value:function(e,t,n,i,o){var r=this;return Promise.all([n.ensureCatalog("acroForm"),o?this._getPageIndex(e,t,n):-1]).then((function(a){var s=(0,d.A)(a,2),c=s[0],l=s[1];return n.ensure(r,"_create",[e,t,n,i,c,o,l])}))}},{key:"_create",value:function(e,t,n,i,o,r){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:-1,s=e.fetchIfRef(t);if((0,v.Zm)(s)){var c=(0,v.i9)(t)?t.toString():"annot_".concat(i.createObjId()),l=s.get("Subtype"),d={xref:e,ref:t,dict:s,subtype:l=(0,v.Eo)(l)?l.name:null,id:c,pdfManager:n,acroForm:o instanceof v.Bi?o:v.Bi.empty,collectFields:r,pageIndex:a};switch(l){case"Link":return new ie(d);case"Text":return new ne(d);case"Widget":var u=(0,m.Zx)({dict:s,key:"FT"});switch(u=(0,v.Eo)(u)?u.name:null){case"Tx":return new Z(d);case"Btn":return new $(d);case"Ch":return new ee(d);case"Sig":return new te(d)}return(0,f.warn)('Unimplemented widget field type "'.concat(u,'", ')+"falling back to base field type."),new X(d);case"Popup":return new oe(d);case"FreeText":return new re(d);case"Line":return new ae(d);case"Square":return new se(d);case"Circle":return new ce(d);case"PolyLine":return new le(d);case"Polygon":return new de(d);case"Caret":return new ue(d);case"Ink":return new ge(d);case"Highlight":return new he(d);case"Underline":return new fe(d);case"Squiggly":return new me(d);case"StrikeOut":return new be(d);case"Stamp":return new ve(d);case"FileAttachment":return new _e(d);case"Sound":return new xe(d);case"Redact":return new ye(d);case"RichMedia":return new we(d);default:return r||(l?(0,f.warn)('Unimplemented annotation type "'.concat(l,'", ')+"falling back to base annotation."):(0,f.warn)("Annotation is missing the required /Subtype.")),new q(d)}}}},{key:"_getPageIndex",value:(e=(0,l.A)(h().mark((function e(t,n,i){var o,r,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.fetchIfRefAsync(n);case 3:if(o=e.sent,(0,v.Zm)(o)){e.next=6;break}return e.abrupt("return",-1);case 6:if(r=o.getRaw("P"),(0,v.i9)(r)){e.next=9;break}return e.abrupt("return",-1);case 9:return e.next=11,i.ensureCatalog("getPageIndex",[r]);case 11:return a=e.sent,e.abrupt("return",a);case 15:return e.prev=15,e.t0=e.catch(0),(0,f.warn)('_getPageIndex: "'.concat(e.t0,'".')),e.abrupt("return",-1);case 19:case"end":return e.stop()}}),e,null,[[0,15]])}))),function(t,n,i){return e.apply(this,arguments)})}]);var e}();function R(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Uint8ClampedArray(3);if(!Array.isArray(e))return t;var n=t||new Uint8ClampedArray(3);switch(e.length){case 0:return null;case 1:return x.I.singletons.gray.getRgbItem(e,0,n,0),n;case 3:return x.I.singletons.rgb.getRgbItem(e,0,n,0),n;case 4:return x.I.singletons.cmyk.getRgbItem(e,0,n,0),n;default:return t}}function B(e,t){if(!e.has("QuadPoints"))return null;var n=e.getArray("QuadPoints");if(!Array.isArray(n)||0===n.length||n.length%8>0)return null;for(var i=[],o=0,r=n.length/8;o<r;o++){i.push([]);for(var a=8*o,s=8*o+8;a<s;a+=2){var c=n[a],l=n[a+1];if(null!==t&&(c<t[0]||c>t[2]||l<t[1]||l>t[3]))return null;i[o].push({x:c,y:l})}}return i.map((function(e){var t=e.reduce((function(e,t){var n=(0,d.A)(e,4),i=n[0],o=n[1],r=n[2],a=n[3];return[Math.min(i,t.x),Math.max(o,t.x),Math.min(r,t.y),Math.max(a,t.y)]}),[Number.MAX_VALUE,Number.MIN_VALUE,Number.MAX_VALUE,Number.MIN_VALUE]),n=(0,d.A)(t,4),i=n[0],o=n[1],r=n[2],a=n[3];return[{x:i,y:a},{x:o,y:a},{x:i,y:r},{x:o,y:r}]}))}function F(e,t,n){var i=f.Util.getAxialAlignedBoundingBox(t,n),o=(0,d.A)(i,4),r=o[0],a=o[1],s=o[2],c=o[3];if(r===s||a===c)return[1,0,0,1,e[0],e[1]];var l=(e[2]-e[0])/(s-r),u=(e[3]-e[1])/(c-a);return[l,0,0,u,e[0]-r*l,e[1]-a*u]}function N(e,t,n,i){var o;return e instanceof v.oS&&(e=null==t?void 0:t.fetch(e)),e instanceof v.Bi&&(e=e.has("Type")&&e.has("EF")&&"Filespec"===(null===(o=e.get("Type"))||void 0===o?void 0:o.name)?new w.w(e,t).serializable:j(e,t,n,i)),e}function j(e,t,n,i){if(!e)return e;n||(n=[]);var o={};return e.forEach((function(e,r){var a=(0,M.toCamelCase)(e),s=r&&void 0!==r.name?r.name:r;if(s=N(s,t,n,i),Array.isArray(s)){for(var c=[],l=0;l<s.length;l++)c[l]=N(s[l],t,n,i);s=c}"undefined"!=typeof Element&&"undefined"!=typeof Window&&"undefined"!=typeof window&&(s instanceof Element||s instanceof Window||s===window)||s instanceof P.x||n&&n.includes(a)||i&&i.length>0&&!i.includes(a)||(o[a]=s)})),o}var U=/([\d.]{1,}[ ]{1,}[\d.]{0,}[ ]{0,1}[\d.]{0,}) (g|rg|k)/gm,H=/([\d.]{1,})[ ]{1,}Tf/gm,V=/\/([a-zA-Z-\d]+)[ ]{1,}\d/gm,Y={Arial:{name:"Arial",style:{}},ArialBold:{name:"Arial",style:{fontWeight:"bold"}},ArialItalic:{name:"Arial",style:{fontStyle:"italic"}},ArialBoldItalic:{name:"Arial",style:{fontStyle:"italic",fontWeight:"bold"}},ArialNarrow:{name:"Arial Narrow",style:{}},ArialNova:{name:"Arial Nova",style:{}},ArialNovaCond:{name:"Arial Nova",style:{}},ArialNovaCondItalic:{name:"Arial Nova",style:{fontStyle:"italic"}},ArialNovaCondBoldItalic:{name:"Arial Nova",style:{fontStyle:"italic",fontWeight:"bold"}},Helv:{name:"Helvetica",style:{}},Helvetica:{name:"Helvetica",style:{}},HelveticaItalic:{name:"Helvetica",style:{fontStyle:"italic"}},HelveticaOblique:{name:"Helvetica",style:{fontStyle:"oblique"}},HelveticaBold:{name:"Helvetica",style:{fontWeight:"bold"}},HelveticaBoldItalic:{name:"Helvetica",style:{fontStyle:"italic",fontWeight:"bold"}},HelveticaBoldOblique:{name:"Helvetica",style:{fontStyle:"oblique",fontWeight:"bold"}},Times:{name:"Times New Roman",style:{}},TimesRoman:{name:"Times New Roman",style:{}},TimesNewRoman:{name:"Times New Roman",style:{}},TimesNewRomanItalic:{name:"Times New Roman",style:{fontStyle:"italic"}},TimesNewRomanBold:{name:"Times New Roman",style:{fontWeight:"bold"}},TimesNewRomanBoldItalic:{name:"Times New Roman",style:{fontStyle:"italic",fontWeight:"bold"}},TimesRegular:{name:"Times New Roman",style:{}},TimesItalic:{name:"Times New Roman",style:{fontStyle:"italic"}},TimesOblique:{name:"Times New Roman",style:{fontStyle:"oblique"}},TimesBold:{name:"Times New Roman",style:{fontWeight:"bold"}},TimesBoldItalic:{name:"Times New Roman",style:{fontStyle:"italic",fontWeight:"bold"}},TimesBoldOblique:{name:"Times New Roman",style:{fontStyle:"oblique",fontWeight:"bold"}},Courier:{name:"Courier",style:{}},CourierRegular:{name:"Courier",style:{}},CourierItalic:{name:"Courier",style:{fontStyle:"italic"}},CourierOblique:{name:"Courier",style:{fontStyle:"oblique"}},CourierBold:{name:"Courier",style:{fontWeight:"bold"}},CourierBoldItalic:{name:"Courier",style:{fontStyle:"italic",fontWeight:"bold"}},CourierBoldOblique:{name:"Courier",style:{fontStyle:"oblique",fontWeight:"bold"}},CourierNew:{name:"Courier New",style:{}},CourierNewItalic:{name:"Courier New",style:{fontStyle:"italic"}},CourierNewBold:{name:"Courier New",style:{fontWeight:"bold"}},CourierNewBoldItalic:{name:"Courier New",style:{fontStyle:"italic",fontWeight:"bold"}},Symbol:{name:"Symbol",style:{}},ZaDb:{name:"Zapf Dingbats",style:{}},ZapfDingbats:{name:"Zapf Dingbats",style:{}}};function W(e){if(!e)return e;var t=e.match(/\/?([^+]+)$/);return t&&t[1]?t[1]:e}function G(e){var t=new Uint8ClampedArray(3);if(!Array.isArray(e))return null;switch(e.length){case 0:return null;case 1:return x.I.singletons.gray.getRgbItem(e,0,t,0),t;case 3:return x.I.singletons.rgb.getRgbItem(e,0,t,0),t;case 4:return x.I.singletons.cmyk.getRgbItem(e,0,t,0),t;default:return t}}var q=function(){return(0,g.A)((function e(t){var n,i;(0,u.A)(this,e);var o=t.dict;this.setTitle(o.get("T")),this.setContents(o.get("Contents")),this.setModificationDate(o.get("M")),this.setFlags(o.get("F")),this.setRectangle(o.getArray("Rect")),this.setColor(o.getArray("C")),this.setBorderStyle(o),this.setAppearance(o),this._streams=[],this.appearance&&this._streams.push(this.appearance),this.ref=t.ref;var r=null;if(o.has("AA")){var a=o.get("AA");if((0,v.Zm)(a)){r={};for(var s=a.getKeys(),l=0;l<s.length;l++){var d=a.get(s[l]);if(d&&(0,v.Zm)(d)&&d.has("S")&&d.has("JS")){var g=d.get("S"),p=d.get("JS");if((0,v.Eo)(g)&&(0,f.isString)(p)){var h=(0,f.stringToPDFString)(p);r[s[l]]={type:g.name,action:h}}}}}}var b=void 0;o.has("Rotate")&&(b=parseInt(o.get("Rotate")),Number.isFinite(b)||(b=void 0)),this.rotate=b;var _=1;o.has("CA")&&(_=parseFloat(o.get("CA")),Number.isFinite(_)||(_=1)),this.opacity=_,this.setColor(o.getArray("IC"),"interiorColor");var y=o.has("DA")?o.get("DA"):"";if(!y&&"Widget"===t.subtype&&t.acroForm&&(y=t.acroForm.has("DA")?t.acroForm.get("DA"):""),y){var x=function(e){try{var t=e.matchAll(U).next().value[1];if(t){for(var n=t.toString().split(" ",4),i=0;i<n.length;i++)if(n[i]=parseFloat(n[i]),!isFinite(n[i])){n=n.splice(i,n.length-i);break}return n}}catch(e){}return null}(y);this.setColor(x,"appearanceColor"),this.fontSize=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12;try{var n=e.matchAll(H).next().value[1];if(n){var i=parseFloat(n.toString());if(null!==i&&isFinite(i))return i}}catch(e){}return t}(y,12),this.fontName=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,i="";try{var o=e.matchAll(V).next().value[1];if(o){var r=o.toString()||"";try{var a,s=null===(a=n.acroForm)||void 0===a||null===(a=a.get("DR"))||void 0===a||null===(a=a.get("Font"))||void 0===a||null===(a=a.get(r))||void 0===a||null===(a=a.get("BaseFont"))||void 0===a?void 0:a.name;s||(s=function(e,t){try{for(var n,i=e.toLowerCase(),o=null===(n=t.dict)||void 0===n||null===(n=n.get("AP"))||void 0===n||null===(n=n.get("N"))||void 0===n||null===(n=n.dict)||void 0===n||null===(n=n.get("Resources"))||void 0===n?void 0:n.get("Font"),r=(null==o?void 0:o.getRawValues())||[],a=(null==o?void 0:o.getKeys())||[],s=void 0,c=0;c<r.length;c++){var l;s=r[c];var d=a[c]||"",u=W(s?null===(l=t.xref.fetch(s).get("BaseFont"))||void 0===l?void 0:l.name:void 0)||"";if(i===u.toLowerCase()||i===d.toLowerCase())return u}if(Y[e]){var g,p=W(s?null===(g=t.xref.fetch(s).get("BaseFont"))||void 0===g?void 0:g.name:void 0)||"";return 0===p.indexOf(e)?p:e}}catch(e){(0,f.warn)("extractFontNameFromAppearanceStream error: "+e)}}(r,n)),i=s||r}catch(e){i=r}}}catch(e){}return i||t}(y,"",t)}this.setBorderStyle(o),this.annotationName=o.has("NM")?o.get("NM"):null;var w=function(e){if(!e||!e.has("GcProps"))return{};var t=e.get("GcProps"),n={};try{for(var i=t.getKeys(),o=0;o<i.length;o++){var r=i[o];if(t.has(r)){var a=t.get(r);"string"==typeof a?a=(0,f.stringToPDFString)(a):"object"===(0,c.A)(a)&&(0,v.Eo)(a)&&(a=(0,f.stringToPDFString)(a.name||"")),n[r.toLowerCase().replace("gc-","")]=a}}}catch(e){(0,f.warn)("readGcProps error: "+e)}return n}(o),k=this._hasFlag(this.flags,f.AnnotationFlag.LOCKED)||w.locked,A=this._hasFlag(this.flags,f.AnnotationFlag.LOCKEDCONTENTS)||w.lockedContents;if(this.data={annotationFlags:this.flags,borderStyle:this.borderStyle,color:this.color,contentsObj:this._contents,id:t.id,modificationDate:this.modificationDate,rect:this.rectangle,subtype:t.subtype,appearanceBBox:this.appearanceBBox,hasAppearance:!!this.checkHasNormalAppearance(o),contents:null===(n=this._contents)||void 0===n?void 0:n.str,title:null===(i=this._title)||void 0===i?void 0:i.str,annotationName:this.annotationName,interiorColor:this.interiorColor,appearanceColor:this.appearanceColor,rotate:this.rotate,opacity:this.opacity,fontSize:void 0===this.fontSize?12:this.fontSize,autoSizeFont:0===this.fontSize,fontName:this.fontName||"",additionalActions:r,gcProps:w,locked:k,lockedContents:A},this.data.printableFlag=this.printable,this.data.invisibleFlag=!this.viewable,this.data.noRotateFlag=this.hasFlag(f.AnnotationFlag.NOROTATE),this.setCMDates(o),t.collectFields){var S=o.get("Kids");if(Array.isArray(S)){var C,E=[],M=D(S);try{for(M.s();!(C=M.n()).done;){var P=C.value;(0,v.i9)(P)&&E.push(P.toString())}}catch(e){M.e(e)}finally{M.f()}0!==E.length&&(this.data.kidIds=E)}this.data.actions=(0,m.sv)(t.xref,o,f.AnnotationActionEventType),this.data.fieldName=this._constructFieldName(o),this.data.pageIndex=t.pageIndex}this._fallbackFontDict=null}),[{key:"loadResourcesForAppearance",value:function(e,t){return t.dict.getAsync("Resources").then((function(t){if(t)return new k.X(t,e,t.xref).load().then((function(){return t}))}))}},{key:"getOperatorListForAppearance",value:(t=(0,l.A)(h().mark((function e(t,n,i,o,r){var a,c,l,d,u,g,p,m,b,v,_,y;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a=this.data,c=i.dict,e.next=5,this.loadResourcesForAppearance(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"],i);case 5:return l=e.sent,d=(0,s.A)(a.rect),u=c.getArray("BBox")||[0,0,1,1],g=c.getArray("Matrix")||[1,0,0,1,0,0],r&&a.annotationType===f.AnnotationType.FREETEXT&&(p=f.Util.normalizeRect(u),m=(0,s.A)(d),b=0-m[0],v=0-m[1],m[0]+=b,m[1]+=v,m[2]+=b,m[3]+=v,Math.abs(p[0])<=1&&Math.abs(p[1])<=1&&(d=m)),_=F(d,u,g),(y=new A.P).addOp(f.OPS.beginAnnotation,[a.id,d,_,g,a.annotationType===f.AnnotationType.SIGNATURE]),e.next=15,t.getOperatorList({stream:i,task:n,resources:l,operatorList:y,fallbackFontDict:this._fallbackFontDict});case 15:if(y.addOp(f.OPS.endAnnotation,[]),i.reset(),!o){e.next=19;break}return e.abrupt("return",{opList:y,mark:o,data:this.data});case 19:return e.abrupt("return",y);case 22:return e.prev=22,e.t0=e.catch(0),(0,f.warn)("get annotation (id: "+this.data.id+", state key: "+o+") operators list error: "+e.t0),e.abrupt("return",new A.P);case 26:case"end":return e.stop()}}),e,this,[[0,22]])}))),function(e,n,i,o,r){return t.apply(this,arguments)})},{key:"_hasFlag",value:function(e,t){return!!(e&t)}},{key:"_isViewable",value:function(e){return!this._hasFlag(e,f.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,f.AnnotationFlag.NOVIEW)}},{key:"_isPrintable",value:function(e){return this._hasFlag(e,f.AnnotationFlag.PRINT)&&!this._hasFlag(e,f.AnnotationFlag.INVISIBLE)}},{key:"mustBeViewed",value:function(e){var t=e&&e.get(this.data.id);return t&&void 0!==t.hidden?!t.hidden:this.viewable&&!this._hasFlag(this.flags,f.AnnotationFlag.HIDDEN)}},{key:"mustBePrinted",value:function(e){var t=e&&e.get(this.data.id);return t&&void 0!==t.print?t.print:this.printable}},{key:"viewable",get:function(){return null!==this.data.quadPoints&&(0===this.flags||this._isViewable(this.flags))}},{key:"printable",get:function(){return null!==this.data.quadPoints&&0!==this.flags&&this._isPrintable(this.flags)}},{key:"_parseStringHelper",value:function(e){var t="string"==typeof e?(0,f.stringToPDFString)(e):"";return{str:t,dir:t&&"rtl"===(0,_.J)(t).dir?"rtl":"ltr"}}},{key:"setTitle",value:function(e){this._title=this._parseStringHelper(e),this.data&&(this.data.title=this._title.str)}},{key:"setContents",value:function(e){this._contents=this._parseStringHelper(e),this.data&&(this.data.contents=this._contents.str)}},{key:"setModificationDate",value:function(e){this.modificationDate=(0,f.isString)(e)?e:null}},{key:"setFlags",value:function(e){this.flags=Number.isInteger(e)&&e>0?e:0}},{key:"hasFlag",value:function(e){return this._hasFlag(this.flags,e)}},{key:"setRectangle",value:function(e){Array.isArray(e)&&4===e.length?this.rectangle=f.Util.normalizeRect(e):this.rectangle=[0,0,0,0]}},{key:"setColor",value:function(e){this[arguments.length>1&&void 0!==arguments[1]?arguments[1]:"color"]=(0,M.rgbToHex)(G(e))}},{key:"setBorderAndBackgroundColors",value:function(e){e instanceof v.Bi?(this.borderColor=R(e.getArray("BC"),null),this.backgroundColor=R(e.getArray("BG"),null)):this.borderColor=this.backgroundColor=null}},{key:"setBorderStyle",value:function(e){if(("undefined"==typeof PDFJSDev||PDFJSDev.test("!PRODUCTION || TESTING"))&&(0,f.assert)(this.rectangle,"setRectangle must have been called previously."),this.borderStyle=new Q,(0,v.Zm)(e))if(e.has("BS")){var t=e.get("BS");if(t instanceof v.Bi){var n=t.get("Type");n&&!(0,v.Eo)(n,"Border")||(this.borderStyle.setWidth(t.get("W"),this.rectangle),this.borderStyle.setStyle(t.get("S")),this.borderStyle.setDashArray(t.getArray("D")))}}else if(e.has("Border")){var i=e.getArray("Border");Array.isArray(i)&&i.length>=3&&(this.borderStyle.setHorizontalCornerRadius(i[0]),this.borderStyle.setVerticalCornerRadius(i[1]),this.borderStyle.setWidth(i[2],this.rectangle),4===i.length&&this.borderStyle.setDashArray(i[3]))}else{var o=0;(this instanceof le||this instanceof de||this instanceof ae||this instanceof se||this instanceof ce||this instanceof ge||this instanceof X||this instanceof re)&&(o=1),this.borderStyle.setWidth(o)}}},{key:"setAppearance",value:function(e){this.appearance=null;var t=e.get("AP");if((0,v.Zm)(t)){var n=t.get("N");if((0,v.rL)(n)){if(this.appearance=n,n.dict&&(this.appearanceBBox=n.dict.get("BBox"),this.appearanceBBox)){var i=Math.max(this.rectangle[2]-this.rectangle[0],this.rectangle[3]-this.rectangle[1]),o=Math.max(this.appearanceBBox[2]-this.appearanceBBox[0],this.appearanceBBox[3]-this.appearanceBBox[1]);if(i<o){var r=i/o;this.appearanceBBox[2]=this.appearanceBBox[2]*r,this.appearanceBBox[3]=this.appearanceBBox[3]*r}}}else if((0,v.Zm)(n)){var a=e.get("AS");(0,v.Eo)(a)&&n.has(a.name)&&(this.appearance=n.get(a.name))}}}},{key:"setAllAppearancesHash",value:function(e){this.allAppearancesHash={};var t=e.get("AP");if((0,v.Zm)(t)){var n=!1,i=!1;this.data&&this.data.annotationType===f.AnnotationType.REDACT&&(n=!0,i=!0),this.allAppearancesHash={N:null,R:null,D:null},this.allAppearancesHash.N=this.readAppearance(e,t,"N"),this.allAppearancesHash.R=n?this.readAppearance(e,t,"R"):null,this.allAppearancesHash.D=i?this.readAppearance(e,t,"D"):null;var o,r=D(t.getKeys()||[]);try{for(r.s();!(o=r.n()).done;){var a=o.value;if((i||"D"!==a)&&(n||"R"!==a)){var s=t.get(a);if((0,v.Zm)(s)){var c,l=D(s.getKeys()||[]);try{for(l.s();!(c=l.n()).done;){var d=c.value;this.allAppearancesHash[a.replace(/[\s\\\/\n]+/gm,"_")+"_"+d.replace(/[\s\\\/\n]+/gm,"_")]=this.readAppearance(e,t,a,d)}}catch(e){l.e(e)}finally{l.f()}}}}}catch(e){r.e(e)}finally{r.f()}}}},{key:"checkHasNormalAppearance",value:function(e){var t=e.get("AP");return!!(0,v.Zm)(t)&&!!this.readAppearance(e,t,"N")}},{key:"readAppearance",value:function(e,t,n,i){var o=t.get(n);if((0,v.rL)(o))return o;if(!(0,v.Zm)(o))return null;if(!i){var r=e.get("AS");if(!(0,v.Eo)(r)||!o.has(r.name))return null;i=r.name}return o.get(i)}},{key:"getPopupDict",value:function(e){var t=e&&e.has("Popup")?e.get("Popup"):null;return t&&(0,v.Zm)(t)?t:null}},{key:"getParentDict",value:function(e){var t=e&&e.has("Parent")?e.get("Parent"):null;return t&&(0,v.Zm)(t)?t:null}},{key:"setCMDates",value:function(e){var t=this.getPopupDict(e),n=this.getParentDict(e);this.setCreationDate(e&&e.has("CreationDate")?e.get("CreationDate"):null),this.creationDate||this.setCreationDate(t&&t.has("CreationDate")?t.get("CreationDate"):null),this.creationDate||this.setCreationDate(n&&n.has("CreationDate")?n.get("CreationDate"):null),this.setModificationDate(e&&e.has("M")?e.get("M"):null),this.modificationDate||this.setModificationDate(t&&t.has("M")?t.get("M"):null),this.modificationDate||this.setModificationDate(n&&n.has("M")?n.get("M"):null),this.data.creationDate=this.creationDate,this.data.modificationDate=this.modificationDate}},{key:"setCreationDate",value:function(e){this.creationDate=(0,f.isString)(e)?e:null}},{key:"_preparePopup",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;e.has("C")||(this.data.color=null);var n=this.getPopupDict(e);this.data.hasPopup=!!n,n&&(this.data.popupId=n.objId),this.data.title=(0,f.stringToPDFString)(e.get("T")||"");var i="";e.has("RC")?(i=(0,f.stringToPDFString)(e.get("RC")||""),this.data.isRichContents=!0):(i=(0,f.stringToPDFString)(e.get("Contents")||""),this.data.isRichContents=!1),this.data.contents=i,t===f.AnnotationType.FREETEXT?this.data.open=!0:this.data.open=!!e.has("Open")&&e.get("Open")}},{key:"loadResources",value:function(e){return this.appearance.dict.getAsync("Resources").then((function(t){if(t)return new k.X(t,e,t.xref).load().then((function(){return t}))}))}},{key:"getOperatorList",value:function(e,t,n,i){var o=this;if(!this.appearance)return Promise.resolve(new A.P);var r=this.appearance,a=this.data,s=r.dict,c=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),l=s.getArray("BBox")||[0,0,1,1],d=s.getArray("Matrix")||[1,0,0,1,0,0],u=F(a.rect,l,d);return c.then((function(n){var i=new A.P;return i.addOp(f.OPS.beginAnnotation,[a.id,a.rect,u,d,a.annotationType===f.AnnotationType.SIGNATURE]),e.getOperatorList({stream:r,task:t,resources:n,operatorList:i,fallbackFontDict:o._fallbackFontDict}).then((function(){return i.addOp(f.OPS.endAnnotation,[]),o.reset(),i}))}))}},{key:"save",value:(e=(0,l.A)(h().mark((function e(t,n,i){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",null);case 1:case"end":return e.stop()}}),e)}))),function(t,n,i){return e.apply(this,arguments)})},{key:"getFieldObject",value:function(){return this.data.kidIds?{id:this.data.id,actions:this.data.actions,name:this.data.fieldName,type:"",kidIds:this.data.kidIds,page:this.data.pageIndex}:null}},{key:"reset",value:function(){"undefined"!=typeof PDFJSDev&&!PDFJSDev.test("!PRODUCTION || TESTING")||!this.appearance||this._streams.includes(this.appearance)||(0,f.unreachable)("The appearance stream should always be reset.");var e,t=D(this._streams);try{for(t.s();!(e=t.n()).done;)e.value.reset()}catch(e){t.e(e)}finally{t.f()}}},{key:"_constructFieldName",value:function(e){if(!e.has("T")&&!e.has("Parent"))return(0,f.warn)("Unknown field name, falling back to empty field name."),"";if(!e.has("Parent"))return(0,f.stringToPDFString)(e.get("T"));var t=[];e.has("T")&&t.unshift((0,f.stringToPDFString)(e.get("T")));var n=e,i=new v.mx;for(e.objId&&i.put(e.objId);n.has("Parent")&&(n=n.get("Parent"))instanceof v.Bi&&(!n.objId||!i.has(n.objId));)n.objId&&i.put(n.objId),n.has("T")&&t.unshift((0,f.stringToPDFString)(n.get("T")));return t.join(".")}}]);var e,t}(),Q=(0,g.A)((function e(){(0,u.A)(this,e),this.width=1,this.style=f.AnnotationBorderStyleType.SOLID,this.dashArray=[3],this.horizontalCornerRadius=0,this.verticalCornerRadius=0}),[{key:"setWidth",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0,0];if(("undefined"==typeof PDFJSDev||PDFJSDev.test("!PRODUCTION || TESTING"))&&(0,f.assert)(Array.isArray(t)&&4===t.length,"A valid `rect` parameter must be provided."),(0,v.Eo)(e))this.width=0;else if(Number.isInteger(e)){if(e>0){var n=(t[2]-t[0])/2,i=(t[3]-t[1])/2;n>0&&i>0&&(e>n||e>i)&&((0,f.warn)("AnnotationBorderStyle.setWidth - ignoring width: ".concat(e)),e=1)}this.width=e}}},{key:"setStyle",value:function(e){if((0,v.Eo)(e))switch(e.name){case"S":this.style=f.AnnotationBorderStyleType.SOLID;break;case"D":this.style=f.AnnotationBorderStyleType.DASHED;break;case"B":this.style=f.AnnotationBorderStyleType.BEVELED;break;case"I":this.style=f.AnnotationBorderStyleType.INSET;break;case"U":this.style=f.AnnotationBorderStyleType.UNDERLINE}}},{key:"setDashArray",value:function(e){if(Array.isArray(e)&&e.length>0){var t,n=!0,i=!0,o=D(e);try{for(o.s();!(t=o.n()).done;){var r=t.value;if(!(+r>=0)){n=!1;break}r>0&&(i=!1)}}catch(e){o.e(e)}finally{o.f()}n&&!i?this.dashArray=e:this.width=0}else e&&(this.width=0)}},{key:"setHorizontalCornerRadius",value:function(e){Number.isInteger(e)&&(this.horizontalCornerRadius=e)}},{key:"setVerticalCornerRadius",value:function(e){Number.isInteger(e)&&(this.verticalCornerRadius=e)}}]),J=function(e){function t(e){var n;(0,u.A)(this,t),n=I(this,t,[e]);var i=e.dict;i.has("C")||(n.data.color=null),n.data.hasPopup=i.has("Popup"),n.data.title=(0,f.stringToPDFString)(i.get("T")||""),n.data.subject=(0,f.stringToPDFString)(i.get("Subj")||""),i.has("RC")?(n.data.contents=(0,f.stringToPDFString)(i.get("RC")||""),n.data.isRichContents=!0):(n.data.contents=(0,f.stringToPDFString)(i.get("Contents")||""),n.data.isRichContents=!1);var o=i.has("RT")?i.get("RT"):null;n.data.referenceType=(0,v.Eo)(o)?o.name:null;var r=i.has("IRT")?i.get("IRT"):null;return r&&(n.data.referenceAnnotationId=r.objId),i.has("RC")&&(n.data.richText=E.a.getRichTextAsHtml(i.get("RC"))),n}return(0,a.A)(t,e),(0,g.A)(t,[{key:"_setDefaultAppearance",value:function(e){var t=e.xref,n=e.extra,i=e.strokeColor,o=e.fillColor,r=e.blendMode,a=e.strokeAlpha,s=e.fillAlpha,c=e.pointsCallback,l=Number.MAX_VALUE,u=Number.MAX_VALUE,g=Number.MIN_VALUE,p=Number.MIN_VALUE,h=["q"];n&&h.push(n),i&&h.push("".concat(i[0]," ").concat(i[1]," ").concat(i[2]," RG")),o&&h.push("".concat(o[0]," ").concat(o[1]," ").concat(o[2]," rg"));var f=this.data.quadPoints;f||(f=[[{x:this.rectangle[0],y:this.rectangle[3]},{x:this.rectangle[2],y:this.rectangle[3]},{x:this.rectangle[0],y:this.rectangle[1]},{x:this.rectangle[2],y:this.rectangle[1]}]]);var m,b=D(f);try{for(b.s();!(m=b.n()).done;){var _=c(h,m.value),y=(0,d.A)(_,4),x=y[0],w=y[1],k=y[2],A=y[3];l=Math.min(l,x),g=Math.max(g,w),u=Math.min(u,k),p=Math.max(p,A)}}catch(e){b.e(e)}finally{b.f()}h.push("Q");var C=new v.Bi(t),E=new v.Bi(t);E.set("Subtype",v.SX.get("Form"));var M=new S.Kw(h.join(" "));M.dict=E,C.set("Fm0",M);var P=new v.Bi(t);r&&P.set("BM",v.SX.get(r)),"number"==typeof a&&P.set("CA",a),"number"==typeof s&&P.set("ca",s);var T=new v.Bi(t);T.set("GS0",P);var I=new v.Bi(t);I.set("ExtGState",T),I.set("XObject",C);var L=new v.Bi(t);L.set("Resources",I);var O=this.data.rect=[l,u,g,p];L.set("BBox",O),this.appearance=new S.Kw("/GS0 gs /Fm0 Do"),this.appearance.dict=L,this._streams.push(this.appearance,M)}}])}(q),X=function(e){function t(e){var n;(0,u.A)(this,t),n=I(this,t,[e]);var i=e.dict,o=n.data;!function(e,t){try{if(e.has("MK")){var n=e.get("MK");t.borderColor=G(n.get("BC")),t.backgroundColor=G(n.get("BG")),t.CA=(0,f.stringToPDFString)(n.has("CA")?n.get("CA"):""),t.RC=(0,f.stringToPDFString)(n.has("RC")?n.get("RC"):t.CA),t.AC=(0,f.stringToPDFString)(n.has("AC")?n.get("AC"):t.RC),t.TP=n.has("TP")?n.get("TP"):0,t.orientation=n.has("R")?n.get("R"):0}}catch(e){(0,f.warn)("parseMk error")}}(i,o),n.ref=e.ref,o.annotationType=f.AnnotationType.WIDGET,void 0===o.fieldName&&(o.fieldName=n._constructFieldName(i)),void 0===o.actions&&(o.actions=(0,m.sv)(e.xref,i,f.AnnotationActionEventType));var r=(0,m.Zx)({dict:i,key:"V",getArray:!0});o.fieldValue=n._decodeFormValue(r);var a=(0,m.Zx)({dict:i,key:"DV",getArray:!0});o.defaultFieldValue=n._decodeFormValue(a),void 0===r&&null!==o.defaultFieldValue&&(o.fieldValue=o.defaultFieldValue);var s=i.get("TU")||"";s||(s=(0,m.Zx)({dict:i,key:"TU"})||""),o.alternativeText=(0,f.stringToPDFString)(s);var c=(0,m.Zx)({dict:i,key:"DA"})||e.acroForm.get("DA");n._defaultAppearance=(0,f.isString)(c)?c:"",o.defaultAppearanceData=(0,b.v)(n._defaultAppearance);var l=(0,m.Zx)({dict:i,key:"FT"});o.fieldType=(0,v.Eo)(l)?l.name:null;var d=(0,m.Zx)({dict:i,key:"DR"}),g=e.acroForm.get("DR"),p=n.appearance&&n.appearance.dict.get("Resources");return n._fieldResources={localResources:d,acroFormResources:g,appearanceResources:p,mergedResources:v.Bi.merge({xref:e.xref,dictArray:[d,p,g],mergeSubDicts:!0})},o.fieldFlags=(0,m.Zx)({dict:i,key:"Ff"}),(!Number.isInteger(o.fieldFlags)||o.fieldFlags<0)&&(o.fieldFlags=0),o.readOnly=n.hasFieldFlag(f.AnnotationFieldFlag.READONLY),o.hidden=n._hasFlag(o.annotationFlags,f.AnnotationFlag.HIDDEN),o.required=n.hasFieldFlag(f.AnnotationFieldFlag.REQUIRED),o.noExport=n.hasFieldFlag(f.AnnotationFieldFlag.NOEXPORT),n}return(0,a.A)(t,e),(0,g.A)(t,[{key:"_decodeFormValue",value:function(e){return Array.isArray(e)?e.filter((function(e){return(0,f.isString)(e)})).map((function(e){return(0,f.stringToPDFString)(e)})):(0,v.Eo)(e)?(0,f.stringToPDFString)(e.name):(0,f.isString)(e)?(0,f.stringToPDFString)(e):(0,f.isNum)(e)||(0,f.isBool)(e)?e.toString():null}},{key:"hasFieldFlag",value:function(e){return!!(this.data.fieldFlags&e)}},{key:"getOperatorList",value:function(e,n,i,o){var r=this;return i?Promise.resolve(new A.P):this._hasText?this._getAppearance(e,n,o).then((function(a){if(r.appearance&&null===a)return T(t,"getOperatorList",r,3)([e,n,i,o]);var s=new A.P;if(!r._defaultAppearance||null===a)return s;var c=[1,0,0,1,0,0],l=[0,0,r.data.rect[2]-r.data.rect[0],r.data.rect[3]-r.data.rect[1]],d=F(r.data.rect,l,c);s.addOp(f.OPS.beginAnnotation,[r.data.id,r.data.rect,d,c,data.annotationType===f.AnnotationType.SIGNATURE]);var u=new S.Kw(a);return e.getOperatorList({stream:u,task:n,resources:r._fieldResources.mergedResources,operatorList:s}).then((function(){return s.addOp(f.OPS.endAnnotation,[]),s}))})):T(t,"getOperatorList",this,3)([e,n,i,o])}},{key:"save",value:(o=(0,l.A)(h().mark((function e(t,n,i){var o,r,a,s,c,l,d,u,g,p,m,b,_,y,x;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i){e.next=2;break}return e.abrupt("return",null);case 2:if(o=i.get(this.data.id),(r=o&&o.value)!==this.data.fieldValue&&void 0!==r){e.next=6;break}return e.abrupt("return",null);case 6:return e.next=8,this._getAppearance(t,n,i);case 8:if(null!==(a=e.sent)){e.next=11;break}return e.abrupt("return",null);case 11:if(s=t.xref,c=s.fetchIfRef(this.ref),(0,v.Zm)(c)){e.next=15;break}return e.abrupt("return",null);case 15:return l=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],d={path:(0,f.stringToPDFString)(c.get("T")||""),value:r},u=s.getNewRef(),(g=new v.Bi(s)).set("N",u),p=s.encrypt,m=null,b=null,p&&(m=p.createCipherTransform(this.ref.num,this.ref.gen),b=p.createCipherTransform(u.num,u.gen),a=b.encryptString(a)),c.set("V",(0,f.isAscii)(r)?r:(0,f.stringToUTF16BEString)(r)),c.set("AP",g),c.set("M","D:".concat((0,f.getModificationDate)())),(_=new v.Bi(s)).set("Length",a.length),_.set("Subtype",v.SX.get("Form")),_.set("Resources",this._getSaveFieldResources(s)),_.set("BBox",l),y=["".concat(this.ref.num," ").concat(this.ref.gen," obj\n")],(0,C.O)(c,y,m),y.push("\nendobj\n"),x=["".concat(u.num," ").concat(u.gen," obj\n")],(0,C.O)(_,x,b),x.push(" stream\n",a,"\nendstream\nendobj\n"),e.abrupt("return",[{ref:this.ref,data:y.join(""),xfa:d},{ref:u,data:x.join(""),xfa:null}]);case 39:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"_getAppearance",value:(i=(0,l.A)(h().mark((function e(t,n,i){var o,r,a,s,c,l,u,g,p,m,v,_,y,x,w,k,A,S;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this.hasFieldFlag(f.AnnotationFieldFlag.PASSWORD),i&&!o){e.next=3;break}return e.abrupt("return",null);case 3:if(r=i.get(this.data.id),void 0!==(a=r&&r.value)){e.next=7;break}return e.abrupt("return",null);case 7:if(""!==(a=a.trim())){e.next=10;break}return e.abrupt("return","");case 10:return s=-1,this.data.multiLine&&(s=a.split(/\r\n|\r|\n/).length),l=c=2,u=this.data.rect[3]-this.data.rect[1],g=this.data.rect[2]-this.data.rect[0],this._defaultAppearance||(this.data.defaultAppearanceData=(0,b.v)(this._defaultAppearance="/Helvetica 0 Tf 0 g")),p=this._computeFontSize(u,s),m=(0,d.A)(p,2),v=m[0],_=m[1],e.next=20,this._getFontData(t,n);case 20:if(y=e.sent,x=y.descent,isNaN(x)&&(x=0),w=c+Math.abs(x)*_,k=this.data.textAlignment,!this.data.multiLine){e.next=27;break}return e.abrupt("return",this._getMultilineAppearance(v,a,y,_,g,u,k,l,w));case 27:if(A=y.encodeString(a).join(""),!this.data.comb){e.next=30;break}return e.abrupt("return",this._getCombAppearance(v,y,A,g,l,w));case 30:if(!(0===k||k>2)){e.next=32;break}return e.abrupt("return","/Tx BMC q BT "+v+" 1 0 0 1 ".concat(l," ").concat(w," Tm (").concat((0,f.escapeString)(A),") Tj")+" ET Q EMC");case 32:return S=this._renderText(A,y,_,g,k,l,w),e.abrupt("return","/Tx BMC q BT "+v+" 1 0 0 1 0 0 Tm ".concat(S)+" ET Q EMC");case 34:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"_getFontData",value:(n=(0,l.A)(h().mark((function e(t,n){var i,o,r,a,s;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new A.P,o={font:null,clone:function(){return this}},r=this.data.defaultAppearanceData,a=r.fontName,s=r.fontSize,e.next=5,t.handleSetFont(this._fieldResources.mergedResources,[a&&v.SX.get(a),s],null,i,n,o,null);case 5:return e.abrupt("return",o.font);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_computeFontSize",value:function(e,t){var n=this.data.defaultAppearanceData.fontSize;if(!n){var i=function(e){return Math.round(10*e)/10};if(-1===t)n=i(.8*e);else{var o=(n=10)/.8,r=Math.round(e/o);n=i(.8*(o=e/(r=Math.max(r,t))))}var a=this.data.defaultAppearanceData,s=a.fontName,c=a.fontColor;this._defaultAppearance=(0,b.E)({fontSize:n,fontName:s,fontColor:c})}return[this._defaultAppearance,n]}},{key:"_renderText",value:function(e,t,n,i,o,r,a){var s,c,l=n/1e3,d=0,u=D(t.charsToGlyphs(e));try{for(u.s();!(s=u.n()).done;)d+=s.value.width*l}catch(e){u.e(e)}finally{u.f()}return c=(c=1===o?(i-d)/2:2===o?i-d-r:r).toFixed(2),a=a.toFixed(2),"".concat(c," ").concat(a," Td (").concat((0,f.escapeString)(e),") Tj")}},{key:"_getSaveFieldResources",value:function(e){("undefined"==typeof PDFJSDev||PDFJSDev.test("!PRODUCTION || TESTING"))&&(0,f.assert)(this.data.defaultAppearanceData,"Expected `_defaultAppearanceData` to have been set.");var t=this._fieldResources,n=t.localResources,i=t.appearanceResources,o=t.acroFormResources,r=this.data.defaultAppearanceData&&this.data.defaultAppearanceData.fontName;if(!r)return n||v.Bi.empty;for(var a=0,s=[n,i];a<s.length;a++){var c=s[a];if(c instanceof v.Bi){var l=c.get("Font");if(l instanceof v.Bi&&l.has(r))return c}}if(o instanceof v.Bi){var d=o.get("Font");if(d instanceof v.Bi&&d.has(r)){var u=new v.Bi(e);u.set(r,d.getRaw(r));var g=new v.Bi(e);return g.set("Font",u),v.Bi.merge({xref:e,dictArray:[g,n],mergeSubDicts:!0})}}return n||v.Bi.empty}},{key:"getFieldObject",value:function(){return null}}]);var n,i,o}(q);function K(e,t){try{!t.has("C")&&!e.data.borderColor&&e.borderStyle&&e.borderStyle.style&&(e.data.color=null,e.borderStyle.width=0,e.borderStyle.style===f.AnnotationBorderStyleType.DASHED&&(e.borderStyle.style=f.AnnotationBorderStyleType.SOLID))}catch(e){(0,f.warn)("fixFormElementBorder error:"+e)}}var Z=function(e){function t(e){var n;(0,u.A)(this,t),(n=I(this,t,[e]))._hasText=!0;var i=e.dict;(0,f.isString)(n.data.fieldValue)||(n.data.fieldValue="");var o=(0,m.Zx)({dict:i,key:"Q"});(!Number.isInteger(o)||o<0||o>2)&&(o=null),n.data.textAlignment=o;var r=(0,m.Zx)({dict:i,key:"MaxLen"});return(!Number.isInteger(r)||r<0)&&(r=null),n.data.maxLen=r,n.data.multiLine=n.hasFieldFlag(f.AnnotationFieldFlag.MULTILINE),n.data.comb=n.hasFieldFlag(f.AnnotationFieldFlag.COMB)&&!n.hasFieldFlag(f.AnnotationFieldFlag.MULTILINE)&&!n.hasFieldFlag(f.AnnotationFieldFlag.PASSWORD)&&!n.hasFieldFlag(f.AnnotationFieldFlag.FILESELECT)&&null!==n.data.maxLen,n.data.hasPasswordFlag=n.hasFieldFlag(f.AnnotationFieldFlag.PASSWORD),K(n,i),n}return(0,a.A)(t,e),(0,g.A)(t,[{key:"_getCombAppearance",value:function(e,t,n,i,o,r){var a,s=(i/this.data.maxLen).toFixed(2),c=[],l=D(t.getCharPositions(n));try{for(l.s();!(a=l.n()).done;){var u=(0,d.A)(a.value,2),g=u[0],p=u[1];c.push("(".concat((0,f.escapeString)(n.substring(g,p)),") Tj"))}}catch(e){l.e(e)}finally{l.f()}var h=c.join(" ".concat(s," 0 Td "));return"/Tx BMC q BT "+e+" 1 0 0 1 ".concat(o," ").concat(r," Tm ").concat(h)+" ET Q EMC"}},{key:"_getMultilineAppearance",value:function(e,t,n,i,o,r,a,s,c){var l,d=[],u=o-2*s,g=D(t.split(/\r\n|\r|\n/));try{for(g.s();!(l=g.n()).done;){var p,h=l.value,f=D(this._splitLine(h,n,i,u));try{for(f.s();!(p=f.n()).done;){var m=p.value,b=0===d.length?s:0;d.push(this._renderText(m,n,i,o,a,b,-i))}}catch(e){f.e(e)}finally{f.f()}}}catch(e){g.e(e)}finally{g.f()}var v=d.join("\n");return"/Tx BMC q BT "+e+" 1 0 0 1 0 ".concat(r," Tm ").concat(v)+" ET Q EMC"}},{key:"_splitLine",value:function(e,t,n,i){e=t.encodeString(e).join("");var o=t.charsToGlyphs(e);if(o.length<=1)return[e];for(var r=t.getCharPositions(e),a=n/1e3,s=[],c=-1,l=-1,u=-1,g=0,p=0,h=0,f=o.length;h<f;h++){var m=(0,d.A)(r[h],2),b=m[0],v=m[1],_=o[h],y=_.width*a;" "===_.unicode?p+y>i?(s.push(e.substring(g,b)),g=b,p=y,c=-1,u=-1):(p+=y,c=b,l=v,u=h):p+y>i?-1!==c?(s.push(e.substring(g,l)),g=l,h=u+1,c=-1,p=0):(s.push(e.substring(g,b)),g=b,p=y):p+=y}return g<e.length&&s.push(e.substring(g,e.length)),s}},{key:"getFieldObject",value:function(){return{id:this.data.id,value:this.data.fieldValue,defaultValue:this.data.defaultFieldValue,multiline:this.data.multiLine,password:this.hasFieldFlag(f.AnnotationFieldFlag.PASSWORD),charLimit:this.data.maxLen,comb:this.data.comb,editable:!this.data.readOnly,hidden:this.data.hidden,name:this.data.fieldName,rect:this.data.rect,actions:this.data.actions,page:this.data.pageIndex,type:"text"}}}])}(X),$=function(e){function t(e){var n;return(0,u.A)(this,t),(n=I(this,t,[e])).checkedAppearance=null,n.uncheckedAppearance=null,n.data.checkBox=!n.hasFieldFlag(f.AnnotationFieldFlag.RADIO)&&!n.hasFieldFlag(f.AnnotationFieldFlag.PUSHBUTTON),n.data.radioButton=n.hasFieldFlag(f.AnnotationFieldFlag.RADIO)&&!n.hasFieldFlag(f.AnnotationFieldFlag.PUSHBUTTON),n.data.pushButton=n.hasFieldFlag(f.AnnotationFieldFlag.PUSHBUTTON),n.data.isTooltipOnly=!1,n.data.checkBox?n._processCheckBox(e):n.data.radioButton?n._processRadioButton(e):n.data.pushButton?n._processPushButton(e):(0,f.warn)("Invalid field flags for button widget annotation"),K(n,e.dict),n}return(0,a.A)(t,e),(0,g.A)(t,[{key:"getOperatorList",value:function(e,n,i,o){if(this.data.pushButton)return T(t,"getOperatorList",this,3)([e,n,!1,o]);if(o){var r,a=o.get(this.data.id),s=a&&a.value;if(void 0===s)return T(t,"getOperatorList",this,3)([e,n,i,o]);if(r=s?this.checkedAppearance:this.uncheckedAppearance){var c=this.appearance;this.appearance=r;var l=T(t,"getOperatorList",this,3)([e,n,i,o]);return this.appearance=c,l}return Promise.resolve(new A.P)}return T(t,"getOperatorList",this,3)([e,n,i,o])}},{key:"save",value:(o=(0,l.A)(h().mark((function e(t,n,i){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.data.checkBox){e.next=2;break}return e.abrupt("return",this._saveCheckbox(t,n,i));case 2:if(!this.data.radioButton){e.next=4;break}return e.abrupt("return",this._saveRadioButton(t,n,i));case 4:return e.abrupt("return",null);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"_saveCheckbox",value:(i=(0,l.A)(h().mark((function e(t,n,i){var o,r,a,s,c,l,d,u;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i){e.next=2;break}return e.abrupt("return",null);case 2:if(o=i.get(this.data.id),void 0!==(r=o&&o.value)){e.next=6;break}return e.abrupt("return",null);case 6:if((this.data.fieldValue&&"Off"!==this.data.fieldValue)!==r){e.next=9;break}return e.abrupt("return",null);case 9:if(a=t.xref.fetchIfRef(this.ref),(0,v.Zm)(a)){e.next=12;break}return e.abrupt("return",null);case 12:return s={path:(0,f.stringToPDFString)(a.get("T")||""),value:r?this.data.exportValue:""},c=v.SX.get(r?this.data.exportValue:"Off"),a.set("V",c),a.set("AS",c),a.set("M","D:".concat((0,f.getModificationDate)())),l=t.xref.encrypt,d=null,l&&(d=l.createCipherTransform(this.ref.num,this.ref.gen)),u=["".concat(this.ref.num," ").concat(this.ref.gen," obj\n")],(0,C.O)(a,u,d),u.push("\nendobj\n"),e.abrupt("return",[{ref:this.ref,data:u.join(""),xfa:s}]);case 24:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"_saveRadioButton",value:(n=(0,l.A)(h().mark((function e(t,n,i){var o,r,a,s,c,l,d,u,g,p,m,b;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i){e.next=2;break}return e.abrupt("return",null);case 2:if(o=i.get(this.data.id),void 0!==(r=o&&o.value)){e.next=6;break}return e.abrupt("return",null);case 6:if(this.data.fieldValue===this.data.exportValue!==r){e.next=9;break}return e.abrupt("return",null);case 9:if(a=t.xref.fetchIfRef(this.ref),(0,v.Zm)(a)){e.next=12;break}return e.abrupt("return",null);case 12:return s={path:(0,f.stringToPDFString)(a.get("T")||""),value:r?this.data.exportValue:""},c=v.SX.get(r?this.data.exportValue:"Off"),l=null,d=t.xref.encrypt,r&&((0,v.i9)(this.parent)?(u=t.xref.fetch(this.parent),g=null,d&&(g=d.createCipherTransform(this.parent.num,this.parent.gen)),u.set("V",c),l=["".concat(this.parent.num," ").concat(this.parent.gen," obj\n")],(0,C.O)(u,l,g),l.push("\nendobj\n")):(0,v.Zm)(this.parent)&&this.parent.set("V",c)),a.set("AS",c),a.set("M","D:".concat((0,f.getModificationDate)())),p=null,d&&(p=d.createCipherTransform(this.ref.num,this.ref.gen)),m=["".concat(this.ref.num," ").concat(this.ref.gen," obj\n")],(0,C.O)(a,m,p),m.push("\nendobj\n"),b=[{ref:this.ref,data:m.join(""),xfa:s}],null!==l&&b.push({ref:this.parent,data:l.join(""),xfa:null}),e.abrupt("return",b);case 27:case"end":return e.stop()}}),e,this)}))),function(e,t,i){return n.apply(this,arguments)})},{key:"_readButtonValue",value:function(e){var t=e.dict.get("AP");if((0,v.Zm)(t)){var n=t.get("N");if((0,v.Zm)(n))for(var i=n.getKeys(),o=0,r=i.length;o<r;o++)if("Off"!==i[o]){this.data.exportValue=i[o];break}}}},{key:"_processCheckBox",value:function(e){(0,v.Eo)(this.data.fieldValue)&&(this.data.fieldValue=this.data.fieldValue.name),this._readButtonValue(e);var t=e.dict.get("AP");if((0,v.Zm)(t)){var n=t.get("N");if((0,v.Zm)(n)){var i=this._decodeFormValue(e.dict.get("AS"));"string"==typeof i&&(this.data.fieldValue=i);var o=n.getKeys();o.includes("Off")||o.push("Off"),o.includes(this.data.fieldValue)||(this.data.fieldValue=null),2===o.length&&(this.data.exportValue="Off"===o[0]?o[1]:o[0],this.checkedAppearance=n.get(this.data.exportValue),this.uncheckedAppearance=n.get("Off")||null,this._streams.push(this.checkedAppearance),this.uncheckedAppearance&&this._streams.push(this.uncheckedAppearance),this._fallbackFontDict=this.fallbackFontDict)}}}},{key:"_processRadioButton",value:function(e){this.data.radiosInUnison=this.hasFieldFlag(f.AnnotationFieldFlag.RADIOSINUNISON);var t=e.dict.get("Parent");if(t&&(0,v.Zm)(t))if(t.has("V")){var n=t.get("V");this.data.fieldValue=(0,v.Eo)(n)?n.name:n}else this.data.fieldValue=null;this.data.exportValue=null,this._readButtonValue(e);var i=e.dict.get("AP");if((0,v.Zm)(i)){var o=i.get("N");if((0,v.Zm)(o)){var r,a=D(o.getKeys());try{for(a.s();!(r=a.n()).done;){var s=r.value;if("Off"!==s){this.data.exportValue=this._decodeFormValue(s);break}}}catch(e){a.e(e)}finally{a.f()}this.checkedAppearance=o.get(this.data.exportValue),this.uncheckedAppearance=o.get("Off")||null,this._streams.push(this.checkedAppearance),this.uncheckedAppearance&&this._streams.push(this.uncheckedAppearance),this._fallbackFontDict=this.fallbackFontDict}}}},{key:"_processPushButton",value:function(e){this.data.fieldValue=(0,f.stringToPDFString)(this.data.fieldValue||this.data.AC||""),this.data.isTooltipOnly=!e.dict.has("A")&&!e.dict.has("AA"),y.W.parseDestDictionary({destDict:e.dict,resultObj:this.data,docBaseUrl:e.pdfManager.docBaseUrl})}},{key:"getFieldObject",value:function(){var e,t="button";return this.data.checkBox?(t="checkbox",e=this.data.exportValue):this.data.radioButton&&(t="radiobutton",e=this.data.exportValue),{id:this.data.id,value:this.data.fieldValue||"Off",defaultValue:this.data.defaultFieldValue,exportValues:e,editable:!this.data.readOnly,name:this.data.fieldName,rect:this.data.rect,hidden:this.data.hidden,actions:this.data.actions,page:this.data.pageIndex,type:t}}},{key:"fallbackFontDict",get:function(){var e=new v.Bi;return e.set("BaseFont",v.SX.get("ZapfDingbats")),e.set("Type",v.SX.get("FallbackType")),e.set("Subtype",v.SX.get("FallbackType")),e.set("Encoding",v.SX.get("ZapfDingbatsEncoding")),(0,f.shadow)(this,"fallbackFontDict",e)}}]);var n,i,o}(X),ee=function(e){function t(e){var n;(0,u.A)(this,t),(n=I(this,t,[e])).data.options=[];var i=(0,m.Zx)({dict:e.dict,key:"Opt"});if(Array.isArray(i))for(var o=e.xref,r=0,a=i.length;r<a;r++){var s=o.fetchIfRef(i[r]),c=Array.isArray(s);n.data.options[r]={exportValue:n._decodeFormValue(c?o.fetchIfRef(s[0]):s),displayValue:n._decodeFormValue(c?o.fetchIfRef(s[1]):s)}}return(0,f.isString)(n.data.fieldValue)?n.data.fieldValue=[n.data.fieldValue]:n.data.fieldValue||(n.data.fieldValue=[]),n.data.hasEditFlag=n.hasFieldFlag(f.AnnotationFieldFlag.EDIT),n.data.combo=n.hasFieldFlag(f.AnnotationFieldFlag.COMBO),n.data.multiSelect=n.hasFieldFlag(f.AnnotationFieldFlag.MULTISELECT),n._hasText=!0,n}return(0,a.A)(t,e),(0,g.A)(t,[{key:"getFieldObject",value:function(){var e=this.data.combo?"combobox":"listbox",t=this.data.fieldValue.length>0?this.data.fieldValue[0]:null;return{id:this.data.id,value:t,defaultValue:this.data.defaultFieldValue,editable:!this.data.readOnly,name:this.data.fieldName,rect:this.data.rect,numItems:this.data.fieldValue.length,multipleSelection:this.data.multiSelect,hidden:this.data.hidden,actions:this.data.actions,items:this.data.options,page:this.data.pageIndex,type:e}}}])}(X),te=function(e){function t(e){var n;(0,u.A)(this,t),(n=I(this,t,[e])).data.fieldValue=null;var i=e.dict;if(n.data.contents=n.data.CA||"",n.data.annotationType=f.AnnotationType.SIGNATURE,i.has("T")&&(n.data.fieldName=(0,f.stringToPDFString)(i.get("T"))),i.has("V")){var o={},r=i.get("V");o.name=r.has("Name")?(0,f.stringToPDFString)(r.get("Name")):"",o.filter=r.has("Filter")?r.get("Filter").name:"",o.subFilter=r.has("SubFilter")?r.get("SubFilter").name:"",o.location=r.has("Location")?(0,f.stringToPDFString)(r.get("Location")):"",o.modificationDate=r.has("M")?r.get("M"):"",n.data.signatureValue=o}var a=(0,m.Zx)({dict:i,key:"Q"});return(!Number.isInteger(a)||a<0||a>2)&&(a=null),n.data.textAlignment=a,n}return(0,a.A)(t,e),(0,g.A)(t,[{key:"getFieldObject",value:function(){return{id:this.data.id,value:null,page:this.data.pageIndex,type:"signature"}}}])}(X),ne=function(e){function t(e){var n;(