pdfjs-dist
Version:
Generic build of Mozilla's PDF.js library.
25 lines • 66.9 kB
JavaScript
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2024 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* JavaScript code in this page
*/
/**
* pdfjsVersion = 5.7.284
* pdfjsBuild = 7e5b36c2d
*/class SandboxSupportBase{constructor(e){this.win=e;this.timeoutIds=new Map;this.commFun=null}destroy(){this.commFun=null;for(const e of this.timeoutIds.values())this.win.clearTimeout(e);this.timeoutIds=null}exportValueToSandbox(e){throw new Error("Not implemented")}importValueFromSandbox(e){throw new Error("Not implemented")}createErrorForSandbox(e){throw new Error("Not implemented")}callSandboxFunction(e,t){if(this.commFun)try{t=this.exportValueToSandbox(t);this.commFun(e,t)}catch(e){this.win.console.error(e)}}createSandboxExternals(){const e={setTimeout:(e,t)=>{if("number"!=typeof e||"number"!=typeof t)return;0===e&&this.win.clearTimeout(this.timeoutIds.get(e));const r=this.win.setTimeout(()=>{this.timeoutIds.delete(e);this.callSandboxFunction("timeoutCb",{callbackId:e,interval:!1})},t);this.timeoutIds.set(e,r)},clearTimeout:e=>{this.win.clearTimeout(this.timeoutIds.get(e));this.timeoutIds.delete(e)},setInterval:(e,t)=>{if("number"!=typeof e||"number"!=typeof t)return;const r=this.win.setInterval(()=>{this.callSandboxFunction("timeoutCb",{callbackId:e,interval:!0})},t);this.timeoutIds.set(e,r)},clearInterval:e=>{this.win.clearInterval(this.timeoutIds.get(e));this.timeoutIds.delete(e)},alert:e=>{"string"==typeof e&&this.win.alert(e)},confirm:e=>"string"==typeof e&&this.win.confirm(e),prompt:(e,t)=>"string"!=typeof e||"string"!=typeof t?null:this.win.prompt(e,t),parseURL:e=>{const t=new this.win.URL(e);return Object.fromEntries(["hash","host","hostname","href","origin","password","pathname","port","protocol","search","searchParams","username"].map(e=>[e,t[e].toString()]))},send:e=>{if(!e)return;const t=new this.win.CustomEvent("updatefromsandbox",{detail:this.importValueFromSandbox(e)});this.win.dispatchEvent(t)}};Object.setPrototypeOf(e,null);return(t,r)=>{try{const i=e[t](...r);return this.exportValueToSandbox(i)}catch(e){throw this.createErrorForSandbox(e?.toString()??"")}}}}class SandboxSupport extends SandboxSupportBase{exportValueToSandbox(e){return JSON.stringify(e)}importValueFromSandbox(e){return e}createErrorForSandbox(e){return new Error(e)}}class Sandbox{constructor(e,t){this.support=new SandboxSupport(e,this);t.externalCall=this.support.createSandboxExternals();this._module=t;this._alertOnError=0}create(e){const t=['const e=Object.freeze({s:"solid",d:"dashed",b:"beveled",i:"inset",u:"underline"}),t=Object.freeze({visible:0,hidden:1,delay:2}),r=Object.freeze({visible:0,hidden:1,noPrint:2,noView:3}),i=Object.freeze({Times:"Times-Roman",TimesB:"Times-Bold",TimesI:"Times-Italic",TimesBI:"Times-BoldItalic",Helv:"Helvetica",HelvB:"Helvetica-Bold",HelvI:"Helvetica-Oblique",HelvBI:"Helvetica-BoldOblique",Cour:"Courier",CourB:"Courier-Bold",CourI:"Courier-Oblique",CourBI:"Courier-BoldOblique",Symbol:"Symbol",ZapfD:"ZapfDingbats",KaGo:"HeiseiKakuGo-W5-UniJIS-UCS2-H",KaMi:"HeiseiMin-W3-UniJIS-UCS2-H"}),s=Object.freeze({n:"none",i:"invert",p:"push",o:"outline"}),n=Object.freeze({textOnly:0,iconOnly:1,iconTextV:2,textIconV:3,iconTextH:4,textIconH:5,overlay:6}),o=Object.freeze({proportional:0,anamorphic:1}),a=Object.freeze({always:0,never:1,tooBig:2,tooSmall:3}),l=Object.freeze({ch:"check",cr:"cross",di:"diamond",ci:"circle",st:"star",sq:"square"}),u=Object.freeze({blindsH:"BlindsHorizontal",blindsV:"BlindsVertical",boxI:"BoxIn",boxO:"BoxOut",dissolve:"Dissolve",glitterD:"GlitterDown",glitterR:"GlitterRight",glitterRD:"GlitterRightDown",random:"Random",replace:"Replace",splitHI:"SplitHorizontalIn",splitHO:"SplitHorizontalOut",splitVI:"SplitVerticalIn",splitVO:"SplitVerticalOut",wipeD:"WipeDown",wipeL:"WipeLeft",wipeR:"WipeRight",wipeU:"WipeUp"}),c=Object.freeze({none:"NoVary",fitP:"FitPage",fitW:"FitWidth",fitH:"FitHeight",fitV:"FitVisibleWidth",pref:"Preferred",refW:"ReflowWidth"}),h=Object.freeze({IDS_GREATER_THAN:"Invalid value: must be greater than or equal to % s.",IDS_GT_AND_LT:"Invalid value: must be greater than or equal to % s and less than or equal to % s.",IDS_LESS_THAN:"Invalid value: must be less than or equal to % s.",IDS_INVALID_MONTH:"** Invalid **",IDS_INVALID_DATE:"Invalid date / time: please ensure that the date / time exists. Field",IDS_INVALID_DATE2:" should match format ",IDS_INVALID_VALUE:"The value entered does not match the format of the field",IDS_AM:"am",IDS_PM:"pm",IDS_MONTH_INFO:"January[1] February[2] March[3] April[4] May[5] June[6] July[7] August[8] September[9] October[10] November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] Dec[12]",IDS_STARTUP_CONSOLE_MSG:"** ^ _ ^ **",RE_NUMBER_ENTRY_DOT_SEP:["[+-]?\\\\d*\\\\.?\\\\d*"],RE_NUMBER_COMMIT_DOT_SEP:["[+-]?\\\\d+(\\\\.\\\\d+)?","[+-]?\\\\.\\\\d+","[+-]?\\\\d+\\\\."],RE_NUMBER_ENTRY_COMMA_SEP:["[+-]?\\\\d*,?\\\\d*"],RE_NUMBER_COMMIT_COMMA_SEP:["[+-]?\\\\d+([.,]\\\\d+)?","[+-]?[.,]\\\\d+","[+-]?\\\\d+[.,]"],RE_ZIP_ENTRY:["\\\\d{0,5}"],RE_ZIP_COMMIT:["\\\\d{5}"],RE_ZIP4_ENTRY:["\\\\d{0,5}(\\\\.|[- ])?\\\\d{0,4}"],RE_ZIP4_COMMIT:["\\\\d{5}(\\\\.|[- ])?\\\\d{4}"],RE_PHONE_ENTRY:["\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}","\\\\(\\\\d{0,3}","\\\\(\\\\d{0,3}\\\\)(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}","\\\\(\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}","\\\\d{0,3}\\\\)(\\\\.|[- ])?\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,4}","011(\\\\.|[- \\\\d])*"],RE_PHONE_COMMIT:["\\\\d{3}(\\\\.|[- ])?\\\\d{4}","\\\\d{3}(\\\\.|[- ])?\\\\d{3}(\\\\.|[- ])?\\\\d{4}","\\\\(\\\\d{3}\\\\)(\\\\.|[- ])?\\\\d{3}(\\\\.|[- ])?\\\\d{4}","011(\\\\.|[- \\\\d])*"],RE_SSN_ENTRY:["\\\\d{0,3}(\\\\.|[- ])?\\\\d{0,2}(\\\\.|[- ])?\\\\d{0,4}"],RE_SSN_COMMIT:["\\\\d{3}(\\\\.|[- ])?\\\\d{2}(\\\\.|[- ])?\\\\d{4}"]}),d=0,_=1,g=2,m=3,p=4;function createActionsMap(e){return new Map(e?Object.entries(e):null)}function MathClamp(e,t,r){return Math.min(Math.max(e,t),r)}function makeColorComp(e){return Math.floor(255*MathClamp(e,0,1)).toString(16).padStart(2,"0")}function scaleAndClamp(e){return 255*MathClamp(e,0,1)}class ColorConverters{static CMYK_G([e,t,r,i]){return["G",1-Math.min(1,.3*e+.59*r+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=scaleAndClamp(e),e,e]}static G_HTML([e]){const t=makeColorComp(e);return`#${t}${t}${t}`}static RGB_G([e,t,r]){return["G",.3*e+.59*t+.11*r]}static RGB_rgb(e){return e.map(scaleAndClamp)}static RGB_HTML(e){return`#${e.map(makeColorComp).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,r,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,r+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,r,i]){return[scaleAndClamp(1-Math.min(1,e+i)),scaleAndClamp(1-Math.min(1,r+i)),scaleAndClamp(1-Math.min(1,t+i))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,r]){const i=1-e,s=1-t,n=1-r;return["CMYK",i,s,n,Math.min(i,s,n)]}}const f=["m/d","m/d/yy","mm/dd/yy","mm/yy","d-mmm","d-mmm-yy","dd-mmm-yy","yy-mm-dd","mmm-yy","mmmm-yy","mmm d, yyyy","mmmm d, yyyy","m/d/yy h:MM tt","m/d/yy HH:MM"],b=["HH:MM","h:MM tt","HH:MM:ss","h:MM:ss tt"];class PDFObject{constructor(e){this._expandos=Object.create(null);this._send=e.send||null;this._id=e.id||null}}class Color extends PDFObject{transparent=["T"];black=["G",0];white=["G",1];red=["RGB",1,0,0];green=["RGB",0,1,0];blue=["RGB",0,0,1];cyan=["CMYK",1,0,0,0];magenta=["CMYK",0,1,0,0];yellow=["CMYK",0,0,1,0];dkGray=["G",.25];gray=["G",.5];ltGray=["G",.75];constructor(){super({})}static _isValidSpace(e){return"string"==typeof e&&("T"===e||"G"===e||"RGB"===e||"CMYK"===e)}static _isValidColor(e){if(!Array.isArray(e)||0===e.length)return!1;const t=e[0];if(!Color._isValidSpace(t))return!1;switch(t){case"T":if(1!==e.length)return!1;break;case"G":if(2!==e.length)return!1;break;case"RGB":if(4!==e.length)return!1;break;case"CMYK":if(5!==e.length)return!1;break;default:return!1}return e.slice(1).every(e=>"number"==typeof e&&e>=0&&e<=1)}static _getCorrectColor(e){return Color._isValidColor(e)?e:["G",0]}convert(e,t){return Color._isValidSpace(t)?"T"===t?["T"]:(e=Color._getCorrectColor(e))[0]===t?e:"T"===e[0]?this.convert(this.black,t):ColorConverters[`${e[0]}_${t}`](e.slice(1)):this.black}equal(e,t){e=Color._getCorrectColor(e);t=Color._getCorrectColor(t);if("T"===e[0]||"T"===t[0])return"T"===e[0]&&"T"===t[0];e[0]!==t[0]&&(t=this.convert(t,e[0]));return e.slice(1).every((e,r)=>e===t[r+1])}}function serializeError(e){return{command:"error",value:`${e.toString()}\\n${e.stack}`}}const makeArr=()=>[],makeMap=()=>new Map;"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(e){return e.reduce((e,t)=>e+t,0)});"function"!=typeof Map.prototype.getOrInsertComputed&&(Map.prototype.getOrInsertComputed=function(e,t){this.has(e)||this.set(e,t(e));return this.get(e)});class Field extends PDFObject{constructor(e){super(e);this.alignment=e.alignment||"left";this.borderStyle=e.borderStyle||"";this.buttonAlignX=e.buttonAlignX||50;this.buttonAlignY=e.buttonAlignY||50;this.buttonFitBounds=e.buttonFitBounds;this.buttonPosition=e.buttonPosition;this.buttonScaleHow=e.buttonScaleHow;this.ButtonScaleWhen=e.buttonScaleWhen;this.calcOrderIndex=e.calcOrderIndex;this.comb=e.comb;this.commitOnSelChange=e.commitOnSelChange;this.currentValueIndices=e.currentValueIndices;this.defaultStyle=e.defaultStyle;this.defaultValue=e.defaultValue;this.doNotScroll=e.doNotScroll;this.doNotSpellCheck=e.doNotSpellCheck;this.delay=e.delay;this.display=e.display;this.doc=e.doc.wrapped;this.editable=e.editable;this.exportValues=e.exportValues;this.fileSelect=e.fileSelect;this.hidden=e.hidden;this.highlight=e.highlight;this.lineWidth=e.lineWidth;this.multiline=e.multiline;this.multipleSelection=!!e.multipleSelection;this.name=e.name;this.password=e.password;this.print=e.print;this.radiosInUnison=e.radiosInUnison;this.readonly=e.readonly;this.rect=e.rect;this.required=e.required;this.richText=e.richText;this.richValue=e.richValue;this.style=e.style;this.submitName=e.submitName;this.textFont=e.textFont;this.textSize=e.textSize;this.type=e.type;this.userName=e.userName;this._actions=createActionsMap(e.actions);this._browseForFileToSubmit=e.browseForFileToSubmit||null;this._buttonCaption=null;this._buttonIcon=null;this._charLimit=e.charLimit;this._children=null;this._currentValueIndices=e.currentValueIndices||0;this._document=e.doc;this._fieldPath=e.fieldPath;this._fillColor=e.fillColor||["T"];this._isChoice=Array.isArray(e.items);this._items=e.items||[];this._hasValue=Object.hasOwn(e,"value");this._page=e.page||0;this._strokeColor=e.strokeColor||["G",0];this._textColor=e.textColor||["G",0];this._value=null;this._kidIds=e.kidIds||null;this._fieldType=function getFieldType(e){let t=e.get("Format");if(!t)return d;t=t[0];t=t.trim();return t.startsWith("AFNumber_")?_:t.startsWith("AFPercent_")?g:t.startsWith("AFDate_")?m:t.startsWith("AFTime_")?p:d}(this._actions);this._siblings=e.siblings||null;this._rotation=e.rotation||0;this._datetimeFormat=e.datetimeFormat||null;this._hasDateOrTime=!!e.hasDatetimeHTML;this._util=e.util;this._globalEval=e.globalEval;this._appObjects=e.appObjects;this.value=e.value||""}get currentValueIndices(){return this._isChoice?this._currentValueIndices:0}set currentValueIndices(e){if(this._isChoice){Array.isArray(e)||(e=[e]);if(e.every(e=>"number"==typeof e&&Number.isInteger(e)&&e>=0&&e<this.numItems)){e.sort();if(this.multipleSelection){this._currentValueIndices=e;this._value=[];e.forEach(e=>{this._value.push(this._items[e].displayValue)})}else if(e.length>0){e=e.splice(1,e.length-1);this._currentValueIndices=e[0];this._value=this._items[this._currentValueIndices]}this._send({id:this._id,indices:e})}}}get fillColor(){return this._fillColor}set fillColor(e){Color._isValidColor(e)&&(this._fillColor=e)}get bgColor(){return this.fillColor}set bgColor(e){this.fillColor=e}get charLimit(){return this._charLimit}set charLimit(e){if("number"!=typeof e)throw new Error("Invalid argument value");this._charLimit=Math.max(0,Math.floor(e))}get numItems(){if(!this._isChoice)throw new Error("Not a choice widget");return this._items.length}set numItems(e){throw new Error("field.numItems is read-only")}get strokeColor(){return this._strokeColor}set strokeColor(e){Color._isValidColor(e)&&(this._strokeColor=e)}get borderColor(){return this.strokeColor}set borderColor(e){this.strokeColor=e}get page(){return this._page}set page(e){throw new Error("field.page is read-only")}get rotation(){return this._rotation}set rotation(e){if((e=Math.floor(e))%90!=0)throw new Error("Invalid rotation: must be a multiple of 90");(e%=360)<0&&(e+=360);this._rotation=e}get textColor(){return this._textColor}set textColor(e){Color._isValidColor(e)&&(this._textColor=e)}get fgColor(){return this.textColor}set fgColor(e){this.textColor=e}get value(){return this._value}set value(e){if(this._isChoice){this._setChoiceValue(e);return}if(this._hasDateOrTime&&e){const t=this._util.scand(this._datetimeFormat,e);if(t){this._originalValue=t.valueOf();e=this._util.printd(this._datetimeFormat,t);this._value=isNaN(e)?e:parseFloat(e);return}}if(""===e||"string"!=typeof e||this._fieldType>=m){this._originalValue=void 0;this._value=e;return}this._originalValue=e;const t=e.trim().replace(",",".");this._value=isNaN(t)?e:parseFloat(t)}get _initialValue(){return this._hasDateOrTime&&this._originalValue||null}_getValue(){return this._originalValue??this.value}_setChoiceValue(e){if(this.multipleSelection){Array.isArray(e)||(e=[e]);const t=new Set(e);if(Array.isArray(this._currentValueIndices)){this._currentValueIndices.length=0;this._value.length=0}else{this._currentValueIndices=[];this._value=[]}this._items.forEach((e,r)=>{if(t.has(e.exportValue)){this._currentValueIndices.push(r);this._value.push(e.exportValue)}})}else{Array.isArray(e)&&(e=e[0]);const t=this._items.findIndex(({exportValue:t})=>e===t);if(-1!==t){this._currentValueIndices=t;this._value=this._items[t].exportValue}}}get valueAsString(){return(this._value??"").toString()}set valueAsString(e){}browseForFileToSubmit(){this._browseForFileToSubmit&&this._browseForFileToSubmit()}buttonGetCaption(e=0){return this._buttonCaption?this._buttonCaption[e]:""}buttonGetIcon(e=0){return this._buttonIcon?this._buttonIcon[e]:null}buttonImportIcon(e=null,t=0){}buttonSetCaption(e,t=0){this._buttonCaption||(this._buttonCaption=["","",""]);this._buttonCaption[t]=e}buttonSetIcon(e,t=0){this._buttonIcon||(this._buttonIcon=[null,null,null]);this._buttonIcon[t]=e}checkThisBox(e,t=!0){}clearItems(){if(!this._isChoice)throw new Error("Not a choice widget");this._items=[];this._send({id:this._id,clear:null})}deleteItemAt(e=null){if(!this._isChoice)throw new Error("Not a choice widget");if(this.numItems){if(null===e){e=Array.isArray(this._currentValueIndices)?this._currentValueIndices[0]:this._currentValueIndices;e||=0}(e<0||e>=this.numItems)&&(e=this.numItems-1);this._items.splice(e,1);if(Array.isArray(this._currentValueIndices)){let t=this._currentValueIndices.findIndex(t=>t>=e);if(-1!==t){this._currentValueIndices[t]===e&&this._currentValueIndices.splice(t,1);for(const e=this._currentValueIndices.length;t<e;t++)--this._currentValueIndices[t]}}else this._currentValueIndices===e?this._currentValueIndices=this.numItems>0?0:-1:this._currentValueIndices>e&&--this._currentValueIndices;this._send({id:this._id,remove:e})}}getItemAt(e=-1,t=!1){if(!this._isChoice)throw new Error("Not a choice widget");(e<0||e>=this.numItems)&&(e=this.numItems-1);const r=this._items[e];return t?r.exportValue:r.displayValue}getArray(){if(this._kidIds){const e=[],fillArrayWithKids=t=>{for(const r of t){const t=this._appObjects[r];if(t){t.obj._hasValue&&e.push(t.wrapped);t.obj._kidIds&&fillArrayWithKids(t.obj._kidIds)}}};fillArrayWithKids(this._kidIds);return e}return this._children??=this._document.obj._getTerminalChildren(this._fieldPath)}getLock(){}isBoxChecked(e){return!1}isDefaultChecked(e){return!1}insertItemAt(e,t=void 0,r=0){if(!this._isChoice)throw new Error("Not a choice widget");if(!e)return;(r<0||r>this.numItems)&&(r=this.numItems);if(this._items.some(({displayValue:t})=>t===e))return;void 0===t&&(t=e);const i={displayValue:e,exportValue:t};this._items.splice(r,0,i);if(Array.isArray(this._currentValueIndices)){let e=this._currentValueIndices.findIndex(e=>e>=r);if(-1!==e)for(const t=this._currentValueIndices.length;e<t;e++)++this._currentValueIndices[e]}else this._currentValueIndices>=r&&++this._currentValueIndices;this._send({id:this._id,insert:{index:r,...i}})}setAction(e,t){if("string"==typeof e&&"string"==typeof t){e in this._actions||(this._actions[e]=[]);this._actions[e].push(t)}}setFocus(){this._send({id:this._id,focus:!0})}setItems(e){if(!this._isChoice)throw new Error("Not a choice widget");this._items.length=0;for(const t of e){let e,r;if(Array.isArray(t)){e=t[0]?.toString()||"";r=t[1]?.toString()||""}else e=r=t?.toString()||"";this._items.push({displayValue:e,exportValue:r})}this._currentValueIndices=0;this._send({id:this._id,items:this._items})}setLock(){}signatureGetModifications(){}signatureGetSeedValue(){}signatureInfo(){}signatureSetSeedValue(){}signatureSign(){}signatureValidate(){}_isButton(){return!1}_reset(){this.value=this.defaultValue}_runActions(e){const t=e.name;if(!this._actions.has(t))return!1;const r=this._actions.get(t);for(const e of r)try{this._globalEval(e)}catch(e){const r=serializeError(e);r.value=`Error when executing "${t}" for field "${this._id}"\\n${r.value}`;this._send(r)}return!0}}class RadioButtonField extends Field{constructor(e,t){super(t);this.exportValues=[this.exportValues];this._radioIds=[this._id];this._radioActions=[this._actions];for(const t of e){this.exportValues.push(t.exportValues);this._radioIds.push(t.id);this._radioActions.push(createActionsMap(t.actions));this._value===t.exportValues&&(this._id=t.id)}this._hasBeenInitialized=!0;this._value=t.value||""}get _siblings(){return this._radioIds.filter(e=>e!==this._id)}set _siblings(e){}get value(){return this._value}set value(e){if(!this._hasBeenInitialized)return;null==e&&(this._value="");const t=this.exportValues.indexOf(e);if(0<=t&&t<this._radioIds.length){this._id=this._radioIds[t];this._value=e}else if("Off"===e&&2===this._radioIds.length){const e=(1+this._radioIds.indexOf(this._id))%2;this._id=this._radioIds[e];this._value=this.exportValues[e]}}checkThisBox(e,t=!0){if(!(e<0||e>=this._radioIds.length)&&t){this._id=this._radioIds[e];this._value=this.exportValues[e];this._send({id:this._id,value:this._value})}}isBoxChecked(e){return e>=0&&e<this._radioIds.length&&this._id===this._radioIds[e]}isDefaultChecked(e){return e>=0&&e<this.exportValues.length&&this.defaultValue===this.exportValues[e]}_getExportValue(e){const t=this._radioIds.indexOf(this._id);return this.exportValues[t]}_runActions(e){const t=this._radioIds.indexOf(this._id);this._actions=this._radioActions[t];return super._runActions(e)}_isButton(){return!0}}class CheckboxField extends RadioButtonField{get value(){return this._value}set value(e){e&&"Off"!==e?super.value=e:this._value="Off"}_getExportValue(e){return e?super._getExportValue(e):"Off"}isBoxChecked(e){return"Off"!==this._value&&super.isBoxChecked(e)}isDefaultChecked(e){return"Off"===this.defaultValue?"Off"===this._value:super.isDefaultChecked(e)}checkThisBox(e,t=!0){if(!(e<0||e>=this._radioIds.length)){this._id=this._radioIds[e];this._value=t?this.exportValues[e]:"Off";this._send({id:this._id,value:this._value})}}}class AForm{constructor(e,t,r,i){this._document=e;this._app=t;this._util=r;this._color=i;this._emailRegex=new RegExp("^[a-zA-Z0-9.!#$%&\'*+\\\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")}_mkTargetName(e){return e.target?`[ ${e.target.name} ]`:""}_parseDate(e,t){let r=null;try{r=this._util._scand(e,t,!1)}catch{}if(r)return r;r=Date.parse(t);return isNaN(r)?null:new Date(r)}AFMergeChange(e=globalThis.event){return e.willCommit?e.value.toString():this._app._eventDispatcher.mergeChange(e)}AFParseDateEx(e,t){return this._parseDate(t,e)}AFExtractNums(e){if("number"==typeof e)return[e];if(!e||"string"!=typeof e)return null;const t=e.charAt(0);"."!==t&&","!==t||(e=`0${e}`);const r=e.match(/(\\d+)/g);return 0===r.length?null:r}AFMakeNumber(e){if("number"==typeof e)return e;if("string"!=typeof e)return null;e=e.trim().replace(",",".");const t=parseFloat(e);return isNaN(t)||!isFinite(t)?null:t}AFMakeArrayFromList(e){return"string"==typeof e?e.split(/, ?/g):e}AFNumber_Format(e,t,r,i,s,n){const o=globalThis.event;let a=this.AFMakeNumber(o.value);if(null===a){o.value="";return}const l=Math.sign(a),u=[];let c=!1;-1===l&&n&&0===r&&u.push("-");if((2===r||3===r)&&-1===l){u.push("(");c=!0}n&&u.push(s);t=MathClamp(Math.floor(t),0,4);u.push("%,",t,".",e.toString(),"f");n||u.push(s);c&&u.push(")");1!==r&&3!==r||(o.target.textColor=1===l?this._color.black:this._color.red);0===r&&!n||-1!==l||(a=-a);const h=u.join("");o.value=this._util.printf(h,a)}AFNumber_Keystroke(e,t,r,i,s,n){const o=globalThis.event;let a,l=this.AFMergeChange(o);if(l){l=l.trim();a=t>1?o.willCommit?/^[+-]?(\\d+(,\\d*)?|,\\d+)$/:/^[+-]?\\d*,?\\d*$/:o.willCommit?/^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)$/:/^[+-]?\\d*\\.?\\d*$/;if(!a.test(l)){if(o.willCommit){const e=`${h.IDS_INVALID_VALUE} ${this._mkTargetName(o)}`;this._app.alert(e)}o.rc=!1}o.willCommit&&t>1&&(o.value=parseFloat(l.replace(",",".")))}}AFPercent_Format(e,t,r=!1){if("number"!=typeof e)return;if("number"!=typeof t)return;if(e<0)throw new Error("Invalid nDec value in AFPercent_Format");const i=globalThis.event;if(e>512){i.value="%";return}e=Math.floor(e);t=MathClamp(Math.floor(t),0,4);let s=this.AFMakeNumber(i.value);if(null===s){i.value="%";return}const n=`%,${t}.${e}f`;s=this._util.printf(n,100*s);i.value=r?`%${s}`:`${s}%`}AFPercent_Keystroke(e,t){this.AFNumber_Keystroke(e,t,0,0,"",!0)}AFDate_FormatEx(e){const t=globalThis.event,r=t.value;if(!r)return;const i=this._parseDate(e,r);null!==i&&(t.value=this._util.printd(e,i))}AFDate_Format(e){this.AFDate_FormatEx(f[e]??e)}AFDate_KeystrokeEx(e){const t=globalThis.event;if(!t.willCommit)return;const r=this.AFMergeChange(t);if(r&&null===this._parseDate(e,r)){const r=h.IDS_INVALID_DATE,i=h.IDS_INVALID_DATE2,s=`${r} ${this._mkTargetName(t)}${i}${e}`;this._app.alert(s);t.rc=!1}}AFDate_Keystroke(e){e>=0&&e<f.length&&this.AFDate_KeystrokeEx(f[e])}AFRange_Validate(e,t,r,i){const s=globalThis.event;if(!s.value)return;const n=this.AFMakeNumber(s.value);if(null===n)return;r=!!r;if((e=!!e)&&null===(t=this.AFMakeNumber(t)))return;if(r&&null===(i=this.AFMakeNumber(i)))return;let o="";e&&r?(n<t||n>i)&&(o=this._util.printf(h.IDS_GT_AND_LT,t,i)):e?n<t&&(o=this._util.printf(h.IDS_GREATER_THAN,t)):n>i&&(o=this._util.printf(h.IDS_LESS_THAN,i));if(o){this._app.alert(o);s.rc=!1}}AFSimple(e,t,r){const i=this.AFMakeNumber(t);if(null===i)throw new Error("Invalid nValue1 in AFSimple");const s=this.AFMakeNumber(r);if(null===s)throw new Error("Invalid nValue2 in AFSimple");switch(e){case"AVG":return(i+s)/2;case"SUM":return i+s;case"PRD":return i*s;case"MIN":return Math.min(i,s);case"MAX":return Math.max(i,s)}throw new Error("Invalid cFunction in AFSimple")}AFSimple_Calculate(e,t){const r={AVG:e=>Math.sumPrecise(e)/e.length,SUM:e=>Math.sumPrecise(e),PRD:e=>e.reduce((e,t)=>e*t,1),MIN:e=>Math.min(...e),MAX:e=>Math.max(...e)};if(!(e in r))throw new TypeError("Invalid function in AFSimple_Calculate");const i=globalThis.event,s=[];t=this.AFMakeArrayFromList(t);for(const e of t){const t=this._document.getField(e);if(t)for(const e of t.getArray()){const t=this.AFMakeNumber(e.value);s.push(t??0)}}if(0===s.length){i.value=0;return}const n=r[e](s);i.value=Math.round(1e6*n)/1e6}AFSpecial_Format(e){const t=globalThis.event;if(!t.value)return;let r;switch(e=this.AFMakeNumber(e)){case 0:r="99999";break;case 1:r="99999-9999";break;case 2:r=this._util.printx("9999999999",t.value).length>=10?"(999) 999-9999":"999-9999";break;case 3:r="999-99-9999";break;default:throw new Error("Invalid psf in AFSpecial_Format")}t.value=this._util.printx(r,t.value)}AFSpecial_KeystrokeEx(e){const t=globalThis.event,r=e.replaceAll(/[^9AOX]/g,"");this.#e(r,null,!1);if(!t.rc){t.rc=!0;this.#e(e,null,!0)}}#e(e,t,r){if(!e)return;const i=globalThis.event;t||=this.AFMergeChange(i);if(!t)return;const s=new Map([["9",e=>e>="0"&&e<="9"],["A",e=>"a"<=e&&e<="z"||"A"<=e&&e<="Z"],["O",e=>"a"<=e&&e<="z"||"A"<=e&&e<="Z"||"0"<=e&&e<="9"],["X",e=>!0]]);function _checkValidity(e,t){for(let r=0,i=e.length;r<i;r++){const i=t.charAt(r),n=e.charAt(r),o=s.get(i);if(o){if(!o(n))return!1}else if(i!==n)return!1}return!0}const n=`${h.IDS_INVALID_VALUE} = "${e}"`;if(t.length>e.length){r&&this._app.alert(n);i.rc=!1}else if(i.willCommit){if(t.length<e.length){r&&this._app.alert(n);i.rc=!1;return}if(!_checkValidity(t,e)){r&&this._app.alert(n);i.rc=!1;return}i.value+=e.substring(t.length)}else{t.length<e.length&&(e=e.substring(0,t.length));if(!_checkValidity(t,e)){r&&this._app.alert(n);i.rc=!1}}}AFSpecial_Keystroke(e){const t=globalThis.event;e=this.AFMakeNumber(e);let r,i,s=this.AFMergeChange(t);switch(e){case 0:r="99999";break;case 1:r="99999-9999";break;case 2:r="999-9999";i="(999) 999-9999";break;case 3:r="999-99-9999";break;default:throw new Error("Invalid psf in AFSpecial_Keystroke")}const n=i?[r,i]:[r];for(const e of n){this.#e(e,s,!1);if(t.rc)return;t.rc=!0}const o=/([-()]|\\s)+/g;s=s.replaceAll(o,"");for(const e of n){this.#e(e.replaceAll(o,""),s,!1);if(t.rc)return;t.rc=!0}this.AFSpecial_KeystrokeEx((i&&s.match(/\\d/g)||[]).length>7?i:r)}AFTime_FormatEx(e){this.AFDate_FormatEx(e)}AFTime_Format(e){this.AFDate_FormatEx(b[e]??e)}AFTime_KeystrokeEx(e){this.AFDate_KeystrokeEx(e)}AFTime_Keystroke(e){e>=0&&e<b.length&&this.AFDate_KeystrokeEx(b[e])}eMailValidate(e){return this._emailRegex.test(e)}AFExactMatch(e,t){return e instanceof RegExp?t.match(e)?.[0]===t||0:e.findIndex(e=>t.match(e)?.[0]===t)+1}}class Event{constructor(e){this.change=e.change||"";this.changeEx=e.changeEx||null;this.commitKey=e.commitKey||0;this.fieldFull=e.fieldFull||!1;this.keyDown=e.keyDown||!1;this.modifier=e.modifier||!1;this.name=e.name;this.rc=!0;this.richChange=e.richChange||[];this.richChangeEx=e.richChangeEx||[];this.richValue=e.richValue||[];this.selEnd=e.selEnd??-1;this.selStart=e.selStart??-1;this.shift=e.shift||!1;this.source=e.source||null;this.target=e.target||null;this.targetName="";this.type="Field";this.value=e.value||"";this.willCommit=e.willCommit||!1}}class EventDispatcher{constructor(e,t,r,i){this._document=e;this._calculationOrder=t;this._objects=r;this._externalCall=i;this._document.obj._eventDispatcher=this;this._isCalculating=!1}mergeChange(e){let t=e.value;if(Array.isArray(t))return t;"string"!=typeof t&&(t=t.toString());const r=e.selStart>=0?t.substring(0,e.selStart):"",i=e.selEnd>=0&&e.selEnd<=t.length?t.substring(e.selEnd):"";return`${r}${e.change}${i}`}userActivation(){this._document.obj._userActivation=!0;this._externalCall("setTimeout",[0,5e3])}dispatch(e){const t=e.id;if(!(t in this._objects)){let r;if("doc"===t||"page"===t){r=globalThis.event=new Event(e);r.source=r.target=this._document.wrapped;r.name=e.name}if("doc"===t){const e=r.name;if("Open"===e){this.userActivation();this._document.obj._initActions();this.formatAll()}["DidPrint","DidSave","WillPrint","WillSave"].includes(e)||this.userActivation();this._document.obj._dispatchDocEvent(r.name)}else if("page"===t){this.userActivation();this._document.obj._dispatchPageEvent(r.name,e.actions,e.pageNumber)}else if("app"===t&&"ResetForm"===e.name){this.userActivation();for(const t of e.ids){const e=this._objects[t];e?.obj._reset()}}return}const r=e.name,i=this._objects[t],s=globalThis.event=new Event(e);let n;this.userActivation();if(i.obj._isButton()){i.obj._id=t;s.value=i.obj._getExportValue(s.value);"Action"===r&&(i.obj._value=s.value)}switch(r){case"Keystroke":n={value:s.value,changeEx:s.changeEx,change:s.change,selStart:s.selStart,selEnd:s.selEnd};break;case"Blur":case"Focus":Object.defineProperty(s,"value",{configurable:!1,writable:!1,enumerable:!0,value:s.value});break;case"Validate":this.runValidation(i,s);return;case"Action":this.runActions(i,i,s,r);this.runCalculate(i,s);return}this.runActions(i,i,s,r);if("Keystroke"===r)if(s.rc)if(s.willCommit)this.runValidation(i,s);else{if(i.obj._isChoice){i.obj.value=n.changeEx;i.obj._send({id:i.obj._id,siblings:i.obj._siblings,value:i.obj.value});return}const e=i.obj.value=this.mergeChange(s);let t,r;if(s.selStart!==n.selStart||s.selEnd!==n.selEnd){t=s.selStart;r=s.selEnd}else r=t=n.selStart+s.change.length;i.obj._send({id:i.obj._id,siblings:i.obj._siblings,value:e,selRange:[t,r]})}else s.willCommit?i.obj._send({id:i.obj._id,siblings:i.obj._siblings,value:"",formattedValue:null,selRange:[0,0]}):i.obj._send({id:i.obj._id,siblings:i.obj._siblings,value:n.value,selRange:[n.selStart,n.selEnd]})}formatAll(){const e=globalThis.event=new Event({});for(const t of Object.values(this._objects)){e.value=t.obj._getValue();this.runActions(t,t,e,"Format")}}runValidation(e,t){const r=this.runActions(e,e,t,"Validate");if(t.rc){e.obj.value=t.value;this.runCalculate(e,t);const r=t.value=e.obj._getValue();let i=null;this.runActions(e,e,t,"Format")&&(i=t.value?.toString?.());e.obj._send({id:e.obj._id,siblings:e.obj._siblings,value:r,formattedValue:i});t.value=r}else r&&e.obj._send({id:e.obj._id,siblings:e.obj._siblings,value:"",formattedValue:null,selRange:[0,0],focus:!0})}runActions(e,t,r,i){r.source=e.wrapped;r.target=t.wrapped;r.name=i;r.targetName=t.obj.name;r.rc=!0;return t.obj._runActions(r)}calculateNow(){if(!this._calculationOrder||this._isCalculating||!this._document.obj.calculate)return;this._isCalculating=!0;const e=this._calculationOrder[0],t=this._objects[e];globalThis.event=new Event({});this.runCalculate(t,globalThis.event);this._isCalculating=!1}runCalculate(e,t){if(this._calculationOrder&&this._document.obj.calculate)for(const r of this._calculationOrder){if(!(r in this._objects))continue;if(!this._document.obj.calculate)break;t.value=null;const i=this._objects[r];let s=i.obj._getValue();this.runActions(e,i,t,"Calculate");if(!t.rc)continue;null!==t.value?i.obj.value=t.value:t.value=i.obj._getValue();this.runActions(i,i,t,"Validate");if(!t.rc){i.obj._getValue()!==s&&(i.wrapped.value=s);continue}null===t.value&&(t.value=i.obj._getValue());s=i.obj._getValue();let n=null;this.runActions(i,i,t,"Format")&&(n=t.value?.toString?.());i.obj._send({id:i.obj._id,siblings:i.obj._siblings,value:s,formattedValue:n})}}}class FullScreen extends PDFObject{_backgroundColor=[];_clickAdvances=!0;_cursor=t.hidden;_defaultTransition="";_escapeExits=!0;_isFullScreen=!0;_loop=!1;_timeDelay=3600;_usePageTiming=!1;_useTimer=!1;get backgroundColor(){return this._backgroundColor}set backgroundColor(e){}get clickAdvances(){return this._clickAdvances}set clickAdvances(e){}get cursor(){return this._cursor}set cursor(e){}get defaultTransition(){return this._defaultTransition}set defaultTransition(e){}get escapeExits(){return this._escapeExits}set escapeExits(e){}get isFullScreen(){return this._isFullScreen}set isFullScreen(e){}get loop(){return this._loop}set loop(e){}get timeDelay(){return this._timeDelay}set timeDelay(e){}get transitions(){return["Replace","WipeRight","WipeLeft","WipeDown","WipeUp","SplitHorizontalIn","SplitHorizontalOut","SplitVerticalIn","SplitVerticalOut","BlindsHorizontal","BlindsVertical","BoxIn","BoxOut","GlitterRight","GlitterDown","GlitterRightDown","Dissolve","Random"]}set transitions(e){throw new Error("fullscreen.transitions is read-only")}get usePageTiming(){return this._usePageTiming}set usePageTiming(e){}get useTimer(){return this._useTimer}set useTimer(e){}}class Thermometer extends PDFObject{_cancelled=!1;_duration=100;_text="";_value=0;get cancelled(){return this._cancelled}set cancelled(e){throw new Error("thermometer.cancelled is read-only")}get duration(){return this._duration}set duration(e){this._duration=e}get text(){return this._text}set text(e){this._text=e}get value(){return this._value}set value(e){this._value=e}begin(){}end(){}}class App extends PDFObject{constructor(e){super(e);this._constants=null;this._focusRect=!0;this._fs=null;this._language=App._getLanguage(e.language);this._openInPlace=!1;this._platform=App._getPlatform(e.platform);this._runtimeHighlight=!1;this._runtimeHighlightColor=["T"];this._thermometer=null;this._toolbar=!1;this._document=e._document;this._proxyHandler=e.proxyHandler;this._objects=Object.create(null);this._eventDispatcher=new EventDispatcher(this._document,e.calculationOrder,this._objects,e.externalCall);this._timeoutIds=new WeakMap;this._timeoutIdsRegistry=new FinalizationRegistry(this._cleanTimeout.bind(this));this._timeoutCallbackIds=new Map;this._timeoutCallbackId=1;this._globalEval=e.globalEval;this._externalCall=e.externalCall}_dispatchEvent(e){this._eventDispatcher.dispatch(e)}_registerTimeoutCallback(e){const t=this._timeoutCallbackId++;this._timeoutCallbackIds.set(t,e);return t}_unregisterTimeoutCallback(e){this._timeoutCallbackIds.delete(e)}_evalCallback({callbackId:e,interval:t}){const r=this._document.obj;if(0===e){r._userActivation=!1;return}const i=this._timeoutCallbackIds.get(e);t||this._unregisterTimeoutCallback(e);if(i){const e=r._userActivation;r._userActivation=!1;this._globalEval(i);r._userActivation=e}}_registerTimeout(e,t){const r=Object.create(null),i={callbackId:e,interval:t};this._timeoutIds.set(r,i);this._timeoutIdsRegistry.register(r,i);return r}_unregisterTimeout(e){this._timeoutIdsRegistry.unregister(e);const t=this._timeoutIds.get(e);if(t){this._timeoutIds.delete(e);this._cleanTimeout(t)}}_cleanTimeout({callbackId:e,interval:t}){this._unregisterTimeoutCallback(e);t?this._externalCall("clearInterval",[e]):this._externalCall("clearTimeout",[e])}static _getPlatform(e){if("string"==typeof e){if((e=e.toLowerCase()).includes("win"))return"WIN";if(e.includes("mac"))return"MAC"}return"UNIX"}static _getLanguage(e){const[t,r]=e.toLowerCase().split(/[-_]/,2);switch(t){case"zh":return"cn"===r||"sg"===r?"CHS":"CHT";case"da":return"DAN";case"de":return"DEU";case"es":return"ESP";case"fr":return"FRA";case"it":return"ITA";case"ko":return"KOR";case"ja":return"JPN";case"nl":return"NLD";case"no":return"NOR";case"pt":return"br"===r?"PTB":"ENU";case"fi":return"SUO";case"SV":return"SVE";default:return"ENU"}}get activeDocs(){return[this._document.wrapped]}set activeDocs(e){throw new Error("app.activeDocs is read-only")}get calculate(){return this._document.obj.calculate}set calculate(e){this._document.obj.calculate=e}get constants(){return this._constants??=Object.freeze({align:Object.freeze({left:0,center:1,right:2,top:3,bottom:4})})}set constants(e){throw new Error("app.constants is read-only")}get focusRect(){return this._focusRect}set focusRect(e){this._focusRect=e}get formsVersion(){return 21.00720099}set formsVersion(e){throw new Error("app.formsVersion is read-only")}get fromPDFConverters(){return[]}set fromPDFConverters(e){throw new Error("app.fromPDFConverters is read-only")}get fs(){return this._fs??=new Proxy(new FullScreen({send:this._send}),this._proxyHandler)}set fs(e){throw new Error("app.fs is read-only")}get language(){return this._language}set language(e){throw new Error("app.language is read-only")}get media(){}set media(e){throw new Error("app.media is read-only")}get monitors(){return[]}set monitors(e){throw new Error("app.monitors is read-only")}get numPlugins(){return 0}set numPlugins(e){throw new Error("app.numPlugins is read-only")}get openInPlace(){return this._openInPlace}set openInPlace(e){this._openInPlace=e}get platform(){return this._platform}set platform(e){throw new Error("app.platform is read-only")}get plugins(){return[]}set plugins(e){throw new Error("app.plugins is read-only")}get printColorProfiles(){return[]}set printColorProfiles(e){throw new Error("app.printColorProfiles is read-only")}get printerNames(){return[]}set printerNames(e){throw new Error("app.printerNames is read-only")}get runtimeHighlight(){return this._runtimeHighlight}set runtimeHighlight(e){this._runtimeHighlight=e}get runtimeHighlightColor(){return this._runtimeHighlightColor}set runtimeHighlightColor(e){Color._isValidColor(e)&&(this._runtimeHighlightColor=e)}get thermometer(){return this._thermometer??=new Proxy(new Thermometer({send:this._send}),this._proxyHandler)}set thermometer(e){throw new Error("app.thermometer is read-only")}get toolbar(){return this._toolbar}set toolbar(e){this._toolbar=e}get toolbarHorizontal(){return this.toolbar}set toolbarHorizontal(e){this.toolbar=e}get toolbarVertical(){return this.toolbar}set toolbarVertical(e){this.toolbar=e}get viewerType(){return"PDF.js"}set viewerType(e){throw new Error("app.viewerType is read-only")}get viewerVariation(){return"Full"}set viewerVariation(e){throw new Error("app.viewerVariation is read-only")}get viewerVersion(){return 21.00720099}set viewerVersion(e){throw new Error("app.viewerVersion is read-only")}addMenuItem(){}addSubMenu(){}addToolButton(){}alert(e,t=0,r=0,i="PDF.js",s=null,n=null){if(!this._document.obj._userActivation)return 0;this._document.obj._userActivation=!1;if(e&&"object"==typeof e){r=e.nType;e=e.cMsg}if(!(e=(e||"").toString()))return 0;if((r="number"!=typeof r||isNaN(r)||r<0||r>3?0:r)>=2)return this._externalCall("confirm",[e])?4:3;this._externalCall("alert",[e]);return 1}beep(){}beginPriv(){}browseForDoc(){}clearInterval(e){this._unregisterTimeout(e)}clearTimeOut(e){this._unregisterTimeout(e)}endPriv(){}execDialog(){}execMenuItem(e){if(this._document.obj._userActivation){this._document.obj._userActivation=!1;switch(e){case"SaveAs":if(this._document.obj._disableSaving)return;this._send({command:e});break;case"FirstPage":case"LastPage":case"NextPage":case"PrevPage":case"ZoomViewIn":case"ZoomViewOut":this._send({command:e});break;case"FitPage":this._send({command:"zoom",value:"page-fit"});break;case"Print":if(this._document.obj._disablePrinting)return;this._send({command:"print"})}}}getNthPlugInName(){}getPath(){}goBack(){}goForward(){}hideMenuItem(){}hideToolbarButton(){}launchURL(){}listMenuItems(){}listToolbarButtons(){}loadPolicyFile(){}mailGetAddrs(){}mailMsg(){}newDoc(){}newCollection(){}newFDF(){}openDoc(){}openFDF(){}popUpMenu(){}popUpMenuEx(){}removeToolButton(){}response(e,t="",r="",i="",s=""){if(!this._document.obj._userActivation)return null;this._document.obj._userActivation=!1;if(e&&"object"==typeof e){r=e.cDefault;e=e.cQuestion}e=(e||"").toString();r=(r||"").toString();return this._externalCall("prompt",[e,r||""])}setInterval(e,t=0){if(e&&"object"==typeof e){t=e.nMilliseconds||0;e=e.cExpr}if("string"!=typeof e)throw new TypeError("First argument of app.setInterval must be a string");if("number"!=typeof t)throw new TypeError("Second argument of app.setInterval must be a number");const r=this._registerTimeoutCallback(e);this._externalCall("setInterval",[r,t]);return this._registerTimeout(r,!0)}setTimeOut(e,t=0){if(e&&"object"==typeof e){t=e.nMilliseconds||0;e=e.cExpr}if("string"!=typeof e)throw new TypeError("First argument of app.setTimeOut must be a string");if("number"!=typeof t)throw new TypeError("Second argument of app.setTimeOut must be a number");const r=this._registerTimeoutCallback(e);this._externalCall("setTimeout",[r,t]);return this._registerTimeout(r,!1)}trustedFunction(){}trustPropagatorFunction(){}}class Console extends PDFObject{clear(){this._send({id:"clear"})}hide(){}println(e){if("string"!=typeof e)try{e=JSON.stringify(e)}catch{e=e.toString?.()||"[Unserializable object]"}this._send({command:"println",value:"PDF.js Console:: "+e})}show(){}}class PrintParams{binaryOk=!0;bitmapDPI=150;booklet={binding:0,duplexMode:0,subsetFrom:0,subsetTo:-1};colorOverride=0;colorProfile="";constants=Object.freeze({bookletBindings:Object.freeze({Left:0,Right:1,LeftTall:2,RightTall:3}),bookletDuplexMode:Object.freeze({BothSides:0,FrontSideOnly:1,BasicSideOnly:2}),colorOverrides:Object.freeze({auto:0,gray:1,mono:2}),fontPolicies:Object.freeze({everyPage:0,jobStart:1,pageRange:2}),handling:Object.freeze({none:0,fit:1,shrink:2,tileAll:3,tileLarge:4,nUp:5,booklet:6}),interactionLevel:Object.freeze({automatic:0,full:1,silent:2}),nUpPageOrders:Object.freeze({Horizontal:0,HorizontalReversed:1,Vertical:2}),printContents:Object.freeze({doc:0,docAndComments:1,formFieldsOnly:2}),flagValues:Object.freeze({applyOverPrint:1,applySoftProofSettings:2,applyWorkingColorSpaces:4,emitHalftones:8,emitPostScriptXObjects:16,emitFormsAsPSForms:32,maxJP2KRes:64,setPageSize:128,suppressBG:256,suppressCenter:512,suppressCJKFontSubst:1024,suppressCropClip:2,suppressRotate:4096,suppressTransfer:8192,suppressUCR:16384,useTrapAnnots:32768,usePrintersMarks:65536}),rasterFlagValues:Object.freeze({textToOutline:1,strokesToOutline:2,allowComplexClip:4,preserveOverprint:8}),subsets:Object.freeze({all:0,even:1,odd:2}),tileMarks:Object.freeze({none:0,west:1,east:2}),usages:Object.freeze({auto:0,use:1,noUse:2})});downloadFarEastFonts=!1;fileName="";firstPage=0;flags=0;fontPolicy=0;gradientDPI=150;interactive=1;npUpAutoRotate=!1;npUpNumPagesH=2;npUpNumPagesV=2;npUpPageBorder=!1;npUpPageOrder=0;pageHandling=0;pageSubset=0;printAsImage=!1;printContent=0;printerName="";psLevel=0;rasterFlags=0;reversePages=!1;tileLabel=!1;tileMark=0;tileOverlap=0;tileScale=1;transparencyLevel=75;usePrinterCRD=0;useT1Conversion=0;constructor(e){this.lastPage=e.lastPage}}class InfoProxyHandler{static get(e,t){return e[t.toLowerCase()]}static set(e,t,r){throw new Error(`doc.info.${t} is read-only`)}}class Doc extends PDFObject{#t=null;#r=null;constructor(e){super(e);this._expandos=globalThis;this._baseURL=e.baseURL||"";this._calculate=!0;this._delay=!1;this._dirty=!1;this._disclosed=!1;this._media=void 0;this._metadata=e.metadata||"";this._noautocomplete=void 0;this._nocache=void 0;this._spellDictionaryOrder=[];this._spellLanguageOrder=[];this._printParams=null;this._fields=new Map;this._fieldNames=[];this._event=null;this._author=e.Author||"";this._creator=e.Creator||"";this._creationDate=this._getDate(e.CreationDate)||null;this._docID=e.docID||["",""];this._documentFileName=e.filename||"";this._filesize=e.filesize||0;this._keywords=e.Keywords||"";this._layout=e.layout||"";this._modDate=this._getDate(e.ModDate)||null;this._numFields=0;this._numPages=e.numPages||1;this._pageNum=e.pageNum||0;this._producer=e.Producer||"";this._securityHandler=e.EncryptFilterName||null;this._subject=e.Subject||"";this._title=e.Title||"";this._URL=e.URL||"";this._info=new Proxy({title:this._title,author:this._author,authors:e.authors||[this._author],subject:this._subject,keywords:this._keywords,creator:this._creator,producer:this._producer,creationdate:this._creationDate,moddate:this._modDate,trapped:e.Trapped||"Unknown"},InfoProxyHandler);this._zoomType=c.none;this._zoom=e.zoom||100;this._actions=createActionsMap(e.actions);this._globalEval=e.globalEval;this._userActivation=!1;this._disablePrinting=!1;this._disableSaving=!1}_initActions(){for(const{obj:e}of this._fields.values()){const t=e._initialValue;t&&this._send({id:e._id,siblings:e._siblings,value:t,formattedValue:e.value.toString()})}const e=new Set(["WillClose","WillSave","DidSave","WillPrint","DidPrint","OpenAction"]);this._disableSaving=!0;for(const t of this._actions.keys())e.has(t)||this._runActions(t);this._runActions("OpenAction");this._disableSaving=!1}_dispatchDocEvent(e){switch(e){case"Open":this._disableSaving=!0;this._runActions("OpenAction");this._disableSaving=!1;break;case"WillPrint":this._disablePrinting=!0;try{this._runActions(e)}catch(e){this._send(serializeError(e))}this._send({command:"WillPrintFinished"});this._disablePrinting=!1;break;case"WillSave":this._disableSaving=!0;this._runActions(e);this._disableSaving=!1;break;default:this._runActions(e)}}_dispatchPageEvent(e,t,r){if("PageOpen"===e){this.#t??=new Map;this.#t.has(r)||this.#t.set(r,createActionsMap(t));this._pageNum=r-1}for(const i of[this.#t,this.#r]){t=i?.get(r)?.get(e);if(t)for(const e of t)this._globalEval(e)}}_runActions(e){const t=this._actions.get(e);if(t)for(const r of t)try{this._globalEval(r)}catch(t){const r=serializeError(t);r.value=`Error when executing "${e}" for document\\n${r.value}`;this._send(r)}}_addField(e,t){this._fields.set(e,t);this._fieldNames.push(e);this._numFields++;const r=t.obj._actions.get("PageOpen"),i=t.obj._actions.get("PageClose");if(r||i){this.#r??=new Map;const e=this.#r.getOrInsertComputed(t.obj._page+1,makeMap);r&&e.getOrInsertComputed("PageOpen",makeArr).push(...r);i&&e.getOrInsertComputed("PageClose",makeArr).push(...i)}}_getDate(e){if(!e||e.length<15||!e.startsWith("D:"))return e;const t=(e=e.substring(2)).substring(0,4),r=e.substring(4,6),i=e.substring(6,8),s=e.substring(8,10),n=e.substring(10,12),o=e.charAt(12);let a,l;if("Z"===o||"+"===o||"-"===o){a="00";l=12}else{a=e.substring(12,14);l=14}const u=e.substring(l).replaceAll("\'","");return new Date(`${t}-${r}-${i}T${s}:${n}:${a}${u}`)}get author(){return this._author}set author(e){throw new Error("doc.author is read-only")}get baseURL(){return this._baseURL}set baseURL(e){this._baseURL=e}get bookmarkRoot(){}set bookmarkRoot(e){throw new Error("doc.bookmarkRoot is read-only")}get calculate(){return this._calculate}set calculate(e){this._calculate=e}get creator(){return this._creator}set creator(e){throw new Error("doc.creator is read-only")}get dataObjects(){return[]}set dataObjects(e){throw new Error("doc.dataObjects is read-only")}get delay(){return this._delay}set delay(e){this._delay=e}get dirty(){return this._dirty}set dirty(e){this._dirty=e}get disclosed(){return this._disclosed}set disclosed(e){this._disclosed=e}get docID(){return this._docID}set docID(e){throw new Error("doc.docID is read-only")}get documentFileName(){return this._documentFileName}set documentFileName(e){throw new Error("doc.documentFileName is read-only")}get dynamicXFAForm(){return!1}set dynamicXFAForm(e){throw new Error("doc.dynamicXFAForm is read-only")}get external(){return false}set external(e){throw new Error("doc.external is read-only")}get filesize(){return this._filesize}set filesize(e){throw new Error("doc.filesize is read-only")}get hidden(){return!1}set hidden(e){throw new Error("doc.hidden is read-only")}get hostContainer(){}set hostContainer(e){throw new Error("doc.hostContainer is read-only")}get icons(){}set icons(e){throw new Error("doc.icons is read-only")}get info(){return this._info}set info(e){throw new Error("doc.info is read-only")}get innerAppWindowRect(){return[0,0,0,0]}set innerAppWindowRect(e){throw new Error("doc.innerAppWindowRect is read-only")}get innerDocWindowRect(){return[0,0,0,0]}set innerDocWindowRect(e){throw new Error("doc.innerDocWindowRect is read-only")}get isModal(){return!1}set isModal(e){throw new Error("doc.isModal is read-only")}get keywords(){return this._keywords}set keywords(e){throw new Error("doc.keywords is read-only")}get layout(){return this._layout}set layout(e){if(this._userActivation){this._userActivation=!1;if("string"==typeof e){"SinglePage"!==e&&"OneColumn"!==e&&"TwoColumnLeft"!==e&&"TwoPageLeft"!==e&&"TwoColumnRight"!==e&&"TwoPageRight"!==e&&(e="SinglePage");this._send({command:"layout",value:e});this._layout=e}}}get media(){return this._media}set media(e){this._media=e}get metadata(){return this._metadata}set metadata(e){this._metadata=e}get modDate(){return this._modDate}set modDate(e){throw new Error("doc.modDate is read-only")}get mouseX(){return 0}set mouseX(e){throw new Error("doc.mouseX is read-only")}get mouseY(){return 0}set mouseY(e){throw new Error("doc.mouseY is read-only")}get noautocomplete(){return this._noautocomplete}set noautocomplete(e){this._noautocomplete=e}get nocache(){return this._nocache}set nocache(e){this._nocache=e}get numFields(){return this._numFields}set numFields(e){throw new Error("doc.numFields is read-only")}get numPages(){return this._numPages}set numPages(e){throw new Error("doc.numPages is read-only")}get numTemplates(){return 0}set numTemplates(e){throw new Error("doc.numTemplates is read-only")}get outerAppWindowRect(){return[0,0,0,0]}set outerAppWindowRect(e){throw new Error("doc.outerAppWindowRect is read-only")}get outerDocWindowRect(){return[0,0,0,0]}set outerDocWindowRect(e){throw new Error("doc.outerDocWindowRect is read-only")}get pageNum(){return this._pageNum}set pageNum(e){if(this._userActivation){this._userActivation=!1;if(!("number"!=typeof e||e<0||e>=this._numPages)){this._send({command:"page-num",value:e});this._pageNum=e}}}get pageWindowRect(){return[0,0,0,0]}set pageWindowRect(e){throw new Error("doc.pageWindowRect is read-only")}get path(){return""}set path(e){throw new Error("doc.path is read-only")}get permStatusReady(){return!0}set permStatusReady(e){throw new Error("doc.permStatusReady is read-only")}get producer(){return this._producer}set producer(e){throw new Error("doc.producer is read-only")}get requiresFullSave(){return!1}set requiresFullSave(e){throw new Error("doc.requiresFullSave is read-only")}get securityHandler(){return this._securityHandler}set securityHandler(e){throw new Error("doc.securityHandler is read-only")}get selectedAnnots(){return[]}set selectedAnnots(e){throw new Error("doc.selectedAnnots is read-only")}get sounds(){return[]}set sounds(e){throw new Error("doc.sounds is read-only")}get spellDi